Subversion Repositories logviewer

Rev

Rev 2 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 3
Line 23... Line 23...
23
foreach (php_log_locations as $tpl) $phpfiles = array_merge($phpfiles, glob($tpl));
23
foreach (php_log_locations as $tpl) $phpfiles = array_merge($phpfiles, glob($tpl));
24
usort($phpfiles, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
24
usort($phpfiles, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
25
 
25
 
26
$file_nr = 0;
26
$file_nr = 0;
27
$file_max = count($files) + count($phpfiles);
27
$file_max = count($files) + count($phpfiles);
-
 
28
 
-
 
29
// Apache Log Files
-
 
30
 
28
foreach ($files as $file) {
31
foreach ($files as $file) {
29
	$file_nr++;
32
	$file_nr++;
-
 
33
 
-
 
34
	if (time()-filemtime($file) > MAX_DAYS_LOGFILE * 3600) continue;
-
 
35
 
-
 
36
	if (substr($file,-3,3) === '.gz') {
-
 
37
		if (IGNORE_GZ) continue;
-
 
38
		$cont = file_get_contents($file);
-
 
39
		$cont = gzdecode($cont);
-
 
40
		if ($cont === false) continue;
-
 
41
		$lines = explode("\n", $cont);
-
 
42
	} else {
30
	$lines = file($file);
43
		$lines = file($file);
-
 
44
	}
-
 
45
 
31
	$line_nr = 0;
46
	$line_no = 0;
32
	$line_max = count($lines);
47
	$line_max = count($lines);
33
	$logfile = removeLogrotateSuffix($file);
48
	$logfile = removeLogrotateSuffix($file);
34
	foreach ($lines as $line) {
49
	foreach ($lines as $line) {
35
		$line_nr++;
50
		$line_no++;
-
 
51
		$line = trim($line);
-
 
52
 
-
 
53
		if (preg_match('@^\[(.*)\] \[(.*)\] \[(.*)\] \[(.*)\] (.*)$@ismU', $line, $m)) {
36
		#[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
54
			#[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
37
		if (!preg_match('@^\[(.*)\] \[(.*)\] \[(.*)\] \[(.*)\] (.*)$@ismU', $line, $m)) continue;
-
 
38
		$time = $m[1];
55
			$time = $m[1];
39
		$modul = $m[2];
56
			$modul = $m[2];
40
		$text = $m[5];
57
			$text = $m[5];
41
 
58
 
42
		$time = trim(substr($time, 4, 6)).' '.substr($time, -4).' '.substr($time, 11, 8);
59
			$time = trim(substr($time, 4, 6)).' '.substr($time, -4).' '.substr($time, 11, 8);
43
		$time_mysql = date('Y-m-d H:i:s', strtotime($time));
60
			$time_mysql = date('Y-m-d H:i:s', strtotime($time));
-
 
61
		} else if (preg_match('@^(.+)\|(.+)\|(.+)\|(.+)$@ismU', $line, $m)) {
-
 
62
			#  5.6 | /daten/homes/daniel-marschall/hosts/dracenmarx/public_html/wiki/vendor/oyejorge/less.php/lib:91            | ini              | Ini mbstring.internal_encoding is deprecated.
-
 
63
			// A special implementation of PHP codefixer (showing the full path) . TODO: release
-
 
64
			$time = filemtime($file);
-
 
65
			$modul = 'php_codefixer';
-
 
66
			$text = 'PHP Codefixer: ' . trim($m[4]) . ' in ' . trim($m[2]);
-
 
67
 
-
 
68
			$time_mysql = date('Y-m-d H:i:s', $time);
-
 
69
		} else {
-
 
70
			continue;
-
 
71
		}
44
 
72
 
45
		$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)."';");
73
		$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)."';");
46
		#echo mysql_error();
74
		#echo mysql_error();
47
		if (mysql_num_rows($res) > 0) {
75
		if (mysql_num_rows($res) > 0) {
48
			mysql_query("update vts_fehlerlog set anzahl = anzahl + 1, letzter = '$time_mysql' " .
76
			mysql_query("update vts_fehlerlog set anzahl = anzahl + 1, letzter = '$time_mysql' " .
Line 52... Line 80...
52
		} else {
80
		} else {
53
			mysql_query("insert into vts_fehlerlog (modul, text, anzahl, letzter, logfile) " .
81
			mysql_query("insert into vts_fehlerlog (modul, text, anzahl, letzter, logfile) " .
54
			            "values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');");
82
			            "values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');");
55
			#echo mysql_error();
83
			#echo mysql_error();
56
		}
84
		}
57
		echo "file $file_nr/$file_max (line $line_nr/$line_max)                     \r";
85
		echo "file $file_nr/$file_max (line $line_no/$line_max)                     \r";
58
	}
86
	}
59
}
87
}
-
 
