source: trunk/lib/App.inc.php @ 282

Last change on this file since 282 was 282, checked in by quinn, 17 years ago

Added length arg to *Signature functions; added App::setQuery() method; FormValidator? msg rewording.

File size: 46.8 KB
RevLine 
[1]1<?php
2/**
3 * App.inc.php
4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
5 *
6 * Primary application framework class.
7 *
8 * @author  Quinn Comendant <quinn@strangecode.com>
[136]9 * @version 2.1
[1]10 */
[42]11
[37]12// Message Types.
13define('MSG_ERR', 1);
14define('MSG_ERROR', MSG_ERR);
[1]15define('MSG_WARNING', 2);
[37]16define('MSG_NOTICE', 4);
17define('MSG_SUCCESS', 8);
[119]18define('MSG_ALL', MSG_SUCCESS | MSG_NOTICE | MSG_WARNING | MSG_ERROR);
[1]19
20require_once dirname(__FILE__) . '/Utilities.inc.php';
21
22class App {
[42]23
[136]24    // Namespace of this application instance.
25    var $_ns;
[1]26
[136]27    // If $app->start has run successfully.
[1]28    var $running = false;
29
30    // Instance of database object.
31    var $db;
[42]32
[20]33    // Array of query arguments will be carried persistently between requests.
34    var $_carry_queries = array();
[1]35
[136]36    // Dictionary of global application parameters.
[1]37    var $_params = array();
38
39    // Default parameters.
40    var $_param_defaults = array(
41
42        // Public name and email address for this application.
43        'site_name' => null,
44        'site_email' => null,
[39]45        'site_url' => '', // URL automatically determined by _SERVER['HTTP_HOST'] if not set here.
[1]46
[136]47        // The location the user will go if the system doesn't know where else to send them.
[1]48        'redirect_home_url' => '/',
[42]49
[136]50        // SSL URL used when redirecting with $app->sslOn().
[1]51        'ssl_domain' => null,
52        'ssl_enabled' => false,
[42]53
[20]54        // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag.
[1]55        'character_set' => 'utf-8',
56
57        // Human-readable format used to display dates.
58        'date_format' => 'd M Y',
[101]59        'time_format' => 'h:i:s A',
[1]60        'sql_date_format' => '%e %b %Y',
61        'sql_time_format' => '%k:%i',
62
63        // Use php sessions?
64        'enable_session' => false,
[242]65        'session_name' => '_session',
[1]66        'session_use_cookies' => true,
[242]67        'session_use_trans_sid' => false,
[42]68
[1]69        // Use database?
70        'enable_db' => false,
71
72        // Use db-based sessions?
73        'enable_db_session_handler' => false,
[42]74
[1]75        // DB passwords should be set as apache environment variables in httpd.conf, readable only by root.
76        'db_server' => 'localhost',
77        'db_name' => null,
78        'db_user' => null,
79        'db_pass' => null,
80
81        // Database debugging.
82        'db_always_debug' => false, // TRUE = display all SQL queries.
83        'db_debug' => false, // TRUE = display db errors.
84        'db_die_on_failure' => false, // TRUE = script stops on db error.
[42]85
[1]86        // For classes that require db tables, do we check that a table exists and create if missing?
[32]87        'db_create_tables' => true,
[1]88
[136]89        // The level of error reporting. Don't change this to suppress messages, instead use display_errors to control display.
[1]90        'error_reporting' => E_ALL,
91
92        // Don't display errors by default; it is preferable to log them to a file.
93        'display_errors' => false,
[42]94
[1]95        // Directory in which to store log files.
[19]96        'log_directory' => '',
[1]97
98        // PHP error log.
99        'php_error_log' => 'php_error_log',
100
101        // General application log.
[136]102        'log_filename' => 'app_log',
[1]103
104        // Logging priority can be any of the following, or false to deactivate:
105        // LOG_EMERG     system is unusable
106        // LOG_ALERT     action must be taken immediately
107        // LOG_CRIT      critical conditions
108        // LOG_ERR       error conditions
109        // LOG_WARNING   warning conditions
110        // LOG_NOTICE    normal, but significant, condition
111        // LOG_INFO      informational message
112        // LOG_DEBUG     debug-level message
[174]113        'log_file_priority' => LOG_INFO,
[1]114        'log_email_priority' => false,
115        'log_sms_priority' => false,
116        'log_screen_priority' => false,
[42]117
[1]118        // Email address to receive log event emails.
119        'log_to_email_address' => null,
[42]120
[19]121        // SMS Email address to receive log event SMS messages.
[1]122        'log_to_sms_address' => null,
[42]123
[19]124        // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>'.
[136]125        // Existing password hashes rely on the same key/salt being used to compare encryptions.
126        // Don't change this unless you know existing hashes or signatures will not be affected!
[1]127        'signing_key' => 'aae6abd6209d82a691a9f96384a7634a',
128    );
[42]129
[1]130    /**
131     * This method enforces the singleton pattern for this class. Only one application is running at a time.
132     *
[136]133     * $param   string  $namespace  Name of this application.
134     * @return  object  Reference to the global Cache object.
[1]135     * @access  public
136     * @static
137     */
[136]138    function &getInstance($namespace='')
[1]139    {
140        static $instance = null;
141
142        if ($instance === null) {
[136]143            $instance = new App($namespace);
[1]144        }
145
146        return $instance;
147    }
[42]148
[1]149    /**
150     * Constructor.
151     */
[136]152    function App($namespace='')
[1]153    {
[136]154        // Set namespace of application instance.
[154]155        $this->_ns = $namespace;
[42]156
[1]157        // Initialize default parameters.
158        $this->_params = array_merge($this->_params, $this->_param_defaults);
[172]159       
160        // Begin timing script.
161        require_once dirname(__FILE__) . '/ScriptTimer.inc.php';
162        $this->timer = new ScriptTimer();
163        $this->timer->start('_app');
[1]164    }
165
166    /**
167     * Set (or overwrite existing) parameters by passing an array of new parameters.
168     *
169     * @access public
170     * @param  array    $param     Array of parameters (key => val pairs).
171     */
172    function setParam($param=null)
173    {
174        if (isset($param) && is_array($param)) {
175            // Merge new parameters with old overriding only those passed.
[136]176            $this->_params = array_merge($this->_params, $param);
[1]177        }
178    }
179
180    /**
181     * Return the value of a parameter.
182     *
183     * @access  public
184     * @param   string  $param      The key of the parameter to return.
185     * @return  mixed               Parameter value, or null if not existing.
186     */
[136]187    function getParam($param=null)
[1]188    {
189        if ($param === null) {
[136]190            return $this->_params;
191        } else if (isset($this->_params[$param])) {
192            return $this->_params[$param];
[1]193        } else {
[19]194            trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);
[1]195            return null;
196        }
197    }
[42]198
[1]199    /**
200     * Begin running this application.
201     *
202     * @access  public
203     * @author  Quinn Comendant <quinn@strangecode.com>
204     * @since   15 Jul 2005 00:32:21
205     */
206    function start()
207    {
208        if ($this->running) {
209            return false;
210        }
[42]211
[1]212        // Error reporting.
213        ini_set('error_reporting', $this->getParam('error_reporting'));
214        ini_set('display_errors', $this->getParam('display_errors'));
215        ini_set('log_errors', true);
216        if (is_dir($this->getParam('log_directory')) && is_writable($this->getParam('log_directory'))) {
217            ini_set('error_log', $this->getParam('log_directory') . '/' . $this->getParam('php_error_log'));
218        }
[42]219
[248]220        // Set character set to use for multi-byte string functions.
221        mb_internal_encoding($this->getParam('character_set'));
[249]222        switch (mb_strtolower($this->getParam('character_set'))) {
223        case 'utf-8' :
224            mb_language('uni');
225            break;
[42]226
[249]227        case 'iso-2022-jp' :
228            mb_language('ja');
229            break;
230
231        case 'iso-8859-1' :
232        default :
233            mb_language('en');
234            break;
235        }
236
[1]237        /**
238         * 1. Start Database.
239         */
[42]240
[103]241        if (true === $this->getParam('enable_db')) {
[42]242
[1]243            // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root.
244            if (!empty($_SERVER['DB_SERVER'])) {
245                $this->setParam(array('db_server' => $_SERVER['DB_SERVER']));
246            }
247            if (!empty($_SERVER['DB_NAME'])) {
248                $this->setParam(array('db_name' => $_SERVER['DB_NAME']));
249            }
250            if (!empty($_SERVER['DB_USER'])) {
251                $this->setParam(array('db_user' => $_SERVER['DB_USER']));
252            }
253            if (!empty($_SERVER['DB_PASS'])) {
254                $this->setParam(array('db_pass' => $_SERVER['DB_PASS']));
255            }
[42]256
[136]257            // There will ever only be one instance of the DB object, and here is where it is instantiated.
[1]258            require_once dirname(__FILE__) . '/DB.inc.php';
259            $this->db =& DB::getInstance();
260            $this->db->setParam(array(
261                'db_server' => $this->getParam('db_server'),
262                'db_name' => $this->getParam('db_name'),
263                'db_user' => $this->getParam('db_user'),
264                'db_pass' => $this->getParam('db_pass'),
265                'db_always_debug' => $this->getParam('db_always_debug'),
266                'db_debug' => $this->getParam('db_debug'),
267                'db_die_on_failure' => $this->getParam('db_die_on_failure'),
268            ));
269
270            // Connect to database.
271            $this->db->connect();
272        }
[42]273
274
[1]275        /**
276         * 2. Start PHP session.
277         */
[42]278
[1]279        // Skip session for some user agents.
280        if (preg_match('/Atomz|ApacheBench|Wget/i', getenv('HTTP_USER_AGENT'))) {
281            $this->setParam(array('enable_session' => false));
282        }
[42]283
[1]284        if (true === $this->getParam('enable_session')) {
[42]285
[1]286            if (true === $this->getParam('enable_db_session_handler') && true === $this->getParam('enable_db')) {
287                // Database session handling.
288                require_once dirname(__FILE__) . '/DBSessionHandler.inc.php';
289                $db_save_handler = new DBSessionHandler($this->db, array(
290                    'db_table' => 'session_tbl',
291                    'create_table' => $this->getParam('db_create_tables'),
292                ));
293            }
[42]294
[1]295            // Session parameters.
296            ini_set('session.use_cookies', $this->getParam('session_use_cookies'));
297            ini_set('session.use_trans_sid', false);
298            ini_set('session.entropy_file', '/dev/urandom');
299            ini_set('session.entropy_length', '512');
300            session_name($this->getParam('session_name'));
[42]301
[22]302            // Start the session.
[1]303            session_start();
[42]304
[154]305            if (!isset($_SESSION['_app'][$this->_ns])) {
[22]306                // Access session data using: $_SESSION['...'].
307                // Initialize here _after_ session has started.
[154]308                $_SESSION['_app'][$this->_ns] = array(
[22]309                    'messages' => array(),
310                    'boomerang' => array('url'),
311                );
312            }
[1]313        }
[42]314
315
[1]316        /**
317         * 3. Misc setup.
318         */
319
320        // Script URI will be something like http://host.name.tld (no ending slash)
321        // and is used whenever a URL need be used to the current site.
322        // Not available on cli scripts obviously.
[41]323        if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_url')) {
[14]324            $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'))));
[1]325        }
326
327        // A key for calculating simple cryptographic signatures.
328        if (isset($_SERVER['SIGNING_KEY'])) {
329            $this->setParam(array('signing_key' => $_SERVER['SIGNING_KEY']));
330        }
[42]331
[1]332        // Character set. This should also be printed in the html header template.
333        header('Content-type: text/html; charset=' . $this->getParam('character_set'));
[136]334       
335        // Set the version of the codebase we're using.
336        $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt';
337        if (is_readable($codebase_version_file)) {
338            $codebase_version = trim(file_get_contents($codebase_version_file));
[144]339            $this->setParam(array('codebase_version' => $codebase_version));
[136]340            header('X-Codebase-Version: ' . $codebase_version);
341        }
[42]342
[1]343        $this->running = true;
344    }
[42]345
[1]346    /**
347     * Stop running this application.
348     *
349     * @access  public
350     * @author  Quinn Comendant <quinn@strangecode.com>
351     * @since   17 Jul 2005 17:20:18
352     */
353    function stop()
354    {
355        session_write_close();
356        restore_include_path();
357        $this->running = false;
[172]358        $num_queries = 0;
[103]359        if (true === $this->getParam('enable_db')) {
[172]360            $num_queries = $this->db->numQueries();
[103]361            $this->db->close();
362        }
[172]363        $this->timer->stop('_app');
[202]364        $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s.', $this->timer->getTime('_app'), $num_queries), LOG_DEBUG, __FILE__, __LINE__);
[1]365    }
[42]366
367
[1]368    /**
[84]369     * Add a message to the session, which is printed in the header.
[1]370     * Just a simple way to print messages to the user.
371     *
372     * @access public
373     *
374     * @param string $message The text description of the message.
375     * @param int    $type    The type of message: MSG_NOTICE,
376     *                        MSG_SUCCESS, MSG_WARNING, or MSG_ERR.
377     * @param string $file    __FILE__.
378     * @param string $line    __LINE__.
379     */
380    function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
381    {
[32]382        $message = trim($message);
[1]383
[203]384        if (!$this->running) {
385            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]386            return false;
387        }
[42]388
[203]389        if ('' == trim($message)) {
390            $this->logMsg(sprintf('Raised message is an empty string.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
391            return false;
392        }
393
[37]394        // Save message in session under unique key to avoid duplicate messages.
[177]395        $msg_id = md5($type . $message);
396        if (!isset($_SESSION['_app'][$this->_ns]['messages'][$msg_id])) {
397            $_SESSION['_app'][$this->_ns]['messages'][$msg_id] = array(
398                'type'    => $type,
399                'message' => $message,
400                'file'    => $file,
401                'line'    => $line,
402                'count'   => (isset($_SESSION['_app'][$this->_ns]['messages'][$msg_id]['count']) ? (1 + $_SESSION['_app'][$this->_ns]['messages'][$msg_id]['count']) : 1)
403            );
404        }
[42]405
[1]406        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
[136]407            $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__);
[1]408        }
409    }
[46]410   
411    /**
412     * Returns an array of the raised messages.
413     *
414     * @access  public
415     * @return  array   List of messags in FIFO order.
416     * @author  Quinn Comendant <quinn@strangecode.com>
417     * @since   21 Dec 2005 13:09:20
418     */
419    function getRaisedMessages()
420    {
[136]421        if (!$this->running) {
422            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
423            return false;
[46]424        }
[42]425
[154]426        return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array();
[46]427    }
428   
[1]429    /**
[46]430     * Resets the message list.
431     *
432     * @access  public
433     * @author  Quinn Comendant <quinn@strangecode.com>
434     * @since   21 Dec 2005 13:21:54
435     */
436    function clearRaisedMessages()
437    {
[136]438        if (!$this->running) {
439            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[46]440            return false;
441        }
442       
[154]443        $_SESSION['_app'][$this->_ns]['messages'] = array();
[46]444    }
445
446    /**
[1]447     * Prints the HTML for displaying raised messages.
448     *
449     * @access  public
450     * @author  Quinn Comendant <quinn@strangecode.com>
451     * @since   15 Jul 2005 01:39:14
452     */
453    function printRaisedMessages()
454    {
[136]455        if (!$this->running) {
456            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]457            return false;
458        }
[136]459       
460        $messages = $this->getRaisedMessages();
[167]461        if (!empty($messages)) {
[163]462            ?><div id="sc-msg" class="sc-msg"><?php
[167]463            foreach ($messages as $m) {
464                if (error_reporting() > 0 && $this->getParam('display_errors') && isset($m['file']) && isset($m['line'])) {
465                    echo "\n<!-- [" . $m['file'] . ' : ' . $m['line'] . '] -->';
466                }
467                switch ($m['type']) {
468                case MSG_ERR:
469                    echo '<div class="sc-msg-error">' . $m['message'] . '</div>';
470                    break;
[42]471
[167]472                case MSG_WARNING:
473                    echo '<div class="sc-msg-warning">' . $m['message'] . '</div>';
474                    break;
[42]475
[167]476                case MSG_SUCCESS:
477                    echo '<div class="sc-msg-success">' . $m['message'] . '</div>';
478                    break;
[42]479
[167]480                case MSG_NOTICE:
481                default:
482                    echo '<div class="sc-msg-notice">' . $m['message'] . '</div>';
483                    break;
[42]484
[167]485                }
[1]486            }
487            ?></div><?php
488        }
[136]489        $this->clearRaisedMessages();
[1]490    }
[42]491
[1]492    /**
[44]493     * Logs messages to defined channels: file, email, sms, and screen. Repeated messages are
494     * not repeated but printed once with count.
[1]495     *
496     * @access public
497     * @param string $message   The text description of the message.
498     * @param int    $priority  The type of message priority (in descending order):
499     *                          LOG_EMERG     system is unusable
500     *                          LOG_ALERT     action must be taken immediately
501     *                          LOG_CRIT      critical conditions
502     *                          LOG_ERR       error conditions
503     *                          LOG_WARNING   warning conditions
504     *                          LOG_NOTICE    normal, but significant, condition
505     *                          LOG_INFO      informational message
506     *                          LOG_DEBUG     debug-level message
507     * @param string $file      The file where the log event occurs.
508     * @param string $line      The line of the file where the log event occurs.
509     */
510    function logMsg($message, $priority=LOG_INFO, $file=null, $line=null)
511    {
[44]512        static $previous_events = array();
513
[1]514        // If priority is not specified, assume the worst.
[136]515        if (!$this->logPriorityToString($priority)) {
516            $this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
[1]517            $priority = LOG_EMERG;
518        }
[42]519
[15]520        // If log file is not specified, don't log to a file.
[136]521        if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) {
522            $this->setParam(array('log_file_priority' => false));
523            // We must use trigger_error to report this problem rather than calling $app->logMsg, which might lead to an infinite loop.
524            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
[1]525        }
[42]526
[1]527        // Make sure to log in the system's locale.
528        $locale = setlocale(LC_TIME, 0);
529        setlocale(LC_TIME, 'C');
[42]530
[44]531        // Strip HTML tags except any with more than 7 characters because that's probably not a HTML tag, e.g. <email@address.com>.
532        preg_match_all('/(<[^>\s]{7,})[^>]*>/', $message, $strip_tags_allow);
533        $message = strip_tags(preg_replace('/\s+/', ' ', $message), (!empty($strip_tags_allow[1]) ? join('> ', $strip_tags_allow[1]) . '>' : null));
534
535        // Store this event under a unique key, counting each time it occurs so that it only gets reported a limited number of times.
536        $msg_id = md5($message . $priority . $file . $line);
537        if (isset($previous_events[$msg_id])) {
538            $previous_events[$msg_id]++;
539            if ($previous_events[$msg_id] == 2) {
[136]540                $this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
[44]541            }
542            return false;
543        } else {
544            $previous_events[$msg_id] = 1;
545        }
546       
[1]547        // Data to be stored for a log event.
[44]548        $event = array(
549            'date'      => date('Y-m-d H:i:s'),
550            'remote ip' => getRemoteAddr(),
[247]551            'pid'       => (mb_substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''),
[136]552            'type'      => $this->logPriorityToString($priority),
[44]553            'file:line' => "$file : $line",
[247]554            'url'       => mb_substr(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 0, 128),
[44]555            'message'   => $message
556        );
[42]557
[1]558        // FILE ACTION
[136]559        if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
[44]560            $event_str = '[' . join('] [', $event) . ']';
[247]561            error_log(mb_substr($event_str, 0, 1024) . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
[1]562        }
[42]563
[1]564        // EMAIL ACTION
[136]565        if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {
[1]566            $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message);
567            $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST'));
[41]568            $headers = "From: codebase@strangecode.com";
[1]569            foreach ($event as $k=>$v) {
570                $email_msg .= sprintf("%-11s%s\n", $k, $v);
571            }
[247]572            mb_send_mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
[1]573        }
[42]574
[1]575        // SMS ACTION
[136]576        if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
[1]577            $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority);
[247]578            $sms_msg = sprintf('%s [%s:%s]', mb_substr($event['message'], 0, 64), basename($file), $line);
[41]579            $headers = "From: codebase@strangecode.com";
[247]580            mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
[1]581        }
[42]582
[1]583        // SCREEN ACTION
[136]584        if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
[189]585            echo "[{$event['type']}] [{$event['message']}]\n";
[1]586        }
[42]587
[1]588        // Restore original locale.
589        setlocale(LC_TIME, $locale);
590    }
[42]591
[1]592    /**
593     * Returns the string representation of a LOG_* integer constant.
594     *
595     * @param int  $priority  The LOG_* integer constant.
596     *
597     * @return                The string representation of $priority.
598     */
[259]599    function logPriorityToString($priority) {
[1]600        $priorities = array(
601            LOG_EMERG   => 'emergency',
602            LOG_ALERT   => 'alert',
603            LOG_CRIT    => 'critical',
604            LOG_ERR     => 'error',
605            LOG_WARNING => 'warning',
606            LOG_NOTICE  => 'notice',
607            LOG_INFO    => 'info',
608            LOG_DEBUG   => 'debug'
609        );
610        if (isset($priorities[$priority])) {
611            return $priorities[$priority];
612        } else {
613            return false;
614        }
615    }
[42]616
[1]617    /**
[282]618     * Forcefully set a query argument even if one currently exists in the reqeust.
[136]619     * Values in the _carry_queries array will be copied to URLs (via $app->url()) and
[20]620     * to hidden input values (via printHiddenSession()).
621     *
622     * @access  public
[282]623     * @param   mixed   $query_key  The key (or keys, as an array) of the query argument to save.
624     * @param   mixed   $val        The new value of the argument key.
625     * @author  Quinn Comendant <quinn@strangecode.com>
626     * @since   13 Oct 2007 11:34:51
627     */
628    function setQuery($query_key, $val)
629    {
630        if (!is_array($query_key)) {
631            $query_key = array($query_key);
632        }
633        foreach ($query_key as $k) {
634            // Set the value of the specified query argument into the _carry_queries array.
635            $this->_carry_queries[$k] = $val;
636        }
637    }
638
639    /**
640     * Specify which query arguments will be carried persistently between requests.
641     * Values in the _carry_queries array will be copied to URLs (via $app->url()) and
642     * to hidden input values (via printHiddenSession()).
643     *
644     * @access  public
[259]645     * @param   mixed   $query_key   The key (or keys, as an array) of the query argument to save.
[170]646     * @param   mixed   $default    If the key is not available, set to this default value.
[20]647     * @author  Quinn Comendant <quinn@strangecode.com>
648     * @since   14 Nov 2005 19:24:52
649     */
[170]650    function carryQuery($query_key, $default=false)
[20]651    {
[259]652        if (!is_array($query_key)) {
653            $query_key = array($query_key);
[20]654        }
[259]655        foreach ($query_key as $k) {
656            // If not already set, and there is a non-empty value provided in the request...
657            if (!isset($this->_carry_queries[$k]) && false !== getFormData($k, $default)) {
658                // Copy the value of the specified query argument into the _carry_queries array.
659                $this->_carry_queries[$k] = getFormData($k, $default);
660            }
661        }
[20]662    }
[42]663
[20]664    /**
[259]665     * dropQuery() is the opposite of carryQuery(). The specified value will not appear in
666     * url()/ohref()/printHiddenSession() modified URLs unless explicitly written in.
667     *
668     * @access  public
669     * @param   mixed   $query_key  The key (or keys, as an array) of the query argument to remove.
670     * @author  Quinn Comendant <quinn@strangecode.com>
671     * @since   18 Jun 2007 20:57:29
672     */
673    function dropQuery($query_key, $default=false)
674    {
675        if (!is_array($query_key)) {
676            $query_key = array($query_key);
677        }
678        foreach ($query_key as $k) {
[260]679            if (isset($this->_carry_queries[$k])) {
[259]680                // Remove the value of the specified query argument from the _carry_queries array.
[260]681                unset($this->_carry_queries[$k]);
[259]682            }
683        }
684    }
685
686    /**
[1]687     * Outputs a fully qualified URL with a query of all the used (ie: not empty)
[42]688     * keys and values, including optional queries. This allows mindless retention
[32]689     * of query arguments across page requests. If cookies are not
[1]690     * used, the session id will be propogated in the URL.
691     *
[32]692     * @param  string $url              The initial url
693     * @param  mixed  $carry_args       Additional url arguments to carry in the query,
694     *                                  or FALSE to prevent carrying queries. Can be any of the following formats:
695     *                                      array('key1', key2', key3')  <-- to save these keys if in the form data.
696     *                                      array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
697     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
[1]698     *
699     * @param  mixed  $always_include_sid  Always add the session id, even if using_trans_sid = true. This is required when
700     *                                     URL starts with http, since PHP using_trans_sid doesn't do those and also for
701     *                                     header('Location...') redirections.
702     *
703     * @return string url with attached queries and, if not using cookies, the session id
704     */
[32]705    function url($url, $carry_args=null, $always_include_sid=false)
[1]706    {
[136]707        if (!$this->running) {
708            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]709            return false;
710        }
[42]711
[20]712        // Get any provided query arguments to include in the final URL.
713        // If FALSE is a provided here, DO NOT carry the queries.
[1]714        $do_carry_queries = true;
715        $one_time_carry_queries = array();
716        if (!is_null($carry_args)) {
717            if (is_array($carry_args) && !empty($carry_args)) {
718                foreach ($carry_args as $key=>$arg) {
719                    // Get query from appropriate source.
720                    if (false === $arg) {
721                        $do_carry_queries = false;
722                    } else if (false !== getFormData($arg, false)) {
723                        $one_time_carry_queries[$arg] = getFormData($arg); // Set arg to form data if available.
724                    } else if (!is_numeric($key) && '' != $arg) {
725                        $one_time_carry_queries[$key] = getFormData($key, $arg); // Set to arg to default if specified (overwritten by form data).
726                    }
727                }
728            } else if (false !== getFormData($carry_args, false)) {
729                $one_time_carry_queries[$carry_args] = getFormData($carry_args);
730            } else if (false === $carry_args) {
731                $do_carry_queries = false;
732            }
733        }
[42]734
[1]735        // Get the first delimiter that is needed in the url.
[247]736        $delim = mb_strpos($url, '?') !== false ? ini_get('arg_separator.output') : '?';
[32]737
[1]738        $q = '';
739        if ($do_carry_queries) {
[20]740            // Join the global _carry_queries and local one_time_carry_queries.
[136]741            $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
[1]742            foreach ($query_args as $key=>$val) {
743                // Check value is set and value does not already exist in the url.
744                if (!preg_match('/[?&]' . preg_quote($key) . '=/', $url)) {
745                    $q .= $delim . $key . '=' . $val;
746                    $delim = ini_get('arg_separator.output');
747                }
748            }
749        }
[42]750
[1]751        // Include the necessary SID if the following is true:
752        // - no cookie in http request OR cookies disabled in App
753        // - sessions are enabled
754        // - the link stays on our site
755        // - transparent SID propogation with session.use_trans_sid is not being used OR url begins with protocol (using_trans_sid has no effect here)
[42]756        // OR
[1]757        // - we must include the SID because we say so (it's used in a context where cookies will not be effective, ie. moving from http to https)
758        // AND
759        // - the SID is not already in the query.
760        if (
761            (
762                (
763                    (
[42]764                        !isset($_COOKIE[session_name()])
[136]765                        || !$this->getParam('session_use_cookies')
[42]766                    )
[242]767                    && $this->getParam('session_use_trans_sid')
[136]768                    && $this->getParam('enable_session')
[42]769                    && isMyDomain($url)
[242]770                    && (
[20]771                        !ini_get('session.use_trans_sid')
[1]772                        || preg_match('!^(http|https)://!i', $url)
773                    )
[42]774                )
[1]775                || $always_include_sid
776            )
777            && !preg_match('/[?&]' . preg_quote(session_name()) . '=/', $url)
778        ) {
779            $url .= $q . $delim . session_name() . '=' . session_id();
780            return $url;
781        } else {
782            $url .= $q;
783            return $url;
784        }
785    }
[32]786
787    /**
[136]788     * Returns a HTML-friendly URL processed with $app->url and & replaced with &amp;
[32]789     *
790     * @access  public
791     * @param   string  $url    Input URL to parse.
[136]792     * @return  string          URL with $app->url() and htmlentities() applied.
[32]793     * @author  Quinn Comendant <quinn@strangecode.com>
794     * @since   09 Dec 2005 17:58:45
795     */
796    function oHREF($url, $carry_args=null, $always_include_sid=false)
797    {
[136]798        $url = $this->url($url, $carry_args, $always_include_sid);
[42]799
[32]800        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
801        $url = preg_replace('/&(?![\w\d#]{1,10};)/', '&amp;', $url);
[42]802
[32]803        return $url;
804    }
[42]805
[1]806    /**
807     * Prints a hidden form element with the PHPSESSID when cookies are not used, as well
[42]808     * as hidden form elements for GET_VARS that might be in use.
[1]809     *
810     * @param  mixed  $carry_args        Additional url arguments to carry in the query,
811     *                                   or FALSE to prevent carrying queries. Can be any of the following formats:
[32]812     *                                      array('key1', key2', key3')  <-- to save these keys if in the form data.
813     *                                      array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
814     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
[1]815     */
816    function printHiddenSession($carry_args=null)
[32]817    {
[136]818        if (!$this->running) {
819            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]820            return false;
821        }
[42]822
[20]823        // Get any provided query arguments to include in the final hidden form data.
824        // If FALSE is a provided here, DO NOT carry the queries.
[1]825        $do_carry_queries = true;
826        $one_time_carry_queries = array();
827        if (!is_null($carry_args)) {
828            if (is_array($carry_args) && !empty($carry_args)) {
829                foreach ($carry_args as $key=>$arg) {
830                    // Get query from appropriate source.
831                    if (false === $arg) {
832                        $do_carry_queries = false;
833                    } else if (false !== getFormData($arg, false)) {
834                        $one_time_carry_queries[$arg] = getFormData($arg); // Set arg to form data if available.
835                    } else if (!is_numeric($key) && '' != $arg) {
836                        $one_time_carry_queries[$key] = getFormData($key, $arg); // Set to arg to default if specified (overwritten by form data).
837                    }
838                }
839            } else if (false !== getFormData($carry_args, false)) {
840                $one_time_carry_queries[$carry_args] = getFormData($carry_args);
841            } else if (false === $carry_args) {
842                $do_carry_queries = false;
843            }
844        }
[42]845
[1]846        // For each existing POST value, we create a hidden input to carry it through a form.
847        if ($do_carry_queries) {
[20]848            // Join the global _carry_queries and local one_time_carry_queries.
849            // urlencode is not used here, not for form data!
[136]850            $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
[1]851            foreach ($query_args as $key=>$val) {
[136]852                printf('<input type="hidden" name="%s" value="%s" />', $key, $val);
[1]853            }
854        }
[42]855
[1]856        // Include the SID if cookies are disabled.
[20]857        if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) {
[136]858            printf('<input type="hidden" name="%s" value="%s" />', session_name(), session_id());
[1]859        }
860    }
[42]861
[1]862    /**
863     * Uses an http header to redirect the client to the given $url. If sessions are not used
864     * and the session is not already defined in the given $url, the SID is appended as a URI query.
865     * As with all header generating functions, make sure this is called before any other output.
866     *
867     * @param   string  $url                    The URL the client will be redirected to.
868     * @param   mixed   $carry_args             Additional url arguments to carry in the query,
869     *                                          or FALSE to prevent carrying queries. Can be any of the following formats:
870     *                                          -array('key1', key2', key3')  <-- to save these keys if in the form data.
[136]871     *                                          -array('key1' => 'value', key2' => 'value')  <-- to set keys to default values if not present in form data.
[1]872     *                                          -false  <-- To not carry any queries. If URL already has queries those will be retained.
873     * @param   bool    $always_include_sid     Force session id to be added to Location header.
874     */
875    function dieURL($url, $carry_args=null, $always_include_sid=false)
876    {
[136]877        if (!$this->running) {
878            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]879            return false;
880        }
[42]881
[1]882        if ('' == $url) {
883            // If URL is not specified, use the redirect_home_url.
[136]884            $url = $this->getParam('redirect_home_url');
[1]885        }
[42]886
[1]887        if (preg_match('!^/!', $url)) {
888            // If relative URL is given, prepend correct local hostname.
[22]889            $scheme = 'on' == getenv('HTTPS') ? 'https' : 'http';
890            $host = getenv('HTTP_HOST');
891            $url = sprintf('%s://%s%s', $scheme, $host, $url);
[1]892        }
[22]893
[136]894        $url = $this->url($url, $carry_args, $always_include_sid);
[42]895
[202]896        // Should we send a "303 See Other" header here instead of relying on the 302 sent automatically by PHP?
[1]897        header(sprintf('Location: %s', $url));
[136]898        $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
[42]899
[202]900        // End application.
[1]901        // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
[136]902        $this->stop();
[1]903        die;
904    }
[42]905
[84]906    /*
[136]907    * Redirects a user by calling $app->dieURL(). It will use:
[84]908    * 1. the stored boomerang URL, it it exists
909    * 2. a specified $default_url, it it exists
910    * 3. the referring URL, it it exists.
911    * 4. redirect_home_url configuration variable.
912    *
913    * @access   public
914    * @param    string  $id             Identifier for this script.
[136]915    * @param    mixed   $carry_args     Additional arguments to carry in the URL automatically (see $app->oHREF()).
[84]916    * @param    string  $default_url    A default URL if there is not a valid specified boomerang URL.
[159]917    * @param    bool    $queryless_referrer_comparison   Exclude the URL query from the refererIsMe() comparison.
[84]918    * @return   bool                    False if the session is not running. No return otherwise.
919    * @author   Quinn Comendant <quinn@strangecode.com>
920    * @since    31 Mar 2006 19:17:00
921    */
[159]922    function dieBoomerangURL($id=null, $carry_args=null, $default_url=null, $queryless_referrer_comparison=false)
[1]923    {
[136]924        if (!$this->running) {
925            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]926            return false;
927        }
[42]928
[1]929        // Get URL from stored boomerang. Allow non specific URL if ID not valid.
[136]930        if ($this->validBoomerangURL($id, true)) {
[154]931            if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) {
932                $url = $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id];
[136]933                $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]934            } else {
[154]935                $url = end($_SESSION['_app'][$this->_ns]['boomerang']['url']);
[136]936                $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]937            }
[22]938            // Delete stored boomerang.
[136]939            $this->deleteBoomerangURL($id);
[84]940        } else if (isset($default_url)) {
941            $url = $default_url;
[159]942        } else if (!refererIsMe(true === $queryless_referrer_comparison)) {
[1]943            // Ensure that the redirecting page is not also the referrer.
944            $url = getenv('HTTP_REFERER');
[136]945            $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]946        } else {
[22]947            // If URL is not specified, use the redirect_home_url.
[136]948            $url = $this->getParam('redirect_home_url');
[203]949            $this->logMsg(sprintf('dieBoomerangURL(%s) using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]950        }
[42]951
[84]952        // A redirection will never happen immediately twice.
[1]953        // Set the time so ensure this doesn't happen.
[154]954        $_SESSION['_app'][$this->_ns]['boomerang']['time'] = time();
[136]955        $this->dieURL($url, $carry_args);
[1]956    }
[42]957
[1]958    /**
[136]959     * Set the URL to return to when $app->dieBoomerangURL() is called.
[1]960     *
961     * @param string  $url  A fully validated URL.
962     * @param bool  $id     An identification tag for this url.
963     * FIXME: url garbage collection?
964     */
965    function setBoomerangURL($url=null, $id=null)
966    {
[136]967        if (!$this->running) {
968            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]969            return false;
970        }
[84]971        // A redirection will never happen immediately after setting the boomerangURL.
[136]972        // Set the time so ensure this doesn't happen. See $app->validBoomerangURL for more.
[42]973
[22]974        if ('' != $url && is_string($url)) {
[242]975            // Delete any boomerang request keys in the query string (along with any trailing delimiters after the deletion).
976            $url = preg_replace(array('/([&?])boomerang=\w+[&?]?/', '/[&?]$/'), array('$1', ''), $url);
[42]977
[154]978            if (isset($_SESSION['_app'][$this->_ns]['boomerang']['url']) && is_array($_SESSION['_app'][$this->_ns]['boomerang']['url']) && !empty($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
[1]979                // If the URL currently exists in the boomerang array, delete.
[154]980                while ($existing_key = array_search($url, $_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
981                    unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$existing_key]);
[1]982                }
983            }
[42]984
[1]985            if (isset($id)) {
[154]986                $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id] = $url;
[1]987            } else {
[154]988                $_SESSION['_app'][$this->_ns]['boomerang']['url'][] = $url;
[1]989            }
[136]990            $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]991            return true;
992        } else {
[136]993            $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
[1]994            return false;
995        }
996    }
[42]997
[1]998    /**
999     * Return the URL set for the specified $id.
1000     *
1001     * @param string  $id     An identification tag for this url.
1002     */
1003    function getBoomerangURL($id=null)
1004    {
[136]1005        if (!$this->running) {
1006            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]1007            return false;
1008        }
[42]1009
[1]1010        if (isset($id)) {
[154]1011            if (isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) {
1012                return $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id];
[1]1013            } else {
1014                return '';
1015            }
[154]1016        } else if (is_array($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
1017            return end($_SESSION['_app'][$this->_ns]['boomerang']['url']);
[1]1018        } else {
1019            return false;
1020        }
1021    }
[42]1022
[1]1023    /**
1024     * Delete the URL set for the specified $id.
1025     *
1026     * @param string  $id     An identification tag for this url.
1027     */
1028    function deleteBoomerangURL($id=null)
1029    {
[136]1030        if (!$this->running) {
1031            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]1032            return false;
1033        }
[42]1034
[136]1035        $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
[22]1036
[154]1037        if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) {
1038            unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id]);
1039        } else if (is_array($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
1040            array_pop($_SESSION['_app'][$this->_ns]['boomerang']['url']);
[1]1041        }
1042    }
[42]1043
[1]1044    /**
[103]1045     * Check if a valid boomerang URL value has been set. A boomerang URL is considered
1046     * valid if: 1) it is not empty, 2) it is not the current URL, and 3) has not been accessed within n seconds.
[1]1047     *
[103]1048     * @return bool  True if it is set and valid, false otherwise.
[1]1049     */
1050    function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
1051    {
[136]1052        if (!$this->running) {
1053            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
[1]1054            return false;
1055        }
[42]1056
[154]1057        if (!isset($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
[136]1058            $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
[1]1059            return false;
1060        }
[42]1061
[1]1062        // Time is the timestamp of a boomerangURL redirection, or setting of a boomerangURL.
1063        // a boomerang redirection will always occur at least several seconds after the last boomerang redirect
1064        // or a boomerang being set.
[154]1065        $boomerang_time = isset($_SESSION['_app'][$this->_ns]['boomerang']['time']) ? $_SESSION['_app'][$this->_ns]['boomerang']['time'] : 0;
[42]1066
[22]1067        $url = '';
[154]1068        if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) {
1069            $url = $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id];
[1]1070        } else if (!isset($id) || $use_nonspecificboomerang) {
1071            // Use non specific boomerang if available.
[154]1072            $url = end($_SESSION['_app'][$this->_ns]['boomerang']['url']);
[1]1073        }
[42]1074
[136]1075        $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[22]1076
1077        if ('' == $url) {
[136]1078            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
[1]1079            return false;
1080        }
1081        if ($url == absoluteMe()) {
1082            // The URL we are directing to is the current page.
[136]1083            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]1084            return false;
1085        }
1086        if ($boomerang_time >= (time() - 2)) {
[159]1087            // Last boomerang direction was less than 2 seconds ago.
1088            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s seconds', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
[1]1089            return false;
1090        }
[42]1091
[136]1092        $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
[1]1093        return true;
1094    }
1095
1096    /**
1097     * Force the user to connect via https (port 443) by redirecting them to
1098     * the same page but with https.
1099     */
1100    function sslOn()
1101    {
[38]1102        if (function_exists('apache_get_modules')) {
[42]1103            $modules = apache_get_modules();
[38]1104        } else {
1105            // It's safe to assume we have mod_ssl if we can't determine otherwise.
1106            $modules = array('mod_ssl');
1107        }
[42]1108
[136]1109        if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
1110            $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
[1]1111            // Always append session because some browsers do not send cookie when crossing to SSL URL.
[136]1112            $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
[1]1113        }
1114    }
[42]1115
1116
[1]1117    /**
1118     * to enforce the user to connect via http (port 80) by redirecting them to
1119     * a http version of the current url.
1120     */
1121    function sslOff()
1122    {
[53]1123        if ('' != getenv('HTTPS')) {
[1]1124            $this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);
1125        }
1126    }
1127
[42]1128
[1]1129} // End.
1130
1131?>
Note: See TracBrowser for help on using the repository browser.