forked from DSB/MySQLDumper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.php
165 lines (143 loc) · 6.49 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/* ----------------------------------------------------------------------
MyOOS [Dumper]
http://www.oos-shop.de/
Copyright (c) 2013 - 2022 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
MySqlDumper
http://www.mysqldumper.de
Copyright (C)2004-2011 Daniel Schlichtholz ([email protected])
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
define('OOS_VALID_MOD', true);
if (!@ob_start('ob_gzhandler')) {
@ob_start();
}
include './inc/header.php';
include_once './language/'.$config['language'].'/lang_log.php';
echo MODHeader();
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 (0 == $_POST['r']) {
DeleteLog();
} elseif (1 == $_POST['r']) {
@unlink($config['files']['perllog']);
@unlink($config['files']['perllog'].'.gz');
} elseif (2 == $_POST['r']) {
@unlink($config['files']['perllogcomplete']);
@unlink($config['files']['perllogcomplete'].'.gz');
} elseif (3 == $_POST['r']) {
@unlink($config['paths']['log'].'error.log');
@unlink($config['paths']['log'].'error.log.gz');
}
$r = 0;
}
if (0 == $r) {
$lfile = $config['files']['log'];
$lcap = 'PHP-Log';
} elseif (1 == $r) {
$lfile = $config['files']['perllog'];
$lcap = 'Perl-Log';
} elseif (2 == $r) {
$lfile = $config['files']['perllogcomplete'];
$lcap = 'Perl-Complete Log';
} elseif (3 == $r) {
$lfile = $config['paths']['log'].'error.log';
$lcap = 'PHP Error-Log';
}
if (isset($config['logcompression']) && 1 == $config['logcompression']) {
$lfile .= '.gz';
}
if (!file_exists($lfile) && 0 == $r) {
DeleteLog();
}
$nLogcompression = isset($config['logcompression']) ? $config['logcompression'] : 0;
$loginfo = LogFileInfo($nLogcompression);
echo headline($lcap);
if (!is_writable($config['paths']['log'])) {
exit('<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
$icon['blank'] = isset($icon['blank']) ? $icon['blank'] : $config['files']['iconpath'].'blank.gif';
echo '<div align="left"><table class="bdr"><tr><td><table><tr><td valign="top"><strong>'.$lang['L_LOGFILEFORMAT'].'</strong><br><br>'.((isset($config['logcompression']) && (1 == $config['logcompression'])) ? '<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 ''.(((isset($config['logcompression']) && 1 == $config['logcompression'])) ? $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 (2 != $r) {
$out .= '<pre>';
}
if (file_exists($lfile)) {
$zeilen = ((isset($config['logcompression']) && 1 == $config['logcompression'])) ? gzfile($lfile) : file($lfile);
if (30 == $r) {
echo '<pre>'.print_r($zeilen, true).'</pre>';
exit();
}
if (1 == $revers) {
$zeilen = array_reverse($zeilen);
}
foreach ($zeilen as $zeile) {
if (2 == $r) {
$out .= $zeile.'<br>';
} elseif (3 == $r) {
$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 (2 != $r) {
$out .= '</pre>';
}
$suchen = [
'</html>',
'</body>',
];
$ersetzen = [
'',
'',
];
$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 MODFooter();
ob_end_flush();
exit();