info:myphp:identification-fake-apache-authentication_protection_php_very_simple

<?php
/* fake htaccess authentication (simple)
Fred Radeff (aka FR), fradeff@akademia.ch|Fred Radeff]] 2008/04/02 11:03//
<?php
//protection
 $ok=-1; //start with no ID
$login=""; //put a login
$password=""; //put a password here

      if (($_SERVER['PHP_AUTH_USER']==$login) && (md5($_SERVER['PHP_AUTH_PW'])==$password)) {
        //USER ok, keep id
        $ok=$i;
      }

 //if check KO, $ok is still -1
    //ask login+password
    if ($ok==-1) {
	header("WWW-Authenticate: Basic realm='Restricted Area'");
	print("<H1>Authorization Required</H1>This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.<hr>");
	exit;      
    } else {
echo "Welcome, authentified user!";
}

?>
  • info/myphp/identification-fake-apache-authentication_protection_php_very_simple.txt
  • Dernière modification : 2018/07/18 09:45
  • de radeff