Help for module \"$moduleTitle\"";
if (isset($helpConfig['description'])) {
echo "
" . $helpConfig['description'] . "
";
}
echo " ";
foreach ($helpConfig['actions'] as $action) {
?>
- = $action['name'] ?> = $action['path'] ?>
\n
";
echo $helpConfig['append']() ?? '';
exit();
}
$modules = $config['modules'];
$selectedModule = null;
foreach ($modules as $moduleName => $module) {
foreach (array_merge([$moduleName], $module['alias'] ?? []) as $alias) {
if (strpos($_SERVER['HTTP_HOST'], $alias . '.') === 0) {
$selectedModule = $module;
$selectedModule['key'] = $moduleName;
break;
}
}
}
if ($selectedModule === null) {
http_response_code(404);
echo 'unknown module';
}
generateHelp($selectedModule['key']);
if (isset($selectedModule['auth']) && $selectedModule['auth']) {
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))
{
header("WWW-Authenticate: Basic realm=\"You need to provide user and passwd\"");
http_response_code(401);
echo "Authentification Required";
exit();
}
$providedUsername = $_SERVER['PHP_AUTH_USER'];
$providedPassword = $_SERVER['PHP_AUTH_PW'];
$found = false;
foreach ($config['auth'] as $username => $password) {
if ($username === $providedUsername && $password == $providedPassword) {
$found = true;
}
}
if (!$found) {
header("WWW-Authenticate: Basic realm=\"Invalid auth\"");
http_response_code(401);
echo "Invalid authentification, try again";
exit();
}
}
require('./modules/' . $selectedModule['key'] . '/' . $selectedModule['key'] . '.php');