Help for module \"$selectedModule\"";
echo "
";
foreach ($helpConfig['actions'] as $action) {
?>
- = $action['name'] ?> = $action['path'] ?>
\n
";
echo $helpConfig['append']() ?? '';
exit();
}
$modules = $config['modules'];
$selectedModule = null;
foreach ($modules as $key => $module) {
if (strpos($_SERVER['HTTP_HOST'], $key . '.') === 0) {
$selectedModule = $module;
$selectedModule['key'] = $key;
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');