/usr/share/doc/php-auth/examples/logging.php is in php-auth 1.6.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?php
require_once "Auth.php";
require_once 'Log.php';
require_once 'Log/observer.php';
// Callback function to display login form
function loginFunction($username = null, $status = null, &$auth = null)
{
/*
* Change the HTML output so that it fits to your
* application.
*/
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "Username: <input type=\"text\" name=\"username\"><br/>";
echo "Password: <input type=\"password\" name=\"password\"><br/>";
echo "<input type=\"submit\">";
echo "</form>";
}
class Auth_Log_Observer extends Log_observer {
var $messages = array();
function notify($event) {
$this->messages[] = $event;
}
}
$options = array(
'enableLogging' => true,
'cryptType' => 'md5',
'users' => array(
'guest' => md5('password'),
),
);
$a = new Auth("Array", $options, "loginFunction");
$infoObserver = new Auth_Log_Observer(AUTH_LOG_INFO);
$a->attachLogObserver($infoObserver);
$debugObserver = new Auth_Log_Observer(AUTH_LOG_DEBUG);
$a->attachLogObserver($debugObserver);
$a->start();
if ($a->checkAuth()) {
/*
* The output of your site goes here.
*/
print "Authentication Successful.<br/>";
}
print '<h3>Logging Output:</h3>'
.'<b>AUTH_LOG_INFO level messages:</b><br/>';
foreach ($infoObserver->messages as $event) {
print $event['priority'].': '.$event['message'].'<br/>';
}
print '<br/>'
.'<b>AUTH_LOG_DEBUG level messages:</b><br/>';
foreach ($debugObserver->messages as $event) {
print $event['priority'].': '.$event['message'].'<br/>';
}
print '<br/>';
?>
|