Auth
This commit is contained in:
31
index.php
31
index.php
@@ -36,9 +36,6 @@ $title = "<h1>Zaubar Web Tour QA</h1><h3>Pick your version</h3><p>sort_by = " .
|
|||||||
|
|
||||||
// PASSWORD
|
// PASSWORD
|
||||||
$AUTH_ENABLED = true;
|
$AUTH_ENABLED = true;
|
||||||
$AUTH_USER = 'admin';
|
|
||||||
$AUTH_PASS = 'admin';
|
|
||||||
$AUTH_INPUT = "";
|
|
||||||
|
|
||||||
// STYLING (light or dark)
|
// STYLING (light or dark)
|
||||||
$color = "light";
|
$color = "light";
|
||||||
@@ -70,7 +67,7 @@ $index_ext_list = array("html");
|
|||||||
// SET TITLE BASED ON FOLDER NAME, IF NOT SET ABOVE
|
// SET TITLE BASED ON FOLDER NAME, IF NOT SET ABOVE
|
||||||
if( !$title ) { $title = clean_title(basename(dirname(__FILE__))); }
|
if( !$title ) { $title = clean_title(basename(dirname(__FILE__))); }
|
||||||
|
|
||||||
if ($AUTH_ENABLED) { $AUTH_INPUT = require_auth(); }
|
if ($AUTH_ENABLED) { $require_auth(); }
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -452,37 +449,29 @@ function require_auth() {
|
|||||||
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
|
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
|
||||||
$is_not_authenticated = (
|
$is_not_authenticated = (
|
||||||
!$has_supplied_credentials ||
|
!$has_supplied_credentials ||
|
||||||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
|
$_SERVER['PHP_AUTH_USER'] != "admin" ||
|
||||||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
|
$_SERVER['PHP_AUTH_PW'] != "140194"
|
||||||
);
|
);
|
||||||
if ($is_not_authenticated) {
|
if ($is_not_authenticated) {
|
||||||
header('HTTP/1.1 401 Authorization Required');
|
header('HTTP/1.1 401 Authorization Required');
|
||||||
header('WWW-Authenticate: Basic realm="Access denied"');
|
header('WWW-Authenticate: Basic realm="Access denied"');
|
||||||
exit;
|
exit;
|
||||||
} else {
|
|
||||||
return $_SERVER['PHP_AUTH_USER'] . ":" . $_SERVER['PHP_AUTH_PW']
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// GET THE BLOCKS STARTED, FALSE TO INDICATE MAIN FOLDER
|
||||||
|
$items = scandir( dirname(__FILE__) );
|
||||||
|
build_blocks( $items, false );
|
||||||
|
|
||||||
// GET THE BLOCKS STARTED, FALSE TO INDICATE MAIN FOLDER
|
} catch (\Throwable $t) {
|
||||||
$items = scandir( dirname(__FILE__) );
|
echo $t->getMessage(), " at ", $t->getFile(), ":", $t->getLine(), "\n";
|
||||||
build_blocks( $items, false );
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php try { if($AUTH_ENABLED) { ?>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function()
|
|
||||||
{
|
|
||||||
|
|
||||||
alert("" + <?php echo $AUTH_INPUT; ?>);
|
|
||||||
|
|
||||||
});
|
|
||||||
<?php } catch (\Throwable $t) { echo $t->getMessage(), " at ", $t->getFile(), ":", $t->getLine(), "\n"; } ?>
|
|
||||||
|
|
||||||
<?php if($toggle_sub_folders) { ?>
|
<?php if($toggle_sub_folders) { ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
|
|||||||
Reference in New Issue
Block a user