-
Notifications
You must be signed in to change notification settings - Fork 0
/
ntscout.php
executable file
·328 lines (301 loc) · 12.7 KB
/
ntscout.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
<?php
include("header.php");
$_SESSION['returnPage'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
//include("positions.php");
$mysqli = new mysqli('DATABASE SERVER','DATABASE USERNAME','DATABASE PASSWORD','DATABASE NAME');
$mysqli->set_charset("utf8");
?>
<div id="xsnazzy">
<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
<div class="xboxcontent" style="text-align:center">
<p> </p>
<a href="/ntscout.php">NT Scouter</a> | <a href="/visitors.php">Visitor Breakdown</a> | <a href="/world.php">World View</a>
<p> </p>
</div>
<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
</div>
<div id="xsnazzy">
<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
<div class="xboxcontent">
<p> </p>
<?
//Basic sanity checking on parameters
if (($_GET['p_country']) && (!($_GET['p_country']>0) && !($_GET['p_country']<200))) die("ERRORS IN PARAMETERS...");
if (($_GET['s_country']) && (!($_GET['s_country']>0) && !($_GET['s_country']<200))) die("ERRORS IN PARAMETERS...");
if (($_GET['sort'] != NULL) && ($_GET['sort'] != 'age') && ($_GET['sort'] != 'height') && ($_GET['sort'] != 'dmi') && ($_GET['sort'] != 'salary') && ($_GET['sort'] != 'gameshape') && ($_GET['sort'] != 'potential')) die("ERRORS IN PARAMETERS...");
if (($_GET['order'] != NULL) && ($_GET['order'] != 'asc') && ($_GET['order'] != 'desc')) die("ERRORS IN PARAMETERS...");
if (($_GET['bestposition'] != NULL) && ($_GET['bestposition'] != 'PG') && ($_GET['bestposition'] != 'SG') && ($_GET['bestposition'] != 'SF') && ($_GET['bestposition'] != 'PF') && ($_GET['bestposition'] != 'C') && ($_GET['bestposition'] != 'none')) die("ERRORS IN PARAMETERS...");
?>
<div style="text-align:center">
<h1>NT Scouter</h1>
<br/>
<form action='' method='GET'>
<div>
Country Player from: <select name='p_country'>
<?
if(!$_GET['age']) $_GET['age'] = "18";
if ($_GET['p_country']) $player_country = addslashes($_GET['p_country']);
else $player_country = rand(1,30);
if ($_GET['s_country']) $search_country = addslashes($_GET['s_country']);
else $search_country = 'any';
$query="SELECT id,name FROM countries ORDER BY name";
$items = $mysqli->query($query) or die("NT Scout Failed! ERR1");
while($return = mysqli_fetch_array($items))
{
?> <option value='<? echo $return['id']; ?>'<? if ($player_country == $return['id']) echo "selected"; ?>><? echo $return['name']; ?></option><?
}
?>
</select></br>
Country Player Located: <select name='s_country'>
<option value='any'>All Countries</option>
<?
$query="SELECT id,name FROM countries ORDER BY name";
$items = $mysqli->query($query) or die("NT Scout Failed! ERR2");
while($return = mysqli_fetch_array($items))
{
?> <option value='<? echo $return['id']; ?>'<? if ($search_country == $return['id']) echo "selected"; ?>><? echo $return['name']; ?></option><?
}
?></select>
<br>
Sorted by:
<select name='sort'>
<option value='age'<? if ($_GET['sort'] == 'age') echo "selected"; ?>>Age</option>
<option value='height'<? if ($_GET['sort'] == 'height') echo "selected"; ?>>Height</option>
<option value='dmi'<? if (($_GET['sort'] == 'dmi')||(!$_GET['sort'])) echo "selected"; ?>>DMI</option>
<option value='salary'<? if ($_GET['sort'] == 'salary') echo "selected"; ?>>Salary</option>
<option value='gameshape'<? if ($_GET['sort'] == 'gameshape') echo "selected"; ?>>Gameshape</option>
<option value='potential'<? if ($_GET['sort'] == 'potential') echo "selected"; ?>>Potential</option>
</select>
<select name='order'>
<option value='asc'<? if ($_GET['order'] == 'asc') echo "selected"; ?>>Ascending</option>
<option value='desc'<? if (($_GET['order'] == 'desc')||(!$_GET['order'])) echo "selected"; ?>>Descending</option>
</select>
<br/>
Best Position:<select name='bestposition'>
<option value='PG'<? if ($_GET['bestposition'] == 'PG') echo "selected"; ?>>PG</option>
<option value='SG'<? if ($_GET['bestposition'] == 'SG') echo "selected"; ?>>SG</option>
<option value='SF'<? if ($_GET['bestposition'] == 'SF') echo "selected"; ?>>SF</option>
<option value='PF'<? if ($_GET['bestposition'] == 'PF') echo "selected"; ?>>PF</option>
<option value='C'<? if ($_GET['bestposition'] == 'C') echo "selected"; ?>>C</option>
<option value='none'<? if (($_GET['bestposition'] == 'none')||(!$_GET['bestposition'])) echo "selected"; ?>>None</option>
</select>
<br/>
Specific Age:<select name='age'>
<option value='none'<? if ($_GET['age'] == 'none') echo "selected"; ?>>None</option>
<option value='under21'<? if (($_GET['age'] == 'under21')||(!$_GET['age'])) echo "selected"; ?>>Under 21</option>
<option value='25'<? if ($_GET['age'] == '25') echo "selected"; ?>>25</option>
<option value='24'<? if ($_GET['age'] == '24') echo "selected"; ?>>24</option>
<option value='23'<? if ($_GET['age'] == '23') echo "selected"; ?>>23</option>
<option value='22'<? if ($_GET['age'] == '22') echo "selected"; ?>>22</option>
<option value='21'<? if ($_GET['age'] == '21') echo "selected"; ?>>21</option>
<option value='20'<? if ($_GET['age'] == '20') echo "selected"; ?>>20</option>
<option value='19'<? if ($_GET['age'] == '19') echo "selected"; ?>>19</option>
<option value='18'<? if ($_GET['age'] == '18') echo "selected"; ?>>18</option>
</select>
<br>
Days Since Last Update: <input type="text" name="minDays" style="width:20px" value="<? if ($_GET['minDays']) echo $_GET['minDays']; else echo ""; ?>" />
</div>
<input type='submit' value='Search for Players'/>
</form>
<?
//Flush everything so far and then execute the search
echo '<div id="loader" style="margin:0 auto 0 auto; text-align:center;">
<img id="loader" src="/themes/'.$_SESSION['theme'].'/images/ajax-loader.gif" alt="Loading"><br>Searching...</div>';
flush();
?>
<table id="myTable">
<thead>
<tr>
<th> </th>
<th><a href="#">Player</a></th>
<th> </th>
<th><a href="#">Team</a></th>
<th><a href="#">Age</a></th>
<th><a href="#">Height</a></th>
<th><a href="#">DMI</a></th>
<th><a href="#">BP</a></th>
<th style="width:50px;"><a href="#">Salary</a></th>
<th><a href="#" title="Game Shape">Shape</a></th>
<th><a href="#" title="Potential">Pot.</a></th>
<th style="width:60px;"><a href="#" title="Date Last Updated">Latest Update</a></th>
</tr>
</thead>
<tbody>
<?
if ($_GET['sort']) $sort = addslashes($_GET['sort']);
else $sort = 'dmi';
if ($_GET['order']) $order = addslashes($_GET['order']);
else $order = 'DESC';
/*
if ($_GET['sort2']) $sort2 = addslashes($_GET['sort2']);
else $sort2 = 'salary';
if ($_GET['order2']) $order2 = addslashes($_GET['order2']);
else $order2 = 'ASC';*/
if ($search_country!='any')
{
$query="
SELECT PL.id,PL.firstname,PL.lastname,TM.name AS team_name,PL.team_id,PL.nationality
,PL.age,PL.height,PL.dmi,PL.salary,PL.gameshape,PL.potential,PL.update, PL.bestposition,TM.league,LE.countryid,CO2.name as PCName, CO.name as TCName
FROM countries CO
INNER JOIN league LE
ON CO.id = LE.countryid
AND CO.id = '".$search_country."'
AND LE.season = ".$_SESSION['defaultSeason']."
INNER JOIN team TM
ON LE.id = TM.league
AND TM.season = ".$_SESSION['defaultSeason']."
INNER JOIN player PL
ON PL.team_id = TM.id
INNER JOIN countries CO2
ON PL.nationality = CO2.id
WHERE
PL.nationality ='".$player_country."'
";
if ($_GET['age']=='under21')
{
$query .= "
AND (PL.age=18 OR PL.age=19 OR PL.age=20 OR PL.age=21)";
}
else if ($_GET['age']!='none') $age = intval($_GET['age']);
if($age>0)
{
$query .= "
AND PL.age = '".addslashes($age)."'";
}
if ($_GET['minDays']>0) $mindays = $_GET['minDays'];
if($mindays)
{
$histDate = date('U')-(intval($mindays)*60*60*24);
$query .= "
AND PL.update > '".$histDate."'";
}
if(($_GET['bestposition']!="none")&&(strlen($_GET['bestposition'])>0))
{
$query .= "
AND bestposition='".addslashes($_GET['bestposition'])."'";
}
$query .= "
ORDER BY PL.".addslashes($sort)." ".addslashes($order)."
LIMIT 100
";
if($_SESSION['id']=="38596") echo "search in one country: ".$search_country." : <pre>".$query."</pre>";
}
else
{
//if searching in any country
$query="
SELECT PL.id,PL.firstname,PL.lastname,TM.name AS team_name,PL.team_id,PL.nationality
,PL.age,PL.height,PL.dmi,PL.salary,PL.gameshape,PL.potential, PL.bestposition ,PL.update,TM.league
FROM
player PL
INNER JOIN team TM
ON PL.team_id = TM.id
WHERE
TM.season = '".$_SESSION['defaultSeason']."'
AND PL.nationality ='".$player_country."'";
if ($_GET['age']=='under21')
{
$query .= "
AND (PL.age=18 OR PL.age=19 OR PL.age=20 OR PL.age=21)";
}
else if ($_GET['age']!='none') $age = intval($_GET['age']);
if($age>0)
{
$query .= "
AND PL.age = '".addslashes($age)."'";
}
if ($_GET['minDays']>0)
{
$histDate = date('U')-(intval($_GET['minDays'])*60*60*24);
$query=$query."
AND PL.update > '".$histDate."'";
}
if(($_GET['bestposition']!="none")&&(strlen($_GET['bestposition'])>0))
{
$query .= "
AND bestposition='".addslashes($_GET['bestposition'])."'";
}
$query=$query."
ORDER BY PL.".addslashes($sort)." ".addslashes($order)."
LIMIT 100
";
if($_SESSION['id']=="38596") echo "searching all countries : <pre>".$query."</pre>";
}
$items = $mysqli->query($query) or die("NT Scout Failed! ERR4");
while($return = mysqli_fetch_array($items))
{ ?>
<tr>
<td>
<img title="<? echo $return['PCName']; ?>" src="http://<? echo $_SESSION['buzzImages']; ?>/images/flags/flag_<? echo $return['nationality']; ?>.gif" alt="<? echo $return['PCName']; ?>">
</td>
<td>
<a href="http://www.buzzerbeaterstats.com/out.php?url=http://www.buzzerbeater.com/player/<? echo $return['id']; ?>/overview.aspx"><? echo $return['firstname']." ".$return['lastname']." (".$return['id'].")"; ?></a>
</td>
<td>
<?php if($return['TCName']) { ?><img title="<? echo $return['TCName']; ?>" src="http://<? echo $_SESSION['buzzImages']; ?>/images/flags/flag_<? echo $return['countryid']; ?>.gif" alt="<? echo $return['TCName']; ?>"><?php } ?>
</td>
<td>
<a title='in league: <? echo $return['league']; ?>' href='http://www.buzzerbeaterstats.com/out.php?url=http://www.buzzerbeater.com/team/<? echo $return['team_id']; ?>/overview.aspx'><? echo $return['team_name']." (".$return['team_id'].")";?></a>
</td>
<td>
<? echo $return['age']; ?>
</td>
<td>
<?
$height = '';
$cms = round($return['height'] * 2.54,0);
$feet = floor($return['height']/12);
$inches = $return['height']%12;
$height = $feet."'".$inches.'"'; // / '.$cms." cm";
echo $height;
?>
</td>
<td><? echo $return['dmi']; ?></td>
<td><? echo $return['bestposition']; ?></td>
<td style="width:50px;">$<? echo number_format($return['salary'],0,""," "); ?></td>
<td><? echo $return['gameshape']; ?></td>
<td><? echo $return['potential']; ?></td>
<?
$latest_up = $return['update'];
$max = 1728000; //20 days
if ((date('U') - $latest_up) > $max)
{
?>
<td style="font-style:italic">
<a href="/league.php?league=<? echo $return['league']; ?>" title="Click to go and Update League"><? echo date('Y-m-d', $latest_up); ?></a>
</td>
<? }
else {
?>
<td>
<? echo date('Y-m-d', $latest_up); ?>
</td>
<?
} ?>
</tr>
<?
}
if($_SESSION['id']==38596)
{
$query = "SHOW STATUS;";
$items = $mysqli->query($query);
echo "<table>";
while($return = mysqli_fetch_array($items))
{
echo "<tr><td>".$return[0]."</td><td>".$return[1]."</td>";
}
echo "</table>";
}
?>
</tbody>
</table>
</div>
<p> </p>
</div>
<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
</div>
<?
echo '<script type="text/javascript">document.getElementById("loader").style.display="none"</script>';
include("footer.php");
$mysqli->close();
?>