Failed Conditions
Pull Request — master (#353)
by Florian
03:22
created
core/process/locales.loader.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @return array Sorted list of "accept" options
21 21
  */
22
-$sortAccept = function ($header) {
22
+$sortAccept = function ($header)
23
+{
23 24
 	$matches = array();
24 25
 	foreach (explode(',', $header) as $option) {
25 26
 		$option = array_map('trim', explode(';', $option));
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
  *
53 54
  * @return string|NULL a matched option, or NULL if no match
54 55
  */
55
-$matchAccept = function ($header, $supported) use ($sortAccept) {
56
+$matchAccept = function ($header, $supported) use ($sortAccept)
57
+{
56 58
 	$matches = $sortAccept($header);
57 59
 	foreach ($matches as $key => $q) {
58 60
 		if (isset($supported[$key])) {
@@ -83,7 +85,8 @@  discard block
 block discarded – undo
83 85
  *
84 86
  * @return string The negotiated language result or the supplied default.
85 87
  */
86
-$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) {
88
+$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept)
89
+{
87 90
 	$supp = array();
88 91
 	foreach ($supported as $lang => $isSupported) {
89 92
 		if ($isSupported) {
Please login to merge, or discard this patch.
functions.php 1 patch
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -177,7 +177,8 @@  discard block
 block discarded – undo
177 177
 //
178 178
 // Retruns max depth of array
179 179
 ########################################################################
180
-function get_depth($arr) {
180
+function get_depth($arr)
181
+{
181 182
 	$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));
182 183
 	$depth = 0;
183 184
 	foreach ($it as $v) {
@@ -195,12 +196,16 @@  discard block
 block discarded – undo
195 196
 //
196 197
 // Return all pokemon with data at a certain tree depth
197 198
 ########################################################################
198
-function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) {
199
-	if ($depth == $currentDepth) { // Found depth
199
+function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0)
200
+{
201
+	if ($depth == $currentDepth) {
202
+// Found depth
200 203
 		return tree_remove_bellow($trees, $max_pokemon);
201
-	} else { // Go deeper
204
+	} else {
205
+// Go deeper
202 206
 		$arr = array();
203
-		foreach ($trees as $temp) { // Go into all trees
207
+		foreach ($trees as $temp) {
208
+// Go into all trees
204 209
 			$tree = $temp->evolutions;
205 210
 			$results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon);
206 211
 			$arr = tree_check_array($results, $arr, $depth - $currentDepth == 1);
@@ -212,12 +217,16 @@  discard block
 block discarded – undo
212 217
 ########################################################################
213 218
 // used in get_tree_at_depth
214 219
 ########################################################################
215
-function tree_check_array($array_check, $array_add, $correct_arrow) {
220
+function tree_check_array($array_check, $array_add, $correct_arrow)
221
+{
216 222
 	$count = count($array_check);
217 223
 	$i = 0;
218
-	if (!is_null($array_check)) { // check if exists
219
-		foreach ($array_check as $res) { // Check if above, equal or bellow center
220
-			if ($count != 1 && $correct_arrow) { // only add arrow once
224
+	if (!is_null($array_check)) {
225
+// check if exists
226
+		foreach ($array_check as $res) {
227
+// Check if above, equal or bellow center
228
+			if ($count != 1 && $correct_arrow) {
229
+// only add arrow once
221 230
 				$num = $i / ($count - 1);
222 231
 				if ($num < 0.5) {
223 232
 					$res->array_sufix = "_up";
@@ -241,7 +250,8 @@  discard block
 block discarded – undo
241 250
 		return null;
242 251
 	}
243 252
 	$arr = array();
244
-	foreach ($tree as $item) { // Check if above, equal or bellow center
253
+	foreach ($tree as $item) {
254
+// Check if above, equal or bellow center
245 255
 		if ($item->id <= $max_pokemon) {
246 256
 			$arr[] = $item;
247 257
 		}
Please login to merge, or discard this patch.
pages/pokemon.page.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -323,8 +323,7 @@
 block discarded – undo
323 323
 									} elseif (isset($obj->info)) {
324 324
 										$infoName = 'INFO_' . $obj->info;
325 325
 										echo '<br>(' . $locales->$infoName . ')';
326
-									}
327
-									else {
326
+									} else {
328 327
 										echo '<br> </br>';
329 328
 									}
330 329
 									?>
Please login to merge, or discard this patch.
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/process/queries/QueryManagerMysqlRocketmap.php 1 patch
Braces   +92 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-final class QueryManagerMysqlRocketmap extends QueryManagerMysql {
3
+final class QueryManagerMysqlRocketmap extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 	
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM pokemon";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 	
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM gym";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 	
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestop";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,42 +73,48 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 	
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 	
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
79 87
 		$result = $this->mysqli->query($req);
80 88
 		$data = $result->fetch_object();
81 89
 		return $data;
82 90
 	}
83 91
 	
84
-	function getTotalGyms() {
92
+	function getTotalGyms()
93
+	{
85 94
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
86 95
 		$result = $this->mysqli->query($req);
87 96
 		$data = $result->fetch_object();
88 97
 		return $data;
89 98
 	}
90 99
 	
91
-	function getTotalRaids() {
100
+	function getTotalRaids()
101
+	{
92 102
 		$req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND  end >= UTC_TIMESTAMP()";
93 103
 		$result = $this->mysqli->query($req);
94 104
 		$data = $result->fetch_object();
95 105
 		return $data;
96 106
 	}
97 107
 	
98
-	function getTotalGymsForTeam($team_id) {
108
+	function getTotalGymsForTeam($team_id)
109
+	{
99 110
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '".$team_id."'";
100 111
 		$result = $this->mysqli->query($req);
101 112
 		$data = $result->fetch_object();
102 113
 		return $data;
103 114
 	}
104 115
 	
105
-	function getRecentAll() {
116
+	function getRecentAll()
117
+	{
106 118
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
107 119
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
108 120
 					FROM pokemon
@@ -118,7 +130,8 @@  discard block
 block discarded – undo
118 130
 		return $data;
119 131
 	}
120 132
 	
121
-	function getRecentMythic($mythic_pokemons) {
133
+	function getRecentMythic($mythic_pokemons)
134
+	{
122 135
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
123 136
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
124 137
 					FROM pokemon
@@ -139,14 +152,16 @@  discard block
 block discarded – undo
139 152
 	// Single Pokemon
140 153
 	///////////////////
141 154
 	
142
-	function getGymsProtectedByPokemon($pokemon_id) {
155
+	function getGymsProtectedByPokemon($pokemon_id)
156
+	{
143 157
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'";
144 158
 		$result = $this->mysqli->query($req);
145 159
 		$data = $result->fetch_object();
146 160
 		return $data;
147 161
 	}
148 162
 	
149
-	function getPokemonLastSeen($pokemon_id) {
163
+	function getPokemonLastSeen($pokemon_id)
164
+	{
150 165
 		$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude
151 166
 							FROM pokemon
152 167
 							WHERE pokemon_id = '".$pokemon_id."'
@@ -157,7 +172,8 @@  discard block
 block discarded – undo
157 172
 		return $data;
158 173
 	}
159 174
 
160
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
175
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
176
+	{
161 177
 		$req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude,
162 178
 							cp, individual_attack, individual_defense, individual_stamina,
163 179
 							ROUND(100*(individual_attack+individual_defense+individual_stamina)/45,1) AS IV, move_1, move_2, form
@@ -174,7 +190,8 @@  discard block
 block discarded – undo
174 190
 		return $top;
175 191
 	}
176 192
 
177
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
193
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
194
+	{
178 195
 		$trainer_blacklist = "";
179 196
 		if (!empty(self::$config->system->trainer_blacklist)) {
180 197
 			$trainer_blacklist = " AND trainer_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -195,7 +212,8 @@  discard block
 block discarded – undo
195 212
 		return $toptrainer;
196 213
 	}
197 214
 
198
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
215
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
216
+	{
199 217
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
200 218
 			. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
201 219
 		$req 		= "SELECT latitude, longitude FROM pokemon".$where." 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() {
728
+	public function getNestData()
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).")";
Please login to merge, or discard this patch.
core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 1 patch
Braces   +82 added lines, -41 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() {
740
+	public function getNestData()
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) . ")";
Please login to merge, or discard this patch.
core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 patch
Braces   +82 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql {
3
+class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM sightings";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM forts";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestops";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,26 +73,30 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$data = (object) array("total" => 0);
79 87
 		return $data;
80 88
 	}
81 89
 
82
-	function getTotalGyms() {
90
+	function getTotalGyms()
91
+	{
83 92
 		$req = "SELECT COUNT(*) AS total FROM forts";
84 93
 		$result = $this->mysqli->query($req);
85 94
 		$data = $result->fetch_object();
86 95
 		return $data;
87 96
 	}
88 97
 
89
-	function getTotalRaids() {
98
+	function getTotalRaids()
99
+	{
90 100
 		$req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= UNIX_TIMESTAMP() AND time_end >= UNIX_TIMESTAMP()";
91 101
 		$result = $this->mysqli->query($req);
92 102
 		$data = $result->fetch_object();
@@ -94,7 +104,8 @@  discard block
 block discarded – undo
94 104
 	}
95 105
 
96 106
 
97
-	function getTotalGymsForTeam($team_id) {
107
+	function getTotalGymsForTeam($team_id)
108
+	{
98 109
 		$req = "SELECT COUNT(*) AS total 
99 110
 					FROM forts f
100 111
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -104,7 +115,8 @@  discard block
 block discarded – undo
104 115
 		return $data;
105 116
 	}
106 117
 
107
-	function getRecentAll() {
118
+	function getRecentAll()
119
+	{
108 120
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
109 121
               lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
110 122
               FROM sightings
@@ -120,7 +132,8 @@  discard block
 block discarded – undo
120 132
 		return $data;
121 133
 	}
122 134
 
123
-	function getRecentMythic($mythic_pokemon) {
135
+	function getRecentMythic($mythic_pokemon)
136
+	{
124 137
 		$req = "SELECT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
125 138
                 lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
126 139
                 FROM sightings
@@ -141,7 +154,8 @@  discard block
 block discarded – undo
141 154
 	// Single Pokemon
142 155
 	///////////////////
143 156
 
144
-	function getGymsProtectedByPokemon($pokemon_id) {
157
+	function getGymsProtectedByPokemon($pokemon_id)
158
+	{
145 159
 		$req = "SELECT COUNT(f.id) AS total 
146 160
 					FROM forts f
147 161
 					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
@@ -151,7 +165,8 @@  discard block
 block discarded – undo
151 165
 		return $data;
152 166
 	}
153 167
 
154
-	function getPokemonLastSeen($pokemon_id) {
168
+	function getPokemonLastSeen($pokemon_id)
169
+	{
155 170
 		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
156 171
                 FROM sightings
157 172
                 WHERE pokemon_id = '".$pokemon_id."'
@@ -162,7 +177,8 @@  discard block
 block discarded – undo
162 177
 		return $data;
163 178
 	}
164 179
 
165
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
180
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
181
+	{
166 182
 		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS distime, pokemon_id as pokemon_id, FROM_UNIXTIME(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
167 183
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
168 184
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form
@@ -179,7 +195,8 @@  discard block
 block discarded – undo
179 195
 		return $top;
180 196
 	}
181 197
 
182
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
198
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
199
+	{
183 200
 		$trainer_blacklist = "";
184 201
 		if (!empty(self::$config->system->trainer_blacklist)) {
185 202
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -200,7 +217,8 @@  discard block
 block discarded – undo
200 217
 		return $toptrainer;
201 218
 	}
202 219
 
203
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
220
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
221
+	{
204 222
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
205 223
 			. "AND FROM_UNIXTIME(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
206 224
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." 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() {
736
+	public function getNestData()
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) . ")";
Please login to merge, or discard this patch.