Subversion Repositories logviewer

Compare Revisions

Regard whitespace Rev 2 → Rev 3

/trunk/backend/insert_logs
25,16 → 25,33
 
$file_nr = 0;
$file_max = count($files) + count($phpfiles);
 
// Apache Log Files
 
foreach ($files as $file) {
$file_nr++;
 
if (time()-filemtime($file) > MAX_DAYS_LOGFILE * 3600) continue;
 
if (substr($file,-3,3) === '.gz') {
if (IGNORE_GZ) continue;
$cont = file_get_contents($file);
$cont = gzdecode($cont);
if ($cont === false) continue;
$lines = explode("\n", $cont);
} else {
$lines = file($file);
$line_nr = 0;
}
 
$line_no = 0;
$line_max = count($lines);
$logfile = removeLogrotateSuffix($file);
foreach ($lines as $line) {
$line_nr++;
$line_no++;
$line = trim($line);
 
if (preg_match('@^\[(.*)\] \[(.*)\] \[(.*)\] \[(.*)\] (.*)$@ismU', $line, $m)) {
#[Sun Aug 13 15:54:16.054530 2017] [fcgid:warn] [pid 28401] [client 104.236.113.44:52188] mod_fcgid: stderr: PHP Notice: Undefined offset: 11 in /home/d
if (!preg_match('@^\[(.*)\] \[(.*)\] \[(.*)\] \[(.*)\] (.*)$@ismU', $line, $m)) continue;
$time = $m[1];
$modul = $m[2];
$text = $m[5];
41,7 → 58,18
 
$time = trim(substr($time, 4, 6)).' '.substr($time, -4).' '.substr($time, 11, 8);
$time_mysql = date('Y-m-d H:i:s', strtotime($time));
} else if (preg_match('@^(.+)\|(.+)\|(.+)\|(.+)$@ismU', $line, $m)) {
# 5.6 | /daten/homes/daniel-marschall/hosts/dracenmarx/public_html/wiki/vendor/oyejorge/less.php/lib:91 | ini | Ini mbstring.internal_encoding is deprecated.
// A special implementation of PHP codefixer (showing the full path) . TODO: release
$time = filemtime($file);
$modul = 'php_codefixer';
$text = 'PHP Codefixer: ' . trim($m[4]) . ' in ' . trim($m[2]);
 
$time_mysql = date('Y-m-d H:i:s', $time);
} else {
continue;
}
 
$res = mysql_query("select * from vts_fehlerlog where modul = '".mysql_real_escape_string($modul)."' and logfile = '".mysql_real_escape_string($logfile)."' and text = '".mysql_real_escape_string($text)."';");
#echo mysql_error();
if (mysql_num_rows($res) > 0) {
54,24 → 82,38
"values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');");
#echo mysql_error();
}
echo "file $file_nr/$file_max (line $line_nr/$line_max) \r";
echo "file $file_nr/$file_max (line $line_no/$line_max) \r";
}
}
 
// PHP Log files
 
foreach ($phpfiles as $file) {
$file_nr++;
 
if (time()-filemtime($file) > MAX_DAYS_LOGFILE * 3600) continue;
 
if (substr($file,-3,3) === '.gz') {
if (IGNORE_GZ) continue;
$cont = file_get_contents($file);
$cont = gzdecode($cont);
if ($cont === false) continue;
} else {
$cont = file_get_contents($file);
}
$cont = str_replace("\r", "", $cont);
$cont = str_replace("\n ", " ", $cont);
$lines = explode("\n", $cont);
 
$line_nr = 0;
$line_no = 0;
$line_max = count($lines);
$logfile = removeLogrotateSuffix($file);
foreach ($lines as $line) {
$line_nr++;
$line_no++;
$line = trim($line);
 
if (preg_match('@^\[(.*)\] ((.*)(\n ){0,1})$@ismU', $line, $m)) {
# [19-Aug-2017 23:00:54 europe/berlin] PHP Notice: Undefined variable: ssl in /home/viathinksoft/public_html/serverinfo/index.php on line 364
if (!preg_match('@^\[(.*)\] ((.*)(\n ){0,1})$@ismU', $line, $m)) continue;
$time = $m[1];
$modul = '';
$text = $m[2];
78,6 → 120,9
 
$time = trim(substr($time, 0, 20));
$time_mysql = date('Y-m-d H:i:s', strtotime($time));
} else {
continue;
}
 
$res = mysql_query("select * from vts_fehlerlog where modul = '".mysql_real_escape_string($modul)."' and logfile = '".mysql_real_escape_string($logfile)."' and text = '".mysql_real_escape_string($text)."';");
#echo mysql_error();
91,7 → 136,7
"values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');");
#echo mysql_error();
}
echo "file $file_nr/$file_max (line $line_nr/$line_max) \r";
echo "file $file_nr/$file_max (line $line_no/$line_max) \r";
}
}
echo "\n";
/trunk/config.inc.php
4,8 → 4,8
 
define('MAXYEARS', 1);
 
#define('apache_log_locations', array('/home/*/log/error*.log*', '/home/*/hosts/*/log/error*.log*'));
define('apache_log_locations', array());
#define('apache_log_locations', array('/home/*/log/error*.log*', '/home/*/hosts/*/log/error*.log*', '/daten/admin/_probleme/php_codefixer/all_php_files.out'));
define('apache_log_locations', array('/daten/admin/_probleme/php_codefixer/all_php_files.out'));
 
define('php_log_locations', array('/home/*/log/php_error*.log*', '/home/*/hosts/*/log/php_error*.log*'/* , '/var/log/php/error.log*' */));
 
14,3 → 14,7
// 2 = Column "user" which tries to find out the user's home dir from the logfile
define('SOURCE_STYLE', 2);
 
// Don't look at .gz files. But if you enable it, then it is important that you run insert_logs before log-rotating.
define('IGNORE_GZ', false);
 
define('MAX_DAYS_LOGFILE', 30); // only read the logfiles of the last 30 days
/trunk/index.php
34,9 → 34,24
die();
}
 
$filter = isset($_REQUEST['filter']) ? '%'.mysql_real_escape_string($filter).'%' : '';
$filter_add = $filter ? "and text like '%".mysql_real_escape_string($filter)."%'" : '';
$filter_add = '';
if (isset($_REQUEST['filter'])) {
$ary = explode(' ', $_REQUEST['filter']);
foreach ($ary as $a) {
$a = trim($a);
if ($a == '') continue;
 
if (substr($a,0,1) == '-') {
$negate = "NOT ";
$a = substr($a, 1); // remove "-"
} else {
$negate = " ";
}
 
$filter_add .= " and text $negate like '".mysql_real_escape_string('%'.$a.'%')."' ";
}
}
 
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
if ($sort == '') $sort = 'anzahl';
if (($sort != 'anzahl') && ($sort != 'letzter') && ($sort != 'random')) die('Sort falsch');
64,6 → 79,7
}
}
?></p>
<p><font size="-3">Search terms divided with whitespace. Prepend hyphen to exclude a search term. Only field "Message" will be searched.</font></p>
</form>
 
<?php