From d6c63ccd32aa9e1569ff0c56c4c409eb180421e3 Mon Sep 17 00:00:00 2001 From: Banana Date: Sun, 12 Feb 2017 10:57:19 +0100 Subject: [PATCH] http auth update... --- .gitignore | 3 +++ README | 4 +++- authentication/http-auth.php | 24 +++++++++++++++--------- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..baf6b9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.buildpath +.project +.settings/ diff --git a/README b/README index 2d30a7d..81f0461 100644 --- a/README +++ b/README @@ -1,2 +1,4 @@ Dolphin is a collection of useful PHP skeletons -v1.1 + +In this collection there are scripts which are made as is. Some are old and are not up to date. +So use at your own risk. \ No newline at end of file diff --git a/authentication/http-auth.php b/authentication/http-auth.php index 5ad1eca..f173e0a 100644 --- a/authentication/http-auth.php +++ b/authentication/http-auth.php @@ -1,7 +1,7 @@ Hello ".$_SERVER['PHP_AUTH_USER'].".

"; - echo "

You entered ".$_SERVER['PHP_AUTH_PW']." as your password.

"; +# place this anywhere you need it. +# define FRONTEND_USERNAME and FRONTEND_PASSWORD as a constand +simpleAuth(); + +function simpleAuth() { + if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) + || $_SERVER['PHP_AUTH_USER'] !== FRONTEND_USERNAME || $_SERVER['PHP_AUTH_PW'] !== FRONTEND_PASSWORD + ) { + header('WWW-Authenticate: Basic realm="Your secret area"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'No Access.'; + exit; + } } + ?> \ No newline at end of file -- 2.39.5