78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
<?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' => 'Meteorströme',
|
|
'geocron/index.php' => 'Geocron',
|
|
'geocron3d.php' => 'Geocron 3D',
|
|
'mondfinsternis.php' => 'Mondfinsternis',
|
|
'sonnenfinsternis.php' => 'Sonnenfinsternis',
|
|
'bedeckung.php' => 'Bedeckungsphänomene',
|
|
'sternbedeckungen.php' => 'Mond-Stern-Bedeckungen',
|
|
'monatsvorhersage.php' => 'Monatsvorhersage',
|
|
'wochenvorhersage.php' => 'Wochenvorhersage',
|
|
'satellitenhimmel.php' => 'Satellitenhimmel',
|
|
];
|
|
}
|