forked from Warpten/WPPSniffStorage
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.php
373 lines (339 loc) · 19.3 KB
/
index.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
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
function getExpansion($build)
{
if ($build <= 5875)
return Expansions::Classic;
else if ($build > 5875 && $build <= 8606)
return Expansions::Tbc;
else if ($build > 8606 && $build <= 12340)
return Expansions::Wotlk;
else if ($build > 12340 && $build <= 15595)
return Expansions::Cataclysm;
else if ($build > 15595 && $build <= 18414)
return Expansions::Mop;
else if ($build > 18414 && $build <= 21742)
return Expansions::Wod;
else if ($build > 21742 && $build <= 26899)
return Expansions::Legion;
else if ($build > 26972 && $build <= 27843)
return Expansions::Bfa;
return Expansions::Unknown;
}
abstract class Expansions
{
const Unknown = -1;
const Classic = 0;
const Tbc = 1;
const Wotlk = 2;
const Cataclysm = 3;
const Mop = 4;
const Wod = 5;
const Legion = 6;
const Bfa = 7;
};
$buildVersions = array(0 => "All Builds",
// Classic
5875 => "1.12.1 5875",
// The Burning Crusade
6180 => "2.0.1 6180", 6299 => "2.0.3 6299", 6337 => "2.0.6 6337",
6692 => "2.1.0 6692", 6739 => "2.1.1 6739", 6803 => "2.1.2 6803", 6898 => "2.1.3 6898",
7272 => "2.2.0 7272", 7318 => "2.2.2 7318", 7359 => "2.2.3 7359",
7561 => "2.3.0 7561", 7741 => "2.3.2 7741", 7799 => "2.3.3 7799",
8089 => "2.4.0 8089", 8125 => "2.4.1 8125", 8209 => "2.4.2 8209", 8606 => "2.4.3 8606",
// Wrath of the Lich King
9056 => "3.0.2 9056", 9183 => "3.0.3 9183", 9464 => "3.0.8 9464", 9506 => "3.0.8a 9506", 9551 => "3.0.9 9551",
9767 => "3.1.0 9767", 9806 => "3.1.1 9806", 9835 => "3.1.1a 9835", 9901 => "3.1.2 9901", 9947 => "3.1.3 9947",
10192 => "3.2.0 10192", 10314 => "3.2.0a 10314", 10482 => "3.2.2 10482", 10505 => "3.2.2a 10505",
10958 => "3.3.0 10958", 11159 => "3.3.0a 11159", 11685 => "3.3.3 11685", 11723 => "3.3.3a 11723", 12213 => "3.3.5 12213", 12340 => "3.3.5a 12340",
// Cataclysm
13164 => "4.0.1 13164", 13205 => "4.0.1a 13205", 13329 => "4.0.3 13329", 13596 => "4.0.6 13596", 13623 => "4.0.6a 13623",
13914 => "4.1.0 13914", 14007 => "4.1.0a 14007",
14333 => "4.2.0 14333", 14480 => "4.2.0a 14480", 14545 => "4.2.2 14545",
15005 => "4.3.0 15005", 15050 => "4.3.0 15050", 15211 => "4.3.2 15211", 15354 => "4.3.3 15354", 15595 => "4.3.4 15595",
// Mists of Pandaria
16016 => "5.0.4 16016", 16048 => "5.0.5 16048", 16057 => "5.0.5 16057", 16135 => "5.0.5b 16135",
16309 => "5.1.0 16309", 16357 => "5.1.0a 16357",
16650 => "5.2.0 16650", 16669 => "5.2.0a 16669", 16683 => "5.2.0b 16683", 16685 => "5.2.0c 16685", 16701 => "5.2.0d 16701", 16709 => "5.2.0e 16709", 16716 => "5.2.0f 16716", 16733 => "5.2.0g 16733", 16760 => "5.2.0h 16760", 16769 => "5.2.0i 16769", 16826 => "5.2.0j 16826",
16977 => "5.3.0 16977", 16981 => "5.3.0 16981", 16983 => "5.3.0hotfix1 16983", 16992 => "5.3.0hotfix2 16992", 17055 => "5.3.0hotfix3 17055", 17116 => "5.3.0hotfix4 17116", 17128 => "5.3.0a 17128",
17359 => "5.4.0 17359", 17371 => "5.4.0hotfix1 17371", 17399 => "5.4.0hotfix2 17399", 17538 => "5.4.1 17538", 17658 => "5.4.2 17658", 17688 => "5.4.2 17688", 17898 => "5.4.7 17898", 17930 => "5.4.7 17930", 17956 => "5.4.7 17956", 18019 => "5.4.7 18019", 18291 => "5.4.8 18291", 18414 => "5.4.8 18414",
// Warlords of Draenor
19034 => "6.0.2 19034", 19103 => "6.0.3 19103", 19116 => "6.0.3 19116", 19342 => "6.0.1 19342",
19678 => "6.1.0 19678", 19702 => "6.1.0 19702", 19802 => "6.1.2 19802", 19831 => "6.1.2 19831", 19865 => "6.1.2 19865",
20173 => "6.2.0 20173", 20182 => "6.2.0 20182", 20201 => "6.2.0 20201", 20216 => "6.2.0 20216", 20253 => "6.2.0 20253", 20338 => "6.2.0 20338", 20444 => "6.2.2 20444", 20490 => "6.2.2a 20490", 20574 => "6.2.2a 20574", 20726 => "6.2.3 20726", 20779 => "6.2.3 20779", 20886 => "6.2.3 20886", 21315 => "6.2.4 21315", 21336 => "6.2.4 21336", 21348 => "6.2.4 21348", 21355 => "6.2.4 21355", 21463 => "6.2.4 21463", 21676 => "6.2.4 21676", 21742 => "6.2.4 21742",
// Legion
22248 => "7.0.3 22248", 22267 => "7.0.3 22267", 22280 => "7.0.3 22280", 22289 => "7.0.3 22289", 22293 => "7.0.3 22293", 22345 => "7.0.3 22345", 22396 => "7.0.3 22396", 22410 => "7.0.3 22410", 22423 => "7.0.3 22423", 22498 => "7.0.3 22498", 22522 => "7.0.3 22522", 22566 => "7.0.3 22566", 22594 => "7.0.3 22594", 22624 => "7.0.3 22624", 22747 => "7.0.3 22747", 22810 => "7.0.3 22810",
22900 => "7.1.0 22900", 22908 => "7.1.0 22908", 22950 => "7.1.0 22950", 22989 => "7.1.0 22989", 22995 => "7.1.0 22995", 22996 => "7.1.0 22996", 23171 => "7.1.0 23171", 23222 => "7.1.0 23222",
23360 => "7.1.5 23360", 23420 => "7.1.5 23420",
23826 => "7.2.0 23826", 23835 => "7.2.0 23835", 23836 => "7.2.0 23836", 23846 => "7.2.0 23846", 23852 => "7.2.0 23852", 23857 => "7.2.0 23857", 23877 => "7.2.0 23877", 23911 => "7.2.0 23911", 23937 => "7.2.0 23937", 24015 => "7.2.0 24015",
24330 => "7.2.5 24330", 24367 => "7.2.5 24367", 24414 => "7.2.5 24414", 24415 => "7.2.5 24415", 24430 => "7.2.5 24430", 24461 => "7.2.5 24461", 24742 => "7.2.5 24742",
24920 => "7.3.0 24920", 24931 => "7.3.0 24931", 24956 => "7.3.0 24956", 24970 => "7.3.0 24970", 24974 => "7.3.0 24974", 25021 => "7.3.0 25021", 25195 => "7.3.0 25195",
25383 => "7.3.2 25383", 25442 => "7.3.2 25442", 25455 => "7.3.2 25455", 25477 => "7.3.2 25477", 25480 => "7.3.2 25480", 25497 => "7.3.2 25497", 25549 => "7.3.2 25549",
25848 => "7.3.5 25848", 25860 => "7.3.5 25860", 25864 => "7.3.5 25864", 25875 => "7.3.5 25875", 25881 => "7.3.5 25881", 25901 => "7.3.5 25901", 25928 => "7.3.5 25928", 25937 => "7.3.5 25937", 25944 => "7.3.5 25944", 25946 => "7.3.5 25946", 25950 => "7.3.5 25950", 25961 => "7.3.5 25961", 25996 => "7.3.5 25996", 26124 => "7.3.5 26124", 26365 => "7.3.5 26365", 26654 => "7.3.5 26654", 26755 => "7.3.5 26755", 26822 => "7.3.5 26822", 26899 => "7.3.5 26899", 26972 => "7.3.5.26972",
// Battle for Azeroth
27101 => "8.0.1.27101", 27144 => "8.0.1.27144", 27165 => "8.0.1.27165", 27178 => "8.0.1.27178", 27219 => "8.0.1.27219", 27291 => "8.0.1.27291", 27326 => "8.0.1.27326", 27353 => "8.0.1.27353", 27355 => "8.0.1.27355", 27356 => "8.0.1.27356", 27366 => "8.0.1.27366", 27377 => "8.0.1.27377", 27404 => "8.0.1.27404", 27481 => "8.0.1.27481", 27547 => "8.0.1.27547", 27602 => "8.0.1.27602", 27791 => "8.0.1.27791", 27843 => "8.0.1.27843", 27980 => "8.0.1.27980", 28153 => "8.0.1.28153",
);
require_once('./includes/header.php');
require_once('./includes/SniffQuery.php');
$takenBuilds = array();
$builds = '<input type="checkbox" name="builds[]" value="0"> All Builds';
if ($result = $mysqlCon->query("SELECT DISTINCT(Build) AS b FROM sniff_data WHERE Build <> 0 ORDER BY Build DESC")) {
while ($row = $result->fetch_object()) {
$exp = getExpansion($row->b);
$takenBuilds[$exp] .= '<input type="checkbox" name="builds[]" value="' . $row->b . '"';
if (isset($_GET['builds']) && in_array($row->b, $_GET["builds"]))
$takenBuilds[$exp] .= ' checked';
$takenBuilds[$exp] .= '> ' . $buildVersions[$row->b] . '</br>';
}
}
$builds .= '<table><tr>';
if (!empty($takenBuilds[Expansions::Classic]))
$builds .= '<td><input type="checkbox" name="builds[]" value="classic"> Classic<br>' . $takenBuilds[Expansions::Classic] . '</td>';
if (!empty($takenBuilds[Expansions::Tbc]))
$builds .= '<td><input type="checkbox" name="builds[]" value="tbc"> TBC<br>' . $takenBuilds[Expansions::Tbc] . '</td>';
if (!empty($takenBuilds[Expansions::Wotlk]))
$builds .= '<td><input type="checkbox" name="builds[]" value="wotlk"> Wotlk<br>' . $takenBuilds[Expansions::Wotlk] . '</td>';
if (!empty($takenBuilds[Expansions::Cataclysm]))
$builds .= '<td><input type="checkbox" name="builds[]" value="cata"> Cataclysm<br>' . $takenBuilds[Expansions::Cataclysm] . '</td>';
if (!empty($takenBuilds[Expansions::Mop]))
$builds .= '<td><input type="checkbox" name="builds[]" value="mop"> Mop<br>' . $takenBuilds[Expansions::Mop] . '</td>';
if (!empty($takenBuilds[Expansions::Wod]))
$builds .= '<td><input type="checkbox" name="builds[]" value="wod"> Wod<br>' . $takenBuilds[Expansions::Wod] . '</td>';
if (!empty($takenBuilds[Expansions::Legion]))
$builds .= '<td><input type="checkbox" name="builds[]" value="legion"> Legion<br>' . $takenBuilds[Expansions::Legion] . '</td>';
if (!empty($takenBuilds[Expansions::Bfa]))
$builds .= '<td><input type="checkbox" name="builds[]" value="bfa"> BFA<br>' . $takenBuilds[Expansions::Bfa] . '</td>';
$builds .= '</tr></table>';
$searchQuantity = isset($_GET['entryType']) ? count($_GET['entryType']) : 1;
$startOffset = isset($_GET['startOffset']) ? intval($_GET['startOffset']) : 0;
?>
<form action="?startOffset=<?php echo $startOffset; ?>" name="search" method="get">
<table><tr><td>
<fieldset>
<legend>Sniff Search</legend>
<div id="entryContainer">
<p>
<a href="#" id="addSearch">Add New Search</a> | <a id="removeSearch">Remove Last Search</a>
</p>
<?php
for ($i = 0; $i < $searchQuantity; ++$i) {
?>
<div class="entry" style="clear: left;" class="searchFilter">
<label>Entry Type: </label>
<select name="entryType[]" onchange="filterSelect(this)">
<?php
for ($j = 0, $m = count($types); $j < $m; ++$j) {
echo '<option value="' . $types[$j] . '"';
if (isset($_GET['entryType'][$i]) && $_GET['entryType'][$i] == $types[$j])
echo ' selected';
echo ">" . $types[$j] . "</option>";
}
?>
</select><br>
<label>Entry: </label>
<input type="text" name="entry[]" class="searchInput" value="<?php echo isset($_GET['entry'][$i]) ? $_GET['entry'][$i] : ""; ?>" />
<p style="display:none;clear:both;" id="likesentries[]">
<input type="checkbox" name="likeBehavior[]" value="1" <?php if (isset($_GET['likeBehavior'][$i])) echo 'checked '; ?>/>
Use like instead of equals for opcode name.
</p>
<?php if ($searchQuantity != 1 && $i+1 != $searchQuantity) { ?>
<hr />
<p style="clear: both">
<input type="checkbox" name="isAndGroup[]" <?php
if (isset($_GET['isAndGroup'][$i]) && $_GET['isAndGroup'][$i] == true)
echo "checked ";
?>/> <small>Previous search OR new search (Defaults to AND).</small>
</p>
<?php } ?>
</div>
<?php
}
?>
</div>
<input type="submit" name="exec" class="submit" value="Submit" />
</fieldset>
</td><td>
<fieldset class="clientBuildSelector">
<legend>Client Version</legend>
<div class="buildList" name="buildList"><?php echo $builds; ?></div>
</fieldset>
</td></tr></table>
</form>
<?php
if (isset($_GET['exec'])) {
$sqlQuery = new SniffQuery(isset($_GET['builds']) ? $_GET['builds'] : array(), $startOffset);
$likes = isset($_GET['likes']) ? $_GET['likes'] : array();
$patternCount = count($_GET['entryType']);
for ($i = 0; $i < $patternCount; ++$i) {
$type = $_GET['entryType'][$i];
$value = $_GET['entry'][$i];
if ($type == "None")
continue;
if ($type == "Opcode Number") {
$sqlQuery->AddCondition(SniffQuery::DATABASE_SNIFFDATA."ObjectType", "Opcode", SniffQuery::CONDITION_EQUAL);
$sqlQuery->AddCondition(SniffQuery::DATABASE_SNIFFDATA."Id", $value, SniffQuery::CONDITION_EQUAL);
} else if ($type == "Opcode Name") {
$sqlQuery->AddCondition(SniffQuery::DATABASE_SNIFFDATA."ObjectType", "Opcode", SniffQuery::CONDITION_EQUAL);
if (@isset($_GET['likeBehavior'][$i]) && $_GET['likeBehavior'][$i] == 1)
$sqlQuery->AddCondition(SniffQuery::DATABASE_SNIFFDATA."Data", $value, SniffQuery::CONDITION_LIKE);
else
$sqlQuery->AddCondition(SniffQuery::DATABASE_SNIFFDATA."Data", $value, SniffQuery::CONDITION_EQUAL);
} else {
$sqlQuery->AddCondition(SniffQuery::DATABASE_SNIFFDATA."ObjectType", $type, SniffQuery::CONDITION_EQUAL);
if (!empty($value))
$sqlQuery->AddCondition(ctype_digit($value) ? SniffQuery::DATABASE_SNIFFDATA."Id" : SniffQuery::DATABASE_OBJECTNAMES."name", $value);
}
/// NOT a typo: just me not thinking straight when coding.
$sqlQuery->SetAndGroup(isset($_GET['isAndGroup'][$i]) ? !$_GET['isAndGroup'][$i] : true);
$sqlQuery->CreateNewConditionGroup();
}
$resultSet = $sqlQuery->Generate();
if ($resultSet === false)
echo "Nothing to look for, sorreh.";
else {
echo "<p>Query executed: {$resultSet[1]}</p>";
$resultSet = $resultSet[0];
if (count($resultSet) == 0) {
echo "No result.";
return;
}
echo '<table id="resultSet"><tr><th style="width:90px">Build</th><th style="width:500px">Sniff Name</th><th>Data Name</th><th style="width:70px">Value</th><th>Name</th></tr>';
foreach ($resultSet as $i => &$row) {
// $row[0] = Build | $row[1] = Sniff name | $row[2] = Data name | $row[3] = Value | $row[4] = Name | $row[5] = Object type
echo '<tr' . ($i % 2 == 0 ? " class='odd'" : '') . '><td>' . $row[0] . '</td>';
echo '<td><a title="' . $row[1] . '">' . substr($row[1], 0, 28) . '</a></td>';
echo '<td>' . $row[2] . '</td>';
echo '<td>' . $row[3] . '</td>';
$isObjTypeValid = true; // only will be valid: Spell, Unit, GameObject, Item, Quest, Zone, Achievement
$objType = strtolower($row[5]);
switch ($objType)
{
case "spell":
break;
case "unit":
$objType = "npc";
break;
case "gameobject":
$objType = "object";
break;
case "item":
break;
case "quest":
break;
case "zone":
break;
case "achievement":
break;
default:
$isObjTypeValid = false;
break;
}
if ($isObjTypeValid)
echo '<td><a href="' . $config['tooltipRedirectionUrl'] . '/?' . $objType . '=' . $row[3] . '" target="_blank" title="Id: ' . $row[3] . '">' . $row[4] . '</a></td></tr>';
else
echo '<td>' . $row[4] . '</td></tr>';
}
echo "</table>";
$pageArgs = http_build_query($_GET, "&");
if ($startOffset != 0)
echo '<a class="paging" href="?'.$pageArgs.'&startOffset='.($startOffset - 50).'">Previous Page</a>';
if (count($resultSet) == 50)
echo '<a class="paging" href="?'.$pageArgs.'&startOffset='.($startOffset + 50).'">Next Page</a>';
}
}
?>
<script src="./includes/jquery.js"></script>
<script>
$(function() {
var types = <?php echo json_encode($types); ?>;
function filterSelect(select) {
alert("Yeah, i'm broken too.");
}
$("#removeSearch").click(function() {
if ($(".searchFilter").length > 0)
$(".searchFilter").last().remove();
});
$("#addSearch").click(function() {
// var filtersCount = $("div.searchFilter").length;
var entriesDiv = $(document.createElement('div')).attr('class', 'searchFilter');
$(entriesDiv).append($(document.createElement('hr'))).css({
'clear': 'both',
'margin-bottom': '4px'
});
$(entriesDiv).append($(document.createElement('p')).css('clear','both').append($(document.createElement('input')).attr({
'type': 'checkbox',
'name': 'isAndGroup[]'}
)).append(' <small>Previous search OR new search (Defaults to AND).</small>'));
$(entriesDiv).append($(document.createElement('label')).text('Entry Type: '));
var entriesSel = $(document.createElement('select')).attr('name','entryType[]');
for (type in types)
$(entriesSel).append($(document.createElement('option')).val(types[type]).text(types[type]));
$(entriesDiv).append($(entriesSel));
$(entriesDiv).append('<br>');
$(entriesDiv).append($(document.createElement('label')).text('Entry: '));
$(entriesDiv).append($(document.createElement('input')).attr({
'type': 'text',
'name': 'entry[]'
}).addClass('searchInput'));
/* $(entriesDiv).append($(document.createElement('p')).css({
'display': 'none',
'clear': 'both'
}).attr('id','likesentries' + entriesCount).append($(document.createElement('input')).attr({
'type': 'checkbox',
'name': 'likes' + entriesCount
}).val(1)).append(' Use like instead of equals for opcode name.')); */
$('#entryContainer').append(entriesDiv);
// $('#entries[] select').change(function(i) { filterSelect(this); });
});
$("input[value=classic]").click(function() {
var checked = $(this).prop("checked");
$("input[value=classic] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=tbc]").click(function() {
var checked = $(this).prop("checked");
$("input[value=tbc] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=wotlk]").click(function() {
var checked = $(this).prop("checked");
$("input[value=wotlk] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=cata]").click(function() {
var checked = $(this).prop("checked");
$("input[value=cata] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=mop]").click(function() {
var checked = $(this).prop("checked");
$("input[value=mop] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=wod]").click(function() {
var checked = $(this).prop("checked");
$("input[value=wod] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=legion]").click(function() {
var checked = $(this).prop("checked");
$("input[value=legion] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
$("input[value=bfa]").click(function() {
$var checked = $(this).prop("checked");
$("input[value=bfa] ~ input").each(function(i) {
$(this).prop("checked", checked ? true : false);
});
});
});
</script>
<?php
include('includes/footer.php');
?>