Changeset 135
- Timestamp:
- Jun 1, 2006 7:42:53 AM (18 years ago)
- Location:
- branches/2.0singleton
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0singleton/bin/module_maker/skel/admin.php
r132 r135 58 58 if (getFormData('break_list_cache', false)) { 59 59 // Break the cache because we are changing the list data. 60 $cache-> breakCache($_SERVER['PHP_SELF']);60 $cache->delete($_SERVER['PHP_SELF']); 61 61 } 62 62 … … 258 258 259 259 // Break the cache because we are changing the list data. 260 $cache-> breakCache($_SERVER['PHP_SELF']);260 $cache->delete($_SERVER['PHP_SELF']); 261 261 262 262 // Get the information for this object. … … 288 288 289 289 // Break the cache because we are changing the list data. 290 $cache-> breakCache($_SERVER['PHP_SELF']);290 $cache->delete($_SERVER['PHP_SELF']); 291 291 292 292 %INSERT% … … 314 314 315 315 // Break the cache because we are changing the list data. 316 $cache-> breakCache($_SERVER['PHP_SELF']);316 $cache->delete($_SERVER['PHP_SELF']); 317 317 318 318 %UPDATE% … … 383 383 // without knowing the hash. 384 384 $cache_hash = md5($sql . '|' . $page->total_items); 385 if ($prefs->get Value('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {386 $cache-> breakCache($_SERVER['PHP_SELF']);387 $prefs->set Value('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);388 } 389 390 if ($cache-> isCached($_SERVER['PHP_SELF'])) {385 if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) { 386 $cache->delete($_SERVER['PHP_SELF']); 387 $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 388 } 389 390 if ($cache->exists($_SERVER['PHP_SELF'])) { 391 391 // Get the cached results. 392 $list = $cache->get Cache($_SERVER['PHP_SELF']);392 $list = $cache->get($_SERVER['PHP_SELF']); 393 393 } else { 394 394 // If the list is not already cached, query now. … … 401 401 if (isset($list) && !empty($list)) { 402 402 // Cache the results. 403 $cache-> putCache($list, $_SERVER['PHP_SELF']);403 $cache->set($list, $_SERVER['PHP_SELF']); 404 404 } 405 405 } … … 419 419 420 420 // Break the cache because we are changing the list data. 421 $cache-> breakCache($_SERVER['PHP_SELF']);421 $cache->delete($_SERVER['PHP_SELF']); 422 422 423 423 // Count the ranks with invalid numbers -
branches/2.0singleton/docs/file_layout.txt
r42 r135 55 55 RecordVersion.inc.php (db record versioning system) 56 56 ScriptTimer.inc.php (timer for scripts) 57 SessionCache.inc.php (class for accessing a cache in a users session, stores any variables for quick retreival)57 Cache.inc.php (class for accessing a cache in a users session, stores any variables for quick retreival) 58 58 SortOrder.inc.php (class dealing with sorting of columns in database generated lists) 59 59 SpellCheck.inc.php -
branches/2.0singleton/docs/revision_history.txt
r42 r135 22 22 - RecordLock 23 23 - RecordVersion 24 - SessionCache24 - Cache 25 25 - Upload 26 26 … … 47 47 - app object can be accessed globally without reference to object name by calling methods statically, e.g. App:logMsg() 48 48 - seperate application and codebase parameters from site configuration variables. 49 Use $app->getParam('var') or App::getParam('var') to get app params.49 Use $app->getParam('var') or $app->getParam('var') to get app params. 50 50 F or site configurations do whatever you want (I'm using $cfg['node']['features'] format for configurations) 51 51 … … 59 59 60 60 DB object: 61 - Self contained class for DB functions. db::query is the only necessary function. Maintains connections and state independent of App.61 - Self contained class for DB functions. $db->query is the only necessary function. Maintains connections and state independent of App. 62 62 63 63 Full test suite for all codebase libraries. Run from the command line: "codebase/tests/run_tests.sh;" -
branches/2.0singleton/lib/App.inc.php
r127 r135 7 7 * 8 8 * @author Quinn Comendant <quinn@strangecode.com> 9 * @version 2. 09 * @version 2.1 10 10 */ 11 11 … … 22 22 class App { 23 23 24 // Name of this application.25 var $ app = '_app_';24 // Namespace of this application instance. 25 var $ns; 26 26 27 27 // If $app->start has run successfully. … … 34 34 var $_carry_queries = array(); 35 35 36 // Hashof global application parameters.36 // Dictionary of global application parameters. 37 37 var $_params = array(); 38 38 … … 99 99 100 100 // General application log. 101 'log_filename' => 'app_ error_log',101 'log_filename' => 'app_log', 102 102 103 103 // Logging priority can be any of the following, or false to deactivate: … … 128 128 * This method enforces the singleton pattern for this class. Only one application is running at a time. 129 129 * 130 * @return object Reference to the global SessionCache object. 130 * $param string $namespace Name of this application. 131 * @return object Reference to the global Cache object. 131 132 * @access public 132 133 * @static 133 134 */ 134 function &getInstance($ app=null)135 function &getInstance($namespace='') 135 136 { 136 137 static $instance = null; 137 138 138 139 if ($instance === null) { 139 $instance = new App($ app);140 $instance = new App($namespace); 140 141 } 141 142 … … 146 147 * Constructor. 147 148 */ 148 function App($app=null) 149 { 150 if (isset($app)) { 151 $this->app .= $app; 152 } 149 function App($namespace='') 150 { 151 // Set namespace of application instance. 152 $this->ns = '_app_' . $namespace; 153 153 154 154 // Initialize default parameters. … … 164 164 function setParam($param=null) 165 165 { 166 if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {167 $_this =& App::getInstance();168 }169 170 166 if (isset($param) && is_array($param)) { 171 167 // Merge new parameters with old overriding only those passed. 172 $ _this->_params = array_merge($_this->_params, $param);168 $this->_params = array_merge($this->_params, $param); 173 169 } 174 170 } … … 181 177 * @return mixed Parameter value, or null if not existing. 182 178 */ 183 function &getParam($param=null) 184 { 185 if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) { 186 $_this =& App::getInstance(); 187 } 188 179 function getParam($param=null) 180 { 189 181 if ($param === null) { 190 return $ _this->_params;191 } else if (isset($ _this->_params[$param])) {192 return $ _this->_params[$param];182 return $this->_params; 183 } else if (isset($this->_params[$param])) { 184 return $this->_params[$param]; 193 185 } else { 194 186 trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE); … … 239 231 } 240 232 241 // The only instance of the DB object.233 // There will ever only be one instance of the DB object, and here is where it is instantiated. 242 234 require_once dirname(__FILE__) . '/DB.inc.php'; 243 244 235 $this->db =& DB::getInstance(); 245 246 236 $this->db->setParam(array( 247 237 'db_server' => $this->getParam('db_server'), … … 270 260 if (true === $this->getParam('enable_session')) { 271 261 272 // Set the session ID to one provided in GET/POST. This is necessary for linking273 // between domains and keeping the same session.274 if ($ses = getFormData($this->getParam('session_name'), false)) {275 session_id($ses);276 }277 278 262 if (true === $this->getParam('enable_db_session_handler') && true === $this->getParam('enable_db')) { 279 263 // Database session handling. … … 295 279 session_start(); 296 280 297 if (!isset($_SESSION[$this-> app])) {281 if (!isset($_SESSION[$this->ns])) { 298 282 // Access session data using: $_SESSION['...']. 299 283 // Initialize here _after_ session has started. 300 $_SESSION[$this-> app] = array(284 $_SESSION[$this->ns] = array( 301 285 'messages' => array(), 302 286 'boomerang' => array('url'), … … 360 344 function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null) 361 345 { 362 if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {363 $_this =& App::getInstance();364 }365 366 346 $message = trim($message); 367 347 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__);348 if (!$this->running || '' == $message) { 349 $this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 370 350 return false; 371 351 } … … 373 353 // Save message in session under unique key to avoid duplicate messages. 374 354 $msg_id = md5($type . $message . $file . $line); 375 $_SESSION[$ _this->app]['messages'][$msg_id] = array(355 $_SESSION[$this->ns]['messages'][$msg_id] = array( 376 356 'type' => $type, 377 357 'message' => $message, 378 358 'file' => $file, 379 359 'line' => $line, 380 'count' => (isset($_SESSION[$ _this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1)360 'count' => (isset($_SESSION[$this->ns]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->ns]['messages'][$msg_id]['count']) : 1) 381 361 ); 382 362 383 363 if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) { 384 $ _this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);364 $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__); 385 365 } 386 366 } … … 396 376 function getRaisedMessages() 397 377 { 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__); 378 if (!$this->running) { 379 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 404 380 return false; 405 381 } 406 382 407 383 $output = array(); 408 while (isset($_SESSION[$ _this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {384 while (isset($_SESSION[$this->ns]['messages']) && $message = array_shift($_SESSION[$this->ns]['messages'])) { 409 385 $output[] = $message; 410 386 } … … 421 397 function clearRaisedMessages() 422 398 { 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__); 399 if (!$this->running) { 400 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 429 401 return false; 430 402 } 431 403 432 $_SESSION[$ _this->app]['messages'] = array();404 $_SESSION[$this->ns]['messages'] = array(); 433 405 } 434 406 … … 442 414 function printRaisedMessages() 443 415 { 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'])) { 416 if (!$this->running) { 417 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 418 return false; 419 } 420 421 while (isset($_SESSION[$this->ns]['messages']) && $message = array_shift($_SESSION[$this->ns]['messages'])) { 454 422 ?><div class="sc-msg"><?php 455 if (error_reporting() > 0 && $ _this->getParam('display_errors')) {423 if (error_reporting() > 0 && $this->getParam('display_errors')) { 456 424 echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->'; 457 425 } … … 501 469 static $previous_events = array(); 502 470 503 if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {504 $_this =& App::getInstance();505 }506 507 471 // If priority is not specified, assume the worst. 508 if (!$ _this->logPriorityToString($priority)) {509 $ _this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);472 if (!$this->logPriorityToString($priority)) { 473 $this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line); 510 474 $priority = LOG_EMERG; 511 475 } 512 476 513 477 // If log file is not specified, don't log to a file. 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));478 if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) { 479 $this->setParam(array('log_file_priority' => false)); 516 480 // We must use trigger_error to report this problem rather than calling $app->logMsg, which might lead to an infinite loop. 517 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $ _this->getParam('log_directory')), E_USER_NOTICE);481 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE); 518 482 } 519 483 … … 531 495 $previous_events[$msg_id]++; 532 496 if ($previous_events[$msg_id] == 2) { 533 $ _this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);497 $this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line); 534 498 } 535 499 return false; … … 543 507 'remote ip' => getRemoteAddr(), 544 508 'pid' => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''), 545 'type' => $ _this->logPriorityToString($priority),509 'type' => $this->logPriorityToString($priority), 546 510 'file:line' => "$file : $line", 547 511 'url' => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''), … … 550 514 551 515 // FILE ACTION 552 if ($ _this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) {516 if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) { 553 517 $event_str = '[' . join('] [', $event) . ']'; 554 error_log($event_str . "\n", 3, $ _this->getParam('log_directory') . '/' . $_this->getParam('log_filename'));518 error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename')); 555 519 } 556 520 557 521 // EMAIL ACTION 558 if ($ _this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) {522 if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) { 559 523 $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message); 560 524 $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST')); … … 563 527 $email_msg .= sprintf("%-11s%s\n", $k, $v); 564 528 } 565 mail($ _this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');529 mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com'); 566 530 } 567 531 568 532 // SMS ACTION 569 if ($ _this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) {533 if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) { 570 534 $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority); 571 535 $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line); 572 536 $headers = "From: codebase@strangecode.com"; 573 mail($ _this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');537 mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com'); 574 538 } 575 539 576 540 // SCREEN ACTION 577 if ($ _this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) {541 if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) { 578 542 echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n"; 579 543 } … … 620 584 function carryQuery($query_key) 621 585 { 622 if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {623 $_this =& App::getInstance();624 }625 626 586 // If not already set, and there is a non-empty value provided in the request... 627 if (!isset($ _this->_carry_queries[$query_key]) && getFormData($query_key, false)) {587 if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) { 628 588 // Copy the value of the specified query argument into the _carry_queries array. 629 $ _this->_carry_queries[$query_key] = getFormData($query_key);589 $this->_carry_queries[$query_key] = getFormData($query_key); 630 590 } 631 591 } … … 652 612 function url($url, $carry_args=null, $always_include_sid=false) 653 613 { 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__); 614 if (!$this->running) { 615 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 660 616 return false; 661 617 } … … 691 647 if ($do_carry_queries) { 692 648 // Join the global _carry_queries and local one_time_carry_queries. 693 $query_args = urlEncodeArray(array_merge($ _this->_carry_queries, $one_time_carry_queries));649 $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries)); 694 650 foreach ($query_args as $key=>$val) { 695 651 // Check value is set and value does not already exist in the url. … … 715 671 ( 716 672 !isset($_COOKIE[session_name()]) 717 || !$ _this->getParam('session_use_cookies')673 || !$this->getParam('session_use_cookies') 718 674 ) 719 && $ _this->getParam('enable_session')675 && $this->getParam('enable_session') 720 676 && isMyDomain($url) 721 677 && … … 748 704 function oHREF($url, $carry_args=null, $always_include_sid=false) 749 705 { 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); 706 $url = $this->url($url, $carry_args, $always_include_sid); 755 707 756 708 // Replace any & not followed by an html or unicode entity with it's & equivalent. … … 772 724 function printHiddenSession($carry_args=null) 773 725 { 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__); 726 if (!$this->running) { 727 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 780 728 return false; 781 729 } … … 808 756 // Join the global _carry_queries and local one_time_carry_queries. 809 757 // urlencode is not used here, not for form data! 810 $query_args = array_merge($ _this->_carry_queries, $one_time_carry_queries);758 $query_args = array_merge($this->_carry_queries, $one_time_carry_queries); 811 759 foreach ($query_args as $key=>$val) { 812 echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';760 printf('<input type="hidden" name="%s" value="%s" />', $key, $val); 813 761 } 814 762 } … … 816 764 // Include the SID if cookies are disabled. 817 765 if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) { 818 echo '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';766 printf('<input type="hidden" name="%s" value="%s" />', session_name(), session_id()); 819 767 } 820 768 } … … 829 777 * or FALSE to prevent carrying queries. Can be any of the following formats: 830 778 * -array('key1', key2', key3') <-- to save these keys if in the form data. 831 * -array('key1' =>'value', key2'='value') <-- to set keys to default values if not present in form data.779 * -array('key1' => 'value', key2' => 'value') <-- to set keys to default values if not present in form data. 832 780 * -false <-- To not carry any queries. If URL already has queries those will be retained. 833 781 * @param bool $always_include_sid Force session id to be added to Location header. … … 835 783 function dieURL($url, $carry_args=null, $always_include_sid=false) 836 784 { 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__); 785 if (!$this->running) { 786 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 843 787 return false; 844 788 } … … 846 790 if ('' == $url) { 847 791 // If URL is not specified, use the redirect_home_url. 848 $url = $ _this->getParam('redirect_home_url');792 $url = $this->getParam('redirect_home_url'); 849 793 } 850 794 … … 856 800 } 857 801 858 $url = $ _this->url($url, $carry_args, $always_include_sid);802 $url = $this->url($url, $carry_args, $always_include_sid); 859 803 860 804 header(sprintf('Location: %s', $url)); 861 $ _this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);805 $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__); 862 806 863 807 // End this application. 864 808 // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close 865 $ _this->stop();809 $this->stop(); 866 810 die; 867 811 } … … 884 828 function dieBoomerangURL($id=null, $carry_args=null, $default_url=null) 885 829 { 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__); 830 if (!$this->running) { 831 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 892 832 return false; 893 833 } 894 834 895 835 // Get URL from stored boomerang. Allow non specific URL if ID not valid. 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__);836 if ($this->validBoomerangURL($id, true)) { 837 if (isset($id) && isset($_SESSION[$this->ns]['boomerang']['url'][$id])) { 838 $url = $_SESSION[$this->ns]['boomerang']['url'][$id]; 839 $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 900 840 } else { 901 $url = end($_SESSION[$ _this->app]['boomerang']['url']);902 $ _this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);841 $url = end($_SESSION[$this->ns]['boomerang']['url']); 842 $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 903 843 } 904 844 // Delete stored boomerang. 905 $ _this->deleteBoomerangURL($id);845 $this->deleteBoomerangURL($id); 906 846 } else if (isset($default_url)) { 907 847 $url = $default_url; … … 909 849 // Ensure that the redirecting page is not also the referrer. 910 850 $url = getenv('HTTP_REFERER'); 911 $ _this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);851 $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 912 852 } else { 913 853 // If URL is not specified, use the redirect_home_url. 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__);854 $url = $this->getParam('redirect_home_url'); 855 $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 916 856 } 917 857 918 858 // A redirection will never happen immediately twice. 919 859 // Set the time so ensure this doesn't happen. 920 $_SESSION[$ _this->app]['boomerang']['time'] = time();921 $ _this->dieURL($url, $carry_args);860 $_SESSION[$this->ns]['boomerang']['time'] = time(); 861 $this->dieURL($url, $carry_args); 922 862 } 923 863 … … 931 871 function setBoomerangURL($url=null, $id=null) 932 872 { 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__); 873 if (!$this->running) { 874 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 939 875 return false; 940 876 } … … 946 882 $url = preg_replace('/boomerang=[\w]+/', '', $url); 947 883 948 if (isset($_SESSION[$ _this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) {884 if (isset($_SESSION[$this->ns]['boomerang']['url']) && is_array($_SESSION[$this->ns]['boomerang']['url']) && !empty($_SESSION[$this->ns]['boomerang']['url'])) { 949 885 // If the URL currently exists in the boomerang array, delete. 950 while ($existing_key = array_search($url, $_SESSION[$ _this->app]['boomerang']['url'])) {951 unset($_SESSION[$ _this->app]['boomerang']['url'][$existing_key]);886 while ($existing_key = array_search($url, $_SESSION[$this->ns]['boomerang']['url'])) { 887 unset($_SESSION[$this->ns]['boomerang']['url'][$existing_key]); 952 888 } 953 889 } 954 890 955 891 if (isset($id)) { 956 $_SESSION[$ _this->app]['boomerang']['url'][$id] = $url;892 $_SESSION[$this->ns]['boomerang']['url'][$id] = $url; 957 893 } else { 958 $_SESSION[$ _this->app]['boomerang']['url'][] = $url;959 } 960 $ _this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);894 $_SESSION[$this->ns]['boomerang']['url'][] = $url; 895 } 896 $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 961 897 return true; 962 898 } else { 963 $ _this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);899 $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__); 964 900 return false; 965 901 } … … 973 909 function getBoomerangURL($id=null) 974 910 { 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__); 911 if (!$this->running) { 912 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 981 913 return false; 982 914 } 983 915 984 916 if (isset($id)) { 985 if (isset($_SESSION[$ _this->app]['boomerang']['url'][$id])) {986 return $_SESSION[$ _this->app]['boomerang']['url'][$id];917 if (isset($_SESSION[$this->ns]['boomerang']['url'][$id])) { 918 return $_SESSION[$this->ns]['boomerang']['url'][$id]; 987 919 } else { 988 920 return ''; 989 921 } 990 } else if (is_array($_SESSION[$ _this->app]['boomerang']['url'])) {991 return end($_SESSION[$ _this->app]['boomerang']['url']);922 } else if (is_array($_SESSION[$this->ns]['boomerang']['url'])) { 923 return end($_SESSION[$this->ns]['boomerang']['url']); 992 924 } else { 993 925 return false; … … 1002 934 function deleteBoomerangURL($id=null) 1003 935 { 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']); 936 if (!$this->running) { 937 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 938 return false; 939 } 940 941 $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__); 942 943 if (isset($id) && isset($_SESSION[$this->ns]['boomerang']['url'][$id])) { 944 unset($_SESSION[$this->ns]['boomerang']['url'][$id]); 945 } else if (is_array($_SESSION[$this->ns]['boomerang']['url'])) { 946 array_pop($_SESSION[$this->ns]['boomerang']['url']); 1019 947 } 1020 948 } … … 1028 956 function validBoomerangURL($id=null, $use_nonspecificboomerang=false) 1029 957 { 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__); 958 if (!$this->running) { 959 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 960 return false; 961 } 962 963 if (!isset($_SESSION[$this->ns]['boomerang']['url'])) { 964 $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__); 1041 965 return false; 1042 966 } … … 1045 969 // a boomerang redirection will always occur at least several seconds after the last boomerang redirect 1046 970 // or a boomerang being set. 1047 $boomerang_time = isset($_SESSION[$ _this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0;971 $boomerang_time = isset($_SESSION[$this->ns]['boomerang']['time']) ? $_SESSION[$this->ns]['boomerang']['time'] : 0; 1048 972 1049 973 $url = ''; 1050 if (isset($id) && isset($_SESSION[$ _this->app]['boomerang']['url'][$id])) {1051 $url = $_SESSION[$ _this->app]['boomerang']['url'][$id];974 if (isset($id) && isset($_SESSION[$this->ns]['boomerang']['url'][$id])) { 975 $url = $_SESSION[$this->ns]['boomerang']['url'][$id]; 1052 976 } else if (!isset($id) || $use_nonspecificboomerang) { 1053 977 // Use non specific boomerang if available. 1054 $url = end($_SESSION[$ _this->app]['boomerang']['url']);1055 } 1056 1057 $ _this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);978 $url = end($_SESSION[$this->ns]['boomerang']['url']); 979 } 980 981 $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1058 982 1059 983 if ('' == $url) { 1060 $ _this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);984 $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__); 1061 985 return false; 1062 986 } 1063 987 if ($url == absoluteMe()) { 1064 988 // The URL we are directing to is the current page. 1065 $ _this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);989 $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1066 990 return false; 1067 991 } 1068 992 if ($boomerang_time >= (time() - 2)) { 1069 993 // Last boomerang direction was more than 2 seconds ago. 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__);994 $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__); 995 return false; 996 } 997 998 $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1075 999 return true; 1076 1000 } … … 1082 1006 function sslOn() 1083 1007 { 1084 if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {1085 $_this =& App::getInstance();1086 }1087 1088 1008 if (function_exists('apache_get_modules')) { 1089 1009 $modules = apache_get_modules(); … … 1093 1013 } 1094 1014 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__);1015 if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) { 1016 $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__); 1097 1017 // Always append session because some browsers do not send cookie when crossing to SSL URL. 1098 $ _this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);1018 $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true); 1099 1019 } 1100 1020 } -
branches/2.0singleton/lib/Auth_File.inc.php
r127 r135 1 1 <?php 2 2 /** 3 * Auth_File.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * The Auth_File:: class provides a htpasswd file implementation for 4 7 * authentication. … … 100 103 return $this->_params[$param]; 101 104 } else { 102 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);105 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 103 106 return null; 104 107 } -
branches/2.0singleton/lib/Auth_SQL.inc.php
r130 r135 239 239 return $this->_params[$param]; 240 240 } else { 241 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);241 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 242 242 return null; 243 243 } -
branches/2.0singleton/lib/AuthorizeNet.inc.php
r127 r135 1 1 <?php 2 /** 3 * AuthorizeNet.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 6 * The AuthorizeNet class provides an abstract interface for communicating 7 * with authorize.net's AIM interface. Supports Auth.Net v3.1 8 * 9 * @author Quinn Comendant <quinn@strangecode.com> 10 * @version 1.0 11 * @date 2004-04-06 12 */ 13 2 14 // Example usage 3 15 // require_once 'codebase/lib/AuthorizeNet.inc.php'; … … 14 26 // 'x_Exp_Date' => '042008', 15 27 // 'x_Invoice_Num' => '100', 16 // 'x_Address' => '10 rue Levouv ',28 // 'x_Address' => '10 rue Levouvé', 17 29 // 'x_City' => 'SomeCity', 18 30 // 'x_State' => 'CA', … … 27 39 // } 28 40 29 /** 30 * The AuthorizeNet class provides an abstract interface for communicating 31 * with authorize.net's AIM interface. Supports Auth.Net v3.1 32 * 33 * @author Quinn Comendant <quinn@strangecode.com> 34 * @version 1.0 35 * @date 2004-04-06 36 */ 37 38 require_once dirname(__FILE__) . '/Utilities.inc.php'; 39 40 class AuthorizeNet 41 { 41 class AuthorizeNet { 42 42 43 var $post_url = ''; // The URL to post data to. 43 44 var $md5_hash_value = ','; // A custom value for the response delimination character. … … 156 157 return $this->_params[$param]; 157 158 } else { 158 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);159 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 159 160 return null; 160 161 } -
branches/2.0singleton/lib/CSS.inc.php
r127 r135 52 52 return $this->_params[$param]; 53 53 } else { 54 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);54 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 55 55 return null; 56 56 } -
branches/2.0singleton/lib/DB.inc.php
r127 r135 4 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 5 * 6 * DB abstraction layer.6 * Very lightweight DB semi-abstraction layer. Mainly to catch errors with mysql_query, with some goodies. 7 7 * 8 8 * @author Quinn Comendant <quinn@strangecode.com> 9 * @version 1.0.19 * @version 2.1 10 10 */ 11 11 12 12 class DB { 13 13 14 // If DB::connect has successfully opened a db connection.14 // If $db->connect has successfully opened a db connection. 15 15 var $_connected = false; 16 16 17 // Database handle r.17 // Database handle. 18 18 var $dbh; 19 19 … … 30 30 'db_pass' => null, 31 31 32 // Debugging. 33 'db_always_debug' => false, // TRUE = display all SQL queries. 34 'db_debug' => false, // TRUE = display db errors. 35 'db_die_on_failure' => false, // TRUE = script stops on db error. 32 // Display all SQL queries. 33 'db_always_debug' => false, 34 35 // Display db errors. 36 'db_debug' => false, 37 38 // Script stops on db error. 39 'db_die_on_failure' => false, 36 40 ); 37 41 … … 49 53 * This method enforces the singleton pattern for this class. 50 54 * 51 * @return object Reference to the global SessionCacheobject.55 * @return object Reference to the global DB object. 52 56 * @access public 53 57 * @static … … 65 69 66 70 /** 67 * Constructor. 68 */ 69 function DB() 70 { 71 // Initialize default params. 71 * Set (or overwrite existing) parameters by passing an array of new parameters. 72 * 73 * @access public 74 * 75 * @param array $params Array of parameters (key => val pairs). 76 */ 77 function setParam($params) 78 { 79 $app =& App::getInstance(); 80 72 81 if (isset($params) && is_array($params)) { 73 82 // Merge new parameters with old overriding only those passed. 74 83 $this->_params = array_merge($this->_params, $params); 75 }76 }77 78 /**79 * Set (or overwrite existing) parameters by passing an array of new parameters.80 *81 * @access public82 *83 * @param array $params Array of parameters (key => val pairs).84 */85 function setParam($params)86 {87 $app =& App::getInstance();88 89 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {90 $_this =& DB::getInstance();91 }92 93 if (isset($params) && is_array($params)) {94 // Merge new parameters with old overriding only those passed.95 $_this->_params = array_merge($_this->_params, $params);96 84 } else { 97 85 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 100 88 101 89 /** 102 * Return the value of a parameter. 103 * 104 * @access public 105 * 106 * @param string $param The key of the parameter to return. 107 * 108 * @return mixed Parameter value. 90 * Return the value of a parameter, if it exists. 91 * 92 * @access public 93 * @param string $param Which parameter to return. 94 * @return mixed Configured parameter value. 109 95 */ 110 96 function getParam($param) … … 112 98 $app =& App::getInstance(); 113 99 114 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 115 $_this =& DB::getInstance(); 116 } 117 118 if (isset($_this->_params[$param])) { 119 return $_this->_params[$param]; 100 if (isset($this->_params[$param])) { 101 return $this->_params[$param]; 120 102 } else { 121 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);103 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 122 104 return null; 123 105 } … … 135 117 $app =& App::getInstance(); 136 118 137 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 138 $_this =& DB::getInstance(); 139 } 140 141 if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) { 119 if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) { 142 120 $app->logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__); 143 121 return false; … … 145 123 146 124 // Connect to database. Always create a new link to the server. 147 if ($ _this->dbh = mysql_connect($_this->getParam('db_server'), $_this->getParam('db_user'), $_this->getParam('db_pass'), true)) {125 if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) { 148 126 // Select database 149 mysql_select_db($ _this->getParam('db_name'), $_this->dbh);127 mysql_select_db($this->getParam('db_name'), $this->dbh); 150 128 } 151 129 152 130 // Test for connection errors. 153 if (!$ _this->dbh || mysql_error($_this->dbh)) {154 $mysql_error_msg = $ _this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.';131 if (!$this->dbh || mysql_error($this->dbh)) { 132 $mysql_error_msg = $this->dbh ? 'Codebase MySQL error: (' . mysql_errno($this->dbh) . ') ' . mysql_error($this->dbh) : 'Codebase MySQL error: Could not connect to server.'; 155 133 $app->logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__); 156 134 157 135 // Print helpful or pretty error? 158 if ($ _this->getParam('db_debug')) {136 if ($this->getParam('db_debug')) { 159 137 echo $mysql_error_msg . "\n"; 160 } else {161 echo _("This page is temporarily unavailable. It should be back up in a few minutes.");162 138 } 163 139 164 140 // Die or continue without connection? 165 if ($ _this->getParam('db_die_on_failure')) {141 if ($this->getParam('db_die_on_failure')) { 166 142 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; 167 143 die; … … 172 148 173 149 // DB connection success! 174 $ _this->_connected = true;150 $this->_connected = true; 175 151 176 152 // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01. 177 $ _this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower($app->getParam('character_set'))] . "' */");153 $this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower($app->getParam('character_set'))] . "' */"); 178 154 179 155 return true; … … 189 165 function close() 190 166 { 191 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 192 $_this =& DB::getInstance(); 193 } 194 195 if (!$_this->_connected) { 196 return false; 197 } 198 199 mysql_close($_this->dbh); 167 if (!$this->_connected) { 168 return false; 169 } 170 171 return mysql_close($this->dbh); 200 172 } 201 173 … … 210 182 function getDBH() 211 183 { 212 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 213 $_this =& DB::getInstance(); 214 } 215 216 if (!$_this->_connected) { 217 return false; 218 } 219 220 return $_this->dbh; 184 if (!$this->_connected) { 185 return false; 186 } 187 188 return $this->dbh; 221 189 } 222 190 … … 244 212 function escapeString($string) 245 213 { 246 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 247 $_this =& DB::getInstance(); 248 } 249 return mysql_real_escape_string($string, $_this->dbh); 214 return mysql_real_escape_string($string, $this->dbh); 250 215 } 251 216 … … 264 229 static $_query_count = 0; 265 230 266 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 267 $_this =& DB::getInstance(); 268 } 269 270 if (!$_this->_connected) { 231 if (!$this->_connected) { 271 232 return false; 272 233 } … … 274 235 $_query_count++; 275 236 $debugqry = preg_replace("/\n[\t ]+/", "\n", $query); 276 if ($ _this->getParam('db_always_debug') || $debug) {237 if ($this->getParam('db_always_debug') || $debug) { 277 238 echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n"; 278 239 } 279 240 280 241 // Execute! 281 $qid = mysql_query($query, $ _this->dbh);242 $qid = mysql_query($query, $this->dbh); 282 243 283 244 // Error checking. 284 if (!$qid || mysql_error($ _this->dbh)) {285 if ($ _this->getParam('db_debug')) {286 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($ _this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';245 if (!$qid || mysql_error($this->dbh)) { 246 if ($this->getParam('db_debug')) { 247 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>'; 287 248 } else { 288 249 echo _("This page is temporarily unavailable. It should be back up in a few minutes."); 289 250 } 290 $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($ _this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);291 if ($ _this->getParam('db_die_on_failure')) {251 $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__); 252 if ($this->getParam('db_die_on_failure')) { 292 253 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; 293 254 die; … … 312 273 $app =& App::getInstance(); 313 274 314 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 315 $_this =& DB::getInstance(); 316 } 317 318 if (!$_this->_connected) { 319 return false; 320 } 321 322 if (!isset($_this->existing_tables) || !$use_cached_results) { 323 $_this->existing_tables = array(); 324 $qid = $_this->query("SHOW TABLES"); 275 if (!$this->_connected) { 276 return false; 277 } 278 279 if (!isset($this->existing_tables) || !$use_cached_results) { 280 $this->existing_tables = array(); 281 $qid = $this->query("SHOW TABLES"); 325 282 while (list($row) = mysql_fetch_row($qid)) { 326 $ _this->existing_tables[] = $row;327 } 328 } 329 if (in_array($table, $ _this->existing_tables)) {283 $this->existing_tables[] = $row; 284 } 285 } 286 if (in_array($table, $this->existing_tables)) { 330 287 return true; 331 288 } else { 332 $app->logMsg(sprintf('nonexistent DB table: %s.%s', $ _this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);289 $app->logMsg(sprintf('nonexistent DB table: %s.%s', $this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__); 333 290 return false; 334 291 } … … 346 303 function columnExists($table, $columns, $strict=true, $use_cached_results=true) 347 304 { 348 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 349 $_this =& DB::getInstance(); 350 } 351 352 if (!$_this->_connected) { 305 if (!$this->_connected) { 353 306 return false; 354 307 } 355 308 356 309 // Ensure the table exists. 357 if (!$ _this->tableExists($table, $use_cached_results)) {310 if (!$this->tableExists($table, $use_cached_results)) { 358 311 return false; 359 312 } … … 364 317 } 365 318 366 if (!isset($ _this->table_columns[$table]) || !$use_cached_results) {319 if (!isset($this->table_columns[$table]) || !$use_cached_results) { 367 320 // Populate and cache array of current columns for this table. 368 $ _this->table_columns[$table] = array();369 $qid = $ _this->query("DESCRIBE $table");321 $this->table_columns[$table] = array(); 322 $qid = $this->query("DESCRIBE $table"); 370 323 while ($row = mysql_fetch_row($qid)) { 371 $ _this->table_columns[$table][] = $row[0];324 $this->table_columns[$table][] = $row[0]; 372 325 } 373 326 } … … 376 329 // Do an exact comparison of table schemas. 377 330 sort($columns); 378 sort($ _this->table_columns[$table]);379 return $ _this->table_columns[$table] == $columns;331 sort($this->table_columns[$table]); 332 return $this->table_columns[$table] == $columns; 380 333 } else { 381 334 // Only check that the specified columns are available in the table. 382 $match_columns = array_intersect($ _this->table_columns[$table], $columns);335 $match_columns = array_intersect($this->table_columns[$table], $columns); 383 336 sort($columns); 384 337 sort($match_columns); -
branches/2.0singleton/lib/DBSessionHandler.inc.php
r127 r135 3 3 * DBSessionHandler.inc.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information. 5 * 5 6 * @author Quinn Comendant <quinn@strangecode.com> 6 * @version 1.37 * @version 2.1 7 8 * @since 1999 8 9 */ … … 13 14 14 15 var $_params = array( 15 'db_server' => 'localhost',16 'db_name' => '',17 'db_user' => '',18 'db_pass' => '',19 16 'db_table' => 'session_tbl', 20 17 'create_table' => true, // Automatically create table and verify columns. Better set to false after site launch. … … 30 27 * @since 18 Jul 2005 11:02:50 31 28 */ 32 function DBSessionHandler($db =null, $params=array())29 function DBSessionHandler($db, $params=array()) 33 30 { 34 31 $app =& App::getInstance(); … … 36 33 $this->_params = array_merge($this->_params, $params); 37 34 38 if (isset($db)) { 39 if (is_a($db, 'DB')) { 40 if ($db->isConnected()) { 41 // Use existing db connection. 42 $this->db =& $db; 43 } else { 44 $app->logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__); 35 if (!method_exists($db, 'isConnected')) { 36 $app->logMsg(sprintf('Provided object (%s) is not a valid DB object.', get_class($db)), LOG_ERR, __FILE__, __LINE__); 37 } else { 38 if (!$db->isConnected()) { 39 $app->logMsg('Provided DB object is not connected.', LOG_ERR, __FILE__, __LINE__); 40 } else { 41 // OK! We have a valid, connected DB object. 42 $this->db =& $db; 43 44 // Get create tables config from global context. 45 if (!is_null($app->getParam('db_create_tables'))) { 46 $this->_params['create_table'] = $app->getParam('db_create_tables'); 45 47 } 46 } else { 47 $app->logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__); 48 49 // Ensure db table is fit. 50 $this->initDB(); 51 52 ini_set('session.save_handler', 'user'); 53 session_set_save_handler( 54 array(&$this, 'dbSessionOpen'), 55 array(&$this, 'dbSessionClose'), 56 array(&$this, 'dbSessionRead'), 57 array(&$this, 'dbSessionWrite'), 58 array(&$this, 'dbSessionDestroy'), 59 array(&$this, 'dbSessionGarbage') 60 ); 48 61 } 49 } else {50 // Create our own new db connection.51 require_once dirname(__FILE__) . '/DB.inc.php';52 53 $this->db =& new DB();54 $this->db->setParam(array(55 'db_server' => $this->_params['db_server'],56 'db_name' => $this->_params['db_name'],57 'db_user' => $this->_params['db_user'],58 'db_pass' => $this->_params['db_pass'],59 'db_always_debug' => $this->_params['db_always_debug'],60 'db_debug' => $this->_params['db_debug'],61 'db_die_on_failure' => $this->_params['db_die_on_failure'],62 ));63 64 // Connect to database.65 $this->db->connect();66 62 } 67 68 if (!isset($this) || !is_a($this->db, 'DB') || !$this->db->isConnected()) {69 trigger_error('Invalid DB object or unable to connect to database.', E_USER_ERROR);70 }71 72 // Get create tables config from global context.73 if (!is_null($app->getParam('db_create_tables'))) {74 $this->_params['create_table'] = $app->getParam('db_create_tables');75 }76 77 // Ensure db table is fit.78 $this->initDB();79 80 ini_set('session.save_handler', 'user');81 session_set_save_handler(82 array(&$this, 'dbSessionOpen'),83 array(&$this, 'dbSessionClose'),84 array(&$this, 'dbSessionRead'),85 array(&$this, 'dbSessionWrite'),86 array(&$this, 'dbSessionDestroy'),87 array(&$this, 'dbSessionGarbage')88 );89 63 } 90 64 -
branches/2.0singleton/lib/Email.inc.php
r127 r135 8 8 * @author Quinn Comendant <quinn@strangecode.com> 9 9 * @version 1.0 10 ------------------------------------------------------------------------------------- 10 * 11 11 12 // Example. 12 13 $email = new Email(array( … … 28 29 $app->logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__); 29 30 } 30 ------------------------------------------------------------------------------------- 31 32 * 31 33 */ 32 34 class Email { -
branches/2.0singleton/lib/FormValidator.inc.php
r127 r135 23 23 * $fv->validatePhone('phone1'); 24 24 */ 25 class FormValidator 26 { 25 class FormValidator { 27 26 28 27 // Array filling with error messages. -
branches/2.0singleton/lib/Google_API.inc.php
r42 r135 1 1 <?php 2 2 /** 3 * Google_API.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * Interface to the Google API using SOAP/Client.php. 4 7 * … … 25 28 require_once 'SOAP/Client.php'; 26 29 27 28 /** 29 * PHP Interface to the Google API 30 * 31 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> 32 * @access public 33 */ 34 class Google_API 35 { 30 class Google_API { 36 31 37 32 /** -
branches/2.0singleton/lib/Hierarchy.inc.php
r130 r135 2 2 /** 3 3 * Hierarchy.inc.php 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 */ 6 7 /** 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 8 6 * Objective: This class provides the tools to organize pieces of data into a 9 7 * hierarchy of nodes. Any form of data (article, product, image) can be -
branches/2.0singleton/lib/Image.inc.php
r121 r135 2 2 /** 3 3 * Image.inc.php 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information. 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 5 6 * @author Quinn Comendant <quinn@strangecode.com> 6 7 * @version 1.1 -
branches/2.0singleton/lib/ImageThumb.inc.php
r128 r135 2 2 /** 3 3 * ImageThumb.inc.php 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 5 * 6 6 * @author Quinn Comendant <quinn@strangecode.com> … … 131 131 { 132 132 $app =& App::getInstance(); 133 133 134 134 if (isset($this->_params[$param])) { 135 135 return $this->_params[$param]; 136 136 } else { 137 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);137 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 138 138 return null; 139 139 } -
branches/2.0singleton/lib/MCVE.inc.php
r128 r135 1 1 <?php 2 2 /** 3 * MCVE.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * The MCVE:: class provides functions for communicating with a MCVE server. 4 7 * -
branches/2.0singleton/lib/Nav.inc.php
r128 r135 1 1 <?php 2 2 /** 3 * Nav.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * The Nav:: class provides a system for working with navigation elements. 4 7 * Currently it supports storing page titles and URLs for printing breadcrumbs -
branches/2.0singleton/lib/PEdit.inc.php
r128 r135 1 1 <?php 2 2 /** 3 * PEdit.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * PEdit:: provides a mechanism to store text in php variables 4 7 * which will be printed to the client browser under normal … … 11 14 * To use, include this file, initialize variables, 12 15 * and call printing/editing functions where you want data and forms to 13 * show up. Below is an example of use: 16 * show up. 17 * 18 * @author Quinn Comendant <quinn@strangecode.com> 19 * @concept Beau Smith <beau@beausmith.com> 20 * @version 2.0 21 * 22 * Example of use: 14 23 15 24 // Initialize PEdit object. … … 37 46 $pedit->formEnd(); 38 47 39 * @author Quinn Comendant <quinn@strangecode.com>40 * @concept Beau Smith <beau@beausmith.com>41 * @version 2.042 48 */ 43 49 class PEdit { … … 115 121 { 116 122 $app =& App::getInstance(); 117 123 118 124 if (isset($this->_params[$param])) { 119 125 return $this->_params[$param]; -
branches/2.0singleton/lib/PageNumbers.inc.php
r132 r135 81 81 $this->_per_page = $per_page; 82 82 if ($save_value) { 83 $prefs->set Value('items_per_page', $this->_per_page, $_SERVER['PHP_SELF']);83 $prefs->set('items_per_page', $this->_per_page, $_SERVER['PHP_SELF']); 84 84 } 85 85 } else if ($save_value && $prefs->exists('items_per_page', $_SERVER['PHP_SELF'])) { 86 $this->_per_page = (int)$prefs->get Value('items_per_page', $_SERVER['PHP_SELF']);86 $this->_per_page = (int)$prefs->get('items_per_page', $_SERVER['PHP_SELF']); 87 87 } else if (is_numeric($default) && $default > 0) { 88 88 $this->_per_page = $default; … … 109 109 } 110 110 if ($save_value) { 111 $prefs->set Value('page_number', $this->current_page, $_SERVER['PHP_SELF']);111 $prefs->set('page_number', $this->current_page, $_SERVER['PHP_SELF']); 112 112 } 113 113 } else if ($save_value && $prefs->exists('page_number', $_SERVER['PHP_SELF'])) { 114 $this->current_page = (int)$prefs->get Value('page_number', $_SERVER['PHP_SELF']);114 $this->current_page = (int)$prefs->get('page_number', $_SERVER['PHP_SELF']); 115 115 } 116 116 $this->set_page_number_initialized = true; -
branches/2.0singleton/lib/PayPal.inc.php
r128 r135 1 1 <?php 2 2 /** 3 * PayPal.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * The PayPal:: class provides functions for creating PayPal buttons and for 4 7 * receiving PayPal's Instant Payment Notification (IPN) service. … … 233 236 { 234 237 $app =& App::getInstance(); 235 238 236 239 if (isset($this->_params[$param])) { 237 240 return $this->_params[$param]; 238 241 } else { 239 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);242 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 240 243 return null; 241 244 } -
branches/2.0singleton/lib/Prefs.inc.php
r128 r135 1 1 <?php 2 2 /** 3 * Prefs.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * Prefs:: provides an API for saving arbitrary values in a user's session. 4 * Database save routines to come.5 7 * 6 * @inspiration Horde 2.0's Prefs class. This one is much simpler, but7 * the API for the methods that exist are sort of like Horde's8 * in case we want to be more like it in the future.9 8 * @author Quinn Comendant <quinn@strangecode.com> 10 * @version 1.19 * @version 2.1 11 10 */ 12 11 class Prefs { 13 12 14 /** 15 * Where these preferences can be used. To differentiate between preferences 16 * for a specific script, application, or global. 17 * @var string $scope 18 */ 19 var $scope = 'global'; 20 21 /** 22 * Indicator whether we save in the database or not. 23 * @var boolean $_perpetual 24 */ 25 var $_perpetual = false; 26 27 /** 28 * Hash containing connection parameters. 29 * @var array $params 30 */ 31 var $params = array(); 32 13 // Namespace of preferences. 14 var $ns; 33 15 34 16 /** 35 17 * Prefs constructor. 36 18 */ 37 function Prefs($ dbh=false, $params=array())19 function Prefs($ns='') 38 20 { 39 $this->params = $params; 40 $_perpetual = false; // Until database routines are completed. 21 $this->ns = '_pref_' . $ns; 22 23 // Initialized the prefs array. 24 if (!isset($_SESSION[$this->ns])) { 25 $_SESSION[$this->ns] = array(); 26 } 41 27 } 42 28 … … 45 31 * is not set already. 46 32 * 47 * @param string $ prefThe name of the preference to modify.33 * @param string $key The name of the preference to modify. 48 34 * @param string $val The new value for this preference. 49 * @param string $scope The scope for this preference.50 *51 * @return boolean True if the value was successfully set.52 35 */ 53 function setDefault($pref, $val, $scope=null)36 function default($key, $val) 54 37 { 55 if (!isset($scope)) {56 $scope =& $this->scope;57 }58 59 // No empty values allowed.60 if ('' == $pref || '' == $val || '' == $scope) {61 return false;62 }63 64 // Initialized the prefs array.65 if (!isset($_SESSION['_prefs'])) {66 $_SESSION['_prefs'] = array();67 }68 69 // In case boolean or null values are passed as a string.70 if ($val == 'true') {71 $val = true;72 } else if ($val == 'false') {73 $val = false;74 } else if ($val == 'null') {75 $val = null;76 }77 78 38 // Set it only if not set already. 79 if (!isset($_SESSION['_prefs'][$scope][$pref])) { 80 $_SESSION['_prefs'][$scope][$pref] = $val; 81 return true; 39 if (!isset($_SESSION[$this->ns][$key])) { 40 $_SESSION[$this->ns][$key] = $val; 82 41 } 83 42 } … … 86 45 * Sets the given preferences to the specific value, 87 46 * 88 * @param string $ prefThe name of the preference to modify.47 * @param string $key The name of the preference to modify. 89 48 * @param string $val The new value for this preference. 90 * @param string $scope The scope for this preference.91 *92 * @return boolean True if the value was successfully set.93 49 */ 94 function set Value($pref, $val, $scope=null)50 function set($key, $val) 95 51 { 96 if (!isset($scope)) { 97 $scope =& $this->scope; 98 } 99 100 // No empty values allowed. 101 if ('' == $pref || '' == $val || '' == $scope) { 102 return false; 103 } 104 105 // Initialized the prefs array. 106 if (!isset($_SESSION['_prefs'])) { 107 $_SESSION['_prefs'] = array(); 108 } 109 110 // In case boolean or null values are passed as a string. 111 if ($val == 'true') { 112 $val = true; 113 } else if ($val == 'false') { 114 $val = false; 115 } else if ($val == 'null') { 116 $val = null; 117 } 118 119 $_SESSION['_prefs'][$scope][$pref] = $val; 120 return true; 52 $_SESSION[$this->ns][$key] = $val; 121 53 } 122 54 … … 124 56 * Returns the value of the requested preference. 125 57 * 126 * @param string $pref The name of the preference to retrieve. 127 * @param string $scope The scope for this preference. 58 * @param string $key The name of the preference to retrieve. 128 59 * 129 60 * @return string The value of the preference. 130 61 */ 131 function get Value($pref, $scope=null)62 function get($key) 132 63 { 133 if (!isset($scope)) { 134 $scope =& $this->scope; 135 } 136 137 return (isset($_SESSION['_prefs'][$scope][$pref])) ? $_SESSION['_prefs'][$scope][$pref] : null; 64 return (isset($_SESSION[$this->ns][$key])) ? $_SESSION[$this->ns][$key] : null; 138 65 } 139 66 … … 141 68 * To see if a preference has been set. 142 69 * 143 * @param string $pref The name of the preference to check. 144 * @param string $scope The scope for this preference. 70 * @param string $key The name of the preference to check. 145 71 * 146 72 * @return boolean True if the preference isset and not empty 147 73 * false otherwise. 148 74 */ 149 function exists($ pref, $scope=null)75 function exists($key) 150 76 { 151 if (!isset($scope)) { 152 $scope =& $this->scope; 153 } 154 155 return isset($_SESSION['_prefs'][$scope][$pref]); 77 return isset($_SESSION[$this->ns][$key]); 156 78 } 157 79 … … 159 81 * Clear a set preference value. 160 82 * 161 * @param string $pref The name of the preference to check. 162 * @param string $scope The scope for this preference. 83 * @param string $key The name of the preference to check. 163 84 */ 164 function clearValue($pref, $scope=null)85 function delete($key) 165 86 { 166 if ( !isset($scope)) {167 $scope =& $this->scope;87 if (isset($_SESSION[$this->ns][$key])) { 88 unset($_SESSION[$this->ns][$key]); 168 89 } 169 170 if (isset($_SESSION['_prefs'][$scope][$pref])) {171 unset($_SESSION['_prefs'][$scope][$pref]);172 }173 }174 175 /**176 * Retrieves the requested set of preferences from the user's database177 * entry.178 *179 * @param optional array $prefs An array listing the preferences to180 * retrieve. If not specified, retrieve all of the181 * preferences listed in the $prefs hash.182 *183 * @return mixed True on success or a PEAR_Error object on failure.184 */185 function retrieve()186 {187 // Check that we don't have the preferences loaded yet.188 if ($_SESSION['_prefs']['loaded'] == true || !$_perpetual) {189 return true;190 }191 192 // FIXME: Database query goes here....193 return false;194 195 $_SESSION['_prefs']['loaded'] = true;196 }197 198 /**199 * Stores preferences to SQL server.200 *201 * @param array $prefs (optional) An array listing the preferences to be202 * stored. If not specified, store all of the203 * preferences listed in the $prefs hash.204 *205 * @return mixed True on success or a PEAR_Error object on failure.206 */207 function store($prefs=array())208 {209 $app =& App::getInstance();210 211 // If we are not storing prefs in perpetually.212 if (!$_perpetual) {213 return true;214 }215 216 /*217 * If a list of preferences to store hasn't been provided in218 * $prefs, assume all preferences are desired.219 */220 if (empty($prefs)) {221 $prefs =& $_SESSION['_prefs'];222 } else if ($_SESSION['_prefs']['loaded'] == true) {223 $prefs = array_merge($_SESSION['_prefs'], $prefs);224 }225 226 if (!is_array($prefs) || empty($prefs)) {227 $app->raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__);228 $app->dieBoomerangURL();229 }230 231 // FIXME: Database query goes here....232 return false;233 234 90 } 235 91 … … 237 93 * Perform cleanup operations. 238 94 */ 239 function clea nup()95 function clear() 240 96 { 241 $_SESSION[ '_prefs'] = array();97 $_SESSION[$this->ns] = array(); 242 98 } 243 99 } 244 100 245 101 246 247 248 102 ?> -
branches/2.0singleton/lib/RecordLock.inc.php
r130 r135 1 1 <?php 2 2 /** 3 * RecordLock.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * The RecordLock:: class provides a system for locking abstract DB rows. 4 7 * 5 8 * @author Quinn Comendant <quinn@strangecode.com> 6 * @version 2. 09 * @version 2.1 7 10 */ 8 11 class RecordLock { … … 32 35 function &getInstance($auth_object) 33 36 { 34 static $instance s = array();35 36 if ( !isset($instances[$auth_object->getVal('auth_name')])) {37 $instance s[$auth_object->getVal('auth_name')]= new RecordLock($auth_object);38 } 39 40 return $instance s[$auth_object->getVal('auth_name')];37 static $instance = null; 38 39 if ($instance === null) { 40 $instance = new RecordLock($auth_object); 41 } 42 43 return $instance; 41 44 } 42 45 … … 44 47 * Constructor. Pass an Auth object on which to perform user lookups. 45 48 * 46 * @param mixed $auth_object An Auth_SQL o bject.49 * @param mixed $auth_object An Auth_SQL or Auth_FILE object. 47 50 */ 48 51 function RecordLock($auth_object) … … 50 53 $app =& App::getInstance(); 51 54 52 if (! is_a($auth_object, 'Auth_SQL')) {53 trigger_error('Constructor not provided a valid Auth_ SQLobject.', E_USER_ERROR);55 if (!method_exists($auth_object, 'getVal') || !method_exists($auth_object, 'getUsername')) { 56 trigger_error('Constructor not provided a valid Auth_* object.', E_USER_ERROR); 54 57 } 55 58 … … 125 128 126 129 /** 127 * Return the value of a param setting.128 * 129 * @access 130 * @param string $params Which paramto return.131 * @return mixed Configured paramvalue.130 * Return the value of a parameter, if it exists. 131 * 132 * @access public 133 * @param string $param Which parameter to return. 134 * @return mixed Configured parameter value. 132 135 */ 133 136 function getParam($param) 134 137 { 135 138 $app =& App::getInstance(); 136 139 137 140 if (isset($this->_params[$param])) { 138 141 return $this->_params[$param]; 139 142 } else { 140 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);143 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 141 144 return null; 142 145 } -
branches/2.0singleton/lib/RecordVersion.inc.php
r130 r135 1 1 <?php 2 2 /** 3 * RecordVersion.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 3 6 * The RecordVersion:: class provides a system for saving, reviewing, and 4 7 * restoring versions of a record of any DB table. All the data in the record is … … 14 17 * @version 2.1 15 18 */ 16 17 19 class RecordVersion { 18 20 … … 33 35 * This method enforces the singleton pattern for this class. 34 36 * 35 * @return object Reference to the global Record Versionobject.37 * @return object Reference to the global RecordLock object. 36 38 * @access public 37 39 * @static … … 39 41 function &getInstance($auth_object) 40 42 { 41 static $instance s = array();42 43 if ( !isset($instances[$auth_object->getVal('auth_name')])) {44 $instance s[$auth_object->getVal('auth_name')] = new RecordVersion($auth_object);45 } 46 47 return $instance s[$auth_object->getVal('auth_name')];43 static $instance = null; 44 45 if ($instance === null) { 46 $instance = new RecordLock($auth_object); 47 } 48 49 return $instance; 48 50 } 49 51 … … 57 59 $app =& App::getInstance(); 58 60 59 if (! is_a($auth_object, 'Auth_SQL')) {60 trigger_error('Constructor not provided a valid Auth_ SQLobject.', E_USER_ERROR);61 if (!method_exists($auth_object, 'getVal') || !method_exists($auth_object, 'getUsername')) { 62 trigger_error('Constructor not provided a valid Auth_* object.', E_USER_ERROR); 61 63 } 62 64 … … 136 138 137 139 /** 138 * Return the value of a param setting.139 * 140 * @access 141 * @param string $params Which paramto return.142 * @return mixed Configured paramvalue.140 * Return the value of a parameter, if it exists. 141 * 142 * @access public 143 * @param string $param Which parameter to return. 144 * @return mixed Configured parameter value. 143 145 */ 144 146 function getParam($param) 145 147 { 146 148 $app =& App::getInstance(); 147 149 148 150 if (isset($this->_params[$param])) { 149 151 return $this->_params[$param]; 150 152 } else { 151 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);153 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 152 154 return null; 153 155 } -
branches/2.0singleton/lib/ScriptTimer.inc.php
r92 r135 1 1 <?php 2 2 /** 3 * ScriptTimer.inc.php 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information3 * ScriptTimer.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 5 */ 6 7 6 class ScriptTimer { 8 7 -
branches/2.0singleton/lib/SessionCache.inc.php
r128 r135 1 1 <?php 2 2 /** 3 * SessionCache.inc.php 3 * Cache.inc.php 4 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information 5 * 4 6 * Provides an API for storing a limited amount of data 5 7 * intended to have a short lifetime in a user's session. 6 8 * 7 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information.8 9 * @author Quinn Comendant <quinn@strangecode.com> 9 * @version 1.210 * @version 2.1 10 11 * @since 2001 11 12 */ 12 class SessionCache 13 { 13 14 // Flags. 15 define('CACHE_IGNORE_SIZE', 1); 16 17 class Cache { 18 14 19 var $_params = array( 15 20 'enabled' => true, … … 22 27 * This method enforces the singleton pattern for this class. 23 28 * 24 * @return object Reference to the global SessionCache object.29 * @return object Reference to the global Cache object. 25 30 * @access public 26 31 * @static 27 32 */ 28 function &getInstance() { 33 function &getInstance() 34 { 29 35 static $instance = null; 30 36 31 37 if ($instance === null) { 32 $instance = new SessionCache();38 $instance = new Cache(); 33 39 } 34 40 … … 46 52 $app =& App::getInstance(); 47 53 48 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) {49 $_this =& SessionCache::getInstance();50 }51 52 54 if (isset($params) && is_array($params)) { 53 55 // Merge new parameters with old overriding only those passed. 54 $ _this->_params = array_merge($_this->_params, $params);56 $this->_params = array_merge($this->_params, $params); 55 57 } else { 56 58 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 68 70 { 69 71 $app =& App::getInstance(); 70 71 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 72 $_this =& SessionCache::getInstance(); 73 } 74 75 if (isset($_this->_params[$param])) { 76 return $_this->_params[$param]; 77 } else { 78 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 72 73 if (isset($this->_params[$param])) { 74 return $this->_params[$param]; 75 } else { 76 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 79 77 return null; 80 78 } … … 82 80 83 81 /** 84 * Stores a new variable in the session cache. The $ var_idis is md5'ed82 * Stores a new variable in the session cache. The $key is is md5'ed 85 83 * because if a variable id is a very large integer, the array_shift function 86 * will reset the key to the next largest int key. Weird behavio ur I can't84 * will reset the key to the next largest int key. Weird behavior I can't 87 85 * understand. $session_cache[32341234123] will become $session_cache[0] 88 86 * for example. Usage warning: if the variable is too big to fit, or is 89 87 * old and discarded, you must provide alternative ways of accessing the data. 90 88 * 89 * @param str $key An identifier for the cached object. 91 90 * @param mixed $var The var to store in the session cache. 92 * @param str $var_id An identifyer for the cached object. 93 * @param bool $force_it_in If we have something really big that we 94 * still want to cache, setting this true 95 * allows this. 96 * 97 * @return string The $var_id, or false if the object was too big to cache. 98 */ 99 function putCache($var, $var_id, $force_it_in=false) 91 * @param bool $flags If we have something really big that we 92 * still want to cache, setting this to 93 * CACHE_IGNORE_SIZE allows this. 94 * 95 * @return bool True on success, false otherwise. 96 */ 97 function set($key, $var, $flags=0) 100 98 { 101 99 $app =& App::getInstance(); 102 100 103 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 104 $_this =& SessionCache::getInstance(); 105 } 106 107 if (!$_this->getParam('enabled')) { 108 $app->logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__); 109 return false; 110 } 111 112 $var_id = md5($var_id); 101 if (!$this->getParam('enabled')) { 102 $app->logMsg(sprintf('Cache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__); 103 return false; 104 } 105 106 $key = md5($key); 113 107 $serialized_var = serialize($var); 114 108 $serialized_var_len = strlen($serialized_var); 115 109 116 if ($ serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) {117 $app->logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $ _this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);118 return false; 119 } 120 121 if ($serialized_var_len >= $ _this->getParam('hard_limit')) {122 $app->logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $ _this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);110 if ($flags & CACHE_IGNORE_SIZE > 0 && $serialized_var_len >= $this->getParam('soft_limit')) { 111 $app->logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 112 return false; 113 } 114 115 if ($serialized_var_len >= $this->getParam('hard_limit')) { 116 $app->logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); 123 117 return false; 124 118 } … … 127 121 $_SESSION['_session_cache'] = array(); 128 122 } else { 129 unset($_SESSION['_session_cache'][$ var_id]);123 unset($_SESSION['_session_cache'][$key]); 130 124 // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least. 131 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $ _this->getParam('soft_limit')132 && sizeof($_SESSION['_session_cache']) >= $ _this->getParam('min_items')) {125 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 126 && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) { 133 127 array_shift($_SESSION['_session_cache']); 134 128 } 135 129 } 136 $_SESSION['_session_cache'][$ var_id] =& $serialized_var;130 $_SESSION['_session_cache'][$key] =& $serialized_var; 137 131 138 132 if ($serialized_var_len >= 1024000) { … … 140 134 } 141 135 142 return $var_id;136 return true; 143 137 } 144 138 … … 149 143 * first. 150 144 * 151 * @param string $ var_id The identifyerfor the datum to retrieve.145 * @param string $key The key for the datum to retrieve. 152 146 * 153 147 * @return mixed The requested datum, or false on failure. 154 148 */ 155 function getCache($var_id) 156 { 157 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 158 $_this =& SessionCache::getInstance(); 159 } 160 161 if (!$_this->getParam('enabled')) { 162 return false; 163 } 164 165 $var_id = md5($var_id); 166 if (isset($_SESSION['_session_cache'][$var_id])) { 149 function get($key) 150 { 151 if (!$this->getParam('enabled')) { 152 return false; 153 } 154 155 $key = md5($key); 156 if (isset($_SESSION['_session_cache'][$key])) { 167 157 // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this? 168 $tmp =& $_SESSION['_session_cache'][$ var_id];169 unset($_SESSION['_session_cache'][$ var_id]);170 $_SESSION['_session_cache'][$ var_id] =& $tmp;158 $tmp =& $_SESSION['_session_cache'][$key]; 159 unset($_SESSION['_session_cache'][$key]); 160 $_SESSION['_session_cache'][$key] =& $tmp; 171 161 // Return the unserialized datum. 172 return unserialize($_SESSION['_session_cache'][$ var_id]);162 return unserialize($_SESSION['_session_cache'][$key]); 173 163 } else { 174 164 return false; … … 179 169 * Tells you if the object is cached. 180 170 * 181 * @param string $ var_id The IDof the object to check.171 * @param string $key The key of the object to check. 182 172 * 183 173 * @return bool The return from isset(). 184 174 */ 185 function isCached($var_id) 186 { 187 if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) { 188 $_this =& SessionCache::getInstance(); 189 } 190 191 if (!$_this->getParam('enabled')) { 192 return false; 193 } 194 195 $var_id = md5($var_id); 196 return isset($_SESSION['_session_cache'][$var_id]); 175 function exists($key) 176 { 177 if (!$this->getParam('enabled')) { 178 return false; 179 } 180 181 $key = md5($key); 182 return isset($_SESSION['_session_cache'][$key]); 197 183 } 198 184 … … 200 186 * Tells you if the object is cached. 201 187 * 202 * @param string $ var_id The IDof the object to check.188 * @param string $key The key of the object to check. 203 189 * 204 190 * @return bool The return from isset(). 205 191 */ 206 function breakCache($var_id)207 { 208 $ var_id = md5($var_id);209 if (isset($_SESSION['_session_cache'][$ var_id])) {210 unset($_SESSION['_session_cache'][$ var_id]);211 } 212 } 213 214 // END SessionCache192 function delete($key) 193 { 194 $key = md5($key); 195 if (isset($_SESSION['_session_cache'][$key])) { 196 unset($_SESSION['_session_cache'][$key]); 197 } 198 } 199 200 // END Cache 215 201 } 216 202 -
branches/2.0singleton/lib/SortOrder.inc.php
r132 r135 78 78 if (!empty($new_sort_by)) { 79 79 $this->sort_by = $new_sort_by; 80 $prefs->set Value('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);80 $prefs->set('sort_by', $this->sort_by, $_SERVER['PHP_SELF']); 81 81 } else if ($prefs->exists('sort_by', $_SERVER['PHP_SELF'])) { 82 $this->sort_by = $prefs->get Value('sort_by', $_SERVER['PHP_SELF']);82 $this->sort_by = $prefs->get('sort_by', $_SERVER['PHP_SELF']); 83 83 } else { 84 84 $this->sort_by = $default_sort; … … 92 92 if (!empty($new_order)) { 93 93 $this->order = $new_order; 94 $prefs->set Value('sort_order', $this->order, $_SERVER['PHP_SELF']);94 $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']); 95 95 } else if ($prefs->exists('sort_order', $_SERVER['PHP_SELF'])) { 96 $this->order = $prefs->get Value('sort_order', $_SERVER['PHP_SELF']);96 $this->order = $prefs->get('sort_order', $_SERVER['PHP_SELF']); 97 97 } else { 98 98 $this->order = $default_order; … … 116 116 if (isset($sort)) { 117 117 $this->sort_by = $sort; 118 $prefs->set Value('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);118 $prefs->set('sort_by', $this->sort_by, $_SERVER['PHP_SELF']); 119 119 } 120 120 … … 122 122 if (isset($order)) { 123 123 $this->order = $order; 124 $prefs->set Value('sort_order', $this->order, $_SERVER['PHP_SELF']);124 $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']); 125 125 } 126 126 } -
branches/2.0singleton/lib/SpellCheck.inc.php
r128 r135 116 116 { 117 117 $app =& App::getInstance(); 118 118 119 119 if (isset($this->_params[$param])) { 120 120 return $this->_params[$param]; 121 121 } else { 122 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);122 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 123 123 return null; 124 124 } -
branches/2.0singleton/lib/Upload.inc.php
r128 r135 96 96 { 97 97 $app =& App::getInstance(); 98 98 99 99 if (isset($this->_params[$param])) { 100 100 return $this->_params[$param]; 101 101 } else { 102 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_ DEBUG, __FILE__, __LINE__);102 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 103 103 return null; 104 104 } -
branches/2.0singleton/services/admins.php
r132 r135 11 11 12 12 require_once 'codebase/lib/PageNumbers.inc.php'; 13 require_once 'codebase/lib/ SessionCache.inc.php';13 require_once 'codebase/lib/Cache.inc.php'; 14 14 require_once 'codebase/lib/FormValidator.inc.php'; 15 15 require_once 'codebase/lib/SortOrder.inc.php'; … … 30 30 $fv = new FormValidator(); 31 31 32 $cache =& SessionCache::getInstance();32 $cache =& Cache::getInstance(); 33 33 34 34 // Instantiate a sorting object with the default sort and order. Add SQL for each column. … … 71 71 if (getFormData('break_list_cache', false)) { 72 72 // Break the cache because we are changing the list data. 73 $cache-> breakCache($_SERVER['PHP_SELF']);73 $cache->delete($_SERVER['PHP_SELF']); 74 74 } 75 75 … … 319 319 $app =& App::getInstance(); 320 320 $db =& DB::getInstance(); 321 $cache =& SessionCache::getInstance();321 $cache =& Cache::getInstance(); 322 322 323 323 $lock->select('admin_tbl', 'admin_id', $id); … … 327 327 328 328 // Break the cache because we are changing the list data. 329 $cache-> breakCache($_SERVER['PHP_SELF']);329 $cache->delete($_SERVER['PHP_SELF']); 330 330 331 331 // Get the information for this object. … … 367 367 $app =& App::getInstance(); 368 368 $db =& DB::getInstance(); 369 $cache =& SessionCache::getInstance();369 $cache =& Cache::getInstance(); 370 370 371 371 // Break the cache because we are changing the list data. 372 $cache-> breakCache($_SERVER['PHP_SELF']);372 $cache->delete($_SERVER['PHP_SELF']); 373 373 374 374 // Insert record data. … … 411 411 $app =& App::getInstance(); 412 412 $db =& DB::getInstance(); 413 $cache =& SessionCache::getInstance();413 $cache =& Cache::getInstance(); 414 414 415 415 $lock->select('admin_tbl', 'admin_id', $frm['admin_id']); … … 419 419 420 420 // Break the cache because we are changing the list data. 421 $cache-> breakCache($_SERVER['PHP_SELF']);421 $cache->delete($_SERVER['PHP_SELF']); 422 422 423 423 // If the userpass is left blank or with the filler **** characters, we don't want to update it. … … 456 456 $db =& DB::getInstance(); 457 457 $prefs =& Prefs::getInstance(); 458 $cache =& SessionCache::getInstance();458 $cache =& Cache::getInstance(); 459 459 460 460 $where_clause = ''; … … 507 507 // without knowing the hash. 508 508 $cache_hash = md5($sql . '|' . $page->total_items); 509 if ($prefs->get Value('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {510 $cache-> breakCache($_SERVER['PHP_SELF']);511 $prefs->set Value('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);512 } 513 514 if ($cache-> isCached($_SERVER['PHP_SELF']) && false) {509 if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) { 510 $cache->delete($_SERVER['PHP_SELF']); 511 $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 512 } 513 514 if ($cache->exists($_SERVER['PHP_SELF']) && false) { 515 515 // Get the cached results. 516 $list = $cache->get Cache($_SERVER['PHP_SELF']);516 $list = $cache->get($_SERVER['PHP_SELF']); 517 517 } else { 518 518 // If the list is not already cached, query now. … … 525 525 if (isset($list) && !empty($list)) { 526 526 // Cache the results. 527 $cache-> putCache($list, $_SERVER['PHP_SELF']);527 $cache->set($list, $_SERVER['PHP_SELF']); 528 528 } 529 529 } -
branches/2.0singleton/services/logout.php
r129 r135 5 5 */ 6 6 7 if (is _a($auth, 'Auth_SQL')) {7 if (isset($auth) && method_exists($auth, 'getVal')) { 8 8 // Delete the current user's record locks. 9 9 require_once 'codebase/lib/RecordLock.inc.php'; -
branches/2.0singleton/services/logs.php
r132 r135 40 40 // Set the defaults and catch incoming settings. 41 41 $prefs =& Prefs::getInstance(); 42 $prefs-> setDefault('log_file', $app->getParam('log_filename'), 'logs_module');43 $prefs->set Value('log_file', getFormData('log'), 'logs_module');42 $prefs->default('log_file', $app->getParam('log_filename'), 'logs_module'); 43 $prefs->set('log_file', getFormData('log'), 'logs_module'); 44 44 45 45 // Titles and navigation header. 46 $nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $prefs->get Value('log_file', 'logs_module')), '/admin/logs.php');46 $nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $prefs->get('log_file', 'logs_module')), '/admin/logs.php'); 47 47 48 48 /****************************************************************************** … … 57 57 case 'delete' : 58 58 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); 59 deleteLog($prefs->get Value('log_file', 'logs_module'));60 $prefs->set Value('log_file', $app->getParam('log_filename'), 'logs_module');59 deleteLog($prefs->get('log_file', 'logs_module')); 60 $prefs->set('log_file', $app->getParam('log_filename'), 'logs_module'); 61 61 if ($app->validBoomerangURL('app_log')) { 62 62 // Display boomerang page. … … 69 69 case 'clear' : 70 70 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); 71 clearLog($prefs->get Value('log_file', 'logs_module'));71 clearLog($prefs->get('log_file', 'logs_module')); 72 72 if ($app->validBoomerangURL('app_log')) { 73 73 // Display boomerang page. … … 80 80 case 'archive' : 81 81 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); 82 if (archiveLog($prefs->get Value('log_file', 'logs_module'))) {82 if (archiveLog($prefs->get('log_file', 'logs_module'))) { 83 83 // Now flush current log. 84 84 $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear'); … … 98 98 case 'download' : 99 99 header('Content-Type: application/octet-stream'); 100 header(sprintf('Content-Disposition: attachment; filename=%s.txt', $prefs->get Value('log_file', 'logs_module')));101 printLog($prefs->get Value('log_file', 'logs_module'));100 header(sprintf('Content-Disposition: attachment; filename=%s.txt', $prefs->get('log_file', 'logs_module'))); 101 printLog($prefs->get('log_file', 'logs_module')); 102 102 die; 103 103 break; 104 104 105 105 default : 106 $list =& getLog($prefs->get Value('log_file', 'logs_module'), getFormData('search_query'));106 $list =& getLog($prefs->get('log_file', 'logs_module'), getFormData('search_query')); 107 107 $main_template = 'log_list.ihtml'; 108 108 break; … … 126 126 include 'header.ihtml'; 127 127 if ('output' == $main_template) { 128 printLog($prefs->get Value('log_file', 'logs_module'));128 printLog($prefs->get('log_file', 'logs_module')); 129 129 } else { 130 130 include 'codebase/services/templates/' . $main_template; -
branches/2.0singleton/services/templates/log_list.ihtml
r132 r135 10 10 <tr class="commandtext"> 11 11 <td> 12 <?php if ($l['filename'] == $prefs->get Value('log_file', 'logs_module')) { ?>12 <?php if ($l['filename'] == $prefs->get('log_file', 'logs_module')) { ?> 13 13 <span class="commanditem"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></span> 14 14 <?php } else { ?> -
branches/2.0singleton/tests/SessionCacheTest.php
r42 r135 4 4 5 5 /** 6 * PHPUnit test case for SessionCache6 * PHPUnit test case for Cache 7 7 * 8 8 * The method skeletons below need to be filled in with … … 13 13 */ 14 14 require_once 'PHPUnit.php'; 15 class SessionCacheTest extends PHPUnit_TestCase {15 class CacheTest extends PHPUnit_TestCase { 16 16 17 var $ SessionCache;17 var $Cache; 18 18 19 function SessionCacheTest($name)19 function CacheTest($name) 20 20 { 21 21 $this->PHPUnit_TestCase($name); … … 25 25 { 26 26 require dirname(__FILE__) . '/_config.inc.php'; 27 require_once '../lib/ SessionCache.inc.php';28 $this-> SessionCache =& new SessionCache(PARAM);27 require_once '../lib/Cache.inc.php'; 28 $this->Cache =& new Cache(PARAM); 29 29 } 30 30 31 31 function tearDown() 32 32 { 33 unset($this-> SessionCache);33 unset($this->Cache); 34 34 } 35 35 36 36 function test_getinstance() 37 37 { 38 $result = $this-> SessionCache->getinstance(PARAM);38 $result = $this->Cache->getinstance(PARAM); 39 39 $expected = EXPECTED_VAL; 40 40 $this->assertEquals($expected, $result); … … 43 43 function test_setparam() 44 44 { 45 $result = $this-> SessionCache->setparam(PARAM);45 $result = $this->Cache->setparam(PARAM); 46 46 $expected = EXPECTED_VAL; 47 47 $this->assertEquals($expected, $result); … … 50 50 function test_getparam() 51 51 { 52 $result = $this-> SessionCache->getparam(PARAM);52 $result = $this->Cache->getparam(PARAM); 53 53 $expected = EXPECTED_VAL; 54 54 $this->assertEquals($expected, $result); … … 57 57 function test_putcache() 58 58 { 59 $result = $this-> SessionCache->putcache(PARAM);59 $result = $this->Cache->putcache(PARAM); 60 60 $expected = EXPECTED_VAL; 61 61 $this->assertEquals($expected, $result); … … 64 64 function test_getcache() 65 65 { 66 $result = $this-> SessionCache->getcache(PARAM);66 $result = $this->Cache->getcache(PARAM); 67 67 $expected = EXPECTED_VAL; 68 68 $this->assertEquals($expected, $result); … … 71 71 function test_iscached() 72 72 { 73 $result = $this-> SessionCache->iscached(PARAM);73 $result = $this->Cache->iscached(PARAM); 74 74 $expected = EXPECTED_VAL; 75 75 $this->assertEquals($expected, $result); … … 78 78 function test_breakcache() 79 79 { 80 $result = $this-> SessionCache->breakcache(PARAM);80 $result = $this->Cache->breakcache(PARAM); 81 81 $expected = EXPECTED_VAL; 82 82 $this->assertEquals($expected, $result); … … 85 85 } 86 86 // Running the test. 87 $suite = new PHPUnit_TestSuite(' SessionCacheTest');87 $suite = new PHPUnit_TestSuite('CacheTest'); 88 88 $result = PHPUnit::run($suite); 89 89 echo $result->toString();
Note: See TracChangeset
for help on using the changeset viewer.