Rectesystem eingebaut
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
function currentUserRole(): string
|
||||
{
|
||||
return trim((string) ($_SESSION['role'] ?? ''));
|
||||
}
|
||||
|
||||
function isMasterRole(?string $role): bool
|
||||
{
|
||||
return trim((string) $role) === 'master';
|
||||
}
|
||||
|
||||
function isAdminLikeRole(?string $role): bool
|
||||
{
|
||||
$normalizedRole = trim((string) $role);
|
||||
|
||||
return $normalizedRole === 'admin' || $normalizedRole === 'master';
|
||||
}
|
||||
|
||||
function currentUserIsAdminLike(): bool
|
||||
{
|
||||
return isAdminLikeRole(currentUserRole());
|
||||
}
|
||||
|
||||
function publicAccessAllowlist(): array
|
||||
{
|
||||
return [
|
||||
'login.php',
|
||||
'register.php',
|
||||
'logout.php',
|
||||
];
|
||||
}
|
||||
|
||||
function currentPublicPageKey(): string
|
||||
{
|
||||
$scriptName = str_replace('\\', '/', (string) ($_SERVER['SCRIPT_NAME'] ?? ''));
|
||||
$scriptName = ltrim($scriptName, '/');
|
||||
|
||||
if ($scriptName === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$publicMarker = 'public/';
|
||||
$publicPosition = strpos($scriptName, $publicMarker);
|
||||
if ($publicPosition !== false) {
|
||||
return substr($scriptName, $publicPosition + strlen($publicMarker));
|
||||
}
|
||||
|
||||
return $scriptName;
|
||||
}
|
||||
|
||||
function manageablePublicPages(): array
|
||||
{
|
||||
return [
|
||||
'index.php' => 'Startseite',
|
||||
'settings.php' => 'Einstellungen',
|
||||
'my_favorites.php' => 'Favoriten',
|
||||
'moonphase.php' => 'Mondphase',
|
||||
'planetensichtbarkeit.php' => 'Planetensichtbarkeit',
|
||||
'tcrb_lightcurve.php' => 'T CrB Lichtkurve',
|
||||
'solarsystem.php' => 'Sonnensystem',
|
||||
'jupitersystem.php' => 'Jupitersystem',
|
||||
'tagbogen.php' => 'Tagbogen',
|
||||
'sternenhimmel.php' => 'Sternenhimmel',
|
||||
'meteorshowers.php' => 'Meteorstroeme',
|
||||
'geocron/index.php' => 'Geocron',
|
||||
'geocron3d.php' => 'Geocron 3D',
|
||||
'mondfinsternis.php' => 'Mondfinsternis',
|
||||
'sonnenfinsternis.php' => 'Sonnenfinsternis',
|
||||
'bedeckung.php' => 'Bedeckungsphaenomene',
|
||||
'sternbedeckungen.php' => 'Mond-Stern-Bedeckungen',
|
||||
'monatsvorhersage.php' => 'Monatsvorhersage',
|
||||
'wochenvorhersage.php' => 'Wochenvorhersage',
|
||||
'satellitenhimmel.php' => 'Satellitenhimmel',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user