Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for phpPlatonLib/Auth_AuthDB/AuthDB.php between version 1.10 and 1.11

version 1.10, 2003/07/19 11:52:04 version 1.11, 2003/07/27 15:42:30
Line 7 
Line 7 
  * ____________________________________________________________   * ____________________________________________________________
  *   *
  * Developed by Ondrej Jombik <nepto@platon.sk>   * Developed by Ondrej Jombik <nepto@platon.sk>
  * Copyright (c) 2001-2002 Platon SDG, http://platon.sk/   * Copyright (c) 2001-2003 Platon SDG, http://platon.sk/
  * All rights reserved.   * All rights reserved.
  *   *
  * See README file for more information about this software.   * See README file for more information about this software.
Line 17 
Line 17 
  * http://platon.sk/projects/phpPlatonLib/   * http://platon.sk/projects/phpPlatonLib/
  */   */
   
 /* $Platon: AuthDB.php,v 1.7 2002/07/31 15:34:14 nepto Exp $ */  /* $Platon: phpPlatonLib/Auth_AuthDB/AuthDB.php,v 1.10 2003/07/19 11:52:04 nepto Exp $ */
   
 /*  /*
  * History:   * History:
Line 29 
Line 29 
  * 05/9/2002 - expiration & timeout implementation   * 05/9/2002 - expiration & timeout implementation
  *           - better HTTP_X_FORWARDED_FOR handling in authentification   *           - better HTTP_X_FORWARDED_FOR handling in authentification
  *           - extensive code cleanup   *           - extensive code cleanup
    * 27/7/2003 - support for authentification via another cooperative
    *             authentification interface
  */   */
   
 require_once 'DB.php';  require_once 'DB.php';
Line 46  define('AUTH_DB_FAILED',        -5);
Line 48  define('AUTH_DB_FAILED',        -5);
   
 class AuthDB  class AuthDB
 {  {
         var $_status  = AUTH_DB_UNDEFINED;          var $_status     = AUTH_DB_UNDEFINED;
         var $_options = null;          var $_options    = null;
         var $_db      = null;          var $_db         = null;
         var $_props   = array(          var $_logged_fnc = null;
           var $_props      = array(
                         'username'   => null,                          'username'   => null,
                         'password'   => null,                          'password'   => null,
                         'session_id' => null,                          'session_id' => null,
Line 62  class AuthDB
Line 65  class AuthDB
                 $this->_options = $options;                  $this->_options = $options;
         }          }
   
           /**
            * Tells AuthDB, that particular user is already authentificated
            * via another cooperative authetification interface.
            *
            * @param       fncname         name of the function, which returns
            *                                              username of already logged in user
            * @return      status
            */
           function setLoggedFunction($fncname)
           {
                   $this->_logged_fnc = $fncname;
           }
   
   
         function assignData()          function assignData()
         {          {
                 global $HTTP_POST_VARS;                  global $HTTP_POST_VARS;
Line 96  class AuthDB
Line 113  class AuthDB
   
         function _processStatus()          function _processStatus()
         {          {
                   if ($this->_logged_fnc != null && function_exists($this->_logged_fnc)) {
                           $this->_props['username'] = call_user_func($this->_logged_fnc);
                   }
                 $this->_checkDB();                  $this->_checkDB();
                 $this->_DBupdateTimeout();                  $this->_DBupdateTimeout();
   
                 $status = $this->_DBcheckLogin();                  $status = $this->_DBcheckLogin();
                 if ($status != AUTH_DB_UNDEFINED) {  
                   /* If there is a defined login status returns it.
                      Exception is, if we are in "logged" mode, which means we are
                      authentificated via another cooperative authentification interface.
                      In this case only LOGGED_IN and FAILED are returned.
                      Other statuses purpously force login function again. */
                   if ($status != AUTH_DB_UNDEFINED && ($this->_logged_fnc == null
                                           || $status == AUTH_DB_FAILED
                                           || $status == AUTH_DB_LOGGED_IN)) {
                         if ($status != AUTH_DB_LOGGED_IN) {                          if ($status != AUTH_DB_LOGGED_IN) {
                                 setcookie(AUTH_DB_COOKIE_NAME, '', time() - 100000);                                  setcookie(AUTH_DB_COOKIE_NAME, '', time() - 100000);
                         }                          }
                         return $status;                          return $status;
                 }                  }
   
                   /* If not in "logged" mode, assign login data into variables. */
                 $this->assignData();                  $this->_logged_fnc != null || $this->assignData();
                 $status = $this->login();                  $status = $this->login();
   
                 if ($status == AUTH_DB_LOGGED_IN) {                  if ($status == AUTH_DB_LOGGED_IN) {
                         $this->_DBinsert();                          $this->_DBinsert();
                         setcookie(AUTH_DB_COOKIE_NAME,                          setcookie(AUTH_DB_COOKIE_NAME,
                                         $this->_getProperty('session_id'),                                          $this->_getProperty('session_id'), 0, '', '', false);
                                         0, '', '', false);  
                 } elseif ($status == AUTH_DB_FAILED) {                  } elseif ($status == AUTH_DB_FAILED) {
                         $this->_DBlog();                          $this->_DBlog();
                 }                  }
Line 128  class AuthDB
Line 155  class AuthDB
                 $status = AUTH_DB_UNDEFINED;                  $status = AUTH_DB_UNDEFINED;
   
                 if (! empty($this->_props['username'])) {                  if (! empty($this->_props['username'])) {
   
                         $password = $this->_DBgetPassword();                          $password = $this->_DBgetPassword();
                         if (isset($password)                          if (isset($password)) {
                                 && ! strcmp($password, md5($this->_props['password']))) {                                  if ($this->_logged_fnc ||
                                 $status = AUTH_DB_LOGGED_IN;                                                  ! strcmp($password, md5($this->_props['password']))) {
                                           $status = AUTH_DB_LOGGED_IN;
                                   } else {
                                           $status = AUTH_DB_FAILED;
                                   }
                         } else {                          } else {
                                 $status = AUTH_DB_FAILED;                                  $status = AUTH_DB_FAILED;
                         }                          }
Line 201  class AuthDB
Line 231  class AuthDB
                         case 'remote_ip':                          case 'remote_ip':
                                 global $HTTP_SERVER_VARS;                                  global $HTTP_SERVER_VARS;
                                 /* Sending HTTP_X_FORWARDED_FOR? OK, send anything you want,                                  /* Sending HTTP_X_FORWARDED_FOR? OK, send anything you want,
                                  but it must persis for whole session. */                                     but it must persist for the whole session. */
                                 $ret = array();                                  $ret = array();
                                 foreach (array('REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR') as $key) {                                  foreach (array('REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR') as $key) {
                                         if (isset($HTTP_SERVER_VARS[$key]))                                          if (isset($HTTP_SERVER_VARS[$key]))

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top