-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtail.php
70 lines (65 loc) · 1.73 KB
/
tail.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
<?php
$tail = isset($_GET['tail']) ? trim($_GET['tail']) : '';
$lite = isset($_GET['lite']) ? true : false;
if (!is_numeric($tail)) { $tail = 40; }
$lines = file('server.log');
?>
<html>
<head>
<title>Server log</title>
<style type="text/css">
body {
font-family: "Courier New",
Consolas,
"Bitstream Vera Sans Mono",
"DejaVu Sans Mono",
monospace;
}
</style>
<script language="JavaScript">
function doLoad(url) {
setTimeout( function(){ refresh(url) }, 5*1000 );
}
function refresh(url) {
window.location.href = url;
}
</script>
</head>
<body onload="doLoad('tail.php?tail=<?php print $tail; if ($lite) { print "&lite=1"; } ?>')">
<?php
if (!$lite) {
include('nav.php');
?>
<form>
<span>Number of lines to show: </span>
<input type="text" name="tail" value="<?php echo $tail; ?>" />
<input type="submit"/>
</form>
<?php
}
$lines = array_slice($lines, (-1 * $tail * 5));
foreach($lines as $key => $value) {
if($value == "" || $value == " " || is_null($value) || strpos($value,'Did the system time change') !== false) {
unset($lines[$key]);
}
}
$lines = array_slice($lines, (-1 * $tail));
foreach($lines as $line) {
$line = '<span>' . $line . '</span>';
$srem = array('[0m','[31m','[32m','[33m','[34m','[35m','[36m','[37m');
$swith = array(
'</span><span style="color:gray">',
'</span><span style="color:red">',
'</span><span style="color:green">',
'</span><span style="color:orange">',
'</span><span style="color:blue">',
'</span><span style="color:purple">',
'</span><span style="color:teal">',
'</span><span style="color:black">',
);
$line = str_replace($srem, $swith, $line);
echo $line . '<br/>';
}
?>
</body>
</html>