Failed Conditions
Pull Request — master (#353)
by Florian
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,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	public function getNestData() {
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() - 86400
687
-			          " . $pokemon_exclude_sql . "
687
+			          " . $pokemon_exclude_sql."
688 688
 			          GROUP BY p.spawn_id, p.pokemon_id
689 689
 			          HAVING COUNT(p.pokemon_id) >= 6
690 690
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +82 added lines, -41 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() {
718
+	public function getNestData()
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) . ")";
Please login to merge, or discard this patch.
core/cron/crontabs.include.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 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
 
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
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 			          FROM pokemon p
672 672
 			          INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id)
673 673
 			          WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL 24 HOUR
674
-			          " . $pokemon_exclude_sql . "
674
+			          " . $pokemon_exclude_sql."
675 675
 			          GROUP BY p.spawnpoint_id, p.pokemon_id
676 676
 			          HAVING COUNT(p.pokemon_id) >= 6
677 677
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +92 added lines, -46 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() {
710
+	public function getNestData()
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).")";
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
@@ -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 50 OFFSET 0";
173 173
 		$result = pg_query($this->db, $req);
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
182 182
 		$trainer_blacklist = "";
183 183
 		if (!empty(self::$config->system->trainer_blacklist)) {
184
-			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
184
+			$trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
185 185
 		}
186 186
 
187 187
 		$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,
188 188
                 TO_TIMESTAMP(last_modified) AS lasttime, last_modified as last_seen
189 189
                 FROM gym_defenders
190
-				WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . "
190
+				WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist."
191 191
 				ORDER BY $best_order_by $best_direction, owner_name ASC
192 192
 				LIMIT 50 OFFSET 0";
193 193
 
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 
230 230
 	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
231 231
 		$inmap_pkms_filter = "";
232
-		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
232
+		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = ".$pokemon_id;
233 233
 
234
-		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where;
234
+		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings ".$where;
235 235
 		$resultTestIv = pg_query($this->db, $reqTestIv);
236 236
 		$testIv = pg_fetch_object($resultTestIv);
237 237
 		if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) {
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
 				$inmap_pkms_filter .= "'".$inmap."',";
240 240
 			}
241 241
 			$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
242
-			$where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") ";
242
+			$where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") ";
243 243
 		}
244 244
 		if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) {
245
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") ";
245
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (".$ivMin.") ";
246 246
 		}
247 247
 		if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) {
248
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") ";
248
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (".$ivMax.") ";
249 249
 		}
250 250
 		$req = "SELECT pokemon_id, lat AS latitude, lon AS longitude,
251 251
     					TO_TIMESTAMP(expire_timestamp) AS disappear_time,
252 252
     					TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
253 253
     					atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina,
254 254
    						move_1, move_2
255
-					FROM sightings " . $where . "
255
+					FROM sightings " . $where."
256 256
 					LIMIT 5000";
257 257
 		$result = pg_query($this->db, $req);
258 258
 		$spawns = array();
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
342 342
         			FROM forts f
343 343
 					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))
344
-        			WHERE fs.team = '" . $team_id . "'";
344
+        			WHERE fs.team = '" . $team_id."'";
345 345
 		$result = pg_query($this->db, $req);
346 346
 		$data = pg_fetch_object($result);
