-
Notifications
You must be signed in to change notification settings - Fork 13
/
ipsearch.php
155 lines (148 loc) · 5.31 KB
/
ipsearch.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
<?php
require_once('lib/function.php');
$windowtitle = "IP Address Search";
require_once('lib/layout.php');
print "$header<br>";
admincheck();
print adminlinkbar('ipsearch.php');
print "$tblstart";
if(!$su) $su='n';
if(!$sp) $sp='u';
if(!$sm) $sm='n';
if(!$d) $d='y';
$ch1[$su]=' checked';
$ch2[$sp]=' checked';
$ch3[$sm]=' checked';
$ch4[$d]=' checked';
print "
<form action=ipsearch.php method=post>
$tccellh colspan=2>IP search<tr>
$tccell1 width=20%><b>IP to search:</b></td>
$tccell2l>$inpt=ip size=15 maxlength=15 value=$ip><tr>
$tccell1><b>Sort users by:</b></td>
$tccell2l>
$radio=su value=n$ch1[n]> Name
$radio=su value=p$ch1[p]> Posts
$radio=su value=r$ch1[r]> Registration
$radio=su value=s$ch1[s]> Last post
$radio=su value=a$ch1[a]> Last activity
$radio=su value=i$ch1[i]> Last IP
<tr>
$tccell1><b>Sort posts by:</b></td>
$tccell2l>
$radio=sp value=u$ch2[u]> User
$radio=sp value=d$ch2[d]> Date
$radio=sp value=i$ch2[i]> IP
<tr>
$tccell1><b>Sort private messages by:</b></td>
$tccell2l>
$radio=sm value=n$ch3[n]> Sent by
$radio=sm value=d$ch3[d]> Date
$radio=sm value=i$ch3[i]> IP
<tr>
$tccell1><b>Distinct users and IP's:</b></td>
$tccell2l>
$radio=d value=y$ch4[y]> Yes
$radio=d value=n$ch4[n]> No
<tr>
$tccell1> </td>
$tccell1l>$inps=s value=Submit></td>
</form>
";
if($ip) {
$ip=str_replace('*','%',$ip);
switch($su) {
case 'n': $usort='ORDER BY name'; break;
case 'p': $usort='ORDER BY posts DESC'; break;
case 'r': $usort='ORDER BY regdate'; break;
case 's': $usort='ORDER BY lastposttime'; break;
case 'a': $usort='ORDER BY lastactivity'; break;
case 'i': $usort='ORDER BY lastip'; break;
}
switch($sp) {
case 'u': $psort='ORDER BY name'; break;
case 'd': $psort='ORDER BY date'; break;
case 'i': $psort='ORDER BY ip'; break;
}
switch($sm) {
case 'n': $msort='ORDER BY name1'; break;
case 'd': $msort='ORDER BY date'; break;
case 'i': $msort='ORDER BY ip'; break;
}
if($d === 'y') {
$pgroup='GROUP BY p.ip,u.id';
$mgroup='GROUP BY p.ip,u1.id';
}
$users=$sql->query("SELECT * FROM users WHERE lastip LIKE '$ip' $usort");
$posts=$sql->query("SELECT p.*,u.name,u.sex,u.powerlevel,t.title FROM posts p,users u,threads t WHERE ip LIKE '$ip' AND p.user=u.id AND p.thread=t.id $pgroup $psort");
$pmsgs=$sql->query("SELECT p.*,t.title,u1.name AS name1,u2.name AS name2,u1.sex AS sex1,u2.sex AS sex2,u1.powerlevel pow1,u2.powerlevel pow2 FROM pmsgs p,pmsgs_text t,users u1,users u2 WHERE ip LIKE '$ip' AND p.userfrom=u1.id AND p.userto=u2.id AND p.id=pid $mgroup $msort");
print "
$tblend<br>$tblstart
$tccellh colspan=7><b>Users: ".mysql_num_rows($users)."</b><tr>
$tccellc>id</td>
$tccellc>Name</td>
$tccellc>Registered on</td>
$tccellc>Last post</td>
$tccellc>Last activity</td>
$tccellc>Posts</td>
$tccellc>Last IP</td>
";
for($c=0;$c<500 && $user=$sql->fetch($users);$c++)
print "
<tr>
$tccell2>$user[id]</td>
$tccell1><a href=profile.php?id=$user[id]><font ".getnamecolor($user['sex'],$user['powerlevel']).">$user[name]</font></a></td>
$tccell1>".@date($dateformat,$user['regdate'])."</td>
$tccell1>".date($dateformat,$user['lastposttime'])."</td>
$tccell1>".date($dateformat,$user['lastactivity'])."</td>
$tccell1>$user[posts]</td>
$tccell2>$user[lastip]</td>
";
if($post=$sql->fetch($users))
print "<tr>$tccell2 colspan=7>Too many results!";
print "
$tblend<br>$tblstart
$tccellh colspan=5><b>Posts: ".mysql_num_rows($posts)."</b><tr>
$tccellc>id</td>
$tccellc>Posted by</td>
$tccellc>Thread</td>
$tccellc>Date</td>
$tccellc>IP</td>
";
for($c=0;$c<500 && $post=$sql->fetch($posts);$c++)
print "
<tr>
$tccell2>$post[id]</td>
$tccell1><a href=profile.php?id=$post[user]><font ".getnamecolor($post['sex'],$post['powerlevel']).">$post[name]</font></a></td>
$tccell1><a href=thread.php?id=$post[thread]>$post[title]</a></td>
$tccell1><nobr>".date($dateformat,$post['date'])."</nobr></td>
$tccell2>$post[ip]</td>
";
if($post=$sql->fetch($posts))
print "<tr>$tccell2 colspan=5>Too many results!";
print "
$tblend<br>$tblstart
$tccellh colspan=6><b>Private messages: ".mysql_num_rows($pmsgs)."</b><tr>
$tccellc>id</td>
$tccellc>Sent by</td>
$tccellc>Sent to</td>
$tccellc>Title</td>
$tccellc>Date</td>
$tccellc>IP</td>
";
for($c=0;$c<500 && $pmsg=$sql->fetch($pmsgs);$c++)
print "
<tr>
$tccell2>$pmsg[id]</td>
$tccell1><a href=profile.php?id=$pmsg[userfrom]><font ".getnamecolor($pmsg['sex1'],$pmsg['pow1']).">$pmsg[name1]</font></a></td>
$tccell1><a href=profile.php?id=$pmsg[userto]><font ".getnamecolor($pmsg['sex2'],$pmsg['pow2']).">$pmsg[name2]</font></a></td>
$tccell1><a href=showprivate.php?id=$pmsg[id]>$pmsg[title]</a></td>
$tccell1><nobr>".date($dateformat,$pmsg['date'])."</nobr></td>
$tccell2>$pmsg[ip]</td>
";
if($pmsg=$sql->fetch($pmsgs))
print "<tr>$tccell2 colspan=6>Too many results!";
}
print $tblend.$footer;
printtimedif($startingtime);
?>