-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
148 lines (147 loc) · 5.41 KB
/
search.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
<?
include("header.php");
if ($do_search)
{
$query = "";
if (!$searchlimit)
{
$searchlimit = 25;
}
if (!$order_by)
{
$order_by = "rank";
}
if ($search_type == "string")
{
SQLquotes($search_string);
$query .= " empire LIKE '%$search_string%'";
}
elseif ($search_type == "num")
{
if ($search_num)
$query .= " num=$search_num";
else TheEnd("No empire number specified!");
}
elseif ($search_type == "clan")
$query .= " clan=$search_clan";
elseif ($search_type == "online")
$query .= " online=1";
else TheEnd("No search type specified!");
if (($search_era) && ($search_era != -1))
$query .= " and era=$search_era";
if (($search_max_nw) && ($search_nw_max))
{
fixInputNum($search_max_nw);
$query .= " and networth<=$search_max_nw";
}
if (($search_min_nw) && ($search_nw_min))
{
fixInputNum($search_min_nw);
$query .= " and networth>=$search_min_nw";
}
if (($search_race) && ($search_race != -1))
{
fixInputNum($search_min_nw);
$query .= " and race=$search_race";
}
if ($search_dead)
{
$query .= " and ip!='0.0.0.0'";
}
$dbstr = mysql_query("SELECT rank,empire,num,land,networth,clan,race,era,online,disabled,turnsused,vacation,offsucc,offtotal,defsucc,deftotal,kills FROM $playerdb WHERE $query ORDER BY $order_by LIMIT $searchlimit;");
if ($numrows = mysql_num_rows($dbstr))
{
?>
Color Key: <span class="mprotected">Protected/Vacation</span>, <span class="mdead">Dead</span>, <span class="mally">Ally</span>, <span class="mdisabled">Disabled</span>, <span class="madmin">Administrator</span>, <span class="mself">You</span><br>
Stats Key: O = Offensive Actions (success%), D = Defenses (success%), K = Number of empires killed<br>
<table class="scorestable">
<?
printSearchHeader($users[era]);
while ($enemy = mysql_fetch_array($dbstr))
printSearchLine();
printSearchHeader($users[era]);
?>
</table>
<?
if ($numrows > $searchlimit)
print "Search limit reached.<br>\n";
else print "Found $numrows empires matching your criteria.<br>\n";
}
else print "No empires found.<br>\n";
}
?>
<form method="post" action="<?=$config[main]?>?action=search">
<table class="inputtable">
<tr><td>
<table class="inputtable">
<tr><th class="aleft"><label>In Era:</label></th>
<td><select name="search_era" size="1">
<option value="-1">Any</option>
<?
$eralist = mysql_query("SELECT id,name FROM $eradb;");
while ($era = mysql_fetch_array($eralist))
{
?>
<option value="<?=$era[id]?>"><?=$era[name]?></option>
<?
}
?>
</select></td></tr>
<tr><th class="aleft"><label>Race:</label></th>
<td><select name="search_race" size="1">
<option value="-1" selected>Any</option>
<?
$races = mysql_query("select id,name from $racedb;");
while ($race = mysql_fetch_array($races))
{
?>
<option value="<?=$race[id]?>"><?=$race[name]?></option>
<?
}
?>
</select></td></tr>
<tr><th class="aleft"><label>Maximum Networth:</label><input type="checkbox" name="search_nw_max" <?if($search_nw_max) print" checked";?>)></th>
<td>$<input type="text" name="search_max_nw" size="9" value="<?if ($search_max_nw) echo $search_max_nw; else echo commas(10*$users[networth]);?>"></td></tr>
<tr><th class="aleft"><label>Minimum Networth:</label><input type="checkbox" name="search_nw_min" <?if($search_nw_min) print" checked";?>></th>
<td>$<input type="text" name="search_min_nw" size="9" value="<?if ($search_min_nw) echo $search_min_nw; else echo commas($users[networth]/10);?>"></td></tr>
<tr><th class="aleft">Order by:</th>
<td><input type="radio" name="order_by" value="rank" checked>Networth</td></tr>
<tr><th></th>
<td><input type="radio" name="order_by" value="num">Empire Number</td></tr>
<tr><th></th>
<td><input type="radio" name="order_by" value="empire">Empire Name</td></tr>
<tr><th></th>
<td><input type="radio" name="order_by" value="clan">Clan</td></tr>
<tr><th>Exclude dead empires:</th>
<td><input type="checkbox" name="search_dead"></td></tr>
<tr><th class="aleft"><label>Maximum Results:</label></th>
<td><input type="text" name="searchlimit" size="4" value="<?if ($searchlimit) echo $searchlimit; else echo 25;?>"></td></tr>
</table></td>
<td><table class="inputtable">
<tr><th class="aleft"><label><input type="radio" name="search_type" value="num"> Empire Number:</label></th>
<td><input type="text" name="search_num" size="4"></td></tr>
<tr><th class="aleft"><label><input type="radio" name="search_type" value="string" checked> String Search:</label></th>
<td><input type="text" name="search_string" size="15"></td></tr>
<tr><th class="aleft"><label><input type="radio" name="search_type" value="clan"> Clan Tag Search:</label></th>
<td><select name="search_clan" size="1">
<option value="0">None - Unallied Empires</option>
<?
$clanlist = mysql_query("SELECT num,name,tag FROM $clandb WHERE members>0 ORDER BY num;");
while ($clan = mysql_fetch_array($clanlist))
{
?>
<option value="<?=$clan[num]?>"><?=$clan[tag]?> - <?=$clan[name]?></option>
<?
}
?>
</select></td></tr>
<tr><th class="aleft"><label><input type="radio" name="search_type" value="online"> Online Search</label></th>
<td></td></tr>
</table>
</td></tr>
<tr><td colspan="2"><input type="submit" name="do_search" value="Search"></td></tr>
</table>
</form>
<?
TheEnd("");
?>