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.

File:
1 edited

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    }
Note: See TracChangeset for help on using the changeset viewer.