Bearsampp 2026.7.11
Loading...
Searching...
No Matches
homepage.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2022-2025 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
16
20require_once __DIR__ . '/../../root.php';
21require_once __DIR__ . '/../../classes/actions/class.action.quickPick.php';
22
27
31header('X-Frame-Options: SAMEORIGIN');
32header('X-Content-Type-Options: nosniff');
33header('X-XSS-Protection: 1; mode=block');
34header('Referrer-Policy: strict-origin-when-cross-origin');
35header("Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://api.github.com https://bearsampp.com https://* http://*; img-src 'self' data: https:; font-src 'self' data:;");
36
42
47
51$iconsPath = $resourcesPath . '/img/icons/';
53
54// Instantiate the QuickPick class
56
61
65$getLoader = '<span class = "loader float-end"><img src = "' . $imagesPath . 'loader.gif" alt="spinner"></span>';
66
71?>
72<!DOCTYPE html>
73<html lang = "<?php echo htmlspecialchars($bearsamppLang->getValue( Lang::LOCALE ), ENT_QUOTES, 'UTF-8') ?>">
74
75<head>
76 <meta charset = "utf-8">
77 <meta name = "viewport" content = "width=device-width, initial-scale=1.0">
78 <meta name = "description" content = "Localhost Dashboard">
79 <meta name = "author" content = "Bearsampp">
80 <?php echo Csrf::getTokenMeta(); ?>
81
82 <?php
87 "/css/app.css",
88 "/libs/bootstrap/css/bootstrap.min.css",
89 "/libs/fontawesome/css/all.min.css",
90 ];
92
93 "/libs/bootstrap/js/bootstrap.bundle.min.js",
94 "/libs/fontawesome/js/all.min.js",
95 "/js/csrf.js",
96 "/js/_commons.js",
97 "/js/latestversion.js",
98 "/js/summary.js",
99 "/js/apache.js",
100 '/js/mailpit.js',
101 "/js/mariadb.js",
102 "/js/memcached.js",
103 "/js/mysql.js",
104 "/js/nodejs.js",
105 "/js/php.js",
106 "/js/postgresql.js",
107 "/js/xlight.js",
108 "/js/quickpick.js",
109 "/js/loading-cursor.js"
110 ];
111
115 foreach ( $cssFiles as $file ) {
116 echo '<link href="' . $resourcesPath . '/' . ltrim($file, '/') . '" rel="stylesheet">' . PHP_EOL;
117 }
118 ?>
119
120 <link href = "<?php echo $iconsPath . 'favicon.ico'; ?>" rel = "icon" />
121 <title><?php echo APP_TITLE . ' ' . $bearsamppCore->getAppVersion(); ?></title>
122
123 <script>
124 var AJAX_URL = "<?php echo Path::getWebResourcesUrl(); ?>/ajax.php";
125
126 // Protocol-relative URL handling for HTTPS and custom vhosts
127 if (AJAX_URL.startsWith('http://localhost') || AJAX_URL.startsWith('https://localhost')) {
128 var pathParts = AJAX_URL.split('/');
129 var ajaxIndex = pathParts.findIndex(function(p) { return p.endsWith('.php'); });
130 if (ajaxIndex > 0) {
131 AJAX_URL = "/" + pathParts.slice(ajaxIndex - 1).join("/");
132 }
133 }
134 </script>
135
136 <!-- Inline script to set loading cursor immediately -->
137 <script>
138 // Set loading cursor immediately
139 document.documentElement.classList.add('loading-cursor');
140
141 // Create and show loading overlay
142 window.addEventListener('DOMContentLoaded', function() {
143 // Remove loading cursor when page is fully loaded
144 window.addEventListener('load', function() {
145 document.documentElement.classList.remove('loading-cursor');
146
147 // If there's an overlay, remove it
148 const existingOverlay = document.querySelector('.loading-overlay');
149 if (existingOverlay) {
150 existingOverlay.parentNode.removeChild(existingOverlay);
151 }
152 });
153 });
154 </script>
155</head>
156
157<body>
158<nav class = "navbar navbar-expand-md navbar-light bg-dark fixed-top" role = "navigation">
159 <div class = "container-fluid d-flex justify-content-between align-items-center">
160 <div class = "d-inline-block">
161 <a class = "navbar-brand" href = "<?php echo HttpClient::getWebsiteUrl(); ?>" aria-label = 'Home'>
162 <img class = "p-1" alt = "<?php echo APP_TITLE . ' ' . $bearsamppCore->getAppVersion(); ?>"
163 src = "<?php echo $imagesPath . 'header-logo.png'; ?>">
164 </a>
165 <button class = "navbar-toggler" type = "button" data-bs-toggle = "collapse" data-bs-target = "#navbarSupportedContent" aria-controls = "navbarSupportedContent"
166 aria-expanded = "false" aria-label = "Toggle navigation">
167 <span class = "navbar-toggler-icon"></span>
168 </button>
169 </div>
170
171 <div class = "d-flex align-items-center quickpick-menu-wrapper">
172 <div class = "collapse navbar-collapse icons" id = "navbarSupportedContent">
173 <div class = "d-flex flex-row flex-nowrap align-items-center mb-0 quickpick-menu">
174 <!-- Enhanced Mode Toggle and QuickPick Container -->
175 <div class = "quickpick-controls">
176 <?php
177 try {
178 echo $quickPick->loadQuickpick($imagesPath);
179 } catch (Exception $e) {
180 // Log the error but continue with the page
181 error_log('Error loading QuickPick: ' . $e->getMessage());
182 echo '<div id="quickPickError" class="text-center">
183 <span>QuickPick unavailable</span>
184 </div>';
185 }
186 ?>
187 </div>
188 <!-- Social media icons wrapper -->
189 <div class = "social-icons-wrapper d-none d-lg-flex align-items-center">
190 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::DISCORD ); ?>" target = "_blank"
191 href = "https://discord.gg/UEczsEkG4A" aria-label = "Discord">
192 <i class = 'fa-brands fa-discord'></i>
193 </a>
194 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::FACEBOOK ); ?>" target = "_blank"
195 href = "https://www.facebook.com/groups/bearsampp" aria-label = "Facebook">
196 <i class = "fa-brands fa-facebook"></i>
197 </a>
198 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::GITHUB ); ?>" target = "_blank"
199 href = "<?php echo HttpClient::getGithubUrl(); ?>" aria-label = "GitHub">
200 <i class = "fa-brands fa-github"></i>
201 </a>
202 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::DONATE ); ?>" target = "_blank"
203 href = "<?php echo HttpClient::getWebsiteUrl( 'donate' ); ?>"><img class = "donate" src = "<?php echo $imagesPath . 'donate.png'; ?>" alt = 'Donation Icon' />
204 </a>
205 </div>
206 </div>
207 </div>
208 </div>
209 </div>
210</nav>
211
212<div id = "page-wrapper">
213 <?php
214 try {
215 include __DIR__ . '/tpls/hp.latestversion.html';
216 } catch (Exception $e) {
217 error_log('Error including latest version template: ' . $e->getMessage());
218 echo '<div class="alert alert-warning">Latest version information unavailable</div>';
219 }
220
221 try {
222 $page = preg_replace('/[^a-z0-9_-]/i', '', (string) $bearsamppHomepage->getPage());
223 $pagePath = __DIR__ . '/tpls/hp.' . $page . '.html';
224 if (is_file($pagePath)) {
225 include $pagePath;
226 } else {
227 include __DIR__ . '/tpls/hp.index.html';
228 }
229 } catch (Exception $e) {
230 error_log('Error including page template: ' . $e->getMessage());
231 echo '<div class="alert alert-warning">Page content unavailable</div>';
232 }
233 ?>
234</div>
235
236<?php
237foreach ( $jsFiles as $file ) {
238 echo '<script src="' . $resourcesPath . '/' . ltrim($file, '/') . '"></script>' . PHP_EOL;
239}
240?>
241</body>
242</html>
global $bearsamppLang
global $bearsamppRoot
global $bearsamppCore
catch(Exception $e)
global $downloadTitle
static getTokenMeta()
static init()
const DOWNLOAD_MORE
static getWebResourcesPath()
$quickPick
Definition homepage.php:55
$resourcesPath
Definition homepage.php:46
$pagePath
Definition homepage.php:223
global $bearsamppConfig
Definition homepage.php:41
global $bearsamppHomepage
Definition homepage.php:41
$iconsPath
Definition homepage.php:51
$jsFiles
Definition homepage.php:91
$cssFiles
Definition homepage.php:86
$getLoader
Definition homepage.php:65
$imagesPath
Definition homepage.php:52
const APP_TITLE
Definition root.php:13