]> 91.132.146.200 Git - dolphin.git/commitdiff
http auth update...
authorBanana <banana@optimus.de>
Sun, 12 Feb 2017 09:57:19 +0000 (10:57 +0100)
committerBanana <banana@optimus.de>
Sun, 12 Feb 2017 09:57:19 +0000 (10:57 +0100)
.gitignore [new file with mode: 0644]
README
authentication/http-auth.php

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..baf6b9d
--- /dev/null
@@ -0,0 +1,3 @@
+.buildpath
+.project
+.settings/
diff --git a/README b/README
index 2d30a7d96d043100649c70d9a93009afea21e003..81f0461adbd37d8bee43f666d99446239a47f77d 100644 (file)
--- 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
index 5ad1ecafe137e6acdeaf1836cc40e7919d996b67..f173e0adb1f26b9f5d11f26d2d9661de2cacc3b9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  *  dolphin. Collection of useful PHP skeletons.
- *  Copyright (C) 2012  Johannes 'Banana' Keßler
+ *  Copyright (C) 2017  Johannes 'Banana' Keßler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
  * http://php.net/manual/en/features.http-auth.php
  */
 
-if (!isset($_SERVER['PHP_AUTH_USER'])) {
-    header('WWW-Authenticate: Basic realm="My secret base"');
-    header('HTTP/1.0 401 Unauthorized');
-    echo 'You canceled the auth process. Reload the page to get the box again.';
-    exit;
-} else {
-    echo "<p>Hello ".$_SERVER['PHP_AUTH_USER'].".</p>";
-    echo "<p>You entered ".$_SERVER['PHP_AUTH_PW']." as your password.</p>";
+# 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