Failed Conditions
Pull Request — master (#363)
by Florian
03:15
created
core/process/queries/QueryManagerPostgresql.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,11 +3,13 @@  discard block
 block discarded – undo
3 3
 include_once __DIR__ . '/QueryManagerPostgresqlMonocleAlternate.php';
4 4
 
5 5
 
6
-abstract class QueryManagerPostgresql extends QueryManager {
6
+abstract class QueryManagerPostgresql extends QueryManager
7
+{
7 8
 
8 9
 	protected $db;
9 10
 
10
-	protected function __construct() {
11
+	protected function __construct()
12
+	{
11 13
 
12 14
 		$this->db = pg_connect("host=".SYS_DB_HOST." port=".SYS_DB_PORT." dbname=".SYS_DB_NAME." user=".SYS_DB_USER." password=".SYS_DB_PSWD);
13 15
 
@@ -17,7 +19,8 @@  discard block
 block discarded – undo
17 19
 		}
18 20
 	}
19 21
 
20
-	public function __destruct() {
22
+	public function __destruct()
23
+	{
21 24
 		pg_close($this->db);
22 25
 	}
23 26
 
@@ -25,7 +28,8 @@  discard block
 block discarded – undo
25 28
 	// Misc
26 29
 	/////////
27 30
 
28
-	public function getEcapedString($string) {
31
+	public function getEcapedString($string)
32
+	{
29 33
 		return pg_escape_string($this->db, $string);
30 34
 	}
31 35
 
Please login to merge, or discard this patch.
core/process/queries/QueryManagerMysql.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,11 +4,13 @@  discard block
 block discarded – undo
4 4
 include_once __DIR__ . '/QueryManagerMysqlMonocleAlternate.php';
5 5
 
6 6
 
7
-abstract class QueryManagerMysql extends QueryManager {
7
+abstract class QueryManagerMysql extends QueryManager
8
+{
8 9
 
9 10
 	protected $mysqli;
10 11
 
11
-	protected function __construct() {
12
+	protected function __construct()
13
+	{
12 14
 		$this->mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
13 15
 		if ($this->mysqli->connect_error != '') {
14 16
 			header('Location:'.HOST_URL.'offline.html');
@@ -22,7 +24,8 @@  discard block
 block discarded – undo
22 24
 		}
23 25
 	}
24 26
 
25
-	public function __destruct() {
27
+	public function __destruct()
28
+	{
26 29
 		$this->mysqli->close();
27 30
 	}
28 31
 
@@ -30,7 +33,8 @@  discard block
 block discarded – undo
30 33
 	// Misc
31 34
 	/////////
32 35
 
33
-	public function getEcapedString($string) {
36
+	public function getEcapedString($string)
37
+	{
34 38
 		return mysqli_real_escape_string($this->mysqli, $string);
35 39
 	}
36 40
 
Please login to merge, or discard this patch.
core/process/queries/QueryManager.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,13 +4,15 @@  discard block
 block discarded – undo
4 4
 include_once __DIR__ . '/QueryManagerMysql.php';
5 5
 include_once __DIR__ . '/QueryManagerPostgresql.php';
6 6
 
7
-abstract class QueryManager {
7
+abstract class QueryManager
8
+{
8 9
 
9 10
 	protected static $time_offset;
10 11
 	protected static $config;
11 12
 
12 13
 	private static $current;
13
-	public static function current() {
14
+	public static function current()
15
+	{
14 16
 		global $time_offset;
15 17
 
16 18
 		if (self::$current == null) {
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 		}
38 40
 		return self::$current;
39 41
 	}
40
-	private function __construct(){}
42
+	private function __construct()
43
+	{
44
+}
41 45
 
42 46
 	// Misc
43 47
 	abstract public function getEcapedString($string);
Please login to merge, or discard this patch.
core/cron/crontabs.include.php 1 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/cron/nests.cron.php 1 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.
functions.php 1 patch
Braces   +33 added lines, -17 removed lines patch added patch discarded remove patch
@@ -181,7 +181,8 @@  discard block
 block discarded – undo
181 181
 //
182 182
 // Retruns max depth of array
183 183
 ########################################################################
184
-function get_depth($arr) {
184
+function get_depth($arr)
185
+{
185 186
 	$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));
186 187
 	$depth = 0;
187 188
 	foreach ($it as $v) {
@@ -199,12 +200,16 @@  discard block
 block discarded – undo
199 200
 //
200 201
 // Return all pokemon with data at a certain tree depth
201 202
 ########################################################################
202
-function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) {
203
-	if ($depth == $currentDepth) { // Found depth
203
+function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0)
204
+{
205
+	if ($depth == $currentDepth) {
206
+// Found depth
204 207
 		return tree_remove_bellow($trees, $max_pokemon);
205
-	} else { // Go deeper
208
+	} else {
209
+// Go deeper
206 210
 		$arr = array();
207
-		foreach ($trees as $temp) { // Go into all trees
211
+		foreach ($trees as $temp) {
212
+// Go into all trees
208 213
 			$tree = $temp->evolutions;
209 214
 			$results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon);
210 215
 			$arr = tree_check_array($results, $arr, $depth - $currentDepth == 1);
@@ -216,12 +221,16 @@  discard block
 block discarded – undo
216 221
 ########################################################################
217 222
 // used in get_tree_at_depth
218 223
 ########################################################################
219
-function tree_check_array($array_check, $array_add, $correct_arrow) {
224
+function tree_check_array($array_check, $array_add, $correct_arrow)
225
+{
220 226
 	$count = count($array_check);
221 227
 	$i = 0;
222
-	if (!is_null($array_check)) { // check if exists
223
-		foreach ($array_check as $res) { // Check if above, equal or bellow center
224
-			if ($count != 1 && $correct_arrow) { // only add arrow once
228
+	if (!is_null($array_check)) {
229
+// check if exists
230
+		foreach ($array_check as $res) {
231
+// Check if above, equal or bellow center
232
+			if ($count != 1 && $correct_arrow) {
233
+// only add arrow once
225 234
 				$num = $i / ($count - 1);
226 235
 				if ($num < 0.5) {
227 236
 					$res->array_sufix = "_up";
@@ -249,7 +258,8 @@  discard block
 block discarded – undo
249 258
 		return null;
250 259
 	}
251 260
 	$arr = array();
252
-	foreach ($tree as $item) { // Check if above, equal or bellow center
261
+	foreach ($tree as $item) {
262
+// Check if above, equal or bellow center
253 263
 		if ($item->id <= $max_pokemon) {
254 264
 			$arr[] = $item;
255 265
 		}
@@ -283,7 +293,8 @@  discard block
 block discarded – undo
283 293
 ########################################################################
284 294
 // check if point is inside porygon
285 295
 ########################################################################
286
-function pointIsInsidePolygon($lat, $lng, $geos, $bounds) {
296
+function pointIsInsidePolygon($lat, $lng, $geos, $bounds)
297
+{
287 298
 	if ($lat >= $bounds["minlat"] && $lat <= $bounds["maxlat"] && $lng >= $bounds["minlon"] && $lng <= $bounds["maxlon"]) {
288 299
 
289 300
 		$intersections = 0;
@@ -292,15 +303,18 @@  discard block
 block discarded – undo
292 303
 		for ($i = 1; $i < $geos_count; $i++) {
293 304
 			$geo1 = $geos[$i - 1];
294 305
 			$geo2 = $geos[$i];
295
-			if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) { // On one of the coords
306
+			if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) {
307
+// On one of the coords
296 308
 				return true;
297 309
 			}
298
-			if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) { // Check if point is on an horizontal polygon boundary
310
+			if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) {
311
+// Check if point is on an horizontal polygon boundary
299 312
 				return true;
300 313
 			}
301 314
 			if ($lng > min($geo1['lng'], $geo2['lng']) and $lng <= max($geo1['lng'], $geo2['lng']) and $lat <= max($geo1['lat'], $geo2['lat']) and $geo1['lng'] != $geo2['lng']) {
302 315
 				$xinters = ($lng - $geo1['lng']) * ($geo2['lat'] - $geo1['lat']) / ($geo2['lng'] - $geo1['lng']) + $geo1['lat'];
303
-				if ($xinters == $lat) { // Check if point is on the polygon boundary (other than horizontal)
316
+				if ($xinters == $lat) {
317
+// Check if point is on the polygon boundary (other than horizontal)
304 318
 					return true;
305 319
 				}
306 320
 				if ($geo1['lat'] == $geo2['lat'] || $lat <= $xinters) {
@@ -322,7 +336,8 @@  discard block
 block discarded – undo
322 336
 ########################################################################
323 337
 // check if $boundsIn is inside (or equal to) $boundsOut
324 338
 ########################################################################
325
-function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut) {
339
+function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut)
340
+{
326 341
 	if ($boundsIn["minlat"] >= $boundsOut["minlat"] && $boundsIn["maxlat"] <= $boundsOut["maxlat"] && $boundsIn["minlon"] >= $boundsOut["minlon"] && $boundsIn["maxlon"] <= $boundsOut["maxlon"]) {
327 342
 		$insideCount = 0;
328 343
 		foreach ($geoIn as $coord) {
@@ -339,7 +354,8 @@  discard block
 block discarded – undo
339 354
 ########################################################################
340 355
 // compine outer ways into porygon
341 356
 ########################################################################
342
-function combineOuter($outers) {
357
+function combineOuter($outers)
358
+{
343 359
 	$polygons = array();
344 360
 	$index = 0;
345 361
 	$count = 0;
@@ -372,7 +388,7 @@  discard block
 block discarded – undo
372 388
 			
373 389
 			$firstElePoly = $polygons[$index][0];
374 390
 			$lastElePoly = $polygons[$index][count($polygons[$index]) - 1];
375
-			if ($firstElePoly == $lastElePoly){
391
+			if ($firstElePoly == $lastElePoly) {
376 392
 				$index++;
377 393
 			}
378 394
 		}
Please login to merge, or discard this patch.
core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 patch
Braces   +84 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql {
3
+class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM sightings";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM forts";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestops";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,26 +73,30 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$data = (object) array("total" => 0);
79 87
 		return $data;
80 88
 	}
81 89
 
82
-	function getTotalGyms() {
90
+	function getTotalGyms()
91
+	{
83 92
 		$req = "SELECT COUNT(*) AS total FROM forts";
84 93
 		$result = $this->mysqli->query($req);
85 94
 		$data = $result->fetch_object();
86 95
 		return $data;
87 96
 	}
88 97
 
89
-	function getTotalRaids() {
98
+	function getTotalRaids()
99
+	{
90 100
 		$req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= UNIX_TIMESTAMP() AND time_end >= UNIX_TIMESTAMP()";
91 101
 		$result = $this->mysqli->query($req);
92 102
 		$data = $result->fetch_object();
@@ -94,7 +104,8 @@  discard block
 block discarded – undo
94 104
 	}
95 105
 
96 106
 
97
-	function getTotalGymsForTeam($team_id) {
107
+	function getTotalGymsForTeam($team_id)
108
+	{
98 109
 		$req = "SELECT COUNT(*) AS total
99 110
 					FROM forts f
100 111
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -104,7 +115,8 @@  discard block
 block discarded – undo
104 115
 		return $data;
105 116
 	}
106 117
 
107
-	function getRecentAll() {
118
+	function getRecentAll()
119
+	{
108 120
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
109 121
               lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
110 122
               FROM sightings
@@ -120,7 +132,8 @@  discard block
 block discarded – undo
120 132
 		return $data;
121 133
 	}
122 134
 
123
-	function getRecentMythic($mythic_pokemon) {
135
+	function getRecentMythic($mythic_pokemon)
136
+	{
124 137
 		$req = "SELECT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
125 138
                 lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
126 139
                 FROM sightings
@@ -141,7 +154,8 @@  discard block
 block discarded – undo
141 154
 	// Single Pokemon
142 155
 	///////////////////
143 156
 
144
-	function getGymsProtectedByPokemon($pokemon_id) {
157
+	function getGymsProtectedByPokemon($pokemon_id)
158
+	{
145 159
 		$req = "SELECT COUNT(f.id) AS total
146 160
 					FROM forts f
147 161
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -151,7 +165,8 @@  discard block
 block discarded – undo
151 165
 		return $data;
152 166
 	}
153 167
 
154
-	function getPokemonLastSeen($pokemon_id) {
168
+	function getPokemonLastSeen($pokemon_id)
169
+	{
155 170
 		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
156 171
                 FROM sightings
157 172
                 WHERE pokemon_id = '".$pokemon_id."'
@@ -162,7 +177,8 @@  discard block
 block discarded – undo
162 177
 		return $data;
163 178
 	}
164 179
 
165
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
180
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
181
+	{
166 182
 		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS distime, pokemon_id as pokemon_id, FROM_UNIXTIME(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
167 183
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
168 184
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form
@@ -179,7 +195,8 @@  discard block
 block discarded – undo
179 195
 		return $top;
180 196
 	}
181 197
 
182
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
198
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
199
+	{
183 200
 		$trainer_blacklist = "";
184 201
 		if (!empty(self::$config->system->trainer_blacklist)) {
185 202
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -200,7 +217,8 @@  discard block
 block discarded – undo
200 217
 		return $toptrainer;
201 218
 	}
202 219
 
203
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
220
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
221
+	{
204 222
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
205 223
 			. "AND FROM_UNIXTIME(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
206 224
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000";
@@ -212,7 +230,8 @@  discard block
 block discarded – undo
212 230
 		return $points;
213 231
 	}
214 232
 
215
-	public function getPokemonGraph($pokemon_id) {
233
+	public function getPokemonGraph($pokemon_id)
234
+	{
216 235
 		$req = "SELECT COUNT(*) AS total, HOUR(disappear_time) AS disappear_hour
217 236
 					FROM (SELECT FROM_UNIXTIME(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
218 237
 				GROUP BY disappear_hour
@@ -228,7 +247,8 @@  discard block
 block discarded – undo
228 247
 		return $array;
229 248
 	}
230 249
 
231
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
250
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
251
+	{
232 252
 		$inmap_pkms_filter = "";
233 253
 		$where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = " . $pokemon_id;
234 254
 
@@ -263,14 +283,16 @@  discard block
 block discarded – undo
263 283
 		return $spawns;
264 284
 	}
265 285
 
266
-	public function getPokemonSliderMinMax() {
286
+	public function getPokemonSliderMinMax()
287
+	{
267 288
 		$req = "SELECT FROM_UNIXTIME(MIN(expire_timestamp)) AS min, FROM_UNIXTIME(MAX(expire_timestamp)) AS max FROM sightings";
268 289
 		$result = $this->mysqli->query($req);
269 290
 		$data = $result->fetch_object();
270 291
 		return $data;
271 292
 	}
272 293
 
273
-	public function getMapsCoords() {
294
+	public function getMapsCoords()
295
+	{
274 296
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
275 297
 		$result = $this->mysqli->query($req);
276 298
 		$data = $result->fetch_object();
@@ -283,14 +305,16 @@  discard block
 block discarded – undo
283 305
 	//////////////
284 306
 
285 307
 
286
-	function getTotalPokestops() {
308
+	function getTotalPokestops()
309
+	{
287 310
 		$req = "SELECT COUNT(*) as total FROM pokestops";
288 311
 		$result = $this->mysqli->query($req);
289 312
 		$data = $result->fetch_object();
290 313
 		return $data;
291 314
 	}
292 315
 
293
-	public function getAllPokestops() {
316
+	public function getAllPokestops()
317
+	{
294 318
 		$req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, UNIX_TIMESTAMP() AS now, null AS lure_expiration_real FROM pokestops";
295 319
 		$result = $this->mysqli->query($req);
296 320
 		$pokestops = array();
@@ -305,7 +329,8 @@  discard block
 block discarded – undo
305 329
 	// Gyms
306 330
 	/////////
307 331
 
308
-	function getTeamGuardians($team_id) {
332
+	function getTeamGuardians($team_id)
333
+	{
309 334
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id
310 335
 					FROM forts f
311 336
 					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))
@@ -320,7 +345,8 @@  discard block
 block discarded – undo
320 345
 		return $datas;
321 346
 	}
322 347
 
323
-	function getOwnedAndPoints($team_id) {
348
+	function getOwnedAndPoints($team_id)
349
+	{
324 350
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points
325 351
         			FROM forts f
326 352
 					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))
@@ -330,7 +356,8 @@  discard block
 block discarded – undo
330 356
 		return $data;
331 357
 	}
332 358
 
333
-	function getAllGyms() {
359
+	function getAllGyms()
360
+	{
334 361
 		$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
335 362
 					FROM forts f
336 363
 					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));";
@@ -342,7 +369,8 @@  discard block
 block discarded – undo
342 369
 		return $gyms;
343 370
 	}
344 371
 
345
-	public function getGymData($gym_id) {
372
+	public function getGymData($gym_id)
373
+	{
346 374
 		$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
347 375
 			FROM forts f
348 376
 			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))
@@ -352,7 +380,8 @@  discard block
 block discarded – undo
352 380
 		return $data;
353 381
 	}
354 382
 
355
-	public function getGymDefenders($gym_id) {
383
+	public function getGymDefenders($gym_id)
384
+	{
356 385
 		$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
357 386
 			FROM gym_defenders
358 387
 			WHERE fort_id='".$gym_id."'
@@ -370,7 +399,8 @@  discard block
 block discarded – undo
370 399
 	// Raids
371 400
 	///////////
372 401
 
373
-	public function getAllRaids($page) {
402
+	public function getAllRaids($page)
403
+	{
374 404
 		$limit = " LIMIT ".($page * 10).",10";
375 405
 		$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
376 406
 					FROM forts f
@@ -500,7 +530,8 @@  discard block
 block discarded – undo
500 530
 	// Trainers
501 531
 	//////////////
502 532
 
503
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
533
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
534
+	{
504 535
 		$ranking = $this->getTrainerLevelRanking();
505 536
 		$where = "";
506 537
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -552,7 +583,8 @@  discard block
 block discarded – undo
552 583
 		return $trainers;
553 584
 	}
554 585
 
555
-	public function getTrainerLevelRanking() {
586
+	public function getTrainerLevelRanking()
587
+	{
556 588
 		$exclue = "";
557 589
 		if (!empty(self::$config->system->trainer_blacklist)) {
558 590
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -573,7 +605,8 @@  discard block
 block discarded – undo
573 605
 		return $levelData;
574 606
 	}
575 607
 
576
-	public function getActivePokemon($trainer_name) {
608
+	public function getActivePokemon($trainer_name)
609
+	{
577 610
 		$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
578 611
 						FROM gym_defenders
579 612
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -586,7 +619,8 @@  discard block
 block discarded – undo
586 619
 		return $pokemon;
587 620
 	}
588 621
 
589
-	public function getInactivePokemon($trainer_name) {
622
+	public function getInactivePokemon($trainer_name)
623
+	{
590 624
 		$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
591 625
 					FROM gym_defenders
592 626
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -599,7 +633,8 @@  discard block
 block discarded – undo
599 633
 		return $pokemon;
600 634
 	}
601 635
 
602
-	public function getTrainerLevelCount($team_id) {
636
+	public function getTrainerLevelCount($team_id)
637
+	{
603 638
 		$exclue = "";
604 639
 		if (!empty(self::$config->system->trainer_blacklist)) {
605 640
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -625,7 +660,8 @@  discard block
 block discarded – undo
625 660
 	// Cron
626 661
 	/////////
627 662
 
628
-	public function getPokemonCountsActive() {
663
+	public function getPokemonCountsActive()
664
+	{
629 665
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() GROUP BY pokemon_id";
630 666
 		$result = $this->mysqli->query($req);
631 667
 		$counts = array();
@@ -635,7 +671,8 @@  discard block
 block discarded – undo
635 671
 		return $counts;
636 672
 	}
637 673
 
638
-	public function getPokemonCountsLastDay() {
674
+	public function getPokemonCountsLastDay()
675
+	{
639 676
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
640 677
 					FROM sightings
641 678
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -649,7 +686,8 @@  discard block
 block discarded – undo
649 686
 		return $counts;
650 687
 	}
651 688
 
652
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
689
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
690
+	{
653 691
 		$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."'";
654 692
 		$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
655 693
 					FROM sightings p
@@ -667,7 +705,8 @@  discard block
 block discarded – undo
667 705
 		return $data;
668 706
 	}
669 707
 
670
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
708
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
709
+	{
671 710
 		$where = "WHERE pokemon_id = '".$pokemon_id."AND".$last_update."'";
672 711
 		$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
673 712
 					FROM raids r
@@ -685,14 +724,16 @@  discard block
 block discarded – undo
685 724
 		return $data;
686 725
 	}
687 726
 
688
-	public function getCaptchaCount() {
727
+	public function getCaptchaCount()
728
+	{
689 729
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
690 730
 		$result = $this->mysqli->query($req);
691 731
 		$data = $result->fetch_object();
692 732
 		return $data;
693 733
 	}
694 734
 
695
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
735
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
736
+	{
696 737
 		$pokemon_exclude_sql = "";
697 738
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
698 739
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
@@ -714,7 +755,8 @@  discard block
 block discarded – undo
714 755
 		return $nests;
715 756
 	}
716 757
 
717
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
758
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
759
+	{
718 760
 		$req = "SELECT COUNT(*) as total 
719 761
 					FROM spawnpoints 
720 762
  					WHERE lat >= ".$minLatitude." AND lat < ".$maxLatitude." AND lon >= ".$minLongitude." AND lon < ".$maxLongitude;
Please login to merge, or discard this patch.
core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 1 patch
Braces   +84 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,13 +6,16 @@  discard block
 block discarded – undo
6 6
  * Time: 02:26
7 7
  */
8 8
 
9
-class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql {
9
+class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql
10
+{
10 11
 
11
-	public function __construct() {
12
+	public function __construct()
13
+	{
12 14
 		parent::__construct();
13 15
 	}
14 16
 
15
-	public function __destruct() {
17
+	public function __destruct()
18
+	{
16 19
 		parent::__destruct();
17 20
 	}
18 21
 
@@ -20,7 +23,8 @@  discard block
 block discarded – undo
20 23
 	// Tester
21 24
 	///////////
22 25
 
23
-	function testTotalPokemon() {
26
+	function testTotalPokemon()
27
+	{
24 28
 		$req = "SELECT COUNT(*) as total FROM sightings";
25 29
 		$result = pg_query($this->db, $req);
26 30
 		if ($result === false) {
@@ -36,7 +40,8 @@  discard block
 block discarded – undo
36 40
 		return 0;
37 41
 	}
38 42
 
39
-	function testTotalGyms() {
43
+	function testTotalGyms()
44
+	{
40 45
 		$req = "SELECT COUNT(*) as total FROM forts";
41 46
 		$result = pg_query($this->db, $req);
42 47
 		if ($result === false) {
@@ -52,7 +57,8 @@  discard block
 block discarded – undo
52 57
 		return 0;
53 58
 	}
54 59
 
55
-	function testTotalPokestops() {
60
+	function testTotalPokestops()
61
+	{
56 62
 		$req = "SELECT COUNT(*) as total FROM pokestops";
57 63
 		$result = pg_query($this->db, $req);
58 64
 		if ($result === false) {
@@ -73,26 +79,30 @@  discard block
 block discarded – undo
73 79
 	// Homepage
74 80
 	/////////////
75 81
 
76
-	function getTotalPokemon() {
82
+	function getTotalPokemon()
83
+	{
77 84
 		$req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW())";
78 85
 		$result = pg_query($this->db, $req);
79 86
 		$data = pg_fetch_object($result);
80 87
 		return $data;
81 88
 	}
82 89
 
83
-	function getTotalLures() {
90
+	function getTotalLures()
91
+	{
84 92
 		$data = (object) array("total" => 0);
85 93
 		return $data;
86 94
 	}
87 95
 
88
-	function getTotalGyms() {
96
+	function getTotalGyms()
97
+	{
89 98
 		$req = "SELECT COUNT(*) AS total FROM forts";
90 99
 		$result = pg_query($this->db, $req);
91 100
 		$data = pg_fetch_object($result);
92 101
 		return $data;
93 102
 	}
94 103
 
95
-	function getTotalRaids() {
104
+	function getTotalRaids()
105
+	{
96 106
 		$req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= EXTRACT(EPOCH FROM NOW()) AND time_end >= EXTRACT(EPOCH FROM NOW())";
97 107
 		$result = pg_query($this->db, $req);
98 108
 		$data = pg_fetch_object($result);
@@ -100,7 +110,8 @@  discard block
 block discarded – undo
100 110
 	}
101 111
 
102 112
 
103
-	function getTotalGymsForTeam($team_id) {
113
+	function getTotalGymsForTeam($team_id)
114
+	{
104 115
 		$req = "SELECT COUNT(*) AS total
105 116
 					FROM forts f
106 117
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -110,7 +121,8 @@  discard block
 block discarded – undo
110 121
 		return $data;
111 122
 	}
112 123
 
113
-	function getRecentAll() {
124
+	function getRecentAll()
125
+	{
114 126
 		$req = "SELECT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
115 127
               lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
116 128
               FROM sightings
@@ -126,7 +138,8 @@  discard block
 block discarded – undo
126 138
 		return $data;
127 139
 	}
128 140
 
129
-	function getRecentMythic($mythic_pokemon) {
141
+	function getRecentMythic($mythic_pokemon)
142
+	{
130 143
 		$req = "SELECT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
131 144
                 lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
132 145
                 FROM sightings
@@ -147,7 +160,8 @@  discard block
 block discarded – undo
147 160
 	// Single Pokemon
148 161
 	///////////////////
149 162
 
150
-	function getGymsProtectedByPokemon($pokemon_id) {
163
+	function getGymsProtectedByPokemon($pokemon_id)
164
+	{
151 165
 		$req = "SELECT COUNT(f.id) AS total
152 166
 					FROM forts f
153 167
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -157,7 +171,8 @@  discard block
 block discarded – undo
157 171
 		return $data;
158 172
 	}
159 173
 
160
-	function getPokemonLastSeen($pokemon_id) {
174
+	function getPokemonLastSeen($pokemon_id)
175
+	{
161 176
 		$req = "SELECT TO_TIMESTAMP(expire_timestamp) AS expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
162 177
                 FROM sightings
163 178
                 WHERE pokemon_id = '".$pokemon_id."'
@@ -168,7 +183,8 @@  discard block
 block discarded – undo
168 183
 		return $data;
169 184
 	}
170 185
 
171
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
186
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
187
+	{
172 188
 		$req = "SELECT expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS distime, pokemon_id as pokemon_id, TO_TIMESTAMP(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
173 189
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
174 190
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form
@@ -184,7 +200,8 @@  discard block
 block discarded – undo
184 200
 		return $top;
185 201
 	}
186 202
 
187
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
203
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
204
+	{
188 205
 		$trainer_blacklist = "";
189 206
 		if (!empty(self::$config->system->trainer_blacklist)) {
190 207
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -205,7 +222,8 @@  discard block
 block discarded – undo
205 222
 		return $toptrainer;
206 223
 	}
207 224
 
208
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
225
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
226
+	{
209 227
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
210 228
 			. "AND TO_TIMESTAMP(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
211 229
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000";
@@ -217,7 +235,8 @@  discard block
 block discarded – undo
217 235
 		return $points;
218 236
 	}
219 237
 
220
-	public function getPokemonGraph($pokemon_id) {
238
+	public function getPokemonGraph($pokemon_id)
239
+	{
221 240
 		$req = "SELECT COUNT(*) AS total, EXTRACT(HOUR FROM disappear_time) AS disappear_hour
222 241
 					FROM (SELECT TO_TIMESTAMP(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
223 242
 				GROUP BY disappear_hour
@@ -233,7 +252,8 @@  discard block
 block discarded – undo
233 252
 		return $array;
234 253
 	}
235 254
 
236
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
255
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
256
+	{
237 257
 		$inmap_pkms_filter = "";
238 258
 		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
239 259
 
@@ -268,14 +288,16 @@  discard block
 block discarded – undo
268 288
 		return $spawns;
269 289
 	}
270 290
 
271
-	public function getPokemonSliderMinMax() {
291
+	public function getPokemonSliderMinMax()
292
+	{
272 293
 		$req = "SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings";
273 294
 		$result = pg_query($this->db, $req);
274 295
 		$data = pg_fetch_object($result);
275 296
 		return $data;
276 297
 	}
277 298
 
278
-	public function getMapsCoords() {
299
+	public function getMapsCoords()
300
+	{
279 301
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
280 302
 		$result = pg_query($this->db, $req);
281 303
 		$data = pg_fetch_object($result);
@@ -288,14 +310,16 @@  discard block
 block discarded – undo
288 310
 	//////////////
289 311
 
290 312
 
291
-	function getTotalPokestops() {
313
+	function getTotalPokestops()
314
+	{
292 315
 		$req = "SELECT COUNT(*) as total FROM pokestops";
293 316
 		$result = pg_query($this->db, $req);
294 317
 		$data = pg_fetch_object($result);
295 318
 		return $data;
296 319
 	}
297 320
 
298
-	public function getAllPokestops() {
321
+	public function getAllPokestops()
322
+	{
299 323
 		$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";
300 324
 		$result = pg_query($this->db, $req);
301 325
 		$pokestops = array();
@@ -310,7 +334,8 @@  discard block
 block discarded – undo
310 334
 	// Gyms
311 335
 	/////////
312 336
 
313
-	function getTeamGuardians($team_id) {
337
+	function getTeamGuardians($team_id)
338
+	{
314 339
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id
315 340
 					FROM forts f
316 341
 					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))
@@ -325,7 +350,8 @@  discard block
 block discarded – undo
325 350
 		return $datas;
326 351
 	}
327 352
 
328
-	function getOwnedAndPoints($team_id) {
353
+	function getOwnedAndPoints($team_id)
354
+	{
329 355
 		$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points
330 356
         			FROM forts f
331 357
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -335,7 +361,8 @@  discard block
 block discarded – undo
335 361
 		return $data;
336 362
 	}
337 363
 
338
-	function getAllGyms() {
364
+	function getAllGyms()
365
+	{
339 366
 		$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
340 367
 					FROM forts f
341 368
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))";
@@ -347,7 +374,8 @@  discard block
 block discarded – undo
347 374
 		return $gyms;
348 375
 	}
349 376
 
350
-	public function getGymData($gym_id) {
377
+	public function getGymData($gym_id)
378
+	{
351 379
 		$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
352 380
 			FROM forts f
353 381
 			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))
@@ -358,7 +386,8 @@  discard block
 block discarded – undo
358 386
 		return $data;
359 387
 	}
360 388
 
361
-	public function getGymDefenders($gym_id) {
389
+	public function getGymDefenders($gym_id)
390
+	{
362 391
 		$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
363 392
 			FROM gym_defenders
364 393
 			WHERE fort_id='".$gym_id."'
@@ -484,7 +513,8 @@  discard block
 block discarded – undo
484 513
 	// Raids
485 514
 	///////////
486 515
 
487
-	public function getAllRaids($page) {
516
+	public function getAllRaids($page)
517
+	{
488 518
 		$limit = " LIMIT 10 OFFSET ". ($page * 10);
489 519
 		$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
490 520
 					FROM forts f
@@ -505,7 +535,8 @@  discard block
 block discarded – undo
505 535
 	// Trainers
506 536
 	//////////////
507 537
 
508
-	public function getTrainers($trainer_name, $team, $page, $rankingNumber) {
538
+	public function getTrainers($trainer_name, $team, $page, $rankingNumber)
539
+	{
509 540
 		$ranking = $this->getTrainerLevelRanking();
510 541
 		$where = "";
511 542
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -557,7 +588,8 @@  discard block
 block discarded – undo
557 588
 		return $trainers;
558 589
 	}
559 590
 
560
-	public function getTrainerLevelRanking() {
591
+	public function getTrainerLevelRanking()
592
+	{
561 593
 		$exclue = "";
562 594
 		if (!empty(self::$config->system->trainer_blacklist)) {
563 595
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -578,7 +610,8 @@  discard block
 block discarded – undo
578 610
 		return $levelData;
579 611
 	}
580 612
 
581
-	public function getActivePokemon($trainer_name) {
613
+	public function getActivePokemon($trainer_name)
614
+	{
582 615
 		$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
583 616
 						FROM gym_defenders
584 617
 						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
@@ -591,7 +624,8 @@  discard block
 block discarded – undo
591 624
 		return $pokemon;
592 625
 	}
593 626
 
594
-	public function getInactivePokemon($trainer_name) {
627
+	public function getInactivePokemon($trainer_name)
628
+	{
595 629
 		$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
596 630
 					FROM gym_defenders
597 631
 					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
@@ -604,7 +638,8 @@  discard block
 block discarded – undo
604 638
 		return $pokemon;
605 639
 	}
606 640
 
607
-	public function getTrainerLevelCount($team_id) {
641
+	public function getTrainerLevelCount($team_id)
642
+	{
608 643
 		$exclue = "";
609 644
 		if (!empty(self::$config->system->trainer_blacklist)) {
610 645
 			$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -630,7 +665,8 @@  discard block
 block discarded – undo
630 665
 	// Cron
631 666
 	/////////
632 667
 
633
-	public function getPokemonCountsActive() {
668
+	public function getPokemonCountsActive()
669
+	{
634 670
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) GROUP BY pokemon_id";
635 671
 		$result = pg_query($this->db, $req);
636 672
 		$counts = array();
@@ -640,7 +676,8 @@  discard block
 block discarded – undo
640 676
 		return $counts;
641 677
 	}
642 678
 
643
-	public function getPokemonCountsLastDay() {
679
+	public function getPokemonCountsLastDay()
680
+	{
644 681
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
645 682
 					FROM sightings
646 683
 					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
@@ -654,7 +691,8 @@  discard block
 block discarded – undo
654 691
 		return $counts;
655 692
 	}
656 693
 
657
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
694
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
695
+	{
658 696
 		$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."'";
659 697
 		$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
660 698
 					FROM sightings p
@@ -672,7 +710,8 @@  discard block
 block discarded – undo
672 710
 		return $data;
673 711
 	}
674 712
 
675
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
713
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
714
+	{
676 715
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND time_battle > '".$last_update."'";
677 716
 		$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
678 717
 					FROM raids r
@@ -689,14 +728,16 @@  discard block
 block discarded – undo
689 728
 		return $data;
690 729
 	}
691 730
 
692
-	public function getCaptchaCount() {
731
+	public function getCaptchaCount()
732
+	{
693 733
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
694 734
 		$result = pg_query($this->db, $req);
695 735
 		$data = pg_fetch_object($result);
696 736
 		return $data;
697 737
 	}
698 738
 
699
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
739
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
740
+	{
700 741
 		$pokemon_exclude_sql = "";
701 742
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
702 743
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
@@ -718,7 +759,8 @@  discard block
 block discarded – undo
718 759
 		return $nests;
719 760
 	}
720 761
 
721
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
762
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
763
+	{
722 764
 		$req = "SELECT COUNT(*) as total 
723 765
 					FROM spawnpoints 
724 766
  					WHERE lat >= ".$minLatitude." AND lat < ".$maxLatitude." AND lon >= ".$minLongitude." AND lon < ".$maxLongitude;
Please login to merge, or discard this patch.
core/process/queries/QueryManagerMysqlRocketmap.php 1 patch
Braces   +94 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-final class QueryManagerMysqlRocketmap extends QueryManagerMysql {
3
+final class QueryManagerMysqlRocketmap extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM pokemon";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM gym";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestop";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,42 +73,48 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
79 87
 		$result = $this->mysqli->query($req);
80 88
 		$data = $result->fetch_object();
81 89
 		return $data;
82 90
 	}
83 91
 
84
-	function getTotalGyms() {
92
+	function getTotalGyms()
93
+	{
85 94
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
86 95
 		$result = $this->mysqli->query($req);
87 96
 		$data = $result->fetch_object();
88 97
 		return $data;
89 98
 	}
90 99
 
91
-	function getTotalRaids() {
100
+	function getTotalRaids()
101
+	{
92 102
 		$req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND  end >= UTC_TIMESTAMP()";
93 103
 		$result = $this->mysqli->query($req);
94 104
 		$data = $result->fetch_object();
95 105
 		return $data;
96 106
 	}
97 107
 
98
-	function getTotalGymsForTeam($team_id) {
108
+	function getTotalGymsForTeam($team_id)
109
+	{
99 110
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '".$team_id."'";
100 111
 		$result = $this->mysqli->query($req);
101 112
 		$data = $result->fetch_object();
102 113
 		return $data;
103 114
 	}
104 115
 
105
-	function getRecentAll() {
116
+	function getRecentAll()
117
+	{
106 118
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
107 119
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
108 120
 					FROM pokemon
@@ -118,7 +130,8 @@  discard block
 block discarded – undo
118 130
 		return $data;
119 131
 	}
120 132
 
121
-	function getRecentMythic($mythic_pokemons) {
133
+	function getRecentMythic($mythic_pokemons)
134
+	{
122 135
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
123 136
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
124 137
 					FROM pokemon
@@ -139,14 +152,16 @@  discard block
 block discarded – undo
139 152
 	// Single Pokemon
140 153
 	///////////////////
141 154
 
142
-	function getGymsProtectedByPokemon($pokemon_id) {
155
+	function getGymsProtectedByPokemon($pokemon_id)
156
+	{
143 157
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'";
144 158
 		$result = $this->mysqli->query($req);
145 159
 		$data = $result->fetch_object();
146 160
 		return $data;
147 161
 	}
148 162
 
149
-	function getPokemonLastSeen($pokemon_id) {
163
+	function getPokemonLastSeen($pokemon_id)
164
+	{
150 165
 		$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude
151 166
 							FROM pokemon
152 167
 							WHERE pokemon_id = '".$pokemon_id."'
@@ -157,7 +172,8 @@  discard block
 block discarded – undo
157 172
 		return $data;
158 173
 	}
159 174
 
160
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
175
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
176
+	{
161 177
 		$req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude,
162 178
 							cp, individual_attack, individual_defense, individual_stamina,
163 179
 							ROUND(100*(individual_attack+individual_defense+individual_stamina)/45,1) AS IV, move_1, move_2, form
@@ -174,7 +190,8 @@  discard block
 block discarded – undo
174 190
 		return $top;
175 191
 	}
176 192
 
177
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
193
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
194
+	{
178 195
 		$trainer_blacklist = "";
179 196
 		if (!empty(self::$config->system->trainer_blacklist)) {
180 197
 			$trainer_blacklist = " AND trainer_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -195,7 +212,8 @@  discard block
 block discarded – undo
195 212
 		return $toptrainer;
196 213
 	}
197 214
 
198
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
215
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
216
+	{
199 217
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
200 218
 			. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
201 219
 		$req 		= "SELECT latitude, longitude FROM pokemon".$where." LIMIT 10000";
@@ -207,7 +225,8 @@  discard block
 block discarded – undo
207 225
 		return $points;
208 226
 	}
209 227
 
210
-	public function getPokemonGraph($pokemon_id) {
228
+	public function getPokemonGraph($pokemon_id)
229
+	{
211 230
 		$req = "SELECT COUNT(*) AS total,
212 231
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_hour
213 232
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
@@ -224,7 +243,8 @@  discard block
 block discarded – undo
224 243
 		return $array;
225 244
 	}
226 245
 
227
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
246
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
247
+	{
228 248
 		$inmap_pkms_filter = "";
229 249
 		$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id;
230 250
 
@@ -257,14 +277,16 @@  discard block
 block discarded – undo
257 277
 		return $spawns;
258 278
 	}
259 279
 
260
-	public function getPokemonSliderMinMax() {
280
+	public function getPokemonSliderMinMax()
281
+	{
261 282
 		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
262 283
 		$result = $this->mysqli->query($req);
263 284
 		$data = $result->fetch_object();
264 285
 		return $data;
265 286
 	}
266 287
 
267
-	public function getMapsCoords() {
288
+	public function getMapsCoords()
289
+	{
268 290
 		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
269 291
 		$result = $this->mysqli->query($req);
270 292
 		$data = $result->fetch_object();
@@ -276,14 +298,16 @@  discard block
 block discarded – undo
276 298
 	// Pokestops
277 299
 	//////////////
278 300
 
279
-	function getTotalPokestops() {
301
+	function getTotalPokestops()
302
+	{
280 303
 		$req = "SELECT COUNT(*) as total FROM pokestop";
281 304
 		$result = $this->mysqli->query($req);
282 305
 		$data = $result->fetch_object();
283 306
 		return $data;
284 307
 	}
285 308
 
286
-	public function getAllPokestops() {
309
+	public function getAllPokestops()
310
+	{
287 311
 		$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";
288 312
 		$result = $this->mysqli->query($req);
289 313
 		$pokestops = array();
@@ -298,7 +322,8 @@  discard block
 block discarded – undo
298 322
 	// Gyms
299 323
 	/////////
300 324
 
301
-	function getTeamGuardians($team_id) {
325
+	function getTeamGuardians($team_id)
326
+	{
302 327
 		$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 328
 		$result = $this->mysqli->query($req);
304 329
 		$datas = array();
@@ -308,14 +333,16 @@  discard block
 block discarded – undo
308 333
 		return $datas;
309 334
 	}
310 335
 
311
-	function getOwnedAndPoints($team_id) {
336
+	function getOwnedAndPoints($team_id)
337
+	{
312 338
 		$req 	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
313 339
 		$result = $this->mysqli->query($req);
314 340
 		$data = $result->fetch_object();
315 341
 		return $data;
316 342
 	}
317 343
 
318
-	function getAllGyms() {
344
+	function getAllGyms()
345
+	{
319 346
 		$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";
320 347
 		$result = $this->mysqli->query($req);
321 348
 		$gyms = array();
@@ -325,7 +352,8 @@  discard block
 block discarded – undo
325 352
 		return $gyms;
326 353
 	}
327 354
 
328
-	public function getGymData($gym_id) {
355
+	public function getGymData($gym_id)
356
+	{
329 357
 		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
330 358
 					(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
331 359
 					FROM gymdetails
@@ -336,7 +364,8 @@  discard block
 block discarded – undo
336 364
 		return $data;
337 365
 	}
338 366
 
339
-	public function getGymDefenders($gym_id) {
367
+	public function getGymDefenders($gym_id)
368
+	{
340 369
 		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
341 370
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
342 371
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
@@ -356,7 +385,8 @@  discard block
 block discarded – undo
356 385
 	// Gym History
357 386
 	////////////////
358 387
 
359
-	public function getGymHistories($gym_name, $team, $page, $ranking) {
388
+	public function getGymHistories($gym_name, $team, $page, $ranking)
389
+	{
360 390
 		$where = '';
361 391
 		if (isset($gym_name) && $gym_name != '') {
362 392
 			$where = " WHERE name LIKE '%".$gym_name."%'";
@@ -391,7 +421,8 @@  discard block
 block discarded – undo
391 421
 		return $gym_history;
392 422
 	}
393 423
 
394
-	public function getGymHistoriesPokemon($gym_id) {
424
+	public function getGymHistoriesPokemon($gym_id)
425
+	{
395 426
 		$req = "SELECT DISTINCT gymmember.pokemon_uid, pokemon_id, cp, trainer_name
396 427
 					FROM gymmember
397 428
 					LEFT JOIN gympokemon
@@ -406,7 +437,8 @@  discard block
 block discarded – undo
406 437
 		return $pokemons;
407 438
 	}
408 439
 
409
-	public function getHistoryForGym($page, $gym_id) {
440
+	public function getHistoryForGym($page, $gym_id)
441
+	{
410 442
 		if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) {
411 443
 			$pageSize = 25;
412 444
 		} else {
@@ -442,7 +474,8 @@  discard block
 block discarded – undo
442 474
 		return array("last_page" => $last_page, "data" => $history);
443 475
 	}
444 476
 
445
-	private function getHistoryForGymPokemon($pkm_uids) {
477
+	private function getHistoryForGymPokemon($pkm_uids)
478
+	{
446 479
 		$req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name
447 480
 								FROM gympokemon
448 481
 								WHERE pokemon_uid IN ('".implode("','", $pkm_uids)."')
@@ -460,7 +493,8 @@  discard block
 block discarded – undo
460 493
 	// Raids
461 494
 	///////////
462 495
 
463
-	public function getAllRaids($page) {
496
+	public function getAllRaids($page)
497
+	{
464 498
 		$limit = " LIMIT ".($page * 10).",10";
465 499
 		$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
466 500
 					JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
@@ -480,7 +514,8 @@  discard block
 block discarded – undo
480 514
 	// Trainers
481 515
 	//////////////
482 516
 
483
-	public function getTrainers($trainer_name, $team, $page, $ranking) {
517
+	public function getTrainers($trainer_name, $team, $page, $ranking)
518
+	{
484 519
 		$trainers = $this->getTrainerData($trainer_name, $team, $page, $ranking);
485 520
 		foreach ($trainers as $trainer) {
486 521
 
@@ -505,7 +540,8 @@  discard block
 block discarded – undo
505 540
 		return $trainers;
506 541
 	}
507 542
 
508
-	public function getTrainerLevelCount($team_id) {
543
+	public function getTrainerLevelCount($team_id)
544
+	{
509 545
 		$req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'";
510 546
 		if (!empty(self::$config->system->trainer_blacklist)) {
511 547
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -526,7 +562,8 @@  discard block
 block discarded – undo
526 562
 		return $levelData;
527 563
 	}
528 564
 
529
-	private function getTrainerData($trainer_name, $team, $page, $ranking) {
565
+	private function getTrainerData($trainer_name, $team, $page, $ranking)
566
+	{
530 567
 		$where = "";
531 568
 
532 569
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -567,7 +604,8 @@  discard block
 block discarded – undo
567 604
 		return $trainers;
568 605
 	}
569 606
 
570
-	private function getTrainerLevelRating($level) {
607
+	private function getTrainerLevelRating($level)
608
+	{
571 609
 		$req = "SELECT COUNT(1) AS rank FROM trainer WHERE level = ".$level;
572 610
 		if (!empty(self::$config->system->trainer_blacklist)) {
573 611
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -577,7 +615,8 @@  discard block
 block discarded – undo
577 615
 		return $data;
578 616
 	}
579 617
 
580
-	private function getTrainerActivePokemon($trainer_name){
618
+	private function getTrainerActivePokemon($trainer_name)
619
+	{
581 620
 		$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
582 621
 					FROM gympokemon INNER JOIN
583 622
 					(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
@@ -592,7 +631,8 @@  discard block
 block discarded – undo
592 631
 		return $pokemons;
593 632
 	}
594 633
 
595
-	private function getTrainerInactivePokemon($trainer_name){
634
+	private function getTrainerInactivePokemon($trainer_name)
635
+	{
596 636
 		$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
597 637
 					FROM gympokemon LEFT JOIN
598 638
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -612,7 +652,8 @@  discard block
 block discarded – undo
612 652
 	// Cron
613 653
 	/////////
614 654
 
615
-	public function getPokemonCountsActive() {
655
+	public function getPokemonCountsActive()
656
+	{
616 657
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP() GROUP BY pokemon_id";
617 658
 		$result = $this->mysqli->query($req);
618 659
 		$counts = array();
@@ -622,7 +663,8 @@  discard block
 block discarded – undo
622 663
 		return $counts;
623 664
 	}
624 665
 
625
-	public function getPokemonCountsLastDay() {
666
+	public function getPokemonCountsLastDay()
667
+	{
626 668
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
627 669
 					FROM pokemon
628 670
 					WHERE disappear_time >= (SELECT MAX(disappear_time) FROM pokemon) - INTERVAL 1 DAY
@@ -636,7 +678,8 @@  discard block
 block discarded – undo
636 678
 		return $counts;
637 679
 	}
638 680
 
639
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
681
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
682
+	{
640 683
 		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) > '".$last_update."'";
641 684
 		$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
642 685
 				FROM pokemon p
@@ -654,7 +697,8 @@  discard block
 block discarded – undo
654 697
 		return $data;
655 698
 	}
656 699
 
657
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
700
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
701
+	{
658 702
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND UNIX_TIMESTAMP(start) > '".$last_update."'";
659 703
 		$req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".self::$time_offset."')) AS end_time_real, latitude, longitude, count
660 704
                 FROM raid r
@@ -672,14 +716,16 @@  discard block
 block discarded – undo
672 716
 		return $data;
673 717
 	}
674 718
 
675
-	public function getCaptchaCount() {
719
+	public function getCaptchaCount()
720
+	{
676 721
 		$req = "SELECT SUM(accounts_captcha) AS total FROM mainworker";
677 722
 		$result = $this->mysqli->query($req);
678 723
 		$data = $result->fetch_object();
679 724
 		return $data;
680 725
 	}
681 726
 
682
-	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
727
+	public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
728
+	{
683 729
 		$pokemon_exclude_sql = "";
684 730
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
685 731
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
@@ -701,7 +747,8 @@  discard block
 block discarded – undo
701 747
 		return $nests;
702 748
 	}
703 749
 
704
-	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude) {
750
+	public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
751
+	{
705 752
 		$req = "SELECT COUNT(*) as total
706 753
 					FROM spawnpoint
707 754
  					WHERE latitude >= ".$minLatitude." AND latitude < ".$maxLatitude." AND longitude >= ".$minLongitude." AND longitude < ".$maxLongitude;
Please login to merge, or discard this patch.