Changeset 475
- Timestamp:
- Apr 26, 2014 3:04:02 AM (10 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r468 r475 311 311 */ 312 312 313 // Skip session for some user agents.314 if (preg_match('/Atomz|ApacheBench|Wget/i', getenv('HTTP_USER_AGENT'))) {315 $this->setParam(array('enable_session' => false));316 }317 318 313 // Skip sessions if disabled or automatically skip if run in a CLI script. 319 314 if (true === $this->getParam('enable_session') && !defined('_CLI')) { … … 657 652 'type' => $this->logPriorityToString($priority), 658 653 'file:line' => "$file : $line", 659 'url' => mb_substr(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 0, 1 28),654 'url' => mb_substr(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 0, 1024), 660 655 'message' => $message 661 656 ); 657 // Here's a shortened version of event data. 658 $event_short = $event; 659 $event_short['url'] = truncate($event_short['url'], 120); 660 662 661 663 662 // FILE ACTION 664 663 if (false !== $this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) { 665 $event_str = '[' . join('] [', $event ) . ']';664 $event_str = '[' . join('] [', $event_short) . ']'; 666 665 error_log(mb_substr($event_str, 0, 1024) . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename')); 667 666 } … … 683 682 $hostname = (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n'); 684 683 $subject = sprintf('[%s %s]', $hostname, $priority); 685 $sms_msg = sprintf('%s [%s:%s]', mb_substr($event ['message'], 0, 64), basename($file), $line);684 $sms_msg = sprintf('%s [%s:%s]', mb_substr($event_short['message'], 0, 64), basename($file), $line); 686 685 $headers = 'From: ' . $this->getParam('site_email'); 687 686 mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers); … … 695 694 // Restore original locale. 696 695 setlocale(LC_TIME, $locale); 696 697 unset($event, $event_short); 697 698 698 699 return true; -
trunk/lib/Navigation.inc.php
r468 r475 268 268 269 269 /** 270 * Returns a string if the queried page is the current page. One use is to print 271 * CSS tags if the current page matches a link, such as: 272 * $nav->currentPage('mypage.php', ' id="current"'); 273 * 274 * @access public 275 * 276 * @param mixed $page The URI of the page to query, with PREG express markup, if needed. 277 * @param mixed $return The value to return if the current page matches the page queried. 278 * 279 * @return mixed The value set for $return, TRUE by default. 280 */ 281 public function currentPage($test_uri, $true_return=true, $false_return=false, $strip_query=false) 282 { 283 $actual_uri = $strip_query ? strtok($_SERVER['REQUEST_URI'], '?') : $_SERVER['REQUEST_URI']; 284 $test_uri = $strip_query ? strtok($test_uri, '?') : $test_uri; 285 if (preg_match('/^' . preg_quote(urldecode($test_uri), '/') . '$/i', $actual_uri)) { 270 * Test if the given URI matches the URL of the current page. By default the URI is tested 271 * without concern 272 * One use is to change the returned value for a positive match 273 * so a css class prints for an element representing the current page: 274 * echo $nav->currentPage('/script.php?op=info', ' class="current"', '', true); 275 * The above will match only if the current page (REQUEST_URI) is also '/script.php?op=info', 276 * and will return the string ' class="current"' if it is. 277 * 278 * @access public 279 * 280 * @param string $test_uri A URI to test against the current page. 281 * @param mixed $true_return The value to return if the current page matches the test URI. 282 * @param mixed $false_return The value to return if the current page does not match the test URI. 283 * @param bool $include_query If set true, include the URI query string in the test. 284 * 285 * @return mixed If the test URI matches the current page URI, the value given for $true_return 286 * is returned (true by default), otherwise the value given for $false_return is 287 * returned (false by default). 288 */ 289 public function currentPage($test_uri, $true_return=true, $false_return=false, $include_query=false) 290 { 291 $app =& App::getInstance(); 292 293 $actual_uri = $include_query ? $_SERVER['REQUEST_URI'] : strtok($_SERVER['REQUEST_URI'], '?'); 294 $test_uri = $include_query ? $test_uri : strtok($test_uri, '?'); 295 if (mb_strtolower($test_uri) == mb_strtolower($actual_uri)) { 296 // $app->logMsg(sprintf('Current page (%s) == test URI (%s)', $actual_uri, $test_uri), LOG_DEBUG, __FILE__, __LINE__); 286 297 return $true_return; 287 298 } 299 // $app->logMsg(sprintf('Current page (%s) != test URI (%s)', $actual_uri, $test_uri), LOG_DEBUG, __FILE__, __LINE__); 288 300 return $false_return; 289 301 }
Note: See TracChangeset
for help on using the changeset viewer.