Auth
[ class tree: Auth ] [ index: Auth ] [ all elements ]

Source for file Html.php

Documentation is available at Html.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Martin Jansen <mj@php.net>                                  |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Html.php,v 1.7 2006/02/28 05:11:39 aashley Exp $
  20. //
  21.  
  22.  
  23. /**
  24.  * Standard Html Login form
  25.  * 
  26.  * @author   Yavor Shahpasov <yavo@netsmart.com.cy>
  27.  * @author   Adam Ashley <aashley@php.net>
  28.  * @package  Auth
  29.  * @version  $Revision: 1.7 $
  30.  */
  31.     
  32.     // {{{ render()
  33.  
  34.     /**
  35.      * Displays the login form
  36.      *
  37.      * @param object The calling auth instance
  38.      * @param string The previously used username
  39.      * @return void 
  40.      */
  41.     function render(&$caller$username ''{
  42.         $loginOnClick 'return true;';
  43.         
  44.         // Try To Use Challene response
  45.         // TODO javascript might need some improvement for work on other browsers
  46.         if($caller->advancedsecurity && $caller->storage->supportsChallengeResponse() ) {
  47.  
  48.             // Init the secret cookie
  49.             $caller->session['loginchallenege'md5(microtime());
  50.  
  51.             print "\n";
  52.             print '<script language="JavaScript">'."\n";
  53.  
  54.             include 'Auth/Frontend/md5.js';
  55.  
  56.             print "\n";
  57.             print ' function securePassword() { '."\n";
  58.             print '   var pass = document.getElementById(\''.$caller->getPostPasswordField().'\');'."\n";
  59.             print '   var secret = document.getElementById(\'authsecret\')'."\n";
  60.             //print '   alert(pass);alert(secret); '."\n";
  61.  
  62.             // If using md5 for password storage md5 the password before 
  63.             // we hash it with the secret
  64.             // print '   alert(pass.value);';
  65.             if ($caller->storage->getCryptType(== 'md5' {
  66.                 print '   pass.value = hex_md5(pass.value); '."\n";
  67.                 #print '   alert(pass.value);';
  68.             }
  69.  
  70.             print '   pass.value = hex_md5(pass.value+\''.$caller->session['loginchallenege'].'\'); '."\n";
  71.             // print '   alert(pass.value);';
  72.             print '   secret.value = 1;'."\n";
  73.             print '   var doLogin = document.getElementById(\'doLogin\')'."\n";
  74.             print '   doLogin.disabled = true;'."\n";
  75.             print '   return true;';
  76.             print ' } '."\n";
  77.             print '</script>'."\n";;
  78.             print "\n";
  79.  
  80.             $loginOnClick ' return securePassword(); ';
  81.         }
  82.  
  83.         print '<center>'."\n";
  84.  
  85.         $status '';
  86.         if (!empty($caller->status&& $caller->status == AUTH_EXPIRED{
  87.             $status '<i>Your session has expired. Please login again!</i>'."\n";
  88.         else if (!empty($caller->status&& $caller->status == AUTH_IDLED{
  89.             $status '<i>You have been idle for too long. Please login again!</i>'."\n";
  90.         else if (!empty ($caller->status&& $caller->status == AUTH_WRONG_LOGIN{
  91.             $status '<i>Wrong login data!</i>'."\n";
  92.         else if (!empty ($caller->status&& $caller->status == AUTH_SECURITY_BREACH{
  93.             $status '<i>Security problem detected. </i>'."\n";
  94.         }
  95.         
  96.         print '<form method="post" action="'.$caller->server['PHP_SELF'].'" '
  97.             .'onSubmit="'.$loginOnClick.'">'."\n";
  98.         print '<table border="0" cellpadding="2" cellspacing="0" '
  99.             .'summary="login form" align="center" >'."\n";
  100.         print '<tr>'."\n";
  101.         print '    <td colspan="2" bgcolor="#eeeeee"><strong>Login </strong>'
  102.             .$status.'</td>'."\n";
  103.         print '</tr>'."\n";
  104.         print '<tr>'."\n";
  105.         print '    <td>Username:</td>'."\n";
  106.         print '    <td><input type="text" id="'.$caller->getPostUsernameField()
  107.             .'" name="'.$caller->getPostUsernameField().'" value="' $username 
  108.             .'" /></td>'."\n";
  109.         print '</tr>'."\n";
  110.         print '<tr>'."\n";
  111.         print '    <td>Password:</td>'."\n";
  112.         print '    <td><input type="password" id="'.$caller->getPostPasswordField()
  113.             .'" name="'.$caller->getPostPasswordField().'" /></td>'."\n";
  114.         print '</tr>'."\n";
  115.         print '<tr>'."\n";
  116.         
  117.         //onClick=" '.$loginOnClick.' "
  118.         print '    <td colspan="2" bgcolor="#eeeeee"><input value="Login" '
  119.             .'id="doLogin" name="doLogin" type="submit" /></td>'."\n";
  120.         print '</tr>'."\n";
  121.         print '</table>'."\n";
  122.  
  123.         // Might be a good idea to make the variable name variable 
  124.         print '<input type="hidden" id="authsecret" name="authsecret" value="" />';
  125.         print '</form>'."\n";
  126.     }
  127.  
  128.     // }}}
  129.     
  130. }
  131.  
  132. ?>

Documentation generated on Mon, 11 Mar 2019 14:37:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.