Changeset 22 for trunk/lib/App.inc.php
- Timestamp:
- Nov 23, 2005 9:29:33 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r21 r22 152 152 } 153 153 154 if (!isset($_SESSION[$this->app])) {155 $_SESSION[$this->app] = array();156 }157 158 154 // Initialize default parameters. 159 155 $this->_params = array_merge($this->_params, $this->_param_defaults); … … 296 292 session_name($this->getParam('session_name')); 297 293 298 // Start the session. Access session data using: $_SESSION['...']294 // Start the session. 299 295 session_start(); 296 297 if (!isset($_SESSION[$this->app])) { 298 // Access session data using: $_SESSION['...']. 299 // Initialize here _after_ session has started. 300 $_SESSION[$this->app] = array( 301 'messages' => array(), 302 'boomerang' => array('url'), 303 ); 304 } 300 305 } 301 306 … … 374 379 375 380 if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) { 376 App::logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);381 $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__); 377 382 } 378 383 } … … 752 757 if (preg_match('!^/!', $url)) { 753 758 // If relative URL is given, prepend correct local hostname. 754 $my_url = parse_url($_SERVER['SCRIPT_URI']); 755 $url = sprintf('%s://%s%s', $my_url['scheme'], $my_url['host'], $url); 756 } 757 759 $scheme = 'on' == getenv('HTTPS') ? 'https' : 'http'; 760 $host = getenv('HTTP_HOST'); 761 $url = sprintf('%s://%s%s', $scheme, $host, $url); 762 } 763 758 764 $url = $this->oHREF($url, $carry_args, $always_include_sid); 759 765 … … 787 793 if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) { 788 794 $url = $_SESSION[$this->app]['boomerang']['url'][$id]; 795 $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 789 796 } else { 790 797 $url = end($_SESSION[$this->app]['boomerang']['url']); 791 } 792 } else if (!refererIsMe() && !preg_match('/admin_common/', getenv('SCRIPT_NAME'))) { 798 $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 799 } 800 // Delete stored boomerang. 801 $this->deleteBoomerangURL($id); 802 } else if (!refererIsMe()) { 793 803 // Ensure that the redirecting page is not also the referrer. 794 // admin_common is an alias of 'admin', which confuses this function. Just here for local testing.795 804 $url = getenv('HTTP_REFERER'); 805 $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 796 806 } else { 797 $url = ''; 798 } 799 800 $this->logMsg(sprintf('dieBoomerangURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__); 801 802 // Delete stored boomerang. 803 $this->deleteBoomerangURL($id); 807 // If URL is not specified, use the redirect_home_url. 808 $url = $this->getParam('redirect_home_url'); 809 $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 810 } 811 804 812 805 813 // A redirection will never happen immediatly twice. … … 825 833 return false; 826 834 } 827 828 835 // A redirection will never happen immediatly after setting the boomerangURL. 829 836 // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more. 830 837 831 if ( isset($url)&& is_string($url)) {838 if ('' != $url && is_string($url)) { 832 839 // Delete any boomerang request keys in the query string. 833 840 $url = preg_replace('/boomerang=[\w]+/', '', $url); 834 841 835 if (is _array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {842 if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) { 836 843 // If the URL currently exists in the boomerang array, delete. 837 844 while ($existing_key = array_search($url, $_SESSION[$this->app]['boomerang']['url'])) { … … 845 852 $_SESSION[$this->app]['boomerang']['url'][] = $url; 846 853 } 847 $this->logMsg(sprintf('setBoomerangURL : %s', $url), LOG_DEBUG, __FILE__, __LINE__);854 $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 848 855 return true; 849 856 } else { 857 $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__); 850 858 return false; 851 859 } … … 895 903 } 896 904 905 $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__); 906 897 907 if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) { 898 908 unset($_SESSION[$this->app]['boomerang']['url'][$id]); … … 927 937 $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0; 928 938 939 $url = ''; 929 940 if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) { 930 941 $url = $_SESSION[$this->app]['boomerang']['url'][$id]; … … 934 945 } 935 946 936 $this->logMsg(sprintf('validBoomerangURL testing url: %s', $url), LOG_DEBUG, __FILE__, __LINE__); 937 if (empty($url)) { 947 $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 948 949 if ('' == $url) { 950 $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_NOTICE, __FILE__, __LINE__); 938 951 return false; 939 952 } 940 953 if ($url == absoluteMe()) { 941 954 // The URL we are directing to is the current page. 942 $this->logMsg(sprintf(' Boomerang URL not valid, same as absoluteMe: %s', $url), LOG_WARNING, __FILE__, __LINE__);955 $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_NOTICE, __FILE__, __LINE__); 943 956 return false; 944 957 } 945 958 if ($boomerang_time >= (time() - 2)) { 946 959 // Last boomerang direction was more than 2 seconds ago. 947 $this->logMsg(sprintf(' Boomerang URL not valid, boomerang_time too short: %s', time() - $boomerang_time), LOG_WARNING, __FILE__, __LINE__);948 return false; 949 } 950 951 $this->logMsg(sprintf('validBoomerangURL found: %s', $url), LOG_DEBUG, __FILE__, __LINE__);960 $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_NOTICE, __FILE__, __LINE__); 961 return false; 962 } 963 964 $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 952 965 return true; 953 966 }
Note: See TracChangeset
for help on using the changeset viewer.