88
 
-
 
89
// PHP Log files
-
 
90
 
60
foreach ($phpfiles as $file) {
91
foreach ($phpfiles as $file) {
61
	$file_nr++;
92
	$file_nr++;
62
 
93
 
-
 
94
	if (time()-filemtime($file) > MAX_DAYS_LOGFILE * 3600) continue;
-
 
95
 
-
 
96
	if (substr($file,-3,3) === '.gz') {
-
 
97
		if (IGNORE_GZ) continue;
63
	$cont = file_get_contents($file);
98
		$cont = file_get_contents($file);
-
 
99
		$cont = gzdecode($cont);
-
 
100
		if ($cont === false) continue;
-
 
101
	} else {
-
 
102
		$cont = file_get_contents($file);
-
 
103
	}
64
	$cont = str_replace("\r", "", $cont);
104
	$cont = str_replace("\r", "", $cont);
65
	$cont = str_replace("\n ", " ", $cont);
105
	$cont = str_replace("\n ", " ", $cont);
66
	$lines = explode("\n", $cont);
106
	$lines = explode("\n", $cont);
67
 
107
 
68
	$line_nr = 0;
108
	$line_no = 0;
69
	$line_max = count($lines);
109
	$line_max = count($lines);
70
	$logfile = removeLogrotateSuffix($file);
110
	$logfile = removeLogrotateSuffix($file);
71
	foreach ($lines as $line) {
111
	foreach ($lines as $line) {
72
		$line_nr++;
112
		$line_no++;
-
 
113
		$line = trim($line);
-
 
114
 
-
 
115
		if (preg_match('@^\[(.*)\] ((.*)(\n ){0,1})$@ismU', $line, $m)) {
73
		# [19-Aug-2017 23:00:54 europe/berlin] PHP Notice:  Undefined variable: ssl in /home/viathinksoft/public_html/serverinfo/index.php on line 364
116
			# [19-Aug-2017 23:00:54 europe/berlin] PHP Notice:  Undefined variable: ssl in /home/viathinksoft/public_html/serverinfo/index.php on line 364
74
		if (!preg_match('@^\[(.*)\] ((.*)(\n ){0,1})$@ismU', $line, $m)) continue;
-
 
75
		$time = $m[1];
117
			$time = $m[1];
76
		$modul = '';
118
			$modul = '';
77
		$text = $m[2];
119
			$text = $m[2];
78
 
120
 
79
		$time = trim(substr($time, 0, 20));
121
			$time = trim(substr($time, 0, 20));
80
		$time_mysql = date('Y-m-d H:i:s', strtotime($time));
122
			$time_mysql = date('Y-m-d H:i:s', strtotime($time));
-
 
123
		} else {
-
 
124
			continue;
-
 
125
		}
81
 
126
 
82
		$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)."';");
127
		$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)."';");
83
		#echo mysql_error();
128
		#echo mysql_error();
84
		if (mysql_num_rows($res) > 0) {
129
		if (mysql_num_rows($res) > 0) {
85
			mysql_query("update vts_fehlerlog set anzahl = anzahl + 1, letzter = '$time_mysql' " .
130
			mysql_query("update vts_fehlerlog set anzahl = anzahl + 1, letzter = '$time_mysql' " .
Line 89... Line 134...
89
		} else {
134
		} else {
90
			mysql_query("insert into vts_fehlerlog (modul, text, anzahl, letzter, logfile) " .
135
			mysql_query("insert into vts_fehlerlog (modul, text, anzahl, letzter, logfile) " .
91
			            "values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');");
136
			            "values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');");
92
			#echo mysql_error();
137
			#echo mysql_error();
93
		}
138
		}
94
		echo "file $file_nr/$file_max (line $line_nr/$line_max)                     \r";
139
		echo "file $file_nr/$file_max (line $line_no/$line_max)                     \r";
95
	}
140
	}
96
}
141
}
97
echo "\n";
142
echo "\n";
98
 
143
 
99
# ---
144
# ---