Passed
Push — master ( ae528b...7f2df7 )
by Markus
02:41
created
core/process/locales.loader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @return array Sorted list of "accept" options
21 21
  */
22
-$sortAccept = function ($header) {
22
+$sortAccept = function($header) {
23 23
 	$matches = array();
24 24
 	foreach (explode(',', $header) as $option) {
25 25
 		$option = array_map('trim', explode(';', $option));
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  *
53 53
  * @return string|NULL a matched option, or NULL if no match
54 54
  */
55
-$matchAccept = function ($header, $supported) use ($sortAccept) {
55
+$matchAccept = function($header, $supported) use ($sortAccept) {
56 56
 	$matches = $sortAccept($header);
57 57
 	foreach ($matches as $key => $q) {
58 58
 		if (isset($supported[$key])) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  *
84 84
  * @return string The negotiated language result or the supplied default.
85 85
  */
86
-$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) {
86
+$negotiateLanguage = function($supported, $default = 'en-US') use ($matchAccept) {
87 87
 	$supp = array();
88 88
 	foreach ($supported as $lang => $isSupported) {
89 89
 		if ($isSupported) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @return array Sorted list of "accept" options
21 21
  */
22
-$sortAccept = function ($header) {
22
+$sortAccept = function ($header)
23
+{
23 24
 	$matches = array();
24 25
 	foreach (explode(',', $header) as $option) {
25 26
 		$option = array_map('trim', explode(';', $option));
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
  *
53 54
  * @return string|NULL a matched option, or NULL if no match
54 55
  */
55
-$matchAccept = function ($header, $supported) use ($sortAccept) {
56
+$matchAccept = function ($header, $supported) use ($sortAccept)
57
+{
56 58
 	$matches = $sortAccept($header);
57 59
 	foreach ($matches as $key => $q) {
58 60
 		if (isset($supported[$key])) {
@@ -83,7 +85,8 @@  discard block
 block discarded – undo
83 85
  *
84 86
  * @return string The negotiated language result or the supplied default.
85 87
  */
86
-$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) {
88
+$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept)
89
+{
87 90
 	$supp = array();
88 91
 	foreach ($supported as $lang => $isSupported) {
89 92
 		if ($isSupported) {
Please login to merge, or discard this patch.
pages/gymhistory.page.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 <script type="text/javascript">
69 69
 <?=
70 70
 $gymName = "";
71
-if (isset($_GET['name']) && $_GET['name']!="") {
71
+if (isset($_GET['name']) && $_GET['name'] != "") {
72 72
 	$gymName = htmlentities($_GET['name']);
73 73
 }
74 74
 ?>
Please login to merge, or discard this patch.
functions.php 1 patch
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -177,7 +177,8 @@  discard block
 block discarded – undo
177 177
 //
178 178
 // Retruns max depth of array
179 179
 ########################################################################
180
-function get_depth($arr) {
180
+function get_depth($arr)
181
+{
181 182
 	$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));
182 183
 	$depth = 0;
183 184
 	foreach ($it as $v) {
@@ -195,12 +196,16 @@  discard block
 block discarded – undo
195 196
 //
196 197
 // Return all pokemon with data at a certain tree depth
197 198
 ########################################################################
198
-function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) {
199
-	if ($depth == $currentDepth) { // Found depth
199
+function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0)
200
+{
201
+	if ($depth == $currentDepth) {
202
+// Found depth
200 203
 		return tree_remove_bellow($trees, $max_pokemon);
201
-	} else { // Go deeper
204
+	} else {
205
+// Go deeper
202 206
 		$arr = array();
203
-		foreach ($trees as $temp) { // Go into all trees
207
+		foreach ($trees as $temp) {
208
+// Go into all trees
204 209
 			$tree = $temp->evolutions;
205 210
 			$results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon);
206 211
 			$arr = tree_check_array($results, $arr, $depth - $currentDepth == 1);
@@ -212,12 +217,16 @@  discard block
 block discarded – undo
212 217
 ########################################################################
213 218
 // used in get_tree_at_depth
214 219
 ########################################################################
215
-function tree_check_array($array_check, $array_add, $correct_arrow) {
220
+function tree_check_array($array_check, $array_add, $correct_arrow)
221
+{
216 222
 	$count = count($array_check);
217 223
 	$i = 0;
218
-	if (!is_null($array_check)) { // check if exists
219
-		foreach ($array_check as $res) { // Check if above, equal or bellow center
220
-			if ($count != 1 && $correct_arrow) { // only add arrow once
224
+	if (!is_null($array_check)) {
225
+// check if exists
226
+		foreach ($array_check as $res) {
227
+// Check if above, equal or bellow center
228
+			if ($count != 1 && $correct_arrow) {
229
+// only add arrow once
221 230
 				$num = $i / ($count - 1);
222 231
 				if ($num < 0.5) {
223 232
 					$res->array_sufix = "_up";
@@ -241,7 +250,8 @@  discard block
 block discarded – undo
241 250
 		return null;
242 251
 	}
243 252
 	$arr = array();
244
-	foreach ($tree as $item) { // Check if above, equal or bellow center
253
+	foreach ($tree as $item) {
254
+// Check if above, equal or bellow center
245 255
 		if ($item->id <= $max_pokemon) {
246 256
 			$arr[] = $item;
247 257
 		}
Please login to merge, or discard this patch.
pages/pokemon.page.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -323,8 +323,7 @@
 block discarded – undo
323 323
 									} elseif (isset($obj->info)) {
324 324
 										$infoName = 'INFO_' . $obj->info;
325 325
 										echo '<br>(' . $locales->$infoName . ')';
326
-									}
327
-									else {
326
+									} else {
328 327
 										echo '<br> </br>';
329 328
 									}
330 329
 									?>
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -316,11 +316,11 @@
 block discarded – undo
316 316
 								<img src="core/img/arrow<?=$obj->array_sufix?>.png" alt="Arrow" class="img">
317 317
 								<p class="pkmn-name">
318 318
 									<?php
319
-                                    if (isset($obj->candies)) {
320
-                                        echo $obj->candies . ' ' . $locales->POKEMON_CANDIES;
321
-                                    } else {
322
-                                        echo '? ' . $locales->POKEMON_CANDIES;
323
-                                    }
319
+									if (isset($obj->candies)) {
320
+										echo $obj->candies . ' ' . $locales->POKEMON_CANDIES;
321
+									} else {
322
+										echo '? ' . $locales->POKEMON_CANDIES;
323
+									}
324 324
 
325 325
 									if (isset($obj->item)) {
326 326
 										$itemName = 'ITEM_' . $obj->item;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -317,17 +317,17 @@
 block discarded – undo
317 317
 								<p class="pkmn-name">
318 318
 									<?php
319 319
                                     if (isset($obj->candies)) {
320
-                                        echo $obj->candies . ' ' . $locales->POKEMON_CANDIES;
320
+                                        echo $obj->candies.' '.$locales->POKEMON_CANDIES;
321 321
                                     } else {
322
-                                        echo '? ' . $locales->POKEMON_CANDIES;
322
+                                        echo '? '.$locales->POKEMON_CANDIES;
323 323
                                     }
324 324
 
325 325
 									if (isset($obj->item)) {
326
-										$itemName = 'ITEM_' . $obj->item;
327
-										echo '<br>+ ' . $locales->$itemName;
326
+										$itemName = 'ITEM_'.$obj->item;
327
+										echo '<br>+ '.$locales->$itemName;
328 328
 									} elseif (isset($obj->info)) {
329
-										$infoName = 'INFO_' . $obj->info;
330
-										echo '<br>(' . $locales->$infoName . ')';
329
+										$infoName = 'INFO_'.$obj->info;
330
+										echo '<br>('.$locales->$infoName.')';
331 331
 									}
332 332
 									else {
333 333
 										echo '<br> </br>';
Please login to merge, or discard this patch.
core/process/aru.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 							FROM gymmember
744 744
 							LEFT JOIN gympokemon
745 745
 							ON gymmember.pokemon_uid = gympokemon.pokemon_uid
746
-							WHERE gymmember.gym_id = '". $data->gym_id ."'
746
+							WHERE gymmember.gym_id = '". $data->gym_id."'
747 747
 							ORDER BY deployment_time";
748 748
 				$pkm_result = $mysqli->query($pkm_req);
749 749
 				while ($pkm_result && $pkm_data = $pkm_result->fetch_object()) {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 				$entry->total_cp_diff = 0;
811 811
 				$entry->only_cp_changed = true;
812 812
 				if ($idx < count($entries) - 1) {
813
-					$next_entry = $entries[$idx+1];
813
+					$next_entry = $entries[$idx + 1];
814 814
 					$entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp;
815 815
 					$entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : '');
816 816
 					$entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY);
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 					foreach ($old_pokemon as $pkm) {
824 824
 						$next_entry->pokemon[$pkm]->class = 'old';
825 825
 					}
826
-					if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) {
826
+					if ($entry->team_id != $next_entry->team_id || $entry->pokemon_uids != $next_entry->pokemon_uids) {
827 827
 						$entry->only_cp_changed = false;
828 828
 					}
829 829
 				}
Please login to merge, or discard this patch.
Switch Indentation   +451 added lines, -451 removed lines patch added patch discarded remove patch
@@ -58,162 +58,162 @@  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
-		// Active Raids
83
-		// -----------
82
+			// Active Raids
83
+			// -----------
84 84
 
85
-		$req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND  end >= UTC_TIMESTAMP()";
86
-		$result = $mysqli->query($req);
87
-		$data = $result->fetch_object();
85
+			$req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND  end >= UTC_TIMESTAMP()";
86
+			$result = $mysqli->query($req);
87
+			$data = $result->fetch_object();
88 88
 
89
-		$values[] = $data->total;
89
+			$values[] = $data->total;
90 90
 
91 91
 
92
-		// Team battle
93
-		// -----------
92
+			// Team battle
93
+			// -----------
94 94
 
95
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
96
-		$result = $mysqli->query($req);
97
-		$data = $result->fetch_object();
95
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
96
+			$result = $mysqli->query($req);
97
+			$data = $result->fetch_object();
98 98
 
99
-		$values[] = $data->total;
99
+			$values[] = $data->total;
100 100
 
101
-		// Team
102
-		// 1 = bleu
103
-		// 2 = rouge
104
-		// 3 = jaune
101
+			// Team
102
+			// 1 = bleu
103
+			// 2 = rouge
104
+			// 3 = jaune
105 105
 
106
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '2'";
107
-		$result = $mysqli->query($req);
108
-		$data = $result->fetch_object();
106
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '2'";
107
+			$result = $mysqli->query($req);
108
+			$data = $result->fetch_object();
109 109
 
110
-		// Red
111
-		$values[] = $data->total;
110
+			// Red
111
+			$values[] = $data->total;
112 112
 
113 113
 
114
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '1'";
115
-		$result = $mysqli->query($req);
116
-		$data = $result->fetch_object();
114
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '1'";
115
+			$result = $mysqli->query($req);
116
+			$data = $result->fetch_object();
117 117
 
118
-		// Blue
119
-		$values[] = $data->total;
118
+			// Blue
119
+			$values[] = $data->total;
120 120
 
121 121
 
122
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '3'";
123
-		$result = $mysqli->query($req);
124
-		$data = $result->fetch_object();
122
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '3'";
123
+			$result = $mysqli->query($req);
124
+			$data = $result->fetch_object();
125 125
 
126
-		// Yellow
127
-		$values[] = $data->total;
126
+			// Yellow
127
+			$values[] = $data->total;
128 128
 
129
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '0'";
130
-		$result = $mysqli->query($req);
131
-		$data = $result->fetch_object();
129
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '0'";
130
+			$result = $mysqli->query($req);
131
+			$data = $result->fetch_object();
132 132
 
133
-		// Neutral
134
-		$values[] = $data->total;
133
+			// Neutral
134
+			$values[] = $data->total;
135 135
 
136
-		header('Content-Type: application/json');
137
-		echo json_encode($values);
136
+			header('Content-Type: application/json');
137
+			echo json_encode($values);
138 138
 
139
-		break;
139
+			break;
140 140
 
141 141
 
142
-	####################################
143
-	//
144
-	// Update latests spawn on homepage
145
-	//
146
-	####################################
142
+		####################################
143
+		//
144
+		// Update latests spawn on homepage
145
+		//
146
+		####################################
147 147
 
148
-	case 'spawnlist_update':
149
-		// Recent spawn
150
-		// ------------
151
-		$total_spawns = array();
152
-		$last_uid_param = "";
153
-		if (isset($_GET['last_uid'])) {
154
-			$last_uid_param = $_GET['last_uid'];
155
-		}
156
-		if ($config->system->recents_filter) {
157
-			// get all mythic pokemon ids
158
-			$mythic_pokemons = array();
159
-			foreach ($pokemons->pokemon as $id => $pokemon) {
160
-				if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) {
161
-					$mythic_pokemons[] = $id;
162
-				}
148
+		case 'spawnlist_update':
149
+			// Recent spawn
150
+			// ------------
151
+			$total_spawns = array();
152
+			$last_uid_param = "";
153
+			if (isset($_GET['last_uid'])) {
154
+				$last_uid_param = $_GET['last_uid'];
163 155
 			}
156
+			if ($config->system->recents_filter) {
157
+				// get all mythic pokemon ids
158
+				$mythic_pokemons = array();
159
+				foreach ($pokemons->pokemon as $id => $pokemon) {
160
+					if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) {
161
+						$mythic_pokemons[] = $id;
162
+					}
163
+				}
164 164
 
165
-			// get last mythic pokemon
166
-			$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
165
+				// get last mythic pokemon
166
+				$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
167 167
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
168 168
 					FROM pokemon
169 169
 					WHERE pokemon_id IN (".implode(",", $mythic_pokemons).")
170 170
 					ORDER BY last_modified DESC
171 171
 					LIMIT 0,12";
172
-		} else {
173
-			// get last pokemon
174
-			$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
172
+			} else {
173
+				// get last pokemon
174
+				$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
175 175
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
176 176
 					FROM pokemon
177 177
 					ORDER BY last_modified DESC
178 178
 					LIMIT 0,12";
179
-		}
180
-		$result = $mysqli->query($req);
181
-		while ($data = $result->fetch_object()) {
182
-			$new_spawn = array();
183
-			$pokeid = $data->pokemon_id;
184
-			$pokeuid = $data->encounter_id;
185
-
186
-			if ($last_uid_param != $pokeuid) {
187
-				$last_seen = strtotime($data->disappear_time_real);
188
-
189
-				$location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16';
190
-				$location_link = str_replace('{latitude}', $data->latitude, $location_link);
191
-				$location_link = str_replace('{longitude}', $data->longitude, $location_link);
192
-
193
-				if ($config->system->recents_encounter_details) {
194
-					$encdetails = new stdClass();
195
-					$encdetails->cp = $data->cp;
196
-					$encdetails->attack = $data->individual_attack;
197
-					$encdetails->defense = $data->individual_defense;
198
-					$encdetails->stamina = $data->individual_stamina;
199
-					if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) {
200
-						$encdetails->available = true;
201
-					} else {
202
-						$encdetails->available = false;
179
+			}
180
+			$result = $mysqli->query($req);
181
+			while ($data = $result->fetch_object()) {
182
+				$new_spawn = array();
183
+				$pokeid = $data->pokemon_id;
184
+				$pokeuid = $data->encounter_id;
185
+
186
+				if ($last_uid_param != $pokeuid) {
187
+					$last_seen = strtotime($data->disappear_time_real);
188
+
189
+					$location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16';
190
+					$location_link = str_replace('{latitude}', $data->latitude, $location_link);
191
+					$location_link = str_replace('{longitude}', $data->longitude, $location_link);
192
+
193
+					if ($config->system->recents_encounter_details) {
194
+						$encdetails = new stdClass();
195
+						$encdetails->cp = $data->cp;
196
+						$encdetails->attack = $data->individual_attack;
197
+						$encdetails->defense = $data->individual_defense;
198
+						$encdetails->stamina = $data->individual_stamina;
199
+						if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) {
200
+							$encdetails->available = true;
201
+						} else {
202
+							$encdetails->available = false;
203
+						}
203 204
 					}
204
-				}
205 205
 
206
-				$html = '
206
+					$html = '
207 207
 			    <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;">
208 208
 				<a href="pokemon/'.$pokeid.'"><img src="'.$pokemons->pokemon->$pokeid->img.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a>
209 209
 				<a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a>
210 210
 				<a href="'.$location_link.'" target="_blank">
211 211
 					<small class="pokemon-timer">00:00:00</small>
212 212
 				</a>';
213
-				if ($config->system->recents_encounter_details) {
214
-					if ($encdetails->available) {
215
-						if ($config->system->iv_numbers) {
216
-							$html .= '
213
+					if ($config->system->recents_encounter_details) {
214
+						if ($encdetails->available) {
215
+							if ($config->system->iv_numbers) {
216
+								$html .= '
217 217
 							<div class="progress" style="height: 15px; margin-bottom: 0">
218 218
 								<div title="'.$locales->IV_ATTACK.': '.$encdetails->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px">
219 219
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>'.$encdetails->attack.'
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>'.$encdetails->stamina.'
226 226
 								</div>
227 227
 							</div>';
228
-						} else {
229
-							$html .= '
228
+							} else {
229
+								$html .= '
230 230
 							<div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto">
231 231
 							<div title="'.$locales->IV_ATTACK.': '.$encdetails->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $encdetails->attack) / 3).'%">
232 232
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>
239 239
 							</div>
240 240
 							</div>';
241
-						}
242
-						$html .= '<small>'.$encdetails->cp.'</small>';
243
-					} else {
244
-						if ($config->system->iv_numbers) {
245
-							$html .= '
241
+							}
242
+							$html .= '<small>'.$encdetails->cp.'</small>';
243
+						} else {
244
+							if ($config->system->iv_numbers) {
245
+								$html .= '
246 246
 							<div class="progress" style="height: 15px; margin-bottom: 0">
247 247
 								<div title="'.$locales->IV_ATTACK.': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px">
248 248
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>?
@@ -254,123 +254,123 @@  discard block
 block discarded – undo
254 254
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>?
255 255
 								</div>
256 256
 							</div>';
257
-						} else {
258
-						$html .= '
257
+							} else {
258
+							$html .= '
259 259
 					    <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto">
260 260
 						    <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">
261 261
 							    <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span>
262 262
 						    </div>
263 263
 					    </div>';
264
+							}
265
+							$html .= '<small>???</small>';
264 266
 						}
265
-						$html .= '<small>???</small>';
266 267
 					}
267
-				}
268
-				$html .= '
268
+					$html .= '
269 269
 			    </div>';
270
-				$new_spawn['html'] = $html;
271
-				$countdown = $last_seen - time();
272
-				$new_spawn['countdown'] = $countdown;
273
-				$new_spawn['pokemon_uid'] = $pokeuid;
274
-				$total_spawns[] = $new_spawn;
275
-			} else {
276
-				break;
270
+					$new_spawn['html'] = $html;
271
+					$countdown = $last_seen - time();
272
+					$new_spawn['countdown'] = $countdown;
273
+					$new_spawn['pokemon_uid'] = $pokeuid;
274
+					$total_spawns[] = $new_spawn;
275
+				} else {
276
+					break;
277
+				}
277 278
 			}
278
-		}
279 279
 
280
-		header('Content-Type: application/json');
281
-		echo json_encode($total_spawns);
280
+			header('Content-Type: application/json');
281
+			echo json_encode($total_spawns);
282 282
 
283
-		break;
283
+			break;
284 284
 
285 285
 
286
-	####################################
287
-	//
288
-	// List Pokestop
289
-	//
290
-	####################################
286
+		####################################
287
+		//
288
+		// List Pokestop
289
+		//
290
+		####################################
291 291
 
292
-	case 'pokestop':
293
-		$where = "";
294
-		$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop ";
292
+		case 'pokestop':
293
+			$where = "";
294
+			$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop ";
295 295
 
296
-		$result = $mysqli->query($req);
296
+			$result = $mysqli->query($req);
297 297
 
298
-		$pokestops = [];
298
+			$pokestops = [];
299 299
 
300
-		while ($data = $result->fetch_object()) {
301
-			if ($data->lure_expiration >= $data->now) {
302
-				$icon = 'pokestap_lured.png';
303
-				$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
304
-				$lured = true;
305
-			} else {
306
-				$icon = 'pokestap.png';
307
-				$text = $locales->POKESTOPS_MAP_REGULAR;
308
-				$lured = false;
309
-			}
300
+			while ($data = $result->fetch_object()) {
301
+				if ($data->lure_expiration >= $data->now) {
302
+					$icon = 'pokestap_lured.png';
303
+					$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
304
+					$lured = true;
305
+				} else {
306
+					$icon = 'pokestap.png';
307
+					$text = $locales->POKESTOPS_MAP_REGULAR;
308
+					$lured = false;
309
+				}
310 310
 
311
-			$pokestops[] = [
312
-				$text,
313
-				$icon,
314
-				$data->latitude,
315
-				$data->longitude,
316
-				$lured
317
-			];
318
-		}
311
+				$pokestops[] = [
312
+					$text,
313
+					$icon,
314
+					$data->latitude,
315
+					$data->longitude,
316
+					$lured
317
+				];
318
+			}
319 319
 
320
-		header('Content-Type: application/json');
321
-		echo json_encode($pokestops);
320
+			header('Content-Type: application/json');
321
+			echo json_encode($pokestops);
322 322
 
323
-		break;
323
+			break;
324 324
 
325 325
 
326
-	####################################
327
-	//
328
-	// Update data for the gym battle
329
-	//
330
-	####################################
326
+		####################################
327
+		//
328
+		// Update data for the gym battle
329
+		//
330
+		####################################
331 331
 
332
-	case 'update_gym':
333
-		$teams = new stdClass();
334
-		$teams->mystic = 1;
335
-		$teams->valor = 2;
336
-		$teams->instinct = 3;
332
+		case 'update_gym':
333
+			$teams = new stdClass();
334
+			$teams->mystic = 1;
335
+			$teams->valor = 2;
336
+			$teams->instinct = 3;
337 337
 
338 338
 
339
-		foreach ($teams as $team_name => $team_id) {
340
-			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
341
-			$result = $mysqli->query($req);
342
-			$data = $result->fetch_object();
339
+			foreach ($teams as $team_name => $team_id) {
340
+				$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
341
+				$result = $mysqli->query($req);
342
+				$data = $result->fetch_object();
343 343
 
344
-			$return[] = $data->total;
345
-			$return[] = $data->average_points;
346
-		}
344
+				$return[] = $data->total;
345
+				$return[] = $data->average_points;
346
+			}
347 347
 
348
-		header('Content-Type: application/json');
349
-		echo json_encode($return);
348
+			header('Content-Type: application/json');
349
+			echo json_encode($return);
350 350
 
351
-		break;
351
+			break;
352 352
 
353 353
 
354
-	####################################
355
-	//
356
-	// Get datas for the gym map
357
-	//
358
-	####################################
354
+		####################################
355
+		//
356
+		// Get datas for the gym map
357
+		//
358
+		####################################
359 359
 
360 360
 
361
-	case 'gym_map':
362
-		$req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym";
363
-		$result = $mysqli->query($req);
361
+		case 'gym_map':
362
+			$req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym";
363
+			$result = $mysqli->query($req);
364 364
 
365
-		$gyms = [];
365
+			$gyms = [];
366 366
 
367
-		while ($data = $result->fetch_object()) {
368
-			// Team
369
-			// 1 = bleu
370
-			// 2 = rouge
371
-			// 3 = jaune
367
+			while ($data = $result->fetch_object()) {
368
+				// Team
369
+				// 1 = bleu
370
+				// 2 = rouge
371
+				// 3 = jaune
372 372
 
373
-			switch ($data->team_id) {
373
+				switch ($data->team_id) {
374 374
 				case 0:
375 375
 					$icon	= 'map_white.png';
376 376
 					$team	= 'No Team (yet)';
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 					$team	= 'Team Instinct';
395 395
 					$color = 'rgba(254, 217, 40, .6)';
396 396
 					break;
397
-			}
397
+				}
398 398
 
399 399
 			if ($data->team_id != 0) {
400 400
 				$icon .= $data->level.".png";
@@ -420,50 +420,50 @@  discard block
 block discarded – undo
420 420
 	//
421 421
 	####################################
422 422
 
423
-	case 'gym_defenders':
424
-		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
425
-		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
423
+		case 'gym_defenders':
424
+			$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
425
+			$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
426 426
 					(CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, gym.total_cp AS total_cp, (6 - gym.slots_available) AS level
427 427
 					FROM gymdetails
428 428
 					LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id
429 429
 					WHERE gym.gym_id='".$gym_id."'";
430
-		$result = $mysqli->query($req);
430
+			$result = $mysqli->query($req);
431 431
 
432
-		$gymData['gymDetails']['gymInfos'] = false;
432
+			$gymData['gymDetails']['gymInfos'] = false;
433 433
 
434
-		while ($data = $result->fetch_object()) {
435
-			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
436
-			$gymData['gymDetails']['gymInfos']['description'] = $data->description;
437
-			if ($data->url == null) {
438
-				$gymData['gymDetails']['gymInfos']['url'] = '';
439
-			} else {
440
-				$gymData['gymDetails']['gymInfos']['url'] = $data->url;
434
+			while ($data = $result->fetch_object()) {
435
+				$gymData['gymDetails']['gymInfos']['name'] = $data->name;
436
+				$gymData['gymDetails']['gymInfos']['description'] = $data->description;
437
+				if ($data->url == null) {
438
+					$gymData['gymDetails']['gymInfos']['url'] = '';
439
+				} else {
440
+					$gymData['gymDetails']['gymInfos']['url'] = $data->url;
441
+				}
442
+				$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
443
+				$gymData['gymDetails']['gymInfos']['level'] = $data->level;
444
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
445
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team;
446
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
441 447
 			}
442
-			$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
443
-			$gymData['gymDetails']['gymInfos']['level'] = $data->level;
444
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
445
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
446
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
447
-		}
448 448
 
449
-		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
449
+			$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
450 450
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
451 451
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
452 452
 					HAVING gymmember.gym_id='".$gym_id."'
453 453
 					ORDER BY cp DESC";
454
-		$result = $mysqli->query($req);
454
+			$result = $mysqli->query($req);
455 455
 
456
-		$i = 0;
456
+			$i = 0;
457 457
 
458
-		$gymData['infoWindow'] = '
458
+			$gymData['infoWindow'] = '
459 459
 			<div class="gym_defenders">
460 460
 			';
461
-		while ($data = $result->fetch_object()) {
462
-			$gymData['gymDetails']['pokemons'][] = $data;
463
-			if ($data != false) {
464
-				$pokemon_id = $data->pokemon_id;
465
-				if ($config->system->iv_numbers) {
466
-					$gymData['infoWindow'] .= '
461
+			while ($data = $result->fetch_object()) {
462
+				$gymData['gymDetails']['pokemons'][] = $data;
463
+				if ($data != false) {
464
+					$pokemon_id = $data->pokemon_id;
465
+					if ($config->system->iv_numbers) {
466
+						$gymData['infoWindow'] .= '
467 467
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
468 468
 						<a href="pokemon/'.$data->pokemon_id.'">
469 469
 						<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 								</div>
482 482
 							</div>
483 483
 						</div>';
484
-				} else {
485
-					$gymData['infoWindow'] .= '
484
+					} else {
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="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
@@ -500,80 +500,80 @@  discard block
 block discarded – undo
500 500
 							</div>
501 501
 						</div>
502 502
 					</div>'
503
-						; }
504
-			} else {
505
-				$pokemon_id = $gymData['gymDetails']['gymInfos']['guardPokemonId'];
506
-				$gymData['infoWindow'] .= '
503
+							; }
504
+				} else {
505
+					$pokemon_id = $gymData['gymDetails']['gymInfos']['guardPokemonId'];
506
+					$gymData['infoWindow'] .= '
507 507
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
508 508
 					<a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'">
509 509
 					<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
510 510
 					</a>
511 511
 					<p class="pkmn-name">???</p>
512 512
 				</div>'
513
-				;
513
+					;
514
+				}
515
+				$i++;
514 516
 			}
515
-			$i++;
516
-		}
517 517
 
518
-		// check whether we could retrieve gym infos, otherwise use basic gym info
519
-		if (!$gymData['gymDetails']['gymInfos']) {
520
-			$req = "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, total_cp, (6 - slots_available) AS level
518
+			// check whether we could retrieve gym infos, otherwise use basic gym info
519
+			if (!$gymData['gymDetails']['gymInfos']) {
520
+				$req = "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, total_cp, (6 - slots_available) AS level
521 521
 				FROM gym WHERE gym_id='".$gym_id."'";
522
-			$result = $mysqli->query($req);
523
-			$data = $result->fetch_object();
524
-
525
-			$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
526
-			$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
527
-			$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
528
-			$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
529
-			$gymData['gymDetails']['gymInfos']['level'] = $data->level;
530
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
531
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
532
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
533
-
534
-			$pokemon_id = $data->guard_pokemon_id;
535
-			$gymData['infoWindow'] .= '
522
+				$result = $mysqli->query($req);
523
+				$data = $result->fetch_object();
524
+
525
+				$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
526
+				$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
527
+				$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
528
+				$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
529
+				$gymData['gymDetails']['gymInfos']['level'] = $data->level;
530
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
531
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
532
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
533
+
534
+				$pokemon_id = $data->guard_pokemon_id;
535
+				$gymData['infoWindow'] .= '
536 536
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
537 537
 					<a href="pokemon/'.$data->guard_pokemon_id.'">
538 538
 					<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
539 539
 					</a>
540 540
 					<p class="pkmn-name">???</p>
541 541
 				</div>';
542
-		}
543
-		$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
542
+			}
543
+			$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
544 544
 
545
-		header('Content-Type: application/json');
546
-		echo json_encode($gymData);
545
+			header('Content-Type: application/json');
546
+			echo json_encode($gymData);
547 547
 
548
-		break;
548
+			break;
549 549
 
550 550
 
551
-	case 'trainer':
552
-		$name = "";
553
-		$page = "0";
554
-		$where = "";
555
-		$order = "";
556
-		$team = 0;
557
-		$ranking = 0;
558
-		if (isset($_GET['name'])) {
559
-			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
560
-			$where = " HAVING name LIKE '%".$trainer_name."%'";
561
-		}
562
-		if (isset($_GET['team']) && $_GET['team'] != 0) {
563
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
564
-			$where .= ($where == "" ? " HAVING" : " AND")." team = ".$team;
565
-		}
566
-		if (!empty($config->system->trainer_blacklist)) {
567
-			$where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')";
568
-		}
569
-		if (isset($_GET['page'])) {
570
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
571
-		}
572
-		if (isset($_GET['ranking'])) {
573
-			$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
574
-		}
551
+		case 'trainer':
552
+			$name = "";
553
+			$page = "0";
554
+			$where = "";
555
+			$order = "";
556
+			$team = 0;
557
+			$ranking = 0;
558
+			if (isset($_GET['name'])) {
559
+				$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
560
+				$where = " HAVING name LIKE '%".$trainer_name."%'";
561
+			}
562
+			if (isset($_GET['team']) && $_GET['team'] != 0) {
563
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
564
+				$where .= ($where == "" ? " HAVING" : " AND")." team = ".$team;
565
+			}
566
+			if (!empty($config->system->trainer_blacklist)) {
567
+				$where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')";
568
+			}
569
+			if (isset($_GET['page'])) {
570
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
571
+			}
572
+			if (isset($_GET['ranking'])) {
573
+				$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
574
+			}
575 575
 
576
-		switch ($ranking) {
576
+			switch ($ranking) {
577 577
 			case 1:
578 578
 				$order = " ORDER BY active DESC, level DESC";
579 579
 				break;
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 				break;
583 583
 			default:
584 584
 				$order = " ORDER BY level DESC, active DESC";
585
-		}
585
+			}
586 586
 
587 587
 		$order .= ", last_seen DESC, name ";
588 588
 
@@ -658,73 +658,73 @@  discard block
 block discarded – undo
658 658
 		break;
659 659
 
660 660
 
661
-	case 'raids':
662
-		$page = "0";
663
-		if (isset($_GET['page'])) {
664
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
665
-		}
661
+		case 'raids':
662
+			$page = "0";
663
+			if (isset($_GET['page'])) {
664
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
665
+			}
666 666
 
667
-		$limit = " LIMIT ".($page * 10).",10";
667
+			$limit = " LIMIT ".($page * 10).",10";
668 668
 
669
-		$req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid
669
+			$req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid
670 670
 				JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
671 671
 				JOIN gym ON gym.gym_id = raid.gym_id
672 672
 				WHERE raid.end > UTC_TIMESTAMP()
673 673
 				ORDER BY raid.level DESC, raid.start".$limit;
674 674
 
675
-		$result = $mysqli->query($req);
676
-		$raids = array();
677
-		while ($data = $result->fetch_object()) {
678
-			$data->starttime = date("H:i", strtotime($data->start));
679
-			$data->endtime = date("H:i", strtotime($data->end));
680
-			$data->gym_id = str_replace('.', '_', $data->gym_id);
681
-			if (isset($data->move_1)) {
682
-				$move1 = $data->move_1;
683
-				$data->quick_move = $move->$move1->name;
684
-			} else {
685
-				$data->quick_move = "?";
686
-			}
687
-			if (isset($data->move_2)) {
688
-				$move2 = $data->move_2;
689
-				$data->charge_move = $move->$move2->name;
690
-			} else {
691
-				$data->charge_move = "?";
675
+			$result = $mysqli->query($req);
676
+			$raids = array();
677
+			while ($data = $result->fetch_object()) {
678
+				$data->starttime = date("H:i", strtotime($data->start));
679
+				$data->endtime = date("H:i", strtotime($data->end));
680
+				$data->gym_id = str_replace('.', '_', $data->gym_id);
681
+				if (isset($data->move_1)) {
682
+					$move1 = $data->move_1;
683
+					$data->quick_move = $move->$move1->name;
684
+				} else {
685
+					$data->quick_move = "?";
686
+				}
687
+				if (isset($data->move_2)) {
688
+					$move2 = $data->move_2;
689
+					$data->charge_move = $move->$move2->name;
690
+				} else {
691
+					$data->charge_move = "?";
692
+				}
693
+				$raids[$data->gym_id] = $data;
692 694
 			}
693
-			$raids[$data->gym_id] = $data;
694
-		}
695
-		$json = array();
696
-		$json['raids'] = $raids;
697
-		$locale = array();
698
-		$locale['noraids'] = $locales->RAIDS_NONE;
699
-		$json['locale'] = $locale;
695
+			$json = array();
696
+			$json['raids'] = $raids;
697
+			$locale = array();
698
+			$locale['noraids'] = $locales->RAIDS_NONE;
699
+			$json['locale'] = $locale;
700 700
 
701
-		header('Content-Type: application/json');
702
-		echo json_encode($json);
701
+			header('Content-Type: application/json');
702
+			echo json_encode($json);
703 703
 
704
-		break;
704
+			break;
705 705
 
706 706
 
707
-	case 'gyms':
708
-		$page = '0';
709
-		$where = '';
710
-		$order = '';
711
-		$ranking = 0;
712
-		if (isset($_GET['name']) && $_GET['name'] != '') {
713
-			$gym_name = mysqli_real_escape_string($mysqli, $_GET['name']);
714
-			$where = " WHERE name LIKE '%".$gym_name."%'";
715
-		}
716
-		if (isset($_GET['team']) && $_GET['team'] != '') {
717
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
718
-			$where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team;
719
-		}
720
-		if (isset($_GET['page'])) {
721
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
722
-		}
723
-		if (isset($_GET['ranking'])) {
724
-			$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
725
-		}
707
+		case 'gyms':
708
+			$page = '0';
709
+			$where = '';
710
+			$order = '';
711
+			$ranking = 0;
712
+			if (isset($_GET['name']) && $_GET['name'] != '') {
713
+				$gym_name = mysqli_real_escape_string($mysqli, $_GET['name']);
714
+				$where = " WHERE name LIKE '%".$gym_name."%'";
715
+			}
716
+			if (isset($_GET['team']) && $_GET['team'] != '') {
717
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
718
+				$where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team;
719
+			}
720
+			if (isset($_GET['page'])) {
721
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
722
+			}
723
+			if (isset($_GET['ranking'])) {
724
+				$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
725
+			}
726 726
 
727
-		switch ($ranking) {
727
+			switch ($ranking) {
728 728
 			case 1:
729 729
 				$order = " ORDER BY name, last_modified DESC";
730 730
 				break;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 				break;
734 734
 			default:
735 735
 				$order = " ORDER BY last_modified DESC, name";
736
-		}
736
+			}
737 737
 
738 738
 		$limit = " LIMIT ".($page * 10).",10";
739 739
 
@@ -775,163 +775,163 @@  discard block
 block discarded – undo
775 775
 		break;
776 776
 
777 777
 
778
-	case 'gymhistory':
779
-		$gym_id = '';
780
-		$page = '0';
781
-		if (isset($_GET['gym_id'])) {
782
-			$gym_id = mysqli_real_escape_string($mysqli, $_GET['gym_id']);
783
-			$gym_id = str_replace('_', '.', $gym_id);
784
-		}
785
-		if (isset($_GET['page'])) {
786
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
787
-		}
778
+		case 'gymhistory':
779
+			$gym_id = '';
780
+			$page = '0';
781
+			if (isset($_GET['gym_id'])) {
782
+				$gym_id = mysqli_real_escape_string($mysqli, $_GET['gym_id']);
783
+				$gym_id = str_replace('_', '.', $gym_id);
784
+			}
785
+			if (isset($_GET['page'])) {
786
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
787
+			}
788 788
 
789
-		$entries = array();
789
+			$entries = array();
790 790
 
791
-		if ($gym_id != '') {
792
-			$req = "SELECT gym_id, team_id, total_cp, pokemon_uids, pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '".$time_offset."')) as last_modified
791
+			if ($gym_id != '') {
792
+				$req = "SELECT gym_id, team_id, total_cp, pokemon_uids, pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '".$time_offset."')) as last_modified
793 793
 					FROM gymhistory
794 794
 					WHERE gym_id='".$gym_id."'
795 795
 					ORDER BY last_modified DESC
796 796
 					LIMIT ".($page * 10).",11";
797 797
 
798
-			$result = $mysqli->query($req);
799
-			while ($result && $data = $result->fetch_object()) {
800
-				$pkm = array();
801
-				if ($data->total_cp == 0) { $data->pokemon_uids = ''; }
802
-				if ($data->pokemon_uids != '') {
803
-					$pkm_uids = explode(',', $data->pokemon_uids);
804
-					$pkm_req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name
798
+				$result = $mysqli->query($req);
799
+				while ($result && $data = $result->fetch_object()) {
800
+					$pkm = array();
801
+					if ($data->total_cp == 0) { $data->pokemon_uids = ''; }
802
+					if ($data->pokemon_uids != '') {
803
+						$pkm_uids = explode(',', $data->pokemon_uids);
804
+						$pkm_req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name
805 805
 								FROM gympokemon
806 806
 								WHERE pokemon_uid IN ('".implode("','", $pkm_uids)."')
807 807
 								ORDER BY FIND_IN_SET(pokemon_uid, '".implode(",", $pkm_uids)."')";
808
-					$pkm_result = $mysqli->query($pkm_req);
809
-					while ($pkm_result && $pkm_data = $pkm_result->fetch_object()) {
810
-						$pkm[$pkm_data->pokemon_uid] = $pkm_data;
808
+						$pkm_result = $mysqli->query($pkm_req);
809
+						while ($pkm_result && $pkm_data = $pkm_result->fetch_object()) {
810
+							$pkm[$pkm_data->pokemon_uid] = $pkm_data;
811
+						}
811 812
 					}
813
+					$data->pokemon = $pkm;
814
+					$data->gym_id = str_replace('.', '_', $data->gym_id);
815
+					$entries[] = $data;
812 816
 				}
813
-				$data->pokemon = $pkm;
814
-				$data->gym_id = str_replace('.', '_', $data->gym_id);
815
-				$entries[] = $data;
816
-			}
817
-
818
-			foreach ($entries as $idx => $entry) {
819
-				$entry->total_cp_diff = 0;
820
-				$entry->only_cp_changed = true;
821
-				if ($idx < count($entries) - 1) {
822
-					$next_entry = $entries[$idx+1];
823
-					$entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp;
824
-					$entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : '');
825
-					$entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY);
826
-					$next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY);
827
-					$new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon);
828
-					$old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon);
829
-					foreach ($new_pokemon as $pkm) {
830
-						$entry->pokemon[$pkm]->class = 'new';
831
-					}
832
-					foreach ($old_pokemon as $pkm) {
833
-						$next_entry->pokemon[$pkm]->class = 'old';
834
-					}
835
-					if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) {
836
-						$entry->only_cp_changed = false;
817
+
818
+				foreach ($entries as $idx => $entry) {
819
+					$entry->total_cp_diff = 0;
820
+					$entry->only_cp_changed = true;
821
+					if ($idx < count($entries) - 1) {
822
+						$next_entry = $entries[$idx+1];
823
+						$entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp;
824
+						$entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : '');
825
+						$entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY);
826
+						$next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY);
827
+						$new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon);
828
+						$old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon);
829
+						foreach ($new_pokemon as $pkm) {
830
+							$entry->pokemon[$pkm]->class = 'new';
831
+						}
832
+						foreach ($old_pokemon as $pkm) {
833
+							$next_entry->pokemon[$pkm]->class = 'old';
834
+						}
835
+						if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) {
836
+							$entry->only_cp_changed = false;
837
+						}
837 838
 					}
839
+					unset($entry->pokemon_uids);
838 840
 				}
839
-				unset($entry->pokemon_uids);
841
+
842
+				if (count($entries) > 10) { array_pop($entries); }
840 843
 			}
841 844
 
842
-			if (count($entries) > 10) { array_pop($entries); }
843
-		}
845
+			$json = array();
846
+			$json['entries'] = $entries;
847
+			$locale = array();
848
+			$json['locale'] = $locale;
844 849
 
845
-		$json = array();
846
-		$json['entries'] = $entries;
847
-		$locale = array();
848
-		$json['locale'] = $locale;
850
+			header('Content-Type: application/json');
851
+			echo json_encode($json);
849 852
 
850
-		header('Content-Type: application/json');
851
-		echo json_encode($json);
853
+			break;
852 854
 
853
-		break;
854 855
 
856
+		case 'pokemon_slider_init':
857
+			$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
858
+			$result 	= $mysqli->query($req);
859
+			$bounds		= $result->fetch_object();
855 860
 
856
-	case 'pokemon_slider_init':
857
-		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
858
-		$result 	= $mysqli->query($req);
859
-		$bounds		= $result->fetch_object();
861
+			header('Content-Type: application/json');
862
+			echo json_encode($bounds);
860 863
 
861
-		header('Content-Type: application/json');
862
-		echo json_encode($bounds);
864
+			break;
863 865
 
864
-		break;
865 866
 
867
+		case 'pokemon_heatmap_points':
868
+			$json = "";
869
+			if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
870
+				$start = date("Y-m-d H:i", (int) $_GET['start']);
871
+				$end = date("Y-m-d H:i", (int) $_GET['end']);
872
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
873
+				$where = " WHERE pokemon_id = ".$pokemon_id." "
874
+						. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
875
+				$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
876
+				$result = $mysqli->query($req);
877
+				$points = array();
878
+				while ($result && $data = $result->fetch_object()) {
879
+					$points[] = $data;
880
+				}
866 881
 
867
-	case 'pokemon_heatmap_points':
868
-		$json = "";
869
-		if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
870
-			$start = date("Y-m-d H:i", (int) $_GET['start']);
871
-			$end = date("Y-m-d H:i", (int) $_GET['end']);
872
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
873
-			$where = " WHERE pokemon_id = ".$pokemon_id." "
874
-					. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
875
-			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
876
-			$result = $mysqli->query($req);
877
-			$points = array();
878
-			while ($result && $data = $result->fetch_object()) {
879
-				$points[] = $data;
882
+				$json = json_encode($points);
880 883
 			}
881 884
 
882
-			$json = json_encode($points);
883
-		}
884
-
885
-		header('Content-Type: application/json');
886
-		echo $json;
887
-		break;
885
+			header('Content-Type: application/json');
886
+			echo $json;
887
+			break;
888 888
 
889 889
 
890
-	case 'maps_localization_coordinates':
891
-		$json = "";
892
-		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
893
-		$result = $mysqli->query($req);
894
-		$coordinates = $result->fetch_object();
890
+		case 'maps_localization_coordinates':
891
+			$json = "";
892
+			$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
893
+			$result = $mysqli->query($req);
894
+			$coordinates = $result->fetch_object();
895 895
 
896
-		header('Content-Type: application/json');
897
-		echo json_encode($coordinates);
896
+			header('Content-Type: application/json');
897
+			echo json_encode($coordinates);
898 898
 
899
-		break;
899
+			break;
900 900
 
901 901
 
902
-	case 'pokemon_graph_data':
903
-		$json = "";
904
-		if (isset($_GET['pokemon_id'])) {
905
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
906
-			$req = "SELECT COUNT(*) AS total,
902
+		case 'pokemon_graph_data':
903
+			$json = "";
904
+			if (isset($_GET['pokemon_id'])) {
905
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
906
+				$req = "SELECT COUNT(*) AS total,
907 907
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour
908 908
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered
909 909
 					GROUP BY disappear_hour
910 910
 					ORDER BY disappear_hour";
911
-			$result = $mysqli->query($req);
912
-			$array = array_fill(0, 24, 0);
913
-			while ($result && $data = $result->fetch_object()) {
914
-				$array[$data->disappear_hour] = $data->total;
911
+				$result = $mysqli->query($req);
912
+				$array = array_fill(0, 24, 0);
913
+				while ($result && $data = $result->fetch_object()) {
914
+					$array[$data->disappear_hour] = $data->total;
915
+				}
916
+				// shift array because AM/PM starts at 1AM not 0:00
917
+				$array[] = $array[0];
918
+				array_shift($array);
919
+
920
+				$json = json_encode($array);
915 921
 			}
916
-			// shift array because AM/PM starts at 1AM not 0:00
917
-			$array[] = $array[0];
918
-			array_shift($array);
919 922
 
920
-			$json = json_encode($array);
921
-		}
923
+			header('Content-Type: application/json');
924
+			echo $json;
925
+			break;
922 926
 
923
-		header('Content-Type: application/json');
924
-		echo $json;
925
-		break;
926 927
 
928
+		case 'postRequest':
929
+			break;
927 930
 
928
-	case 'postRequest':
931
+		default:
932
+			echo "What do you mean?";
933
+			exit();
929 934
 		break;
930
-
931
-	default:
932
-		echo "What do you mean?";
933
-		exit();
934
-	break;
935 935
 }
936 936
 
937 937
 if ($postRequest != "") {
Please login to merge, or discard this patch.