Bearsampp 2026.3.26
API documentation
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'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://api.github.com https://bearsampp.com;");
36
42
46$resourcesPath = rtrim( $bearsamppHomepage->getResourcesPath(), '/' ) . '/';
47
53
54// Instantiate the QuickPick class
56
57$ajaxUrl = $bearsamppCore->getAjaxPath() . '/ajax.getmodule_versions.php';
58
59
64
68$getLoader = '<span class = "loader float-end"><img src = "' . $imagesPath . 'loader.gif" alt="spinner"></span>';
69
74?>
75<!DOCTYPE html>
76<html lang = "<?php echo htmlspecialchars($bearsamppLang->getValue( Lang::LOCALE ), ENT_QUOTES, 'UTF-8') ?>">
77
78<head>
79 <meta charset = "utf-8">
80 <meta name = "viewport" content = "width=device-width, initial-scale=1.0">
81 <meta name = "description" content = "Localhost Dashboard">
82 <meta name = "author" content = "Bearsampp">
83 <?php echo Csrf::getTokenMeta(); ?>
84
85 <?php
90 "/css/app.css",
91 "/libs/bootstrap/css/bootstrap.min.css",
92 "/libs/fontawesome/css/all.min.css",
93 ];
95
96 "/libs/bootstrap/js/bootstrap.bundle.min.js",
97 "/libs/fontawesome/js/all.min.js",
98 "/js/csrf.js",
99 "/js/_commons.js",
100 "/js/latestversion.js",
101 "/js/summary.js",
102 "/js/apache.js",
103 '/js/mailpit.js',
104 "/js/mariadb.js",
105 "/js/memcached.js",
106 "/js/mysql.js",
107 "/js/nodejs.js",
108 "/js/php.js",
109 "/js/postgresql.js",
110 "/js/xlight.js",
111 "/js/quickpick.js",
112 "/js/loading-cursor.js"
113 ];
114
118 foreach ( $cssFiles as $file ) {
119 echo '<link href="' . $resourcesPath . $file . '" rel="stylesheet">' . PHP_EOL;
120 }
121 ?>
122
123 <link href = "<?php echo $iconsPath . 'favicon.ico'; ?>" rel = "icon" />
124 <title><?php echo APP_TITLE . ' ' . $bearsamppCore->getAppVersion(); ?></title>
125
126 <!-- Inline script to set loading cursor immediately -->
127 <script>
128 // Set loading cursor immediately
129 document.documentElement.classList.add('loading-cursor');
130
131 // Create and show loading overlay
132 window.addEventListener('DOMContentLoaded', function() {
133 // Remove loading cursor when page is fully loaded
134 window.addEventListener('load', function() {
135 document.documentElement.classList.remove('loading-cursor');
136
137 // If there's an overlay, remove it
138 const existingOverlay = document.querySelector('.loading-overlay');
139 if (existingOverlay) {
140 existingOverlay.parentNode.removeChild(existingOverlay);
141 }
142 });
143 });
144 </script>
145</head>
146
147<body>
148<nav class = "navbar navbar-expand-md navbar-light bg-dark fixed-top" role = "navigation">
149 <div class = "container-fluid d-flex justify-content-between align-items-center">
150 <div class = "d-inline-block">
151 <a class = "navbar-brand" href = "<?php echo Util::getWebsiteUrl(); ?>" aria-label = 'Home'>
152 <img class = "p-1" alt = "<?php echo APP_TITLE . ' ' . $bearsamppCore->getAppVersion(); ?>"
153 src = "<?php echo $imagesPath . 'header-logo.png'; ?>">
154 </a>
155 <button class = "navbar-toggler" type = "button" data-bs-toggle = "collapse" data-bs-target = "#navbarSupportedContent" aria-controls = "navbarSupportedContent"
156 aria-expanded = "false" aria-label = "Toggle navigation">
157 <span class = "navbar-toggler-icon"></span>
158 </button>
159 </div>
160
161 <div class = "d-flex align-items-center quickpick-menu-wrapper">
162 <div class = "collapse navbar-collapse icons" id = "navbarSupportedContent">
163 <div class = "d-flex flex-row flex-nowrap align-items-center mb-0 quickpick-menu">
164 <!-- Enhanced Mode Toggle and QuickPick Container -->
165 <div class = "quickpick-controls">
166 <!-- Enhanced Mode Toggle - inline with icons, FIRST -->
167 <?php
168 // Get enhanced mode setting
169 $enhancedMode = $bearsamppConfig->getEnhancedQuickPick();
170 ?>
171 <div class = "enhanced-mode-toggle">
172 <label class = "form-check-label me-2" for = "enhancedQuickPickSwitch">
173 Enhanced Mode
174 </label>
175 <div class = "form-check form-switch mb-0">
176 <input class = "form-check-input" type = "checkbox" role = "switch" id = "enhancedQuickPickSwitch"
177 <?php echo $enhancedMode == 1 ? 'checked' : ''; ?>
178 data-bs-toggle = "tooltip" data-bs-placement = "bottom"
179 title = "Toggle between enhanced (auto-config update) and standard QuickPick mode">
180 </div>
181 </div>
182 <?php
183 try {
184 echo $quickPick->loadQuickpick($imagesPath);
185 } catch (Exception $e) {
186 // Log the error but continue with the page
187 error_log('Error loading QuickPick: ' . $e->getMessage());
188 echo '<div id="quickPickError" class="text-center mt-3 pe-3">
189 <span>QuickPick unavailable</span>
190 </div>';
191 }
192 ?>
193 </div>
194 <!-- Social media icons wrapper -->
195 <div class = "social-icons-wrapper d-none d-lg-flex align-items-center">
196 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::DISCORD ); ?>" target = "_blank"
197 href = "https://discord.gg/UEczsEkG4A" aria-label = "Discord">
198 <i class = 'fa-brands fa-discord'></i>
199 </a>
200 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::FACEBOOK ); ?>" target = "_blank"
201 href = "https://www.facebook.com/groups/bearsampp" aria-label = "Facebook">
202 <i class = "fa-brands fa-facebook"></i>
203 </a>
204 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::GITHUB ); ?>" target = "_blank"
205 href = "<?php echo Util::getGithubUrl(); ?>" aria-label = "GitHub">
206 <i class = "fa-brands fa-github"></i>
207 </a>
208 <a data-bs-toggle = "tooltip" data-bs-placement = "top" data-bs-title = "<?php echo $bearsamppLang->getValue( Lang::DONATE ); ?>" target = "_blank"
209 href = "<?php echo Util::getWebsiteUrl( 'donate' ); ?>"><img class = "donate" src = "<?php echo $imagesPath . 'donate.png'; ?>" alt = 'Donation Icon' />
210 </a>
211 </div>
212 </div>
213 </div>
214 </div>
215</nav>
216
217<div id = "page-wrapper">
218 <?php
219 try {
220 include __DIR__ . '/tpls/hp.latestversion.html';
221 } catch (Exception $e) {
222 error_log('Error including latest version template: ' . $e->getMessage());
223 echo '<div class="alert alert-warning">Latest version information unavailable</div>';
224 }
225
226 try {
227 $page = preg_replace('/[^a-z0-9_-]/i', '', (string) $bearsamppHomepage->getPage());
228 $pagePath = __DIR__ . '/tpls/hp.' . $page . '.html';
229 if (is_file($pagePath)) {
230 include $pagePath;
231 } else {
232 include __DIR__ . '/tpls/hp.index.html';
233 }
234 } catch (Exception $e) {
235 error_log('Error including page template: ' . $e->getMessage());
236 echo '<div class="alert alert-warning">Page content unavailable</div>';
237 }
238 ?>
239</div>
240
241<?php
242foreach ( $jsFiles as $file ) {
243 echo '<script src="' . $resourcesPath . $file . '"></script>' . PHP_EOL;
244}
245?>
246</body>
247</html>
global $bearsamppLang
global $bearsamppRoot
global $bearsamppCore
catch(Exception $e)
global $downloadTitle
static getTokenMeta()
static init()
const DOWNLOAD_MORE
$quickPick
Definition homepage.php:55
$resourcesPath
Definition homepage.php:46
$pagePath
Definition homepage.php:228
global $bearsamppConfig
Definition homepage.php:41
global $bearsamppHomepage
Definition homepage.php:41
$iconsPath
Definition homepage.php:51
$jsFiles
Definition homepage.php:94
$cssFiles
Definition homepage.php:89
$getLoader
Definition homepage.php:68
$imagesPath
Definition homepage.php:52
$ajaxUrl
Definition homepage.php:57
const APP_TITLE
Definition root.php:13