Changeset 119 for trunk/lib/App.inc.php


Ignore:
Timestamp:
May 20, 2006 2:12:12 AM (18 years ago)
Author:
scdev
Message:

Q - making codebase 2 work with php5. Rewrote ImageThumb? class to work with GD

File:
1 edited

Legend:

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

    r108 r119  
    1616define('MSG_NOTICE', 4);
    1717define('MSG_SUCCESS', 8);
     18define('MSG_ALL', MSG_SUCCESS | MSG_NOTICE | MSG_WARNING | MSG_ERROR);
    1819
    1920require_once dirname(__FILE__) . '/Utilities.inc.php';
     
    163164    function setParam($param=null)
    164165    {
    165         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    166             $this =& App::getInstance();
     166        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
     167            $_this =& App::getInstance();
    167168        }
    168169
    169170        if (isset($param) && is_array($param)) {
    170171            // Merge new parameters with old overriding only those passed.
    171             $this->_params = array_merge($this->_params, $param);
     172            $_this->_params = array_merge($_this->_params, $param);
    172173        }
    173174    }
     
    182183    function &getParam($param=null)
    183184    {
    184         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    185             $this =& App::getInstance();
     185        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
     186            $_this =& App::getInstance();
    186187        }
    187188
    188189        if ($param === null) {
    189             return $this->_params;
    190         } else if (isset($this->_params[$param])) {
    191             return $this->_params[$param];
     190            return $_this->_params;
     191        } else if (isset($_this->_params[$param])) {
     192            return $_this->_params[$param];
    192193        } else {
    193194            trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);
     
    359360    function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
    360361    {
    361         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    362             $this =& App::getInstance();
     362        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
     363            $_this =& App::getInstance();
    363364        }
    364365
    365366        $message = trim($message);
    366367
    367         if (!$this->running || '' == $message) {
    368             $this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    369370            return false;
    370371        }
     
    372373        // Save message in session under unique key to avoid duplicate messages.
    373374        $msg_id = md5($type . $message . $file . $line);
    374         $_SESSION[$this->app]['messages'][$msg_id] = array(
     375        $_SESSION[$_this->app]['messages'][$msg_id] = array(
    375376            'type'    => $type,
    376377            'message' => $message,
    377378            'file'    => $file,
    378379            'line'    => $line,
    379             'count'   => (isset($_SESSION[$this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->app]['messages'][$msg_id]['count']) : 1)
     380            'count'   => (isset($_SESSION[$_this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1)
    380381        );
    381382
    382383        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
    383             $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
     384            $_this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
    384385        }
    385386    }
     
    395396    function getRaisedMessages()
    396397    {
    397         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    398             $this =& App::getInstance();
    399         }
    400 
    401         if (!$this->running) {
    402             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    403404            return false;
    404405        }
    405406       
    406407        $output = array();
    407         while (isset($_SESSION[$this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {
     408        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
    408409            $output[] = $message;
    409410        }
     
    420421    function clearRaisedMessages()
    421422    {
    422         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    423             $this =& App::getInstance();
    424         }
    425 
    426         if (!$this->running) {
    427             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    428429            return false;
    429430        }
    430431       
    431         $_SESSION[$this->app]['messages'] = array();
     432        $_SESSION[$_this->app]['messages'] = array();
    432433    }
    433434
     
    441442    function printRaisedMessages()
    442443    {
    443         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    444             $this =& App::getInstance();
    445         }
    446 
    447         if (!$this->running) {
    448             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    449             return false;
    450         }
    451 
    452         while (isset($_SESSION[$this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {
     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'])) {
    453454            ?><div class="sc-msg"><?php
    454             if (error_reporting() > 0 && $this->getParam('display_errors')) {
     455            if (error_reporting() > 0 && $_this->getParam('display_errors')) {
    455456                echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->';
    456457            }
     
    500501        static $previous_events = array();
    501502
    502         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    503             $this =& App::getInstance();
     503        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
     504            $_this =& App::getInstance();
    504505        }
    505506
    506507        // If priority is not specified, assume the worst.
    507         if (!$this->logPriorityToString($priority)) {
    508             $this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
     508        if (!$_this->logPriorityToString($priority)) {
     509            $_this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
    509510            $priority = LOG_EMERG;
    510511        }
    511512
    512513        // If log file is not specified, don't log to a file.
    513         if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) {
    514             $this->setParam(array('log_file_priority' => false));
     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));
    515516            // We must use trigger_error to report this problem rather than calling App::logMsg, which might lead to an infinite loop.
    516             trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
     517            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE);
    517518        }
    518519
     
    530531            $previous_events[$msg_id]++;
    531532            if ($previous_events[$msg_id] == 2) {
    532                 $this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
     533                $_this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
    533534            }
    534535            return false;
     
    542543            'remote ip' => getRemoteAddr(),
    543544            'pid'       => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''),
    544             'type'      => $this->logPriorityToString($priority),
     545            'type'      => $_this->logPriorityToString($priority),
    545546            'file:line' => "$file : $line",
    546547            'url'       => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''),
     
    549550
    550551        // FILE ACTION
    551         if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
     552        if ($_this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) {
    552553            $event_str = '[' . join('] [', $event) . ']';
    553             error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
     554            error_log($event_str . "\n", 3, $_this->getParam('log_directory') . '/' . $_this->getParam('log_filename'));
    554555        }
    555556
    556557        // EMAIL ACTION
    557         if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {
     558        if ($_this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) {
    558559            $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message);
    559560            $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST'));
     
    562563                $email_msg .= sprintf("%-11s%s\n", $k, $v);
    563564            }
    564             mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
     565            mail($_this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
    565566        }
    566567
    567568        // SMS ACTION
    568         if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
     569        if ($_this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) {
    569570            $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority);
    570571            $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line);
    571572            $headers = "From: codebase@strangecode.com";
    572             mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
     573            mail($_this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
    573574        }
    574575
    575576        // SCREEN ACTION
    576         if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
     577        if ($_this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) {
    577578            echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n";
    578579        }
     
    619620    function carryQuery($query_key)
    620621    {
    621         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    622             $this =& App::getInstance();
     622        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
     623            $_this =& App::getInstance();
    623624        }
    624625
    625626        // If not already set, and there is a non-empty value provided in the request...
    626         if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
     627        if (!isset($_this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
    627628            // Copy the value of the specified query argument into the _carry_queries array.
    628             $this->_carry_queries[$query_key] = getFormData($query_key);
     629            $_this->_carry_queries[$query_key] = getFormData($query_key);
    629630        }
    630631    }
     
    651652    function url($url, $carry_args=null, $always_include_sid=false)
    652653    {
    653         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    654             $this =& App::getInstance();
    655         }
    656 
    657         if (!$this->running) {
    658             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    659660            return false;
    660661        }
     
    690691        if ($do_carry_queries) {
    691692            // Join the global _carry_queries and local one_time_carry_queries.
    692             $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
     693            $query_args = urlEncodeArray(array_merge($_this->_carry_queries, $one_time_carry_queries));
    693694            foreach ($query_args as $key=>$val) {
    694695                // Check value is set and value does not already exist in the url.
     
    714715                    (
    715716                        !isset($_COOKIE[session_name()])
    716                         || !$this->getParam('session_use_cookies')
     717                        || !$_this->getParam('session_use_cookies')
    717718                    )
    718                     && $this->getParam('enable_session')
     719                    && $_this->getParam('enable_session')
    719720                    && isMyDomain($url)
    720721                    &&
     
    747748    function oHREF($url, $carry_args=null, $always_include_sid=false)
    748749    {
    749         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    750             $this =& App::getInstance();
    751         }
    752 
    753         $url = $this->url($url, $carry_args, $always_include_sid);
     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);
    754755
    755756        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
     
    771772    function printHiddenSession($carry_args=null)
    772773    {
    773         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    774             $this =& App::getInstance();
    775         }
    776 
    777         if (!$this->running) {
    778             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    779780            return false;
    780781        }
     
    807808            // Join the global _carry_queries and local one_time_carry_queries.
    808809            // urlencode is not used here, not for form data!
    809             $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
     810            $query_args = array_merge($_this->_carry_queries, $one_time_carry_queries);
    810811            foreach ($query_args as $key=>$val) {
    811812                echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
     
    834835    function dieURL($url, $carry_args=null, $always_include_sid=false)
    835836    {
    836         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    837             $this =& App::getInstance();
    838         }
    839 
    840         if (!$this->running) {
    841             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    842843            return false;
    843844        }
     
    845846        if ('' == $url) {
    846847            // If URL is not specified, use the redirect_home_url.
    847             $url = $this->getParam('redirect_home_url');
     848            $url = $_this->getParam('redirect_home_url');
    848849        }
    849850
     
    855856        }
    856857
    857         $url = $this->url($url, $carry_args, $always_include_sid);
     858        $url = $_this->url($url, $carry_args, $always_include_sid);
    858859
    859860        header(sprintf('Location: %s', $url));
    860         $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
     861        $_this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    861862
    862863        // End this application.
    863864        // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
    864         $this->stop();
     865        $_this->stop();
    865866        die;
    866867    }
     
    883884    function dieBoomerangURL($id=null, $carry_args=null, $default_url=null)
    884885    {
    885         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    886             $this =& App::getInstance();
    887         }
    888 
    889         if (!$this->running) {
    890             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    891892            return false;
    892893        }
    893894
    894895        // Get URL from stored boomerang. Allow non specific URL if ID not valid.
    895         if ($this->validBoomerangURL($id, true)) {
    896             if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    897                 $url = $_SESSION[$this->app]['boomerang']['url'][$id];
    898                 $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    899900            } else {
    900                 $url = end($_SESSION[$this->app]['boomerang']['url']);
    901                 $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     901                $url = end($_SESSION[$_this->app]['boomerang']['url']);
     902                $_this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    902903            }
    903904            // Delete stored boomerang.
    904             $this->deleteBoomerangURL($id);
     905            $_this->deleteBoomerangURL($id);
    905906        } else if (isset($default_url)) {
    906907            $url = $default_url;
     
    908909            // Ensure that the redirecting page is not also the referrer.
    909910            $url = getenv('HTTP_REFERER');
    910             $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     911            $_this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    911912        } else {
    912913            // If URL is not specified, use the redirect_home_url.
    913             $url = $this->getParam('redirect_home_url');
    914             $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    915916        }
    916917
    917918        // A redirection will never happen immediately twice.
    918919        // Set the time so ensure this doesn't happen.
    919         $_SESSION[$this->app]['boomerang']['time'] = time();
    920         $this->dieURL($url, $carry_args);
     920        $_SESSION[$_this->app]['boomerang']['time'] = time();
     921        $_this->dieURL($url, $carry_args);
    921922    }
    922923
     
    930931    function setBoomerangURL($url=null, $id=null)
    931932    {
    932         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    933             $this =& App::getInstance();
    934         }
    935 
    936         if (!$this->running) {
    937             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    938939            return false;
    939940        }
     
    945946            $url = preg_replace('/boomerang=[\w]+/', '', $url);
    946947
    947             if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {
     948            if (isset($_SESSION[$_this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) {
    948949                // If the URL currently exists in the boomerang array, delete.
    949                 while ($existing_key = array_search($url, $_SESSION[$this->app]['boomerang']['url'])) {
    950                     unset($_SESSION[$this->app]['boomerang']['url'][$existing_key]);
     950                while ($existing_key = array_search($url, $_SESSION[$_this->app]['boomerang']['url'])) {
     951                    unset($_SESSION[$_this->app]['boomerang']['url'][$existing_key]);
    951952                }
    952953            }
    953954
    954955            if (isset($id)) {
    955                 $_SESSION[$this->app]['boomerang']['url'][$id] = $url;
     956                $_SESSION[$_this->app]['boomerang']['url'][$id] = $url;
    956957            } else {
    957                 $_SESSION[$this->app]['boomerang']['url'][] = $url;
    958             }
    959             $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     958                $_SESSION[$_this->app]['boomerang']['url'][] = $url;
     959            }
     960            $_this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    960961            return true;
    961962        } else {
    962             $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
     963            $_this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
    963964            return false;
    964965        }
     
    972973    function getBoomerangURL($id=null)
    973974    {
    974         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    975             $this =& App::getInstance();
    976         }
    977 
    978         if (!$this->running) {
    979             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    980981            return false;
    981982        }
    982983
    983984        if (isset($id)) {
    984             if (isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    985                 return $_SESSION[$this->app]['boomerang']['url'][$id];
     985            if (isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     986                return $_SESSION[$_this->app]['boomerang']['url'][$id];
    986987            } else {
    987988                return '';
    988989            }
    989         } else if (is_array($_SESSION[$this->app]['boomerang']['url'])) {
    990             return end($_SESSION[$this->app]['boomerang']['url']);
     990        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
     991            return end($_SESSION[$_this->app]['boomerang']['url']);
    991992        } else {
    992993            return false;
     
    10011002    function deleteBoomerangURL($id=null)
    10021003    {
    1003         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1004             $this =& App::getInstance();
    1005         }
    1006 
    1007         if (!$this->running) {
    1008             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    1009             return false;
    1010         }
    1011 
    1012         $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
    1013 
    1014         if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    1015             unset($_SESSION[$this->app]['boomerang']['url'][$id]);
    1016         } else if (is_array($_SESSION[$this->app]['boomerang']['url'])) {
    1017             array_pop($_SESSION[$this->app]['boomerang']['url']);
     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']);
    10181019        }
    10191020    }
     
    10271028    function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
    10281029    {
    1029         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1030             $this =& App::getInstance();
    1031         }
    1032 
    1033         if (!$this->running) {
    1034             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
    1035             return false;
    1036         }
    1037 
    1038         if (!isset($_SESSION[$this->app]['boomerang']['url'])) {
    1039             $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    10401041            return false;
    10411042        }
     
    10441045        // a boomerang redirection will always occur at least several seconds after the last boomerang redirect
    10451046        // or a boomerang being set.
    1046         $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;
     1047        $boomerang_time = isset($_SESSION[$_this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0;
    10471048
    10481049        $url = '';
    1049         if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    1050             $url = $_SESSION[$this->app]['boomerang']['url'][$id];
     1050        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
     1051            $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
    10511052        } else if (!isset($id) || $use_nonspecificboomerang) {
    10521053            // Use non specific boomerang if available.
    1053             $url = end($_SESSION[$this->app]['boomerang']['url']);
    1054         }
    1055 
    1056         $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1054            $url = end($_SESSION[$_this->app]['boomerang']['url']);
     1055        }
     1056
     1057        $_this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10571058
    10581059        if ('' == $url) {
    1059             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
     1060            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
    10601061            return false;
    10611062        }
    10621063        if ($url == absoluteMe()) {
    10631064            // The URL we are directing to is the current page.
    1064             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1065            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    10651066            return false;
    10661067        }
    10671068        if ($boomerang_time >= (time() - 2)) {
    10681069            // Last boomerang direction was more than 2 seconds ago.
    1069             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
    1070             return false;
    1071         }
    1072 
    1073         $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     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__);
    10741075        return true;
    10751076    }
     
    10811082    function sslOn()
    10821083    {
    1083         if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
    1084             $this =& App::getInstance();
     1084        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
     1085            $_this =& App::getInstance();
    10851086        }
    10861087
     
    10921093        }
    10931094
    1094         if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
    1095             $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
     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__);
    10961097            // Always append session because some browsers do not send cookie when crossing to SSL URL.
    1097             $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
     1098            $_this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
    10981099        }
    10991100    }
Note: See TracChangeset for help on using the changeset viewer.