347 347
 		return $data;
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	{
429 429
 		$req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name
430 430
 					FROM gym_defenders
431
-					WHERE fort_id = '". $gym_id ."'
431
+					WHERE fort_id = '". $gym_id."'
432 432
 					ORDER BY deployment_time";
433 433
 		$result = pg_query($this->db, $req);
434 434
 		$pokemons = array();
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
 		$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
449 449
 					FROM fort_sightings fs
450 450
 					LEFT JOIN forts f ON f.id = fs.fort_id
451
-					WHERE f.id = '". $gym_id ."'
451
+					WHERE f.id = '". $gym_id."'
452 452
 					ORDER BY fs.last_modified DESC
453
-					LIMIT ".($pageSize+1)." OFFSET ".($page * $pageSize);
453
+					LIMIT ".($pageSize + 1)." OFFSET ".($page * $pageSize);
454 454
 		$result = pg_query($this->db, $req);
455 455
 		$history = array();
456 456
 		$count = 0;
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		$req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
483 483
 					FROM gym_history_defenders ghd
484 484
 					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
485
-					WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."'
485
+					WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."'
486 486
 					ORDER BY gd.deployment_time";
487 487
 		$result = pg_query($this->db, $req);
488 488
 		$pokemons = array();
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	///////////
498 498
 
499 499
 	public function getAllRaids($page) {
500
-		$limit = " LIMIT 10 OFFSET ". ($page * 10);
500
+		$limit = " LIMIT 10 OFFSET ".($page * 10);
501 501
 		$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
502 502
 					FROM forts f
503 503
 					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))
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 						WHERE fort_id IS NOT NULL
550 550
 				  		GROUP BY owner_name
551 551
 				  	) active ON active.owner_name = gd.owner_name
552
-				  	WHERE level IS NOT NULL " . $where . "
553
-				  	GROUP BY gd.owner_name" . $order  . $limit;
552
+				  	WHERE level IS NOT NULL " . $where."
553
+				  	GROUP BY gd.owner_name" . $order.$limit;
554 554
 		$result = pg_query($this->db, $req);
555 555
 		$trainers = array();
556 556
 		while ($data = pg_fetch_object($result)) {
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 			}
561 561
 			$trainers[$data->name] = $data;
562 562
 
563
-			$pokemon = array_merge($this->getActivePokemon($data->name),  $this->getInactivePokemon($data->name));
563
+			$pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name));
564 564
 
565 565
 			$trainers[$data->name]->gyms = $data->active;
566 566
 			$trainers[$data->name]->pokemons = $pokemon;
@@ -677,13 +677,13 @@  discard block
 block discarded – undo
677 677
 	public function getNestData() {
678 678
 		$pokemon_exclude_sql = "";
679 679
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
680
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
680
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
681 681
 		}
682 682
 		$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
683 683
 			          FROM sightings p
684 684
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
685 685
 			          WHERE p.expire_timestamp > EXTRACT(EPOCH FROM NOW()) - 86400
686
-			          " . $pokemon_exclude_sql . "
686
+			          " . $pokemon_exclude_sql."
687 687
 			          GROUP BY p.spawn_id, p.pokemon_id
688 688
 			          HAVING COUNT(p.pokemon_id) >= 6
