I'm looking for a working php script that will work to log/save attempted username and password combinations to access my protected .htpasswd file (the .htaccess file is redirecting people to this php scripted file). I found this one:
<?php
define('LOGINS_LOG','/web/user/log-htpasswd.log');
if(isset($_ENV['REDIRECT_REMOTE_USER']) && !empty($_ENV['REDIRECT_REMOTE_USER'])){
$fp = fopen(LOGINS_LOG, 'a+');
fwrite($fp, $_ENV['REDIRECT_REMOTE_USER']);
fclose($fp);
}
ob_start();
header("HTTP/1.1 401 Authorization Required",1);
header("Status: 401 Authorization Required",1);
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head><title>401 Authorization Required</title></head><body>
<h1>Authorization Required</h1>
<p>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.</p>';
exit;
exit();
?>
But when i attempt to use it i get this error message:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /web/user/log-htpasswd.log on line 20
Anyone know a php script that will work?