Failed Conditions
Pull Request — master (#177)
by PoUpA
05:08 queued 02:35
created
core/process/aru.php 1 patch
Switch Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -58,149 +58,149 @@  discard block
 block discarded – undo
58 58
 	//
59 59
 	############################
60 60
 
61
-	case 'home_update':
62
-		// Right now
63
-		// ---------
61
+		case 'home_update':
62
+			// Right now
63
+			// ---------
64 64
 
65
-		$req 		= "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
66
-		$result 	= $mysqli->query($req);
67
-		$data 		= $result->fetch_object();
65
+			$req 		= "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
66
+			$result 	= $mysqli->query($req);
67
+			$data 		= $result->fetch_object();
68 68
 
69
-		$values[] 	= $data->total;
69
+			$values[] 	= $data->total;
70 70
 
71 71
 
72
-		// Lured stops
73
-		// -----------
72
+			// Lured stops
73
+			// -----------
74 74
 
75
-		$req 		= "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
76
-		$result 	= $mysqli->query($req);
77
-		$data 		= $result->fetch_object();
75
+			$req 		= "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
76
+			$result 	= $mysqli->query($req);
77
+			$data 		= $result->fetch_object();
78 78
 
79
-		$values[] 	= $data->total;
79
+			$values[] 	= $data->total;
80 80
 
81 81
 
82 82
 
83
-		// Team battle
84
-		// -----------
83
+			// Team battle
84
+			// -----------
85 85
 
86
-		$req 		= "SELECT count( DISTINCT(gym_id) ) as total FROM gym";
87
-		$result 	= $mysqli->query($req);
88
-		$data 		= $result->fetch_object();
86
+			$req 		= "SELECT count( DISTINCT(gym_id) ) as total FROM gym";
87
+			$result 	= $mysqli->query($req);
88
+			$data 		= $result->fetch_object();
89 89
 
90
-		$values[] 	= $data->total;
90
+			$values[] 	= $data->total;
91 91
 
92
-		// Team
93
-		// 1 = bleu
94
-		// 2 = rouge
95
-		// 3 = jaune
92
+			// Team
93
+			// 1 = bleu
94
+			// 2 = rouge
95
+			// 3 = jaune
96 96
 
97
-		$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '2'  ";
98
-		$result	= $mysqli->query($req);
99
-		$data	= $result->fetch_object();
97
+			$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '2'  ";
98
+			$result	= $mysqli->query($req);
99
+			$data	= $result->fetch_object();
100 100
 
101
-		// Red
102
-		$values[] = $data->total;
101
+			// Red
102
+			$values[] = $data->total;
103 103
 
104 104
 
105
-		$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '1'  ";
106
-		$result	= $mysqli->query($req);
107
-		$data	= $result->fetch_object();
105
+			$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '1'  ";
106
+			$result	= $mysqli->query($req);
107
+			$data	= $result->fetch_object();
108 108
 
109
-		// Blue
110
-		$values[] = $data->total;
109
+			// Blue
110
+			$values[] = $data->total;
111 111
 
112 112
 
113
-		$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '3'  ";
114
-		$result	= $mysqli->query($req);
115
-		$data	= $result->fetch_object();
113
+			$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '3'  ";
114
+			$result	= $mysqli->query($req);
115
+			$data	= $result->fetch_object();
116 116
 
117
-		// Yellow
118
-		$values[] = $data->total;
117
+			// Yellow
118
+			$values[] = $data->total;
119 119
 
120
-		$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '0'  ";
121
-		$result	= $mysqli->query($req);
122
-		$data	= $result->fetch_object();
120
+			$req	= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '0'  ";
121
+			$result	= $mysqli->query($req);
122
+			$data	= $result->fetch_object();
123 123
 
124
-		// Neutral
125
-		$values[] = $data->total;
124
+			// Neutral
125
+			$values[] = $data->total;
126 126
 
127 127
 
128
-		header('Content-Type: application/json');
129
-		$json = json_encode($values);
128
+			header('Content-Type: application/json');
129
+			$json = json_encode($values);
130 130
 
131
-		echo $json;
131
+			echo $json;
132 132
 
133 133
 
134
-		break;
134
+			break;
135 135
 
136 136
 
137 137
 
138
-	####################################
139
-	//
140
-	// Update latests spawn on homepage
141
-	//
142
-	####################################
138
+		####################################
139
+		//
140
+		// Update latests spawn on homepage
141
+		//
142
+		####################################
143 143
 
144
-	case 'spawnlist_update':
145
-		// Recent spawn
146
-		// ------------
147
-		$total_spawns = array();
148
-		$last_uid_param = "";
149
-		if (isset($_GET['last_uid'])) {
150
-			$last_uid_param = $_GET['last_uid'];
151
-		}
152
-		if ($config->system->mythic_recents) {
153
-			// get all mythic pokemon ids
154
-			$mythic_pokemons = array();
155
-			foreach ($pokemons->pokemon as $id => $pokemon) {
156
-				if ($pokemon->spawn_rate < 0.01) {
157
-					$mythic_pokemons[] = $id;
158
-				}
144
+		case 'spawnlist_update':
145
+			// Recent spawn
146
+			// ------------
147
+			$total_spawns = array();
148
+			$last_uid_param = "";
149
+			if (isset($_GET['last_uid'])) {
150
+				$last_uid_param = $_GET['last_uid'];
159 151
 			}
152
+			if ($config->system->mythic_recents) {
153
+				// get all mythic pokemon ids
154
+				$mythic_pokemons = array();
155
+				foreach ($pokemons->pokemon as $id => $pokemon) {
156
+					if ($pokemon->spawn_rate < 0.01) {
157
+						$mythic_pokemons[] = $id;
158
+					}
159
+				}
160 160
 
161
-			// get last mythic pokemon
162
-			$req		= "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon
161
+				// get last mythic pokemon
162
+				$req		= "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon
163 163
                         WHERE pokemon_id IN (".implode(",", $mythic_pokemons).")
164 164
                         ORDER BY last_modified DESC LIMIT 0,12";
165
-		} else {
166
-			// get last pokemon
167
-			$req		= "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12";
168
-		}
169
-		$result = $mysqli->query($req);
170
-		while ($data = $result->fetch_object()) {
171
-			$new_spawn = array();
172
-			$pokeid = $data->pokemon_id;
173
-			$pokeuid = $data->encounter_id;
174
-
175
-			if ($last_uid_param != $pokeuid) {
176
-				$last_seen = strtotime($data->disappear_time_real);
177
-
178
-				$last_location = new stdClass();
179
-				$last_location->latitude = $data->latitude;
180
-				$last_location->longitude = $data->longitude;
181
-
182
-				if ($config->system->recents_show_iv) {
183
-					$iv = new stdClass();
184
-					$iv->attack = $data->individual_attack;
185
-					$iv->defense = $data->individual_defense;
186
-					$iv->stamina = $data->individual_stamina;
187
-					if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) {
188
-						$iv->available = true;
189
-					} else {
190
-						$iv->available = false;
165
+			} else {
166
+				// get last pokemon
167
+				$req		= "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12";
168
+			}
169
+			$result = $mysqli->query($req);
170
+			while ($data = $result->fetch_object()) {
171
+				$new_spawn = array();
172
+				$pokeid = $data->pokemon_id;
173
+				$pokeuid = $data->encounter_id;
174
+
175
+				if ($last_uid_param != $pokeuid) {
176
+					$last_seen = strtotime($data->disappear_time_real);
177
+
178
+					$last_location = new stdClass();
179
+					$last_location->latitude = $data->latitude;
180
+					$last_location->longitude = $data->longitude;
181
+
182
+					if ($config->system->recents_show_iv) {
183
+						$iv = new stdClass();
184
+						$iv->attack = $data->individual_attack;
185
+						$iv->defense = $data->individual_defense;
186
+						$iv->stamina = $data->individual_stamina;
187
+						if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) {
188
+							$iv->available = true;
189
+						} else {
190
+							$iv->available = false;
191
+						}
191 192
 					}
192
-				}
193 193
 
194
-				$html = '
194
+					$html = '
195 195
 			    <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;">
196 196
 				<a href="pokemon/'.$pokeid.'"><img src="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a>
197 197
 				<a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a>
198 198
 				<a href="https://maps.google.com/?q='.$last_location->latitude.','.$last_location->longitude.'&ll='.$last_location->latitude.','.$last_location->longitude.'&z=16" target="_blank">
199 199
 				    <small class="pokemon-timer">00:00:00</small>
200 200
 				</a>';
201
-				if ($config->system->recents_show_iv) {
202
-					if ($iv->available) {
203
-						$html .= '
201
+					if ($config->system->recents_show_iv) {
202
+						if ($iv->available) {
203
+							$html .= '
204 204
 					<div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto;">
205 205
 					    <div title="Attack IV: '. $iv->attack .'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'. $iv->attack .'" aria-valuemin="0" aria-valuemax="45" style="width: '. ((100/15)*$iv->attack)/3 .'%">
206 206
 							<span class="sr-only">Attack IV: '. $iv->attack .'</span>
@@ -212,124 +212,124 @@  discard block
 block discarded – undo
212 212
 							<span class="sr-only">Stamina IV: '. $iv->stamina .'</span>
213 213
 					    </div>
214 214
 					</div>';
215
-					} else {
216
-						$html .= '
215
+						} else {
216
+							$html .= '
217 217
 					    <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 15px auto;">
218 218
 						    <div title="IV not available" class="progress-bar" role="progressbar" style="width: 100%; background-color: rgb(210,210,210);" aria-valuenow="1" aria-valuemin="0" aria-valuemax="1">
219 219
 							    <span class="sr-only">IV not available</span>
220 220
 						    </div>
221 221
 					    </div>';
222
+						}
222 223
 					}
223
-				}
224
-				$html .= '
224
+					$html .= '
225 225
 			    </div>';
226
-				$new_spawn['html'] = $html;
227
-				$countdown = $last_seen - time();
228
-				$new_spawn['countdown'] = $countdown;
229
-				$new_spawn['pokemon_uid'] = $pokeuid;
230
-				$total_spawns[] = $new_spawn;
231
-			} else {
232
-				break;
226
+					$new_spawn['html'] = $html;
227
+					$countdown = $last_seen - time();
228
+					$new_spawn['countdown'] = $countdown;
229
+					$new_spawn['pokemon_uid'] = $pokeuid;
230
+					$total_spawns[] = $new_spawn;
231
+				} else {
232
+					break;
233
+				}
233 234
 			}
234
-		}
235
-		header('Content-Type: application/json');
236
-		echo json_encode($total_spawns);
237
-		break;
235
+			header('Content-Type: application/json');
236
+			echo json_encode($total_spawns);
237
+			break;
238 238
 
239 239
 
240 240
 
241
-	####################################
242
-	//
243
-	// List Pokestop
244
-	//
245
-	####################################
241
+		####################################
242
+		//
243
+		// List Pokestop
244
+		//
245
+		####################################
246 246
 
247
-	case 'pokestop':
248
-		$req 		= "SELECT latitude, longitude, lure_expiration FROM pokestop";
249
-		$result 	= $mysqli->query($req);
247
+		case 'pokestop':
248
+			$req 		= "SELECT latitude, longitude, lure_expiration FROM pokestop";
249
+			$result 	= $mysqli->query($req);
250 250
 
251
-		$i=0;
251
+			$i=0;
252 252
 
253
-		while ($data = $result->fetch_object()) {
254
-			if ($data->lure_expiration != '') {
255
-				$icon = 'pokestap_lured.png';
256
-				$text = 'Lured expire @ '.date('h:i:s', strtotime($data->lure_expiration)+(3600*2)) ;
257
-			} else {
258
-				$icon = 'pokestap.png';
259
-				$text = 'Normal stop';
260
-			}
253
+			while ($data = $result->fetch_object()) {
254
+				if ($data->lure_expiration != '') {
255
+					$icon = 'pokestap_lured.png';
256
+					$text = 'Lured expire @ '.date('h:i:s', strtotime($data->lure_expiration)+(3600*2)) ;
257
+				} else {
258
+					$icon = 'pokestap.png';
259
+					$text = 'Normal stop';
260
+				}
261 261
 
262
-			$temp[$i][] = $text;
263
-			$temp[$i][] = $icon;
264
-			$temp[$i][] = $data->latitude;
265
-			$temp[$i][] = $data->longitude;
266
-			$temp[$i][] = $i;
262
+				$temp[$i][] = $text;
263
+				$temp[$i][] = $icon;
264
+				$temp[$i][] = $data->latitude;
265
+				$temp[$i][] = $data->longitude;
266
+				$temp[$i][] = $i;
267 267
 
268
-			$temp_json[] = json_encode($temp[$i]);
268
+				$temp_json[] = json_encode($temp[$i]);
269 269
 
270 270
 
271
-			$i++;
272
-		}
271
+				$i++;
272
+			}
273 273
 
274
-		$return = json_encode($temp_json);
274
+			$return = json_encode($temp_json);
275 275
 
276
-		echo $return;
276
+			echo $return;
277 277
 
278
-		break;
278
+			break;
279 279
 
280 280
 
281 281
 
282
-	####################################
283
-	//
284
-	// Update data for the gym battle
285
-	//
286
-	####################################
282
+		####################################
283
+		//
284
+		// Update data for the gym battle
285
+		//
286
+		####################################
287 287
 
288
-	case 'update_gym':
289
-		$teams			= new stdClass();
290
-		$teams->mystic 		= 1;
291
-		$teams->valor 		= 2;
292
-		$teams->instinct 	= 3;
288
+		case 'update_gym':
289
+			$teams			= new stdClass();
290
+			$teams->mystic 		= 1;
291
+			$teams->valor 		= 2;
292
+			$teams->instinct 	= 3;
293 293
 
294 294
 
295
-		foreach ($teams as $team_name => $team_id) {
296
-			$req	= "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."'  ";
297
-			$result	= $mysqli->query($req);
298
-			$data	= $result->fetch_object();
295
+			foreach ($teams as $team_name => $team_id) {
296
+				$req	= "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."'  ";
297
+				$result	= $mysqli->query($req);
298
+				$data	= $result->fetch_object();
299 299
 
300
-			$return[] 	= $data->total;
301
-			$return[]	= $data->average_points;
302
-		}
300
+				$return[] 	= $data->total;
301
+				$return[]	= $data->average_points;
302
+			}
303 303
 
304
-		$json = json_encode($return);
304
+			$json = json_encode($return);
305 305
 
306
-		header('Content-Type: application/json');
307
-		echo $json;
306
+			header('Content-Type: application/json');
307
+			echo $json;
308 308
 
309 309
 
310
-		break;
310
+			break;
311 311
 
312
-	####################################
313
-	//
314
-	// Get datas for the gym map
315
-	//
316
-	####################################
312
+		####################################
313
+		//
314
+		// Get datas for the gym map
315
+		//
316
+		####################################
317 317
 
318 318
 
319
-	case 'gym_map':
320
-		$req 		= "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_modified, '+00:00', '".$time_offset."')) as last_modified FROM gym";
321
-		$result 	= $mysqli->query($req);
319
+		case 'gym_map':
320
+			$req 		= "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_modified, '+00:00', '".$time_offset."')) as last_modified FROM gym";
321
+			$result 	= $mysqli->query($req);
322 322
 
323 323
 
324
-		$i=0;
324
+			$i=0;
325 325
 
326
-		while ($data = $result->fetch_object()) {
327
-			// Team
328
-			// 1 = bleu
329
-			// 2 = rouge
330
-			// 3 = jaune
326
+			while ($data = $result->fetch_object()) {
327
+				// Team
328
+				// 1 = bleu
329
+				// 2 = rouge
330
+				// 3 = jaune
331 331
 
332
-			switch ($data->team_id) {
332
+				switch ($data->team_id) {
333 333
 				case 0:
334 334
 					$icon	= 'map_white.png';
335 335
 					$team	= 'No Team (yet)';
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 					$team	= 'Team Instinct';
354 354
 					$color	= 'rgba(254, 217, 40, .6)';
355 355
 					break;
356
-			}
356
+				}
357 357
 
358 358
 			// Set gym level
359 359
 			$data->gym_level=0;
@@ -425,64 +425,64 @@  discard block
 block discarded – undo
425 425
 	//
426 426
 	####################################
427 427
 
428
-	case 'gym_defenders':
429
-		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
430
-		$req 		= "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_modified, '+00:00', '".$time_offset."')) as last_modified, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'";
431
-		$result 	= $mysqli->query($req);
432
-		$gymData['gymDetails']['gymInfos'] = false;
433
-		while ($data = $result->fetch_object()) {
434
-			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
435
-			$gymData['gymDetails']['gymInfos']['description'] = $data->description;
436
-			if ($data->url == null) {
437
-				$gymData['gymDetails']['gymInfos']['url'] = '';
438
-			} else {
439
-				$gymData['gymDetails']['gymInfos']['url'] = $data->url;
440
-			}
441
-			$gymData['gymDetails']['gymInfos']['points'] = $data->points;
442
-			$gymData['gymDetails']['gymInfos']['level'] = 0;
443
-			$gymData['gymDetails']['gymInfos']['last_modified'] = $data->last_modified;
444
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
445
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
446
-			if ($data->points < 2000) {
447
-				$gymData['gymDetails']['gymInfos']['level']=1;
448
-			} elseif ($data->points < 4000) {
449
-				$gymData['gymDetails']['gymInfos']['level']=2;
450
-			} elseif ($data->points < 8000) {
451
-				$gymData['gymDetails']['gymInfos']['level']=3;
452
-			} elseif ($data->points < 12000) {
453
-				$gymData['gymDetails']['gymInfos']['level']=4;
454
-			} elseif ($data->points < 16000) {
455
-				$gymData['gymDetails']['gymInfos']['level']=5;
456
-			} elseif ($data->points < 20000) {
457
-				$gymData['gymDetails']['gymInfos']['level']=6;
458
-			} elseif ($data->points < 30000) {
459
-				$gymData['gymDetails']['gymInfos']['level']=7;
460
-			} elseif ($data->points < 40000) {
461
-				$gymData['gymDetails']['gymInfos']['level']=8;
462
-			} elseif ($data->points < 50000) {
463
-				$gymData['gymDetails']['gymInfos']['level']=9;
464
-			} else {
465
-				$gymData['gymDetails']['gymInfos']['level']=10;
428
+		case 'gym_defenders':
429
+			$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
430
+			$req 		= "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_modified, '+00:00', '".$time_offset."')) as last_modified, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'";
431
+			$result 	= $mysqli->query($req);
432
+			$gymData['gymDetails']['gymInfos'] = false;
433
+			while ($data = $result->fetch_object()) {
434
+				$gymData['gymDetails']['gymInfos']['name'] = $data->name;
435
+				$gymData['gymDetails']['gymInfos']['description'] = $data->description;
436
+				if ($data->url == null) {
437
+					$gymData['gymDetails']['gymInfos']['url'] = '';
438
+				} else {
439
+					$gymData['gymDetails']['gymInfos']['url'] = $data->url;
440
+				}
441
+				$gymData['gymDetails']['gymInfos']['points'] = $data->points;
442
+				$gymData['gymDetails']['gymInfos']['level'] = 0;
443
+				$gymData['gymDetails']['gymInfos']['last_modified'] = $data->last_modified;
444
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team;
445
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
446
+				if ($data->points < 2000) {
447
+					$gymData['gymDetails']['gymInfos']['level']=1;
448
+				} elseif ($data->points < 4000) {
449
+					$gymData['gymDetails']['gymInfos']['level']=2;
450
+				} elseif ($data->points < 8000) {
451
+					$gymData['gymDetails']['gymInfos']['level']=3;
452
+				} elseif ($data->points < 12000) {
453
+					$gymData['gymDetails']['gymInfos']['level']=4;
454
+				} elseif ($data->points < 16000) {
455
+					$gymData['gymDetails']['gymInfos']['level']=5;
456
+				} elseif ($data->points < 20000) {
457
+					$gymData['gymDetails']['gymInfos']['level']=6;
458
+				} elseif ($data->points < 30000) {
459
+					$gymData['gymDetails']['gymInfos']['level']=7;
460
+				} elseif ($data->points < 40000) {
461
+					$gymData['gymDetails']['gymInfos']['level']=8;
462
+				} elseif ($data->points < 50000) {
463
+					$gymData['gymDetails']['gymInfos']['level']=9;
464
+				} else {
465
+					$gymData['gymDetails']['gymInfos']['level']=10;
466
+				}
466 467
 			}
467
-		}
468
-		//print_r($gymData);
469
-		$req 		= "SELECT DISTINCT gympokemon.pokemon_uid, "
470
-				. "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id "
471
-				. "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid "
472
-				. "GROUP BY gympokemon.pokemon_uid"
473
-				. " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC";
474
-		$result 	= $mysqli->query($req);
475
-		$i=0;
468
+			//print_r($gymData);
469
+			$req 		= "SELECT DISTINCT gympokemon.pokemon_uid, "
470
+					. "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id "
471
+					. "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid "
472
+					. "GROUP BY gympokemon.pokemon_uid"
473
+					. " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC";
474
+			$result 	= $mysqli->query($req);
475
+			$i=0;
476 476
 
477 477
 
478 478
 
479
-		$gymData['infoWindow'] = '
479
+			$gymData['infoWindow'] = '
480 480
 			<div class="gym_defenders">
481 481
 			';
482
-		while ($data = $result->fetch_object()) {
483
-			$gymData['gymDetails']['pokemons'][] = $data;
484
-			if ($data != false) {
485
-				$gymData['infoWindow'] .= '
482
+			while ($data = $result->fetch_object()) {
483
+				$gymData['gymDetails']['pokemons'][] = $data;
484
+				if ($data != false) {
485
+					$gymData['infoWindow'] .= '
486 486
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
487 487
 					<a href="pokemon/'.$data->pokemon_id.'">
488 488
 					<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -500,50 +500,50 @@  discard block
 block discarded – undo
500 500
 						</div>
501 501
 					</div>
502 502
 				</div>'
503
-				;
504
-			} else {
505
-				$gymData['infoWindow'] .= '
503
+					;
504
+				} else {
505
+					$gymData['infoWindow'] .= '
506 506
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
507 507
 					<a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'">
508 508
 					<img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
509 509
 					</a>
510 510
 					<p class="pkmn-name">???</p>
511 511
 				</div>'
512
-				;
512
+					;
513
+				}
514
+				$i++;
513 515
 			}
514
-			$i++;
515
-		}
516
-		$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
517
-		$return = json_encode($gymData);
516
+			$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
517
+			$return = json_encode($gymData);
518 518
 
519
-		echo $return;
519
+			echo $return;
520 520
 
521 521
 
522
-		break;
522
+			break;
523 523
 
524
-	case 'trainer':
525
-		$name = "";
526
-		$page = "0";
527
-		$where = "";
528
-		$order="";
529
-		$team=0;
530
-		$ranking=0;
531
-		if (isset($_GET['name'])) {
532
-			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
533
-			$where = " HAVING name LIKE '%".$trainer_name."%'";
534
-		}
535
-		if (isset($_GET['team']) && $_GET['team']!=0) {
536
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
537
-			$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
538
-		}
539
-		if (isset($_GET['page'])) {
540
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
541
-		}
542
-		if (isset($_GET['ranking'])) {
543
-			$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
544
-		}
524
+		case 'trainer':
525
+			$name = "";
526
+			$page = "0";
527
+			$where = "";
528
+			$order="";
529
+			$team=0;
530
+			$ranking=0;
531
+			if (isset($_GET['name'])) {
532
+				$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
533
+				$where = " HAVING name LIKE '%".$trainer_name."%'";
534
+			}
535
+			if (isset($_GET['team']) && $_GET['team']!=0) {
536
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
537
+				$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
538
+			}
539
+			if (isset($_GET['page'])) {
540
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
541
+			}
542
+			if (isset($_GET['ranking'])) {
543
+				$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
544
+			}
545 545
 
546
-		switch ($ranking) {
546
+			switch ($ranking) {
547 547
 			case 1:
548 548
 				$order=" ORDER BY active DESC ";
549 549
 				break;
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 				break;
553 553
 			default:
554 554
 				$order=" ORDER BY level DESC, active DESC ";
555
-		}
555
+			}
556 556
 
557 557
 		$limit = " LIMIT ".($page*10).",10 ";
558 558
 
@@ -609,100 +609,100 @@  discard block
 block discarded – undo
609 609
 
610 610
 		break;
611 611
 
612
-	case 'pokemon_slider_init':
613
-		$req 		= "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon";
614
-		$result 	= $mysqli->query($req);
615
-		$data 		= $result->fetch_object();
616
-		$bounds 	= $data;
612
+		case 'pokemon_slider_init':
613
+			$req 		= "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon";
614
+			$result 	= $mysqli->query($req);
615
+			$data 		= $result->fetch_object();
616
+			$bounds 	= $data;
617 617
 
618
-		header('Content-Type: application/json');
619
-		$json = json_encode($bounds);
618
+			header('Content-Type: application/json');
619
+			$json = json_encode($bounds);
620 620
 
621
-		echo $json;
622
-		break;
621
+			echo $json;
622
+			break;
623 623
 
624
-	case 'pokemon_heatmap_points':
625
-		$json="";
626
-		if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
627
-			$start = Date("Y-m-d H:i",(int)$_GET['start']);
628
-			$end = Date("Y-m-d H:i",(int)$_GET['end']);
629
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
630
-			$where = " WHERE pokemon.pokemon_id = ".$pokemon_id." "
631
-					. "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'";
632
-			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
633
-			$result 	= $mysqli->query($req);
634
-			$points = array();
635
-			while ($result && $data = $result->fetch_object()) {
636
-				$points[] 	= $data;
624
+		case 'pokemon_heatmap_points':
625
+			$json="";
626
+			if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
627
+				$start = Date("Y-m-d H:i",(int)$_GET['start']);
628
+				$end = Date("Y-m-d H:i",(int)$_GET['end']);
629
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
630
+				$where = " WHERE pokemon.pokemon_id = ".$pokemon_id." "
631
+						. "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'";
632
+				$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
633
+				$result 	= $mysqli->query($req);
634
+				$points = array();
635
+				while ($result && $data = $result->fetch_object()) {
636
+					$points[] 	= $data;
637
+				}
638
+
639
+				$json = json_encode($points);
637 640
 			}
638 641
 
639
-			$json = json_encode($points);
640
-		}
642
+			header('Content-Type: application/json');
641 643
 
642
-		header('Content-Type: application/json');
644
+			echo $json;
643 645
 
644
-		echo $json;
646
+			break;
645 647
 
646
-		break;
648
+		case 'pokedex':
649
+			$json="";
650
+			if (isset($_GET['pokemon_id'])) {
651
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
652
+				$where = " WHERE pokemon.pokemon_id = ".$pokemon_id;
653
+				$req 		= "SELECT COUNT(encounter_id) as total FROM pokemon".$where;
654
+				$result 	= $mysqli->query($req);
655
+				$total = 0;
656
+				while ($result && $data = $result->fetch_object()) {
657
+					$total 	= $data;
658
+				}
647 659
 
648
-	case 'pokedex':
649
-		$json="";
650
-		if (isset($_GET['pokemon_id'])) {
651
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
652
-			$where = " WHERE pokemon.pokemon_id = ".$pokemon_id;
653
-			$req 		= "SELECT COUNT(encounter_id) as total FROM pokemon".$where;
654
-			$result 	= $mysqli->query($req);
655
-			$total = 0;
656
-			while ($result && $data = $result->fetch_object()) {
657
-				$total 	= $data;
660
+				$json = json_encode($total);
658 661
 			}
659 662
 
660
-			$json = json_encode($total);
661
-		}
662
-
663
-		header('Content-Type: application/json');
663
+			header('Content-Type: application/json');
664 664
 
665
-		echo $json;
665
+			echo $json;
666 666
 
667
-		break;
667
+			break;
668 668
 
669 669
 		case 'postRequest':
670 670
 		break;
671 671
 
672
-	case 'pokemon_graph_data':
673
-		$json="";
674
-		if (isset($_GET['pokemon_id'])) {
675
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
676
-			$where = " WHERE pokemonFiltered.pokemon_id = ".$pokemon_id;
677
-			$req 		= "SELECT COUNT(*) as total, "
678
-					. "HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_hour
672
+		case 'pokemon_graph_data':
673
+			$json="";
674
+			if (isset($_GET['pokemon_id'])) {
675
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
676
+				$where = " WHERE pokemonFiltered.pokemon_id = ".$pokemon_id;
677
+				$req 		= "SELECT COUNT(*) as total, "
678
+						. "HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_hour
679 679
 			FROM (SELECT * FROM pokemon WHERE pokemon_id = '".$pokemon_id."' LIMIT 10000) as pokemonFiltered
680 680
 			GROUP BY disappear_hour
681 681
 			ORDER BY disappear_hour";
682
-			$result 	= $mysqli->query($req);
683
-			$array = array();
684
-			while ($result && $data = $result->fetch_object()) {
685
-				$array[] = $data->total;
682
+				$result 	= $mysqli->query($req);
683
+				$array = array();
684
+				while ($result && $data = $result->fetch_object()) {
685
+					$array[] = $data->total;
686
+				}
687
+				$array[] = array_shift($array);
688
+				$json = json_encode($array);
686 689
 			}
687
-			$array[] = array_shift($array);
688
-			$json = json_encode($array);
689
-		}
690 690
 
691
-		header('Content-Type: application/json');
691
+			header('Content-Type: application/json');
692 692
 
693
-		echo $json;
693
+			echo $json;
694 694
 
695
-		break;
695
+			break;
696 696
 
697 697
 		case 'postRequest':
698 698
 		break;
699 699
 
700 700
 
701
-	default:
702
-		echo "What do you mean?";
703
-		exit();
701
+		default:
702
+			echo "What do you mean?";
703
+			exit();
704 704
 
705
-	break;
705
+		break;
706 706
 }
707 707
 if ($postRequest!=""){
708 708
 	switch ($postRequest) {
Please login to merge, or discard this patch.