Changeset 119 for trunk/lib/App.inc.php
- Timestamp:
- May 20, 2006 2:12:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r108 r119 16 16 define('MSG_NOTICE', 4); 17 17 define('MSG_SUCCESS', 8); 18 define('MSG_ALL', MSG_SUCCESS | MSG_NOTICE | MSG_WARNING | MSG_ERROR); 18 19 19 20 require_once dirname(__FILE__) . '/Utilities.inc.php'; … … 163 164 function setParam($param=null) 164 165 { 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(); 167 168 } 168 169 169 170 if (isset($param) && is_array($param)) { 170 171 // 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); 172 173 } 173 174 } … … 182 183 function &getParam($param=null) 183 184 { 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(); 186 187 } 187 188 188 189 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]; 192 193 } else { 193 194 trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE); … … 359 360 function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null) 360 361 { 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(); 363 364 } 364 365 365 366 $message = trim($message); 366 367 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__); 369 370 return false; 370 371 } … … 372 373 // Save message in session under unique key to avoid duplicate messages. 373 374 $msg_id = md5($type . $message . $file . $line); 374 $_SESSION[$ this->app]['messages'][$msg_id] = array(375 $_SESSION[$_this->app]['messages'][$msg_id] = array( 375 376 'type' => $type, 376 377 'message' => $message, 377 378 'file' => $file, 378 379 '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) 380 381 ); 381 382 382 383 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__); 384 385 } 385 386 } … … 395 396 function getRaisedMessages() 396 397 { 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__); 403 404 return false; 404 405 } 405 406 406 407 $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'])) { 408 409 $output[] = $message; 409 410 } … … 420 421 function clearRaisedMessages() 421 422 { 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__); 428 429 return false; 429 430 } 430 431 431 $_SESSION[$ this->app]['messages'] = array();432 $_SESSION[$_this->app]['messages'] = array(); 432 433 } 433 434 … … 441 442 function printRaisedMessages() 442 443 { 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'])) { 453 454 ?><div class="sc-msg"><?php 454 if (error_reporting() > 0 && $ this->getParam('display_errors')) {455 if (error_reporting() > 0 && $_this->getParam('display_errors')) { 455 456 echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->'; 456 457 } … … 500 501 static $previous_events = array(); 501 502 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(); 504 505 } 505 506 506 507 // 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); 509 510 $priority = LOG_EMERG; 510 511 } 511 512 512 513 // 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)); 515 516 // 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); 517 518 } 518 519 … … 530 531 $previous_events[$msg_id]++; 531 532 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); 533 534 } 534 535 return false; … … 542 543 'remote ip' => getRemoteAddr(), 543 544 'pid' => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''), 544 'type' => $ this->logPriorityToString($priority),545 'type' => $_this->logPriorityToString($priority), 545 546 'file:line' => "$file : $line", 546 547 'url' => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''), … … 549 550 550 551 // 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')) { 552 553 $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')); 554 555 } 555 556 556 557 // 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')) { 558 559 $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message); 559 560 $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST')); … … 562 563 $email_msg .= sprintf("%-11s%s\n", $k, $v); 563 564 } 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'); 565 566 } 566 567 567 568 // 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')) { 569 570 $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority); 570 571 $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line); 571 572 $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'); 573 574 } 574 575 575 576 // 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')) { 577 578 echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n"; 578 579 } … … 619 620 function carryQuery($query_key) 620 621 { 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(); 623 624 } 624 625 625 626 // 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)) { 627 628 // 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); 629 630 } 630 631 } … … 651 652 function url($url, $carry_args=null, $always_include_sid=false) 652 653 { 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__); 659 660 return false; 660 661 } … … 690 691 if ($do_carry_queries) { 691 692 // 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)); 693 694 foreach ($query_args as $key=>$val) { 694 695 // Check value is set and value does not already exist in the url. … … 714 715 ( 715 716 !isset($_COOKIE[session_name()]) 716 || !$ this->getParam('session_use_cookies')717 || !$_this->getParam('session_use_cookies') 717 718 ) 718 && $ this->getParam('enable_session')719 && $_this->getParam('enable_session') 719 720 && isMyDomain($url) 720 721 && … … 747 748 function oHREF($url, $carry_args=null, $always_include_sid=false) 748 749 { 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); 754 755 755 756 // Replace any & not followed by an html or unicode entity with it's & equivalent. … … 771 772 function printHiddenSession($carry_args=null) 772 773 { 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__); 779 780 return false; 780 781 } … … 807 808 // Join the global _carry_queries and local one_time_carry_queries. 808 809 // 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); 810 811 foreach ($query_args as $key=>$val) { 811 812 echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; … … 834 835 function dieURL($url, $carry_args=null, $always_include_sid=false) 835 836 { 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__); 842 843 return false; 843 844 } … … 845 846 if ('' == $url) { 846 847 // If URL is not specified, use the redirect_home_url. 847 $url = $ this->getParam('redirect_home_url');848 $url = $_this->getParam('redirect_home_url'); 848 849 } 849 850 … … 855 856 } 856 857 857 $url = $ this->url($url, $carry_args, $always_include_sid);858 $url = $_this->url($url, $carry_args, $always_include_sid); 858 859 859 860 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__); 861 862 862 863 // End this application. 863 864 // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close 864 $ this->stop();865 $_this->stop(); 865 866 die; 866 867 } … … 883 884 function dieBoomerangURL($id=null, $carry_args=null, $default_url=null) 884 885 { 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__); 891 892 return false; 892 893 } 893 894 894 895 // 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__); 899 900 } 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__); 902 903 } 903 904 // Delete stored boomerang. 904 $ this->deleteBoomerangURL($id);905 $_this->deleteBoomerangURL($id); 905 906 } else if (isset($default_url)) { 906 907 $url = $default_url; … … 908 909 // Ensure that the redirecting page is not also the referrer. 909 910 $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__); 911 912 } else { 912 913 // 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__); 915 916 } 916 917 917 918 // A redirection will never happen immediately twice. 918 919 // 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); 921 922 } 922 923 … … 930 931 function setBoomerangURL($url=null, $id=null) 931 932 { 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__); 938 939 return false; 939 940 } … … 945 946 $url = preg_replace('/boomerang=[\w]+/', '', $url); 946 947 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'])) { 948 949 // 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]); 951 952 } 952 953 } 953 954 954 955 if (isset($id)) { 955 $_SESSION[$ this->app]['boomerang']['url'][$id] = $url;956 $_SESSION[$_this->app]['boomerang']['url'][$id] = $url; 956 957 } 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__); 960 961 return true; 961 962 } 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__); 963 964 return false; 964 965 } … … 972 973 function getBoomerangURL($id=null) 973 974 { 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__); 980 981 return false; 981 982 } 982 983 983 984 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]; 986 987 } else { 987 988 return ''; 988 989 } 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']); 991 992 } else { 992 993 return false; … … 1001 1002 function deleteBoomerangURL($id=null) 1002 1003 { 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']); 1018 1019 } 1019 1020 } … … 1027 1028 function validBoomerangURL($id=null, $use_nonspecificboomerang=false) 1028 1029 { 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__); 1040 1041 return false; 1041 1042 } … … 1044 1045 // a boomerang redirection will always occur at least several seconds after the last boomerang redirect 1045 1046 // 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; 1047 1048 1048 1049 $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]; 1051 1052 } else if (!isset($id) || $use_nonspecificboomerang) { 1052 1053 // 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__); 1057 1058 1058 1059 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__); 1060 1061 return false; 1061 1062 } 1062 1063 if ($url == absoluteMe()) { 1063 1064 // 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__); 1065 1066 return false; 1066 1067 } 1067 1068 if ($boomerang_time >= (time() - 2)) { 1068 1069 // 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__); 1074 1075 return true; 1075 1076 } … … 1081 1082 function sslOn() 1082 1083 { 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(); 1085 1086 } 1086 1087 … … 1092 1093 } 1093 1094 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__); 1096 1097 // 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); 1098 1099 } 1099 1100 }
Note: See TracChangeset
for help on using the changeset viewer.