Changeset 475


Ignore:
Timestamp:
Apr 26, 2014 3:04:02 AM (10 years ago)
Author:
anonymous
Message:

Logging longer messages when possible. Fixed compatibility regression with Nav::currentPage(); may break compatability with codebase v2.1.6 only.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r468 r475  
    311311         */
    312312
    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 
    318313        // Skip sessions if disabled or automatically skip if run in a CLI script.
    319314        if (true === $this->getParam('enable_session') && !defined('_CLI')) {
     
    657652            'type'      => $this->logPriorityToString($priority),
    658653            'file:line' => "$file : $line",
    659             'url'       => mb_substr(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 0, 128),
     654            'url'       => mb_substr(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 0, 1024),
    660655            'message'   => $message
    661656        );
     657        // Here's a shortened version of event data.
     658        $event_short = $event;
     659        $event_short['url'] = truncate($event_short['url'], 120);
     660
    662661
    663662        // FILE ACTION
    664663        if (false !== $this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
    665             $event_str = '[' . join('] [', $event) . ']';
     664            $event_str = '[' . join('] [', $event_short) . ']';
    666665            error_log(mb_substr($event_str, 0, 1024) . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
    667666        }
     
    683682            $hostname = (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n');
    684683            $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);
    686685            $headers = 'From: ' . $this->getParam('site_email');
    687686            mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers);
     
    695694        // Restore original locale.
    696695        setlocale(LC_TIME, $locale);
     696
     697        unset($event, $event_short);
    697698
    698699        return true;
  • trunk/lib/Navigation.inc.php

    r468 r475  
    268268
    269269    /**
    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__);
    286297            return $true_return;
    287298        }
     299        // $app->logMsg(sprintf('Current page (%s) != test URI (%s)', $actual_uri, $test_uri), LOG_DEBUG, __FILE__, __LINE__);
    288300        return $false_return;
    289301    }
Note: See TracChangeset for help on using the changeset viewer.