* SURLS is a simple URL shortener written in PHP based on Apache RewriteRule Directive * See README on how to use it * * @package SURLS * @version 1.4 * @author Varun Agrawal <*****@*****.**> * @link https://github.com/VarunAgw/SURLS */ session_start(); /* * ":" is not allowed in either username/password * Password can be raw or sha256 value * * Use `php -r "echo hash('sha256', rtrim(fgets(STDIN)));"` to generate SHA256 value */ BasicAuthenticator::setCredentials('admin', 'password'); Request::handleRequest(); class BasicAuthenticator { protected static $_credentials; public static function setCredentials($username, $password) { self::$_credentials = array('username' => $username, 'password' => $password); } public static function Authenticate() { $credentials = self::$_credentials; if (!isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { header('WWW-Authenticate: Basic realm="Welcome to SURLS: Simple URL Shortener. This developer is lazy to implement a fancy login page'); header('HTTP/1.0 401 Unauthorized'); die(str_repeat('<br />', 100) . 'End of scroll ;)');