- Timestamp:
- Jun 8, 2006 5:36:10 AM (18 years ago)
- Location:
- trunk/lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r144 r154 152 152 { 153 153 // Set namespace of application instance. 154 $this->_ns = '_app_' .$namespace;154 $this->_ns = $namespace; 155 155 156 156 // Initialize default parameters. … … 281 281 session_start(); 282 282 283 if (!isset($_SESSION[ $this->_ns])) {283 if (!isset($_SESSION['_app'][$this->_ns])) { 284 284 // Access session data using: $_SESSION['...']. 285 285 // Initialize here _after_ session has started. 286 $_SESSION[ $this->_ns] = array(286 $_SESSION['_app'][$this->_ns] = array( 287 287 'messages' => array(), 288 288 'boomerang' => array('url'), … … 363 363 // Save message in session under unique key to avoid duplicate messages. 364 364 $msg_id = md5($type . $message . $file . $line); 365 $_SESSION[ $this->_ns]['messages'][$msg_id] = array(365 $_SESSION['_app'][$this->_ns]['messages'][$msg_id] = array( 366 366 'type' => $type, 367 367 'message' => $message, 368 368 'file' => $file, 369 369 'line' => $line, 370 'count' => (isset($_SESSION[ $this->_ns]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->_ns]['messages'][$msg_id]['count']) : 1)370 'count' => (isset($_SESSION['_app'][$this->_ns]['messages'][$msg_id]['count']) ? (1 + $_SESSION['_app'][$this->_ns]['messages'][$msg_id]['count']) : 1) 371 371 ); 372 372 … … 391 391 } 392 392 393 return isset($_SESSION[ $this->_ns]['messages']) ? $_SESSION[$this->_ns]['messages'] : array();393 return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array(); 394 394 } 395 395 … … 408 408 } 409 409 410 $_SESSION[ $this->_ns]['messages'] = array();410 $_SESSION['_app'][$this->_ns]['messages'] = array(); 411 411 } 412 412 … … 843 843 // Get URL from stored boomerang. Allow non specific URL if ID not valid. 844 844 if ($this->validBoomerangURL($id, true)) { 845 if (isset($id) && isset($_SESSION[ $this->_ns]['boomerang']['url'][$id])) {846 $url = $_SESSION[ $this->_ns]['boomerang']['url'][$id];845 if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) { 846 $url = $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id]; 847 847 $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 848 848 } else { 849 $url = end($_SESSION[ $this->_ns]['boomerang']['url']);849 $url = end($_SESSION['_app'][$this->_ns]['boomerang']['url']); 850 850 $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 851 851 } … … 866 866 // A redirection will never happen immediately twice. 867 867 // Set the time so ensure this doesn't happen. 868 $_SESSION[ $this->_ns]['boomerang']['time'] = time();868 $_SESSION['_app'][$this->_ns]['boomerang']['time'] = time(); 869 869 $this->dieURL($url, $carry_args); 870 870 } … … 890 890 $url = preg_replace('/boomerang=[\w]+/', '', $url); 891 891 892 if (isset($_SESSION[ $this->_ns]['boomerang']['url']) && is_array($_SESSION[$this->_ns]['boomerang']['url']) && !empty($_SESSION[$this->_ns]['boomerang']['url'])) {892 if (isset($_SESSION['_app'][$this->_ns]['boomerang']['url']) && is_array($_SESSION['_app'][$this->_ns]['boomerang']['url']) && !empty($_SESSION['_app'][$this->_ns]['boomerang']['url'])) { 893 893 // If the URL currently exists in the boomerang array, delete. 894 while ($existing_key = array_search($url, $_SESSION[ $this->_ns]['boomerang']['url'])) {895 unset($_SESSION[ $this->_ns]['boomerang']['url'][$existing_key]);894 while ($existing_key = array_search($url, $_SESSION['_app'][$this->_ns]['boomerang']['url'])) { 895 unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$existing_key]); 896 896 } 897 897 } 898 898 899 899 if (isset($id)) { 900 $_SESSION[ $this->_ns]['boomerang']['url'][$id] = $url;900 $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id] = $url; 901 901 } else { 902 $_SESSION[ $this->_ns]['boomerang']['url'][] = $url;902 $_SESSION['_app'][$this->_ns]['boomerang']['url'][] = $url; 903 903 } 904 904 $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); … … 923 923 924 924 if (isset($id)) { 925 if (isset($_SESSION[ $this->_ns]['boomerang']['url'][$id])) {926 return $_SESSION[ $this->_ns]['boomerang']['url'][$id];925 if (isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) { 926 return $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id]; 927 927 } else { 928 928 return ''; 929 929 } 930 } else if (is_array($_SESSION[ $this->_ns]['boomerang']['url'])) {931 return end($_SESSION[ $this->_ns]['boomerang']['url']);930 } else if (is_array($_SESSION['_app'][$this->_ns]['boomerang']['url'])) { 931 return end($_SESSION['_app'][$this->_ns]['boomerang']['url']); 932 932 } else { 933 933 return false; … … 949 949 $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__); 950 950 951 if (isset($id) && isset($_SESSION[ $this->_ns]['boomerang']['url'][$id])) {952 unset($_SESSION[ $this->_ns]['boomerang']['url'][$id]);953 } else if (is_array($_SESSION[ $this->_ns]['boomerang']['url'])) {954 array_pop($_SESSION[ $this->_ns]['boomerang']['url']);951 if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) { 952 unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id]); 953 } else if (is_array($_SESSION['_app'][$this->_ns]['boomerang']['url'])) { 954 array_pop($_SESSION['_app'][$this->_ns]['boomerang']['url']); 955 955 } 956 956 } … … 969 969 } 970 970 971 if (!isset($_SESSION[ $this->_ns]['boomerang']['url'])) {971 if (!isset($_SESSION['_app'][$this->_ns]['boomerang']['url'])) { 972 972 $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__); 973 973 return false; … … 977 977 // a boomerang redirection will always occur at least several seconds after the last boomerang redirect 978 978 // or a boomerang being set. 979 $boomerang_time = isset($_SESSION[ $this->_ns]['boomerang']['time']) ? $_SESSION[$this->_ns]['boomerang']['time'] : 0;979 $boomerang_time = isset($_SESSION['_app'][$this->_ns]['boomerang']['time']) ? $_SESSION['_app'][$this->_ns]['boomerang']['time'] : 0; 980 980 981 981 $url = ''; 982 if (isset($id) && isset($_SESSION[ $this->_ns]['boomerang']['url'][$id])) {983 $url = $_SESSION[ $this->_ns]['boomerang']['url'][$id];982 if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) { 983 $url = $_SESSION['_app'][$this->_ns]['boomerang']['url'][$id]; 984 984 } else if (!isset($id) || $use_nonspecificboomerang) { 985 985 // Use non specific boomerang if available. 986 $url = end($_SESSION[ $this->_ns]['boomerang']['url']);986 $url = end($_SESSION['_app'][$this->_ns]['boomerang']['url']); 987 987 } 988 988 -
trunk/lib/Auth_File.inc.php
r149 r154 68 68 function Auth_File($namespace='null') 69 69 { 70 $this->_ns = '_auth_' .$namespace;70 $this->_ns = $namespace; 71 71 72 72 // Initialize default parameters. … … 114 114 function clear() 115 115 { 116 $_SESSION[ $this->_ns] = array('authenticated' => false);116 $_SESSION['_auth_file'][$this->_ns] = array('authenticated' => false); 117 117 } 118 118 … … 127 127 function set($key, $val) 128 128 { 129 if (!isset($_SESSION[ $this->_ns]['user_data'])) {130 $_SESSION[ $this->_ns]['user_data'] = array();131 } 132 $_SESSION[ $this->_ns]['user_data'][$key] = $val;129 if (!isset($_SESSION['_auth_file'][$this->_ns]['user_data'])) { 130 $_SESSION['_auth_file'][$this->_ns]['user_data'] = array(); 131 } 132 $_SESSION['_auth_file'][$this->_ns]['user_data'][$key] = $val; 133 133 } 134 134 … … 143 143 function get($key, $default='') 144 144 { 145 if (isset($_SESSION[ $this->_ns][$key])) {146 return $_SESSION[ $this->_ns][$key];147 } else if (isset($_SESSION[ $this->_ns]['user_data'][$key])) {148 return $_SESSION[ $this->_ns]['user_data'][$key];145 if (isset($_SESSION['_auth_file'][$this->_ns][$key])) { 146 return $_SESSION['_auth_file'][$this->_ns][$key]; 147 } else if (isset($_SESSION['_auth_file'][$this->_ns]['user_data'][$key])) { 148 return $_SESSION['_auth_file'][$this->_ns]['user_data'][$key]; 149 149 } else { 150 150 return $default; … … 209 209 } 210 210 211 $_SESSION[ $this->_ns] = array(211 $_SESSION['_auth_file'][$this->_ns] = array( 212 212 'authenticated' => true, 213 213 'username' => $username, … … 238 238 if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) { 239 239 $user_in_trusted_network = true; 240 $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[ $this->_ns]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);240 $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION['_auth_file'][$this->_ns]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__); 241 241 } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) { 242 242 $user_in_trusted_network = true; 243 $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[ $this->_ns]['username']), LOG_DEBUG, __FILE__, __LINE__);243 $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION['_auth_file'][$this->_ns]['username']), LOG_DEBUG, __FILE__, __LINE__); 244 244 } else { 245 245 $user_in_trusted_network = false; … … 247 247 248 248 // Test login with information stored in session. Skip IP matching for users from trusted networks. 249 if (isset($_SESSION[ $this->_ns])250 && true === $_SESSION[ $this->_ns]['authenticated']251 && !empty($_SESSION[ $this->_ns]['username'])252 && strtotime($_SESSION[ $this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']253 && strtotime($_SESSION[ $this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']254 && ($_SESSION[ $this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)249 if (isset($_SESSION['_auth_file'][$this->_ns]) 250 && true === $_SESSION['_auth_file'][$this->_ns]['authenticated'] 251 && !empty($_SESSION['_auth_file'][$this->_ns]['username']) 252 && strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout'] 253 && strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout'] 254 && ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network) 255 255 ) { 256 256 // User is authenticated! 257 $_SESSION[ $this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s');257 $_SESSION['_auth_file'][$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s'); 258 258 return true; 259 } else if (isset($_SESSION[ $this->_ns]) && true === $_SESSION[$this->_ns]['authenticated']) {260 if (strtotime($_SESSION[ $this->_ns]['last_access_datetime']) > time() - 43200) {259 } else if (isset($_SESSION['_auth_file'][$this->_ns]) && true === $_SESSION['_auth_file'][$this->_ns]['authenticated']) { 260 if (strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - 43200) { 261 261 // Only raise message if last session is less than 12 hours old. 262 262 $app->raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__); … … 265 265 // Log the reason for login expiration. 266 266 $expire_reasons = array(); 267 if (empty($_SESSION[ $this->_ns]['username'])) {267 if (empty($_SESSION['_auth_file'][$this->_ns]['username'])) { 268 268 $expire_reasons[] = 'username not found'; 269 269 } 270 if (strtotime($_SESSION[ $this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) {270 if (strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) { 271 271 $expire_reasons[] = 'login_timeout expired'; 272 272 } 273 if (strtotime($_SESSION[ $this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {273 if (strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) { 274 274 $expire_reasons[] = 'idle_timeout expired'; 275 275 } 276 if ($_SESSION[ $this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {277 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[ $this->_ns]['remote_ip'], getRemoteAddr());278 } 279 $app->logMsg(sprintf('User %s session expired: %s', $_SESSION[ $this->_ns]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);276 if ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) { 277 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION['_auth_file'][$this->_ns]['remote_ip'], getRemoteAddr()); 278 } 279 $app->logMsg(sprintf('User %s session expired: %s', $_SESSION['_auth_file'][$this->_ns]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__); 280 280 } 281 281 -
trunk/lib/Auth_SQL.inc.php
r149 r154 100 100 $app =& App::getInstance(); 101 101 102 $this->_ns = '_auth_' .$namespace;102 $this->_ns = $namespace; 103 103 104 104 // Initialize default parameters. … … 264 264 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "' 265 265 "); 266 $_SESSION[ $this->_ns] = array('authenticated' => false);266 $_SESSION['_auth_sql'][$this->_ns] = array('authenticated' => false); 267 267 } 268 268 … … 276 276 function set($key, $val) 277 277 { 278 if (!isset($_SESSION[ $this->_ns]['user_data'])) {279 $_SESSION[ $this->_ns]['user_data'] = array();280 } 281 $_SESSION[ $this->_ns]['user_data'][$key] = $val;278 if (!isset($_SESSION['_auth_sql'][$this->_ns]['user_data'])) { 279 $_SESSION['_auth_sql'][$this->_ns]['user_data'] = array(); 280 } 281 $_SESSION['_auth_sql'][$this->_ns]['user_data'][$key] = $val; 282 282 } 283 283 … … 292 292 function get($key, $default='') 293 293 { 294 if (isset($_SESSION[ $this->_ns][$key])) {295 return $_SESSION[ $this->_ns][$key];296 } else if (isset($_SESSION[ $this->_ns]['user_data'][$key])) {297 return $_SESSION[ $this->_ns]['user_data'][$key];294 if (isset($_SESSION['_auth_sql'][$this->_ns][$key])) { 295 return $_SESSION['_auth_sql'][$this->_ns][$key]; 296 } else if (isset($_SESSION['_auth_sql'][$this->_ns]['user_data'][$key])) { 297 return $_SESSION['_auth_sql'][$this->_ns]['user_data'][$key]; 298 298 } else { 299 299 return $default; … … 373 373 374 374 // Register authenticated session. 375 $_SESSION[ $this->_ns] = array(375 $_SESSION['_auth_sql'][$this->_ns] = array( 376 376 'authenticated' => true, 377 377 'user_id' => $user_data['user_id'], … … 497 497 498 498 // User login test need only be run once per script execution. We cache the result in the session. 499 if ($this->_authentication_tested && isset($_SESSION[ $this->_ns]['authenticated'])) {500 return $_SESSION[ $this->_ns]['authenticated'];499 if ($this->_authentication_tested && isset($_SESSION['_auth_sql'][$this->_ns]['authenticated'])) { 500 return $_SESSION['_auth_sql'][$this->_ns]['authenticated']; 501 501 } 502 502 … … 521 521 522 522 // Test login with information stored in session. Skip IP matching for users from trusted networks. 523 if (isset($_SESSION[ $this->_ns])524 && true === $_SESSION[ $this->_ns]['authenticated']525 && !empty($_SESSION[ $this->_ns]['username'])526 && strtotime($_SESSION[ $this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']527 && strtotime($_SESSION[ $this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']528 && ($_SESSION[ $this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)523 if (isset($_SESSION['_auth_sql'][$this->_ns]) 524 && true === $_SESSION['_auth_sql'][$this->_ns]['authenticated'] 525 && !empty($_SESSION['_auth_sql'][$this->_ns]['username']) 526 && strtotime($_SESSION['_auth_sql'][$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout'] 527 && strtotime($_SESSION['_auth_sql'][$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout'] 528 && ($_SESSION['_auth_sql'][$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network) 529 529 ) { 530 530 // User is authenticated! 531 $_SESSION[ $this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s');531 $_SESSION['_auth_sql'][$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s'); 532 532 533 533 // Update the DB with the last_access_datetime and increment the seconds_online. … … 544 544 $app->logMsg(sprintf('User update failed. Record not found for user %s (%s).', $this->get('user_id'), $this->get('username')), LOG_NOTICE, __FILE__, __LINE__); 545 545 } 546 } else if (isset($_SESSION[ $this->_ns]) && true === $_SESSION[$this->_ns]['authenticated']) {546 } else if (isset($_SESSION['_auth_sql'][$this->_ns]) && true === $_SESSION['_auth_sql'][$this->_ns]['authenticated']) { 547 547 // User is authenticated, but login has expired. 548 if (strtotime($_SESSION[ $this->_ns]['last_access_datetime']) > time() - 43200) {548 if (strtotime($_SESSION['_auth_sql'][$this->_ns]['last_access_datetime']) > time() - 43200) { 549 549 // Only raise message if last session is less than 12 hours old. 550 550 $app->raiseMsg(_("Your session has expired. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__); … … 553 553 // Log the reason for login expiration. 554 554 $expire_reasons = array(); 555 if (empty($_SESSION[ $this->_ns]['username'])) {555 if (empty($_SESSION['_auth_sql'][$this->_ns]['username'])) { 556 556 $expire_reasons[] = 'username not found'; 557 557 } 558 if (strtotime($_SESSION[ $this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) {558 if (strtotime($_SESSION['_auth_sql'][$this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) { 559 559 $expire_reasons[] = 'login_timeout expired'; 560 560 } 561 if (strtotime($_SESSION[ $this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {561 if (strtotime($_SESSION['_auth_sql'][$this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) { 562 562 $expire_reasons[] = 'idle_timeout expired'; 563 563 } 564 if ($_SESSION[ $this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {565 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[ $this->_ns]['remote_ip'], getRemoteAddr());564 if ($_SESSION['_auth_sql'][$this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) { 565 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION['_auth_sql'][$this->_ns]['remote_ip'], getRemoteAddr()); 566 566 } 567 567 $app->logMsg(sprintf('User %s (%s) session expired: %s', $this->get('user_id'), $this->get('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__); -
trunk/lib/Cache.inc.php
r153 r154 47 47 function Cache($namespace='') 48 48 { 49 $this->_ns = '_cache' .$namespace;50 51 if (!isset($_SESSION[ $this->_ns])) {49 $this->_ns = $namespace; 50 51 if (!isset($_SESSION['_cache'][$this->_ns])) { 52 52 $this->clear(); 53 53 } … … 146 146 147 147 // Remove any value already stored under this key. 148 unset($_SESSION[ $this->_ns][$keyhash]);148 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 149 149 150 150 // Continue to prune the cache if its size is greater than stack_size_limit, but keep at least min_items. 151 while (strlen(serialize($_SESSION[ $this->_ns])) + $var_len >= $this->getParam('stack_size_limit') && sizeof($_SESSION[$this->_ns]) >= $this->getParam('min_items')) {152 array_shift($_SESSION[ $this->_ns]);151 while (strlen(serialize($_SESSION['_cache'][$this->_ns])) + $var_len >= $this->getParam('stack_size_limit') && sizeof($_SESSION['_cache'][$this->_ns]) >= $this->getParam('min_items')) { 152 array_shift($_SESSION['_cache'][$this->_ns]); 153 153 } 154 154 155 155 // Save this value under the specified key. 156 $_SESSION[ $this->_ns][$keyhash] =& $var;156 $_SESSION['_cache'][$this->_ns][$keyhash] =& $var; 157 157 158 158 if ($var_len >= 1024000) { … … 182 182 183 183 $keyhash = md5($key); 184 if (isset($_SESSION[ $this->_ns][$keyhash])) {184 if (isset($_SESSION['_cache'][$this->_ns][$keyhash])) { 185 185 $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__); 186 186 // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this? 187 $tmp =& $_SESSION[ $this->_ns][$keyhash];188 unset($_SESSION[ $this->_ns][$keyhash]);189 $_SESSION[ $this->_ns][$keyhash] =& $tmp;187 $tmp =& $_SESSION['_cache'][$this->_ns][$keyhash]; 188 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 189 $_SESSION['_cache'][$this->_ns][$keyhash] =& $tmp; 190 190 // Return the unserialized datum. 191 return unserialize($_SESSION[ $this->_ns][$keyhash]);191 return unserialize($_SESSION['_cache'][$this->_ns][$keyhash]); 192 192 } else { 193 193 return false; … … 208 208 209 209 $keyhash = md5($key); 210 return array_key_exists($keyhash, $_SESSION[ $this->_ns]);210 return array_key_exists($keyhash, $_SESSION['_cache'][$this->_ns]); 211 211 } 212 212 … … 220 220 { 221 221 $keyhash = md5($key); 222 unset($_SESSION[ $this->_ns][$keyhash]);222 unset($_SESSION['_cache'][$this->_ns][$keyhash]); 223 223 } 224 224 … … 233 233 function clear() 234 234 { 235 $_SESSION[ $this->_ns] = array();235 $_SESSION['_cache'][$this->_ns] = array(); 236 236 } 237 237 -
trunk/lib/ImageThumb.inc.php
r152 r154 320 320 if (!$this->_validFileExtension($file_name)) { 321 321 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s not a valid type. It must have one of the following file name extensions: %s"), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__); 322 $app->logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_ ERR, __FILE__, __LINE__);322 $app->logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_WARNING, __FILE__, __LINE__); 323 323 return false; 324 324 } … … 382 382 if (IMAGETHUMB_METHOD_NETPBM === $this->getParam('resize_method') && file_exists($this->getParam('anytopnm_binary')) && file_exists($this->getParam('pnmscale_binary')) && file_exists($this->getParam('cjpeg_binary'))) { 383 383 // Resize using Netpbm binaries. 384 $app->logMsg(sprintf('Resizing with Netpbm: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);384 // $app->logMsg(sprintf('Resizing with Netpbm: %s', $source_file), LOG_DEBUG, __FILE__, __LINE__); 385 385 $return_val += $this->_resizeWithNetpbm($source_file, $dest_file, $spec); 386 386 } else if (IMAGETHUMB_METHOD_GD === $this->getParam('resize_method') && extension_loaded('gd')) { 387 387 // Resize with GD. 388 $app->logMsg(sprintf('Resizing with GD: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);388 // $app->logMsg(sprintf('Resizing with GD: %s', $source_file), LOG_DEBUG, __FILE__, __LINE__); 389 389 $return_val += $this->_resizeWithGD($source_file, $dest_file, $spec); 390 390 } else { … … 739 739 } 740 740 if (!file_exists($dest_dir)) { 741 if (phpversion() > '5' && false) { ///741 if (phpversion() > '5') { 742 742 // Recursive. 743 if (! 743 if (!file_exists($dest_dir) && !($ret = mkdir($dest_dir, $this->getParam('dest_dir_perms'), true))) { 744 744 $return_val++; 745 745 $app->logMsg(sprintf('mkdir failure: %s', $dest_dir), LOG_ERR, __FILE__, __LINE__); -
trunk/lib/PageNumbers.inc.php
r153 r154 66 66 $this->url_base = $_SERVER['PHP_SELF'] . '?page_number='; 67 67 68 $this->prefs = new Prefs( );68 $this->prefs = new Prefs($_SERVER['PHP_SELF']); 69 69 $this->prefs->setParam(array('persistent' => false)); 70 70 } -
trunk/lib/Prefs.inc.php
r153 r154 63 63 $app =& App::getInstance(); 64 64 65 $this->_ns = '_prefs_' .$namespace;65 $this->_ns = $namespace; 66 66 67 67 // Initialized the prefs array. 68 if (!isset($_SESSION[ $this->_ns])) {68 if (!isset($_SESSION['_prefs'][$this->_ns])) { 69 69 $this->clear(); 70 70 } … … 158 158 { 159 159 if (isset($defaults) && is_array($defaults)) { 160 $_SESSION[ $this->_ns]['defaults'] = array_merge($_SESSION[$this->_ns]['defaults'], $defaults);160 $_SESSION['_prefs'][$this->_ns]['defaults'] = array_merge($_SESSION['_prefs'][$this->_ns]['defaults'], $defaults); 161 161 } 162 162 } … … 180 180 } 181 181 182 if (!isset($_SESSION[ $this->_ns]['defaults'][$key]) || $_SESSION[$this->_ns]['defaults'][$key] != $val || isset($_SESSION[$this->_ns]['persistent'][$key])) {183 $_SESSION[ $this->_ns]['persistent'][$key] = $val;182 if (!isset($_SESSION['_prefs'][$this->_ns]['defaults'][$key]) || $_SESSION['_prefs'][$this->_ns]['defaults'][$key] != $val || isset($_SESSION['_prefs'][$this->_ns]['persistent'][$key])) { 183 $_SESSION['_prefs'][$this->_ns]['persistent'][$key] = $val; 184 184 } 185 185 } … … 196 196 { 197 197 $app =& App::getInstance(); 198 if (array_key_exists($key, $_SESSION[ $this->_ns]['persistent'])) {199 return $_SESSION[ $this->_ns]['persistent'][$key];200 } else if (array_key_exists($key, $_SESSION[ $this->_ns]['defaults'])) {201 return $_SESSION[ $this->_ns]['defaults'][$key];198 if (array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['persistent'])) { 199 return $_SESSION['_prefs'][$this->_ns]['persistent'][$key]; 200 } else if (array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['defaults'])) { 201 return $_SESSION['_prefs'][$this->_ns]['defaults'][$key]; 202 202 } else { 203 $app->logMsg(sprintf('Key not found in prefs cache: %s', $key), LOG_ NOTICE, __FILE__, __LINE__);203 $app->logMsg(sprintf('Key not found in prefs cache: %s', $key), LOG_DEBUG, __FILE__, __LINE__); 204 204 return null; 205 205 } … … 214 214 function exists($key) 215 215 { 216 return array_key_exists($key, $_SESSION[ $this->_ns]['persistent']);216 return array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['persistent']); 217 217 } 218 218 … … 224 224 function delete($key) 225 225 { 226 unset($_SESSION[ $this->_ns]['persistent'][$key]);226 unset($_SESSION['_prefs'][$this->_ns]['persistent'][$key]); 227 227 } 228 228 … … 233 233 function clear() 234 234 { 235 $_SESSION[ $this->_ns] = array(235 $_SESSION['_prefs'][$this->_ns] = array( 236 236 'loaded' => false, 237 237 'load_datetime' => '1970-01-01', … … 286 286 "); 287 287 while (list($key, $val) = mysql_fetch_row($qid)) { 288 $_SESSION[ $this->_ns]['persistent'][$key] = $val;288 $_SESSION['_prefs'][$this->_ns]['persistent'][$key] = $val; 289 289 } 290 290 291 $app->logMsg(sprintf('Loaded %s prefs from database.', sizeof($_SESSION[ $this->_ns]['persistent'])), LOG_DEBUG, __FILE__, __LINE__);291 $app->logMsg(sprintf('Loaded %s prefs from database.', sizeof($_SESSION['_prefs'][$this->_ns]['persistent'])), LOG_DEBUG, __FILE__, __LINE__); 292 292 293 293 // Data loaded only once per session. 294 $_SESSION[ $this->_ns]['loaded'] = true;295 $_SESSION[ $this->_ns]['load_datetime'] = date('Y-m-d H:i:s');294 $_SESSION['_prefs'][$this->_ns]['loaded'] = true; 295 $_SESSION['_prefs'][$this->_ns]['load_datetime'] = date('Y-m-d H:i:s'); 296 296 297 297 return true; … … 310 310 function _isLoaded() 311 311 { 312 if (isset($_SESSION[ $this->_ns]['load_datetime'])313 && strtotime($_SESSION[ $this->_ns]['load_datetime']) > time() - $this->getParam('load_timeout')314 && isset($_SESSION[ $this->_ns]['loaded'])315 && true === $_SESSION[ $this->_ns]['loaded']) {312 if (isset($_SESSION['_prefs'][$this->_ns]['load_datetime']) 313 && strtotime($_SESSION['_prefs'][$this->_ns]['load_datetime']) > time() - $this->getParam('load_timeout') 314 && isset($_SESSION['_prefs'][$this->_ns]['loaded']) 315 && true === $_SESSION['_prefs'][$this->_ns]['loaded']) { 316 316 return true; 317 317 } else { … … 347 347 $this->initDB(); 348 348 349 if (isset($_SESSION[ $this->_ns]['persistent']) && is_array($_SESSION[$this->_ns]['persistent'])) {349 if (isset($_SESSION['_prefs'][$this->_ns]['persistent']) && is_array($_SESSION['_prefs'][$this->_ns]['persistent'])) { 350 350 // Delete old prefs from database. 351 351 $db->query(" … … 357 357 // Insert new prefs. 358 358 $insert_values = array(); 359 foreach ($_SESSION[ $this->_ns]['persistent'] as $key => $val) {359 foreach ($_SESSION['_prefs'][$this->_ns]['persistent'] as $key => $val) { 360 360 $insert_values[] = sprintf("('%s', '%s', '%s', '%s')", $db->escapeString($this->getParam('user_id')), $db->escapeString($this->_ns), $db->escapeString($key), $db->escapeString($val)); 361 361 } -
trunk/lib/SortOrder.inc.php
r153 r154 35 35 function SortOrder($default_sort = '', $default_order = '') 36 36 { 37 $this->prefs = new Prefs($_SERVER['PHP_SELF']); 38 $this->prefs->setParam(array('persistent' => false)); 39 37 40 $this->setDefault($default_sort, $default_order); 38 41 39 42 $this->default_sort = $default_sort; 40 $this->default_order = $default_order; 41 42 $this->prefs = new Prefs(); 43 $this->prefs->setParam(array('persistent' => false)); 43 $this->default_order = $default_order; 44 44 } 45 45 -
trunk/lib/Utilities.inc.php
r136 r154 250 250 * @version 1.1.0 251 251 */ 252 function humanFileSize($size, $ unit=null, $format='%01.2f %s')252 function humanFileSize($size, $max_unit=null, $format='%01.2f %s') 253 253 { 254 254 // Units … … 257 257 258 258 // Max unit 259 $ unit = array_search((string) $unit, $units);260 if ($ unit === null || $unit === false) {261 $ unit = $ii;259 $max_unit = array_search((string) $max_unit, $units); 260 if ($max_unit === null || $max_unit === false) { 261 $max_unit = $ii; 262 262 } 263 263 264 264 // Loop 265 265 $i = 0; 266 while ($ unit != $i && $size >= 1024 && $i < $ii) {266 while ($max_unit != $i && $size >= 1024 && $i < $ii) { 267 267 $size /= 1024; 268 268 $i++;
Note: See TracChangeset
for help on using the changeset viewer.