Failed Conditions
Pull Request — master (#363)
by Florian
07:46 queued 05:07
created
core/process/queries/QueryManagerMysqlMonocleAlternate.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -540,9 +540,9 @@
 block discarded – undo
540 540
 		$trainers = array();
541 541
 		while ($data = $result->fetch_object()) {
542 542
 			$data->last_seen = date("Y-m-d", strtotime($data->last_seen));
543
-            if (is_null($data->active)) {
544
-                $data->active = 0;
545
-            }
543
+			if (is_null($data->active)) {
544
+				$data->active = 0;
545
+			}
546 546
 			$trainers[$data->name] = $data;
547 547
 
548 548
 			$pokemon = array_merge($this->getActivePokemon($data->name),  $this->getInactivePokemon($data->name));
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
168 168
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form
169 169
                 FROM sightings
170
-	            WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0'
170
+	            WHERE pokemon_id = '" . $pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0'
171 171
 	            ORDER BY $top_order_by $top_direction, expire_timestamp DESC
172 172
 	            LIMIT 0,50";
173 173
 
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
183 183
 		$trainer_blacklist = "";
184 184
 		if (!empty(self::$config->system->trainer_blacklist)) {
185
-			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
185
+			$trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
186 186
 		}
187 187
 
188 188
 		$req = "SELECT owner_name as trainer_name, ROUND((100*((atk_iv)+(def_iv)+(sta_iv))/45),1) AS IV, move_1, move_2, cp as cp,
189 189
                 FROM_UNIXTIME(last_modified) AS lasttime, last_modified as last_seen
190 190
                 FROM gym_defenders
191
-				WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . "
191
+				WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist."
192 192
 				ORDER BY $best_order_by $best_direction, owner_name ASC
193 193
 				LIMIT 0,50";
194 194
 
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 
231 231
 	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
232 232
 		$inmap_pkms_filter = "";
233
-		$where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = " . $pokemon_id;
233
+		$where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = ".$pokemon_id;
234 234
 
235
-		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where;
235
+		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings ".$where;
236 236
 		$resultTestIv = $this->mysqli->query($reqTestIv);
237 237
 		$testIv = $resultTestIv->fetch_object();
238 238
 		if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) {
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 				$inmap_pkms_filter .= "'".$inmap."',";
241 241
 			}
242 242
 			$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
243
-			$where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") ";
243
+			$where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") ";
244 244
 		}
245 245
 		if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) {
246
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") ";
246
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (".$ivMin.") ";
247 247
 		}
248 248
 		if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) {
249
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") ";
249
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (".$ivMax.") ";
250 250
 		}
251 251
 		$req = "SELECT pokemon_id, lat AS latitude, lon AS longitude,
252 252
     					FROM_UNIXTIME(expire_timestamp) AS disappear_time,
253 253
     					FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
254 254
     					atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina,
255 255
    						move_1, move_2
256
-					FROM sightings " . $where . "
256
+					FROM sightings " . $where."
257 257
 					LIMIT 5000";
258 258
 		$result = $this->mysqli->query($req);
259 259
 		$spawns = array();
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points
344 344
         			FROM forts f
345 345
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
346
-        			WHERE fs.team = '" . $team_id . "'";
346
+        			WHERE fs.team = '" . $team_id."'";
347 347
 		$result = $this->mysqli->query($req);
348 348
 		$data = $result->fetch_object();
349 349
 		return $data;
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	{
450 450
 		$req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name
451 451
 					FROM gym_defenders
452
-					WHERE fort_id = '". $gym_id ."'
452
+					WHERE fort_id = '". $gym_id."'
453 453
 					ORDER BY deployment_time";
454 454
 		$result = $this->mysqli->query($req);
455 455
 		$pokemons = array();
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
 		$req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, FROM_UNIXTIME(fs.last_modified) as last_modified, last_modified as last_modified_real
470 470
 					FROM fort_sightings fs
471 471
 					LEFT JOIN forts f ON f.id = fs.fort_id
472
-					WHERE f.id = '". $gym_id ."'
472
+					WHERE f.id = '". $gym_id."'
473 473
 					ORDER BY fs.last_modified DESC
474
-					LIMIT ".($page * $pageSize).",".($pageSize+1);
474
+					LIMIT ".($page * $pageSize).",".($pageSize + 1);
475 475
 		$result = $this->mysqli->query($req);
476 476
 		$history = array();
477 477
 		$count = 0;
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		$req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
504 504
 					FROM gym_history_defenders ghd
505 505
 					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
506
-					WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."'
506
+					WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."'
507 507
 					ORDER BY gd.deployment_time";
508 508
 		$result = $this->mysqli->query($req);
509 509
 		$pokemons = array();
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 						WHERE fort_id IS NOT NULL
552 552
 				  		GROUP BY owner_name
553 553
 				  	) active ON active.owner_name = gd.owner_name
554
-				  	WHERE gd.owner_level IS NOT NULL " . $where . "
555
-				  	GROUP BY gd.owner_name" . $order  . $limit;
554
+				  	WHERE gd.owner_level IS NOT NULL " . $where."
555
+				  	GROUP BY gd.owner_name" . $order.$limit;
556 556
 		$result = $this->mysqli->query($req);
557 557
 		$trainers = array();
558 558
 		while ($data = $result->fetch_object()) {
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
             }
563 563
 			$trainers[$data->name] = $data;
564 564
 
565
-			$pokemon = array_merge($this->getActivePokemon($data->name),  $this->getInactivePokemon($data->name));
565
+			$pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name));
566 566
 
567 567
 			$trainers[$data->name]->gyms = $data->active;
568 568
 			$trainers[$data->name]->pokemons = $pokemon;
@@ -678,14 +678,14 @@  discard block
 block discarded – undo
678 678
 	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
679 679
 		$pokemon_exclude_sql = "";
680 680
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
681
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
681
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
682 682
 		}
683 683
 		$req = "SELECT p.pokemon_id, MAX(p.lat) AS latitude, MAX(p.lon) AS longitude, count(p.pokemon_id) AS total_pokemon, MAX(s.updated) as latest_seen, coalesce(CASE WHEN MAX(duration) = 0 THEN NULL ELSE MAX(duration) END ,30)*60 as duration
684 684
 			          FROM sightings p
685 685
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
686 686
 			          WHERE p.expire_timestamp > UNIX_TIMESTAMP() - ".($time * 3600)."
687 687
 			            AND p.lat >= ".$minLatitude." AND p.lat < ".$maxLatitude." AND p.lon >= ".$minLongitude." AND p.lon < ".$maxLongitude."
688
-			          " . $pokemon_exclude_sql . "
688
+			          " . $pokemon_exclude_sql."
689 689
 			          GROUP BY p.spawn_id, p.pokemon_id
690 690
 			          HAVING COUNT(p.pokemon_id) >= ".($time / 4)."
691 691
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +84 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql {
3
+class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM sightings";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM forts";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestops";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,26 +73,30 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$data = (object) array("total" => 0);
79 87
 		return $data;
80 88
 	}
81 89
 
