Re: HTTP authentication : logout!!!

From: Date: Tue, 08 May 2001 19:44:31 +0000
Subject: Re: HTTP authentication : logout!!!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51967@lists.php.net to get a copy of this message
On 07-May-01 Mauricio Souza Lima wrote: <snip> > And you have to inform the user to clean the password field, click ok, > then the pop-up will open again, then user click in cancel. > > I just know that way to do. If anyone know another way, Postit! > create a tmp directory -------- logoff.php3: require('secure.php3'); authuser("Logoff"); // validate user (possible Dos attack here) $fname="tmp/$PHP_AUTH_USER"; touch($fname); Header("Location: http://www.mydomain.com/index.html"); --------- secure.php3: function checklogin($user,$pass='',$realm='') { if (! dbInit()) { echo "\n\n<BODY><CENTER>"; die("<P><H2>Unable to contact database server</H2>"); } $fname="tmp/$user"; if (file_exists($fname)) { unlink($fname); return(false); } $query="select login from users where login='$user' and password=PASSWORD('$pass')"; // echo $query .'<BR>'; $result = mysql_query( $query); $row = mysql_fetch_object($result); if ($row) { return(true); } return(false); } function authheader($realm) { Header('WWW-authenticate: basic realm="'.$realm .'"'); Header('HTTP/1.0 401 Unauthorized'); echo "\n\n"; } function authuser($realm='Access') { global $PHP_AUTH_USER, $PHP_AUTH_PW; if (! (isset($PHP_AUTH_USER)) ) { authheader($realm); exit; } if (! (checklogin($PHP_AUTH_USER, $PHP_AUTH_PW, $realm)) ) { authheader($realm); echo '<CENTER>Failed Login'; exit; } } Regards, -- Don Read dread@texas.net -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it.

« previous php.general (#51967) next »