Ignore:
Timestamp:
Jun 8, 2006 5:36:10 AM (18 years ago)
Author:
scdev
Message:

${1}

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Auth_File.inc.php

    r149 r154  
    6868    function Auth_File($namespace='null')
    6969    {
    70         $this->_ns = '_auth_' . $namespace;
     70        $this->_ns = $namespace;
    7171
    7272        // Initialize default parameters.
     
    114114    function clear()
    115115    {
    116         $_SESSION[$this->_ns] = array('authenticated' => false);
     116        $_SESSION['_auth_file'][$this->_ns] = array('authenticated' => false);
    117117    }
    118118
     
    127127    function set($key, $val)
    128128    {
    129         if (!isset($_SESSION[$this->_ns]['user_data'])) {
    130             $_SESSION[$this->_ns]['user_data'] = array();
    131         }
    132         $_SESSION[$this->_ns]['user_data'][$key] = $val;
     129        if (!isset($_SESSION['_auth_file'][$this->_ns]['user_data'])) {
     130            $_SESSION['_auth_file'][$this->_ns]['user_data'] = array();
     131        }
     132        $_SESSION['_auth_file'][$this->_ns]['user_data'][$key] = $val;
    133133    }
    134134
     
    143143    function get($key, $default='')
    144144    {
    145         if (isset($_SESSION[$this->_ns][$key])) {
    146             return $_SESSION[$this->_ns][$key];
    147         } else if (isset($_SESSION[$this->_ns]['user_data'][$key])) {
    148             return $_SESSION[$this->_ns]['user_data'][$key];
     145        if (isset($_SESSION['_auth_file'][$this->_ns][$key])) {
     146            return $_SESSION['_auth_file'][$this->_ns][$key];
     147        } else if (isset($_SESSION['_auth_file'][$this->_ns]['user_data'][$key])) {
     148            return $_SESSION['_auth_file'][$this->_ns]['user_data'][$key];
    149149        } else {
    150150            return $default;
     
    209209        }
    210210       
    211         $_SESSION[$this->_ns] = array(
     211        $_SESSION['_auth_file'][$this->_ns] = array(
    212212            'authenticated' => true,
    213213            'username' => $username,
     
    238238        if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
    239239            $user_in_trusted_network = true;
    240             $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_ns]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);
     240            $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION['_auth_file'][$this->_ns]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);
    241241        } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) {
    242242            $user_in_trusted_network = true;
    243             $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_ns]['username']), LOG_DEBUG, __FILE__, __LINE__);
     243            $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION['_auth_file'][$this->_ns]['username']), LOG_DEBUG, __FILE__, __LINE__);
    244244        } else {
    245245            $user_in_trusted_network = false;
     
    247247
    248248        // Test login with information stored in session. Skip IP matching for users from trusted networks.
    249         if (isset($_SESSION[$this->_ns])
    250             && true === $_SESSION[$this->_ns]['authenticated']
    251             && !empty($_SESSION[$this->_ns]['username'])
    252             && strtotime($_SESSION[$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']
    253             && strtotime($_SESSION[$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']
    254             && ($_SESSION[$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
     249        if (isset($_SESSION['_auth_file'][$this->_ns])
     250            && true === $_SESSION['_auth_file'][$this->_ns]['authenticated']
     251            && !empty($_SESSION['_auth_file'][$this->_ns]['username'])
     252            && strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']
     253            && strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']
     254            && ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
    255255        ) {
    256256            // User is authenticated!
    257             $_SESSION[$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s');
     257            $_SESSION['_auth_file'][$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s');
    258258            return true;
    259         } else if (isset($_SESSION[$this->_ns]) && true === $_SESSION[$this->_ns]['authenticated']) {
    260             if (strtotime($_SESSION[$this->_ns]['last_access_datetime']) > time() - 43200) {
     259        } else if (isset($_SESSION['_auth_file'][$this->_ns]) && true === $_SESSION['_auth_file'][$this->_ns]['authenticated']) {
     260            if (strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - 43200) {
    261261                // Only raise message if last session is less than 12 hours old.
    262262                $app->raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
     
    265265            // Log the reason for login expiration.
    266266            $expire_reasons = array();
    267             if (empty($_SESSION[$this->_ns]['username'])) {
     267            if (empty($_SESSION['_auth_file'][$this->_ns]['username'])) {
    268268                $expire_reasons[] = 'username not found';
    269269            }
    270             if (strtotime($_SESSION[$this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) {
     270            if (strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) {
    271271                $expire_reasons[] = 'login_timeout expired';
    272272            }
    273             if (strtotime($_SESSION[$this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {
     273            if (strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {
    274274                $expire_reasons[] = 'idle_timeout expired';
    275275            }
    276             if ($_SESSION[$this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {
    277                 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_ns]['remote_ip'], getRemoteAddr());
    278             }
    279             $app->logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_ns]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
     276            if ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {
     277                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION['_auth_file'][$this->_ns]['remote_ip'], getRemoteAddr());
     278            }
     279            $app->logMsg(sprintf('User %s session expired: %s', $_SESSION['_auth_file'][$this->_ns]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
    280280        }
    281281
Note: See TracChangeset for help on using the changeset viewer.