82
-	function getTotalGyms() {
90
+	function getTotalGyms()
91
+	{
83 92
 		$req = "SELECT COUNT(*) AS total FROM forts";
84 93
 		$result = $this->mysqli->query($req);
85 94
 		$data = $result->fetch_object();
86 95
 		return $data;
87 96
 	}
88 97
 
89
-	function getTotalRaids() {
98
+	function getTotalRaids()
99
+	{
90 100
 		$req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= UNIX_TIMESTAMP() AND time_end >= UNIX_TIMESTAMP()";
91 101
 		$result = $this->mysqli->query($req);
92 102
 		$data = $result->fetch_object();
@@ -94,7 +104,8 @@  discard block
 block discarded – undo
94 104
 	}
95 105
 
96 106
 
97
-	function getTotalGymsForTeam($team_id) {
107
+	function getTotalGymsForTeam($team_id)
108
+	{
98 109
 		$req = "SELECT COUNT(*) AS total
99 110
 					FROM forts f
100 111
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -104,7 +115,8 @@  discard block
 block discarded – undo
104 115
 		return $data;
105 116
 	}
106 117
 
107
-	function getRecentAll() {
118
+	function getRecentAll()
119
+	{
108 120
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
109 121
               lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
110 122
               FROM sightings
@@ -120,7 +132,8 @@  discard block
 block discarded – undo
120 132
 		return $data;
121 133
 	}
122 134
 
123
-	function getRecentMythic($mythic_pokemon) {
135
+	function getRecentMythic($mythic_pokemon)
136
+	{
124 137
 		$req = "SELECT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
125 138
                 lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
126 139
                 FROM sightings
@@ -141,7 +154,8 @@  discard block
 block discarded – undo
141 154
 	// Single Pokemon
142 155
 	///////////////////
143 156
 
144
-	function getGymsProtectedByPokemon($pokemon_id) {
157
+	function getGymsProtectedByPokemon($pokemon_id)
158
+	{
145 159
 		$req = "SELECT COUNT(f.id) AS total
146 160
 					FROM forts f
147 161
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -151,7 +165,8 @@  discard block
 block discarded – undo
151 165
 		return $data;
152 166
 	}
153 167
 
154
-	function getPokemonLastSeen($pokemon_id) {
168
+	function getPokemonLastSeen($pokemon_id)
169
+	{
155 170
 		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
156 171
                 FROM sightings
157 172
                 WHERE pokemon_id = '".$pokemon_id."'
@@ -162,7 +177,8 @@  discard block
 block discarded – undo
162 177
 		return $data;
163 178
 	}
164 179
 
165
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
180
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
181
+	{
166 182
 		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS distime, pokemon_id as pokemon_id, FROM_UNIXTIME(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
167 183
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
168 184
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form
@@ -179,7 +195,8 @@  discard block
 block discarded – undo
179 195
 		return $top;
180 196
 	}
181 197
 
182
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
198
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
199
+	{
183 200
 		$trainer_blacklist = "";
184 201
 		if (!empty(self::$config->system->trainer_blacklist)) {
185 202
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -200,7 +217,8 @@  discard block
 block discarded – undo
200 217
 		return $toptrainer;
201 218
 	}
202 219
 
203
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
220
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
221
+	{
204 222
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
205 223
 			. "AND FROM_UNIXTIME(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
206 224
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000";
@@ -212,7 +230,8 @@  discard block
 block discarded – undo
212 230
 		return $points;
213 231
 	}
214 232
 
215
-	public function getPokemonGraph($pokemon_id) {
233
+	public function getPokemonGraph($pokemon_id)
234
+	{
216 235
 		$req = "SELECT COUNT(*) AS total, HOUR(disappear_time) AS disappear_hour
217 236
 					FROM (SELECT FROM_UNIXTIME(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
218 237
 				GROUP BY disappear_hour
@@ -228,7 +247,8 @@  discard block
 block discarded – undo
228 247
 		return $array;
229 248
 	}
230 249
 
231
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
250
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
251
+	{
232 252
 		$inmap_pkms_filter = "";
233 253
 		$where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = " . $pokemon_id;
234 254
 
@@ -263,21 +283,24 @@  discard block
 block discarded – undo
263 283
 		return $spawns;
264 284
 	}
265 285
 
266
-	public function getPokemonSliderMinMax() {
286
+	public function getPokemonSliderMinMax()
287
+	{
267 288
 		$req = "SELECT FROM_UNIXTIME(MIN(expire_timestamp)) AS min, FROM_UNIXTIME(MAX(expire_timestamp)) AS max FROM sightings";
268 289
 		$result = $this->mysqli->query($req);
269 290
 		$data = $result->fetch_object();
270 291
 		return $data;
271 292
 	}
272 293
 
273
-	public function getMapsCoords() {
294
+	public function getMapsCoords()
295
+	{
274 296
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
275 297
 		$result = $this->mysqli->query($req);
276 298
 		$data = $result->fetch_object();
277 299
 		return $data;
278 300
 	}
279 301
 
280
-	public function getPokemonCount($pokemon_id) {
302
+	public function getPokemonCount($pokemon_id)
303
+	{
281 304
 		$req = "SELECT count, last_seen, latitude, longitude
282 305
 					FROM pokemon_stats
283 306
 					WHERE pid = ".$pokemon_id;
@@ -286,7 +309,8 @@  discard block
 block discarded – undo
286 309
 		return $data;
287 310
 	}
288 311
 
289
-	public function getRaidCount($pokemon_id) {
312
+	public function getRaidCount($pokemon_id)
313
+	{
290 314
 		$req = "SELECT count, last_seen, latitude, longitude
291 315
 					FROM raid_stats
292 316
 					WHERE pid = ".$pokemon_id;
@@ -302,14 +326,16 @@  discard block
 block discarded – undo
302 326
 	//////////////
303 327
 
304 328
 
305
-	function getTotalPokestops() {
329
+	function getTotalPokestops()
330
+	{
306 331
 		$req = "SELECT COUNT(*) as total FROM pokestops";
307 332
 		$result = $this->mysqli->query($req);
308 333
 		$data = $result->fetch_object();
309 334
 		return $data;
310 335
 	}
311 336
 
312
-	public function getAllPokestops() {
337
+	public function getAllPokestops()
338
+	{
313 339
 		$req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, UNIX_TIMESTAMP() AS now, null AS lure_expiration_real FROM pokestops";
314 340
 		$result = $this->mysqli->query($req);
315 341
 		$pokestops = array();
@@ -324,7 +350,8 @@  discard block
 block discarded – undo
324 350
 	// Gyms
325 351
 	/////////
326 352
 
327
-	function getTeamGuardians($team_id) {
353
+	function getTeamGuardians($team_id)
354
+	{
328 355
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id
329 356
 					FROM forts f
330 357
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -339,7 +366,8 @@  discard block
 block discarded – undo
339 366
 		return $datas;
340 367
 	}
341 368
 
342
-	function getOwnedAndPoints($team_id) {
369
+	function getOwnedAndPoints($team_id)
370
+	{
343 371
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points
344 372
         			FROM forts f
345 373
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -349,7 +377,8 @@  discard block
 block discarded – undo
349 377
 		return $data;
350 378
 	}
351 379
 
352
-	function getAllGyms() {
380
+	function getAllGyms()
381
+	{
353 382
 		$req = "SELECT f.id as gym_id, team as team_id, f.lat as latitude, f.lon as longitude, updated as last_scanned, (6 - fs.slots_available) AS level
354 383
 					FROM forts f
355 384
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id));";
@@ -361,7 +390,8 @@  discard block
 block discarded – undo
361 390
 		return $gyms;
362 391
 	}
363 392
 
364
-	public function getGymData($gym_id) {
393
+	public function getGymData($gym_id)
394
+	{
365 395
 		$req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, FROM_UNIXTIME(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp
366 396
 			FROM forts f
367 397
 			LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -371,7 +401,8 @@  discard block
 block discarded – undo
371 401
 		return $data;
372 402
 	}
373 403
 
374
-	public function getGymDefenders($gym_id) {
404
+	public function getGymDefenders($gym_id)
405
+	{
375 406
 		$req = "SELECT external_id as pokemon_uid, pokemon_id, atk_iv as iv_attack, def_iv as iv_defense, sta_iv as iv_stamina, cp, fort_id as gym_id
376 407
 			FROM gym_defenders
377 408
 			WHERE fort_id='".$gym_id."'
@@ -389,7 +420,8 @@  discard block
 block discarded – undo
389 420
 	// Raids
390 421
 	///////////
391 422
 
392
-	public function getAllRaids($page) {
423
+	public function getAllRaids($page)
424
+	{
393 425
 		$limit = " LIMIT ".($page * 10).",10";
394 426
 		$req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, FROM_UNIXTIME(r.time_spawn) AS spawn, FROM_UNIXTIME(r.time_battle) AS start, FROM_UNIXTIME(r.time_end) AS end, FROM_UNIXTIME(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude
395 427
 					FROM forts f
@@ -519,7 +551,8 @@  discard block
 block discarded – undo
519 551
 	// Trainers
520 552
 	//////////////
521 553
 
522
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
554
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
555
+	{
523 556
 		$ranking = $this->getTrainerLevelRanking();
524 557
 		$where = "";
525 558
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -571,7 +604,8 @@  discard block
 block discarded – undo
571 604
 		return $trainers;
572 605
 	}
573 606
 
574
-	public function getTrainerLevelRanking() {
607
+	public function getTrainerLevelRanking()
608
+	{
575 609
 		$exclue = "";
576 610
 		if (!empty(self::$config->system->trainer_blacklist)) {
577 611
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -592,7 +626,8 @@  discard block
 block discarded – undo
592 626
 		return $levelData;
593 627
 	}
594 628
 
595
-	public function getActivePokemon($trainer_name) {
629
+	public function getActivePokemon($trainer_name)
630
+	{
596 631
 		$req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, FROM_UNIXTIME(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned
597 632
 						FROM gym_defenders
598 633
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -605,7 +640,8 @@  discard block
 block discarded – undo
605 640
 		return $pokemon;
606 641
 	}
607 642
 
608
-	public function getInactivePokemon($trainer_name) {
643
+	public function getInactivePokemon($trainer_name)
644
+	{
609 645
 		$req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, NULL AS deployment_time, '0' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned
610 646
 					FROM gym_defenders
611 647
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -618,7 +654,8 @@  discard block
 block discarded – undo
618 654
 		return $pokemon;
619 655
 	}
620 656
 
621
-	public function getTrainerLevelCount($team_id) {
657
+	public function getTrainerLevelCount($team_id)
658
+	{
622 659
 		$exclue = "";
623 660
 		if (!empty(self::$config->system->trainer_blacklist)) {
624 661
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -644,7 +681,8 @@  discard block
 block discarded – undo
644 681
 	// Cron
645 682
 	/////////
646 683
 
647
-	public function getPokemonCountsActive() {
684
+	public function getPokemonCountsActive()
685
+	{
648 686
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() GROUP BY pokemon_id";
649 687
 		$result = $this->mysqli->query($req);
650 688
 		$counts = array();
@@ -654,7 +692,8 @@  discard block
 block discarded – undo
654 692
 		return $counts;
655 693
 	}
656 694
 
657
-	public function getPokemonCountsLastDay() {
695
+	public function getPokemonCountsLastDay()
696
+	{
658 697
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
659 698
 					FROM sightings
660 699
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -668,14 +707,16 @@  discard block
 block discarded – undo
668 707
 		return $counts;
669 708
 	}
670 709
 
671
-	public function getCaptchaCount() {
710
+	public function getCaptchaCount()
711
+	{
672 712
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
673 713
 		$result = $this->mysqli->query($req);
674 714
 		$data = $result->fetch_object();
675 715
 		return $data;
676 716
 	}
677 717
 
678
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
718
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
719
+	{
679 720
 		$pokemon_exclude_sql = "";
680 721
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
681 722
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
@@ -697,7 +738,8 @@  discard block
 block discarded – undo
697 738
 		return $nests;
698 739
 	}
699 740
 
700
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
741
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
742
+	{
701 743
 		$req = "SELECT COUNT(*) as total 
702 744
 					FROM spawnpoints 
703 745
  					WHERE lat >= ".$minLatitude." AND lat < ".$maxLatitude." AND lon >= ".$minLongitude." AND lon < ".$maxLongitude;
Please login to merge, or discard this patch.
functions.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -216,6 +216,9 @@
 block discarded – undo
216 216
 ########################################################################
217 217
 // used in get_tree_at_depth
218 218
 ########################################################################
219
+/**
220
+ * @param boolean $correct_arrow
221
+ */
219 222
 function tree_check_array($array_check, $array_add, $correct_arrow) {
220 223
 	$count = count($array_check);
221 224
 	$i = 0;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -372,7 +372,7 @@
 block discarded – undo
372 372
 			
373 373
 			$firstElePoly = $polygons[$index][0];
374 374
 			$lastElePoly = $polygons[$index][count($polygons[$index]) - 1];
375
-			if ($firstElePoly == $lastElePoly){
375
+			if ($firstElePoly == $lastElePoly) {
376 376
 				$index++;
377 377
 			}
378 378
 		}
Please login to merge, or discard this patch.
Braces   +33 added lines, -17 removed lines patch added patch discarded remove patch
@@ -181,7 +181,8 @@  discard block
 block discarded – undo
181 181
 //
182 182
 // Retruns max depth of array
183 183
 ########################################################################
184
-function get_depth($arr) {
184
+function get_depth($arr)
185
+{
185 186
 	$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));
186 187
 	$depth = 0;
187 188
 	foreach ($it as $v) {
@@ -199,12 +200,16 @@  discard block
 block discarded – undo
199 200
 //
200 201
 // Return all pokemon with data at a certain tree depth
201 202
 ########################################################################
202
-function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) {
203
-	if ($depth == $currentDepth) { // Found depth
203
+function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0)
204
+{
205
+	if ($depth == $currentDepth) {
206
+// Found depth
204 207
 		return tree_remove_bellow($trees, $max_pokemon);
205
-	} else { // Go deeper
208
+	} else {
209
+// Go deeper
206 210
 		$arr = array();
207
-		foreach ($trees as $temp) { // Go into all trees
211
+		foreach ($trees as $temp) {
212
+// Go into all trees
208 213
 			$tree = $temp->evolutions;
209 214
 			$results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon);
210 215
 			$arr = tree_check_array($results, $arr, $depth - $currentDepth == 1);
@@ -216,12 +221,16 @@  discard block
 block discarded – undo
216 221
 ########################################################################
217 222
 // used in get_tree_at_depth
218 223
 ########################################################################
219
-function tree_check_array($array_check, $array_add, $correct_arrow) {
224
+function tree_check_array($array_check, $array_add, $correct_arrow)
225
+{
220 226
 	$count = count($array_check);
221 227
 	$i = 0;
222
-	if (!is_null($array_check)) { // check if exists
223
-		foreach ($array_check as $res) { // Check if above, equal or bellow center
224
-			if ($count != 1 && $correct_arrow) { // only add arrow once
228
+	if (!is_null($array_check)) {
229
+// check if exists
230
+		foreach ($array_check as $res) {
231
+// Check if above, equal or bellow center
232
+			if ($count != 1 && $correct_arrow) {
233
+// only add arrow once
225 234
 				$num = $i / ($count - 1);
226 235
 				if ($num < 0.5) {
227 236
 					$res->array_sufix = "_up";
@@ -249,7 +258,8 @@  discard block
 block discarded – undo
249 258
 		return null;
250 259
 	}
251 260
 	$arr = array();
252
-	foreach ($tree as $item) { // Check if above, equal or bellow center
261
+	foreach ($tree as $item) {
262
+// Check if above, equal or bellow center
253 263
 		if ($item->id <= $max_pokemon) {
254 264
 			$arr[] = $item;
255 265
 		}
@@ -283,7 +293,8 @@  discard block
 block discarded – undo
283 293
 ########################################################################
284 294
 // check if point is inside porygon
285 295
 ########################################################################
286
-function pointIsInsidePolygon($lat, $lng, $geos, $bounds) {
296
+function pointIsInsidePolygon($lat, $lng, $geos, $bounds)
297
+{
287 298
 	if ($lat >= $bounds["minlat"] && $lat <= $bounds["maxlat"] && $lng >= $bounds["minlon"] && $lng <= $bounds["maxlon"]) {
288 299
 
289 300
 		$intersections = 0;
@@ -292,15 +303,18 @@  discard block
 block discarded – undo
292 303
 		for ($i = 1; $i < $geos_count; $i++) {
293 304
 			$geo1 = $geos[$i - 1];
294 305
 			$geo2 = $geos[$i];
295
-			if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) { // On one of the coords
306
+			if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) {
307
+// On one of the coords
296 308
 				return true;
297 309
 			}
298
-			if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) { // Check if point is on an horizontal polygon boundary
310
+			if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) {
311
+// Check if point is on an horizontal polygon boundary
299 312
 				return true;
300 313
 			}
301 314
 			if ($lng > min($geo1['lng'], $geo2['lng']) and $lng <= max($geo1['lng'], $geo2['lng']) and $lat <= max($geo1['lat'], $geo2['lat']) and $geo1['lng'] != $geo2['lng']) {
302 315
 				$xinters = ($lng - $geo1['lng']) * ($geo2['lat'] - $geo1['lat']) / ($geo2['lng'] - $geo1['lng']) + $geo1['lat'];
303
-				if ($xinters == $lat) { // Check if point is on the polygon boundary (other than horizontal)
316
+				if ($xinters == $lat) {
317
+// Check if point is on the polygon boundary (other than horizontal)
304 318
 					return true;
305 319
 				}
306 320
 				if ($geo1['lat'] == $geo2['lat'] || $lat <= $xinters) {
@@ -322,7 +336,8 @@  discard block
 block discarded – undo
322 336
 ########################################################################
323 337
 // check if $boundsIn is inside (or equal to) $boundsOut
324 338
 ########################################################################
325
-function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut) {
339
+function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut)
340
+{
326 341
 	if ($boundsIn["minlat"] >= $boundsOut["minlat"] && $boundsIn["maxlat"] <= $boundsOut["maxlat"] && $boundsIn["minlon"] >= $boundsOut["minlon"] && $boundsIn["maxlon"] <= $boundsOut["maxlon"]) {
327 342
 		$insideCount = 0;
328 343
 		foreach ($geoIn as $coord) {
@@ -339,7 +354,8 @@  discard block
 block discarded – undo
339 354
 ########################################################################
340 355
 // compine outer ways into porygon
341 356
 ########################################################################
342
-function combineOuter($outers) {
357
+function combineOuter($outers)
358
+{
343 359
 	$polygons = array();
344 360
 	$index = 0;
345 361
 	$count = 0;
@@ -372,7 +388,7 @@  discard block
 block discarded – undo
372 388
 			
373 389
 			$firstElePoly = $polygons[$index][0];
374 390
 			$lastElePoly = $polygons[$index][count($polygons[$index]) - 1];
375
-			if ($firstElePoly == $lastElePoly){
391
+			if ($firstElePoly == $lastElePoly) {
376 392
 				$index++;
377 393
 			}
378 394
 		}
Please login to merge, or discard this patch.
core/cron/crontabs.include.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,8 @@
 block discarded – undo
103 103
 	touch($pokedex_rarity_file);
104 104
 	// update pokedex rarity
105 105
 	include_once(SYS_PATH.'/core/cron/pokedex_rarity.cron.php');
106
-} elseif ( (file_update_ago($nests_parks_file) >= 43200) && (time() - $migration  >= 43200) && (time() - $migration  < 86400) ) { # extra update 12h after migration
106
+} elseif ( (file_update_ago($nests_parks_file) >= 43200) && (time() - $migration  >= 43200) && (time() - $migration  < 86400) ) {
107
+# extra update 12h after migration
107 108
 	if (is_file($nests_parks_file)) {
108 109
 		$prevNestTime = filemtime($nests_parks_file);
109 110
 	} else {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 // Load Query Manager
30 30
 // ###################
31 31
 
32
-include_once __DIR__ . '/../process/queries/QueryManager.php';
32
+include_once __DIR__.'/../process/queries/QueryManager.php';
33 33
 $manager = QueryManager::current();
34 34
 
35 35
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 } while ($migration < new DateTime());
80 80
 $migration = $migrationPrev->getTimestamp();
81 81
 
82
-if ( filemtime($nests_parks_file) - $migration <= 0 ) {
82
+if (filemtime($nests_parks_file) - $migration <= 0) {
83 83
 	file_put_contents($nests_file, json_encode(array()));
84 84
 	file_put_contents($nests_parks_file, json_encode(array()));
85 85
 	touch($nests_parks_file, 1);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	touch($pokedex_rarity_file);
93 93
 	// update pokedex rarity
94 94
 	include_once(SYS_PATH.'/core/cron/pokedex_rarity.cron.php');
95
-} elseif ( (file_update_ago($nests_parks_file) >= 43200) && (time() - $migration  >= 43200) && (time() - $migration  < 86400) ) { # extra update 12h after migration
95
+} elseif ((file_update_ago($nests_parks_file) >= 43200) && (time() - $migration >= 43200) && (time() - $migration < 86400)) { # extra update 12h after migration
96 96
 	if (is_file($nests_parks_file)) {
97 97
 		$prevNestTime = filemtime($nests_parks_file);
98 98
 	} else {
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	touch($nests_parks_file);
105 105
 	// update nests
106 106
 	$nestTime = 12;
107
-	include_once(SYS_PATH . '/core/cron/nests.cron.php');
108
-} elseif ( (file_update_ago($nests_parks_file) >= 86400) && (time() - $migration  >= 86400) ) {
107
+	include_once(SYS_PATH.'/core/cron/nests.cron.php');
108
+} elseif ((file_update_ago($nests_parks_file) >= 86400) && (time() - $migration >= 86400)) {
109 109
 	if (is_file($nests_parks_file)) {
110 110
 		$prevNestTime = filemtime($nests_parks_file);
111 111
 	} else {
@@ -117,5 +117,5 @@  discard block
 block discarded – undo
117 117
 	touch($nests_parks_file);
118 118
 	// update nests
119 119
 	$nestTime = 24;
120
-	include_once(SYS_PATH . '/core/cron/nests.cron.php');
120
+	include_once(SYS_PATH.'/core/cron/nests.cron.php');
121 121
 }
Please login to merge, or discard this patch.
core/cron/nests.cron.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@
 block discarded – undo
25 25
 		$minLongitude = $totalMinLon + $iLng * 0.5;
26 26
 		$maxLongitude = min($minLongitude + 0.5 ,$totalMaxLon);
27 27
 
28
-		if ($manager->getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)->total == 0) { //Skip empty areas
28
+		if ($manager->getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)->total == 0) {
29
+//Skip empty areas
29 30
 			$iLng++;
30 31
 			continue;
31 32
 		}
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		$minLatitude = $totalMinLat + $iLat * 0.5;
24 24
 		$maxLatitude = min($minLatitude + 0.5, $totalMaxLat);
25 25
 		$minLongitude = $totalMinLon + $iLng * 0.5;
26
-		$maxLongitude = min($minLongitude + 0.5 ,$totalMaxLon);
26
+		$maxLongitude = min($minLongitude + 0.5, $totalMaxLon);
27 27
 
28 28
 		if ($manager->getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)->total == 0) { //Skip empty areas
29 29
 			$iLng++;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		}
32 32
 
33 33
 		// Get Parks from overpass
34
-		$req = '[timeout:600][out:json][date:"2017-01-22T00:00:00Z"][bbox:' . $minLatitude . ',' . $minLongitude . ',' . $maxLatitude . ',' . $maxLongitude . '];
34
+		$req = '[timeout:600][out:json][date:"2017-01-22T00:00:00Z"][bbox:'.$minLatitude.','.$minLongitude.','.$maxLatitude.','.$maxLongitude.'];
35 35
 				(
36 36
 					way["leisure"="park"];
37 37
 					way["leisure"="garden"];
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 		$curl = curl_init($endpoint);
90 90
 
91 91
 		curl_setopt($curl, CURLOPT_POST, 1);
92
-		curl_setopt($curl, CURLOPT_POSTFIELDS, "data=" . urlencode($req));
93
-		curl_setopt($curl, CURLOPT_USERAGENT,"Worldopole/NestUpdater ".$config->infos->site_name);
92
+		curl_setopt($curl, CURLOPT_POSTFIELDS, "data=".urlencode($req));
93
+		curl_setopt($curl, CURLOPT_USERAGENT, "Worldopole/NestUpdater ".$config->infos->site_name);
94 94
 		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
95 95
 		curl_setopt($curl, CURLOPT_TIMEOUT, 660);
96 96
 		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 			echo "Got Error 429: Trying again in 5 Minutes...\n";
219 219
 			sleep(300);
220 220
 		} else {
221
-			echo "Error " . $status . " while getting nests from overpass-turbo. Aborting Nest Update.\n";
221
+			echo "Error ".$status." while getting nests from overpass-turbo. Aborting Nest Update.\n";
222 222
 			touch($nests_parks_file, $prevNestTime);
223 223
 			exit();
224 224
 		}
Please login to merge, or discard this patch.
core/process/locales.loader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 // Load Query Manager
4 4
 // ###################
5 5
 
6
-include_once __DIR__ . '/queries/QueryManager.php';
6
+include_once __DIR__.'/queries/QueryManager.php';
7 7
 $manager = QueryManager::current();
8 8
 
9 9
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @return array Sorted list of "accept" options
27 27
  */
28 28
 
29
-$sortAccept = function ($header) {
29
+$sortAccept = function($header) {
30 30
 	$matches = array();
31 31
 	foreach (explode(',', $header) as $option) {
32 32
 		$option = array_map('trim', explode(';', $option));
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return string|NULL a matched option, or NULL if no match
61 61
  */
62
-$matchAccept = function ($header, $supported) use ($sortAccept) {
62
+$matchAccept = function($header, $supported) use ($sortAccept) {
63 63
 	$matches = $sortAccept($header);
64 64
 	foreach ($matches as $key => $q) {
65 65
 		if (isset($supported[$key])) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return string The negotiated language result or the supplied default.
92 92
  */
93
-$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) {
93
+$negotiateLanguage = function($supported, $default = 'en-US') use ($matchAccept) {
94 94
 	$supp = array();
95 95
 	foreach ($supported as $lang => $isSupported) {
96 96
 		if ($isSupported) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
26 26
  * @return array Sorted list of "accept" options
27 27
  */
28 28
 
29
-$sortAccept = function ($header) {
29
+$sortAccept = function ($header)
30
+{
30 31
 	$matches = array();
31 32
 	foreach (explode(',', $header) as $option) {
32 33
 		$option = array_map('trim', explode(';', $option));
@@ -59,7 +60,8 @@  discard block
 block discarded – undo
59 60
  *
60 61
  * @return string|NULL a matched option, or NULL if no match
61 62
  */
62
-$matchAccept = function ($header, $supported) use ($sortAccept) {
63
+$matchAccept = function ($header, $supported) use ($sortAccept)
64
+{
63 65
 	$matches = $sortAccept($header);
64 66
 	foreach ($matches as $key => $q) {
65 67
 		if (isset($supported[$key])) {
@@ -90,7 +92,8 @@  discard block
 block discarded – undo
90 92
  *
91 93
  * @return string The negotiated language result or the supplied default.
92 94
  */
93
-$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) {
95
+$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept)
96
+{
94 97
 	$supp = array();
95 98
 	foreach ($supported as $lang => $isSupported) {
96 99
 		if ($isSupported) {
Please login to merge, or discard this patch.
core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
174 174
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form
175 175
                 FROM sightings
176
-	            WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0'
176
+	            WHERE pokemon_id = '" . $pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0'
177 177
 	            ORDER BY $top_order_by $top_direction, expire_timestamp DESC
178 178
 	            LIMIT 50 OFFSET 0";
179 179
 		$result = pg_query($this->db, $req);
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
188 188
 		$trainer_blacklist = "";
189 189
 		if (!empty(self::$config->system->trainer_blacklist)) {
190
-			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
190
+			$trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
191 191
 		}
192 192
 
193 193
 		$req = "SELECT owner_name as trainer_name, ROUND((100.0*((atk_iv)+(def_iv)+(sta_iv))/45),1) AS \"IV\", move_1, move_2, cp as cp,
194 194
                 TO_TIMESTAMP(last_modified) AS lasttime, last_modified as last_seen
195 195
                 FROM gym_defenders
196
-				WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . "
196
+				WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist."
197 197
 				ORDER BY $best_order_by $best_direction, owner_name ASC
198 198
 				LIMIT 50 OFFSET 0";
199 199
 
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 
236 236
 	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
237 237
 		$inmap_pkms_filter = "";
238
-		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
238
+		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = ".$pokemon_id;
239 239
 
240
-		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where;
240
+		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings ".$where;
241 241
 		$resultTestIv = pg_query($this->db, $reqTestIv);
242 242
 		$testIv = pg_fetch_object($resultTestIv);
243 243
 		if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) {
@@ -245,20 +245,20 @@  discard block
 block discarded – undo
245 245
 				$inmap_pkms_filter .= "'".$inmap."',";
246 246
 			}
247 247
 			$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
248
-			$where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") ";
248
+			$where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") ";
249 249
 		}
250 250
 		if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) {
251
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") ";
251
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (".$ivMin.") ";
252 252
 		}
253 253
 		if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) {
254
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") ";
254
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (".$ivMax.") ";
255 255
 		}
256 256
 		$req = "SELECT pokemon_id, lat AS latitude, lon AS longitude,
257 257
     					TO_TIMESTAMP(expire_timestamp) AS disappear_time,
258 258
     					TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
259 259
     					atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina,
260 260
    						move_1, move_2
261
-					FROM sightings " . $where . "
261
+					FROM sightings " . $where."
262 262
 					LIMIT 5000";
263 263
 		$result = pg_query($this->db, $req);
264 264
 		$spawns = array();
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
348 348
         			FROM forts f
349 349
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
350
-        			WHERE fs.team = '" . $team_id . "'";
350
+        			WHERE fs.team = '" . $team_id."'";
351 351
 		$result = pg_query($this->db, $req);
352 352
 		$data = pg_fetch_object($result);
353 353
 		return $data;
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	{
435 435
 		$req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name
436 436
 					FROM gym_defenders
437
-					WHERE fort_id = '". $gym_id ."'
437
+					WHERE fort_id = '". $gym_id."'
438 438
 					ORDER BY deployment_time";
439 439
 		$result = $this->mysqli->query($req);
440 440
 		$pokemons = array();
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
 		$req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, TO_TIMESTAMP(fs.last_modified) as last_modified, last_modified as last_modified_real
455 455
 					FROM fort_sightings fs
456 456
 					LEFT JOIN forts f ON f.id = fs.fort_id
457
-					WHERE f.id = '". $gym_id ."'
457
+					WHERE f.id = '". $gym_id."'
458 458
 					ORDER BY fs.last_modified DESC
459
-					LIMIT ".($pageSize+1)." OFFSET ".($page * $pageSize);
459
+					LIMIT ".($pageSize + 1)." OFFSET ".($page * $pageSize);
460 460
 		$result = $this->mysqli->query($req);
461 461
 		$history = array();
462 462
 		$count = 0;
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		$req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
489 489
 					FROM gym_history_defenders ghd
490 490
 					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
491
-					WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."'
491
+					WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."'
492 492
 					ORDER BY gd.deployment_time";
493 493
 		$result = $this->mysqli->query($req);
494 494
 		$pokemons = array();
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 	///////////
504 504
 
505 505
 	public function getAllRaids($page) {
506
-		$limit = " LIMIT 10 OFFSET ". ($page * 10);
506
+		$limit = " LIMIT 10 OFFSET ".($page * 10);
507 507
 		$req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude
508 508
 					FROM forts f
509 509
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 						WHERE fort_id IS NOT NULL
556 556
 				  		GROUP BY owner_name
557 557
 				  	) active ON active.owner_name = gd.owner_name
558
-				  	WHERE level IS NOT NULL " . $where . "
559
-				  	GROUP BY gd.owner_name" . $order  . $limit;
558
+				  	WHERE level IS NOT NULL " . $where."
559
+				  	GROUP BY gd.owner_name" . $order.$limit;
560 560
 		$result = $this->mysqli->query($req);
561 561
 		$trainers = array();
562 562
 		while ($data = $result->fetch_object()) {
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 			}
567 567
 			$trainers[$data->name] = $data;
568 568
 
569
-			$pokemon = array_merge($this->getActivePokemon($data->name),  $this->getInactivePokemon($data->name));
569
+			$pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name));
570 570
 
571 571
 			$trainers[$data->name]->gyms = $data->active;
572 572
 			$trainers[$data->name]->pokemons = $pokemon;
@@ -683,14 +683,14 @@  discard block
 block discarded – undo
683 683
 	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
684 684
 		$pokemon_exclude_sql = "";
685 685
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
686
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
686
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
687 687
 		}
688 688
 		$req = "SELECT p.spawn_id, p.pokemon_id, MAX(p.lat) AS latitude, MAX(p.lon) AS longitude, count(p.pokemon_id) AS total_pokemon, MAX(s.updated) as latest_seen, coalesce(CASE WHEN MAX(duration) = 0 THEN NULL ELSE MAX(duration) END ,30)*60 as duration
689 689
 			          FROM sightings p
690 690
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
691 691
 			          WHERE p.expire_timestamp > EXTRACT(EPOCH FROM NOW()) - ".($time * 3600)."
692 692
 			            AND p.lat >= ".$minLatitude." AND p.lat < ".$maxLatitude." AND p.lon >= ".$minLongitude." AND p.lon < ".$maxLongitude."
693
-			          " . $pokemon_exclude_sql . "
693
+			          " . $pokemon_exclude_sql."
694 694
 			          GROUP BY p.spawn_id, p.pokemon_id
695 695
 			          HAVING COUNT(p.pokemon_id) >= ".($time / 4)."
696 696
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +84 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,13 +6,16 @@  discard block
 block discarded – undo
6 6
  * Time: 02:26
7 7
  */
8 8
 
9
-class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql {
9
+class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql
10
+{
10 11
 
11
-	public function __construct() {
12
+	public function __construct()
13
+	{
12 14
 		parent::__construct();
13 15
 	}
14 16
 
15
-	public function __destruct() {
17
+	public function __destruct()
18
+	{
16 19
 		parent::__destruct();
17 20
 	}
18 21
 
@@ -20,7 +23,8 @@  discard block
 block discarded – undo
20 23
 	// Tester
21 24
 	///////////
22 25
 
23
-	function testTotalPokemon() {
26
+	function testTotalPokemon()
27
+	{
24 28
 		$req = "SELECT COUNT(*) as total FROM sightings";
25 29
 		$result = pg_query($this->db, $req);
26 30
 		if ($result === false) {
@@ -36,7 +40,8 @@  discard block
 block discarded – undo
36 40
 		return 0;
37 41
 	}
38 42
 
39
-	function testTotalGyms() {
43
+	function testTotalGyms()
44
+	{
40 45
 		$req = "SELECT COUNT(*) as total FROM forts";
41 46
 		$result = pg_query($this->db, $req);
42 47
 		if ($result === false) {
@@ -52,7 +57,8 @@  discard block
 block discarded – undo
52 57
 		return 0;
53 58
 	}
54 59
 
55
-	function testTotalPokestops() {
60
+	function testTotalPokestops()
61
+	{
56 62
 		$req = "SELECT COUNT(*) as total FROM pokestops";
57 63
 		$result = pg_query($this->db, $req);
58 64
 		if ($result === false) {
@@ -73,26 +79,30 @@  discard block
 block discarded – undo
73 79
 	// Homepage
74 80
 	/////////////
75 81
 
76
-	function getTotalPokemon() {
82
+	function getTotalPokemon()
83
+	{
77 84
 		$req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW())";
78 85
 		$result = pg_query($this->db, $req);
79 86
 		$data = pg_fetch_object($result);
80 87
 		return $data;
81 88
 	}
82 89
 
83
-	function getTotalLures() {
90
+	function getTotalLures()
91
+	{
84 92
 		$data = (object) array("total" => 0);
85 93
 		return $data;
86 94
 	}
87 95
 
88
-	function getTotalGyms() {
96
+	function getTotalGyms()
97
+	{
89 98
 		$req = "SELECT COUNT(*) AS total FROM forts";
90 99
 		$result = pg_query($this->db, $req);
91 100
 		$data = pg_fetch_object($result);
92 101
 		return $data;
93 102
 	}
94 103
 
95
-	function getTotalRaids() {
104
+	function getTotalRaids()
105
+	{
96 106
 		$req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= EXTRACT(EPOCH FROM NOW()) AND time_end >= EXTRACT(EPOCH FROM NOW())";
97 107
 		$result = pg_query($this->db, $req);
98 108
 		$data = pg_fetch_object($result);
@@ -100,7 +110,8 @@  discard block
 block discarded – undo
100 110
 	}
101 111
 
102 112
 
103
-	function getTotalGymsForTeam($team_id) {
113
+	function getTotalGymsForTeam($team_id)
114
+	{
104 115
 		$req = "SELECT COUNT(*) AS total
105 116
 					FROM forts f
106 117
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -110,7 +121,8 @@  discard block
 block discarded – undo
110 121
 		return $data;
111 122
 	}
112 123
 
113
-	function getRecentAll() {
124
+	function getRecentAll()
125
+	{
114 126
 		$req = "SELECT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
115 127
               lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
116 128
               FROM sightings
@@ -126,7 +138,8 @@  discard block
 block discarded – undo
126 138
 		return $data;
127 139
 	}
128 140
 
129
-	function getRecentMythic($mythic_pokemon) {
141
+	function getRecentMythic($mythic_pokemon)
142
+	{
130 143
 		$req = "SELECT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
131 144
                 lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
132 145
                 FROM sightings
@@ -147,7 +160,8 @@  discard block
 block discarded – undo
147 160
 	// Single Pokemon
148 161
 	///////////////////
149 162
 
150
-	function getGymsProtectedByPokemon($pokemon_id) {
163
+	function getGymsProtectedByPokemon($pokemon_id)
164
+	{
151 165
 		$req = "SELECT COUNT(f.id) AS total
152 166
 					FROM forts f
153 167
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -157,7 +171,8 @@  discard block
 block discarded – undo
157 171
 		return $data;
158 172
 	}
159 173
 
160
-	function getPokemonLastSeen($pokemon_id) {
174
+	function getPokemonLastSeen($pokemon_id)
175
+	{
161 176
 		$req = "SELECT TO_TIMESTAMP(expire_timestamp) AS expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
162 177
                 FROM sightings
163 178
                 WHERE pokemon_id = '".$pokemon_id."'
@@ -168,7 +183,8 @@  discard block
 block discarded – undo
168 183
 		return $data;
169 184
 	}
170 185
 
171
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
186
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
187
+	{
172 188
 		$req = "SELECT expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS distime, pokemon_id as pokemon_id, TO_TIMESTAMP(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
173 189
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
174 190
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form
@@ -184,7 +200,8 @@  discard block
 block discarded – undo
184 200
 		return $top;
185 201
 	}
186 202
 
187
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
203
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
204
+	{
188 205
 		$trainer_blacklist = "";
189 206
 		if (!empty(self::$config->system->trainer_blacklist)) {
190 207
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -205,7 +222,8 @@  discard block
 block discarded – undo
205 222
 		return $toptrainer;
206 223
 	}
207 224
 
208
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
225
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
226
+	{
209 227
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
210 228
 			. "AND TO_TIMESTAMP(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
211 229
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000";
@@ -217,7 +235,8 @@  discard block
 block discarded – undo
217 235
 		return $points;
218 236
 	}
219 237
 
220
-	public function getPokemonGraph($pokemon_id) {
238
+	public function getPokemonGraph($pokemon_id)
239
+	{
221 240
 		$req = "SELECT COUNT(*) AS total, EXTRACT(HOUR FROM disappear_time) AS disappear_hour
222 241
 					FROM (SELECT TO_TIMESTAMP(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
223 242
 				GROUP BY disappear_hour
@@ -233,7 +252,8 @@  discard block
 block discarded – undo
233 252
 		return $array;
234 253
 	}
235 254
 
236
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
255
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
256
+	{
237 257
 		$inmap_pkms_filter = "";
238 258
 		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
239 259
 
@@ -268,21 +288,24 @@  discard block
 block discarded – undo
268 288
 		return $spawns;
269 289
 	}
270 290
 
271
-	public function getPokemonSliderMinMax() {
291
+	public function getPokemonSliderMinMax()
292
+	{
272 293
 		$req = "SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings";
273 294
 		$result = pg_query($this->db, $req);
274 295
 		$data = pg_fetch_object($result);
275 296
 		return $data;
276 297
 	}
277 298
 
278
-	public function getMapsCoords() {
299
+	public function getMapsCoords()
300
+	{
279 301
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
280 302
 		$result = pg_query($this->db, $req);
281 303
 		$data = pg_fetch_object($result);
282 304
 		return $data;
283 305
 	}
284 306
 
285
-	public function getPokemonCount($pokemon_id) {
307
+	public function getPokemonCount($pokemon_id)
308
+	{
286 309
 		$req = "SELECT count, last_seen, latitude, longitude
287 310
 					FROM pokemon_stats
288 311
 					WHERE pid = ".$pokemon_id;
@@ -291,7 +314,8 @@  discard block
 block discarded – undo
291 314
 		return $data;
292 315
 	}
293 316
 
294
-	public function getRaidCount($pokemon_id) {
317
+	public function getRaidCount($pokemon_id)
318
+	{
295 319
 		$req = "SELECT count, last_seen, latitude, longitude
296 320
 					FROM raid_stats
297 321
 					WHERE pid = ".$pokemon_id;
@@ -306,14 +330,16 @@  discard block
 block discarded – undo
306 330
 	//////////////
307 331
 
308 332
 
309
-	function getTotalPokestops() {
333
+	function getTotalPokestops()
334
+	{
310 335
 		$req = "SELECT COUNT(*) as total FROM pokestops";
311 336
 		$result = pg_query($this->db, $req);
312 337
 		$data = pg_fetch_object($result);
313 338
 		return $data;
314 339
 	}
315 340
 
316
-	public function getAllPokestops() {
341
+	public function getAllPokestops()
342
+	{
317 343
 		$req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, EXTRACT(EPOCH FROM NOW()) AS now, null AS lure_expiration_real FROM pokestops";
318 344
 		$result = pg_query($this->db, $req);
319 345
 		$pokestops = array();
@@ -328,7 +354,8 @@  discard block
 block discarded – undo
328 354
 	// Gyms
329 355
 	/////////
330 356
 
331
-	function getTeamGuardians($team_id) {
357
+	function getTeamGuardians($team_id)
358
+	{
332 359
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id
333 360
 					FROM forts f
334 361
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -343,7 +370,8 @@  discard block
 block discarded – undo
343 370
 		return $datas;
344 371
 	}
345 372
 
346
-	function getOwnedAndPoints($team_id) {
373
+	function getOwnedAndPoints($team_id)
374
+	{
347 375
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
348 376
         			FROM forts f
349 377
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -353,7 +381,8 @@  discard block
 block discarded – undo
353 381
 		return $data;
354 382
 	}
355 383
 
356
-	function getAllGyms() {
384
+	function getAllGyms()
385
+	{
357 386
 		$req = "SELECT f.id as gym_id, team as team_id, f.lat as latitude, f.lon as longitude, updated as last_scanned, (6 - fs.slots_available) AS level
358 387
 					FROM forts f
359 388
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))";
@@ -365,7 +394,8 @@  discard block
 block discarded – undo
365 394
 		return $gyms;
366 395
 	}
367 396
 
368
-	public function getGymData($gym_id) {
397
+	public function getGymData($gym_id)
398
+	{
369 399
 		$req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, TO_TIMESTAMP(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp
370 400
 			FROM forts f
371 401
 			LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -376,7 +406,8 @@  discard block
 block discarded – undo
376 406
 		return $data;
377 407
 	}
378 408
 
379
-	public function getGymDefenders($gym_id) {
409
+	public function getGymDefenders($gym_id)
410
+	{
380 411
 		$req = "SELECT external_id as pokemon_uid, pokemon_id, atk_iv as iv_attack, def_iv as iv_defense, sta_iv as iv_stamina, cp, fort_id as gym_id
381 412
 			FROM gym_defenders
382 413
 			WHERE fort_id='".$gym_id."'
@@ -502,7 +533,8 @@  discard block
 block discarded – undo
502 533
 	// Raids
503 534
 	///////////
504 535
 
505
-	public function getAllRaids($page) {
536
+	public function getAllRaids($page)
537
+	{
506 538
 		$limit = " LIMIT 10 OFFSET ". ($page * 10);
507 539
 		$req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude
508 540
 					FROM forts f
@@ -523,7 +555,8 @@  discard block
 block discarded – undo
523 555
 	// Trainers
524 556
 	//////////////
525 557
 
526
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
558
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
559
+	{
527 560
 		$ranking = $this->getTrainerLevelRanking();
528 561
 		$where = "";
529 562
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -575,7 +608,8 @@  discard block
 block discarded – undo
575 608
 		return $trainers;
576 609
 	}
577 610
 
578
-	public function getTrainerLevelRanking() {
611
+	public function getTrainerLevelRanking()
612
+	{
579 613
 		$exclue = "";
580 614
 		if (!empty(self::$config->system->trainer_blacklist)) {
581 615
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -596,7 +630,8 @@  discard block
 block discarded – undo
596 630
 		return $levelData;
597 631
 	}
598 632
 
599
-	public function getActivePokemon($trainer_name) {
633
+	public function getActivePokemon($trainer_name)
634
+	{
600 635
 		$req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, TO_TIMESTAMP(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned
601 636
 						FROM gym_defenders
602 637
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -609,7 +644,8 @@  discard block
 block discarded – undo
609 644
 		return $pokemon;
610 645
 	}
611 646
 
612
-	public function getInactivePokemon($trainer_name) {
647
+	public function getInactivePokemon($trainer_name)
648
+	{
613 649
 		$req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, NULL AS deployment_time, '0' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned
614 650
 					FROM gym_defenders
615 651
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -622,7 +658,8 @@  discard block
 block discarded – undo
622 658
 		return $pokemon;
623 659
 	}
624 660
 
625
-	public function getTrainerLevelCount($team_id) {
661
+	public function getTrainerLevelCount($team_id)
662
+	{
626 663
 		$exclue = "";
627 664
 		if (!empty(self::$config->system->trainer_blacklist)) {
628 665
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -648,7 +685,8 @@  discard block
 block discarded – undo
648 685
 	// Cron
649 686
 	/////////
650 687
 
651
-	public function getPokemonCountsActive() {
688
+	public function getPokemonCountsActive()
689
+	{
652 690
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) GROUP BY pokemon_id";
653 691
 		$result = pg_query($this->db, $req);
654 692
 		$counts = array();
@@ -658,7 +696,8 @@  discard block
 block discarded – undo
658 696
 		return $counts;
659 697
 	}
660 698
 
661
-	public function getPokemonCountsLastDay() {
699
+	public function getPokemonCountsLastDay()
700
+	{
662 701
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
663 702
 					FROM sightings
664 703
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -673,14 +712,16 @@  discard block
 block discarded – undo
673 712
 	}
674 713
 
675 714
 
676
-	public function getCaptchaCount() {
715
+	public function getCaptchaCount()
716
+	{
677 717
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
678 718
 		$result = pg_query($this->db, $req);
679 719
 		$data = pg_fetch_object($result);
680 720
 		return $data;
681 721
 	}
682 722
 
683
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
723
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
724
+	{
684 725
 		$pokemon_exclude_sql = "";
685 726
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
686 727
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
@@ -702,7 +743,8 @@  discard block
 block discarded – undo
702 743
 		return $nests;
703 744
 	}
704 745
 
705
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
746
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
747
+	{
706 748
 		$req = "SELECT COUNT(*) as total 
707 749
 					FROM spawnpoints 
708 750
  					WHERE lat >= ".$minLatitude." AND lat < ".$maxLatitude." AND lon >= ".$minLongitude." AND lon < ".$maxLongitude;
Please login to merge, or discard this patch.
core/process/queries/QueryManagerMysqlRocketmap.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	/////////
319 319
 
320 320
 	function getTeamGuardians($team_id) {
321
-		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id ."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
321
+		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
322 322
 		$result = $this->mysqli->query($req);
323 323
 		$datas = array();
324 324
 		while ($data = $result->fetch_object()) {
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 
397 397
 		$limit = " LIMIT ".($page * 10).",10";
398 398
 
399
-		$req = "SELECT gymdetails.gym_id, name, team_id, total_cp, (6 - slots_available) as pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '" . self::$time_offset . "')) as last_modified
399
+		$req = "SELECT gymdetails.gym_id, name, team_id, total_cp, (6 - slots_available) as pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '".self::$time_offset."')) as last_modified
400 400
 				FROM gymdetails
401 401
 				LEFT JOIN gym
402 402
 				ON gymdetails.gym_id = gym.gym_id
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 					FROM gymmember
416 416
 					LEFT JOIN gympokemon
417 417
 					ON gymmember.pokemon_uid = gympokemon.pokemon_uid
418
-					WHERE gymmember.gym_id = '". $gym_id ."'
418
+					WHERE gymmember.gym_id = '". $gym_id."'
419 419
 					ORDER BY deployment_time";
420 420
 		$result = $this->mysqli->query($req);
421 421
 		$pokemons = array();
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 					FROM gymhistory
436 436
 					WHERE gym_id='".$gym_id."'
437 437
 					ORDER BY last_modified DESC
438
-					LIMIT ".($page * $pageSize).",".($pageSize+1);
438
+					LIMIT ".($page * $pageSize).",".($pageSize + 1);
439 439
 		$result = $this->mysqli->query($req);
440 440
 		$history = array();
441 441
 		$count = 0;
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 				FROM gympokemon
576 576
 				INNER JOIN (SELECT gymmember.pokemon_uid, gymmember.gym_id FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember
577 577
 				ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid) AS actives_pokemons ON actives_pokemons.trainer_name = trainer.name
578
-				GROUP BY trainer.name " . $where . $order . $limit;
578
+				GROUP BY trainer.name " . $where.$order.$limit;
579 579
 
580 580
 		$result = $this->mysqli->query($req);
581 581
 		$trainers = array();
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 		return $data;
597 597
 	}
598 598
 
599
-	private function getTrainerActivePokemon($trainer_name){
599
+	private function getTrainerActivePokemon($trainer_name) {
600 600
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, filtered_gymmember.gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '1' AS active
601 601
 					FROM gympokemon INNER JOIN
602 602
 					(SELECT gymmember.pokemon_uid, gymmember.gym_id, gymmember.deployment_time FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.deployment_time, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 		return $pokemons;
612 612
 	}
613 613
 
614
-	private function getTrainerInactivePokemon($trainer_name){
614
+	private function getTrainerInactivePokemon($trainer_name) {
615 615
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, null AS gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '0' AS active
616 616
 					FROM gympokemon LEFT JOIN
617 617
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 			          INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id) 
673 673
 			          WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL ".($time)." HOUR 
674 674
 			            AND p.latitude >= ".$minLatitude." AND p.latitude < ".$maxLatitude." AND p.longitude >= ".$minLongitude." AND p.longitude < ".$maxLongitude."
675
-			          " . $pokemon_exclude_sql . " 
675
+			          " . $pokemon_exclude_sql." 
676 676
 			          GROUP BY p.spawnpoint_id, p.pokemon_id 
677 677
 			          HAVING COUNT(p.pokemon_id) >= ".($time / 4)." 
678 678
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +94 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-final class QueryManagerMysqlRocketmap extends QueryManagerMysql {
3
+final class QueryManagerMysqlRocketmap extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM pokemon";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM gym";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestop";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,42 +73,48 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
79 87
 		$result = $this->mysqli->query($req);
80 88
 		$data = $result->fetch_object();
81 89
 		return $data;
82 90
 	}
83 91
 
84
-	function getTotalGyms() {
92
+	function getTotalGyms()
93
+	{
85 94
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
86 95
 		$result = $this->mysqli->query($req);
87 96
 		$data = $result->fetch_object();
88 97
 		return $data;
89 98
 	}
90 99
 
91
-	function getTotalRaids() {
100
+	function getTotalRaids()
101
+	{
92 102
 		$req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND  end >= UTC_TIMESTAMP()";
93 103
 		$result = $this->mysqli->query($req);
94 104
 		$data = $result->fetch_object();
95 105
 		return $data;
96 106
 	}
97 107
 
98
-	function getTotalGymsForTeam($team_id) {
108
+	function getTotalGymsForTeam($team_id)
109
+	{
99 110
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '".$team_id."'";
100 111
 		$result = $this->mysqli->query($req);
101 112
 		$data = $result->fetch_object();
102 113
 		return $data;
103 114
 	}
104 115
 
105
-	function getRecentAll() {
116
+	function getRecentAll()
117
+	{
106 118
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
107 119
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
108 120
 					FROM pokemon
@@ -118,7 +130,8 @@  discard block
 block discarded – undo
118 130
 		return $data;
119 131
 	}
120 132
 
121
-	function getRecentMythic($mythic_pokemons) {
133
+	function getRecentMythic($mythic_pokemons)
134
+	{
122 135
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
123 136
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
124 137
 					FROM pokemon
@@ -139,14 +152,16 @@  discard block
 block discarded – undo
139 152
 	// Single Pokemon
140 153
 	///////////////////
141 154
 
142
-	function getGymsProtectedByPokemon($pokemon_id) {
155
+	function getGymsProtectedByPokemon($pokemon_id)
156
+	{
143 157
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'";
144 158
 		$result = $this->mysqli->query($req);
145 159
 		$data = $result->fetch_object();
146 160
 		return $data;
147 161
 	}
148 162
 
149
-	function getPokemonLastSeen($pokemon_id) {
163
+	function getPokemonLastSeen($pokemon_id)
164
+	{
150 165
 		$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude
151 166
 							FROM pokemon
152 167
 							WHERE pokemon_id = '".$pokemon_id."'
@@ -157,7 +172,8 @@  discard block
 block discarded – undo
157 172
 		return $data;
158 173
 	}
159 174
 
160
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
175
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
176
+	{
161 177
 		$req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude,
162 178
 							cp, individual_attack, individual_defense, individual_stamina,
163 179
 							ROUND(100*(individual_attack+individual_defense+individual_stamina)/45,1) AS IV, move_1, move_2, form
@@ -174,7 +190,8 @@  discard block
 block discarded – undo
174 190
 		return $top;
175 191
 	}
176 192
 
177
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
193
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
194
+	{
178 195
 		$trainer_blacklist = "";
179 196
 		if (!empty(self::$config->system->trainer_blacklist)) {
180 197
 			$trainer_blacklist = " AND trainer_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -195,7 +212,8 @@  discard block
 block discarded – undo
195 212
 		return $toptrainer;
196 213
 	}
197 214
 
198
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
215
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
216
+	{
199 217
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
200 218
 			. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
201 219
 		$req 		= "SELECT latitude, longitude FROM pokemon".$where." LIMIT 10000";
@@ -207,7 +225,8 @@  discard block
 block discarded – undo
207 225
 		return $points;
208 226
 	}
209 227
 
210
-	public function getPokemonGraph($pokemon_id) {
228
+	public function getPokemonGraph($pokemon_id)
229
+	{
211 230
 		$req = "SELECT COUNT(*) AS total,
212 231
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_hour
213 232
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
@@ -224,7 +243,8 @@  discard block
 block discarded – undo
224 243
 		return $array;
225 244
 	}
226 245
 
227
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
246
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
247
+	{
228 248
 		$inmap_pkms_filter = "";
229 249
 		$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id;
230 250
 
@@ -257,21 +277,24 @@  discard block
 block discarded – undo
257 277
 		return $spawns;
258 278
 	}
259 279
 
260
-	public function getPokemonSliderMinMax() {
280
+	public function getPokemonSliderMinMax()
281
+	{
261 282
 		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
262 283
 		$result = $this->mysqli->query($req);
263 284
 		$data = $result->fetch_object();
264 285
 		return $data;
265 286
 	}
266 287
 
267
-	public function getMapsCoords() {
288
+	public function getMapsCoords()
289
+	{
268 290
 		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
269 291
 		$result = $this->mysqli->query($req);
270 292
 		$data = $result->fetch_object();
271 293
 		return $data;
272 294
 	}
273 295
 
274
-	public function getPokemonCount($pokemon_id) {
296
+	public function getPokemonCount($pokemon_id)
297
+	{
275 298
 		$req = "SELECT count, last_seen, latitude, longitude
276 299
 					FROM pokemon_stats
277 300
 					WHERE pid = ".$pokemon_id;
@@ -280,7 +303,8 @@  discard block
 block discarded – undo
280 303
 		return $data;
281 304
 	}
282 305
 
283
-	public function getRaidCount($pokemon_id) {
306
+	public function getRaidCount($pokemon_id)
307
+	{
284 308
 		$req = "SELECT count, last_seen, latitude, longitude
285 309
 					FROM raid_stats
286 310
 					WHERE pid = ".$pokemon_id;
@@ -295,14 +319,16 @@  discard block
 block discarded – undo
295 319
 	// Pokestops
296 320
 	//////////////
297 321
 
298
-	function getTotalPokestops() {
322
+	function getTotalPokestops()
323
+	{
299 324
 		$req = "SELECT COUNT(*) as total FROM pokestop";
300 325
 		$result = $this->mysqli->query($req);
301 326
 		$data = $result->fetch_object();
302 327
 		return $data;
303 328
 	}
304 329
 
305
-	public function getAllPokestops() {
330
+	public function getAllPokestops()
331
+	{
306 332
 		$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".self::$time_offset."')) AS lure_expiration_real FROM pokestop";
307 333
 		$result = $this->mysqli->query($req);
308 334
 		$pokestops = array();
@@ -317,7 +343,8 @@  discard block
 block discarded – undo
317 343
 	// Gyms
318 344
 	/////////
319 345
 
320
-	function getTeamGuardians($team_id) {
346
+	function getTeamGuardians($team_id)
347
+	{
321 348
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id ."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
322 349
 		$result = $this->mysqli->query($req);
323 350
 		$datas = array();
@@ -327,14 +354,16 @@  discard block
 block discarded – undo
327 354
 		return $datas;
328 355
 	}
329 356
 
330
-	function getOwnedAndPoints($team_id) {
357
+	function getOwnedAndPoints($team_id)
358
+	{
331 359
 		$req 	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
332 360
 		$result = $this->mysqli->query($req);
333 361
 		$data = $result->fetch_object();
334 362
 		return $data;
335 363
 	}
336 364
 
337
-	function getAllGyms() {
365
+	function getAllGyms()
366
+	{
338 367
 		$req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".self::$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym";
339 368
 		$result = $this->mysqli->query($req);
340 369
 		$gyms = array();
@@ -344,7 +373,8 @@  discard block
 block discarded – undo
344 373
 		return $gyms;
345 374
 	}
346 375
 
347
-	public function getGymData($gym_id) {
376
+	public function getGymData($gym_id)
377
+	{
348 378
 		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
349 379
 					(CONVERT_TZ(gym.last_scanned, '+00:00', '".self::$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
350 380
 					FROM gymdetails
@@ -355,7 +385,8 @@  discard block
 block discarded – undo
355 385
 		return $data;
356 386
 	}
357 387
 
358
-	public function getGymDefenders($gym_id) {
388
+	public function getGymDefenders($gym_id)
389
+	{
359 390
 		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
360 391
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
361 392
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
@@ -375,7 +406,8 @@  discard block
 block discarded – undo
375 406
 	// Gym History
376 407
 	////////////////
377 408
 
378
-	public function getGymHistories($gym_name, $team, $page, $ranking) {
409
+	public function getGymHistories($gym_name, $team, $page, $ranking)
410
+	{
379 411
 		$where = '';
380 412
 		if (isset($gym_name) && $gym_name != '') {
381 413
 			$where = " WHERE name LIKE '%".$gym_name."%'";
@@ -410,7 +442,8 @@  discard block
 block discarded – undo
410 442
 		return $gym_history;
411 443
 	}
412 444
 
413
-	public function getGymHistoriesPokemon($gym_id) {
445
+	public function getGymHistoriesPokemon($gym_id)
446
+	{
414 447
 		$req = "SELECT DISTINCT gymmember.pokemon_uid, pokemon_id, cp, trainer_name
415 448
 					FROM gymmember
416 449
 					LEFT JOIN gympokemon
@@ -425,7 +458,8 @@  discard block
 block discarded – undo
425 458
 		return $pokemons;
426 459
 	}
427 460
 
428
-	public function getHistoryForGym($page, $gym_id) {
461
+	public function getHistoryForGym($page, $gym_id)
462
+	{
429 463
 		if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) {
430 464
 			$pageSize = 25;
431 465
 		} else {
@@ -461,7 +495,8 @@  discard block
 block discarded – undo
461 495
 		return array("last_page" => $last_page, "data" => $history);
462 496
 	}
463 497
 
464
-	private function getHistoryForGymPokemon($pkm_uids) {
498
+	private function getHistoryForGymPokemon($pkm_uids)
499
+	{
465 500
 		$req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name
466 501
 								FROM gympokemon
467 502
 								WHERE pokemon_uid IN ('".implode("','", $pkm_uids)."')
@@ -479,7 +514,8 @@  discard block
 block discarded – undo
479 514
 	// Raids
480 515
 	///////////
481 516
 
482
-	public function getAllRaids($page) {
517
+	public function getAllRaids($page)
518
+	{
483 519
 		$limit = " LIMIT ".($page * 10).",10";
484 520
 		$req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".self::$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".self::$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".self::$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".self::$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid
485 521
 					JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
@@ -499,7 +535,8 @@  discard block
 block discarded – undo
499 535
 	// Trainers
500 536
 	//////////////
501 537
 
502
-	public function getTrainers($trainer_name, $team, $page, $ranking) {
538
+	public function getTrainers($trainer_name, $team, $page, $ranking)
539
+	{
503 540
 		$trainers = $this->getTrainerData($trainer_name, $team, $page, $ranking);
504 541
 		foreach ($trainers as $trainer) {
505 542
 
@@ -524,7 +561,8 @@  discard block
 block discarded – undo
524 561
 		return $trainers;
525 562
 	}
526 563
 
527
-	public function getTrainerLevelCount($team_id) {
564
+	public function getTrainerLevelCount($team_id)
565
+	{
528 566
 		$req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'";
529 567
 		if (!empty(self::$config->system->trainer_blacklist)) {
530 568
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -545,7 +583,8 @@  discard block
 block discarded – undo
545 583
 		return $levelData;
546 584
 	}
547 585
 
548
-	private function getTrainerData($trainer_name, $team, $page, $ranking) {
586
+	private function getTrainerData($trainer_name, $team, $page, $ranking)
587
+	{
549 588
 		$where = "";
550 589
 
551 590
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -586,7 +625,8 @@  discard block
 block discarded – undo
586 625
 		return $trainers;
587 626
 	}
588 627
 
589
-	private function getTrainerLevelRating($level) {
628
+	private function getTrainerLevelRating($level)
629
+	{
590 630
 		$req = "SELECT COUNT(1) AS rank FROM trainer WHERE level = ".$level;
591 631
 		if (!empty(self::$config->system->trainer_blacklist)) {
592 632
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -596,7 +636,8 @@  discard block
 block discarded – undo
596 636
 		return $data;
597 637
 	}
598 638
 
599
-	private function getTrainerActivePokemon($trainer_name){
639
+	private function getTrainerActivePokemon($trainer_name)
640
+	{
600 641
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, filtered_gymmember.gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '1' AS active
601 642
 					FROM gympokemon INNER JOIN
602 643
 					(SELECT gymmember.pokemon_uid, gymmember.gym_id, gymmember.deployment_time FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.deployment_time, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -611,7 +652,8 @@  discard block
 block discarded – undo
611 652
 		return $pokemons;
612 653
 	}
613 654
 
614
-	private function getTrainerInactivePokemon($trainer_name){
655
+	private function getTrainerInactivePokemon($trainer_name)
656
+	{
615 657
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, null AS gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '0' AS active
616 658
 					FROM gympokemon LEFT JOIN
617 659
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -631,7 +673,8 @@  discard block
 block discarded – undo
631 673
 	// Cron
632 674
 	/////////
633 675
 
634
-	public function getPokemonCountsActive() {
676
+	public function getPokemonCountsActive()
677
+	{
635 678
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP() GROUP BY pokemon_id";
636 679
 		$result = $this->mysqli->query($req);
637 680
 		$counts = array();
@@ -641,7 +684,8 @@  discard block
 block discarded – undo
641 684
 		return $counts;
642 685
 	}
643 686
 
644
-	public function getPokemonCountsLastDay() {
687
+	public function getPokemonCountsLastDay()
688
+	{
645 689
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
646 690
 					FROM pokemon
647 691
 					WHERE disappear_time >= (SELECT MAX(disappear_time) FROM pokemon) - INTERVAL 1 DAY
@@ -655,14 +699,16 @@  discard block
 block discarded – undo
655 699
 		return $counts;
656 700
 	}
657 701
 
658
-	public function getCaptchaCount() {
702
+	public function getCaptchaCount()
703
+	{
659 704
 		$req = "SELECT SUM(accounts_captcha) AS total FROM mainworker";
660 705
 		$result = $this->mysqli->query($req);
661 706
 		$data = $result->fetch_object();
662 707
 		return $data;
663 708
 	}
664 709
 
665
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
710
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
711
+	{
666 712
 		$pokemon_exclude_sql = "";
667 713
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
668 714
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
@@ -684,7 +730,8 @@  discard block
 block discarded – undo
684 730
 		return $nests;
685 731
 	}
686 732
 
687
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
733
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
734
+	{
688 735
 		$req = "SELECT COUNT(*) as total 
689 736
 					FROM spawnpoint
690 737
  					WHERE latitude >= ".$minLatitude." AND latitude < ".$maxLatitude." AND longitude >= ".$minLongitude." AND longitude < ".$maxLongitude;
Please login to merge, or discard this patch.