Changeset 157
- Timestamp:
- Jun 9, 2006 9:25:54 PM (18 years ago)
- Files:
-
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/lib/App.inc.php
r126 r157 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 } 166 $_this =& App::getInstance(); 169 167 170 168 if (isset($param) && is_array($param)) { 171 169 // Merge new parameters with old overriding only those passed. 172 $ this->_params = array_merge($this->_params, $param);170 $_this->_params = array_merge($_this->_params, $param); 173 171 } 174 172 } … … 183 181 function &getParam($param=null) 184 182 { 185 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 186 $this =& App::getInstance(); 187 } 183 $_this =& App::getInstance(); 188 184 189 185 if ($param === null) { 190 return $ this->_params;191 } else if (isset($ this->_params[$param])) {192 return $ this->_params[$param];186 return $_this->_params; 187 } else if (isset($_this->_params[$param])) { 188 return $_this->_params[$param]; 193 189 } else { 194 190 trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE); … … 360 356 function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null) 361 357 { 362 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 363 $this =& App::getInstance(); 364 } 358 $_this =& App::getInstance(); 365 359 366 360 $message = trim($message); 367 361 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__);362 if (!$_this->running || '' == $message) { 363 $_this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 370 364 return false; 371 365 } … … 373 367 // Save message in session under unique key to avoid duplicate messages. 374 368 $msg_id = md5($type . $message . $file . $line); 375 $_SESSION[$ this->app]['messages'][$msg_id] = array(369 $_SESSION[$_this->app]['messages'][$msg_id] = array( 376 370 'type' => $type, 377 371 'message' => $message, 378 372 'file' => $file, 379 373 'line' => $line, 380 'count' => (isset($_SESSION[$ this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->app]['messages'][$msg_id]['count']) : 1)374 'count' => (isset($_SESSION[$_this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1) 381 375 ); 382 376 383 377 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__);378 $_this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__); 385 379 } 386 380 } … … 396 390 function getRaisedMessages() 397 391 { 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__); 392 $_this =& App::getInstance(); 393 394 if (!$_this->running) { 395 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 404 396 return false; 405 397 } 406 398 407 399 $output = array(); 408 while (isset($_SESSION[$ this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {400 while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) { 409 401 $output[] = $message; 410 402 } … … 421 413 function clearRaisedMessages() 422 414 { 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__); 415 $_this =& App::getInstance(); 416 417 if (!$_this->running) { 418 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 429 419 return false; 430 420 } 431 421 432 $_SESSION[$ this->app]['messages'] = array();422 $_SESSION[$_this->app]['messages'] = array(); 433 423 } 434 424 … … 442 432 function printRaisedMessages() 443 433 { 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'])) { 434 $_this =& App::getInstance(); 435 436 if (!$_this->running) { 437 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 438 return false; 439 } 440 441 while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) { 454 442 ?><div class="sc-msg"><?php 455 if (error_reporting() > 0 && $ this->getParam('display_errors')) {443 if (error_reporting() > 0 && $_this->getParam('display_errors')) { 456 444 echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->'; 457 445 } … … 501 489 static $previous_events = array(); 502 490 503 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 504 $this =& App::getInstance(); 505 } 491 $_this =& App::getInstance(); 506 492 507 493 // 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);494 if (!$_this->logPriorityToString($priority)) { 495 $_this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line); 510 496 $priority = LOG_EMERG; 511 497 } 512 498 513 499 // 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));500 if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) { 501 $_this->setParam(array('log_file_priority' => false)); 516 502 // 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);503 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE); 518 504 } 519 505 … … 531 517 $previous_events[$msg_id]++; 532 518 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);519 $_this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line); 534 520 } 535 521 return false; … … 543 529 'remote ip' => getRemoteAddr(), 544 530 'pid' => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''), 545 'type' => $ this->logPriorityToString($priority),531 'type' => $_this->logPriorityToString($priority), 546 532 'file:line' => "$file : $line", 547 533 'url' => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''), … … 550 536 551 537 // FILE ACTION 552 if ($ this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {538 if ($_this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) { 553 539 $event_str = '[' . join('] [', $event) . ']'; 554 error_log($event_str . "\n", 3, $ this->getParam('log_directory') . '/' . $this->getParam('log_filename'));540 error_log($event_str . "\n", 3, $_this->getParam('log_directory') . '/' . $_this->getParam('log_filename')); 555 541 } 556 542 557 543 // EMAIL ACTION 558 if ($ this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {544 if ($_this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) { 559 545 $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message); 560 546 $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST')); … … 563 549 $email_msg .= sprintf("%-11s%s\n", $k, $v); 564 550 } 565 mail($ this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');551 mail($_this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com'); 566 552 } 567 553 568 554 // SMS ACTION 569 if ($ this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {555 if ($_this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) { 570 556 $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority); 571 557 $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line); 572 558 $headers = "From: codebase@strangecode.com"; 573 mail($ this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');559 mail($_this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com'); 574 560 } 575 561 576 562 // SCREEN ACTION 577 if ($ this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {563 if ($_this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) { 578 564 echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n"; 579 565 } … … 620 606 function carryQuery($query_key) 621 607 { 622 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 623 $this =& App::getInstance(); 624 } 608 $_this =& App::getInstance(); 625 609 626 610 // 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)) {611 if (!isset($_this->_carry_queries[$query_key]) && getFormData($query_key, false)) { 628 612 // Copy the value of the specified query argument into the _carry_queries array. 629 $ this->_carry_queries[$query_key] = getFormData($query_key);613 $_this->_carry_queries[$query_key] = getFormData($query_key); 630 614 } 631 615 } … … 652 636 function url($url, $carry_args=null, $always_include_sid=false) 653 637 { 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__); 638 $_this =& App::getInstance(); 639 640 if (!$_this->running) { 641 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 660 642 return false; 661 643 } … … 691 673 if ($do_carry_queries) { 692 674 // Join the global _carry_queries and local one_time_carry_queries. 693 $query_args = urlEncodeArray(array_merge($ this->_carry_queries, $one_time_carry_queries));675 $query_args = urlEncodeArray(array_merge($_this->_carry_queries, $one_time_carry_queries)); 694 676 foreach ($query_args as $key=>$val) { 695 677 // Check value is set and value does not already exist in the url. … … 715 697 ( 716 698 !isset($_COOKIE[session_name()]) 717 || !$ this->getParam('session_use_cookies')699 || !$_this->getParam('session_use_cookies') 718 700 ) 719 && $ this->getParam('enable_session')701 && $_this->getParam('enable_session') 720 702 && isMyDomain($url) 721 703 && … … 748 730 function oHREF($url, $carry_args=null, $always_include_sid=false) 749 731 { 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); 732 $_this =& App::getInstance(); 733 734 $url = $_this->url($url, $carry_args, $always_include_sid); 755 735 756 736 // Replace any & not followed by an html or unicode entity with it's & equivalent. … … 772 752 function printHiddenSession($carry_args=null) 773 753 { 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__); 754 $_this =& App::getInstance(); 755 756 if (!$_this->running) { 757 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 780 758 return false; 781 759 } … … 808 786 // Join the global _carry_queries and local one_time_carry_queries. 809 787 // urlencode is not used here, not for form data! 810 $query_args = array_merge($ this->_carry_queries, $one_time_carry_queries);788 $query_args = array_merge($_this->_carry_queries, $one_time_carry_queries); 811 789 foreach ($query_args as $key=>$val) { 812 790 echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; … … 835 813 function dieURL($url, $carry_args=null, $always_include_sid=false) 836 814 { 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__); 815 $_this =& App::getInstance(); 816 817 if (!$_this->running) { 818 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 843 819 return false; 844 820 } … … 846 822 if ('' == $url) { 847 823 // If URL is not specified, use the redirect_home_url. 848 $url = $ this->getParam('redirect_home_url');824 $url = $_this->getParam('redirect_home_url'); 849 825 } 850 826 … … 856 832 } 857 833 858 $url = $ this->url($url, $carry_args, $always_include_sid);834 $url = $_this->url($url, $carry_args, $always_include_sid); 859 835 860 836 header(sprintf('Location: %s', $url)); 861 $ this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);837 $_this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__); 862 838 863 839 // End this application. 864 840 // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close 865 $ this->stop();841 $_this->stop(); 866 842 die; 867 843 } … … 884 860 function dieBoomerangURL($id=null, $carry_args=null, $default_url=null) 885 861 { 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__); 862 $_this =& App::getInstance(); 863 864 if (!$_this->running) { 865 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 892 866 return false; 893 867 } 894 868 895 869 // 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__);870 if ($_this->validBoomerangURL($id, true)) { 871 if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 872 $url = $_SESSION[$_this->app]['boomerang']['url'][$id]; 873 $_this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 900 874 } else { 901 $url = end($_SESSION[$ this->app]['boomerang']['url']);902 $ this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);875 $url = end($_SESSION[$_this->app]['boomerang']['url']); 876 $_this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 903 877 } 904 878 // Delete stored boomerang. 905 $ this->deleteBoomerangURL($id);879 $_this->deleteBoomerangURL($id); 906 880 } else if (isset($default_url)) { 907 881 $url = $default_url; … … 909 883 // Ensure that the redirecting page is not also the referrer. 910 884 $url = getenv('HTTP_REFERER'); 911 $ this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);885 $_this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 912 886 } else { 913 887 // 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__);888 $url = $_this->getParam('redirect_home_url'); 889 $_this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 916 890 } 917 891 918 892 // A redirection will never happen immediately twice. 919 893 // Set the time so ensure this doesn't happen. 920 $_SESSION[$ this->app]['boomerang']['time'] = time();921 $ this->dieURL($url, $carry_args);894 $_SESSION[$_this->app]['boomerang']['time'] = time(); 895 $_this->dieURL($url, $carry_args); 922 896 } 923 897 … … 931 905 function setBoomerangURL($url=null, $id=null) 932 906 { 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__); 907 $_this =& App::getInstance(); 908 909 if (!$_this->running) { 910 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 939 911 return false; 940 912 } … … 946 918 $url = preg_replace('/boomerang=[\w]+/', '', $url); 947 919 948 if (isset($_SESSION[$ this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {920 if (isset($_SESSION[$_this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) { 949 921 // 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]);922 while ($existing_key = array_search($url, $_SESSION[$_this->app]['boomerang']['url'])) { 923 unset($_SESSION[$_this->app]['boomerang']['url'][$existing_key]); 952 924 } 953 925 } 954 926 955 927 if (isset($id)) { 956 $_SESSION[$ this->app]['boomerang']['url'][$id] = $url;928 $_SESSION[$_this->app]['boomerang']['url'][$id] = $url; 957 929 } else { 958 $_SESSION[$ this->app]['boomerang']['url'][] = $url;959 } 960 $ this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);930 $_SESSION[$_this->app]['boomerang']['url'][] = $url; 931 } 932 $_this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 961 933 return true; 962 934 } else { 963 $ this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);935 $_this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__); 964 936 return false; 965 937 } … … 973 945 function getBoomerangURL($id=null) 974 946 { 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__); 947 $_this =& App::getInstance(); 948 949 if (!$_this->running) { 950 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 981 951 return false; 982 952 } 983 953 984 954 if (isset($id)) { 985 if (isset($_SESSION[$ this->app]['boomerang']['url'][$id])) {986 return $_SESSION[$ this->app]['boomerang']['url'][$id];955 if (isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 956 return $_SESSION[$_this->app]['boomerang']['url'][$id]; 987 957 } else { 988 958 return ''; 989 959 } 990 } else if (is_array($_SESSION[$ this->app]['boomerang']['url'])) {991 return end($_SESSION[$ this->app]['boomerang']['url']);960 } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) { 961 return end($_SESSION[$_this->app]['boomerang']['url']); 992 962 } else { 993 963 return false; … … 1002 972 function deleteBoomerangURL($id=null) 1003 973 { 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']); 974 $_this =& App::getInstance(); 975 976 if (!$_this->running) { 977 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 978 return false; 979 } 980 981 $_this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $_this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__); 982 983 if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 984 unset($_SESSION[$_this->app]['boomerang']['url'][$id]); 985 } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) { 986 array_pop($_SESSION[$_this->app]['boomerang']['url']); 1019 987 } 1020 988 } … … 1028 996 function validBoomerangURL($id=null, $use_nonspecificboomerang=false) 1029 997 { 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__); 998 $_this =& App::getInstance(); 999 1000 if (!$_this->running) { 1001 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 1002 return false; 1003 } 1004 1005 if (!isset($_SESSION[$_this->app]['boomerang']['url'])) { 1006 $_this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__); 1041 1007 return false; 1042 1008 } … … 1045 1011 // a boomerang redirection will always occur at least several seconds after the last boomerang redirect 1046 1012 // or a boomerang being set. 1047 $boomerang_time = isset($_SESSION[$ this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;1013 $boomerang_time = isset($_SESSION[$_this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0; 1048 1014 1049 1015 $url = ''; 1050 if (isset($id) && isset($_SESSION[$ this->app]['boomerang']['url'][$id])) {1051 $url = $_SESSION[$ this->app]['boomerang']['url'][$id];1016 if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 1017 $url = $_SESSION[$_this->app]['boomerang']['url'][$id]; 1052 1018 } else if (!isset($id) || $use_nonspecificboomerang) { 1053 1019 // 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__);1020 $url = end($_SESSION[$_this->app]['boomerang']['url']); 1021 } 1022 1023 $_this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1058 1024 1059 1025 if ('' == $url) { 1060 $ this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);1026 $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__); 1061 1027 return false; 1062 1028 } 1063 1029 if ($url == absoluteMe()) { 1064 1030 // 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__);1031 $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1066 1032 return false; 1067 1033 } 1068 1034 if ($boomerang_time >= (time() - 2)) { 1069 1035 // 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__);1036 $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__); 1037 return false; 1038 } 1039 1040 $_this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1075 1041 return true; 1076 1042 } … … 1082 1048 function sslOn() 1083 1049 { 1084 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 1085 $this =& App::getInstance(); 1086 } 1050 $_this =& App::getInstance(); 1087 1051 1088 1052 if (function_exists('apache_get_modules')) { … … 1093 1057 } 1094 1058 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__);1059 if ('' == getenv('HTTPS') && $_this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) { 1060 $_this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $_this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__); 1097 1061 // 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);1062 $_this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true); 1099 1063 } 1100 1064 } … … 1107 1071 function sslOff() 1108 1072 { 1109 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 1110 $this =& App::getInstance(); 1111 } 1073 $_this =& App::getInstance(); 1112 1074 1113 1075 if ('' != getenv('HTTPS')) { 1114 $ this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);1076 $_this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true); 1115 1077 } 1116 1078 } -
branches/2.0/lib/DB.inc.php
r71 r157 85 85 function setParam($params) 86 86 { 87 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 88 $this =& DB::getInstance(); 89 } 87 $_this =& DB::getInstance(); 90 88 91 89 if (isset($params) && is_array($params)) { 92 90 // Merge new parameters with old overriding only those passed. 93 $ this->_params = array_merge($this->_params, $params);91 $_this->_params = array_merge($_this->_params, $params); 94 92 } else { 95 93 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 108 106 function getParam($param) 109 107 { 110 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 111 $this =& DB::getInstance(); 112 } 113 114 if (isset($this->_params[$param])) { 115 return $this->_params[$param]; 108 $_this =& DB::getInstance(); 109 110 if (isset($_this->_params[$param])) { 111 return $_this->_params[$param]; 116 112 } else { 117 113 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); … … 129 125 function connect() 130 126 { 131 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 132 $this =& DB::getInstance(); 133 } 134 135 if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) { 127 $_this =& DB::getInstance(); 128 129 if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) { 136 130 App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__); 137 131 return false; … … 139 133 140 134 // Connect to database. Always create a new link to the server. 141 if ($ this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {135 if ($_this->dbh = mysql_connect($_this->getParam('db_server'), $_this->getParam('db_user'), $_this->getParam('db_pass'), true)) { 142 136 // Select database 143 mysql_select_db($ this->getParam('db_name'), $this->dbh);137 mysql_select_db($_this->getParam('db_name'), $_this->dbh); 144 138 } 145 139 146 140 // Test for connection errors. 147 if (!$ this->dbh || mysql_error($this->dbh)) {148 $mysql_error_msg = $ this->dbh ? 'Codebase MySQL error: (' . mysql_errno($this->dbh) . ') ' . mysql_error($this->dbh) : 'Codebase MySQL error: Could not connect to server.';141 if (!$_this->dbh || mysql_error($_this->dbh)) { 142 $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.'; 149 143 App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__); 150 144 151 145 // Print helpful or pretty error? 152 if ($ this->getParam('db_debug')) {146 if ($_this->getParam('db_debug')) { 153 147 echo $mysql_error_msg . "\n"; 154 148 } else { … … 157 151 158 152 // Die or continue without connection? 159 if ($ this->getParam('db_die_on_failure')) {153 if ($_this->getParam('db_die_on_failure')) { 160 154 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; 161 155 die; … … 166 160 167 161 // DB connection success! 168 $ this->_connected = true;162 $_this->_connected = true; 169 163 170 164 // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01. 171 $ this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");165 $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */"); 172 166 173 167 return true; … … 183 177 function close() 184 178 { 185 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 186 $this =& DB::getInstance(); 187 } 188 189 if (!$this->_connected) { 190 return false; 191 } 192 193 mysql_close($this->dbh); 179 $_this =& DB::getInstance(); 180 181 if (!$_this->_connected) { 182 return false; 183 } 184 185 mysql_close($_this->dbh); 194 186 } 195 187 … … 198 190 * 199 191 * @access public 200 * @return resource Current value of $ this->dbh.192 * @return resource Current value of $_this->dbh. 201 193 * @author Quinn Comendant <quinn@strangecode.com> 202 194 * @since 20 Aug 2005 13:50:36 … … 204 196 function getDBH() 205 197 { 206 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 207 $this =& DB::getInstance(); 208 } 209 210 if (!$this->_connected) { 211 return false; 212 } 213 214 return $this->dbh; 198 $_this =& DB::getInstance(); 199 200 if (!$_this->_connected) { 201 return false; 202 } 203 204 return $_this->dbh; 215 205 } 216 206 … … 224 214 function isConnected() 225 215 { 226 return $this->_connected; 216 $_this =& DB::getInstance(); 217 218 return $_this->_connected; 227 219 } 228 220 … … 238 230 function escapeString($string) 239 231 { 240 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 241 $this =& DB::getInstance(); 242 } 243 return mysql_real_escape_string($string, $this->dbh); 232 $_this =& DB::getInstance(); 233 234 return mysql_real_escape_string($string, $_this->dbh); 244 235 } 245 236 … … 256 247 static $_query_count = 0; 257 248 258 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 259 $this =& DB::getInstance(); 260 } 261 262 if (!$this->_connected) { 249 $_this =& DB::getInstance(); 250 251 if (!$_this->_connected) { 263 252 return false; 264 253 } … … 266 255 $_query_count++; 267 256 $debugqry = preg_replace("/\n[\t ]+/", "\n", $query); 268 if ($ this->getParam('db_always_debug') || $debug) {257 if ($_this->getParam('db_always_debug') || $debug) { 269 258 echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n"; 270 259 } 271 260 272 261 // Execute! 273 $qid = mysql_query($query, $ this->dbh);262 $qid = mysql_query($query, $_this->dbh); 274 263 275 264 // Error checking. 276 if (!$qid || mysql_error($ this->dbh)) {277 if ($ this->getParam('db_debug')) {278 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($ this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';265 if (!$qid || mysql_error($_this->dbh)) { 266 if ($_this->getParam('db_debug')) { 267 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($_this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>'; 279 268 } else { 280 269 echo _("This page is temporarily unavailable. It should be back up in a few minutes."); 281 270 } 282 App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($ this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);283 if ($ this->getParam('db_die_on_failure')) {271 App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__); 272 if ($_this->getParam('db_die_on_failure')) { 284 273 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; 285 274 die; … … 302 291 function tableExists($table, $use_cached_results=true) 303 292 { 304 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 305 $this =& DB::getInstance(); 306 } 307 308 if (!$this->_connected) { 309 return false; 310 } 311 312 if (!isset($this->existing_tables) || !$use_cached_results) { 313 $this->existing_tables = array(); 314 $qid = $this->query("SHOW TABLES"); 293 $_this =& DB::getInstance(); 294 295 if (!$_this->_connected) { 296 return false; 297 } 298 299 if (!isset($_this->existing_tables) || !$use_cached_results) { 300 $_this->existing_tables = array(); 301 $qid = $_this->query("SHOW TABLES"); 315 302 while (list($row) = mysql_fetch_row($qid)) { 316 $ this->existing_tables[] = $row;317 } 318 } 319 if (in_array($table, $ this->existing_tables)) {303 $_this->existing_tables[] = $row; 304 } 305 } 306 if (in_array($table, $_this->existing_tables)) { 320 307 return true; 321 308 } else { 322 App::logMsg(sprintf('nonexistent DB table: %s.%s', $ this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);309 App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__); 323 310 return false; 324 311 } … … 336 323 function columnExists($table, $columns, $strict=true, $use_cached_results=true) 337 324 { 338 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 339 $this =& DB::getInstance(); 340 } 341 342 if (!$this->_connected) { 325 $_this =& DB::getInstance(); 326 327 if (!$_this->_connected) { 343 328 return false; 344 329 } 345 330 346 331 // Ensure the table exists. 347 if (!$ this->tableExists($table, $use_cached_results)) {332 if (!$_this->tableExists($table, $use_cached_results)) { 348 333 return false; 349 334 } … … 354 339 } 355 340 356 if (!isset($ this->table_columns[$table]) || !$use_cached_results) {341 if (!isset($_this->table_columns[$table]) || !$use_cached_results) { 357 342 // Populate and cache array of current columns for this table. 358 $ this->table_columns[$table] = array();359 $qid = $ this->query("DESCRIBE $table");343 $_this->table_columns[$table] = array(); 344 $qid = $_this->query("DESCRIBE $table"); 360 345 while ($row = mysql_fetch_row($qid)) { 361 $ this->table_columns[$table][] = $row[0];346 $_this->table_columns[$table][] = $row[0]; 362 347 } 363 348 } … … 366 351 // Do an exact comparison of table schemas. 367 352 sort($columns); 368 sort($ this->table_columns[$table]);369 return $ this->table_columns[$table] == $columns;353 sort($_this->table_columns[$table]); 354 return $_this->table_columns[$table] == $columns; 370 355 } else { 371 356 // Only check that the specified columns are available in the table. 372 $match_columns = array_intersect($ this->table_columns[$table], $columns);357 $match_columns = array_intersect($_this->table_columns[$table], $columns); 373 358 sort($columns); 374 359 sort($match_columns); … … 386 371 function resetCache() 387 372 { 388 $ this->existing_tables = null;389 $ this->table_columns = null;373 $_this->existing_tables = null; 374 $_this->table_columns = null; 390 375 } 391 376 -
branches/2.0/lib/SessionCache.inc.php
r53 r157 44 44 function setParam($params) 45 45 { 46 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 47 $this =& SessionCache::getInstance(); 48 } 46 $_this =& SessionCache::getInstance(); 49 47 50 48 if (isset($params) && is_array($params)) { 51 49 // Merge new parameters with old overriding only those passed. 52 $ this->_params = array_merge($this->_params, $params);50 $_this->_params = array_merge($_this->_params, $params); 53 51 } else { 54 52 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 65 63 function getParam($param) 66 64 { 67 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 68 $this =& SessionCache::getInstance(); 69 } 70 71 if (isset($this->_params[$param])) { 72 return $this->_params[$param]; 65 $_this =& SessionCache::getInstance(); 66 67 if (isset($_this->_params[$param])) { 68 return $_this->_params[$param]; 73 69 } else { 74 70 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); … … 95 91 function putCache($var, $var_id, $force_it_in=false) 96 92 { 97 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 98 $this =& SessionCache::getInstance(); 99 } 100 101 if (!$this->getParam('enabled')) { 93 $_this =& SessionCache::getInstance(); 94 95 if (!$_this->getParam('enabled')) { 102 96 App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__); 103 97 return false; … … 108 102 $serialized_var_len = strlen($serialized_var); 109 103 110 if ($serialized_var_len >= $ this->getParam('soft_limit') && !$force_it_in) {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__);104 if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) { 105 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 106 return false; 107 } 108 109 if ($serialized_var_len >= $_this->getParam('hard_limit')) { 110 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); 117 111 return false; 118 112 } … … 123 117 unset($_SESSION['_session_cache'][$var_id]); 124 118 // 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. 125 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $ this->getParam('soft_limit')126 && sizeof($_SESSION['_session_cache']) >= $ this->getParam('min_items')) {119 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit') 120 && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) { 127 121 array_shift($_SESSION['_session_cache']); 128 122 } … … 149 143 function getCache($var_id) 150 144 { 151 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 152 $this =& SessionCache::getInstance(); 153 } 154 155 if (!$this->getParam('enabled')) { 145 $_this =& SessionCache::getInstance(); 146 147 if (!$_this->getParam('enabled')) { 156 148 return false; 157 149 } … … 179 171 function isCached($var_id) 180 172 { 181 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 182 $this =& SessionCache::getInstance(); 183 } 184 185 if (!$this->getParam('enabled')) { 173 $_this =& SessionCache::getInstance(); 174 175 if (!$_this->getParam('enabled')) { 186 176 return false; 187 177 } -
branches/2.0/tests/Auth_SQLTest.php
r126 r157 108 108 $this->assertTrue($true, 'User login failed, but should have succeeded.'); 109 109 110 echo "Testing wrong password...\n";110 // echo "Testing wrong password...\n"; 111 111 $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass'); 112 112 … … 124 124 $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.'); 125 125 126 echo "Testing wrong password...\n";126 // echo "Testing wrong password...\n"; 127 127 $login2 = $this->Auth_SQL->login('testuser', 'wrongpass'); 128 128 $this->assertFalse($login2, '4. User login succeeded, but should have failed.'); -
branches/2.0/tests/EmailTest.php
r42 r157 94 94 $this->assertEquals(41, $gc, 'Unexpected good count.'); 95 95 $this->assertEquals(47, $bc, 'Unexpected bad count.'); 96 echo "Good addresses: $gc\n";97 echo "Bad addresses: $bc\n";96 // echo "Good addresses: $gc\n"; 97 // echo "Bad addresses: $bc\n"; 98 98 // echo join("\n", $bad); 99 99 // echo "\n"; -
tags/2.0.2/lib/App.inc.php
r126 r157 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 } 166 $_this =& App::getInstance(); 169 167 170 168 if (isset($param) && is_array($param)) { 171 169 // Merge new parameters with old overriding only those passed. 172 $ this->_params = array_merge($this->_params, $param);170 $_this->_params = array_merge($_this->_params, $param); 173 171 } 174 172 } … … 183 181 function &getParam($param=null) 184 182 { 185 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 186 $this =& App::getInstance(); 187 } 183 $_this =& App::getInstance(); 188 184 189 185 if ($param === null) { 190 return $ this->_params;191 } else if (isset($ this->_params[$param])) {192 return $ this->_params[$param];186 return $_this->_params; 187 } else if (isset($_this->_params[$param])) { 188 return $_this->_params[$param]; 193 189 } else { 194 190 trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE); … … 360 356 function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null) 361 357 { 362 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 363 $this =& App::getInstance(); 364 } 358 $_this =& App::getInstance(); 365 359 366 360 $message = trim($message); 367 361 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__);362 if (!$_this->running || '' == $message) { 363 $_this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 370 364 return false; 371 365 } … … 373 367 // Save message in session under unique key to avoid duplicate messages. 374 368 $msg_id = md5($type . $message . $file . $line); 375 $_SESSION[$ this->app]['messages'][$msg_id] = array(369 $_SESSION[$_this->app]['messages'][$msg_id] = array( 376 370 'type' => $type, 377 371 'message' => $message, 378 372 'file' => $file, 379 373 'line' => $line, 380 'count' => (isset($_SESSION[$ this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->app]['messages'][$msg_id]['count']) : 1)374 'count' => (isset($_SESSION[$_this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1) 381 375 ); 382 376 383 377 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__);378 $_this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__); 385 379 } 386 380 } … … 396 390 function getRaisedMessages() 397 391 { 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__); 392 $_this =& App::getInstance(); 393 394 if (!$_this->running) { 395 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 404 396 return false; 405 397 } 406 398 407 399 $output = array(); 408 while (isset($_SESSION[$ this->app]['messages']) && $message = array_shift($_SESSION[$this->app]['messages'])) {400 while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) { 409 401 $output[] = $message; 410 402 } … … 421 413 function clearRaisedMessages() 422 414 { 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__); 415 $_this =& App::getInstance(); 416 417 if (!$_this->running) { 418 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 429 419 return false; 430 420 } 431 421 432 $_SESSION[$ this->app]['messages'] = array();422 $_SESSION[$_this->app]['messages'] = array(); 433 423 } 434 424 … … 442 432 function printRaisedMessages() 443 433 { 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'])) { 434 $_this =& App::getInstance(); 435 436 if (!$_this->running) { 437 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 438 return false; 439 } 440 441 while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) { 454 442 ?><div class="sc-msg"><?php 455 if (error_reporting() > 0 && $ this->getParam('display_errors')) {443 if (error_reporting() > 0 && $_this->getParam('display_errors')) { 456 444 echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->'; 457 445 } … … 501 489 static $previous_events = array(); 502 490 503 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 504 $this =& App::getInstance(); 505 } 491 $_this =& App::getInstance(); 506 492 507 493 // 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);494 if (!$_this->logPriorityToString($priority)) { 495 $_this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line); 510 496 $priority = LOG_EMERG; 511 497 } 512 498 513 499 // 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));500 if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) { 501 $_this->setParam(array('log_file_priority' => false)); 516 502 // 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);503 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE); 518 504 } 519 505 … … 531 517 $previous_events[$msg_id]++; 532 518 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);519 $_this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line); 534 520 } 535 521 return false; … … 543 529 'remote ip' => getRemoteAddr(), 544 530 'pid' => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''), 545 'type' => $ this->logPriorityToString($priority),531 'type' => $_this->logPriorityToString($priority), 546 532 'file:line' => "$file : $line", 547 533 'url' => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''), … … 550 536 551 537 // FILE ACTION 552 if ($ this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {538 if ($_this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) { 553 539 $event_str = '[' . join('] [', $event) . ']'; 554 error_log($event_str . "\n", 3, $ this->getParam('log_directory') . '/' . $this->getParam('log_filename'));540 error_log($event_str . "\n", 3, $_this->getParam('log_directory') . '/' . $_this->getParam('log_filename')); 555 541 } 556 542 557 543 // EMAIL ACTION 558 if ($ this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {544 if ($_this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) { 559 545 $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message); 560 546 $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST')); … … 563 549 $email_msg .= sprintf("%-11s%s\n", $k, $v); 564 550 } 565 mail($ this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');551 mail($_this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com'); 566 552 } 567 553 568 554 // SMS ACTION 569 if ($ this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {555 if ($_this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) { 570 556 $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority); 571 557 $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line); 572 558 $headers = "From: codebase@strangecode.com"; 573 mail($ this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');559 mail($_this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com'); 574 560 } 575 561 576 562 // SCREEN ACTION 577 if ($ this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {563 if ($_this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) { 578 564 echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n"; 579 565 } … … 620 606 function carryQuery($query_key) 621 607 { 622 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 623 $this =& App::getInstance(); 624 } 608 $_this =& App::getInstance(); 625 609 626 610 // 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)) {611 if (!isset($_this->_carry_queries[$query_key]) && getFormData($query_key, false)) { 628 612 // Copy the value of the specified query argument into the _carry_queries array. 629 $ this->_carry_queries[$query_key] = getFormData($query_key);613 $_this->_carry_queries[$query_key] = getFormData($query_key); 630 614 } 631 615 } … … 652 636 function url($url, $carry_args=null, $always_include_sid=false) 653 637 { 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__); 638 $_this =& App::getInstance(); 639 640 if (!$_this->running) { 641 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 660 642 return false; 661 643 } … … 691 673 if ($do_carry_queries) { 692 674 // Join the global _carry_queries and local one_time_carry_queries. 693 $query_args = urlEncodeArray(array_merge($ this->_carry_queries, $one_time_carry_queries));675 $query_args = urlEncodeArray(array_merge($_this->_carry_queries, $one_time_carry_queries)); 694 676 foreach ($query_args as $key=>$val) { 695 677 // Check value is set and value does not already exist in the url. … … 715 697 ( 716 698 !isset($_COOKIE[session_name()]) 717 || !$ this->getParam('session_use_cookies')699 || !$_this->getParam('session_use_cookies') 718 700 ) 719 && $ this->getParam('enable_session')701 && $_this->getParam('enable_session') 720 702 && isMyDomain($url) 721 703 && … … 748 730 function oHREF($url, $carry_args=null, $always_include_sid=false) 749 731 { 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); 732 $_this =& App::getInstance(); 733 734 $url = $_this->url($url, $carry_args, $always_include_sid); 755 735 756 736 // Replace any & not followed by an html or unicode entity with it's & equivalent. … … 772 752 function printHiddenSession($carry_args=null) 773 753 { 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__); 754 $_this =& App::getInstance(); 755 756 if (!$_this->running) { 757 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 780 758 return false; 781 759 } … … 808 786 // Join the global _carry_queries and local one_time_carry_queries. 809 787 // urlencode is not used here, not for form data! 810 $query_args = array_merge($ this->_carry_queries, $one_time_carry_queries);788 $query_args = array_merge($_this->_carry_queries, $one_time_carry_queries); 811 789 foreach ($query_args as $key=>$val) { 812 790 echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; … … 835 813 function dieURL($url, $carry_args=null, $always_include_sid=false) 836 814 { 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__); 815 $_this =& App::getInstance(); 816 817 if (!$_this->running) { 818 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 843 819 return false; 844 820 } … … 846 822 if ('' == $url) { 847 823 // If URL is not specified, use the redirect_home_url. 848 $url = $ this->getParam('redirect_home_url');824 $url = $_this->getParam('redirect_home_url'); 849 825 } 850 826 … … 856 832 } 857 833 858 $url = $ this->url($url, $carry_args, $always_include_sid);834 $url = $_this->url($url, $carry_args, $always_include_sid); 859 835 860 836 header(sprintf('Location: %s', $url)); 861 $ this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);837 $_this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__); 862 838 863 839 // End this application. 864 840 // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close 865 $ this->stop();841 $_this->stop(); 866 842 die; 867 843 } … … 884 860 function dieBoomerangURL($id=null, $carry_args=null, $default_url=null) 885 861 { 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__); 862 $_this =& App::getInstance(); 863 864 if (!$_this->running) { 865 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 892 866 return false; 893 867 } 894 868 895 869 // 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__);870 if ($_this->validBoomerangURL($id, true)) { 871 if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 872 $url = $_SESSION[$_this->app]['boomerang']['url'][$id]; 873 $_this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 900 874 } else { 901 $url = end($_SESSION[$ this->app]['boomerang']['url']);902 $ this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);875 $url = end($_SESSION[$_this->app]['boomerang']['url']); 876 $_this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 903 877 } 904 878 // Delete stored boomerang. 905 $ this->deleteBoomerangURL($id);879 $_this->deleteBoomerangURL($id); 906 880 } else if (isset($default_url)) { 907 881 $url = $default_url; … … 909 883 // Ensure that the redirecting page is not also the referrer. 910 884 $url = getenv('HTTP_REFERER'); 911 $ this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);885 $_this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 912 886 } else { 913 887 // 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__);888 $url = $_this->getParam('redirect_home_url'); 889 $_this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 916 890 } 917 891 918 892 // A redirection will never happen immediately twice. 919 893 // Set the time so ensure this doesn't happen. 920 $_SESSION[$ this->app]['boomerang']['time'] = time();921 $ this->dieURL($url, $carry_args);894 $_SESSION[$_this->app]['boomerang']['time'] = time(); 895 $_this->dieURL($url, $carry_args); 922 896 } 923 897 … … 931 905 function setBoomerangURL($url=null, $id=null) 932 906 { 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__); 907 $_this =& App::getInstance(); 908 909 if (!$_this->running) { 910 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 939 911 return false; 940 912 } … … 946 918 $url = preg_replace('/boomerang=[\w]+/', '', $url); 947 919 948 if (isset($_SESSION[$ this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {920 if (isset($_SESSION[$_this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) { 949 921 // 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]);922 while ($existing_key = array_search($url, $_SESSION[$_this->app]['boomerang']['url'])) { 923 unset($_SESSION[$_this->app]['boomerang']['url'][$existing_key]); 952 924 } 953 925 } 954 926 955 927 if (isset($id)) { 956 $_SESSION[$ this->app]['boomerang']['url'][$id] = $url;928 $_SESSION[$_this->app]['boomerang']['url'][$id] = $url; 957 929 } else { 958 $_SESSION[$ this->app]['boomerang']['url'][] = $url;959 } 960 $ this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);930 $_SESSION[$_this->app]['boomerang']['url'][] = $url; 931 } 932 $_this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 961 933 return true; 962 934 } else { 963 $ this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);935 $_this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__); 964 936 return false; 965 937 } … … 973 945 function getBoomerangURL($id=null) 974 946 { 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__); 947 $_this =& App::getInstance(); 948 949 if (!$_this->running) { 950 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 981 951 return false; 982 952 } 983 953 984 954 if (isset($id)) { 985 if (isset($_SESSION[$ this->app]['boomerang']['url'][$id])) {986 return $_SESSION[$ this->app]['boomerang']['url'][$id];955 if (isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 956 return $_SESSION[$_this->app]['boomerang']['url'][$id]; 987 957 } else { 988 958 return ''; 989 959 } 990 } else if (is_array($_SESSION[$ this->app]['boomerang']['url'])) {991 return end($_SESSION[$ this->app]['boomerang']['url']);960 } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) { 961 return end($_SESSION[$_this->app]['boomerang']['url']); 992 962 } else { 993 963 return false; … … 1002 972 function deleteBoomerangURL($id=null) 1003 973 { 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']); 974 $_this =& App::getInstance(); 975 976 if (!$_this->running) { 977 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 978 return false; 979 } 980 981 $_this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $_this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__); 982 983 if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 984 unset($_SESSION[$_this->app]['boomerang']['url'][$id]); 985 } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) { 986 array_pop($_SESSION[$_this->app]['boomerang']['url']); 1019 987 } 1020 988 } … … 1028 996 function validBoomerangURL($id=null, $use_nonspecificboomerang=false) 1029 997 { 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__); 998 $_this =& App::getInstance(); 999 1000 if (!$_this->running) { 1001 $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__); 1002 return false; 1003 } 1004 1005 if (!isset($_SESSION[$_this->app]['boomerang']['url'])) { 1006 $_this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__); 1041 1007 return false; 1042 1008 } … … 1045 1011 // a boomerang redirection will always occur at least several seconds after the last boomerang redirect 1046 1012 // or a boomerang being set. 1047 $boomerang_time = isset($_SESSION[$ this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;1013 $boomerang_time = isset($_SESSION[$_this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0; 1048 1014 1049 1015 $url = ''; 1050 if (isset($id) && isset($_SESSION[$ this->app]['boomerang']['url'][$id])) {1051 $url = $_SESSION[$ this->app]['boomerang']['url'][$id];1016 if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) { 1017 $url = $_SESSION[$_this->app]['boomerang']['url'][$id]; 1052 1018 } else if (!isset($id) || $use_nonspecificboomerang) { 1053 1019 // 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__);1020 $url = end($_SESSION[$_this->app]['boomerang']['url']); 1021 } 1022 1023 $_this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1058 1024 1059 1025 if ('' == $url) { 1060 $ this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);1026 $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__); 1061 1027 return false; 1062 1028 } 1063 1029 if ($url == absoluteMe()) { 1064 1030 // 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__);1031 $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1066 1032 return false; 1067 1033 } 1068 1034 if ($boomerang_time >= (time() - 2)) { 1069 1035 // 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__);1036 $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__); 1037 return false; 1038 } 1039 1040 $_this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__); 1075 1041 return true; 1076 1042 } … … 1082 1048 function sslOn() 1083 1049 { 1084 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 1085 $this =& App::getInstance(); 1086 } 1050 $_this =& App::getInstance(); 1087 1051 1088 1052 if (function_exists('apache_get_modules')) { … … 1093 1057 } 1094 1058 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__);1059 if ('' == getenv('HTTPS') && $_this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) { 1060 $_this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $_this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__); 1097 1061 // 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);1062 $_this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true); 1099 1063 } 1100 1064 } … … 1107 1071 function sslOff() 1108 1072 { 1109 if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) { 1110 $this =& App::getInstance(); 1111 } 1073 $_this =& App::getInstance(); 1112 1074 1113 1075 if ('' != getenv('HTTPS')) { 1114 $ this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);1076 $_this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true); 1115 1077 } 1116 1078 } -
tags/2.0.2/lib/DB.inc.php
r71 r157 85 85 function setParam($params) 86 86 { 87 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 88 $this =& DB::getInstance(); 89 } 87 $_this =& DB::getInstance(); 90 88 91 89 if (isset($params) && is_array($params)) { 92 90 // Merge new parameters with old overriding only those passed. 93 $ this->_params = array_merge($this->_params, $params);91 $_this->_params = array_merge($_this->_params, $params); 94 92 } else { 95 93 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 108 106 function getParam($param) 109 107 { 110 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 111 $this =& DB::getInstance(); 112 } 113 114 if (isset($this->_params[$param])) { 115 return $this->_params[$param]; 108 $_this =& DB::getInstance(); 109 110 if (isset($_this->_params[$param])) { 111 return $_this->_params[$param]; 116 112 } else { 117 113 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); … … 129 125 function connect() 130 126 { 131 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 132 $this =& DB::getInstance(); 133 } 134 135 if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) { 127 $_this =& DB::getInstance(); 128 129 if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) { 136 130 App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__); 137 131 return false; … … 139 133 140 134 // Connect to database. Always create a new link to the server. 141 if ($ this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {135 if ($_this->dbh = mysql_connect($_this->getParam('db_server'), $_this->getParam('db_user'), $_this->getParam('db_pass'), true)) { 142 136 // Select database 143 mysql_select_db($ this->getParam('db_name'), $this->dbh);137 mysql_select_db($_this->getParam('db_name'), $_this->dbh); 144 138 } 145 139 146 140 // Test for connection errors. 147 if (!$ this->dbh || mysql_error($this->dbh)) {148 $mysql_error_msg = $ this->dbh ? 'Codebase MySQL error: (' . mysql_errno($this->dbh) . ') ' . mysql_error($this->dbh) : 'Codebase MySQL error: Could not connect to server.';141 if (!$_this->dbh || mysql_error($_this->dbh)) { 142 $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.'; 149 143 App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__); 150 144 151 145 // Print helpful or pretty error? 152 if ($ this->getParam('db_debug')) {146 if ($_this->getParam('db_debug')) { 153 147 echo $mysql_error_msg . "\n"; 154 148 } else { … … 157 151 158 152 // Die or continue without connection? 159 if ($ this->getParam('db_die_on_failure')) {153 if ($_this->getParam('db_die_on_failure')) { 160 154 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; 161 155 die; … … 166 160 167 161 // DB connection success! 168 $ this->_connected = true;162 $_this->_connected = true; 169 163 170 164 // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01. 171 $ this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");165 $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */"); 172 166 173 167 return true; … … 183 177 function close() 184 178 { 185 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 186 $this =& DB::getInstance(); 187 } 188 189 if (!$this->_connected) { 190 return false; 191 } 192 193 mysql_close($this->dbh); 179 $_this =& DB::getInstance(); 180 181 if (!$_this->_connected) { 182 return false; 183 } 184 185 mysql_close($_this->dbh); 194 186 } 195 187 … … 198 190 * 199 191 * @access public 200 * @return resource Current value of $ this->dbh.192 * @return resource Current value of $_this->dbh. 201 193 * @author Quinn Comendant <quinn@strangecode.com> 202 194 * @since 20 Aug 2005 13:50:36 … … 204 196 function getDBH() 205 197 { 206 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 207 $this =& DB::getInstance(); 208 } 209 210 if (!$this->_connected) { 211 return false; 212 } 213 214 return $this->dbh; 198 $_this =& DB::getInstance(); 199 200 if (!$_this->_connected) { 201 return false; 202 } 203 204 return $_this->dbh; 215 205 } 216 206 … … 224 214 function isConnected() 225 215 { 226 return $this->_connected; 216 $_this =& DB::getInstance(); 217 218 return $_this->_connected; 227 219 } 228 220 … … 238 230 function escapeString($string) 239 231 { 240 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 241 $this =& DB::getInstance(); 242 } 243 return mysql_real_escape_string($string, $this->dbh); 232 $_this =& DB::getInstance(); 233 234 return mysql_real_escape_string($string, $_this->dbh); 244 235 } 245 236 … … 256 247 static $_query_count = 0; 257 248 258 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 259 $this =& DB::getInstance(); 260 } 261 262 if (!$this->_connected) { 249 $_this =& DB::getInstance(); 250 251 if (!$_this->_connected) { 263 252 return false; 264 253 } … … 266 255 $_query_count++; 267 256 $debugqry = preg_replace("/\n[\t ]+/", "\n", $query); 268 if ($ this->getParam('db_always_debug') || $debug) {257 if ($_this->getParam('db_always_debug') || $debug) { 269 258 echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n"; 270 259 } 271 260 272 261 // Execute! 273 $qid = mysql_query($query, $ this->dbh);262 $qid = mysql_query($query, $_this->dbh); 274 263 275 264 // Error checking. 276 if (!$qid || mysql_error($ this->dbh)) {277 if ($ this->getParam('db_debug')) {278 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($ this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';265 if (!$qid || mysql_error($_this->dbh)) { 266 if ($_this->getParam('db_debug')) { 267 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($_this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>'; 279 268 } else { 280 269 echo _("This page is temporarily unavailable. It should be back up in a few minutes."); 281 270 } 282 App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($ this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);283 if ($ this->getParam('db_die_on_failure')) {271 App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__); 272 if ($_this->getParam('db_die_on_failure')) { 284 273 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; 285 274 die; … … 302 291 function tableExists($table, $use_cached_results=true) 303 292 { 304 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 305 $this =& DB::getInstance(); 306 } 307 308 if (!$this->_connected) { 309 return false; 310 } 311 312 if (!isset($this->existing_tables) || !$use_cached_results) { 313 $this->existing_tables = array(); 314 $qid = $this->query("SHOW TABLES"); 293 $_this =& DB::getInstance(); 294 295 if (!$_this->_connected) { 296 return false; 297 } 298 299 if (!isset($_this->existing_tables) || !$use_cached_results) { 300 $_this->existing_tables = array(); 301 $qid = $_this->query("SHOW TABLES"); 315 302 while (list($row) = mysql_fetch_row($qid)) { 316 $ this->existing_tables[] = $row;317 } 318 } 319 if (in_array($table, $ this->existing_tables)) {303 $_this->existing_tables[] = $row; 304 } 305 } 306 if (in_array($table, $_this->existing_tables)) { 320 307 return true; 321 308 } else { 322 App::logMsg(sprintf('nonexistent DB table: %s.%s', $ this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);309 App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__); 323 310 return false; 324 311 } … … 336 323 function columnExists($table, $columns, $strict=true, $use_cached_results=true) 337 324 { 338 if (!isset($this) || !is_a($this, 'DB') && !is_subclass_of($this, 'DB')) { 339 $this =& DB::getInstance(); 340 } 341 342 if (!$this->_connected) { 325 $_this =& DB::getInstance(); 326 327 if (!$_this->_connected) { 343 328 return false; 344 329 } 345 330 346 331 // Ensure the table exists. 347 if (!$ this->tableExists($table, $use_cached_results)) {332 if (!$_this->tableExists($table, $use_cached_results)) { 348 333 return false; 349 334 } … … 354 339 } 355 340 356 if (!isset($ this->table_columns[$table]) || !$use_cached_results) {341 if (!isset($_this->table_columns[$table]) || !$use_cached_results) { 357 342 // Populate and cache array of current columns for this table. 358 $ this->table_columns[$table] = array();359 $qid = $ this->query("DESCRIBE $table");343 $_this->table_columns[$table] = array(); 344 $qid = $_this->query("DESCRIBE $table"); 360 345 while ($row = mysql_fetch_row($qid)) { 361 $ this->table_columns[$table][] = $row[0];346 $_this->table_columns[$table][] = $row[0]; 362 347 } 363 348 } … … 366 351 // Do an exact comparison of table schemas. 367 352 sort($columns); 368 sort($ this->table_columns[$table]);369 return $ this->table_columns[$table] == $columns;353 sort($_this->table_columns[$table]); 354 return $_this->table_columns[$table] == $columns; 370 355 } else { 371 356 // Only check that the specified columns are available in the table. 372 $match_columns = array_intersect($ this->table_columns[$table], $columns);357 $match_columns = array_intersect($_this->table_columns[$table], $columns); 373 358 sort($columns); 374 359 sort($match_columns); … … 386 371 function resetCache() 387 372 { 388 $ this->existing_tables = null;389 $ this->table_columns = null;373 $_this->existing_tables = null; 374 $_this->table_columns = null; 390 375 } 391 376 -
tags/2.0.2/lib/SessionCache.inc.php
r53 r157 44 44 function setParam($params) 45 45 { 46 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 47 $this =& SessionCache::getInstance(); 48 } 46 $_this =& SessionCache::getInstance(); 49 47 50 48 if (isset($params) && is_array($params)) { 51 49 // Merge new parameters with old overriding only those passed. 52 $ this->_params = array_merge($this->_params, $params);50 $_this->_params = array_merge($_this->_params, $params); 53 51 } else { 54 52 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); … … 65 63 function getParam($param) 66 64 { 67 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 68 $this =& SessionCache::getInstance(); 69 } 70 71 if (isset($this->_params[$param])) { 72 return $this->_params[$param]; 65 $_this =& SessionCache::getInstance(); 66 67 if (isset($_this->_params[$param])) { 68 return $_this->_params[$param]; 73 69 } else { 74 70 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); … … 95 91 function putCache($var, $var_id, $force_it_in=false) 96 92 { 97 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 98 $this =& SessionCache::getInstance(); 99 } 100 101 if (!$this->getParam('enabled')) { 93 $_this =& SessionCache::getInstance(); 94 95 if (!$_this->getParam('enabled')) { 102 96 App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__); 103 97 return false; … … 108 102 $serialized_var_len = strlen($serialized_var); 109 103 110 if ($serialized_var_len >= $ this->getParam('soft_limit') && !$force_it_in) {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__);104 if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) { 105 App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__); 106 return false; 107 } 108 109 if ($serialized_var_len >= $_this->getParam('hard_limit')) { 110 App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__); 117 111 return false; 118 112 } … … 123 117 unset($_SESSION['_session_cache'][$var_id]); 124 118 // 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. 125 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $ this->getParam('soft_limit')126 && sizeof($_SESSION['_session_cache']) >= $ this->getParam('min_items')) {119 while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit') 120 && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) { 127 121 array_shift($_SESSION['_session_cache']); 128 122 } … … 149 143 function getCache($var_id) 150 144 { 151 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 152 $this =& SessionCache::getInstance(); 153 } 154 155 if (!$this->getParam('enabled')) { 145 $_this =& SessionCache::getInstance(); 146 147 if (!$_this->getParam('enabled')) { 156 148 return false; 157 149 } … … 179 171 function isCached($var_id) 180 172 { 181 if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) { 182 $this =& SessionCache::getInstance(); 183 } 184 185 if (!$this->getParam('enabled')) { 173 $_this =& SessionCache::getInstance(); 174 175 if (!$_this->getParam('enabled')) { 186 176 return false; 187 177 } -
tags/2.0.2/tests/Auth_SQLTest.php
r126 r157 108 108 $this->assertTrue($true, 'User login failed, but should have succeeded.'); 109 109 110 echo "Testing wrong password...\n";110 // echo "Testing wrong password...\n"; 111 111 $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass'); 112 112 … … 124 124 $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.'); 125 125 126 echo "Testing wrong password...\n";126 // echo "Testing wrong password...\n"; 127 127 $login2 = $this->Auth_SQL->login('testuser', 'wrongpass'); 128 128 $this->assertFalse($login2, '4. User login succeeded, but should have failed.'); -
tags/2.0.2/tests/EmailTest.php
r42 r157 94 94 $this->assertEquals(41, $gc, 'Unexpected good count.'); 95 95 $this->assertEquals(47, $bc, 'Unexpected bad count.'); 96 echo "Good addresses: $gc\n";97 echo "Bad addresses: $bc\n";96 // echo "Good addresses: $gc\n"; 97 // echo "Bad addresses: $bc\n"; 98 98 // echo join("\n", $bad); 99 99 // echo "\n";
Note: See TracChangeset
for help on using the changeset viewer.