Changeset 157


Ignore:
Timestamp:
Jun 9, 2006 9:25:54 PM (18 years ago)
Author:
scdev
Message:

Q - added tags/2.0.2 as the first php5 compatible version of the 2.0 branch.

Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/2.0/lib/App.inc.php

    r126 r157  
    164164    function setParam($param=null)
    165165    {
    166         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    167             $this =& App::getInstance();
    168         }
     166        $_this =& App::getInstance();
    169167
    170168        if (isset($param) && is_array($param)) {
    171169            // Merge new parameters with old overriding only those passed.
    172             $this->_params = array_merge($this->_params, $param);
     170            $_this->_params = array_merge($_this->_params, $param);
    173171        }
    174172    }
     
    183181    function &getParam($param=null)
    184182    {
    185         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    186             $this =& App::getInstance();
    187         }
     183        $_this =& App::getInstance();
    188184
    189185        if ($param === null) {
    190             return $this->_params;
    191         } else if (isset($this->_params[$param])) {
    192             return $this->_params[$param];
     186            return $_this->_params;
     187        } else if (isset($_this->_params[$param])) {
     188            return $_this->_params[$param];
    193189        } else {
    194190            trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);
     
    360356    function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
    361357    {
    362         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    363             $this =& App::getInstance();
    364         }
     358        $_this =& App::getInstance();
    365359
    366360        $message = trim($message);
    367361
    368         if (!$this->running || '' == $message) {
    369             $this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     362        if (!$_this->running || '' == $message) {
     363            $_this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    370364            return false;
    371365        }
     
    373367        // Save message in session under unique key to avoid duplicate messages.
    374368        $msg_id = md5($type . $message . $file . $line);
    375         $_SESSION[$this->app]['messages'][$msg_id] = array(
     369        $_SESSION[$_this->app]['messages'][$msg_id] = array(
    376370            'type'    => $type,
    377371            'message' => $message,
    378372            'file'    => $file,
    379373            'line'    => $line,
    380             'count'   => (isset($_SESSION[$this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->app]['messages'][$msg_id]['count']) : 1)
     374            'count'   => (isset($_SESSION[$_this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1)
    381375        );
    382376
    383377        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
    384             $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
     378            $_this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
    385379        }
    386380    }
     
    396390    function getRaisedMessages()
    397391    {
    398         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    399             $this =& App::getInstance();
    400         }
    401 
    402         if (!$this->running) {
    403             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     392        $_this =& App::getInstance();
     393
     394        if (!$_this->running) {
     395            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    404396            return false;
    405397        }
    406398       
    407399        $output = array();
    408         while (isset($_SESSION[$this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {
     400        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
    409401            $output[] = $message;
    410402        }
     
    421413    function clearRaisedMessages()
    422414    {
    423         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    424             $this =& App::getInstance();
    425         }
    426 
    427         if (!$this->running) {
    428             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     415        $_this =& App::getInstance();
     416
     417        if (!$_this->running) {
     418            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    429419            return false;
    430420        }
    431421       
    432         $_SESSION[$this->app]['messages'] = array();
     422        $_SESSION[$_this->app]['messages'] = array();
    433423    }
    434424
     
    442432    function printRaisedMessages()
    443433    {
    444         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    445             $this =& App::getInstance();
    446         }
    447 
    448         if (!$this->running) {
    449             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    450             return false;
    451         }
    452 
    453         while (isset($_SESSION[$this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {
     434        $_this =& App::getInstance();
     435
     436        if (!$_this->running) {
     437            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     438            return false;
     439        }
     440
     441        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
    454442            ?><div class="sc-msg"><?php
    455             if (error_reporting() > 0 && $this->getParam('display_errors')) {
     443            if (error_reporting() > 0 && $_this->getParam('display_errors')) {
    456444                echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->';
    457445            }
     
    501489        static $previous_events = array();
    502490
    503         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    504             $this =& App::getInstance();
    505         }
     491        $_this =& App::getInstance();
    506492
    507493        // If priority is not specified, assume the worst.
    508         if (!$this->logPriorityToString($priority)) {
    509             $this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
     494        if (!$_this->logPriorityToString($priority)) {
     495            $_this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
    510496            $priority = LOG_EMERG;
    511497        }
    512498
    513499        // If log file is not specified, don't log to a file.
    514         if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) {
    515             $this->setParam(array('log_file_priority' => false));
     500        if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) {
     501            $_this->setParam(array('log_file_priority' => false));
    516502            // We must use trigger_error to report this problem rather than calling App::logMsg, which might lead to an infinite loop.
    517             trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
     503            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE);
    518504        }
    519505
     
    531517            $previous_events[$msg_id]++;
    532518            if ($previous_events[$msg_id] == 2) {
    533                 $this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
     519                $_this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
    534520            }
    535521            return false;
     
    543529            'remote ip' => getRemoteAddr(),
    544530            'pid'       => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''),
    545             'type'      => $this->logPriorityToString($priority),
     531            'type'      => $_this->logPriorityToString($priority),
    546532            'file:line' => "$file : $line",
    547533            'url'       => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''),
     
    550536
    551537        // FILE ACTION
    552         if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
     538        if ($_this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) {
    553539            $event_str = '[' . join('] [', $event) . ']';
    554             error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
     540            error_log($event_str . "\n", 3, $_this->getParam('log_directory') . '/' . $_this->getParam('log_filename'));
    555541        }
    556542
    557543        // EMAIL ACTION
    558         if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {
     544        if ($_this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) {
    559545            $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message);
    560546            $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST'));
     
    563549                $email_msg .= sprintf("%-11s%s\n", $k, $v);
    564550            }
    565             mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
     551            mail($_this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
    566552        }
    567553
    568554        // SMS ACTION
    569         if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
     555        if ($_this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) {
    570556            $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority);
    571557            $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line);
    572558            $headers = "From: codebase@strangecode.com";
    573             mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
     559            mail($_this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
    574560        }
    575561
    576562        // SCREEN ACTION
    577         if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
     563        if ($_this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) {
    578564            echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n";
    579565        }
     
    620606    function carryQuery($query_key)
    621607    {
    622         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    623             $this =& App::getInstance();
    624         }
     608        $_this =& App::getInstance();
    625609
    626610        // If not already set, and there is a non-empty value provided in the request...
    627         if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
     611        if (!isset($_this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
    628612            // Copy the value of the specified query argument into the _carry_queries array.
    629             $this->_carry_queries[$query_key] = getFormData($query_key);
     613            $_this->_carry_queries[$query_key] = getFormData($query_key);
    630614        }
    631615    }
     
    652636    function url($url, $carry_args=null, $always_include_sid=false)
    653637    {
    654         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    655             $this =& App::getInstance();
    656         }
    657 
    658         if (!$this->running) {
    659             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     638        $_this =& App::getInstance();
     639
     640        if (!$_this->running) {
     641            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    660642            return false;
    661643        }
     
    691673        if ($do_carry_queries) {
    692674            // Join the global _carry_queries and local one_time_carry_queries.
    693             $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
     675            $query_args = urlEncodeArray(array_merge($_this->_carry_queries, $one_time_carry_queries));
    694676            foreach ($query_args as $key=>$val) {
    695677                // Check value is set and value does not already exist in the url.
     
    715697                    (
    716698                        !isset($_COOKIE[session_name()])
    717                         || !$this->getParam('session_use_cookies')
     699                        || !$_this->getParam('session_use_cookies')
    718700                    )
    719                     && $this->getParam('enable_session')
     701                    && $_this->getParam('enable_session')
    720702                    && isMyDomain($url)
    721703                    &&
     
    748730    function oHREF($url, $carry_args=null, $always_include_sid=false)
    749731    {
    750         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    751             $this =& App::getInstance();
    752         }
    753 
    754         $url = $this->url($url, $carry_args, $always_include_sid);
     732        $_this =& App::getInstance();
     733
     734        $url = $_this->url($url, $carry_args, $always_include_sid);
    755735
    756736        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
     
    772752    function printHiddenSession($carry_args=null)
    773753    {
    774         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    775             $this =& App::getInstance();
    776         }
    777 
    778         if (!$this->running) {
    779             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     754        $_this =& App::getInstance();
     755
     756        if (!$_this->running) {
     757            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    780758            return false;
    781759        }
     
    808786            // Join the global _carry_queries and local one_time_carry_queries.
    809787            // urlencode is not used here, not for form data!
    810             $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
     788            $query_args = array_merge($_this->_carry_queries, $one_time_carry_queries);
    811789            foreach ($query_args as $key=>$val) {
    812790                echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
     
    835813    function dieURL($url, $carry_args=null, $always_include_sid=false)
    836814    {
    837         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    838             $this =& App::getInstance();
    839         }
    840 
    841         if (!$this->running) {
    842             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     815        $_this =& App::getInstance();
     816
     817        if (!$_this->running) {
     818            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    843819            return false;
    844820        }
     
    846822        if ('' == $url) {
    847823            // If URL is not specified, use the redirect_home_url.
    848             $url = $this->getParam('redirect_home_url');
     824            $url = $_this->getParam('redirect_home_url');
    849825        }
    850826
     
    856832        }
    857833
    858         $url = $this->url($url, $carry_args, $always_include_sid);
     834        $url = $_this->url($url, $carry_args, $always_include_sid);
    859835
    860836        header(sprintf('Location: %s', $url));
    861         $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
     837        $_this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    862838
    863839        // End this application.
    864840        // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
    865         $this->stop();
     841        $_this->stop();
    866842        die;
    867843    }
     
    884860    function dieBoomerangURL($id=null, $carry_args=null, $default_url=null)
    885861    {
    886         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    887             $this =& App::getInstance();
    888         }
    889 
    890         if (!$this->running) {
    891             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     862        $_this =& App::getInstance();
     863
     864        if (!$_this->running) {
     865            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    892866            return false;
    893867        }
    894868
    895869        // Get URL from stored boomerang. Allow non specific URL if ID not valid.
    896         if ($this->validBoomerangURL($id, true)) {
    897             if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    898                 $url = $_SESSION[$this->app]['boomerang']['url'][$id];
    899                 $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     870        if ($_this->validBoomerangURL($id, true)) {
     871            if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     872                $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
     873                $_this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    900874            } else {
    901                 $url = end($_SESSION[$this->app]['boomerang']['url']);
    902                 $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     875                $url = end($_SESSION[$_this->app]['boomerang']['url']);
     876                $_this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    903877            }
    904878            // Delete stored boomerang.
    905             $this->deleteBoomerangURL($id);
     879            $_this->deleteBoomerangURL($id);
    906880        } else if (isset($default_url)) {
    907881            $url = $default_url;
     
    909883            // Ensure that the redirecting page is not also the referrer.
    910884            $url = getenv('HTTP_REFERER');
    911             $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     885            $_this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    912886        } else {
    913887            // If URL is not specified, use the redirect_home_url.
    914             $url = $this->getParam('redirect_home_url');
    915             $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     888            $url = $_this->getParam('redirect_home_url');
     889            $_this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    916890        }
    917891
    918892        // A redirection will never happen immediately twice.
    919893        // Set the time so ensure this doesn't happen.
    920         $_SESSION[$this->app]['boomerang']['time'] = time();
    921         $this->dieURL($url, $carry_args);
     894        $_SESSION[$_this->app]['boomerang']['time'] = time();
     895        $_this->dieURL($url, $carry_args);
    922896    }
    923897
     
    931905    function setBoomerangURL($url=null, $id=null)
    932906    {
    933         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    934             $this =& App::getInstance();
    935         }
    936 
    937         if (!$this->running) {
    938             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     907        $_this =& App::getInstance();
     908
     909        if (!$_this->running) {
     910            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    939911            return false;
    940912        }
     
    946918            $url = preg_replace('/boomerang=[\w]+/', '', $url);
    947919
    948             if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {
     920            if (isset($_SESSION[$_this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) {
    949921                // If the URL currently exists in the boomerang array, delete.
    950                 while ($existing_key = array_search($url, $_SESSION[$this->app]['boomerang']['url'])) {
    951                     unset($_SESSION[$this->app]['boomerang']['url'][$existing_key]);
     922                while ($existing_key = array_search($url, $_SESSION[$_this->app]['boomerang']['url'])) {
     923                    unset($_SESSION[$_this->app]['boomerang']['url'][$existing_key]);
    952924                }
    953925            }
    954926
    955927            if (isset($id)) {
    956                 $_SESSION[$this->app]['boomerang']['url'][$id] = $url;
     928                $_SESSION[$_this->app]['boomerang']['url'][$id] = $url;
    957929            } else {
    958                 $_SESSION[$this->app]['boomerang']['url'][] = $url;
    959             }
    960             $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     930                $_SESSION[$_this->app]['boomerang']['url'][] = $url;
     931            }
     932            $_this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    961933            return true;
    962934        } else {
    963             $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
     935            $_this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
    964936            return false;
    965937        }
     
    973945    function getBoomerangURL($id=null)
    974946    {
    975         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    976             $this =& App::getInstance();
    977         }
    978 
    979         if (!$this->running) {
    980             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     947        $_this =& App::getInstance();
     948
     949        if (!$_this->running) {
     950            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    981951            return false;
    982952        }
    983953
    984954        if (isset($id)) {
    985             if (isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    986                 return $_SESSION[$this->app]['boomerang']['url'][$id];
     955            if (isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     956                return $_SESSION[$_this->app]['boomerang']['url'][$id];
    987957            } else {
    988958                return '';
    989959            }
    990         } else if (is_array($_SESSION[$this->app]['boomerang']['url'])) {
    991             return end($_SESSION[$this->app]['boomerang']['url']);
     960        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
     961            return end($_SESSION[$_this->app]['boomerang']['url']);
    992962        } else {
    993963            return false;
     
    1002972    function deleteBoomerangURL($id=null)
    1003973    {
    1004         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1005             $this =& App::getInstance();
    1006         }
    1007 
    1008         if (!$this->running) {
    1009             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    1010             return false;
    1011         }
    1012 
    1013         $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
    1014 
    1015         if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    1016             unset($_SESSION[$this->app]['boomerang']['url'][$id]);
    1017         } else if (is_array($_SESSION[$this->app]['boomerang']['url'])) {
    1018             array_pop($_SESSION[$this->app]['boomerang']['url']);
     974        $_this =& App::getInstance();
     975
     976        if (!$_this->running) {
     977            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     978            return false;
     979        }
     980
     981        $_this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $_this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
     982
     983        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     984            unset($_SESSION[$_this->app]['boomerang']['url'][$id]);
     985        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
     986            array_pop($_SESSION[$_this->app]['boomerang']['url']);
    1019987        }
    1020988    }
     
    1028996    function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
    1029997    {
    1030         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1031             $this =& App::getInstance();
    1032         }
    1033 
    1034         if (!$this->running) {
    1035             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    1036             return false;
    1037         }
    1038 
    1039         if (!isset($_SESSION[$this->app]['boomerang']['url'])) {
    1040             $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
     998        $_this =& App::getInstance();
     999
     1000        if (!$_this->running) {
     1001            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     1002            return false;
     1003        }
     1004
     1005        if (!isset($_SESSION[$_this->app]['boomerang']['url'])) {
     1006            $_this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
    10411007            return false;
    10421008        }
     
    10451011        // a boomerang redirection will always occur at least several seconds after the last boomerang redirect
    10461012        // or a boomerang being set.
    1047         $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;
     1013        $boomerang_time = isset($_SESSION[$_this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0;
    10481014
    10491015        $url = '';
    1050         if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    1051             $url = $_SESSION[$this->app]['boomerang']['url'][$id];
     1016        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     1017            $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
    10521018        } else if (!isset($id) || $use_nonspecificboomerang) {
    10531019            // Use non specific boomerang if available.
    1054             $url = end($_SESSION[$this->app]['boomerang']['url']);
    1055         }
    1056 
    1057         $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1020            $url = end($_SESSION[$_this->app]['boomerang']['url']);
     1021        }
     1022
     1023        $_this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10581024
    10591025        if ('' == $url) {
    1060             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
     1026            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
    10611027            return false;
    10621028        }
    10631029        if ($url == absoluteMe()) {
    10641030            // The URL we are directing to is the current page.
    1065             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1031            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10661032            return false;
    10671033        }
    10681034        if ($boomerang_time >= (time() - 2)) {
    10691035            // Last boomerang direction was more than 2 seconds ago.
    1070             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
    1071             return false;
    1072         }
    1073 
    1074         $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1036            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
     1037            return false;
     1038        }
     1039
     1040        $_this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10751041        return true;
    10761042    }
     
    10821048    function sslOn()
    10831049    {
    1084         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1085             $this =& App::getInstance();
    1086         }
     1050        $_this =& App::getInstance();
    10871051
    10881052        if (function_exists('apache_get_modules')) {
     
    10931057        }
    10941058
    1095         if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
    1096             $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
     1059        if ('' == getenv('HTTPS') && $_this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
     1060            $_this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $_this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
    10971061            // Always append session because some browsers do not send cookie when crossing to SSL URL.
    1098             $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
     1062            $_this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
    10991063        }
    11001064    }
     
    11071071    function sslOff()
    11081072    {
    1109         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1110             $this =& App::getInstance();
    1111         }
     1073        $_this =& App::getInstance();
    11121074
    11131075        if ('' != getenv('HTTPS')) {
    1114             $this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);
     1076            $_this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);
    11151077        }
    11161078    }
  • branches/2.0/lib/DB.inc.php

    r71 r157  
    8585    function setParam($params)
    8686    {
    87         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    88             $this =& DB::getInstance();
    89         }
     87        $_this =& DB::getInstance();
    9088
    9189        if (isset($params) && is_array($params)) {
    9290            // Merge new parameters with old overriding only those passed.
    93             $this->_params = array_merge($this->_params, $params);
     91            $_this->_params = array_merge($_this->_params, $params);
    9492        } else {
    9593            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     
    108106    function getParam($param)
    109107    {
    110         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    111             $this =& DB::getInstance();
    112         }
    113 
    114         if (isset($this->_params[$param])) {
    115             return $this->_params[$param];
     108        $_this =& DB::getInstance();
     109
     110        if (isset($_this->_params[$param])) {
     111            return $_this->_params[$param];
    116112        } else {
    117113            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     
    129125    function connect()
    130126    {
    131         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    132             $this =& DB::getInstance();
    133         }
    134 
    135         if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) {
     127        $_this =& DB::getInstance();
     128
     129        if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) {
    136130            App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
    137131            return false;
     
    139133
    140134        // Connect to database. Always create a new link to the server.
    141         if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
     135        if ($_this->dbh = mysql_connect($_this->getParam('db_server'), $_this->getParam('db_user'), $_this->getParam('db_pass'), true)) {
    142136            // Select database
    143             mysql_select_db($this->getParam('db_name'), $this->dbh);
     137            mysql_select_db($_this->getParam('db_name'), $_this->dbh);
    144138        }
    145139
    146140        // Test for connection errors.
    147         if (!$this->dbh || mysql_error($this->dbh)) {
    148             $mysql_error_msg = $this->dbh ? 'Codebase MySQL error: (' . mysql_errno($this->dbh) . ') ' . mysql_error($this->dbh) : 'Codebase MySQL error: Could not connect to server.';
     141        if (!$_this->dbh || mysql_error($_this->dbh)) {
     142            $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.';
    149143            App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);
    150144
    151145            // Print helpful or pretty error?
    152             if ($this->getParam('db_debug')) {
     146            if ($_this->getParam('db_debug')) {
    153147                echo $mysql_error_msg . "\n";
    154148            } else {
     
    157151
    158152            // Die or continue without connection?
    159             if ($this->getParam('db_die_on_failure')) {
     153            if ($_this->getParam('db_die_on_failure')) {
    160154                echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
    161155                die;
     
    166160
    167161        // DB connection success!
    168         $this->_connected = true;
     162        $_this->_connected = true;
    169163
    170164        // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01.
    171         $this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");
     165        $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");
    172166
    173167        return true;
     
    183177    function close()
    184178    {
    185         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    186             $this =& DB::getInstance();
    187         }
    188 
    189         if (!$this->_connected) {
    190             return false;
    191         }
    192 
    193         mysql_close($this->dbh);
     179        $_this =& DB::getInstance();
     180
     181        if (!$_this->_connected) {
     182            return false;
     183        }
     184
     185        mysql_close($_this->dbh);
    194186    }
    195187
     
    198190     *
    199191     * @access  public
    200      * @return  resource Current value of $this->dbh.
     192     * @return  resource Current value of $_this->dbh.
    201193     * @author  Quinn Comendant <quinn@strangecode.com>
    202194     * @since   20 Aug 2005 13:50:36
     
    204196    function getDBH()
    205197    {
    206         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    207             $this =& DB::getInstance();
    208         }
    209 
    210         if (!$this->_connected) {
    211             return false;
    212         }
    213 
    214         return $this->dbh;
     198        $_this =& DB::getInstance();
     199
     200        if (!$_this->_connected) {
     201            return false;
     202        }
     203
     204        return $_this->dbh;
    215205    }
    216206
     
    224214    function isConnected()
    225215    {
    226         return $this->_connected;
     216        $_this =& DB::getInstance();
     217
     218        return $_this->_connected;
    227219    }
    228220   
     
    238230    function escapeString($string)
    239231    {
    240         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    241             $this =& DB::getInstance();
    242         }
    243         return mysql_real_escape_string($string, $this->dbh);
     232        $_this =& DB::getInstance();
     233
     234        return mysql_real_escape_string($string, $_this->dbh);
    244235    }
    245236
     
    256247        static $_query_count = 0;
    257248
    258         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    259             $this =& DB::getInstance();
    260         }
    261 
    262         if (!$this->_connected) {
     249        $_this =& DB::getInstance();
     250
     251        if (!$_this->_connected) {
    263252           return false;
    264253        }
     
    266255        $_query_count++;
    267256        $debugqry = preg_replace("/\n[\t ]+/", "\n", $query);
    268         if ($this->getParam('db_always_debug') || $debug) {
     257        if ($_this->getParam('db_always_debug') || $debug) {
    269258            echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n";
    270259        }
    271260
    272261        // Execute!
    273         $qid = mysql_query($query, $this->dbh);
     262        $qid = mysql_query($query, $_this->dbh);
    274263
    275264        // Error checking.
    276         if (!$qid || mysql_error($this->dbh)) {
    277             if ($this->getParam('db_debug')) {
    278                 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
     265        if (!$qid || mysql_error($_this->dbh)) {
     266            if ($_this->getParam('db_debug')) {
     267                echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($_this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
    279268            } else {
    280269                echo _("This page is temporarily unavailable. It should be back up in a few minutes.");
    281270            }
    282             App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
    283             if ($this->getParam('db_die_on_failure')) {
     271            App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
     272            if ($_this->getParam('db_die_on_failure')) {
    284273                echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
    285274                die;
     
    302291    function tableExists($table, $use_cached_results=true)
    303292    {
    304         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    305             $this =& DB::getInstance();
    306         }
    307 
    308         if (!$this->_connected) {
    309             return false;
    310         }
    311 
    312         if (!isset($this->existing_tables) || !$use_cached_results) {
    313             $this->existing_tables = array();
    314             $qid = $this->query("SHOW TABLES");
     293        $_this =& DB::getInstance();
     294
     295        if (!$_this->_connected) {
     296            return false;
     297        }
     298
     299        if (!isset($_this->existing_tables) || !$use_cached_results) {
     300            $_this->existing_tables = array();
     301            $qid = $_this->query("SHOW TABLES");
    315302            while (list($row) = mysql_fetch_row($qid)) {
    316                 $this->existing_tables[] = $row;
    317             }
    318         }
    319         if (in_array($table, $this->existing_tables)) {
     303                $_this->existing_tables[] = $row;
     304            }
     305        }
     306        if (in_array($table, $_this->existing_tables)) {
    320307            return true;
    321308        } else {
    322             App::logMsg(sprintf('nonexistent DB table: %s.%s', $this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
     309            App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
    323310            return false;
    324311        }
     
    336323    function columnExists($table, $columns, $strict=true, $use_cached_results=true)
    337324    {
    338         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    339             $this =& DB::getInstance();
    340         }
    341 
    342         if (!$this->_connected) {
     325        $_this =& DB::getInstance();
     326
     327        if (!$_this->_connected) {
    343328            return false;
    344329        }
    345330
    346331        // Ensure the table exists.
    347         if (!$this->tableExists($table, $use_cached_results)) {
     332        if (!$_this->tableExists($table, $use_cached_results)) {
    348333            return false;
    349334        }
     
    354339        }
    355340
    356         if (!isset($this->table_columns[$table]) || !$use_cached_results) {
     341        if (!isset($_this->table_columns[$table]) || !$use_cached_results) {
    357342            // Populate and cache array of current columns for this table.
    358             $this->table_columns[$table] = array();
    359             $qid = $this->query("DESCRIBE $table");
     343            $_this->table_columns[$table] = array();
     344            $qid = $_this->query("DESCRIBE $table");
    360345            while ($row = mysql_fetch_row($qid)) {
    361                 $this->table_columns[$table][] = $row[0];
     346                $_this->table_columns[$table][] = $row[0];
    362347            }
    363348        }
     
    366351            // Do an exact comparison of table schemas.
    367352            sort($columns);
    368             sort($this->table_columns[$table]);
    369             return $this->table_columns[$table] == $columns;
     353            sort($_this->table_columns[$table]);
     354            return $_this->table_columns[$table] == $columns;
    370355        } else {
    371356            // Only check that the specified columns are available in the table.
    372             $match_columns = array_intersect($this->table_columns[$table], $columns);
     357            $match_columns = array_intersect($_this->table_columns[$table], $columns);
    373358            sort($columns);
    374359            sort($match_columns);
     
    386371    function resetCache()
    387372    {
    388         $this->existing_tables = null;
    389         $this->table_columns = null;
     373        $_this->existing_tables = null;
     374        $_this->table_columns = null;
    390375    }
    391376
  • branches/2.0/lib/SessionCache.inc.php

    r53 r157  
    4444    function setParam($params)
    4545    {
    46         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    47             $this =& SessionCache::getInstance();
    48         }
     46        $_this =& SessionCache::getInstance();
    4947
    5048        if (isset($params) && is_array($params)) {
    5149            // Merge new parameters with old overriding only those passed.
    52             $this->_params = array_merge($this->_params, $params);
     50            $_this->_params = array_merge($_this->_params, $params);
    5351        } else {
    5452            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     
    6563    function getParam($param)
    6664    {
    67         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    68             $this =& SessionCache::getInstance();
    69         }
    70 
    71         if (isset($this->_params[$param])) {
    72             return $this->_params[$param];
     65        $_this =& SessionCache::getInstance();
     66
     67        if (isset($_this->_params[$param])) {
     68            return $_this->_params[$param];
    7369        } else {
    7470            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     
    9591    function putCache($var, $var_id, $force_it_in=false)
    9692    {
    97         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    98             $this =& SessionCache::getInstance();
    99         }
    100 
    101         if (!$this->getParam('enabled')) {
     93        $_this =& SessionCache::getInstance();
     94
     95        if (!$_this->getParam('enabled')) {
    10296            App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
    10397            return false;
     
    108102        $serialized_var_len = strlen($serialized_var);
    109103
    110         if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) {
    111             App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
    112             return false;
    113         }
    114 
    115         if ($serialized_var_len >= $this->getParam('hard_limit')) {
    116             App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
     104        if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) {
     105            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
     106            return false;
     107        }
     108
     109        if ($serialized_var_len >= $_this->getParam('hard_limit')) {
     110            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
    117111            return false;
    118112        }
     
    123117            unset($_SESSION['_session_cache'][$var_id]);
    124118            // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least.
    125             while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit')
    126             && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
     119            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit')
     120            && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) {
    127121                array_shift($_SESSION['_session_cache']);
    128122            }
     
    149143    function getCache($var_id)
    150144    {
    151         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    152             $this =& SessionCache::getInstance();
    153         }
    154 
    155         if (!$this->getParam('enabled')) {
     145        $_this =& SessionCache::getInstance();
     146
     147        if (!$_this->getParam('enabled')) {
    156148            return false;
    157149        }
     
    179171    function isCached($var_id)
    180172    {
    181         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    182             $this =& SessionCache::getInstance();
    183         }
    184 
    185         if (!$this->getParam('enabled')) {
     173        $_this =& SessionCache::getInstance();
     174
     175        if (!$_this->getParam('enabled')) {
    186176            return false;
    187177        }
  • branches/2.0/tests/Auth_SQLTest.php

    r126 r157  
    108108        $this->assertTrue($true, 'User login failed, but should have succeeded.');
    109109
    110         echo "Testing wrong password...\n";
     110        // echo "Testing wrong password...\n";
    111111        $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass');
    112112
     
    124124        $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
    125125
    126         echo "Testing wrong password...\n";
     126        // echo "Testing wrong password...\n";
    127127        $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
    128128        $this->assertFalse($login2, '4. User login succeeded, but should have failed.');
  • branches/2.0/tests/EmailTest.php

    r42 r157  
    9494        $this->assertEquals(41, $gc, 'Unexpected good count.');
    9595        $this->assertEquals(47, $bc, 'Unexpected bad count.');
    96         echo "Good addresses: $gc\n";
    97         echo "Bad addresses: $bc\n";
     96        // echo "Good addresses: $gc\n";
     97        // echo "Bad addresses: $bc\n";
    9898//         echo join("\n", $bad);
    9999//         echo "\n";
  • tags/2.0.2/lib/App.inc.php

    r126 r157  
    164164    function setParam($param=null)
    165165    {
    166         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    167             $this =& App::getInstance();
    168         }
     166        $_this =& App::getInstance();
    169167
    170168        if (isset($param) && is_array($param)) {
    171169            // Merge new parameters with old overriding only those passed.
    172             $this->_params = array_merge($this->_params, $param);
     170            $_this->_params = array_merge($_this->_params, $param);
    173171        }
    174172    }
     
    183181    function &getParam($param=null)
    184182    {
    185         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    186             $this =& App::getInstance();
    187         }
     183        $_this =& App::getInstance();
    188184
    189185        if ($param === null) {
    190             return $this->_params;
    191         } else if (isset($this->_params[$param])) {
    192             return $this->_params[$param];
     186            return $_this->_params;
     187        } else if (isset($_this->_params[$param])) {
     188            return $_this->_params[$param];
    193189        } else {
    194190            trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);
     
    360356    function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
    361357    {
    362         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    363             $this =& App::getInstance();
    364         }
     358        $_this =& App::getInstance();
    365359
    366360        $message = trim($message);
    367361
    368         if (!$this->running || '' == $message) {
    369             $this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     362        if (!$_this->running || '' == $message) {
     363            $_this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    370364            return false;
    371365        }
     
    373367        // Save message in session under unique key to avoid duplicate messages.
    374368        $msg_id = md5($type . $message . $file . $line);
    375         $_SESSION[$this->app]['messages'][$msg_id] = array(
     369        $_SESSION[$_this->app]['messages'][$msg_id] = array(
    376370            'type'    => $type,
    377371            'message' => $message,
    378372            'file'    => $file,
    379373            'line'    => $line,
    380             'count'   => (isset($_SESSION[$this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->app]['messages'][$msg_id]['count']) : 1)
     374            'count'   => (isset($_SESSION[$_this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1)
    381375        );
    382376
    383377        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
    384             $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
     378            $_this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
    385379        }
    386380    }
     
    396390    function getRaisedMessages()
    397391    {
    398         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    399             $this =& App::getInstance();
    400         }
    401 
    402         if (!$this->running) {
    403             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     392        $_this =& App::getInstance();
     393
     394        if (!$_this->running) {
     395            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    404396            return false;
    405397        }
    406398       
    407399        $output = array();
    408         while (isset($_SESSION[$this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {
     400        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
    409401            $output[] = $message;
    410402        }
     
    421413    function clearRaisedMessages()
    422414    {
    423         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    424             $this =& App::getInstance();
    425         }
    426 
    427         if (!$this->running) {
    428             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     415        $_this =& App::getInstance();
     416
     417        if (!$_this->running) {
     418            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    429419            return false;
    430420        }
    431421       
    432         $_SESSION[$this->app]['messages'] = array();
     422        $_SESSION[$_this->app]['messages'] = array();
    433423    }
    434424
     
    442432    function printRaisedMessages()
    443433    {
    444         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    445             $this =& App::getInstance();
    446         }
    447 
    448         if (!$this->running) {
    449             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    450             return false;
    451         }
    452 
    453         while (isset($_SESSION[$this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {
     434        $_this =& App::getInstance();
     435
     436        if (!$_this->running) {
     437            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     438            return false;
     439        }
     440
     441        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
    454442            ?><div class="sc-msg"><?php
    455             if (error_reporting() > 0 && $this->getParam('display_errors')) {
     443            if (error_reporting() > 0 && $_this->getParam('display_errors')) {
    456444                echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->';
    457445            }
     
    501489        static $previous_events = array();
    502490
    503         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    504             $this =& App::getInstance();
    505         }
     491        $_this =& App::getInstance();
    506492
    507493        // If priority is not specified, assume the worst.
    508         if (!$this->logPriorityToString($priority)) {
    509             $this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
     494        if (!$_this->logPriorityToString($priority)) {
     495            $_this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
    510496            $priority = LOG_EMERG;
    511497        }
    512498
    513499        // If log file is not specified, don't log to a file.
    514         if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) {
    515             $this->setParam(array('log_file_priority' => false));
     500        if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) {
     501            $_this->setParam(array('log_file_priority' => false));
    516502            // We must use trigger_error to report this problem rather than calling App::logMsg, which might lead to an infinite loop.
    517             trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
     503            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE);
    518504        }
    519505
     
    531517            $previous_events[$msg_id]++;
    532518            if ($previous_events[$msg_id] == 2) {
    533                 $this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
     519                $_this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
    534520            }
    535521            return false;
     
    543529            'remote ip' => getRemoteAddr(),
    544530            'pid'       => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''),
    545             'type'      => $this->logPriorityToString($priority),
     531            'type'      => $_this->logPriorityToString($priority),
    546532            'file:line' => "$file : $line",
    547533            'url'       => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''),
     
    550536
    551537        // FILE ACTION
    552         if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
     538        if ($_this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) {
    553539            $event_str = '[' . join('] [', $event) . ']';
    554             error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
     540            error_log($event_str . "\n", 3, $_this->getParam('log_directory') . '/' . $_this->getParam('log_filename'));
    555541        }
    556542
    557543        // EMAIL ACTION
    558         if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {
     544        if ($_this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) {
    559545            $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message);
    560546            $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST'));
     
    563549                $email_msg .= sprintf("%-11s%s\n", $k, $v);
    564550            }
    565             mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
     551            mail($_this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
    566552        }
    567553
    568554        // SMS ACTION
    569         if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
     555        if ($_this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) {
    570556            $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority);
    571557            $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line);
    572558            $headers = "From: codebase@strangecode.com";
    573             mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
     559            mail($_this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
    574560        }
    575561
    576562        // SCREEN ACTION
    577         if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
     563        if ($_this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) {
    578564            echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n";
    579565        }
     
    620606    function carryQuery($query_key)
    621607    {
    622         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    623             $this =& App::getInstance();
    624         }
     608        $_this =& App::getInstance();
    625609
    626610        // If not already set, and there is a non-empty value provided in the request...
    627         if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
     611        if (!isset($_this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
    628612            // Copy the value of the specified query argument into the _carry_queries array.
    629             $this->_carry_queries[$query_key] = getFormData($query_key);
     613            $_this->_carry_queries[$query_key] = getFormData($query_key);
    630614        }
    631615    }
     
    652636    function url($url, $carry_args=null, $always_include_sid=false)
    653637    {
    654         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    655             $this =& App::getInstance();
    656         }
    657 
    658         if (!$this->running) {
    659             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     638        $_this =& App::getInstance();
     639
     640        if (!$_this->running) {
     641            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    660642            return false;
    661643        }
     
    691673        if ($do_carry_queries) {
    692674            // Join the global _carry_queries and local one_time_carry_queries.
    693             $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
     675            $query_args = urlEncodeArray(array_merge($_this->_carry_queries, $one_time_carry_queries));
    694676            foreach ($query_args as $key=>$val) {
    695677                // Check value is set and value does not already exist in the url.
     
    715697                    (
    716698                        !isset($_COOKIE[session_name()])
    717                         || !$this->getParam('session_use_cookies')
     699                        || !$_this->getParam('session_use_cookies')
    718700                    )
    719                     && $this->getParam('enable_session')
     701                    && $_this->getParam('enable_session')
    720702                    && isMyDomain($url)
    721703                    &&
     
    748730    function oHREF($url, $carry_args=null, $always_include_sid=false)
    749731    {
    750         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    751             $this =& App::getInstance();
    752         }
    753 
    754         $url = $this->url($url, $carry_args, $always_include_sid);
     732        $_this =& App::getInstance();
     733
     734        $url = $_this->url($url, $carry_args, $always_include_sid);
    755735
    756736        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
     
    772752    function printHiddenSession($carry_args=null)
    773753    {
    774         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    775             $this =& App::getInstance();
    776         }
    777 
    778         if (!$this->running) {
    779             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     754        $_this =& App::getInstance();
     755
     756        if (!$_this->running) {
     757            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    780758            return false;
    781759        }
     
    808786            // Join the global _carry_queries and local one_time_carry_queries.
    809787            // urlencode is not used here, not for form data!
    810             $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
     788            $query_args = array_merge($_this->_carry_queries, $one_time_carry_queries);
    811789            foreach ($query_args as $key=>$val) {
    812790                echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
     
    835813    function dieURL($url, $carry_args=null, $always_include_sid=false)
    836814    {
    837         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    838             $this =& App::getInstance();
    839         }
    840 
    841         if (!$this->running) {
    842             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     815        $_this =& App::getInstance();
     816
     817        if (!$_this->running) {
     818            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    843819            return false;
    844820        }
     
    846822        if ('' == $url) {
    847823            // If URL is not specified, use the redirect_home_url.
    848             $url = $this->getParam('redirect_home_url');
     824            $url = $_this->getParam('redirect_home_url');
    849825        }
    850826
     
    856832        }
    857833
    858         $url = $this->url($url, $carry_args, $always_include_sid);
     834        $url = $_this->url($url, $carry_args, $always_include_sid);
    859835
    860836        header(sprintf('Location: %s', $url));
    861         $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
     837        $_this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    862838
    863839        // End this application.
    864840        // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
    865         $this->stop();
     841        $_this->stop();
    866842        die;
    867843    }
     
    884860    function dieBoomerangURL($id=null, $carry_args=null, $default_url=null)
    885861    {
    886         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    887             $this =& App::getInstance();
    888         }
    889 
    890         if (!$this->running) {
    891             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     862        $_this =& App::getInstance();
     863
     864        if (!$_this->running) {
     865            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    892866            return false;
    893867        }
    894868
    895869        // Get URL from stored boomerang. Allow non specific URL if ID not valid.
    896         if ($this->validBoomerangURL($id, true)) {
    897             if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    898                 $url = $_SESSION[$this->app]['boomerang']['url'][$id];
    899                 $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     870        if ($_this->validBoomerangURL($id, true)) {
     871            if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     872                $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
     873                $_this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    900874            } else {
    901                 $url = end($_SESSION[$this->app]['boomerang']['url']);
    902                 $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     875                $url = end($_SESSION[$_this->app]['boomerang']['url']);
     876                $_this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    903877            }
    904878            // Delete stored boomerang.
    905             $this->deleteBoomerangURL($id);
     879            $_this->deleteBoomerangURL($id);
    906880        } else if (isset($default_url)) {
    907881            $url = $default_url;
     
    909883            // Ensure that the redirecting page is not also the referrer.
    910884            $url = getenv('HTTP_REFERER');
    911             $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     885            $_this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    912886        } else {
    913887            // If URL is not specified, use the redirect_home_url.
    914             $url = $this->getParam('redirect_home_url');
    915             $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     888            $url = $_this->getParam('redirect_home_url');
     889            $_this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    916890        }
    917891
    918892        // A redirection will never happen immediately twice.
    919893        // Set the time so ensure this doesn't happen.
    920         $_SESSION[$this->app]['boomerang']['time'] = time();
    921         $this->dieURL($url, $carry_args);
     894        $_SESSION[$_this->app]['boomerang']['time'] = time();
     895        $_this->dieURL($url, $carry_args);
    922896    }
    923897
     
    931905    function setBoomerangURL($url=null, $id=null)
    932906    {
    933         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    934             $this =& App::getInstance();
    935         }
    936 
    937         if (!$this->running) {
    938             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     907        $_this =& App::getInstance();
     908
     909        if (!$_this->running) {
     910            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    939911            return false;
    940912        }
     
    946918            $url = preg_replace('/boomerang=[\w]+/', '', $url);
    947919
    948             if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {
     920            if (isset($_SESSION[$_this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) {
    949921                // If the URL currently exists in the boomerang array, delete.
    950                 while ($existing_key = array_search($url, $_SESSION[$this->app]['boomerang']['url'])) {
    951                     unset($_SESSION[$this->app]['boomerang']['url'][$existing_key]);
     922                while ($existing_key = array_search($url, $_SESSION[$_this->app]['boomerang']['url'])) {
     923                    unset($_SESSION[$_this->app]['boomerang']['url'][$existing_key]);
    952924                }
    953925            }
    954926
    955927            if (isset($id)) {
    956                 $_SESSION[$this->app]['boomerang']['url'][$id] = $url;
     928                $_SESSION[$_this->app]['boomerang']['url'][$id] = $url;
    957929            } else {
    958                 $_SESSION[$this->app]['boomerang']['url'][] = $url;
    959             }
    960             $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     930                $_SESSION[$_this->app]['boomerang']['url'][] = $url;
     931            }
     932            $_this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    961933            return true;
    962934        } else {
    963             $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
     935            $_this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
    964936            return false;
    965937        }
     
    973945    function getBoomerangURL($id=null)
    974946    {
    975         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    976             $this =& App::getInstance();
    977         }
    978 
    979         if (!$this->running) {
    980             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     947        $_this =& App::getInstance();
     948
     949        if (!$_this->running) {
     950            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    981951            return false;
    982952        }
    983953
    984954        if (isset($id)) {
    985             if (isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    986                 return $_SESSION[$this->app]['boomerang']['url'][$id];
     955            if (isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     956                return $_SESSION[$_this->app]['boomerang']['url'][$id];
    987957            } else {
    988958                return '';
    989959            }
    990         } else if (is_array($_SESSION[$this->app]['boomerang']['url'])) {
    991             return end($_SESSION[$this->app]['boomerang']['url']);
     960        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
     961            return end($_SESSION[$_this->app]['boomerang']['url']);
    992962        } else {
    993963            return false;
     
    1002972    function deleteBoomerangURL($id=null)
    1003973    {
    1004         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1005             $this =& App::getInstance();
    1006         }
    1007 
    1008         if (!$this->running) {
    1009             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    1010             return false;
    1011         }
    1012 
    1013         $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
    1014 
    1015         if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    1016             unset($_SESSION[$this->app]['boomerang']['url'][$id]);
    1017         } else if (is_array($_SESSION[$this->app]['boomerang']['url'])) {
    1018             array_pop($_SESSION[$this->app]['boomerang']['url']);
     974        $_this =& App::getInstance();
     975
     976        if (!$_this->running) {
     977            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     978            return false;
     979        }
     980
     981        $_this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $_this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
     982
     983        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     984            unset($_SESSION[$_this->app]['boomerang']['url'][$id]);
     985        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
     986            array_pop($_SESSION[$_this->app]['boomerang']['url']);
    1019987        }
    1020988    }
     
    1028996    function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
    1029997    {
    1030         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1031             $this =& App::getInstance();
    1032         }
    1033 
    1034         if (!$this->running) {
    1035             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    1036             return false;
    1037         }
    1038 
    1039         if (!isset($_SESSION[$this->app]['boomerang']['url'])) {
    1040             $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
     998        $_this =& App::getInstance();
     999
     1000        if (!$_this->running) {
     1001            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     1002            return false;
     1003        }
     1004
     1005        if (!isset($_SESSION[$_this->app]['boomerang']['url'])) {
     1006            $_this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
    10411007            return false;
    10421008        }
     
    10451011        // a boomerang redirection will always occur at least several seconds after the last boomerang redirect
    10461012        // or a boomerang being set.
    1047         $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;
     1013        $boomerang_time = isset($_SESSION[$_this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0;
    10481014
    10491015        $url = '';
    1050         if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    1051             $url = $_SESSION[$this->app]['boomerang']['url'][$id];
     1016        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     1017            $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
    10521018        } else if (!isset($id) || $use_nonspecificboomerang) {
    10531019            // Use non specific boomerang if available.
    1054             $url = end($_SESSION[$this->app]['boomerang']['url']);
    1055         }
    1056 
    1057         $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1020            $url = end($_SESSION[$_this->app]['boomerang']['url']);
     1021        }
     1022
     1023        $_this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10581024
    10591025        if ('' == $url) {
    1060             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
     1026            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
    10611027            return false;
    10621028        }
    10631029        if ($url == absoluteMe()) {
    10641030            // The URL we are directing to is the current page.
    1065             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1031            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10661032            return false;
    10671033        }
    10681034        if ($boomerang_time >= (time() - 2)) {
    10691035            // Last boomerang direction was more than 2 seconds ago.
    1070             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
    1071             return false;
    1072         }
    1073 
    1074         $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1036            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
     1037            return false;
     1038        }
     1039
     1040        $_this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10751041        return true;
    10761042    }
     
    10821048    function sslOn()
    10831049    {
    1084         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1085             $this =& App::getInstance();
    1086         }
     1050        $_this =& App::getInstance();
    10871051
    10881052        if (function_exists('apache_get_modules')) {
     
    10931057        }
    10941058
    1095         if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
    1096             $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
     1059        if ('' == getenv('HTTPS') && $_this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
     1060            $_this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $_this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
    10971061            // Always append session because some browsers do not send cookie when crossing to SSL URL.
    1098             $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
     1062            $_this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
    10991063        }
    11001064    }
     
    11071071    function sslOff()
    11081072    {
    1109         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1110             $this =& App::getInstance();
    1111         }
     1073        $_this =& App::getInstance();
    11121074
    11131075        if ('' != getenv('HTTPS')) {
    1114             $this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);
     1076            $_this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);
    11151077        }
    11161078    }
  • tags/2.0.2/lib/DB.inc.php

    r71 r157  
    8585    function setParam($params)
    8686    {
    87         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    88             $this =& DB::getInstance();
    89         }
     87        $_this =& DB::getInstance();
    9088
    9189        if (isset($params) && is_array($params)) {
    9290            // Merge new parameters with old overriding only those passed.
    93             $this->_params = array_merge($this->_params, $params);
     91            $_this->_params = array_merge($_this->_params, $params);
    9492        } else {
    9593            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     
    108106    function getParam($param)
    109107    {
    110         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    111             $this =& DB::getInstance();
    112         }
    113 
    114         if (isset($this->_params[$param])) {
    115             return $this->_params[$param];
     108        $_this =& DB::getInstance();
     109
     110        if (isset($_this->_params[$param])) {
     111            return $_this->_params[$param];
    116112        } else {
    117113            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     
    129125    function connect()
    130126    {
    131         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    132             $this =& DB::getInstance();
    133         }
    134 
    135         if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) {
     127        $_this =& DB::getInstance();
     128
     129        if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) {
    136130            App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
    137131            return false;
     
    139133
    140134        // Connect to database. Always create a new link to the server.
    141         if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
     135        if ($_this->dbh = mysql_connect($_this->getParam('db_server'), $_this->getParam('db_user'), $_this->getParam('db_pass'), true)) {
    142136            // Select database
    143             mysql_select_db($this->getParam('db_name'), $this->dbh);
     137            mysql_select_db($_this->getParam('db_name'), $_this->dbh);
    144138        }
    145139
    146140        // Test for connection errors.
    147         if (!$this->dbh || mysql_error($this->dbh)) {
    148             $mysql_error_msg = $this->dbh ? 'Codebase MySQL error: (' . mysql_errno($this->dbh) . ') ' . mysql_error($this->dbh) : 'Codebase MySQL error: Could not connect to server.';
     141        if (!$_this->dbh || mysql_error($_this->dbh)) {
     142            $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.';
    149143            App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);
    150144
    151145            // Print helpful or pretty error?
    152             if ($this->getParam('db_debug')) {
     146            if ($_this->getParam('db_debug')) {
    153147                echo $mysql_error_msg . "\n";
    154148            } else {
     
    157151
    158152            // Die or continue without connection?
    159             if ($this->getParam('db_die_on_failure')) {
     153            if ($_this->getParam('db_die_on_failure')) {
    160154                echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
    161155                die;
     
    166160
    167161        // DB connection success!
    168         $this->_connected = true;
     162        $_this->_connected = true;
    169163
    170164        // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01.
    171         $this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");
     165        $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");
    172166
    173167        return true;
     
    183177    function close()
    184178    {
    185         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    186             $this =& DB::getInstance();
    187         }
    188 
    189         if (!$this->_connected) {
    190             return false;
    191         }
    192 
    193         mysql_close($this->dbh);
     179        $_this =& DB::getInstance();
     180
     181        if (!$_this->_connected) {
     182            return false;
     183        }
     184
     185        mysql_close($_this->dbh);
    194186    }
    195187
     
    198190     *
    199191     * @access  public
    200      * @return  resource Current value of $this->dbh.
     192     * @return  resource Current value of $_this->dbh.
    201193     * @author  Quinn Comendant <quinn@strangecode.com>
    202194     * @since   20 Aug 2005 13:50:36
     
    204196    function getDBH()
    205197    {
    206         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    207             $this =& DB::getInstance();
    208         }
    209 
    210         if (!$this->_connected) {
    211             return false;
    212         }
    213 
    214         return $this->dbh;
     198        $_this =& DB::getInstance();
     199
     200        if (!$_this->_connected) {
     201            return false;
     202        }
     203
     204        return $_this->dbh;
    215205    }
    216206
     
    224214    function isConnected()
    225215    {
    226         return $this->_connected;
     216        $_this =& DB::getInstance();
     217
     218        return $_this->_connected;
    227219    }
    228220   
     
    238230    function escapeString($string)
    239231    {
    240         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    241             $this =& DB::getInstance();
    242         }
    243         return mysql_real_escape_string($string, $this->dbh);
     232        $_this =& DB::getInstance();
     233
     234        return mysql_real_escape_string($string, $_this->dbh);
    244235    }
    245236
     
    256247        static $_query_count = 0;
    257248
    258         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    259             $this =& DB::getInstance();
    260         }
    261 
    262         if (!$this->_connected) {
     249        $_this =& DB::getInstance();
     250
     251        if (!$_this->_connected) {
    263252           return false;
    264253        }
     
    266255        $_query_count++;
    267256        $debugqry = preg_replace("/\n[\t ]+/", "\n", $query);
    268         if ($this->getParam('db_always_debug') || $debug) {
     257        if ($_this->getParam('db_always_debug') || $debug) {
    269258            echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n";
    270259        }
    271260
    272261        // Execute!
    273         $qid = mysql_query($query, $this->dbh);
     262        $qid = mysql_query($query, $_this->dbh);
    274263
    275264        // Error checking.
    276         if (!$qid || mysql_error($this->dbh)) {
    277             if ($this->getParam('db_debug')) {
    278                 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
     265        if (!$qid || mysql_error($_this->dbh)) {
     266            if ($_this->getParam('db_debug')) {
     267                echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($_this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
    279268            } else {
    280269                echo _("This page is temporarily unavailable. It should be back up in a few minutes.");
    281270            }
    282             App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
    283             if ($this->getParam('db_die_on_failure')) {
     271            App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
     272            if ($_this->getParam('db_die_on_failure')) {
    284273                echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
    285274                die;
     
    302291    function tableExists($table, $use_cached_results=true)
    303292    {
    304         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    305             $this =& DB::getInstance();
    306         }
    307 
    308         if (!$this->_connected) {
    309             return false;
    310         }
    311 
    312         if (!isset($this->existing_tables) || !$use_cached_results) {
    313             $this->existing_tables = array();
    314             $qid = $this->query("SHOW TABLES");
     293        $_this =& DB::getInstance();
     294
     295        if (!$_this->_connected) {
     296            return false;
     297        }
     298
     299        if (!isset($_this->existing_tables) || !$use_cached_results) {
     300            $_this->existing_tables = array();
     301            $qid = $_this->query("SHOW TABLES");
    315302            while (list($row) = mysql_fetch_row($qid)) {
    316                 $this->existing_tables[] = $row;
    317             }
    318         }
    319         if (in_array($table, $this->existing_tables)) {
     303                $_this->existing_tables[] = $row;
     304            }
     305        }
     306        if (in_array($table, $_this->existing_tables)) {
    320307            return true;
    321308        } else {
    322             App::logMsg(sprintf('nonexistent DB table: %s.%s', $this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
     309            App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
    323310            return false;
    324311        }
     
    336323    function columnExists($table, $columns, $strict=true, $use_cached_results=true)
    337324    {
    338         if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) {
    339             $this =& DB::getInstance();
    340         }
    341 
    342         if (!$this->_connected) {
     325        $_this =& DB::getInstance();
     326
     327        if (!$_this->_connected) {
    343328            return false;
    344329        }
    345330
    346331        // Ensure the table exists.
    347         if (!$this->tableExists($table, $use_cached_results)) {
     332        if (!$_this->tableExists($table, $use_cached_results)) {
    348333            return false;
    349334        }
     
    354339        }
    355340
    356         if (!isset($this->table_columns[$table]) || !$use_cached_results) {
     341        if (!isset($_this->table_columns[$table]) || !$use_cached_results) {
    357342            // Populate and cache array of current columns for this table.
    358             $this->table_columns[$table] = array();
    359             $qid = $this->query("DESCRIBE $table");
     343            $_this->table_columns[$table] = array();
     344            $qid = $_this->query("DESCRIBE $table");
    360345            while ($row = mysql_fetch_row($qid)) {
    361                 $this->table_columns[$table][] = $row[0];
     346                $_this->table_columns[$table][] = $row[0];
    362347            }
    363348        }
     
    366351            // Do an exact comparison of table schemas.
    367352            sort($columns);
    368             sort($this->table_columns[$table]);
    369             return $this->table_columns[$table] == $columns;
     353            sort($_this->table_columns[$table]);
     354            return $_this->table_columns[$table] == $columns;
    370355        } else {
    371356            // Only check that the specified columns are available in the table.
    372             $match_columns = array_intersect($this->table_columns[$table], $columns);
     357            $match_columns = array_intersect($_this->table_columns[$table], $columns);
    373358            sort($columns);
    374359            sort($match_columns);
     
    386371    function resetCache()
    387372    {
    388         $this->existing_tables = null;
    389         $this->table_columns = null;
     373        $_this->existing_tables = null;
     374        $_this->table_columns = null;
    390375    }
    391376
  • tags/2.0.2/lib/SessionCache.inc.php

    r53 r157  
    4444    function setParam($params)
    4545    {
    46         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    47             $this =& SessionCache::getInstance();
    48         }
     46        $_this =& SessionCache::getInstance();
    4947
    5048        if (isset($params) && is_array($params)) {
    5149            // Merge new parameters with old overriding only those passed.
    52             $this->_params = array_merge($this->_params, $params);
     50            $_this->_params = array_merge($_this->_params, $params);
    5351        } else {
    5452            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     
    6563    function getParam($param)
    6664    {
    67         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    68             $this =& SessionCache::getInstance();
    69         }
    70 
    71         if (isset($this->_params[$param])) {
    72             return $this->_params[$param];
     65        $_this =& SessionCache::getInstance();
     66
     67        if (isset($_this->_params[$param])) {
     68            return $_this->_params[$param];
    7369        } else {
    7470            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     
    9591    function putCache($var, $var_id, $force_it_in=false)
    9692    {
    97         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    98             $this =& SessionCache::getInstance();
    99         }
    100 
    101         if (!$this->getParam('enabled')) {
     93        $_this =& SessionCache::getInstance();
     94
     95        if (!$_this->getParam('enabled')) {
    10296            App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
    10397            return false;
     
    108102        $serialized_var_len = strlen($serialized_var);
    109103
    110         if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) {
    111             App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
    112             return false;
    113         }
    114 
    115         if ($serialized_var_len >= $this->getParam('hard_limit')) {
    116             App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
     104        if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) {
     105            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
     106            return false;
     107        }
     108
     109        if ($serialized_var_len >= $_this->getParam('hard_limit')) {
     110            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
    117111            return false;
    118112        }
     
    123117            unset($_SESSION['_session_cache'][$var_id]);
    124118            // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least.
    125             while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit')
    126             && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
     119            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit')
     120            && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) {
    127121                array_shift($_SESSION['_session_cache']);
    128122            }
     
    149143    function getCache($var_id)
    150144    {
    151         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    152             $this =& SessionCache::getInstance();
    153         }
    154 
    155         if (!$this->getParam('enabled')) {
     145        $_this =& SessionCache::getInstance();
     146
     147        if (!$_this->getParam('enabled')) {
    156148            return false;
    157149        }
     
    179171    function isCached($var_id)
    180172    {
    181         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    182             $this =& SessionCache::getInstance();
    183         }
    184 
    185         if (!$this->getParam('enabled')) {
     173        $_this =& SessionCache::getInstance();
     174
     175        if (!$_this->getParam('enabled')) {
    186176            return false;
    187177        }
  • tags/2.0.2/tests/Auth_SQLTest.php

    r126 r157  
    108108        $this->assertTrue($true, 'User login failed, but should have succeeded.');
    109109
    110         echo "Testing wrong password...\n";
     110        // echo "Testing wrong password...\n";
    111111        $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass');
    112112
     
    124124        $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
    125125
    126         echo "Testing wrong password...\n";
     126        // echo "Testing wrong password...\n";
    127127        $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
    128128        $this->assertFalse($login2, '4. User login succeeded, but should have failed.');
  • tags/2.0.2/tests/EmailTest.php

    r42 r157  
    9494        $this->assertEquals(41, $gc, 'Unexpected good count.');
    9595        $this->assertEquals(47, $bc, 'Unexpected bad count.');
    96         echo "Good addresses: $gc\n";
    97         echo "Bad addresses: $bc\n";
     96        // echo "Good addresses: $gc\n";
     97        // echo "Bad addresses: $bc\n";
    9898//         echo join("\n", $bad);
    9999//         echo "\n";
Note: See TracChangeset for help on using the changeset viewer.