WebOrbiton
v1.0.0.9

Publisium

61 lines · 2.0 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. require_once __DIR__ . '/includes/config.php';
  6. require_once __DIR__ . '/includes/database.php';
  7. require_once __DIR__ . '/includes/user-auth.php';
  8. require_once __DIR__ . '/includes/language.php';
  9. require_once __DIR__ . '/includes/site-front.php';
  10. require_once __DIR__ . '/includes/block-editor.php';
  11. ​
  12. UserAuth::boot();
  13. ​
  14. $db = Database::site();
  15. $settings = SiteFront::settings();
  16. ​
  17. $slug = trim((string) ($_GET['slug'] ?? ''));
  18. ​
  19. $statement = $db->prepare("SELECT * FROM pages WHERE slug = :slug AND status = 'published' LIMIT 1");
  20. $statement->execute(['slug' => $slug]);
  21. $page = $statement->fetch();
  22. ​
  23. if (!$page) {
  24. http_response_code(404);
  25. $pageTitle = Language::get('not_found_title', 'Not found') . ' - ' . $settings['site_name'];
  26. $showBanner = false;
  27. require __DIR__ . '/includes/front-header.php';
  28. echo '<p>' . htmlspecialchars(Language::get('page_not_found', 'We couldn’t find this page. It may have been moved or deleted.')) . '</p>';
  29. require __DIR__ . '/includes/front-footer.php';
  30. exit;
  31. }
  32. ​
  33. if (!defined('PUBLISIUM_SHORT_LINK') && CleanUrls::slugFor('page', (string) $page['slug']) !== null) {
  34. CleanUrls::redirect(SiteFront::pageUrl((string) $page['slug']));
  35. }
  36. ​
  37. $page = Languages::pages([$page])[0];
  38. SiteFront::setAdContext('page', (int) $page['id']);
  39. ​
  40. if (str_contains((string) $page['content_blocks'], '"contact_form"')) {
  41. header('Cache-Control: private, no-store');
  42. }
  43. ​
  44. $pageTitle = $page['title'] . ' - ' . $settings['site_name'];
  45. $pageDescription = $settings['seo_description'];
  46. $showBanner = false;
  47. $pageType = 'pages';
  48. ​
  49. require __DIR__ . '/includes/front-header.php';
  50. ​
  51. ?>
  52. <article class="article-view">
  53. <h1 class="article-title"><?= htmlspecialchars($page['title']) ?></h1>
  54. <?= SiteFront::renderAds('page-top') ?>
  55. <div class="article-content">
  56. <?= BlockEditor::render($page['content_blocks']) ?>
  57. </div>
  58. <?= SiteFront::renderAds('page-bottom') ?>
  59. </article>
  60. ​
  61. <?php require __DIR__ . '/includes/front-footer.php'; ?>