Changeset 446 for branches/eli_branch/lib/App.inc.php
- Timestamp:
- Dec 11, 2013 6:09:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eli_branch/lib/App.inc.php
r442 r446 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 31 31 32 32 //ob_start(); 33 33 34 34 // Message Types. 35 35 define('MSG_ERR', 1); … … 88 88 'session_name' => '_session', 89 89 'session_use_cookies' => true, 90 90 91 91 // Pass the session-id through URLs if cookies are not enabled? 92 92 // Disable this to prevent session ID theft. … … 192 192 // Initialize default parameters. 193 193 $this->_params = array_merge($this->_params, $this->_param_defaults); 194 194 195 195 // Begin timing script. 196 196 require_once dirname(__FILE__) . '/ScriptTimer.inc.php'; … … 246 246 247 247 // Error reporting. 248 /*249 248 ini_set('error_reporting', $this->getParam('error_reporting')); 250 249 ini_set('display_errors', $this->getParam('display_errors')); … … 253 252 ini_set('error_log', $this->getParam('log_directory') . '/' . $this->getParam('php_error_log')); 254 253 } 255 */ 254 256 255 // Set character set to use for multi-byte string functions. 257 256 mb_internal_encoding($this->getParam('character_set')); … … 276 275 277 276 if (true === $this->getParam('enable_db')) { 278 277 279 278 // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root. 280 279 if (!empty($_SERVER['DB_SERVER'])) { … … 367 366 $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST')))); 368 367 } 369 368 370 369 // In case site_email isn't set, use something halfway presentable. 371 370 if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_email')) { … … 380 379 // Character set. This should also be printed in the html header template. 381 380 //header('Content-type: text/html; charset=' . $this->getParam('character_set')); 382 381 383 382 // Set the version of the codebase we're using. 384 383 $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt'; … … 438 437 return false; 439 438 } 440 439 441 440 // Avoid duplicate full-stops.. 442 441 $message = trim(preg_replace('/\.{2}$/', '.', $message)); … … 453 452 ); 454 453 } 455 454 456 455 if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) { 457 456 $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__); 458 457 } 459 458 } 460 459 461 460 /** 462 461 * Returns an array of the raised messages. … … 476 475 return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array(); 477 476 } 478 477 479 478 /** 480 479 * Resets the message list. … … 490 489 return false; 491 490 } 492 491 493 492 $_SESSION['_app'][$this->_ns]['messages'] = array(); 494 493 } … … 507 506 public function printRaisedMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg') 508 507 { 509 508 510 509 if (!$this->running) { 511 510 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 512 511 return false; 513 512 } 514 513 515 514 $messages = $this->getRaisedMessages(); 516 515 if (!empty($messages)) { … … 595 594 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE); 596 595 } 597 596 598 597 // Before we get any further, let's see if ANY log events are configured to be reported. 599 598 if ((false === $this->getParam('log_file_priority') || $priority > $this->getParam('log_file_priority')) … … 631 630 $site_hash = md5(empty($_SERVER['SERVER_NAME']) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['SERVER_NAME']); 632 631 $lock_dir = $this->getParam('tmp_dir') . "/codebase_msgs_$site_hash/"; 633 // Just use the file and line for the msg_id to limit the number of possible messages 632 // Just use the file and line for the msg_id to limit the number of possible messages 634 633 // (the message string itself shan't be used as it may contain innumerable combinations). 635 634 $lock_file = $lock_dir . md5($file . ':' . $line); … … 652 651 } 653 652 } 654 653 655 654 // Data to be stored for a log event. 656 655 $event = array( … … 690 689 mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers); 691 690 } 692 691 693 692 // SCREEN ACTION 694 693 if (false !== $this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) { 695 echo "[{$event['type']}] [{$event['message']}]\n";694 file_put_contents('php://stderr', "[{$event['type']}] [{$event['message']}]\n", FILE_APPEND); 696 695 } 697 696 698 697 // Restore original locale. 699 698 setlocale(LC_TIME, $locale); 700 699 701 700 return true; 702 701 } … … 776 775 777 776 /** 778 * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 777 * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 779 778 * url()/ohref()/printHiddenSession() modified URLs unless explicitly written in. 780 * 779 * 781 780 * @access public 782 781 * @param mixed $query_key The key (or keys, as an array) of the query argument to remove.
Note: See TracChangeset
for help on using the changeset viewer.