-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathiphistory.php
108 lines (83 loc) · 3.5 KB
/
iphistory.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
<?php
require "include/bittorrent.php";
dbconn();
require_once(get_langfile_path());
loggedinorreturn();
global $userprofile_class;
if (get_user_class() < $userprofile_class)
permissiondenied();
$userid = 0 + $_GET["id"];
if (!is_valid_id($userid))
stderr($lang_iphistory['std_error'], $lang_iphistory['std_invalid_id']);
$res = sql_query("SELECT username FROM users WHERE id = $userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
stderr($lang_iphistory['error'], $lang_iphistory['text_user_not_found']);
$arr = mysql_fetch_array($res);
$username = $arr["username"];
$perpage = 20;
$ipcountres = sql_query("SELECT COUNT(DISTINCT(access)) FROM iplog WHERE userid = $userid");
$ipcountres = mysql_fetch_row($ipcountres);
$countrows = $ipcountres[0] + 1;
$order = $_GET['order'];
list($pagertop, $pagerbottom, $limit) = pager($perpage, $countrows, "iphistory.php?id=$userid&order=$order&");
/*
$query = "SELECT u.id, u.ip AS ip, last_access AS access FROM users as u WHERE u.id = $userid
UNION DISTINCT SELECT u.id, iplog.ip as ip, iplog.access as access ,iplog.duplicate FROM users AS u
RIGHT JOIN iplog on u.id = iplog.userid WHERE u.id = $userid ORDER BY access DESC $limit";
*/
$query = "SELECT u.id, iplog.ip as ip, iplog.access as access , iplog.duplicate as duplicate FROM users AS u
RIGHT JOIN iplog on u.id = iplog.userid WHERE u.id = $userid ORDER BY access DESC $limit";
$res = sql_query($query) or sqlerr(__FILE__, __LINE__);
stdhead($lang_iphistory['head_ip_history_log_for'] . $username);
begin_main_frame();
print("<h1 align=\"center\">" . $lang_iphistory['text_historical_ip_by'] . get_username($userid) . "</h1>");
if ($countrows > $perpage)
echo $pagertop;
print("<table width=500 border=1 cellspacing=0 cellpadding=5 align=center>\n");
print("<tr>\n
<td class=colhead>" . $lang_iphistory['col_last_access'] . "</td>\n
<td class=colhead>" . $lang_iphistory['col_ip'] . "</td>\n
<td class=colhead>" . $lang_iphistory['col_location'] . "</td>\n
</tr>\n");
while ($arr = mysql_fetch_array($res)) {
$addr = "";
$ipshow = "";
if ($arr["ip"]) {
$ip = $arr["ip"];
// $dom = @gethostbyaddr($arr["ip"]);
//
////显示IP对应的主机名
//
// if ($dom == $arr["ip"] || @gethostbyname($dom) != $arr["ip"])
// $addr = $lang_iphistory['text_not_available'];
// else
// $addr = str_replace(".tju.edu.cn", "", $dom);
//$addr = $dom;
/*
$queryc = "SELECT COUNT(*) FROM
(
SELECT u.id FROM users AS u WHERE u.ip = " . sqlesc($ip) . "
UNION SELECT u.id FROM users AS u RIGHT JOIN iplog ON u.id = iplog.userid WHERE iplog.ip = " . sqlesc($ip) . "
GROUP BY u.id
) AS ipsearch";
$resip = sql_query($queryc) or sqlerr(__FILE__, __LINE__);
$arrip = mysql_fetch_row($resip);
$ipcount = $arrip[0];
if ($ipcount > 1)
*/
$ipshow = "<a href=\"ipsearch.php?ip=" . $arr['ip'] . "\">" . $arr['ip'] . "</a>" . ($arr["duplicate"] == "yes" ? " <b>(<font class='striking'>" . $lang_iphistory['text_duplicate'] . "</font>)</b>" : "");
/*
else
$ipshow = "<a href=\"ipsearch.php?ip=". $arr['ip'] ."\">" . $arr['ip'] ."</a>";
*/
}
$date = gettime($arr["access"]);
print("<tr><td class='rowfollow'>" . $date . "</td>\n");
print("<td class='rowfollow'>" . $ipshow . "</td>\n");
print("<td class='rowfollow'>" . ip_to_location($arr["ip"]) . "</td></tr>\n");
}
print("</table>");
echo $pagerbottom;
end_main_frame();
stdfoot();
die;