示例#1
0
 static function log_internal($level, $string, $statsLog = false)
 {
     if (self::$loggingHandler === NULL) {
         /* Initialize logging. */
         self::createLoggingHandler();
         if (!empty(self::$earlyLog)) {
             error_log('----------------------------------------------------------------------');
             /* Output messages which were logged before we initialized to the proper log. */
             foreach (self::$earlyLog as $msg) {
                 self::log_internal($msg['level'], $msg['string'], $msg['statsLog']);
             }
         }
     } elseif (self::$loggingHandler === FALSE) {
         /* Some error occured while initializing logging. */
         if (empty(self::$earlyLog)) {
             /* This is the first message. */
             error_log('--- Log message(s) while initializing logging ------------------------');
         }
         error_log($string);
         self::$earlyLog[] = array('level' => $level, 'string' => $string, 'statsLog' => $statsLog);
         return;
     }
     if (self::$captureLog) {
         $ts = microtime(TRUE);
         $msecs = (int) (($ts - (int) $ts) * 1000);
         $ts = GMdate('H:i:s', $ts) . sprintf('.%03d', $msecs) . 'Z';
         self::$capturedLog[] = $ts . ' ' . $string;
     }
     if (self::$logLevel >= $level || $statsLog) {
         if (is_array($string)) {
             $string = implode(",", $string);
         }
         $string = '[' . self::getTrackId() . '] ' . $string;
         if ($statsLog) {
             $string = 'STAT ' . $string;
         }
         self::$loggingHandler->log_internal($level, $string);
     }
 }
示例#2
0
 private static function log($level, $string, $statsLog = FALSE)
 {
     if (self::$loggingHandler === NULL) {
         /* Initialize logging. */
         self::createLoggingHandler();
         if (!empty(self::$earlyLog)) {
             error_log('----------------------------------------------------------------------');
             // output messages which were logged before we properly initialized logging
             foreach (self::$earlyLog as $msg) {
                 self::log($msg['level'], $msg['string'], $msg['statsLog']);
             }
         }
     } elseif (self::$loggingHandler === FALSE) {
         // some error occurred while initializing logging
         if (empty(self::$earlyLog)) {
             // this is the first message
             error_log('--- Log message(s) while initializing logging ------------------------');
         }
         error_log($string);
         self::$earlyLog[] = array('level' => $level, 'string' => $string, 'statsLog' => $statsLog);
         return;
     }
     if (self::$captureLog) {
         $ts = microtime(TRUE);
         $msecs = (int) (($ts - (int) $ts) * 1000);
         $ts = GMdate('H:i:s', $ts) . sprintf('.%03d', $msecs) . 'Z';
         self::$capturedLog[] = $ts . ' ' . $string;
     }
     if (self::$logLevel >= $level || $statsLog) {
         if (is_array($string)) {
             $string = implode(",", $string);
         }
         $formats = array('%trackid', '%msg', '%srcip', '%stat');
         $replacements = array(self::getTrackId(), $string, $_SERVER['REMOTE_ADDR']);
         $stat = '';
         if ($statsLog) {
             $stat = 'STAT ';
         }
         array_push($replacements, $stat);
         $string = str_replace($formats, $replacements, self::$format);
         self::$loggingHandler->log($level, $string);
     }
 }
示例#3
0
 private static function log($level, $string, $statsLog = false)
 {
     if (php_sapi_name() === 'cli' || defined('STDIN')) {
         // we are being executed from the CLI, nowhere to log
         return;
     }
     if (self::$loggingHandler === null) {
         // Initialize logging
         self::createLoggingHandler();
         if (!empty(self::$earlyLog)) {
             // output messages which were logged before we properly initialized logging
             foreach (self::$earlyLog as $msg) {
                 self::log($msg['level'], $msg['string'], $msg['statsLog']);
             }
         }
     } elseif (self::$loggingHandler === false) {
         // some error occurred while initializing logging
         if (empty(self::$earlyLog)) {
             // this is the first message
             error_log('--- Log message(s) while initializing logging ------------------------');
         }
         error_log($string);
         self::defer($level, $string, $statsLog);
         return;
     }
     if (self::$captureLog) {
         $ts = microtime(true);
         $msecs = (int) (($ts - (int) $ts) * 1000);
         $ts = GMdate('H:i:s', $ts) . sprintf('.%03d', $msecs) . 'Z';
         self::$capturedLog[] = $ts . ' ' . $string;
     }
     if (self::$logLevel >= $level || $statsLog) {
         if (is_array($string)) {
             $string = implode(",", $string);
         }
         $formats = array('%trackid', '%msg', '%srcip', '%stat');
         $replacements = array(self::$trackid, $string, $_SERVER['REMOTE_ADDR']);
         $stat = '';
         if ($statsLog) {
             $stat = 'STAT ';
         }
         array_push($replacements, $stat);
         if (self::$trackid === self::NO_TRACKID && !self::$shuttingDown) {
             // we have a log without track ID and we are not still shutting down, so defer logging
             self::defer($level, $string, $statsLog);
             return;
         } elseif (self::$trackid === self::NO_TRACKID) {
             // shutting down without a track ID, prettify it
             array_shift($replacements);
             array_unshift($replacements, 'N/A');
         }
         // we either have a track ID or we are shutting down, so just log the message
         $string = str_replace($formats, $replacements, self::$format);
         self::$loggingHandler->log($level, $string);
     }
 }
function DateAdd($v, $d = null, $f = "Ymd")
{
    $d = $d ? $d : GMdate("Y-m-d");
    return GMdate($f, strtotime($v . " days", strtotime($d)));
}
示例#5
0
if ($Zone10 != "") {
    $time10 = $Z10Offset * 60 + $minutes10;
}
//---------------------------------------------------------------------------
$content = '<script type="text/javascript">
//<![CDATA[
//------------------------------------------------------------
//--  Time Zone Clock Version 3.9.2                         --
//--  The script uses the server time to display the clocks --
//------------------------------------------------------------
var DispDay=';
$content .= $displayday . ';var DispSeconds=';
$content .= $dispseconds . ';var zonefirst=';
$content .= $ZoneFirst . ';var disp_ampm=';
$content .= $DispAM_PM;
$content .= ";var servertimestr='" . GMdate("F d, Y H:i:s", time());
$content .= '\';var servtime=new Date(servertimestr);';
$content .= "var DispHoriz={$Display};";
if ($Zone1 != "") {
    $content .= 'var z1text="' . $Zone1 . '";';
    $content .= 'var z1time=' . $time1 . ';';
    if ($dstrue1) {
        $content .= 'var z1dst="*";';
    } else {
        $content .= 'var z1dst=0;';
    }
}
if ($Zone2 != "") {
    $content .= 'var z2text="' . $Zone2 . '";';
    $content .= 'var z2time=' . $time2 . ';';
    if ($dstrue2) {