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']) . '
-Page not found (404).
- Back to home -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']) . '
+//Page not found (404).
+// Back to home +//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; +?> +