forked from EQMacEmu/allaclone-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.php
360 lines (339 loc) · 15.8 KB
/
items.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?php
/** If the parameter 'isearch' is set, queries for the items matching the criterias and displays them, along with an item search form.
* If only one and only one item is found then this item is displayed.
* If 'isearch' is not set, displays a search item form.
* If no criteria is set then it is equivalent to searching for all items.
* For compatbility with Wikis and multi-word searches, underscores are treated as jokers in 'iname'.
*/
include('./includes/config.php');
include($includes_dir.'constantes.php');
include($includes_dir.'mysql.php');
include($includes_dir.'functions.php');
$isearch = (isset($_GET[ 'isearch']) ? $_GET[ 'isearch'] : '');
$iname = (isset($_GET[ 'iname']) ? $_GET[ 'iname'] : '');
$iclass = (isset($_GET[ 'iclass']) ? addslashes($_GET[ 'iclass']) : '');
$irace = (isset($_GET[ 'irace']) ? addslashes($_GET[ 'irace']) : '');
$islot = (isset($_GET[ 'islot']) ? addslashes($_GET[ 'islot']) : '');
$istat1 = (isset($_GET[ 'istat1']) ? addslashes($_GET[ 'istat1']) : '');
$istat1comp = (isset($_GET[ 'istat1comp']) ? addslashes($_GET[ 'istat1comp']) : '');
$istat1value = (isset($_GET[ 'istat1value']) ? addslashes($_GET[ 'istat1value']) : '');
$istat2 = (isset($_GET[ 'istat2']) ? addslashes($_GET[ 'istat2']) : '');
$istat2comp = (isset($_GET[ 'istat2comp']) ? addslashes($_GET[ 'istat2comp']) : '');
$istat2value = (isset($_GET[ 'istat2value']) ? addslashes($_GET[ 'istat2value']) : '');
$iresists = (isset($_GET[ 'iresists']) ? addslashes($_GET[ 'iresists']) : '');
$iresistscomp = (isset($_GET[ 'iresistscomp']) ? addslashes($_GET[ 'iresistscomp']) : '');
$iresistsvalue = (isset($_GET[ 'iresistsvalue']) ? addslashes($_GET[ 'iresistsvalue']) : '');
$iheroics = (isset($_GET[ 'iheroics']) ? addslashes($_GET[ 'iheroics']) : '');
$iheroicscomp = (isset($_GET[ 'iheroicscomp']) ? addslashes($_GET[ 'iheroicscomp']) : '');
$iheroicsvalue = (isset($_GET[ 'iheroicsvalue']) ? addslashes($_GET[ 'iheroicsvalue']) : '');
$imod = (isset($_GET[ 'imod']) ? addslashes($_GET[ 'imod']) : '');
$imodcomp = (isset($_GET[ 'imodcomp']) ? addslashes($_GET[ 'imodcomp']) : '');
$imodvalue = (isset($_GET[ 'imodvalue']) ? addslashes($_GET[ 'imodvalue']) : '');
$itype = (isset($_GET[ 'itype']) ? addslashes($_GET[ 'itype']) : -1);
$iaugslot = (isset($_GET[ 'iaugslot']) ? addslashes($_GET[ 'iaugslot']) : '');
$ieffect = (isset($_GET[ 'ieffect']) ? addslashes($_GET[ 'ieffect']) : '');
$ireqlevel = (isset($_GET[ 'ireqlevel']) ? addslashes($_GET[ 'ireqlevel']) : '');
$iminlevel = (isset($_GET[ 'iminlevel']) ? addslashes($_GET[ 'iminlevel']) : '');
$inodrop = (isset($_GET[ 'inodrop']) ? addslashes($_GET[ 'inodrop']) : '');
$iavailability = (isset($_GET[ 'iavailability']) ? addslashes($_GET[ 'iavailability']) : '');
$iavailevel = (isset($_GET[ 'iavailevel']) ? addslashes($_GET[ 'iavailevel']) : '');
$ideity = (isset($_GET[ 'ideity']) ? addslashes($_GET[ 'ideity']) : '');
if($isearch != "")
{
$Query = "SELECT $tbitems.* FROM ($tbitems";
if ($DiscoveredItemsOnly==TRUE)
{
$Query .= ",discovered_items";
}
if($iavailability == 1)
{
// mob dropped
$Query .= ",$tblootdropentries,$tbloottableentries,$tbnpctypes";
}
$Query .= ")";
$s = " WHERE";
if($ieffect!="")
{
$effect="%".str_replace(',','%',str_replace(' ','%',addslashes($ieffect)))."%";
$Query.=" LEFT JOIN $tbspells AS proc_s ON proceffect=proc_s.id";
$Query.=" LEFT JOIN $tbspells AS worn_s ON worneffect=worn_s.id";
$Query.=" LEFT JOIN $tbspells AS focus_s ON focuseffect=focus_s.id";
$Query.=" LEFT JOIN $tbspells AS click_s ON clickeffect=click_s.id";
$Query.=" WHERE (proc_s.name LIKE '$effect'
OR worn_s.name LIKE '$effect'
OR focus_s.name LIKE '$effect'
OR click_s.name LIKE '$effect') ";
$s="AND";
}
if(($istat1 != "") AND ($istat1value != ""))
{
if($istat1 == "ratio")
{
$Query .= " $s ($tbitems.delay/$tbitems.damage $istat1comp $istat1value) AND ($tbitems.damage>0)";
$s="AND";
}
else
{
$Query .= " $s ($tbitems.$istat1 $istat1comp $istat1value)";
$s="AND";
}
}
if(($istat2 != "") AND ($istat2value != ""))
{
if($istat2 == "ratio")
{
$Query .= " $s ($tbitems.delay/$tbitems.damage $istat2comp $istat2value) AND ($tbitems.damage>0)";
$s="AND";
}
else
{
$Query .= " $s ($tbitems.$istat2 $istat2comp $istat2value)";
$s="AND";
}
}
if(($imod != "") AND ($imodvalue != ""))
{
$Query .= " $s ($tbitems.$imod $imodcomp $imodvalue)";
$s="AND";
}
if($iavailability == 1) // mob dropped
{
$Query .= " $s $tblootdropentries.item_id=$tbitems.id
AND $tbloottableentries.lootdrop_id=$tblootdropentries.lootdrop_id
AND $tbloottableentries.loottable_id=$tbnpctypes.loottable_id";
if($iavaillevel > 0)
{
$Query .= " AND $tbnpctypes.level<=$iavaillevel";
}
$s="AND";
}
if($iavailability == 2) // merchant sold
{
$Query .= ",$tbmerchantlist $s $tbmerchantlist.item=$tbitems.id";
$s="AND";
}
if ($DiscoveredItemsOnly==TRUE)
{
$Query .= " $s discovered_items.item_id=$tbitems.id";
$s="AND";
}
if($iname != "")
{
$name = addslashes(str_replace("_", "%", str_replace(" ","%",$iname)));
$Query .= " $s ($tbitems.Name like '%".$name."%')"; $s="AND";
}
if($iclass > 0) { $Query.=" $s ($tbitems.classes & $iclass) "; $s="AND"; }
if($ideity > 0) { $Query.=" $s ($tbitems.deity & $ideity) "; $s="AND"; }
if($irace > 0) { $Query.=" $s ($tbitems.races & $irace) "; $s="AND"; }
if($itype >= 0) { $Query.=" $s ($tbitems.itemtype=$itype) "; $s="AND"; }
if($islot > 0) { $Query.=" $s ($tbitems.slots & $islot) "; $s="AND"; }
if($iaugslot > 0)
{
$AugSlot = pow(2, $iaugslot) / 2;
$Query.=" $s ($tbitems.augtype & $AugSlot) "; $s="AND";
}
if($iminlevel > 0) { $Query.=" $s ($tbitems.reqlevel>=$iminlevel) "; $s="AND"; }
if($ireqlevel > 0) { $Query.=" $s ($tbitems.reqlevel<=$ireqlevel) "; $s="AND"; }
if($inodrop) { $Query.=" $s ($tbitems.nodrop=1)"; $s="AND"; }
$Query.=" GROUP BY $tbitems.id ORDER BY $tbitems.Name LIMIT ".(LimitToUse($MaxItemsReturned) + 1);
$QueryResult = mysql_query($Query) or message_die('items.php','MYSQL_QUERY',$Query,mysql_error());
//print $Query;
if(mysql_num_rows($QueryResult) == 1)
{
$row = mysql_fetch_array($QueryResult);
header("Location: item.php?id=".$row["id"]);
exit();
}
}
else
{
$iname = "";
}
/** Here the following holds :
* $QueryResult : items queried for if any query was issued, otherwise it is not defined
* $i* : previously-typed criterias, or empty by default
* $isearch is set if a query was issued
*/
$Title="Item Search";
$XhtmlCompliant = TRUE;
include($includes_dir.'headers.php');
echo "<center><table><tr><td style='toggle_btn'><a href='#' onclick='toggleItem(\"myTbody\")'><b><img src='" . $images_url . "dropdown.png' align='left' width='20' height='20'/>(Toggle Search Fields)</b></a></td></tr></table></center>";
echo "<center><table border='0' width='0%' cellpadding='15'>\n";
echo "<tbody id='myTbody'>";
// Hide the search fields when results show
echo "<form method='GET' action='".$PHP_SELF."'>\n";
// Split into 2 tables side by side
echo "<tr><td><table border='0' width='0%'>";
echo "<tr><td nowrap='1'><b>Name : </b></td><td><input type='text' value=\"$iname\" size='30' name='iname'/></td></tr>\n";
echo "<tr><td nowrap='1'><b>Class : </b></td><td>"; SelectIClass("iclass", $iclass); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Race : </b></td><td>"; SelectRace ("irace", $irace); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Slot : </b></td><td>"; SelectSlot ("islot", $islot); echo "</td></tr>\n";
echo "<tr>\n";
echo " <td nowrap='1'><b>Stats : </b></td>\n";
echo " <td>"; SelectStats("istat1", $istat1); echo "\n";
echo " <select name='istat1comp'>\n";
echo " <option value='>='". ($istat1comp == '>=' ? " selected='1'" : "").">>=</option>\n";
echo " <option value='<='".($istat1comp == '<=' ? " selected='1'" : "")."><=</option>\n";
echo " <option value='='". ($istat1comp == '=' ? " selected='1'" : "").">=</option>\n";
echo " <option value='<'".($istat1comp == '<' ? " selected='1'" : "")."><</option>\n";
echo " </select>\n";
echo " <input type='text' size='4' name='istat1value' value='".$istat1value."'/>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td nowrap='1'><b>Stats : </b></td>\n";
echo " <td>"; SelectStats("istat2",$istat2); echo "\n";
echo " <select name='istat2comp'>\n";
echo " <option value='>='". ($istat2comp == '>=' ? " selected='1'" : "").">>=</option>\n";
echo " <option value='<='".($istat2comp == '<=' ? " selected='1'" : "")."><=</option>\n";
echo " <option value='='". ($istat2comp == '=' ? " selected='1'" : "").">=</option>\n";
echo " <option value='<'".($istat2comp == '<' ? " selected='1'" : "")."><</option>\n";
echo " </select>\n";
echo " <input type='text' size='4' name='istat2value' value='".$istat2value."'/>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td nowrap='1'><b>Resists : </b></td>\n";
echo " <td>"; SelectResists("iresists",$iresists); echo "\n";
echo " <select name='iresistscomp'>\n";
echo " <option value='>='". ($iresistscomp == '>=' ? " selected='1'" : "").">>=</option>\n";
echo " <option value='<='".($iresistscomp == '<=' ? " selected='1'" : "")."><=</option>\n";
echo " <option value='='". ($iresistscomp == '=' ? " selected='1'" : "").">=</option>\n";
echo " <option value='<'".($iresistscomp == '<' ? " selected='1'" : "")."><</option>\n";
echo " </select>\n";
echo " <input type='text' size='4' name='iresistsvalue' value='".$iresistsvalue."'/>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td nowrap='1'><b>Heroic Stats : </b></td>\n";
echo " <td>"; SelectHeroicStats("iheroics",$iheroics); echo "\n";
echo " <select name='iheroicscomp'>\n";
echo " <option value='>='". ($iheroicscomp == '>=' ? " selected='1'" : "").">>=</option>\n";
echo " <option value='<='".($iheroicscomp == '<=' ? " selected='1'" : "")."><=</option>\n";
echo " <option value='='". ($iheroicscomp == '=' ? " selected='1'" : "").">=</option>\n";
echo " <option value='<'".($iheroicscomp == '<' ? " selected='1'" : "")."><</option>\n";
echo " </select>\n";
echo " <input type='text' size='4' name='iheroicsvalue' value='".$iheroicsvalue."'/>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td nowrap='1'><b>Modifiers : </b></td>\n";
echo " <td>"; SelectModifiers("imod",$imod); echo "\n";
echo " <select name='imodcomp'>\n";
echo " <option value='>='". ($imodcomp == '>=' ? " selected='1'" : "").">>=</option>\n";
echo " <option value='<='".($imodcomp == '<=' ? " selected='1'" : "")."><=</option>\n";
echo " <option value='='". ($imodcomp == '=' ? " selected='1'" : "").">=</option>\n";
echo " <option value='<'".($imodcomp == '<' ? " selected='1'" : "")."><</option>\n";
echo " </select>\n";
echo " <input type='text' size='4' name='imodvalue' value='".$imodvalue."'/>\n";
echo " </td>\n";
echo "</tr>\n";
echo "</td></tr></table></td><td>";
// Left Table End and Right Table Start
echo "<table border='0' width='0%'>";
echo "<tr><td nowrap='1'><b>Item Type : </b></td><td>"; SelectIType("itype",$itype); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Augmentation Type : </b></td><td>"; SelectAugSlot("iaugslot",$iaugslot); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>With Effect : </b></td><td><input type='text' value='".$ieffect."' size='30' name='ieffect'/></td></tr>\n";
echo "<tr><td nowrap='1'><b>Min Required Level : </b></td><td>\n"; SelectLevel("iminlevel",$ServerMaxLevel,$iminlevel); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Max Required Level : </b></td><td>\n"; SelectLevel("ireqlevel",$ServerMaxLevel,$ireqlevel); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Tradeable Items Only : </b></td><td><input type='checkbox' name='inodrop'".($inodrop?" checked='1'":"")."/></td></tr>\n";
echo "<tr>\n";
echo " <td nowrap='1'><b>Item availability : </b></td>\n";
echo " <td>\n";
echo " <select name='iavailability'>\n";
echo " <option value='0' ".($iavailability==0?" selected='1'":"").">-</option>\n";
echo " <option value='1' ".($iavailability==1?" selected='1'":"").">Mob Dropped</option>\n";
echo " <option value='2' ".($iavailability==2?" selected='1'":"").">Merchant Sold</option>\n";
echo " </select>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr><td nowrap='1'><b>Max Level : </b></td><td>"; SelectLevel("iavaillevel",$ServerMaxLevel,$iavaillevel); echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Deity : </b></td><td>"; SelectDeity("ideity",$ideity); echo "</td></tr>\n";
echo "</td></tr></table>";
echo "<tr align='center'><td nowrap='1' colspan='2'><input type='submit' value='Search' name='isearch'/> <input type='reset' value='Reset'/></td></tr>\n";
echo "</form>\n";
echo "</tbody>";
echo "</table>\n";
// Print the query results if any
if(isset($QueryResult))
{
$Tableborder = 0;
$num_rows = mysql_num_rows($QueryResult);
$total_row_count = $num_rows;
if($num_rows > LimitToUse($MaxItemsReturned))
{
$num_rows = LimitToUse($MaxItemsReturned);
}
echo "<center>";
if($num_rows == 0)
{
echo "<b>No items found...</b><br>";
}
else
{
$OutOf = "";
if ($total_row_count > $num_rows)
{
$OutOf = " (Searches are limited to 100 Max Results)";
}
echo "<b>" . $num_rows . " " . ($num_rows == 1 ? "item" : "items") . " displayed</b>" . $OutOf . "<br>";
echo "</center>";
echo "<center><table border='$Tableborder' cellpadding='5' width='0%'>";
echo "<tr>
<th class='menuh'>Icon</th>
<th class='menuh'>Item Name</th>
<th class='menuh'>Item Type</th>
<th class='menuh'>AC</th>
<th class='menuh'>HPs</th>
<th class='menuh'>Mana</th>
<th class='menuh'>Damage</th>
<th class='menuh'>Delay</th>
<th class='menuh'>Item ID</th>
</tr>";
$RowClass = "lr";
for( $count = 1 ; $count <= $num_rows ; $count++ )
{
$TableData = "";
$row = mysql_fetch_array($QueryResult);
$TableData .= "<tr valign='top' class='".$RowClass."'><td>";
if(file_exists(getcwd() . "/icons/item_" . $row["icon"] . ".gif"))
{
$TableData .= "<img src='" . $icons_url . "item_" . $row["icon"] . ".gif' align='left'/>";
}
else
{
$TableData .= "<img src='" . $icons_url . "item_.gif' align='left'/>";
}
$TableData .= "</td><td>";
CreateToolTip($row["id"], BuildItemStats($row, 1));
$TableData .= "<a href='item.php?id=" . $row["id"] . "' id='" . $row["id"] . "'>" . $row["Name"] . "</a>";
$TableData .= "</td><td>";
$TableData .= $dbitypes[$row["itemtype"]];
$TableData .= "</td><td>";
$TableData .= $row["ac"];
$TableData .= "</td><td>";
$TableData .= $row["hp"];
$TableData .= "</td><td>";
$TableData .= $row["mana"];
$TableData .= "</td><td>";
$TableData .= $row["damage"];
$TableData .= "</td><td>";
$TableData .= $row["delay"];
$TableData .= "</td><td>";
$TableData .= $row["id"];
$TableData .= "</td></tr>";
if ($RowClass == "lr")
{
$RowClass = "dr";
}
else
{
$RowClass = "lr";
}
print $TableData;
}
echo "</table></center>";
}
}
include($includes_dir."footers.php");
?>