feat(UrlShortner): add module
This commit is contained in:
parent
c677114e08
commit
8f492f2432
4 changed files with 144 additions and 22 deletions
22
index.php
22
index.php
|
|
@ -51,27 +51,7 @@ if ($selectedModule === null) {
|
|||
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();
|
||||
}
|
||||
askAuth($config['auth']);
|
||||
}
|
||||
|
||||
require('./modules/' . $selectedModule['key'] . '/' . $selectedModule['key'] . '.php');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue