Changeset 148


Ignore:
Timestamp:
Jun 5, 2006 1:33:26 AM (18 years ago)
Author:
scdev
Message:

Q - Also change getVal/setVal to get/set in Auth_File.

Location:
trunk/lib
Files:
2 edited

Legend:

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

    r146 r148  
    125125     * @param mixed $val      Value to set variable to.
    126126     */
    127     function setVal($key, $val)
     127    function set($key, $val)
    128128    {
    129129        if (!isset($_SESSION[$this->_ns]['user_data'])) {
     
    141141     * @return mixed          Value stored in session.
    142142     */
    143     function getVal($key, $default='')
     143    function get($key, $default='')
    144144    {
    145145        if (isset($_SESSION[$this->_ns][$key])) {
  • trunk/lib/Auth_SQL.inc.php

    r146 r148  
    262262            seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)),
    263263            last_login_datetime = '0000-00-00 00:00:00'
    264             WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
     264            WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'
    265265        ");
    266266        $_SESSION[$this->_ns] = array('authenticated' => false);
     
    290290     * @return mixed          Value stored in session.
    291291     */
    292     function getVal($key, $default='')
     292    function get($key, $default='')
    293293    {
    294294        if (isset($_SESSION[$this->_ns][$key])) {
     
    390390            if (!empty($user_data['blocked'])) {
    391391
    392                 $app->logMsg(sprintf('User %s (%s) login failed due to blocked account: %s', $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
     392                $app->logMsg(sprintf('User %s (%s) login failed due to blocked account: %s', $this->get('user_id'), $this->get('username'), $this->get('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
    393393
    394394                switch ($user_data['blocked_reason']) {
     
    412412         * (2) If this number exceeds the login_abuse_max_ips, assume multiple people are logging in under the same account.
    413413        **/
    414         if ($this->getParam('abuse_detection') && !$this->getVal('login_abuse_exempt')) {
     414        if ($this->getParam('abuse_detection') && !$this->get('login_abuse_exempt')) {
    415415            $qid = $db->query("
    416416                SELECT COUNT(DISTINCT LEFT(remote_ip_binary, " . $this->_params['login_abuse_ip_bitmask'] . "))
    417417                FROM " . $this->_params['db_login_table'] . "
    418                 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
     418                WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'
    419419                AND DATE_ADD(login_datetime, INTERVAL '" . $this->_params['login_abuse_timeframe'] . "' DAY_HOUR) > NOW()
    420420            ");
    421421            list($distinct_ips) = mysql_fetch_row($qid);
    422422            if ($distinct_ips > $this->_params['login_abuse_max_ips']) {
    423                 if ($this->getVal('abuse_warning_level') < $this->_params['login_abuse_warnings']) {
     423                if ($this->get('abuse_warning_level') < $this->_params['login_abuse_warnings']) {
    424424                    // Warn the user with a password reset.
    425425                    $this->resetPassword(null, _("This is a security precaution. We have detected this account has been accessed from multiple computers simultaneously. It is against policy to share login information with others. If further account abuse is detected this account will be blocked."));
    426426                    $app->raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__);
    427                     $app->logMsg(sprintf('Account abuse detected for user %s (%s) from IP %s', $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_WARNING, __FILE__, __LINE__);
     427                    $app->logMsg(sprintf('Account abuse detected for user %s (%s) from IP %s', $this->get('user_id'), $this->get('username'), $this->get('remote_ip')), LOG_WARNING, __FILE__, __LINE__);
    428428                } else {
    429429                    // Block the account with the reason of account abuse.
    430430                    $this->blockAccount(null, 'account abuse');
    431431                    $app->raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__);
    432                     $app->logMsg(sprintf('Account blocked for user %s (%s) from IP %s', $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_ALERT, __FILE__, __LINE__);
     432                    $app->logMsg(sprintf('Account blocked for user %s (%s) from IP %s', $this->get('user_id'), $this->get('username'), $this->get('remote_ip')), LOG_ALERT, __FILE__, __LINE__);
    433433                }
    434434                // Increment user's warning level.
    435                 $db->query("UPDATE " . $this->_params['db_table'] . " SET abuse_warning_level = abuse_warning_level + 1 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'");
     435                $db->query("UPDATE " . $this->_params['db_table'] . " SET abuse_warning_level = abuse_warning_level + 1 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'");
    436436                // Reset the login counter for this user.
    437                 $db->query("DELETE FROM " . $this->_params['db_login_table'] . " WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'");
     437                $db->query("DELETE FROM " . $this->_params['db_login_table'] . " WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'");
    438438                // No login: reset password because of account abuse!
    439439                $this->clearAuth();
     
    448448                    remote_ip_binary
    449449                ) VALUES (
    450                     '" . $this->getVal('user_id') . "',
    451                     '" . $this->getVal('login_datetime') . "',
    452                     '" . sprintf('%032b', ip2long($this->getVal('remote_ip'))) . "'
     450                    '" . $this->get('user_id') . "',
     451                    '" . $this->get('login_datetime') . "',
     452                    '" . sprintf('%032b', ip2long($this->get('remote_ip'))) . "'
    453453                )
    454454            ");
     
    458458        $db->query("
    459459            UPDATE " . $this->_params['db_table'] . " SET
    460                 last_login_datetime = '" . $this->getVal('login_datetime') . "',
    461                 last_access_datetime = '" . $this->getVal('login_datetime') . "',
    462                 last_login_ip = '" . $this->getVal('remote_ip') . "'
    463             WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
     460                last_login_datetime = '" . $this->get('login_datetime') . "',
     461                last_access_datetime = '" . $this->get('login_datetime') . "',
     462                last_login_ip = '" . $this->get('remote_ip') . "'
     463            WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'
    464464        ");
    465465
     
    508508            $user_in_trusted_network = true;
    509509            $app->logMsg(sprintf('User %s accessing from trusted network %s',
    510                 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : ''),
     510                ($this->get('user_id') ? ' ' . $this->get('user_id') . ' (' .  $this->get('username') . ')' : ''),
    511511                $trusted_net
    512512            ), LOG_DEBUG, __FILE__, __LINE__);
     
    514514            $user_in_trusted_network = true;
    515515            $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com',
    516                 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : '')
     516                ($this->get('user_id') ? ' ' . $this->get('user_id') . ' (' .  $this->get('username') . ')' : '')
    517517            ), LOG_DEBUG, __FILE__, __LINE__);
    518518        } else {
     
    535535                UPDATE " . $this->_params['db_table'] . " SET
    536536                seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)) + 1,
    537                 last_access_datetime = '" . $this->getVal('last_access_datetime') . "'
    538                 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
     537                last_access_datetime = '" . $this->get('last_access_datetime') . "'
     538                WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'
    539539            ");
    540540            if (mysql_affected_rows($db->getDBH()) > 0) {
     
    542542                return true;
    543543            } else {
    544                 $app->logMsg(sprintf('User update failed. Record not found for user %s (%s).', $this->getVal('user_id'), $this->getVal('username')), LOG_NOTICE, __FILE__, __LINE__);
     544                $app->logMsg(sprintf('User update failed. Record not found for user %s (%s).', $this->get('user_id'), $this->get('username')), LOG_NOTICE, __FILE__, __LINE__);
    545545            }
    546546        } else if (isset($_SESSION[$this->_ns]) && true === $_SESSION[$this->_ns]['authenticated']) {
     
    565565                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_ns]['remote_ip'], getRemoteAddr());
    566566            }
    567             $app->logMsg(sprintf('User %s (%s) session expired: %s', $this->getVal('user_id'), $this->getVal('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
     567            $app->logMsg(sprintf('User %s (%s) session expired: %s', $this->get('user_id'), $this->get('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
    568568        }
    569569
     
    617617
    618618            // Get user_id if specified.
    619             $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
     619            $user_id = isset($user_id) ? $user_id : $this->get('user_id');
    620620            $db->query("
    621621                UPDATE " . $this->_params['db_table'] . " SET
     
    638638        if ($this->getParam('blocking')) {
    639639            // Get user_id if specified.
    640             $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
     640            $user_id = isset($user_id) ? $user_id : $this->get('user_id');
    641641            $db->query("
    642642                UPDATE " . $this->_params['db_table'] . " SET
     
    788788
    789789        // Get user_id if specified.
    790         $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
     790        $user_id = isset($user_id) ? $user_id : $this->get('user_id');
    791791
    792792        // Issue the password change query.
     
    817817
    818818        // Get user_id if specified.
    819         $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
     819        $user_id = isset($user_id) ? $user_id : $this->get('user_id');
    820820
    821821        // Reset password of a specific user.
     
    891891        return true;
    892892        $zone_members = preg_split('/,\s*/', $security_zone);
    893         $priv = empty($priv) ? $this->getVal('priv') : $priv;
     893        $priv = empty($priv) ? $this->get('priv') : $priv;
    894894
    895895        // If the current user's privilege level is NOT in that array or if the
     
    917917        /* If the current user's privilege level is NOT in that array or if the
    918918         * user has no privilege, DIE with a message. */
    919         if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) {
     919        if (!in_array($this->get('priv'), $zone_members) || !$this->get('priv')) {
    920920            $message = empty($message) ? _("You have insufficient privileges to view that page.") : $message;
    921921            $app->raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);
Note: See TracChangeset for help on using the changeset viewer.