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