From ff87ffd71377973b55db54b1d81795bf0a2695e3 Mon Sep 17 00:00:00 2001 From: dev2 Date: Mon, 16 Dec 2024 08:49:59 +0000 Subject: [PATCH] s1 --- .hta_404.php | 123 ++++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/.hta_404.php b/.hta_404.php index 7f7465c..9080657 100644 --- a/.hta_404.php +++ b/.hta_404.php @@ -1,76 +1,77 @@ prepare("SELECT * FROM `scc24` WHERE `slug` = :slug"); +// $stmt->bindParam(':slug', $slug, PDO::PARAM_STR); +// $stmt->execute(); +// return $stmt->fetch(PDO::FETCH_ASSOC); +// } -function fetchFromDatabase($slug, $pdo) { - $stmt = $pdo->prepare("SELECT * FROM `scc24` WHERE `slug` = :slug"); - $stmt->bindParam(':slug', $slug, PDO::PARAM_STR); - $stmt->execute(); - return $stmt->fetch(PDO::FETCH_ASSOC); -} +// function saveToCache($filePath, $content) { +// if (!file_put_contents($filePath, $content)) { +// error_log("Failed to write cache file: $filePath"); +// } +// } -function saveToCache($filePath, $content) { - if (!file_put_contents($filePath, $content)) { - error_log("Failed to write cache file: $filePath"); - } -} -$requestUri = $_SERVER['REQUEST_URI']; -$slug = getSlug($requestUri); -if (empty($slug)) { - // echo "Slug not provided!"; - // exit; -} +// if (empty($slug)) { +// // echo "Slug not provided!"; +// // exit; +// } -$fileName = $slug . ".html"; -$filePath = __DIR__ . '/notice/' . $fileName; +// $fileName = $slug . ".html"; +// $filePath = __DIR__ . '/notice/' . $fileName; -ob_start(); +// ob_start(); -$shouldCache = false; // Flag to determine if content should be cached. +// $shouldCache = false; // Flag to determine if content should be cached. -if (!serveStaticFile($filePath)) { - try { - $pdo = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $content = fetchFromDatabase($slug, $pdo); - if ($content && isset($content['content']) && $content['content']) { - echo '
-
-

' . htmlspecialchars($content['title']) . '

-
-
' . $content['content'] . '
-
'; - $shouldCache = true; // Mark content as cacheable. - } else { - echo '

Page not found (404).

- Back to home -
'; - } - } catch (PDOException $e) { - echo "

Error: " . htmlspecialchars($e->getMessage()) . "

"; - } -} +// if (!serveStaticFile($filePath)) { +// try { +// $pdo = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); +// $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +// $content = fetchFromDatabase($slug, $pdo); +// if ($content && isset($content['content']) && $content['content']) { +// echo '
+//
+//

' . htmlspecialchars($content['title']) . '

+//
+//
' . $content['content'] . '
+//
'; +// $shouldCache = true; // Mark content as cacheable. +// } else { +// echo '

Page not found (404).

+// Back to home +//
'; +// } +// } catch (PDOException $e) { +// echo "

Error: " . htmlspecialchars($e->getMessage()) . "

"; +// } +// } -$htmlContent = ob_get_clean(); +// $htmlContent = ob_get_clean(); -// Save to cache only if content was found. -if ($shouldCache) { - saveToCache($filePath, $htmlContent); -} +// // Save to cache only if content was found. +// if ($shouldCache) { +// saveToCache($filePath, $htmlContent); +// } -echo $htmlContent; -?> \ No newline at end of file +// echo $htmlContent; +?> +

404 New

\ No newline at end of file