-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyse.php
117 lines (94 loc) · 2.98 KB
/
analyse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
opcache_reset();
if (PHP_SAPI === 'cli')
{
$_POST['pass'] = $_SERVER['argv'][1];
}
if(isset($_POST['pass']) ){
if($_POST['pass'] == 'xxxxs'){
session_start();
$_SESSION['loggin'] = time();
echo 'ok';
}else {
echo 'pw?';
}
}
if(empty($_SESSION['loggin'])){
?>
<form method="POST">
<input type="password" name="pass">
<input type="submit">
</form>
<?php
exit;
}
ini_set('memory_limit', '900M');
$errorcount = array();
$basedir = __dir__.'/../logs/'.date('Y.m.d').'/';
$errors = array();
$errors_messages = array();
foreach (glob($basedir."*.log") as $filename) {
$logfile_raw = file_get_contents($filename);
$logfile = json_decode($logfile_raw,true);
$error = array();
if(!empty($logfile['POST'])){
$error['type'] = 'post';
$log = json_decode($logfile['POST']['post'],true);
} else {
$error['type'] = 'get';
$log = $logfile['GET'];
}
$error['date'] = date('d.m.Y H:i:s',$logfile['date']);
$error['message'] = $log['message'];
$error['source'] = $log['source'];
$error['lineno'] = $log['lineno'];
$error['colno'] = $log['colno'];
$error['exception'] = $log['exception'];
#$error['raw'] = '<div class="ui button">Show flowing popup</div>
# <div class="ui flowing popup top left transition hidden">'.$logfile_raw.'</div>';
$errorcount[md5($error['message'])]++;
$errors[] = $error;
$errors_messages[$error['message']][$error['source']] = true;
}
$errors = array_reverse($errors);
?>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<h1>Error monitoring</h1>
Einträge: <?php echo count($errors);?> <br>
Message: <?php echo count($errors_messages);?> <br>
<h2>Top Fehlermeldungen</h2>
<table class="ui celled padded table">
<tr><th>Message</th><th>Verschiedene Dateien</th><th>Anzahl</th></tr>
<?php
foreach ($errors_messages as $message => $row) {
echo '<tr>';
echo "<td>".htmlspecialchars($message). "</td>";
echo "<td>".count($row). "</td>";
echo "<td>".$errorcount[md5($message)]."</td>";
echo '</tr>';
}
?>
</table>
<h2>Letzten 200 Einträge</h2>
<table class="ui celled padded table">
<tr><th>Typ</th><th>Datum</th><th>Message</th><th>Quelle</th><th>Line</th><th>Col</th><th>Exception</th><th>Anzahl</th></tr>
<?php
$i = 0;
foreach ($errors as $row) {
++$i;
if($i > 200){
continue;
}
echo '<tr>';
foreach ($row as $cell) {
echo "<td>".htmlspecialchars($cell). "</td>";
}
echo "<td>".$errorcount[md5($row['message'])]."</td>";
echo '</tr>';
}
?></table>