diff --git a/.hta_404.php b/.hta_404.php index 208fb9d..383ad9c 100644 --- a/.hta_404.php +++ b/.hta_404.php @@ -1,41 +1,61 @@ Page saved successfully at $filePath.
"; + } else { + // echo "Failed to save the page.
"; + } + } + try { $conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $stmt = $conn->prepare("SELECT * FROM `scc24` WHERE `slug` = '".$querySlug."'"); + $stmt = $conn->prepare("SELECT * FROM `scc24` WHERE type='page' AND `slug` = :querySlug"); + $stmt->bindParam(':querySlug', $querySlug, PDO::PARAM_STR); $stmt->execute(); $content = $stmt->fetchAll(PDO::FETCH_ASSOC); - if(isset($content[0]['content']) && $content[0]['content']) - $pageContent = ''.$content[0]['title'].'
Page not found (404).
+ + if (isset($content[0]['content']) && $content[0]['content']) { + $pageContent = ' +' . htmlspecialchars($content[0]['title']) . '
+Page not found (404).
Back to home -Error: " . $e->getMessage() . "
"; + $pageContent = "Error: " . $e->getMessage() . "
"; } // Render page content here @@ -43,22 +63,6 @@ $footerContent = file_get_contents('./.hta_footer.php'); - // if($fileExtension[1] && $fileExtension[1] === 'html'){ - // $filePath = __DIR__ . '/notice/' . $fileName; - // } else{ - // $filePath = __DIR__ . '/notice/' . $fileName . '.html'; - // } + // Function to save HTML file - - if($urlParts[1] === 'notice'){ - $filePath = __DIR__ . '/notice/' . $fileName; - $totalPageContent = $headerContent . $pageContent . $footerContent; - } else{ - $filePath = __DIR__ . '/.hta_slug/' . $fileName; - $totalPageContent = $headerContent . $pageContent . $footerContent; - } - - - file_put_contents($filePath, $totalPageContent); - -?> \ No newline at end of file +?> diff --git a/.hta_footer.php b/.hta_footer.php index 8e8327a..2cbdc47 100644 --- a/.hta_footer.php +++ b/.hta_footer.php @@ -1,5 +1,5 @@