-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin_iplog.php
122 lines (110 loc) · 4.36 KB
/
admin_iplog.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
<?php
// Ultimate PHP Board
// Author: Tim Hoeppner aka RR_Pilot, FixITguy
// Website: http://www.myupb.com
// Version: 2.0
// Using textdb Version: 4.3.2
require_once("./includes/upb.initialize.php");
$where = "<a href='admin.php'>Admin</a> ".$_CONFIG["where_sep"]." <a href='admin_iplog.php'>Ip Address Logs</a>";
require_once("./includes/header.php");
if (!isset($_COOKIE["user_env"]) || !isset($_COOKIE["uniquekey_env"]) || !isset($_COOKIE["power_env"]) || !isset($_COOKIE["id_env"])) exitPage("
<div class='alert'><div class='alert_text'>
<strong>Access Denied!</strong></div><div style='padding:4px;'>You are not logged in.</div></div>
<meta http-equiv='refresh' content='2;URL=login.php?ref=admin_iplog.php'>");
if (!$tdb->is_logged_in() || $_COOKIE["power_env"] < 3) exitPage("
<div class='alert'><div class='alert_text'>
<strong>Access Denied!</strong></div><div style='padding:4px;'>you are not authorized to be here.</div></div>");
echoTableHeading(str_replace($_CONFIG["where_sep"], $_CONFIG["table_sep"], $where), $_CONFIG);
echo "
<tr>
<th>Admin Panel Navigation</th>
</tr>";
echo "
<tr>
<td class='area_2' style='padding:20px;' valign='top'>";
require_once("admin_navigation.php");
echo "</td>
</tr>";
echoTableFooter(SKIN_DIR);
print '<a name="skip_nav"> </a>';
//create page numbers and retrieve the raw IP log data
if(!isset($_GET['page']) || $_GET['page'] == '') $_GET['page'] = 1;
if(!file_exists(DB_DIR.'/ip.log') || filesize(DB_DIR.'/ip.log') == 0) {
$pageStr = '';
$log = "cut\toff\tdata\n---\t---\t---\t---\t---\nsome\tmore\tcut\toff\tdata";
} else {
$pageStr = createPageNumbers($_GET['page'], (filesize(DB_DIR.'/ip.log')/(1024*20)));
$pageStr = "<table class='pagenum_container' cellspacing='1'>
<tr>
<td style='text-align:left;height:23px;'><span class='pagination_current'>Pages: </span>".$pageStr."</td>
</tr>
</table>";
$f = fopen(DB_DIR."/ip.log", "r");
fseek($f, filesize(DB_DIR.'/ip.log') - (1024 * 20 * $_GET['page']));
$log = fread($f, (1024 * 20));
fclose($f);
}
$pos1 = strpos($log, "\n");
$pos2 = strrpos($log, "\n") - 1;
$log = array_reverse(explode("\n", substr($log, $pos1+1, $pos2 - $pos1)));
$sublog = array_slice($log,($_GET['page']*$_CONFIG["posts_per_page"])-$_CONFIG["posts_per_page"],$_CONFIG["posts_per_page"]);
$num_pages = ceil((count($log) + 1) / $_CONFIG["posts_per_page"]);
$p = createPageNumbers($_GET['page'], $num_pages, $_SERVER['QUERY_STRING']);
echo pagination($p,$_GET['page'],$num_pages);
echo "<div style='clear:both;'></div>
<div class='tabstyle_1'>
<ul>
<li><a href='admin_iplog_action.php?action=download' title='Download a copy of the IP Log?'><span>Download IP Log</span></a></li>
<li><a href='admin_iplog_action.php?action=clear' title='Clear the IP Log?'><span>Clear the IP Log</span></a></li>
</ul>
</div>
";
echoTableHeading("Visitor's Log", $_CONFIG);
echo "
<tr>
<th style='width:10%;'>REMOTE_HOST</th>
<th style='width:10%;'>Username</th>
<th style='width:20%;text-align:center;'>URL</th>
<th style='width:15%;'>Access Date</th>
<th style='width:35%;text-align:center;'>HTTP_USER_AGENT</th>
</tr>";
//bot list format: $i = HTTP_USER_AGENT keyword; $i+1 = user mask
$bot_list = array(
'Yahoo! Slurp' , 'Y! Web Crawler',
'msnbot' , 'MSN Bot',
'Teoma' , 'Ask Jeeves Bot',
'OpenDNS' , 'OpenDNS Crawler',
'YodaoBot' , 'Yodao Bot',
'Exabot' , 'Exa Bot',
'Googlebot' , 'Google Bot',
'sproose' , 'Sproose Bot',
'sogou' , 'Sogou Crawler',
'VoilaBot' , 'Voila Bot',
'Sensis' , 'Sensis Web Crawler',
'findlinks' , 'Findlinks Spider',
'Yahoo-MMCrawler' , 'Yahoo MMCrawler',
'GingerCrawler' , 'GingerCrawler',
'Baiduspider', 'Baiduspider'
);
foreach($sublog as $entry) {
$entry = explode("\t", $entry, 5);
//bot detection
for($i=0,$c=count($bot_list);$i<$c;$i+=2) {
if(FALSE !== strpos($entry[4], $bot_list[$i])) {
$entry[1] = "<i>".$bot_list[$i+1]."</i>";
break 1;
}
}
echo "
<tr>
<td class='area_1' style='padding:8px;'><strong>{$entry[0]}</strong></td>
<td class='area_2'>{$entry[1]}</td>
<td class='area_1'>{$entry[2]}</td>
<td class='area_2'>".(ctype_digit(($entry[3])) ? gmdate('r', $entry[3]) : $entry[3])."</td>
<td class='area_1'>{$entry[4]}</td>
</tr>";
}
echoTableFooter(SKIN_DIR);
echo pagination($p,$_GET['page'],$num_pages);
require_once("./includes/footer.php");
?>