1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- /**
- * dolphin. Collection of useful PHP skeletons.
- * 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
- *
- * You should have received a copy of the
- * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
- * along with this program. If not, see http://www.sun.com/cddl/cddl.html
- */
- /**
- * simple HTTP auth method with PHP
- * more details can be found here:
- * http://php.net/manual/en/features.http-auth.php
- */
- # 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;
- }
- }
- ?>
|