home
/
aioutajg
/
playpauseonline.com
/
pages
/
Go to Home Directory
+
Upload
Create File
root@0UT1S:~$
Execute
By Order of Mr.0UT1S
[DIR] ..
N/A
404.php
1.89 KB
Rename
Delete
about.php
4.24 KB
Rename
Delete
blog.php
4.38 KB
Rename
Delete
contact.php
3.20 KB
Rename
Delete
error_log
1.73 KB
Rename
Delete
index.php
0 bytes
Rename
Delete
main.php
22.72 KB
Rename
Delete
post.php
6.99 KB
Rename
Delete
privacy.php
4.67 KB
Rename
Delete
search.php
8.40 KB
Rename
Delete
terms.php
3.69 KB
Rename
Delete
<?php // Updated post.php (pages/post.php) require_once __DIR__ . '/../admin/config.php'; // Use admin connection require_once __DIR__ . '/../includes/config.php'; $slug = $_GET['slug'] ?? ''; // Get post data using the existing $db connection $stmt = $db->prepare("SELECT * FROM posts WHERE slug = ? AND status = 'published'"); $stmt->bind_param('s', $slug); $stmt->execute(); $result = $stmt->get_result(); $post = $result->fetch_assoc(); // If reading time is missing (or 0), calculate it dynamically based on word count if (empty($post['reading_time'])) { $wordCount = str_word_count(strip_tags($post['content'])); // Count words, ignoring HTML tags $post['reading_time'] = ceil($wordCount / 200); // Calculate reading time (200 words per minute) } if (!$post) { http_response_code(404); include '../includes/header.php'; echo "<div class='container my-5'><div class='alert alert-danger'>Post not found</div></div>"; include '../includes/footer.php'; exit; } // Get related posts (same tags) $related_posts = []; if ($post['tags']) { $tags = array_map('trim', explode(',', $post['tags'])); $placeholders = implode(',', array_fill(0, count($tags), '?')); $stmt = $db->prepare(" SELECT id, title, slug, image, created_at FROM posts WHERE id != ? AND status = 'published' AND (tags LIKE ? " . str_repeat("OR tags LIKE ? ", count($tags)-1) . ") ORDER BY created_at DESC LIMIT 3 "); $params = array_merge([$post['id']], array_map(function($tag) { return '%' . $tag . '%'; }, $tags)); $types = str_repeat('s', count($params)); $stmt->bind_param($types, ...$params); $stmt->execute(); $related_posts = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); } $pageTitle = $post['title']; $pageDescription = $post['meta_description']; $pageCanonical = SITE_URL . "/pages/post?slug=" . $post['slug']; $pageKeywords = $post['tags']; include '../includes/header.php'; ?> <!-- Preload Fonts --> <link rel="preload" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" as="style"> <main class="container my-5"> <article class="post-article"> <!-- Post Header --> <header class="post-header mb-5"> <div class="breadcrumb mb-3"> <a href="<?= SITE_URL ?>">Home</a> » <a href="<?= SITE_URL ?>/pages/blog">Blog</a> » <span><?= htmlspecialchars($post['title']) ?></span> </div> <h1 class="display-4 mb-3"><?= htmlspecialchars($post['title']) ?></h1> <div class="post-meta d-flex flex-wrap gap-3 align-items-center mb-4"> <div class="d-flex align-items-center"> <i class="fas fa-calendar-alt me-2"></i> <time datetime="<?= date('Y-m-d', strtotime($post['created_at'])) ?>"> <?= date('F j, Y', strtotime($post['created_at'])) ?> </time> </div> <?php if (!empty($post['reading_time']) && $post['reading_time'] > 0): ?> <div class="d-flex align-items-center"> <i class="fas fa-clock me-2"></i> <?= $post['reading_time'] ?> min read </div> <?php endif; ?> </div> </header> <!-- Featured Image --> <?php if ($post['image']): ?> <figure class="post-featured-image mb-5"> <img src="<?= UPLOADS_URL . $post['image'] ?>" alt="<?= htmlspecialchars($post['title']) ?>" class="img-fluid rounded-3 w-100" loading="lazy" width="1200" height="630" style="object-fit: cover; max-height: 500px;"> <?php if (!empty($post['image_caption'])): ?> <figcaption class="figcaption mt-2"> <?= htmlspecialchars($post['image_caption']) ?> </figcaption> <?php endif; ?> </figure> <?php endif; ?> <!-- Post Content --> <div class="post-content content-format mb-5"> <?= htmlspecialchars_decode($post['content']) ?> </div> <!-- Tags --> <?php if ($post['tags']): ?> <div class="post-tags mb-5"> <h5 class="mb-3">Tags:</h5> <div class="d-flex gap-2 flex-wrap"> <?php foreach (explode(',', $post['tags']) as $tag): ?> <?php $cleanedTag = trim($tag); ?> <?php if (!empty($cleanedTag)): ?> <a href="<?= SITE_URL ?>/pages/blog?tag=<?= urlencode($cleanedTag) ?>" class="btn btn-sm btn-outline-primary"> <?= $cleanedTag ?> </a> <?php endif; ?> <?php endforeach; ?> </div> </div> <?php endif; ?> <!-- Related Posts --> <?php if (!empty($related_posts)): ?> <section class="related-posts mt-5 pt-5 border-top"> <h3 class="mb-4">You Might Also Like</h3> <div class="row g-4"> <?php foreach ($related_posts as $related): ?> <div class="col-md-4"> <div class="card h-100"> <?php if ($related['image']): ?> <a href="<?= SITE_URL ?>/pages/post?slug=<?= $related['slug'] ?>"> <img src="<?= UPLOADS_URL . $related['image'] ?>" class="card-img-top" alt="<?= htmlspecialchars($related['title']) ?>" loading="lazy" width="400" height="225" style="object-fit: cover; height: 225px;"> </a> <?php endif; ?> <div class="card-body"> <h5 class="card-title"> <a href="<?= SITE_URL ?>/pages/post?slug=<?= $related['slug'] ?>" class="text-decoration-none"> <?= htmlspecialchars($related['title']) ?> </a> </h5> <time class="small text-muted" datetime="<?= date('Y-m-d', strtotime($related['created_at'])) ?>"> <?= date('F j, Y', strtotime($related['created_at'])) ?> </time> </div> </div> </div> <?php endforeach; ?> </div> </section> <?php endif; ?> </article> </main> <script> </script> <?php include '../includes/footer.php'; ?>
Save