Login   Register  
PHP Classes
elePHPant
Icontem

File: authCallback.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Julio César Carrascal Urquijo  >  Auth Suite  >  authCallback.php  >  Download  
File: authCallback.php
Role: Configuration script
Content type: text/plain
Description: Generates login forms and shows authentication messages to the user when needed.
Class: Auth Suite
User authentication component.
Author: By
Last change:
Date: 2002-07-31 19:45
Size: 5,852 bytes
 

Contents

Class file image Download
<?php

define
('AUTH_CALLBACK''authCallback');

/**
 * Generates login forms and shows authentication messages to the user when needed.
 * This is where you can change the aspect of this forms. Also, if you want to log your
 * authentication trafic set $logging variable to true. and set the corresponding
 * variables according to http://www.php.net/error_log
 *
 * @version 2.4 pl3
 * @param $action        int, one of AUTH_NEED_LOGIN, AUTH_INVALID_USER, AUTH_EXPIRED,
 *                      AUTH_ACCESS_DENIED.
 * @param $message        string a message to show to the user.
 * @param $auth            object Auth.
 * @access public
 */
function authCallback($action$message '', &$auth) {
    if(!isset(
$_GET)) {
        
$_COOKIE = &$GLOBALS['HTTP_COOKIE_VARS'];
        
$_ENV = &$GLOBALS['HTTP_ENV_VARS'];
        
$_GET = &$GLOBALS['HTTP_GET_VARS'];
        
$_POST = &$GLOBALS['HTTP_POST_VARS'];
        
$_SERVER = &$GLOBALS['HTTP_SERVER_VARS'];
        
$_SESSION = &$GLOBALS['HTTP_SESSION_VARS'];
        
$_REQUEST array_merge($_GET$_POST$_COOKIE);
    }

    
// Configuration.
    
$logging false;
    
$logType 0;
    
$logDest '';
    
$logHeaders '';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Authentication.</title>
    <style type="text/css">
/*<![CDATA[*/
body {
    background-color: #FFF;
    font-family: Verdana, Helvetica, sans-serif;
    font-size: 10pt;
}

div, li, p, td, th {
    font-family: Verdana, Helvetica, sans-serif;
    font-size: 10pt;
}

.content{
    background-color: #EEE;
    border: 1px solid #CCC;
    width: 450px;
}

.content .title {
    background: white;
    border: 1px solid #CCC;
    color: #369;
    font-size: 12pt;
    font-weight: bold;
    padding: 10px;
}

.content th {
    background-color: #BDE;
    border: 1px solid #ABD;
    font-size: 12pt;
    font-wight: bold;
}

.content td {
    text-align:center;
}

.content .text {
    background-color: #DDD;
    border: 1px inset #CCC;
    font-size: 8pt;
    width: 200px;
}

.content .button {
    background-color: #DDD;
    border: 1px outset #CCC;
    font-size:8pt;
    padding: 2px 4px 2px 4px;
}

/*]]>*/
    </style>
  </head>
  <body>

    <table align="center" class="content" cellspacing="10">
      <tr>
        <td class="title" colspan="2"><?php echo $message?></td>
      </tr>
<?php

    
switch($action) {
        case 
AUTH_NEED_LOGIN:
?>
    <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
      <tr>
        <th>Username:</th>
        <td><input class="text" name="<?php echo $auth->_options['usernameField']; ?>" type="text" maxlength="32"/></td>
      <tr>
        <th>Password:</th>
        <td><input class="text" name="<?php echo $auth->_options['passwordField']; ?>" type="password"/></td>
      </tr>
      <tr>
        <td colspan="2">To access this zone you need to provide a valid username/password
        pair. If you lost your account info you can use our <a href="/lostpassword.php">
        reset password</a> form to access your account again.</td>
      </tr>
      <tr>
        <td colspan="2"><input class="button" type="submit" value="Login"/> <input class="button" onclick="history.go(-1);" type="button" value="Cancel"/></td>
      </tr>
    </form>
<?php
        
break;

        case 
AUTH_INVALID_USER:
?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <tr>
          <th>Username:</th>
          <td><input class="text" name="<?php echo $auth->_options['usernameField']; ?>" type="text" maxlength="32" /></td>
        </tr>
        <tr>
          <th>Password:</th>
          <td><input class="text" name="<?php echo $auth->_options['passwordField']; ?>" type="password" /></td>
        </tr>
        <tr>
          <td colspan="2">Your account doesn't exists. Please correct your information. If you lost your account info you can use our <a href="/lostpassword.php">reset password</a> form to access your account again.</td>
        </tr>
        <tr>
          <td colspan="2"><input class="button" type="submit" value="Login"/> <input class="button" onclick="history.go(-1);" type="button" value="Cancel"/></td>
        </tr>
      </form>
<?php
        
break;

        case 
AUTH_EXPIRED:
?>
      <tr>
        <td colspan="2">Your session just expired. Please login again.</td>
      </tr>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <tr>
          <th>Username:</th>
          <td><input class="text" name="<?php echo $auth->_options['usernameField']; ?>"
          type="text" maxlength="32" /></td>
        </tr>
        <tr>
          <th>Password:</th>
          <td><input class="text" name="<?php echo $auth->_options['passwordField']; ?>"
          type="password" /></td>
        </tr>
        <tr>
          <td colspan="2">To access this zone you need to provide a valid
          username/password pair. If you lost your account info you can use our <a
          href="/lostpassword.php">reset password</a> form to access your account
          again.</td>
        </tr>
        <tr>
          <td colspan="2"><input class="button" type="submit" value="Login"/> <input
          class="button" onclick="history.go(-1);" type="button" value="Cancel"/></td>
        </tr>
      </form>
<?php
        
break;

        case 
AUTH_ACCESS_DENIED:
        default:
?>
      <tr>
        <td>Your don't have access to this zone. Please leave it now!.</td>
      </tr>
      <tr>
        <td><input class="button" onclick="history.go(-1);" type="button" value="Exit"/></td>
      </tr>
<?php
        
break;
    }
?>
    </table>
  </body>
</html>
<?php

    
if($logging) {
        
error_log("AUTH MESSAGE: $message"logType$logDest,
            
$logHeaders);
    }
    die();
}

?>