-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaugment_search.php
388 lines (335 loc) · 20.7 KB
/
augment_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
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<!DOCTYPE html>
<html>
<?php
include "augment_functions.php";
include "general_functions.php";
include "material_functions.php";
// 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);
// $augment_raw_data[0] contains all augment names
$search_result = binary_search($augment_raw_data[0], $_GET["search_term"]);
?>
<head>
<meta charset="ISO-8859-1">
<title>
<?php
// Print out the current augment as the page title.
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
if(empty($_GET["search_term"]))
{
print "Augment Search";
}
else if(strcasecmp($augment_raw_data[0][$search_result], $_GET["search_term"]) != 0)
{
print "Augment Search";
}
else
{
print $augment_raw_data[0][$search_result];
}
}
?>
</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 Augment Search</h1></center>
<hr/>
<p>
<div class="box">
<p>
<center><h3>Augment Search</h3></center>
Type in the augment you would like information for below. Type it exactly as you see it in-game (else it might not show up). Search is case insensitive. The results will show you everything you need to know about how to obtain the augment.
<br/><br/>
Notes: <br/>
<ul>
<li>Miranium costs for I/V/X/XV/XX are 100/100/100/1500/2000, and unranked are just 100.</li>
<li>You can search the entire database by typing a word in the search box.</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"]))
{
// Temporary solution for the quick index.
// When the database is finished, this will be retrieved from a static file or something
$augment_index = linear_augment_search($augment_raw_data, ""); // Empty string signals the linear search for the augment index
print "<div class=\"box\">\n";
print "
<center><h3>Quick Augment Index</h3>
<br/>
<br/>
<table class=\"resultsTable\">
<tr>
<td>
<b>Augment Name</b>
<td/>
<td>
<b>Effect</b>
<td/>
</tr>";
print print_augment_index($augment_index);
print "</center></div>\n";
die();
}
if(strcasecmp($augment_raw_data[0][$search_result], $_GET["search_term"]) != 0)
{
print "<div class=\"box\">";
print "The requested augment could not be found in the database. Please check the name and try again. <br/><br/>";
// Explode the search term by spaces
$exploded_search_term = explode(" ", $_GET["search_term"]);
// Run a linear search with the first word of the search term
$linear_results = linear_augment_search($augment_raw_data, $exploded_search_term[0]);
$linear_results_count = count($linear_results);
if($linear_results_count != 0)
{
print "<br/><br/>";
print "Did you mean...<br/><br/>";
print "<ul>";
for($i = 0; $i < $linear_results_count; $i++)
{
// Replace spaces with +'s for url link
print "<li><a href =\"augment_search.php?search_term=" . preg_replace('/\s+/', '+', $linear_results[$i]) . "\">" . $linear_results[$i] . "</a></li>";
}
print "</ul></div>";
}
die();
}
// Put all the augment's data in its own array
$augment_data = array();
for($i = 0; $i < 6; $i++) // We have 6 rows
{
$augment_data[$i] = $augment_raw_data[$i][$search_result];
}
// Search succeeded, time to get the rest of the data about the augment
$bestiary_data = get_bestiary_data($con, $augment_raw_data[2][$search_result], $augment_raw_data[3][$search_result], $augment_raw_data[4][$search_result]);
$frontiernav_data = get_frontiernav_data($con, $augment_data[5]);
print
"<div class=\"box\">
<p>
<center><h3>Results for " . $augment_data[0] . "</h3></center>
<br/>
<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>
<tr>
<td>"
. $augment_data[0] .
"<td/>
<td>"
. $augment_data[1] .
"<td/>
<td>"
. $augment_data[2] .
"<td/>
<td>"
. $augment_data[3] .
"<td/>
<td>"
. $augment_data[4] .
"<td/>
<td>"
. $augment_data[5] .
"<td/>
</tr>
</table>
<table class=\"resultsTable\">
<tr>
<td>
<h2><a href=\"material_search.php?search_term=" . preg_replace('/\s+/', '+', trim(preg_replace('/[0-9]+/', '', $augment_data[2]))) . "\" target=\"_blank\">" . trim(preg_replace('/[0-9]+/', '', $augment_data[2])) . "</a></h2>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
</tr>";
print print_bestiary_table_head();
print print_bestiary_table($bestiary_data, 0);
print
"</p>
<p>
<table class=\"resultsTable\">
<tr>
<td>
<h2><a href=\"material_search.php?search_term=" . preg_replace('/\s+/', '+', trim(preg_replace('/[0-9]+/', '', $augment_data[3]))) . "\" target=\"_blank\">" . trim(preg_replace('/[0-9]+/', '', $augment_data[3])) . "</a></h2>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
</tr>";
print print_bestiary_table_head();
print print_bestiary_table($bestiary_data, 1);
print
"</p>
<p>
<table class=\"resultsTable\">
<tr>
<td>
<h2><a href=\"material_search.php?search_term=" . preg_replace('/\s+/', '+', trim(preg_replace('/[0-9]+/', '', $augment_data[4]))) . "\" target=\"_blank\">" . trim(preg_replace('/[0-9]+/', '', $augment_data[4])) . "</a></h2>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
</tr>";
print print_bestiary_table_head();
print print_bestiary_table($bestiary_data, 2);
print
"</p>
<p>
<table class=\"resultsTable\">
<tr>
<td>
<h2>" . trim(preg_replace('/[0-9]+/', '', $augment_data[5])) . "</h2>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
<td>
<p></p>
<td/>
</tr>
<tr>
<td>
<b>FN Site: </b>
<td/>
<td>
<b>Mining: </b>
<td/>
<td>
<b>Research: </b>
<td/>
<td>
<b>Battle: </b>
<td/>
<td>
<b>Tourist Spots: </b>
<td/>
<td>
<b>Rare Resources: </b>
<td/>
<td>
<b>Connections: </b>
<td/>
</tr>";
print print_frontiernav_table($frontiernav_data);
}
?>
</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>