Failed Conditions
Pull Request — master (#363)
by Florian
02:50
created
pages/gymhistory.page.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 <script type="text/javascript">
69 69
 <?=
70 70
 $gymName = "";
71
-if (isset($_GET['name']) && $_GET['name']!="") {
71
+if (isset($_GET['name']) && $_GET['name'] != "") {
72 72
 	$gymName = html_entity_decode($_GET['name']);
73 73
 }
74 74
 ?>
Please login to merge, or discard this patch.
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   +21 added lines, -21 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
 					ORDER BY disappear_time DESC
258 258
 					LIMIT 5000";
259 259
 		$result = $this->mysqli->query($req);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points
326 326
         			FROM forts f
327 327
 					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))
328
-        			WHERE fs.team = '" . $team_id . "'";
328
+        			WHERE fs.team = '" . $team_id."'";
329 329
 		$result = $this->mysqli->query($req);
330 330
 		$data = $result->fetch_object();
331 331
 		return $data;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	{
432 432
 		$req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name
433 433
 					FROM gym_defenders
434
-					WHERE fort_id = '". $gym_id ."'
434
+					WHERE fort_id = '". $gym_id."'
435 435
 					ORDER BY deployment_time";
436 436
 		$result = $this->mysqli->query($req);
437 437
 		$pokemons = array();
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 		$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
452 452
 					FROM fort_sightings fs
453 453
 					LEFT JOIN forts f ON f.id = fs.fort_id
454
-					WHERE f.id = '". $gym_id ."'
454
+					WHERE f.id = '". $gym_id."'
455 455
 					ORDER BY fs.last_modified DESC
456
-					LIMIT ".($page * $pageSize).",".($pageSize+1);
456
+					LIMIT ".($page * $pageSize).",".($pageSize + 1);
457 457
 		$result = $this->mysqli->query($req);
458 458
 		$history = array();
459 459
 		$count = 0;
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		$req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
486 486
 					FROM gym_history_defenders ghd
487 487
 					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
488
-					WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."'
488
+					WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."'
489 489
 					ORDER BY gd.deployment_time";
490 490
 		$result = $this->mysqli->query($req);
491 491
 		$pokemons = array();
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 						WHERE fort_id IS NOT NULL
534 534
 				  		GROUP BY owner_name
535 535
 				  	) active ON active.owner_name = gd.owner_name
536
-				  	WHERE gd.owner_level IS NOT NULL " . $where . "
537
-				  	GROUP BY gd.owner_name" . $order  . $limit;
536
+				  	WHERE gd.owner_level IS NOT NULL " . $where."
537
+				  	GROUP BY gd.owner_name" . $order.$limit;
538 538
 		$result = $this->mysqli->query($req);
539 539
 		$trainers = array();
540 540
 		while ($data = $result->fetch_object()) {
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
             }
545 545
 			$trainers[$data->name] = $data;
546 546
 
547
-			$pokemon = array_merge($this->getActivePokemon($data->name),  $this->getInactivePokemon($data->name));
547
+			$pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name));
548 548
 
549 549
 			$trainers[$data->name]->gyms = $data->active;
550 550
 			$trainers[$data->name]->pokemons = $pokemon;
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 						LEFT JOIN spawnpoints s ON p.spawn_id = s.spawn_id
661 661
                     	" . $where."
662 662
                     ) x
663
-					" . $where . "
663
+					" . $where."
664 664
 					ORDER BY last_timestamp DESC
665 665
 					LIMIT 0 , 1";
666 666
 		$result = $this->mysqli->query($req);
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                     	" . $where."
679 679
                     ) x 
680 680
 					ON r.fort_id = g.id
681
-                    " . $where . "
681
+                    " . $where."
682 682
                     ORDER BY time_battle DESC
683 683
 					LIMIT 0 , 1";
684 684
 		$result = $this->mysqli->query($req);
@@ -696,14 +696,14 @@  discard block
 block discarded – undo
696 696
 	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
697 697
 		$pokemon_exclude_sql = "";
698 698
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
699
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
699
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
700 700
 		}
701 701
 		$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
702 702
 			          FROM sightings p
703 703
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
704 704
 			          WHERE p.expire_timestamp > UNIX_TIMESTAMP() - ".($time * 3600)."
705 705
 			            AND p.lat >= ".$minLatitude." AND p.lat < ".$maxLatitude." AND p.lon >= ".$minLongitude." AND p.lon < ".$maxLongitude."
706
-			          " . $pokemon_exclude_sql . "
706
+			          " . $pokemon_exclude_sql."
707 707
 			          GROUP BY p.spawn_id, p.pokemon_id
708 708
 			          HAVING COUNT(p.pokemon_id) >= ".($time / 4)."
709 709
 			          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." ORDER BY expire_timestamp DESC 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."' ORDER BY disappear_time 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
 
@@ -264,14 +284,16 @@  discard block
 block discarded – undo
264 284
 		return $spawns;
265 285
 	}
266 286
 
