index.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. // loads the config
  3. $config = include(__DIR__ . '/../../config.php');
  4. // go set your id here otehrwise ur site wont load the stuff it needs
  5. $siteId = 2;
  6. // website go search what stuffs it need to load
  7. $websiteConfig = array_filter($config, function($site) use ($siteId) {
  8. return isset($site['id']) && $site['id'] === $siteId;
  9. });
  10. $websiteConfig = reset($websiteConfig);
  11. // include the components so the site actually gets rendered
  12. foreach ($websiteConfig['components'] as $component) {
  13. include($component);
  14. }
  15. ?>
  16. <!DOCTYPE html>
  17. <html lang="en">
  18. <head>
  19. <meta charset="UTF-8">
  20. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  21. <title>Teleco.ch - <?php echo ucfirst($page); ?></title>
  22. <meta name="description" content="<?php echo $metaDescription; ?>">
  23. <link rel="stylesheet" href="assets/css/tc.css">
  24. </head>
  25. <body>
  26. <header>
  27. <div class="header-content" <?php if ($navbarTableExists && $navbarHasEntries) echo 'style="display:none;"'; ?>>
  28. <img src="assets/svg/teleco.svg" alt="Teleco Logo" class="logo">
  29. <h1>Teleco.ch</h1>
  30. </div>
  31. </header>
  32. <?php if ($navbarTableExists && $navbarHasEntries): ?>
  33. <nav class="navbar">
  34. <?php render_navbar($navbarItems, $page); ?>
  35. </nav>
  36. <?php render_mobile_navbar($navbarItems, $menuExpanded); ?>
  37. <?php endif; ?>
  38. <hr>
  39. <div class="container" style="<?php echo $leftSidebarHasItems || $rightSidebarHasItems ? '' : 'margin-left: 0px; margin-right: 0px; flex-wrap: nowrap; margin-top: 0px; margin-bottom: 0px; max-width: 100%; box-sizing: border-box; padding: 10px;'; ?>">
  40. <!-- Left Sidebar -->
  41. <?php if ($leftSidebarHasItems): ?>
  42. <div class="sidebar">
  43. <?php get_sidebar($db, 'left', $page, $sub); ?>
  44. </div>
  45. <?php endif; ?>
  46. <!-- Main Content -->
  47. <div class="content" id="content" style="<?php echo $leftSidebarHasItems || $rightSidebarHasItems ? '' : 'width: calc(100%);'; ?>">
  48. <!-- Comment indicating if left elements were detected -->
  49. <!-- Breadcrumbs -->
  50. <div class="breadcrumbs">
  51. <?php
  52. foreach ($breadcrumbs as $index => $crumb) {
  53. if ($index > 0) echo ' > ';
  54. echo '<a href="?page=' . htmlspecialchars($crumb['page']) . '">';
  55. echo htmlspecialchars($crumb['title']);
  56. echo '</a>';
  57. }
  58. ?>
  59. </div>
  60. <?php if ($leftSidebarHasItems): ?>
  61. <!-- Left sidebar elements detected -->
  62. <?php else: ?>
  63. <!-- No left sidebar elements detected -->
  64. <?php endif; ?>
  65. <?php if ($hasContent): ?>
  66. <?php
  67. $result = $query->execute();
  68. $lastPostId = 0;
  69. while ($row = $result->fetchArray()):
  70. $lastPostId++;
  71. ?>
  72. <div class="box" id="post-<?php echo $lastPostId; ?>">
  73. <h3><?php echo htmlspecialchars($row['title']); ?></h3>
  74. <p><?php echo $row['content']; ?></p> <!-- Always render content as HTML -->
  75. <hr>
  76. <p>Date: <?php echo $row['date']; ?></p>
  77. </div>
  78. <?php endwhile; ?>
  79. <?php else: ?>
  80. <div class="box">
  81. <h3>404 - Page Not Found</h3>
  82. <p>Sorry, the page you are looking for does not exist.</p>
  83. </div>
  84. <?php endif; ?>
  85. <div id="load-container">
  86. <?php if ($hasContent && $offset + $limit < $totalPosts): ?>
  87. <form method="get" action="index.php#post-<?php echo $lastPostId; ?>">
  88. <input type="hidden" name="page" value="<?php echo htmlspecialchars($page); ?>">
  89. <?php if ($sub): ?>
  90. <input type="hidden" name="sub" value="<?php echo htmlspecialchars($sub); ?>">
  91. <?php endif; ?>
  92. <input type="hidden" name="offset" value="<?php echo $offset + $limit; ?>">
  93. <button type="submit">Load More (<?php echo min($offset + $limit, $totalPosts) . " out of " . $totalPosts; ?>)</button>
  94. </form>
  95. <?php endif; ?>
  96. </div>
  97. </div>
  98. <!-- Right Sidebar -->
  99. <?php if ($rightSidebarHasItems): ?>
  100. <div class="sidebar-right">
  101. <?php get_sidebar($db, 'right', $page, $sub); ?>
  102. </div>
  103. <?php endif; ?>
  104. </div>
  105. <footer>
  106. &copy; 2025 Teleco.ch. All Rights Reserved.
  107. </footer>
  108. </body>
  109. </html>