1
|
<?php
|
2
|
/***************
|
3
|
* Apache Log Viewer
|
4
|
* Copyright © 2001 - Eric Gach
|
5
|
*
|
6
|
* This program is free software. You can redistribute it
|
7
|
* and/or modify it under the terms of the GNU General Public
|
8
|
* License as published by the Free Software Foundation.
|
9
|
*
|
10
|
* I am not responsible for ANY harm that your server may
|
11
|
* incur while running this program. This software is used with
|
12
|
* the understanding that its at your own risk.
|
13
|
**************/
|
14
|
|
15
|
// Change this to the path of your Apache log
|
16
|
$file = file("D:/Apache/logs/access.log");
|
17
|
|
18
|
if (empty($offset))
|
19
|
{
|
20
|
$offset = 1;
|
21
|
}
|
22
|
|
23
|
$n_offset = $offset + 100
|
24
|
?>
|
25
|
<table width="95%" align="center">
|
26
|
<?
|
27
|
$p_offset = $offset - 100;
|
28
|
?>
|
29
|
<tr><td colspan="4" align="left">
|
30
|
<font face="Verdana, Arial, Helvetica,
|
31
|
sans-serif" size="2">
|
32
|
<b><a style="color: blue;" href="<?echo $PHP_SELF . "?
|
33
|
offset=" . $offset;?>">Next 100</a>
|
34
|
<?
|
35
|
if ($p_offset >= 1)
|
36
|
{
|
37
|
?>
|
38
|
- <a style="color: blue;"
|
39
|
href="<?echo $PHP_SELF . "?offset=" . $p_offset?>">Prev 100</a>
|
40
|
<?
|
41
|
}?>
|
42
|
</font></td></tr>
|
43
|
<tr><td colspan="4"> </td></tr>
|
44
|
<tr><td width="5%">
|
45
|
<font face="Verdana, Arial, Helvetica, sans-serif"
|
46
|
size="2"><b>ID</font>
|
47
|
</td><td width="10%"><font face="Verdana, Arial, Helvetica,
|
48
|
sans-serif" size="2" color="red"><b>IP</b></font></td>
|
49
|
<td width="65%"><font
|
50
|
face="Verdana, Arial, Helvetica, sans-serif" size="2" color="blue">
|
51
|
<b>URL Visited</b></td>
|
52
|
<td width="20%"><font face="Verdana, Arial, Helvetica, sans-serif"
|
53
|
size="2" color="green"><b>Date/Time</b></font></td></tr>
|
54
|
<?
|
55
|
$count = 1;
|
56
|
$i = 1;
|
57
|
|
58
|
while (list(,$value) = each($file))
|
59
|
{
|
60
|
if($count == $offset)
|
61
|
{
|
62
|
if ($i <= 100)
|
63
|
{
|
64
|
if (ereg("([0-9.]+) - - \[(.*)\] \"POST ([^ ]+) HTTP/([0-9.]{3})\"
|
65
|
(.*)", $value, $link) || ereg("([0-9.]+) - - \[(.*)\]
|
66
|
\"GET ([^ ]+) HTTP/([0-9.]{3})\" (.*)", $value, $link))
|
67
|
{
|
68
|
if(ereg("([0-9]{2})/([a-zA-Z]+)/([0-9]{4}):([0-9]{2}):([0-9]{2}):
|
69
|
([0-9]{2}) -([0-9]{4})", $link[2], $time))
|
70
|
{
|
71
|
$link[2] = $time[2] . " " . date("j, Y, g:i a", mktime($time[4],
|
72
|
$time[5], $time[6], "1", $time[1], $time[3]));
|
73
|
}
|
74
|
echo "<tr><td width=\"5%\"><font face=\"Verdana, Arial, Helvetica,
|
75
|
sans-serif\" size=\"1\"><b>$count</b></font></td><td width=\"10%\">
|
76
|
<font face=\"Verdana, Arial, Helvetica, sans-serif\"
|
77
|
size=\"1\" color=\"red\"><b>$link[1]</b></font></td>
|
78
|
<td width=\"65%\"><font face=\"Verdana, Arial, Helvetica, sans-
|
79
|
serif\" size=\"1\"><b><a style=\"color: blue;\" href=\"http://" .
|
80
|
$SERVER_NAME . ":" . $SERVER_PORT . $link[3] . "\">" . $link
|
81
|
[3] . "</a></b></font></td><td width=\"20%\">
|
82
|
<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"
|
83
|
color=\"green\"><b>$link[2]</b></font></td></tr>";
|
84
|
}
|
85
|
++$offset;
|
86
|
}
|
87
|
++$i;
|
88
|
}
|
89
|
++$count;
|
90
|
}
|
91
|
$p_offset = $offset - 200;
|
92
|
?>
|
93
|
<tr><td colspan="4"> </td></tr>
|
94
|
<tr><td colspan="4" align="left">
|
95
|
<font face="Verdana, Arial, Helvetica, sans-serif"
|
96
|
size="2"><b>
|
97
|
<a style="color: blue;"
|
98
|
href="<?echo $PHP_SELF . "?offset=" . $offset;?>">Next 100</a>
|
99
|
<?
|
100
|
if ($p_offset >= 1)
|
101
|
{
|
102
|
?>
|
103
|
- <a style="color: blue;"
|
104
|
href="<?echo $PHP_SELF . "?offset=" . $p_offset?>">Prev 100</a>
|
105
|
<?
|
106
|
}?>
|
107
|
</font></td></tr>
|
108
|
</table>
|