267
-	public function getPokemonSliderMinMax() {
287
+	public function getPokemonSliderMinMax()
288
+	{
268 289
 		$req = "SELECT FROM_UNIXTIME(MIN(expire_timestamp)) AS min, FROM_UNIXTIME(MAX(expire_timestamp)) AS max FROM sightings";
269 290
 		$result = $this->mysqli->query($req);
270 291
 		$data = $result->fetch_object();
271 292
 		return $data;
272 293
 	}
273 294
 
274
-	public function getMapsCoords() {
295
+	public function getMapsCoords()
296
+	{
275 297
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
276 298
 		$result = $this->mysqli->query($req);
277 299
 		$data = $result->fetch_object();
@@ -284,14 +306,16 @@  discard block
 block discarded – undo
284 306
 	//////////////
285 307
 
286 308
 
287
-	function getTotalPokestops() {
309
+	function getTotalPokestops()
310
+	{
288 311
 		$req = "SELECT COUNT(*) as total FROM pokestops";
289 312
 		$result = $this->mysqli->query($req);
290 313
 		$data = $result->fetch_object();
291 314
 		return $data;
292 315
 	}
293 316
 
294
-	public function getAllPokestops() {
317
+	public function getAllPokestops()
318
+	{
295 319
 		$req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, UNIX_TIMESTAMP() AS now, null AS lure_expiration_real FROM pokestops";
296 320
 		$result = $this->mysqli->query($req);
297 321
 		$pokestops = array();
@@ -306,7 +330,8 @@  discard block
 block discarded – undo
306 330
 	// Gyms
307 331
 	/////////
308 332
 
309
-	function getTeamGuardians($team_id) {
333
+	function getTeamGuardians($team_id)
334
+	{
310 335
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id 
311 336
 					FROM forts f
312 337
 					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))
@@ -321,7 +346,8 @@  discard block
 block discarded – undo
321 346
 		return $datas;
322 347
 	}
323 348
 
324
-	function getOwnedAndPoints($team_id) {
349
+	function getOwnedAndPoints($team_id)
350
+	{
325 351
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points
326 352
         			FROM forts f
327 353
 					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))
@@ -331,7 +357,8 @@  discard block
 block discarded – undo
331 357
 		return $data;
332 358
 	}
333 359
 
334
-	function getAllGyms() {
360
+	function getAllGyms()
361
+	{
335 362
 		$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 
336 363
 					FROM forts f
337 364
 					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 $gyms;
344 371
 	}
345 372
 
346
-	public function getGymData($gym_id) {
373
+	public function getGymData($gym_id)
374
+	{
347 375
 		$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	
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
-	public function getGymDefenders($gym_id) {
384
+	public function getGymDefenders($gym_id)
385
+	{
357 386
 		$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
358 387
 			FROM gym_defenders 
359 388
 			WHERE fort_id='".$gym_id."'
@@ -371,7 +400,8 @@  discard block
 block discarded – undo
371 400
 	// Raids
372 401
 	///////////
373 402
 
374
-	public function getAllRaids($page) {
403
+	public function getAllRaids($page)
404
+	{
375 405
 		$limit = " LIMIT ".($page * 10).",10";
376 406
 		$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 
377 407
 					FROM forts f
@@ -501,7 +531,8 @@  discard block
 block discarded – undo
501 531
 	// Trainers
502 532
 	//////////////
503 533
 
504
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
534
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
535
+	{
505 536
 		$ranking = $this->getTrainerLevelRanking();
506 537
 		$where = "";
507 538
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -553,7 +584,8 @@  discard block
 block discarded – undo
553 584
 		return $trainers;
554 585
 	}
555 586
 
556
-	public function getTrainerLevelRanking() {
587
+	public function getTrainerLevelRanking()
588
+	{
557 589
 		$exclue = "";
558 590
 		if (!empty(self::$config->system->trainer_blacklist)) {
559 591
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -574,7 +606,8 @@  discard block
 block discarded – undo
574 606
 		return $levelData;
575 607
 	}
576 608
 
577
-	public function getActivePokemon($trainer_name) {
609
+	public function getActivePokemon($trainer_name)
610
+	{
578 611
 		$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
579 612
 						FROM gym_defenders 
580 613
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -587,7 +620,8 @@  discard block
 block discarded – undo
587 620
 		return $pokemon;
588 621
 	}
589 622
 
590
-	public function getInactivePokemon($trainer_name) {
623
+	public function getInactivePokemon($trainer_name)
624
+	{
591 625
 		$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
592 626
 					FROM gym_defenders 
593 627
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -600,7 +634,8 @@  discard block
 block discarded – undo
600 634
 		return $pokemon;
601 635
 	}
602 636
 
603
-	public function getTrainerLevelCount($team_id) {
637
+	public function getTrainerLevelCount($team_id)
638
+	{
604 639
 		$exclue = "";
605 640
 		if (!empty(self::$config->system->trainer_blacklist)) {
606 641
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -626,7 +661,8 @@  discard block
 block discarded – undo
626 661
 	// Cron
627 662
 	/////////
628 663
 
629
-	public function getPokemonCountsActive() {
664
+	public function getPokemonCountsActive()
665
+	{
630 666
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() GROUP BY pokemon_id";
631 667
 		$result = $this->mysqli->query($req);
632 668
 		$counts = array();
@@ -636,7 +672,8 @@  discard block
 block discarded – undo
636 672
 		return $counts;
637 673
 	}
638 674
 
639
-	public function getPokemonCountsLastDay() {
675
+	public function getPokemonCountsLastDay()
676
+	{
640 677
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
641 678
 					FROM sightings
642 679
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -650,7 +687,8 @@  discard block
 block discarded – undo
650 687
 		return $counts;
651 688
 	}
652 689
 
653
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
690
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
691
+	{
654 692
 		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) > '".$last_update."'";
655 693
 		$req = "SELECT count, p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) AS last_timestamp, (FROM_UNIXTIME(p.expire_timestamp)) AS disappear_time_real, p.lat as latitude, p.lon as longitude
656 694
 					FROM sightings p
@@ -668,7 +706,8 @@  discard block
 block discarded – undo
668 706
 		return $data;
669 707
 	}
670 708
 
671
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
709
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
710
+	{
672 711
 		$where = "WHERE pokemon_id = '".$pokemon_id."AND".$last_update."'";
673 712
 		$req = "SELECT time_battle AS start_timestamp, time_end as end, (FROM_UNIXTIME(time_end)) AS end_time_real, lat as latitude, lon as longitude, count
674 713
 					FROM raids r
@@ -686,14 +725,16 @@  discard block
 block discarded – undo
686 725
 		return $data;
687 726
 	}
688 727
 
689
-	public function getCaptchaCount() {
728
+	public function getCaptchaCount()
729
+	{
690 730
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
691 731
 		$result = $this->mysqli->query($req);
692 732
 		$data = $result->fetch_object();
693 733
 		return $data;
694 734
 	}
695 735
 
696
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
736
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
737
+	{
697 738
 		$pokemon_exclude_sql = "";
698 739
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
699 740
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
@@ -715,7 +756,8 @@  discard block
 block discarded – undo
715 756
 		return $nests;
716 757
 	}
717 758
 
718
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
759
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
760
+	{
719 761
 		$req = "SELECT COUNT(*) as total 
720 762
 					FROM spawnpoints 
721 763
  					WHERE lat >= ".$minLatitude." AND lat < ".$maxLatitude." AND lon >= ".$minLongitude." AND lon < ".$maxLongitude;
Please login to merge, or discard this patch.
functions.php 2 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.
Braces   +30 added lines, -15 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,12 +303,14 @@  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'] == $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
306
+			if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) {
307
+// Check if point is on an horizontal polygon boundary
296 308
 				return true;
297 309
 			}
298 310
 			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']) {
299 311
 				$xinters = ($lng - $geo1['lng']) * ($geo2['lat'] - $geo1['lat']) / ($geo2['lng'] - $geo1['lng']) + $geo1['lat'];
300
-				if ($xinters == $lat) { // Check if point is on the polygon boundary (other than horizontal)
312
+				if ($xinters == $lat) {
313
+// Check if point is on the polygon boundary (other than horizontal)
301 314
 					return true;
302 315
 				}
303 316
 				if ($geo1['lat'] == $geo2['lat'] || $lat <= $xinters) {
@@ -319,7 +332,8 @@  discard block
 block discarded – undo
319 332
 ########################################################################
320 333
 // check if $boundsIn is inside (or equal to) $boundsOut
321 334
 ########################################################################
322
-function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut) {
335
+function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut)
336
+{
323 337
 	if ($boundsIn["minlat"] >= $boundsOut["minlat"] && $boundsIn["maxlat"] <= $boundsOut["maxlat"] && $boundsIn["minlon"] >= $boundsOut["minlon"] && $boundsIn["maxlon"] <= $boundsOut["maxlon"]) {
324 338
 		foreach ($geoIn as $coord) {
325 339
 			if (!pointIsInsidePolygon($coord["lat"], $coord["lng"], $geoOut, $boundsOut)) {
@@ -335,7 +349,8 @@  discard block
 block discarded – undo
335 349
 ########################################################################
336 350
 // compine outer ways into porygon
337 351
 ########################################################################
338
-function combineOuter($outers) {
352
+function combineOuter($outers)
353
+{
339 354
 	$polygon = array();
340 355
 	foreach ($outers as $key => $outer) {
341 356
 		if ($key == 0) {
Please login to merge, or discard this patch.
core/cron/crontabs.include.php 2 patches
Spacing   +8 added lines, -8 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
 
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	$pokedatas	= json_decode(file_get_contents($pokemonstats_file), true);
52 52
 }
53 53
 if (is_file($pokedex_counts_file)) {
54
-	$pokecountdatas	= json_decode(file_get_contents($pokedex_counts_file), true);
54
+	$pokecountdatas = json_decode(file_get_contents($pokedex_counts_file), true);
55 55
 }
56 56
 if (is_file($pokedex_raids_file)) {
57
-	$raiddatas	= json_decode(file_get_contents($pokedex_raids_file), true);
57
+	$raiddatas = json_decode(file_get_contents($pokedex_raids_file), true);
58 58
 }
59 59
 
60 60
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 } while ($migration < new DateTime());
91 91
 $migration = $migrationPrev->getTimestamp();
92 92
 
93
-if ( filemtime($nests_parks_file) - $migration <= 0 ) {
93
+if (filemtime($nests_parks_file) - $migration <= 0) {
94 94
 	file_put_contents($nests_file, json_encode(array()));
95 95
 	file_put_contents($nests_parks_file, json_encode(array()));
96 96
 	touch($nests_parks_file, 1);
@@ -103,7 +103,7 @@  discard block
 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)) { # extra update 12h after migration
107 107
 	if (is_file($nests_parks_file)) {
108 108
 		$prevNestTime = filemtime($nests_parks_file);
109 109
 	} else {
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	touch($nests_parks_file);
116 116
 	// update nests
117 117
 	$nestTime = 12;
118
-	include_once(SYS_PATH . '/core/cron/nests.cron.php');
119
-} elseif ( (file_update_ago($nests_parks_file) >= 86400) && (time() - $migration  >= 86400) ) {
118
+	include_once(SYS_PATH.'/core/cron/nests.cron.php');
119
+} elseif ((file_update_ago($nests_parks_file) >= 86400) && (time() - $migration >= 86400)) {
120 120
 	if (is_file($nests_parks_file)) {
121 121
 		$prevNestTime = filemtime($nests_parks_file);
122 122
 	} else {
@@ -128,5 +128,5 @@  discard block
 block discarded – undo
128 128
 	touch($nests_parks_file);
129 129
 	// update nests
130 130
 	$nestTime = 24;
131
-	include_once(SYS_PATH . '/core/cron/nests.cron.php');
131
+	include_once(SYS_PATH.'/core/cron/nests.cron.php');
132 132
 }
Please login to merge, or discard this patch.
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.
core/process/queries/QueryManagerMysqlRocketmap.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	/////////
301 301
 
302 302
 	function getTeamGuardians($team_id) {
303
-		$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";
303
+		$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";
304 304
 		$result = $this->mysqli->query($req);
305 305
 		$datas = array();
306 306
 		while ($data = $result->fetch_object()) {
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 
379 379
 		$limit = " LIMIT ".($page * 10).",10";
380 380
 
381
-		$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
381
+		$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
382 382
 				FROM gymdetails
383 383
 				LEFT JOIN gym
384 384
 				ON gymdetails.gym_id = gym.gym_id
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 					FROM gymmember
398 398
 					LEFT JOIN gympokemon
399 399
 					ON gymmember.pokemon_uid = gympokemon.pokemon_uid
400
-					WHERE gymmember.gym_id = '". $gym_id ."'
400
+					WHERE gymmember.gym_id = '". $gym_id."'
401 401
 					ORDER BY deployment_time";
402 402
 		$result = $this->mysqli->query($req);
403 403
 		$pokemons = array();
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 					FROM gymhistory
418 418
 					WHERE gym_id='".$gym_id."'
419 419
 					ORDER BY last_modified DESC
420
-					LIMIT ".($page * $pageSize).",".($pageSize+1);
420
+					LIMIT ".($page * $pageSize).",".($pageSize + 1);
421 421
 		$result = $this->mysqli->query($req);
422 422
 		$history = array();
423 423
 		$count = 0;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 				FROM gympokemon
558 558
 				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
559 559
 				ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid) AS actives_pokemons ON actives_pokemons.trainer_name = trainer.name
560
-				GROUP BY trainer.name " . $where . $order . $limit;
560
+				GROUP BY trainer.name " . $where.$order.$limit;
561 561
 
562 562
 		$result = $this->mysqli->query($req);
563 563
 		$trainers = array();
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		return $data;
579 579
 	}
580 580
 
581
-	private function getTrainerActivePokemon($trainer_name){
581
+	private function getTrainerActivePokemon($trainer_name) {
582 582
 		$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
583 583
 					FROM gympokemon INNER JOIN
584 584
 					(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
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 		return $pokemons;
594 594
 	}
595 595
 
596
-	private function getTrainerInactivePokemon($trainer_name){
596
+	private function getTrainerInactivePokemon($trainer_name) {
597 597
 		$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
598 598
 					FROM gympokemon LEFT JOIN
599 599
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
                     JOIN spawnpoint s ON p.spawnpoint_id = s.id
648 648
                     " . $where."
649 649
                 ) x
650
-				" . $where . "
650
+				" . $where."
651 651
 				ORDER BY last_timestamp DESC
652 652
                 LIMIT 0,1";
653 653
 		$result = $this->mysqli->query($req);
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 			          INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id) 
691 691
 			          WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL ".($time)." HOUR 
692 692
 			            AND p.latitude >= ".$minLatitude." AND p.latitude < ".$maxLatitude." AND p.longitude >= ".$minLongitude." AND p.longitude < ".$maxLongitude."
693
-			          " . $pokemon_exclude_sql . " 
693
+			          " . $pokemon_exclude_sql." 
694 694
 			          GROUP BY p.spawnpoint_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   +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." ORDER BY disappear_time DESC 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."' ORDER BY disappear_time 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
 
@@ -258,14 +278,16 @@  discard block
 block discarded – undo
258 278
 		return $spawns;
259 279
 	}
260 280
 
261
-	public function getPokemonSliderMinMax() {
281
+	public function getPokemonSliderMinMax()
282
+	{
262 283
 		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
263 284
 		$result = $this->mysqli->query($req);
264 285
 		$data = $result->fetch_object();
265 286
 		return $data;
266 287
 	}
267 288
 
268
-	public function getMapsCoords() {
289
+	public function getMapsCoords()
290
+	{
269 291
 		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
270 292
 		$result = $this->mysqli->query($req);
271 293
 		$data = $result->fetch_object();
@@ -277,14 +299,16 @@  discard block
 block discarded – undo
277 299
 	// Pokestops
278 300
 	//////////////
279 301
 
280
-	function getTotalPokestops() {
302
+	function getTotalPokestops()
303
+	{
281 304
 		$req = "SELECT COUNT(*) as total FROM pokestop";
282 305
 		$result = $this->mysqli->query($req);
283 306
 		$data = $result->fetch_object();
284 307
 		return $data;
285 308
 	}
286 309
 
287
-	public function getAllPokestops() {
310
+	public function getAllPokestops()
311
+	{
288 312
 		$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";
289 313
 		$result = $this->mysqli->query($req);
290 314
 		$pokestops = array();
@@ -299,7 +323,8 @@  discard block
 block discarded – undo
299 323
 	// Gyms
300 324
 	/////////
301 325
 
302
-	function getTeamGuardians($team_id) {
326
+	function getTeamGuardians($team_id)
327
+	{
303 328
 		$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";
304 329
 		$result = $this->mysqli->query($req);
305 330
 		$datas = array();
@@ -309,14 +334,16 @@  discard block
 block discarded – undo
309 334
 		return $datas;
310 335
 	}
311 336
 
312
-	function getOwnedAndPoints($team_id) {
337
+	function getOwnedAndPoints($team_id)
338
+	{
313 339
 		$req 	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
314 340
 		$result = $this->mysqli->query($req);
315 341
 		$data = $result->fetch_object();
316 342
 		return $data;
317 343
 	}
318 344
 
319
-	function getAllGyms() {
345
+	function getAllGyms()
346
+	{
320 347
 		$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";
321 348
 		$result = $this->mysqli->query($req);
322 349
 		$gyms = array();
@@ -326,7 +353,8 @@  discard block
 block discarded – undo
326 353
 		return $gyms;
327 354
 	}
328 355
 
329
-	public function getGymData($gym_id) {
356
+	public function getGymData($gym_id)
357
+	{
330 358
 		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
331 359
 					(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
332 360
 					FROM gymdetails
@@ -337,7 +365,8 @@  discard block
 block discarded – undo
337 365
 		return $data;
338 366
 	}
339 367
 
340
-	public function getGymDefenders($gym_id) {
368
+	public function getGymDefenders($gym_id)
369
+	{
341 370
 		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
342 371
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
343 372
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
@@ -357,7 +386,8 @@  discard block
 block discarded – undo
357 386
 	// Gym History
358 387
 	////////////////
359 388
 
360
-	public function getGymHistories($gym_name, $team, $page, $ranking) {
389
+	public function getGymHistories($gym_name, $team, $page, $ranking)
390
+	{
361 391
 		$where = '';
362 392
 		if (isset($gym_name) && $gym_name != '') {
363 393
 			$where = " WHERE name LIKE '%".$gym_name."%'";
@@ -392,7 +422,8 @@  discard block
 block discarded – undo
392 422
 		return $gym_history;
393 423
 	}
394 424
 
395
-	public function getGymHistoriesPokemon($gym_id) {
425
+	public function getGymHistoriesPokemon($gym_id)
426
+	{
396 427
 		$req = "SELECT DISTINCT gymmember.pokemon_uid, pokemon_id, cp, trainer_name
397 428
 					FROM gymmember
398 429
 					LEFT JOIN gympokemon
@@ -407,7 +438,8 @@  discard block
 block discarded – undo
407 438
 		return $pokemons;
408 439
 	}
409 440
 
410
-	public function getHistoryForGym($page, $gym_id) {
441
+	public function getHistoryForGym($page, $gym_id)
442
+	{
411 443
 		if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) {
412 444
 			$pageSize = 25;
413 445
 		} else {
@@ -443,7 +475,8 @@  discard block
 block discarded – undo
443 475
 		return array("last_page" => $last_page, "data" => $history);
444 476
 	}
445 477
 
446
-	private function getHistoryForGymPokemon($pkm_uids) {
478
+	private function getHistoryForGymPokemon($pkm_uids)
479
+	{
447 480
 		$req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name
448 481
 								FROM gympokemon
449 482
 								WHERE pokemon_uid IN ('".implode("','", $pkm_uids)."')
@@ -461,7 +494,8 @@  discard block
 block discarded – undo
461 494
 	// Raids
462 495
 	///////////
463 496
 
464
-	public function getAllRaids($page) {
497
+	public function getAllRaids($page)
498
+	{
465 499
 		$limit = " LIMIT ".($page * 10).",10";
466 500
 		$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
467 501
 					JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
@@ -481,7 +515,8 @@  discard block
 block discarded – undo
481 515
 	// Trainers
482 516
 	//////////////
483 517
 
484
-	public function getTrainers($trainer_name, $team, $page, $ranking) {
518
+	public function getTrainers($trainer_name, $team, $page, $ranking)
519
+	{
485 520
 		$trainers = $this->getTrainerData($trainer_name, $team, $page, $ranking);
486 521
 		foreach ($trainers as $trainer) {
487 522
 
@@ -506,7 +541,8 @@  discard block
 block discarded – undo
506 541
 		return $trainers;
507 542
 	}
508 543
 
509
-	public function getTrainerLevelCount($team_id) {
544
+	public function getTrainerLevelCount($team_id)
545
+	{
510 546
 		$req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'";
511 547
 		if (!empty(self::$config->system->trainer_blacklist)) {
512 548
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -527,7 +563,8 @@  discard block
 block discarded – undo
527 563
 		return $levelData;
528 564
 	}
529 565
 
530
-	private function getTrainerData($trainer_name, $team, $page, $ranking) {
566
+	private function getTrainerData($trainer_name, $team, $page, $ranking)
567
+	{
531 568
 		$where = "";
532 569
 
533 570
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -568,7 +605,8 @@  discard block
 block discarded – undo
568 605
 		return $trainers;
569 606
 	}
570 607
 
571
-	private function getTrainerLevelRating($level) {
608
+	private function getTrainerLevelRating($level)
609
+	{
572 610
 		$req = "SELECT COUNT(1) AS rank FROM trainer WHERE level = ".$level;
573 611
 		if (!empty(self::$config->system->trainer_blacklist)) {
574 612
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -578,7 +616,8 @@  discard block
 block discarded – undo
578 616
 		return $data;
579 617
 	}
580 618
 
581
-	private function getTrainerActivePokemon($trainer_name){
619
+	private function getTrainerActivePokemon($trainer_name)
620
+	{
582 621
 		$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
583 622
 					FROM gympokemon INNER JOIN
584 623
 					(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
@@ -593,7 +632,8 @@  discard block
 block discarded – undo
593 632
 		return $pokemons;
594 633
 	}
595 634
 
596
-	private function getTrainerInactivePokemon($trainer_name){
635
+	private function getTrainerInactivePokemon($trainer_name)
636
+	{
597 637
 		$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
598 638
 					FROM gympokemon LEFT JOIN
599 639
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -613,7 +653,8 @@  discard block
 block discarded – undo
613 653
 	// Cron
614 654
 	/////////
615 655
 
616
-	public function getPokemonCountsActive() {
656
+	public function getPokemonCountsActive()
657
+	{
617 658
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP() GROUP BY pokemon_id";
618 659
 		$result = $this->mysqli->query($req);
619 660
 		$counts = array();
@@ -623,7 +664,8 @@  discard block
 block discarded – undo
623 664
 		return $counts;
624 665
 	}
625 666
 
626
-	public function getPokemonCountsLastDay() {
667
+	public function getPokemonCountsLastDay()
668
+	{
627 669
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
628 670
 					FROM pokemon
629 671
 					WHERE disappear_time >= (SELECT MAX(disappear_time) FROM pokemon) - INTERVAL 1 DAY
@@ -637,7 +679,8 @@  discard block
 block discarded – undo
637 679
 		return $counts;
638 680
 	}
639 681
 
640
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
682
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
683
+	{
641 684
 		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) > '".$last_update."'";
642 685
 		$req = "SELECT count, (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) as last_timestamp, (CONVERT_TZ(p.disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, p.latitude, p.longitude 
643 686
 				FROM pokemon p
@@ -655,7 +698,8 @@  discard block
 block discarded – undo
655 698
 		return $data;
656 699
 	}
657 700
 
658
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
701
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
702
+	{
659 703
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND UNIX_TIMESTAMP(start) > '".$last_update."'";
660 704
 		$req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".self::$time_offset."')) AS end_time_real, latitude, longitude, count
661 705
                 FROM raid r
@@ -673,14 +717,16 @@  discard block
 block discarded – undo
673 717
 		return $data;
674 718
 	}
675 719
 
676
-	public function getCaptchaCount() {
720
+	public function getCaptchaCount()
721
+	{
677 722
 		$req = "SELECT SUM(accounts_captcha) AS total FROM mainworker";
678 723
 		$result = $this->mysqli->query($req);
679 724
 		$data = $result->fetch_object();
680 725
 		return $data;
681 726
 	}
682 727
 
683
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
728
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
729
+	{
684 730
 		$pokemon_exclude_sql = "";
685 731
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
686 732
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
@@ -702,7 +748,8 @@  discard block
 block discarded – undo
702 748
 		return $nests;
703 749
 	}
704 750
 
705
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
751
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
752
+	{
706 753
 		$req = "SELECT COUNT(*) as total 
707 754
 					FROM spawnpoint
708 755
  					WHERE latitude >= ".$minLatitude." AND latitude < ".$maxLatitude." AND longitude >= ".$minLongitude." AND longitude < ".$maxLongitude;
Please login to merge, or discard this patch.
core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 2 patches
Spacing   +22 added lines, -22 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
 					ORDER BY disappear_time DESC
263 263
 					LIMIT 5000";
264 264
 		$result = pg_query($this->db, $req);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
331 331
         			FROM forts f
332 332
 					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))
333
-        			WHERE fs.team = '" . $team_id . "'";
333
+        			WHERE fs.team = '" . $team_id."'";
334 334
 		$result = pg_query($this->db, $req);
335 335
 		$data = pg_fetch_object($result);
336 336
 		return $data;
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	{
418 418
 		$req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name
419 419
 					FROM gym_defenders
420
-					WHERE fort_id = '". $gym_id ."'
420
+					WHERE fort_id = '". $gym_id."'
421 421
 					ORDER BY deployment_time";
422 422
 		$result = $this->mysqli->query($req);
423 423
 		$pokemons = array();
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 		$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
438 438
 					FROM fort_sightings fs
439 439
 					LEFT JOIN forts f ON f.id = fs.fort_id
440
-					WHERE f.id = '". $gym_id ."'
440
+					WHERE f.id = '". $gym_id."'
441 441
 					ORDER BY fs.last_modified DESC
442
-					LIMIT ".($pageSize+1)." OFFSET ".($page * $pageSize);
442
+					LIMIT ".($pageSize + 1)." OFFSET ".($page * $pageSize);
443 443
 		$result = $this->mysqli->query($req);
444 444
 		$history = array();
445 445
 		$count = 0;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 		$req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
472 472
 					FROM gym_history_defenders ghd
473 473
 					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
474
-					WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."'
474
+					WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."'
475 475
 					ORDER BY gd.deployment_time";
476 476
 		$result = $this->mysqli->query($req);
477 477
 		$pokemons = array();
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 	///////////
487 487
 
488 488
 	public function getAllRaids($page) {
489
-		$limit = " LIMIT 10 OFFSET ". ($page * 10);
489
+		$limit = " LIMIT 10 OFFSET ".($page * 10);
490 490
 		$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 
491 491
 					FROM forts f
492 492
 					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))
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 						WHERE fort_id IS NOT NULL
539 539
 				  		GROUP BY owner_name
540 540
 				  	) active ON active.owner_name = gd.owner_name
541
-				  	WHERE level IS NOT NULL " . $where . "
542
-				  	GROUP BY gd.owner_name" . $order  . $limit;
541
+				  	WHERE level IS NOT NULL " . $where."
542
+				  	GROUP BY gd.owner_name" . $order.$limit;
543 543
 		$result = $this->mysqli->query($req);
544 544
 		$trainers = array();
545 545
 		while ($data = $result->fetch_object()) {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 			}
550 550
 			$trainers[$data->name] = $data;
551 551
 
552
-			$pokemon = array_merge($this->getActivePokemon($data->name),  $this->getInactivePokemon($data->name));
552
+			$pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name));
553 553
 
554 554
 			$trainers[$data->name]->gyms = $data->active;
555 555
 			$trainers[$data->name]->pokemons = $pokemon;
@@ -663,9 +663,9 @@  discard block
 block discarded – undo
663 663
 				  	JOIN (SELECT COUNT(*) AS count
664 664
 						FROM FROM sightings p
665 665
 						LEFT JOIN spawnpoints s ON p.spawn_id = s.spawn_id
666
-                    	" . $where. "
666
+                    	" . $where."
667 667
                     ) count ON 1 = 1
668
-					" . $where . "
668
+					" . $where."
669 669
 					ORDER BY last_timestamp DESC
670 670
 					LIMIT 1 OFFSET 0";
671 671
 		$result = pg_query($this->db, $req);
@@ -700,14 +700,14 @@  discard block
 block discarded – undo
700 700
 	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
701 701
 		$pokemon_exclude_sql = "";
702 702
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
703
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
703
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
704 704
 		}
705 705
 		$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
706 706
 			          FROM sightings p
707 707
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
708 708
 			          WHERE p.expire_timestamp > EXTRACT(EPOCH FROM NOW()) - ".($time * 3600)."
709 709
 			            AND p.lat >= ".$minLatitude." AND p.lat < ".$maxLatitude." AND p.lon >= ".$minLongitude." AND p.lon < ".$maxLongitude."
710
-			          " . $pokemon_exclude_sql . "
710
+			          " . $pokemon_exclude_sql."
711 711
 			          GROUP BY p.spawn_id, p.pokemon_id
712 712
 			          HAVING COUNT(p.pokemon_id) >= ".($time / 4)."
713 713
 			          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." ORDER BY expire_timestamp DESC 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."' ORDER BY disappear_time 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
 
@@ -269,14 +289,16 @@  discard block
 block discarded – undo
269 289
 		return $spawns;
270 290
 	}
271 291
 
272
-	public function getPokemonSliderMinMax() {
292
+	public function getPokemonSliderMinMax()
293
+	{
273 294
 		$req = "SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings";
274 295
 		$result = pg_query($this->db, $req);
275 296
 		$data = pg_fetch_object($result);
276 297
 		return $data;
277 298
 	}
278 299
 
279
-	public function getMapsCoords() {
300
+	public function getMapsCoords()
301
+	{
280 302
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
281 303
 		$result = pg_query($this->db, $req);
282 304
 		$data = pg_fetch_object($result);
@@ -289,14 +311,16 @@  discard block
 block discarded – undo
289 311
 	//////////////
290 312
 
291 313
 
292
-	function getTotalPokestops() {
314
+	function getTotalPokestops()
315
+	{
293 316
 		$req = "SELECT COUNT(*) as total FROM pokestops";
294 317
 		$result = pg_query($this->db, $req);
295 318
 		$data = pg_fetch_object($result);
296 319
 		return $data;
297 320
 	}
298 321
 
299
-	public function getAllPokestops() {
322
+	public function getAllPokestops()
323
+	{
300 324
 		$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";
301 325
 		$result = pg_query($this->db, $req);
302 326
 		$pokestops = array();
@@ -311,7 +335,8 @@  discard block
 block discarded – undo
311 335
 	// Gyms
312 336
 	/////////
313 337
 
314
-	function getTeamGuardians($team_id) {
338
+	function getTeamGuardians($team_id)
339
+	{
315 340
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id 
316 341
 					FROM forts f
317 342
 					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))
@@ -326,7 +351,8 @@  discard block
 block discarded – undo
326 351
 		return $datas;
327 352
 	}
328 353
 
329
-	function getOwnedAndPoints($team_id) {
354
+	function getOwnedAndPoints($team_id)
355
+	{
330 356
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
331 357
         			FROM forts f
332 358
 					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))
@@ -336,7 +362,8 @@  discard block
 block discarded – undo
336 362
 		return $data;
337 363
 	}
338 364
 
339
-	function getAllGyms() {
365
+	function getAllGyms()
366
+	{
340 367
 		$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 
341 368
 					FROM forts f
342 369
 					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))";
@@ -348,7 +375,8 @@  discard block
 block discarded – undo
348 375
 		return $gyms;
349 376
 	}
350 377
 
351
-	public function getGymData($gym_id) {
378
+	public function getGymData($gym_id)
379
+	{
352 380
 		$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	
353 381
 			FROM forts f
354 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 +387,8 @@  discard block
 block discarded – undo
359 387
 		return $data;
360 388
 	}
361 389
 
362
-	public function getGymDefenders($gym_id) {
390
+	public function getGymDefenders($gym_id)
391
+	{
363 392
 		$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
364 393
 			FROM gym_defenders 
365 394
 			WHERE fort_id='".$gym_id."'
@@ -485,7 +514,8 @@  discard block
 block discarded – undo
485 514
 	// Raids
486 515
 	///////////
487 516
 
488
-	public function getAllRaids($page) {
517
+	public function getAllRaids($page)
518
+	{
489 519
 		$limit = " LIMIT 10 OFFSET ". ($page * 10);
490 520
 		$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 
491 521
 					FROM forts f
@@ -506,7 +536,8 @@  discard block
 block discarded – undo
506 536
 	// Trainers
507 537
 	//////////////
508 538
 
509
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
539
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
540
+	{
510 541
 		$ranking = $this->getTrainerLevelRanking();
511 542
 		$where = "";
512 543
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -558,7 +589,8 @@  discard block
 block discarded – undo
558 589
 		return $trainers;
559 590
 	}
560 591
 
561
-	public function getTrainerLevelRanking() {
592
+	public function getTrainerLevelRanking()
593
+	{
562 594
 		$exclue = "";
563 595
 		if (!empty(self::$config->system->trainer_blacklist)) {
564 596
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -579,7 +611,8 @@  discard block
 block discarded – undo
579 611
 		return $levelData;
580 612
 	}
581 613
 
582
-	public function getActivePokemon($trainer_name) {
614
+	public function getActivePokemon($trainer_name)
615
+	{
583 616
 		$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
584 617
 						FROM gym_defenders 
585 618
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -592,7 +625,8 @@  discard block
 block discarded – undo
592 625
 		return $pokemon;
593 626
 	}
594 627
 
595
-	public function getInactivePokemon($trainer_name) {
628
+	public function getInactivePokemon($trainer_name)
629
+	{
596 630
 		$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
597 631
 					FROM gym_defenders 
598 632
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -605,7 +639,8 @@  discard block
 block discarded – undo
605 639
 		return $pokemon;
606 640
 	}
607 641
 
608
-	public function getTrainerLevelCount($team_id) {
642
+	public function getTrainerLevelCount($team_id)
643
+	{
609 644
 		$exclue = "";
610 645
 		if (!empty(self::$config->system->trainer_blacklist)) {
611 646
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -631,7 +666,8 @@  discard block
 block discarded – undo
631 666
 	// Cron
632 667
 	/////////
633 668
 
634
-	public function getPokemonCountsActive() {
669
+	public function getPokemonCountsActive()
670
+	{
635 671
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) GROUP BY pokemon_id";
636 672
 		$result = pg_query($this->db, $req);
637 673
 		$counts = array();
@@ -641,7 +677,8 @@  discard block
 block discarded – undo
641 677
 		return $counts;
642 678
 	}
643 679
 
644
-	public function getPokemonCountsLastDay() {
680
+	public function getPokemonCountsLastDay()
681
+	{
645 682
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
646 683
 					FROM sightings
647 684
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -655,7 +692,8 @@  discard block
 block discarded – undo
655 692
 		return $counts;
656 693
 	}
657 694
 
658
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
695
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
696
+	{
659 697
 		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) > '".$last_update."'";
660 698
 		$req = "SELECT count, p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) AS last_timestamp, (TO_TIMESTAMP(expire_timestamp)) AS disappear_time_real, lat as latitude, lon as longitude
661 699
 					FROM sightings p
@@ -673,7 +711,8 @@  discard block
 block discarded – undo
673 711
 		return $data;
674 712
 	}
675 713
 
676
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
714
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
715
+	{
677 716
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND time_battle > '".$last_update."'";
678 717
 		$req = "SELECT time_battle AS start_timestamp, time_end as end, (TO_TIMESTAMP(time_end)) AS end_time_real, lat as latitude, lon as longitude, count
679 718
 					FROM raids r
@@ -690,14 +729,16 @@  discard block
 block discarded – undo
690 729
 		return $data;
691 730
 	}
692 731
 
693
-	public function getCaptchaCount() {
732
+	public function getCaptchaCount()
733
+	{
694 734
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
695 735
 		$result = pg_query($this->db, $req);
696 736
 		$data = pg_fetch_object($result);
697 737
 		return $data;
698 738
 	}
699 739
 
700
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
740
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
741
+	{
701 742
 		$pokemon_exclude_sql = "";
702 743
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
703 744
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
@@ -719,7 +760,8 @@  discard block
 block discarded – undo
719 760
 		return $nests;
720 761
 	}
721 762
 
722
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
763
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
764
+	{
723 765
 		$req = "SELECT COUNT(*) as total 
724 766
 					FROM spawnpoints 
725 767
  					WHERE lat >= ".$minLatitude." AND lat < ".$maxLatitude." AND lon >= ".$minLongitude." AND lon < ".$maxLongitude;
Please login to merge, or discard this patch.
core/cron/nests.cron.php 2 patches
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:"2016-07-17T00:00:00Z"][bbox:' . $minLatitude . ',' . $minLongitude . ',' . $maxLatitude . ',' . $maxLongitude . '];
34
+		$req = '[timeout:600][out:json][date:"2016-07-17T00:00:00Z"][bbox:'.$minLatitude.','.$minLongitude.','.$maxLatitude.','.$maxLongitude.'];
35 35
 				(
36 36
 					way["leisure"="park"];
37 37
 					way["landuse"="garden"];
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		$curl = curl_init($endpoint);
86 86
 
87 87
 		curl_setopt($curl, CURLOPT_POST, 1);
88
-		curl_setopt($curl, CURLOPT_POSTFIELDS, "data=" . urlencode($req));
89
-		curl_setopt($curl, CURLOPT_USERAGENT,"Worldopole/NestUpdater ".$config->infos->site_name);
88
+		curl_setopt($curl, CURLOPT_POSTFIELDS, "data=".urlencode($req));
89
+		curl_setopt($curl, CURLOPT_USERAGENT, "Worldopole/NestUpdater ".$config->infos->site_name);
90 90
 		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
91 91
 		curl_setopt($curl, CURLOPT_TIMEOUT, 660);
92 92
 		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 			echo "Got Error 429: Trying again in 5 Minutes...\n";
212 212
 			sleep(300);
213 213
 		} else {
214
-			echo "Error " . $status . " while getting nests from overpass-turbo. Aborting Nest Update.\n";
214
+			echo "Error ".$status." while getting nests from overpass-turbo. Aborting Nest Update.\n";
215 215
 			touch($nests_parks_file, $prevNestTime);
216 216
 			exit();
217 217
 		}
Please login to merge, or discard this patch.
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.