Last active
August 29, 2015 14:01
-
-
Save schlomo/17579ede67fc16311ee0 to your computer and use it in GitHub Desktop.
PHP Basic Auth Gateway. Requests basic auth (password is reversed username) and redirects to URL passed as query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$username = 1; | |
$revpwd = 0; | |
if (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) { | |
$username = $_SERVER['PHP_AUTH_USER']; | |
$password = $_SERVER['PHP_AUTH_PW']; | |
$revpwd = strrev($password); | |
} | |
if ($username == $revpwd) { | |
if (isset($_SERVER['QUERY_STRING'])) { | |
header("Location: " . $_SERVER['QUERY_STRING']); | |
} | |
else { | |
echo "<p>Hallo {$_SERVER['PHP_AUTH_USER']}.</p>"; | |
echo "<p>Set redirect target in query string, e.g. append <code>?http://schapiro.org</code> to the URL.</p>"; | |
} | |
} | |
else { | |
header('WWW-Authenticate: Basic realm="Login Test"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
echo '<p>Password is reversed Username</p>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment