diff --git a/index.php b/index.php index a826903..5f67eac 100644 --- a/index.php +++ b/index.php @@ -34,6 +34,11 @@ $sort_by = "date_desc"; // options: name_asc, name_desc, date_asc, date_desc // TITLE OF PAGE $title = "

Zaubar Web Tour QA

Pick your version

sort_by = " . $sort_by . "

"; +// PASSWORD +$AUTH_ENABLED = true; +$AUTH_USER = 'admin'; +$AUTH_PASS = 'admin'; + // STYLING (light or dark) $color = "light"; @@ -63,7 +68,12 @@ $index_ext_list = array("html"); // SET TITLE BASED ON FOLDER NAME, IF NOT SET ABOVE if( !$title ) { $title = clean_title(basename(dirname(__FILE__))); } + +if ($AUTH_ENABLED) { require_auth(); } + ?> + + @@ -435,6 +445,22 @@ function build_blocks( $items, $folder ) } +// +function require_auth() { + header('Cache-Control: no-cache, must-revalidate, max-age=0'); + $has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW'])); + $is_not_authenticated = ( + !$has_supplied_credentials || + $_SERVER['PHP_AUTH_USER'] != $AUTH_USER || + $_SERVER['PHP_AUTH_PW'] != $AUTH_PASS + ); + if ($is_not_authenticated) { + header('HTTP/1.1 401 Authorization Required'); + header('WWW-Authenticate: Basic realm="Access denied"'); + exit; + } +} +