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
<?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