Exemplo n.º 1
0
 public static function write_error_log($message)
 {
     $message = dzz_error::clear($message);
     $time = time();
     $file = DZZ_ROOT . './data/log/' . date("Ym") . '_errorlog.php';
     $hash = md5($message);
     $uid = getglobal('uid');
     $ip = getglobal('clientip');
     $user = '******' . intval($uid) . '; IP=' . $ip . '; RIP:' . $_SERVER['REMOTE_ADDR'];
     $uri = 'Request: ' . dhtmlspecialchars(dzz_error::clear($_SERVER['REQUEST_URI']));
     $message = "<?PHP exit;?>\t{$time}\t{$message}\t{$hash}\t{$user} {$uri}\n";
     if ($fp = @fopen($file, 'rb')) {
         $lastlen = 50000;
         $maxtime = 60 * 10;
         $offset = filesize($file) - $lastlen;
         if ($offset > 0) {
             fseek($fp, $offset);
         }
         if ($data = fread($fp, $lastlen)) {
             $array = explode("\n", $data);
             if (is_array($array)) {
                 foreach ($array as $key => $val) {
                     $row = explode("\t", $val);
                     if ($row[0] != '<?PHP exit;?>') {
                         continue;
                     }
                     if ($row[3] == $hash && $row[1] > $time - $maxtime) {
                         return;
                     }
                 }
             }
         }
     }
     error_log($message, 3, $file);
 }