689 689
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +82 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql {
3
+class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql
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 = pg_query($this->db, $req);
20 24
 		if ($result === false) {
@@ -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 = pg_query($this->db, $req);
36 41
 		if ($result === false) {
@@ -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 = pg_query($this->db, $req);
52 58
 		if ($result === false) {
@@ -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 >= EXTRACT(EPOCH FROM NOW())";
72 79
 		$result = pg_query($this->db, $req);
73 80
 		$data = pg_fetch_object($result);
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 = pg_query($this->db, $req);
85 94
 		$data = pg_fetch_object($result);
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 <= EXTRACT(EPOCH FROM NOW()) AND time_end >= EXTRACT(EPOCH FROM NOW())";
91 101
 		$result = pg_query($this->db, $req);
92 102
 		$data = pg_fetch_object($result);
@@ -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 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,
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, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(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 TO_TIMESTAMP(expire_timestamp) AS expire_timestamp, TO_TIMESTAMP(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 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,
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
@@ -178,7 +194,8 @@  discard block
 block discarded – undo
178 194
 		return $top;
179 195
 	}
180 196
 
181
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
197
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
198
+	{
182 199
 		$trainer_blacklist = "";
183 200
 		if (!empty(self::$config->system->trainer_blacklist)) {
184 201
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -199,7 +216,8 @@  discard block
 block discarded – undo
199 216
 		return $toptrainer;
200 217
 	}
201 218
 
202
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
219
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
220
+	{
203 221
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
204 222
 			. "AND TO_TIMESTAMP(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
205 223
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000";
@@ -211,7 +229,8 @@  discard block
 block discarded – undo
211 229
 		return $points;
212 230
 	}
213 231
 
214
-	public function getPokemonGraph($pokemon_id) {
232
+	public function getPokemonGraph($pokemon_id)
233
+	{
215 234
 		$req = "SELECT COUNT(*) AS total, EXTRACT(HOUR FROM disappear_time) AS disappear_hour
216 235
 					FROM (SELECT TO_TIMESTAMP(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
217 236
 				GROUP BY disappear_hour
@@ -227,7 +246,8 @@  discard block
 block discarded – undo
227 246
 		return $array;
228 247
 	}
229 248
 
230
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
249
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
250
+	{
231 251
 		$inmap_pkms_filter = "";
232 252
 		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
233 253
 
@@ -262,21 +282,24 @@  discard block
 block discarded – undo
262 282
 		return $spawns;
263 283
 	}
264 284
 
265
-	public function getPokemonSliderMinMax() {
285
+	public function getPokemonSliderMinMax()
286
+	{
266 287
 		$req = "SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings";
267 288
 		$result = pg_query($this->db, $req);
268 289
 		$data = pg_fetch_object($result);
269 290
 		return $data;
270 291
 	}
271 292
 
272
-	public function getMapsCoords() {
293
+	public function getMapsCoords()
294
+	{
273 295
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
274 296
 		$result = pg_query($this->db, $req);
275 297
 		$data = pg_fetch_object($result);
276 298
 		return $data;
277 299
 	}
278 300
 
279
-	public function getPokemonCount($pokemon_id) {
301
+	public function getPokemonCount($pokemon_id)
302
+	{
280 303
 		$req = "SELECT count, last_seen, latitude, longitude
281 304
 					FROM pokemon_stats
282 305
 					WHERE pid = ".$pokemon_id;
@@ -285,7 +308,8 @@  discard block
 block discarded – undo
285 308
 		return $data;
286 309
 	}
287 310
 
288
-	public function getRaidCount($pokemon_id) {
311
+	public function getRaidCount($pokemon_id)
312
+	{
289 313
 		$req = "SELECT count, last_seen, latitude, longitude
290 314
 					FROM raid_stats
291 315
 					WHERE pid = ".$pokemon_id;
@@ -300,14 +324,16 @@  discard block
 block discarded – undo
300 324
 	//////////////
301 325
 
302 326
 
303
-	function getTotalPokestops() {
327
+	function getTotalPokestops()
328
+	{
304 329
 		$req = "SELECT COUNT(*) as total FROM pokestops";
305 330
 		$result = pg_query($this->db, $req);
306 331
 		$data = pg_fetch_object($result);
307 332
 		return $data;
308 333
 	}
309 334
 
310
-	public function getAllPokestops() {
335
+	public function getAllPokestops()
336
+	{
311 337
 		$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";
312 338
 		$result = pg_query($this->db, $req);
313 339
 		$pokestops = array();
@@ -322,7 +348,8 @@  discard block
 block discarded – undo
322 348
 	// Gyms
323 349
 	/////////
324 350
 
325
-	function getTeamGuardians($team_id) {
351
+	function getTeamGuardians($team_id)
352
+	{
326 353
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id
327 354
 					FROM forts f
328 355
 					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))
@@ -337,7 +364,8 @@  discard block
 block discarded – undo
337 364
 		return $datas;
338 365
 	}
339 366
 
340
-	function getOwnedAndPoints($team_id) {
367
+	function getOwnedAndPoints($team_id)
368
+	{
341 369
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
342 370
         			FROM forts f
343 371
 					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))
@@ -347,7 +375,8 @@  discard block
 block discarded – undo
347 375
 		return $data;
348 376
 	}
349 377
 
350
-	function getAllGyms() {
378
+	function getAllGyms()
379
+	{
351 380
 		$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
352 381
 					FROM forts f
353 382
 					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))";
@@ -359,7 +388,8 @@  discard block
 block discarded – undo
359 388
 		return $gyms;
360 389
 	}
361 390
 
362
-	public function getGymData($gym_id) {
391
+	public function getGymData($gym_id)
392
+	{
363 393
 		$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
364 394
 			FROM forts f
365 395
 			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))
@@ -370,7 +400,8 @@  discard block
 block discarded – undo
370 400
 		return $data;
371 401
 	}
372 402
 
373
-	public function getGymDefenders($gym_id) {
403
+	public function getGymDefenders($gym_id)
404
+	{
374 405
 		$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
375 406
 			FROM gym_defenders
376 407
 			WHERE fort_id='".$gym_id."'
@@ -496,7 +527,8 @@  discard block
 block discarded – undo
496 527
 	// Raids
497 528
 	///////////
498 529
 
499
-	public function getAllRaids($page) {
530
+	public function getAllRaids($page)
531
+	{
500 532
 		$limit = " LIMIT 10 OFFSET ". ($page * 10);
501 533
 		$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
502 534
 					FROM forts f
@@ -517,7 +549,8 @@  discard block
 block discarded – undo
517 549
 	// Trainers
518 550
 	//////////////
519 551
 
520
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
552
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
553
+	{
521 554
 		$ranking = $this->getTrainerLevelRanking();
522 555
 		$where = "";
523 556
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -569,7 +602,8 @@  discard block
 block discarded – undo
569 602
 		return $trainers;
570 603
 	}
571 604
 
572
-	public function getTrainerLevelRanking() {
605
+	public function getTrainerLevelRanking()
606
+	{
573 607
 		$exclue = "";
574 608
 		if (!empty(self::$config->system->trainer_blacklist)) {
575 609
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -590,7 +624,8 @@  discard block
 block discarded – undo
590 624
 		return $levelData;
591 625
 	}
592 626
 
593
-	public function getActivePokemon($trainer_name) {
627
+	public function getActivePokemon($trainer_name)
628
+	{
594 629
 		$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
595 630
 						FROM gym_defenders
596 631
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -603,7 +638,8 @@  discard block
 block discarded – undo
603 638
 		return $pokemon;
604 639
 	}
605 640
 
606
-	public function getInactivePokemon($trainer_name) {
641
+	public function getInactivePokemon($trainer_name)
642
+	{
607 643
 		$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
608 644
 					FROM gym_defenders
609 645
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -616,7 +652,8 @@  discard block
 block discarded – undo
616 652
 		return $pokemon;
617 653
 	}
618 654
 
619
-	public function getTrainerLevelCount($team_id) {
655
+	public function getTrainerLevelCount($team_id)
656
+	{
620 657
 		$exclue = "";
621 658
 		if (!empty(self::$config->system->trainer_blacklist)) {
622 659
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -642,7 +679,8 @@  discard block
 block discarded – undo
642 679
 	// Cron
643 680
 	/////////
644 681
 
645
-	public function getPokemonCountsActive() {
682
+	public function getPokemonCountsActive()
683
+	{
646 684
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) GROUP BY pokemon_id";
647 685
 		$result = pg_query($this->db, $req);
648 686
 		$counts = array();
@@ -652,7 +690,8 @@  discard block
 block discarded – undo
652 690
 		return $counts;
653 691
 	}
654 692
 
655
-	public function getPokemonCountsLastDay() {
693
+	public function getPokemonCountsLastDay()
694
+	{
656 695
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
657 696
 					FROM sightings
658 697
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -667,14 +706,16 @@  discard block
 block discarded – undo
667 706
 	}
668 707
 
669 708
 
670
-	public function getCaptchaCount() {
709
+	public function getCaptchaCount()
710
+	{
671 711
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
672 712
 		$result = pg_query($this->db, $req);
673 713
 		$data = pg_fetch_object($result);
674 714
 		return $data;
675 715
 	}
676 716
 
677
-	public function getNestData() {
717
+	public function getNestData()
718
+	{
678 719
 		$pokemon_exclude_sql = "";
679 720
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
680 721
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
Please login to merge, or discard this patch.