WebOrbiton
v1.0.0.1

StocketBase

58 lines · 1.8 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('page_title_not_found', 'Not found') . ' - ' . $settings['site_name'];
  26. require __DIR__ . '/includes/front-header.php';
  27. echo '<p>' . htmlspecialchars(Language::get('page_not_found', 'Page not found.')) . '</p>';
  28. require __DIR__ . '/includes/front-footer.php';
  29. exit;
  30. }
  31. ​
  32. if ((int) ($page['is_home'] ?? 0) === 1) {
  33. header('Location: index.php', true, 301);
  34. exit;
  35. }
  36. ​
  37. $page = Languages::pages([$page])[0];
  38. ​
  39. if (BlockEditor::containsBlock((string) $page['content_blocks'], 'contact_form')) {
  40. require_once __DIR__ . '/includes/contact-form.php';
  41. ContactForm::handleRequest((string) $page['title']);
  42. }
  43. ​
  44. $pageTitle = $page['title'] . ' - ' . $settings['site_name'];
  45. $pageDescription = $settings['seo_description'];
  46. $pageType = 'pages';
  47. ​
  48. require __DIR__ . '/includes/front-header.php';
  49. ​
  50. ?>
  51. <article class="article-view">
  52. <h1 class="article-title"><?= htmlspecialchars($page['title']) ?></h1>
  53. <div class="article-content">
  54. <?= BlockEditor::render($page['content_blocks']) ?>
  55. </div>
  56. </article>
  57. ​
  58. <?php require __DIR__ . '/includes/front-footer.php'; ?>