/
material_search.php
315 lines (266 loc) · 16.1 KB
/
material_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
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
<!DOCTYPE html>
<html>
<?php
include "augment_functions.php";
include "general_functions.php";
include "material_functions.php";
include "crafting_functions.php";
$material_name = "";
// Load database settings from config file
$settings = array();
$settings = load_config();
$mysql_user = $settings[0];
$mysql_host = $settings[1];
$mysql_pass = $settings[2];
$mysql_database = $settings[3];
// Establish connection to the database
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_database);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
$log_message = "CRITICAL: Failed to connect to database while attempting to update the database tables! Please check your database and database settings!";
log_to_file($log_message);
}
mysqli_query($con, "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
$augment_raw_data = get_augment_data($con);
$bestiary_raw_data = get_raw_bestiary_data($con);
$ground_gear_raw_data = get_ground_gear_data($con);
$superweapons_raw_data = get_superweapons_data($con);
$skell_frame_raw_data = get_skell_frame_data($con);
// $augment_raw_data[2,3,4] contains materials
$augment_search_result = linear_material_augment_search($augment_raw_data, $_GET["search_term"]);
// $ground_gear_raw_data[0] contains all augment names
$ground_gear_search_result = linear_material_ground_gear_search($ground_gear_raw_data, $_GET["search_term"]);
// $superweapons_raw_data[0] contains all augment names
$superweapons_search_result = linear_material_superweapon_search($superweapons_raw_data, $_GET["search_term"]);
// $skell_frame_raw_data[0] contains all augment names
$skell_frame_search_result = linear_material_skell_frame_search($skell_frame_raw_data, $_GET["search_term"]);
// Bestiary search result
$search_result = linear_material_bestiary_search($bestiary_raw_data, $_GET["search_term"]);
?>
<head>
<meta charset="ISO-8859-1">
<title>
<?php
// Print out the searched material as the page title.
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
if(empty($_GET["search_term"]))
{
print "Material Search";
}
else if(stristr($search_result[6][0], $_GET["search_term"]) == false and stristr($search_result[7][0], $_GET["search_term"]) == false and
stristr($search_result[8][0], $_GET["search_term"]) == false and stristr($search_result[9][0], $_GET["search_term"]) == false and
stristr($search_result[10][0], $_GET["search_term"]) == false and stristr($search_result[11][0], $_GET["search_term"]) == false and
stristr($search_result[12][0], $_GET["search_term"]) == false)
{
print "Material Search";
}
else
{
// Check each drops column in database for material name. Starts at 6 and ends with 12 because those positions in the array hold drops
for($i = 6; $i < 13; $i++)
{
if(stristr($search_result[$i][0], $_GET["search_term"]) != false)
{
$material_name = $search_result[$i][0];
print $material_name;
break;
}
}
}
}
?>
</title>
<link rel="stylesheet" type="text/css" href="styles.css" title="Default Styles" media="screen"/>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans" title="Font Styles"/>
</head>
<body link="#E2E2E2" vlink="#ADABAB">
<center><div class="container">
<header>
<?php print_header(); ?>
</header>
<article style="color:#FFFFFF;">
<p>
<!-- <center><img src="logo_big.png"></center> Insert Main Logo here -->
<hr/>
<center><h1>Xenoblade Chronicles X Material Search</h1></center>
<hr/>
<p>
<div class="box">
<p>
<center><h3>Material Search</h3></center>
Type in the material you would like enemy locations and augments for below. Type it exactly as you see it in-game (else it might not show up). Search is case insensitive. The results will include enemy locations and all augments that can be crafted with the desired material.
<br/><br/>
Notes: <br/>
<ul>
<li>You can search the entire database by typing a word in the search box, but it will return the first material that it hits. It is much better to type the full name, or most of it.</li>
<li><b>Some materials will return a blank enemy table!</b> This is because the material is mis-translated in the enemy database. I try to fix as many of these errors as I can.</li>
<br/>
<li><a href ="https://docs.google.com/spreadsheets/d/1g0YR4M8RAHiRhCbAvV4tjXXHLEhRMrARzZMYAUGmyZ4/pub#" target="_blank">Full spreadsheet that was used</a>, created by Gessenkou. I made many additions/corrections for this site's version, but there are still errors and missing entries in the database. If you encounter a material with an incorrect number next to it, please email me with the name of the augment, offending material, and correct value at birdonwheels5 4t gm41l d0t com.</li>
<li>The strange enemy names are due to the fact that the entire database isn't translated yet. Also, some enemies are translated wrong (ie. "Canary Arenatect" which was supposed to be "Saffron Arenatect"). Help with these would be appreciated as well.</li>
<li>This webpage was created by birdonwheels5.</li>
<li><a href="https://github.com/birdonwheels5/xenoblade-x-site/" target="_blank">Source code</a></li>
</ul>
<center><!-- Standard html form -->
<form method="get" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Search: <input type="text" name="search_term" value="<?php //print $_GET["augment_searchterm"]; ?>" size="16">
<center><input type="submit" name="submit" value="Submit"></center>
</form>
</p>
</div>
<?php
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
if(empty($_GET["search_term"]))
{
die();
}
if(stristr($search_result[6][0], $_GET["search_term"]) == false and stristr($search_result[7][0], $_GET["search_term"]) == false and
stristr($search_result[8][0], $_GET["search_term"]) == false and stristr($search_result[9][0], $_GET["search_term"]) == false and
stristr($search_result[10][0], $_GET["search_term"]) == false and stristr($search_result[11][0], $_GET["search_term"]) == false and
stristr($search_result[12][0], $_GET["search_term"]) == false)
{
// TODO Give material suggestions (Might not get around to this... It's going to be harder than the augment suggestions because
// we don't know where the materials will be in the results array)
print "<div class=\"box\">";
print "The requested material could not be found in the database. Please check the name and try again. <br/><br/>";
print "</div>";
die();
}
print "
<div class=\"box\">
<p>
<center><h3>Enemy Location Results for " . $material_name . "</h3></center>
<br/>
<table class=\"resultsTable\">";
print print_bestiary_table_head();
print print_enemy_materials($search_result);
print "
</table>";
if(!empty($augment_search_result[0]))
{
print
"<br/><br/><center><h3>Augment Results for " . $material_name . "</h3></center>
<br/>
<table class=\"resultsTable\">
<tr>
<td>
<b>Augment Name</b>
<td/>
<td>
<b>Effect</b>
<td/>
<td>
<b>Material 1</b>
<td/>
<td>
<b>Material 2</b>
<td/>
<td>
<b>Material 3</b>
<td/>
<td>
<b>Precious Resource</b>
<td/>
</tr>";
print print_augments($augment_search_result);
print "
</table>";
}
if(!empty($ground_gear_search_result[0]))
{
print
"<br/><br/><center><h3>Ground Gear Results for " . $material_name . "</h3></center>
<br/>
<table class=\"resultsTable\">
<tr>
<td>
<b>Gear Name</b>
<td/>
<td>
<b>Gear Slot</b>
<td/>
<td>
<b>Maker</b>
<td/>
<td>
<b>Level</b>
<td/>
<td>
<b>Defense</b>
<td/>
<td>
<b>Battle Traits</b>
<td/>
</tr>";
print print_ground_gear($ground_gear_search_result);
print "
</table>";
}
if(!empty($superweapons_search_result[0]))
{
print
"<br/><br/><center><h3>Superweapon Results for " . $material_name . "</h3></center>
<br/>
<table class=\"resultsTable\">
<tr>
<td>
<b>Weapon Name</b>
<td/>
<td>
<b>Slot</b>
<td/>
<td>
<b>Level</b>
<td/>
<td>
<b>Force</b>
<td/>
<td>
<b>Attribute</b>
<td/>
<td>
<b>Battle Traits</b>
<td/>
</tr>";
print print_superweapons($superweapons_search_result);
print "
</table>";
}
if(!empty($skell_frame_search_result[0]))
{
print
"<br/><br/><center><h3>Skell Frame Results for " . $material_name . "</h3></center>
<br/>
<table class=\"resultsTable\">
<tr>
<td>
<b>Frame Name</b>
<td/>
<td>
<b>Frame Type</b>
<td/>
</tr>";
print print_skell_frame($skell_frame_search_result);
print "
</table>";
}
}
?>
</p>
</div>
</p>
</p>
</article>
<div class="paddingBottom">
</div>
<div id="counter">
<img src="http://simplehitcounter.com/hit.php?uid=1998481&f=16777215&b=0" border="0" height="0" width="0" alt="web counter"></a>
</div>
<!-- <footer>
2016 birdonwheels5.
</footer> -->
</div>
</body>
</html>