This repository has been archived by the owner on May 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
/
log.php
146 lines (130 loc) · 5.33 KB
/
log.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
if (!@ob_start("ob_gzhandler")) @ob_start();
include ( './inc/header.php' );
include_once ( './language/' . $config['language'] . '/lang_log.php' );
echo MSDHeader();
if (isset($_POST['r'])) $r=$_POST['r'];
else $r=( isset($_GET['r']) ) ? $_GET['r'] : 0;
$revers=( isset($_GET['revers']) ) ? $_GET['revers'] : 0;
//loeschen
if (isset($_POST['kill']))
{
if ($_POST['r'] == 0)
{
DeleteLog();
}
elseif ($_POST['r'] == 1)
{
@unlink($config['files']['perllog']);
@unlink($config['files']['perllog'] . '.gz');
}
elseif ($_POST['r'] == 2)
{
@unlink($config['files']['perllogcomplete']);
@unlink($config['files']['perllogcomplete'] . '.gz');
}
elseif ($_POST['r'] == 3)
{
@unlink($config['paths']['log'] . "error.log");
@unlink($config['paths']['log'] . "error.log.gz");
}
$r=0;
}
if ($r == 0)
{
$lfile=$config['files']['log'];
$lcap="PHP-Log";
}
elseif ($r == 1)
{
$lfile=$config['files']['perllog'];
$lcap="Perl-Log";
}
elseif ($r == 2)
{
$lfile=$config['files']['perllogcomplete'];
$lcap="Perl-Complete Log";
}
elseif ($r == 3)
{
$lfile=$config['paths']['log'] . "error.log";
$lcap="PHP Error-Log";
}
if ($config['logcompression'] == 1) $lfile.=".gz";
if (!file_exists($lfile) && $r == 0)
{
DeleteLog();
}
$loginfo=LogFileInfo($config['logcompression']);
echo headline($lcap);
if (!is_writable($config['paths']['log'])) die('<p class="error">ERROR !<br>Logdir is not writable</p>');
//lesen
$errorbutton='';
$perlbutton='';
$perlbutton2='';
if (file_exists($loginfo['errorlog'])) $errorbutton='<td><input class="Formbutton" type="button" onclick="location.href=\'log.php?r=3\'" value="Error-Log"></td>';
if (file_exists($loginfo['perllog'])) $perlbutton='<td><input type="button" onclick="location.href=\'log.php?r=1\'" class="Formbutton" value="Perl-Log"></td>';
if (file_exists($loginfo['perllogcomplete'])) $perlbutton2='<td><input class="Formbutton" type="button" onclick="location.href=\'log.php?r=2\'" value="Perl-Complete Log"></td>';
//anzeigen
echo '<form action="log.php" method="post"><table><tr>';
echo '<td><input class="Formbutton" type="button" onclick="location.href=\'log.php?r=0\'" value="PHP-Log"></td>';
echo "\n" . $errorbutton . "\n" . $perlbutton . "\n" . $perlbutton2 . "\n";
echo '</tr></table><br>';
//Status Logfiles
echo '<div align="left"><table class="bdr"><tr><td><table><tr><td valign="top"><strong>' . $lang['L_LOGFILEFORMAT'] . '</strong><br><br>' . ( ( $config['logcompression'] == 1 ) ? '<img src="' . $config['files']['iconpath'] . 'gz.gif" width="32" height="32" alt="compressed" align="left">' : '<img src="' . $icon['blank'].'" width="32" height="32" alt="" align="left">' );
echo '' . ( ( $config['logcompression'] == 1 ) ? $lang['L_COMPRESSED'] : $lang['L_NOTCOMPRESSED'] ) . '</td>';
echo '<td> </td><td valign="top" align="right">';
echo '<a href="' . $loginfo['log'] . '">' . substr($loginfo['log'],strrpos($loginfo['log'],"/") + 1) . '</a><br>';
echo ( $loginfo['errorlog_size'] > 0 ) ? '<a href="' . $loginfo['errorlog'] . '">' . substr($loginfo['errorlog'],strrpos($loginfo['errorlog'],"/") + 1) . '</a><br>' : substr($loginfo['errorlog'],strrpos($loginfo['errorlog'],"/") + 1) . '<br>';
echo ( $loginfo['perllog_size'] > 0 ) ? '<a href="' . $loginfo['perllog'] . '">' . substr($loginfo['perllog'],strrpos($loginfo['perllog'],"/") + 1) . '</a><br>' : substr($loginfo['perllog'],strrpos($loginfo['perllog'],"/") + 1) . '<br>';
echo ( $loginfo['perllogcomplete_size'] > 0 ) ? '<a href="' . $loginfo['perllogcomplete'] . '">' . substr($loginfo['perllogcomplete'],strrpos($loginfo['perllogcomplete'],"/") + 1) . '</a><br>' : substr($loginfo['perllogcomplete'],strrpos($loginfo['perllogcomplete'],"/") + 1) . '<br>';
echo '<strong>total</strong></td><td valign="top" align="right">' . byte_output($loginfo['log_size']) . '<br>' . byte_output($loginfo['errorlog_size']) . '<br>' . byte_output($loginfo['perllog_size']) . '<br>' . byte_output($loginfo['perllogcomplete_size']) . '<br><strong>' . byte_output($loginfo['log_totalsize']) . '</strong></td>';
echo '</tr><tr><td colspan="3" align="center"><a class="small" href="log.php?r=' . $r . '&revers=0">' . $lang['L_NOREVERSE'] . '</a> <a class="small" href="log.php?r=' . $r . '&revers=1">' . $lang['L_REVERSE'] . '</a></td></tr></table></td></tr></table></div>';
$out='';
if ($r != 2) $out.='<pre>';
if (file_exists($lfile))
{
$zeilen=( $config['logcompression'] == 1 ) ? gzfile($lfile) : file($lfile);
if ($r == 30)
{
echo '<pre>' . print_r($zeilen,true) . '</pre>';
exit();
}
if ($revers == 1) $zeilen=array_reverse($zeilen);
foreach ($zeilen as $zeile)
{
if ($r == 2)
{
$out.=$zeile . '<br>';
}
elseif ($r == 3)
{
$z=explode("|:|",$zeile);
for ($i=0; $i < count($z); $i++)
{
$out.='<span>' . substr($z[$i],0,strpos($z[$i],": ")) . '</span> ' . substr($z[$i],strpos($z[$i],": ")) . "<br>";
}
}
else
$out.=$zeile;
}
}
if ($r != 2) $out.='</pre>';
$suchen=array(
'</html>',
'</body>'
);
$ersetzen=array(
'',
''
);
$out=str_replace($suchen,$ersetzen,$out);
if ($out != "")
{
echo '<div align="left" style="width:100%"><br>';
echo '<input type="hidden" name="r" value="' . $r . '"><input class="Formbutton" type="submit" name="kill" value="' . $lang['L_LOG_DELETE'] . '">';
echo '<br><br><div id="ilog">' . $out . '</div></div>';
}
echo '</form>';
echo MSDFooter();
ob_end_flush();