note 91328 added to features.http-auth

From: Date: Sat, 06 Jun 2009 05:38:24 +0000
Subject: note 91328 added to features.http-auth
Groups: php.notes 
Request: Send a blank email to php-notes+get-156410@lists.php.net to get a copy of this message
I got to experimenting with someone else's little bit of code, and I came up with this one. It seems to work rather sharp for me, not sure on security or anything but maybe it'll help some other people. <?php if($_GET['opipopip'] == 'logout') { header('WWW-Authenticate: Basic realm="Click \'Ok\' then \'Cancel\' to Log Out"'); header('HTTP/1.0 401 Unauthorized'); echo 'You have been successfully logged out. Click <a href="index.php">here</a> to log back in.'; die(); } if((!isset($_SERVER[PHP_AUTH_USER])) || ($_SERVER[PHP_AUTH_USER] != array('username1', 'username2') && $_SERVER[PHP_AUTH_PW] != 'password')) { header('WWW-Authenticate: Basic realm="Site Login"'); header('HTTP/1.0 401 Unauthorized'); echo 'You must enter a valid username and password to access this resource. <a href="index.php">Retry</a>.'; die(); } else { echo 'You have successfully logged in, <a href="index.php?opipopip=logout">Logout</a>'; } ?> Best of luck. ---- Server IP: 69.147.83.197 Probable Submitter: 96.243.131.90 ---- Manual Page -- http://www.php.net/manual/en/features.http-auth.php Edit -- https://master.php.net/note/edit/91328 Del: integrated -- https://master.php.net/note/delete/91328/integrated Del: useless -- https://master.php.net/note/delete/91328/useless Del: bad code -- https://master.php.net/note/delete/91328/bad+code Del: spam -- https://master.php.net/note/delete/91328/spam Del: non-english -- https://master.php.net/note/delete/91328/non-english Del: in docs -- https://master.php.net/note/delete/91328/in+docs Del: other reasons-- https://master.php.net/note/delete/91328 Reject -- https://master.php.net/note/reject/91328 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156410) next »