Failed Conditions
Pull Request — master (#374)
by Michael
02:01
created
core/process/timezone.loader.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 
6 6
 // Include and load variables if not set
7 7
 if (!isset($config)) {
8
-    $variables = realpath(dirname(__FILE__)).'/../json/variables.json';
9
-    $config = json_decode(file_get_contents($variables));
8
+	$variables = realpath(dirname(__FILE__)).'/../json/variables.json';
9
+	$config = json_decode(file_get_contents($variables));
10 10
 }
11 11
 
12 12
 // Set default timezone
Please login to merge, or discard this patch.
core/inc/meta.inc.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		<meta name="theme-color" content="#ffffff">
20 20
 
21 21
 <?php if (!isset($_GET['page'])) {
22
-    ?>
22
+	?>
23 23
 
24 24
 		<title><?= $config->infos->site_name; ?> | <?= strip_tags($config->infos->site_title); ?></title>
25 25
 
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 
47 47
 <?php
48 48
 } else {
49
-        switch ($_GET['page']) {
50
-        case 'pokemon':
51
-        ?>
49
+		switch ($_GET['page']) {
50
+		case 'pokemon':
51
+		?>
52 52
 
53 53
 		<title><?= $config->infos->site_name; ?> | <?= $locales->FIND; ?> <?= $pokemon->name; ?> <?= sprintf($locales->INCITY, $config->infos->city); ?></title>
54 54
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 
72 72
 
73 73
 		<?php
74
-            break;
74
+			break;
75 75
 
76
-        case 'pokestops':
77
-        ?>
76
+		case 'pokestops':
77
+		?>
78 78
 
79 79
 
80 80
 		<title><?= $config->infos->site_name; ?> | <?= sprintf($locales->POKESTOPS_METATITLE, $config->infos->city); ?></title>
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 
98 98
 
99 99
 		<?php
100
-            break;
100
+			break;
101 101
 
102
-        case 'gym':
103
-        ?>
102
+		case 'gym':
103
+		?>
104 104
 
105 105
 		<title><?= $config->infos->site_name; ?> | <?= $locales->GYMS_METATITLE; ?></title>
106 106
 
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 		<meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" />
123 123
 
124 124
 		<?php
125
-            break;
125
+			break;
126 126
 
127
-        case 'trainer':
128
-        ?>
127
+		case 'trainer':
128
+		?>
129 129
 
130 130
 		<title><?= $config->infos->site_name; ?> | <?= $locales->TRAINERS_METATITLE; ?></title>
131 131
 
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
 		<meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" />
147 147
 
148 148
 		<?php
149
-            break;
149
+			break;
150 150
 
151
-        case 'dashboard':
152
-        ?>
151
+		case 'dashboard':
152
+		?>
153 153
 
154 154
 		<title><?= $config->infos->site_name; ?> | <?= $locales->NAV_DASHBOARD; ?></title>
155 155
 
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 
172 172
 
173 173
 		<?php
174
-            break;
174
+			break;
175 175
 
176
-        case 'pokedex':
177
-        ?>
176
+		case 'pokedex':
177
+		?>
178 178
 
179 179
 		<title><?= $config->infos->site_name; ?> | <?= $locales->POKEDEX_METATITLE; ?></title>
180 180
 
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 		<meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" />
196 196
 
197 197
 		<?php
198
-            break;
198
+			break;
199 199
 
200
-        case 'nests':
201
-        ?>
200
+		case 'nests':
201
+		?>
202 202
 
203 203
 		<title><?= $config->infos->site_name; ?> | <?= $locales->NAV_NESTS; ?></title>
204 204
 
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 		<meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" />
220 220
 
221 221
 		<?php
222
-            break;
222
+			break;
223 223
 
224
-        case 'raids':
225
-        ?>
224
+		case 'raids':
225
+		?>
226 226
 
227 227
 		<title><?= $config->infos->site_name; ?> | <?= $locales->NAV_RAIDS; ?></title>
228 228
 
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 		<meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" />
244 244
 
245 245
 		<?php
246
-            break;
246
+			break;
247 247
 
248
-        case 'gymhistory':
249
-        ?>
248
+		case 'gymhistory':
249
+		?>
250 250
 
251 251
 		<title><?= $config->infos->site_name; ?> | Gym History</title>
252 252
 
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 		<meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" />
268 268
 
269 269
 		<?php
270
-            break;
271
-    }
272
-    }
270
+			break;
271
+	}
272
+	}
273 273
 
274 274
 ?>
Please login to merge, or discard this patch.
core/cron/nests.cron.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
 $allNestParks = array();
19 19
 
20 20
 for ($iLat = 0; $iLat < $countLat;) {
21
-    for ($iLng = 0; $iLng < $countLng;) {
22
-        $minLatitude = $totalMinLat + $iLat * 0.5;
23
-        $maxLatitude = min($minLatitude + 0.5, $totalMaxLat);
24
-        $minLongitude = $totalMinLon + $iLng * 0.5;
25
-        $maxLongitude = min($minLongitude + 0.5, $totalMaxLon);
26
-
27
-        if (0 == $manager->getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)->total) { //Skip empty areas
28
-            ++$iLng;
29
-            continue;
30
-        }
31
-
32
-        // Get Parks from overpass
33
-        $req = '[timeout:600][out:json][date:"2017-01-22T00:00:00Z"][bbox:'.$minLatitude.','.$minLongitude.','.$maxLatitude.','.$maxLongitude.'];
21
+	for ($iLng = 0; $iLng < $countLng;) {
22
+		$minLatitude = $totalMinLat + $iLat * 0.5;
23
+		$maxLatitude = min($minLatitude + 0.5, $totalMaxLat);
24
+		$minLongitude = $totalMinLon + $iLng * 0.5;
25
+		$maxLongitude = min($minLongitude + 0.5, $totalMaxLon);
26
+
27
+		if (0 == $manager->getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)->total) { //Skip empty areas
28
+			++$iLng;
29
+			continue;
30
+		}
31
+
32
+		// Get Parks from overpass
33
+		$req = '[timeout:600][out:json][date:"2017-01-22T00:00:00Z"][bbox:'.$minLatitude.','.$minLongitude.','.$maxLatitude.','.$maxLongitude.'];
34 34
 				(
35 35
 					way["leisure"="park"];
36 36
 					way["leisure"="garden"];
@@ -83,157 +83,157 @@  discard block
 block discarded – undo
83 83
 				out meta geom;
84 84
 				>;
85 85
 				out skel qt;';
86
-        $endpoint = 'https://overpass-api.de/api/interpreter';
87
-
88
-        $curl = curl_init($endpoint);
89
-
90
-        curl_setopt($curl, CURLOPT_POST, 1);
91
-        curl_setopt($curl, CURLOPT_POSTFIELDS, 'data='.urlencode($req));
92
-        curl_setopt($curl, CURLOPT_USERAGENT, 'Worldopole/NestUpdater '.$config->infos->site_name);
93
-        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
94
-        curl_setopt($curl, CURLOPT_TIMEOUT, 660);
95
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
96
-
97
-        $response = curl_exec($curl);
98
-        $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
99
-        curl_close($curl);
100
-
101
-        if (200 == $status) {
102
-            $json = json_decode($response, true);
103
-
104
-            $parks = array();
105
-            foreach ($json['elements'] as $key => &$element) {
106
-                $tempGeos = array();
107
-                if (isset($element['type']) && 'way' == $element['type'] && isset($element['geometry'])) {
108
-                    $tempGeos = array($element['geometry']);
109
-                } elseif (isset($element['type']) && 'relation' == $element['type'] && isset($element['members'])) {
110
-                    $outers = array();
111
-                    $members = $element['members'];
112
-                    foreach ($members as $member) {
113
-                        if (isset($member['role']) && 'outer' == $member['role'] && isset($member['geometry'])) {
114
-                            $outers[] = $member['geometry'];
115
-                        }
116
-                    }
117
-                    $tempGeos = combineOuter($outers);
118
-                }
119
-                foreach ($tempGeos as $key => $tempGeo) {
120
-                    if (!is_null($tempGeo) && 0 != count($tempGeo)) {
121
-                        $data = array();
122
-                        $geo = array();
123
-                        foreach ($tempGeo as $ele) {
124
-                            $geo[] = array('lat' => $ele['lat'], 'lng' => $ele['lon']);
125
-                        }
126
-
127
-                        // Finish poly where we started
128
-                        $firstEle = $geo[0];
129
-                        $lastEle = $geo[count($geo) - 1];
130
-                        if ($firstEle != $lastEle) {
131
-                            $geo[] = $firstEle;
132
-                        }
133
-
134
-                        $data['geo'] = $geo;
135
-                        if (isset($element['tags']) && isset($element['tags']['name'])) {
136
-                            $data['name'] = $element['tags']['name'];
137
-                        } else {
138
-                            $data['name'] = null;
139
-                        }
140
-                        $data['id'] = $element['id'].'#'.$key;
141
-                        $data['bounds'] = $element['bounds'];
142
-                        $parks[] = $data;
143
-                    }
144
-                }
145
-                unset($json[$key]);
146
-            }
147
-
148
-            // Get frequent spawn points
149
-            $datas = $manager->getNestData($nestTime, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude);
150
-            $nestsdatas = array();
151
-            foreach ($datas as $key => &$data) {
152
-                $nests['pid'] = $data->pokemon_id;
153
-                $nests['c'] = $data->total_pokemon;
154
-                $nests['lat'] = $data->latitude;
155
-                $nests['lng'] = $data->longitude;
156
-                // $starttime = $data->latest_seen - $data->duration;
157
-
158
-                $nests['st'] = '00'; // date('i', $starttime);
159
-                $nests['et'] = '00'; // date('i', $data->latest_seen);
160
-
161
-                // Add the data to array
162
-                $nestsdatas[] = $nests;
163
-                $allNestSpawns[] = $nests;
164
-                unset($datas[$key]);
165
-            }
166
-
167
-            // Checking Parks for Spawnpoints.
168
-            foreach ($parks as $key => &$park) {
169
-                $spawns = array();
170
-
171
-                foreach ($nestsdatas as $spawnpoint) {
172
-                    $lat = $spawnpoint['lat'];
173
-                    $lng = $spawnpoint['lng'];
174
-                    $pid = $spawnpoint['pid'];
175
-
176
-                    if (pointIsInsidePolygon($lat, $lng, $park['geo'], $park['bounds'])) {
177
-                        if (!isset($spawns[$pid])) {
178
-                            $spawns[$pid] = 0;
179
-                        }
180
-                        ++$spawns[$pid];
181
-                    }
182
-                }
183
-
184
-                $mostPid = 0;
185
-                $mostPidCount = 0;
186
-                foreach ($spawns as $pid => $count) {
187
-                    if ($count > $mostPidCount) {
188
-                        $mostPidCount = $count;
189
-                        $mostPid = $pid;
190
-                    }
191
-                }
192
-                if (0 != $mostPidCount && (!isset($config->system->nest_min_count) || $mostPidCount >= $config->system->nest_min_count)) {
193
-                    $park['pid'] = $mostPid;
194
-                    $park['count'] = $mostPidCount;
195
-
196
-                    $parkId = $park['id'];
197
-                    if (!array_key_exists($parkId, $allNestParks)) {
198
-                        $allNestParks[$parkId] = $park;
199
-                        unset($park['id']);
200
-                    } else {
201
-                        $savedPark = $allNestParks[$parkId];
202
-                        if ($park['pid'] == $savedPark['pid']) {
203
-                            $savedPark['count'] += $park['count'];
204
-                        } elseif ($park['count'] > $savedPark['count']) {
205
-                            $savedPark['count'] = $park['count'];
206
-                            $savedPark['pid'] = $park['pid'];
207
-                        }
208
-                        $allNestParks[$parkId] = $savedPark;
209
-                    }
210
-                }
211
-                unset($parks[$key]);
212
-            }
213
-            ++$iLng;
214
-        } elseif (429 == $status) {
215
-            echo "Got Error 429: Trying again in 5 Minutes...\n";
216
-            sleep(300);
217
-        } else {
218
-            echo 'Error '.$status." while getting nests from overpass-turbo. Aborting Nest Update.\n";
219
-            touch($nests_parks_file, $prevNestTime);
220
-            exit();
221
-        }
222
-    }
223
-    ++$iLat;
86
+		$endpoint = 'https://overpass-api.de/api/interpreter';
87
+
88
+		$curl = curl_init($endpoint);
89
+
90
+		curl_setopt($curl, CURLOPT_POST, 1);
91
+		curl_setopt($curl, CURLOPT_POSTFIELDS, 'data='.urlencode($req));
92
+		curl_setopt($curl, CURLOPT_USERAGENT, 'Worldopole/NestUpdater '.$config->infos->site_name);
93
+		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
94
+		curl_setopt($curl, CURLOPT_TIMEOUT, 660);
95
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
96
+
97
+		$response = curl_exec($curl);
98
+		$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
99
+		curl_close($curl);
100
+
101
+		if (200 == $status) {
102
+			$json = json_decode($response, true);
103
+
104
+			$parks = array();
105
+			foreach ($json['elements'] as $key => &$element) {
106
+				$tempGeos = array();
107
+				if (isset($element['type']) && 'way' == $element['type'] && isset($element['geometry'])) {
108
+					$tempGeos = array($element['geometry']);
109
+				} elseif (isset($element['type']) && 'relation' == $element['type'] && isset($element['members'])) {
110
+					$outers = array();
111
+					$members = $element['members'];
112
+					foreach ($members as $member) {
113
+						if (isset($member['role']) && 'outer' == $member['role'] && isset($member['geometry'])) {
114
+							$outers[] = $member['geometry'];
115
+						}
116
+					}
117
+					$tempGeos = combineOuter($outers);
118
+				}
119
+				foreach ($tempGeos as $key => $tempGeo) {
120
+					if (!is_null($tempGeo) && 0 != count($tempGeo)) {
121
+						$data = array();
122
+						$geo = array();
123
+						foreach ($tempGeo as $ele) {
124
+							$geo[] = array('lat' => $ele['lat'], 'lng' => $ele['lon']);
125
+						}
126
+
127
+						// Finish poly where we started
128
+						$firstEle = $geo[0];
129
+						$lastEle = $geo[count($geo) - 1];
130
+						if ($firstEle != $lastEle) {
131
+							$geo[] = $firstEle;
132
+						}
133
+
134
+						$data['geo'] = $geo;
135
+						if (isset($element['tags']) && isset($element['tags']['name'])) {
136
+							$data['name'] = $element['tags']['name'];
137
+						} else {
138
+							$data['name'] = null;
139
+						}
140
+						$data['id'] = $element['id'].'#'.$key;
141
+						$data['bounds'] = $element['bounds'];
142
+						$parks[] = $data;
143
+					}
144
+				}
145
+				unset($json[$key]);
146
+			}
147
+
148
+			// Get frequent spawn points
149
+			$datas = $manager->getNestData($nestTime, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude);
150
+			$nestsdatas = array();
151
+			foreach ($datas as $key => &$data) {
152
+				$nests['pid'] = $data->pokemon_id;
153
+				$nests['c'] = $data->total_pokemon;
154
+				$nests['lat'] = $data->latitude;
155
+				$nests['lng'] = $data->longitude;
156
+				// $starttime = $data->latest_seen - $data->duration;
157
+
158
+				$nests['st'] = '00'; // date('i', $starttime);
159
+				$nests['et'] = '00'; // date('i', $data->latest_seen);
160
+
161
+				// Add the data to array
162
+				$nestsdatas[] = $nests;
163
+				$allNestSpawns[] = $nests;
164
+				unset($datas[$key]);
165
+			}
166
+
167
+			// Checking Parks for Spawnpoints.
168
+			foreach ($parks as $key => &$park) {
169
+				$spawns = array();
170
+
171
+				foreach ($nestsdatas as $spawnpoint) {
172
+					$lat = $spawnpoint['lat'];
173
+					$lng = $spawnpoint['lng'];
174
+					$pid = $spawnpoint['pid'];
175
+
176
+					if (pointIsInsidePolygon($lat, $lng, $park['geo'], $park['bounds'])) {
177
+						if (!isset($spawns[$pid])) {
178
+							$spawns[$pid] = 0;
179
+						}
180
+						++$spawns[$pid];
181
+					}
182
+				}
183
+
184
+				$mostPid = 0;
185
+				$mostPidCount = 0;
186
+				foreach ($spawns as $pid => $count) {
187
+					if ($count > $mostPidCount) {
188
+						$mostPidCount = $count;
189
+						$mostPid = $pid;
190
+					}
191
+				}
192
+				if (0 != $mostPidCount && (!isset($config->system->nest_min_count) || $mostPidCount >= $config->system->nest_min_count)) {
193
+					$park['pid'] = $mostPid;
194
+					$park['count'] = $mostPidCount;
195
+
196
+					$parkId = $park['id'];
197
+					if (!array_key_exists($parkId, $allNestParks)) {
198
+						$allNestParks[$parkId] = $park;
199
+						unset($park['id']);
200
+					} else {
201
+						$savedPark = $allNestParks[$parkId];
202
+						if ($park['pid'] == $savedPark['pid']) {
203
+							$savedPark['count'] += $park['count'];
204
+						} elseif ($park['count'] > $savedPark['count']) {
205
+							$savedPark['count'] = $park['count'];
206
+							$savedPark['pid'] = $park['pid'];
207
+						}
208
+						$allNestParks[$parkId] = $savedPark;
209
+					}
210
+				}
211
+				unset($parks[$key]);
212
+			}
213
+			++$iLng;
214
+		} elseif (429 == $status) {
215
+			echo "Got Error 429: Trying again in 5 Minutes...\n";
216
+			sleep(300);
217
+		} else {
218
+			echo 'Error '.$status." while getting nests from overpass-turbo. Aborting Nest Update.\n";
219
+			touch($nests_parks_file, $prevNestTime);
220
+			exit();
221
+		}
222
+	}
223
+	++$iLat;
224 224
 }
225 225
 
226 226
 // Check for nests in nests of same pokemon
227 227
 foreach ($allNestParks as $keyA => $parkA) {
228
-    foreach ($allNestParks as $keyB => $parkB) {
229
-        if ($keyA != $keyB && $parkA['pid'] == $parkB['pid']) {
230
-            if (polyIsInsidePolygon($parkA['geo'], $parkA['bounds'], $parkB['geo'], $parkB['bounds'])) {
231
-                unset($allNestParks[$keyA]);
232
-            } elseif (polyIsInsidePolygon($parkB['geo'], $parkB['bounds'], $parkA['geo'], $parkA['bounds'])) {
233
-                unset($allNestParks[$keyB]);
234
-            }
235
-        }
236
-    }
228
+	foreach ($allNestParks as $keyB => $parkB) {
229
+		if ($keyA != $keyB && $parkA['pid'] == $parkB['pid']) {
230
+			if (polyIsInsidePolygon($parkA['geo'], $parkA['bounds'], $parkB['geo'], $parkB['bounds'])) {
231
+				unset($allNestParks[$keyA]);
232
+			} elseif (polyIsInsidePolygon($parkB['geo'], $parkB['bounds'], $parkA['geo'], $parkA['bounds'])) {
233
+				unset($allNestParks[$keyB]);
234
+			}
235
+		}
236
+	}
237 237
 }
238 238
 
239 239
 // Write files
Please login to merge, or discard this patch.
core/cron/pokedex_rarity.cron.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@  discard block
 block discarded – undo
6 6
 $total_pokemon_last_day = 0;
7 7
 $pokelist = array();
8 8
 foreach ($data as $pokemon_id => $total) {
9
-    $total_pokemon_last_day += $total;
10
-    $pokelist[$pokemon_id]['spawns_last_day'] = $total;
9
+	$total_pokemon_last_day += $total;
10
+	$pokelist[$pokemon_id]['spawns_last_day'] = $total;
11 11
 }
12 12
 
13 13
 // calc rarity for last 24h
14 14
 foreach ($pokelist as &$pokemon) {
15
-    $percent = $pokemon['spawns_last_day'] * 100 / $total_pokemon_last_day;
16
-    $pokemon['rate'] = round($percent, 4);
15
+	$percent = $pokemon['spawns_last_day'] * 100 / $total_pokemon_last_day;
16
+	$pokemon['rate'] = round($percent, 4);
17 17
 }
18 18
 
19 19
 // set values for all available pokemon
20 20
 $maxpid = $config->system->max_pokemon;
21 21
 $pokedex_rarity = new stdClass();
22 22
 for ($pid = 1; $pid <= $maxpid; ++$pid) {
23
-    $pokedex_rarity->$pid = new stdClass();
24
-    if (isset($pokelist[$pid])) {
25
-        // seen
26
-        $pokedex_rarity->$pid->rate = $pokelist[$pid]['rate'];
27
-        $pokedex_rarity->$pid->per_day = (int) $pokelist[$pid]['spawns_last_day'];
28
-    } else {
29
-        // unseen
30
-        $pokedex_rarity->$pid->rate = 0.0;
31
-        $pokedex_rarity->$pid->per_day = 0;
32
-    }
23
+	$pokedex_rarity->$pid = new stdClass();
24
+	if (isset($pokelist[$pid])) {
25
+		// seen
26
+		$pokedex_rarity->$pid->rate = $pokelist[$pid]['rate'];
27
+		$pokedex_rarity->$pid->per_day = (int) $pokelist[$pid]['spawns_last_day'];
28
+	} else {
29
+		// unseen
30
+		$pokedex_rarity->$pid->rate = 0.0;
31
+		$pokedex_rarity->$pid->per_day = 0;
32
+	}
33 33
 }
34 34
 
35 35
 // Write to file
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
 
38 38
 $rm_pokemon_file = $config->system->rm_pokemon_file;
39 39
 if (!is_null($rm_pokemon_file)) {
40
-    $string = file_get_contents($rm_pokemon_file);
41
-    $json = json_decode($string, true);
42
-    foreach ($pokedex_rarity as $pid => $rarity) {
43
-        $rate = $rarity->rate;
44
-        if ($rate >= 1) {
45
-            $rarity_string = 'Common';
46
-        } elseif ($rate >= 0.20) {
47
-            $rarity_string = 'Uncommon';
48
-        } elseif ($rate >= 0.01) {
49
-            $rarity_string = 'Rare';
50
-        } elseif ($rate >= 0.0025) {
51
-            $rarity_string = 'Very Rare';
52
-        } else {
53
-            $rarity_string = 'Ultra Rare';
54
-        }
55
-        unset($json[$pid]['rarity']);
56
-        $json[$pid]['rarity'] = $rarity_string;
57
-    }
58
-    file_put_contents($rm_pokemon_file, json_encode($json));
40
+	$string = file_get_contents($rm_pokemon_file);
41
+	$json = json_decode($string, true);
42
+	foreach ($pokedex_rarity as $pid => $rarity) {
43
+		$rate = $rarity->rate;
44
+		if ($rate >= 1) {
45
+			$rarity_string = 'Common';
46
+		} elseif ($rate >= 0.20) {
47
+			$rarity_string = 'Uncommon';
48
+		} elseif ($rate >= 0.01) {
49
+			$rarity_string = 'Rare';
50
+		} elseif ($rate >= 0.0025) {
51
+			$rarity_string = 'Very Rare';
52
+		} else {
53
+			$rarity_string = 'Ultra Rare';
54
+		}
55
+		unset($json[$pid]['rarity']);
56
+		$json[$pid]['rarity'] = $rarity_string;
57
+	}
58
+	file_put_contents($rm_pokemon_file, json_encode($json));
59 59
 }
Please login to merge, or discard this patch.
core/cron/captcha.cron.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -8,73 +8,73 @@
 block discarded – undo
8 8
 
9 9
 $captcha_file = SYS_PATH.'/core/json/captcha.stats.json';
10 10
 if (is_file($captcha_file)) {
11
-    $capdatas = json_decode(file_get_contents($captcha_file), true);
12
-    // Trim json stats files to last 7 days of data
13
-    $capdatas = trim_stats_json($capdatas, $timestamp_lastweek);
11
+	$capdatas = json_decode(file_get_contents($captcha_file), true);
12
+	// Trim json stats files to last 7 days of data
13
+	$capdatas = trim_stats_json($capdatas, $timestamp_lastweek);
14 14
 }
15 15
 
16 16
 $variables_secret = SYS_PATH.'/core/json/variables.secret.json';
17 17
 $config_secret = json_decode(file_get_contents($variables_secret));
18 18
 
19 19
 if ('' == $config_secret->captcha_key) {
20
-    $captcha['timestamp'] = $timestamp;
21
-    // get amount of accounts requiring a captcha
22
-    $data = $manager->getCaptchaCount();
23
-    $captcha['captcha_accs'] = $data->total;
24
-    // Add the datas in file
25
-    $capdatas[] = $captcha;
20
+	$captcha['timestamp'] = $timestamp;
21
+	// get amount of accounts requiring a captcha
22
+	$data = $manager->getCaptchaCount();
23
+	$captcha['captcha_accs'] = $data->total;
24
+	// Add the datas in file
25
+	$capdatas[] = $captcha;
26 26
 } else {
27
-    if (!empty($capdatas)) {
28
-        $lastCaptcha = array_pop($capdatas);
29
-    } else {
30
-        $lastCaptcha['timestamp'] = strtotime('-7 days', strtotime(date('Y-m-d')));
31
-    }
32
-    $lastCaptchaDate = date('Y-m-d', $lastCaptcha['timestamp']);
33
-    $startTime = strtotime($lastCaptchaDate);
34
-    $endTime = strtotime(date('Y-m-d')) + date('Z');
35
-    $timeDiff = abs($endTime - $startTime);
36
-    $numberDays = intval($timeDiff / 86400); // 86400 seconds in one day
37
-    if ($numberDays > 7) {
38
-        $numberDays = 7;
39
-    }
40
-    while ($numberDays >= 0) {
41
-        $day = $endTime - ($numberDays * 86400);
42
-        $captchaUrl =
43
-                'http://2captcha.com/res.php?key='.
44
-                $config_secret->captcha_key.'&action=getstats&date='.date('Y-m-d', $day);
27
+	if (!empty($capdatas)) {
28
+		$lastCaptcha = array_pop($capdatas);
29
+	} else {
30
+		$lastCaptcha['timestamp'] = strtotime('-7 days', strtotime(date('Y-m-d')));
31
+	}
32
+	$lastCaptchaDate = date('Y-m-d', $lastCaptcha['timestamp']);
33
+	$startTime = strtotime($lastCaptchaDate);
34
+	$endTime = strtotime(date('Y-m-d')) + date('Z');
35
+	$timeDiff = abs($endTime - $startTime);
36
+	$numberDays = intval($timeDiff / 86400); // 86400 seconds in one day
37
+	if ($numberDays > 7) {
38
+		$numberDays = 7;
39
+	}
40
+	while ($numberDays >= 0) {
41
+		$day = $endTime - ($numberDays * 86400);
42
+		$captchaUrl =
43
+				'http://2captcha.com/res.php?key='.
44
+				$config_secret->captcha_key.'&action=getstats&date='.date('Y-m-d', $day);
45 45
 
46
-        $ch = curl_init();
47
-        curl_setopt($ch, CURLOPT_URL, $captchaUrl);
48
-        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
49
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
50
-        $fileContents = curl_exec($ch);
51
-        if (curl_errno($ch)) {
52
-            echo curl_error($ch);
53
-            echo "\n<br />";
54
-            $fileContents = '';
55
-        } else {
56
-            curl_close($ch);
57
-        }
46
+		$ch = curl_init();
47
+		curl_setopt($ch, CURLOPT_URL, $captchaUrl);
48
+		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
49
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
50
+		$fileContents = curl_exec($ch);
51
+		if (curl_errno($ch)) {
52
+			echo curl_error($ch);
53
+			echo "\n<br />";
54
+			$fileContents = '';
55
+		} else {
56
+			curl_close($ch);
57
+		}
58 58
 
59
-        if (!is_string($fileContents) || !strlen($fileContents)) {
60
-            echo 'Failed to get contents.';
61
-            $fileContents = '';
62
-        }
63
-        $capXml = simplexml_load_string($fileContents);
59
+		if (!is_string($fileContents) || !strlen($fileContents)) {
60
+			echo 'Failed to get contents.';
61
+			$fileContents = '';
62
+		}
63
+		$capXml = simplexml_load_string($fileContents);
64 64
 
65
-        foreach ($capXml as $key => $value) {
66
-            if ((0 == $numberDays
67
-                && ((int) $value->Attributes()->hour >= (int) date('H', $lastCaptcha['timestamp'])
68
-                && ((int) $value->Attributes()->hour <= (int) date('H')))
69
-                ) || $numberDays > 0) {
70
-                $captcha['timestamp'] =
71
-                        strtotime(date('Y-m-d', $day).' '.$value->Attributes()->hour.':00') + date('Z');
72
-                $captcha['captcha_accs'] = (string) $value->volume;
73
-                $capdatas[] = $captcha;
74
-            }
75
-        }
76
-        --$numberDays;
77
-    }
65
+		foreach ($capXml as $key => $value) {
66
+			if ((0 == $numberDays
67
+				&& ((int) $value->Attributes()->hour >= (int) date('H', $lastCaptcha['timestamp'])
68
+				&& ((int) $value->Attributes()->hour <= (int) date('H')))
69
+				) || $numberDays > 0) {
70
+				$captcha['timestamp'] =
71
+						strtotime(date('Y-m-d', $day).' '.$value->Attributes()->hour.':00') + date('Z');
72
+				$captcha['captcha_accs'] = (string) $value->volume;
73
+				$capdatas[] = $captcha;
74
+			}
75
+		}
76
+		--$numberDays;
77
+	}
78 78
 }
79 79
 
80 80
 // Write to file
Please login to merge, or discard this patch.
core/js/trainer.graph.js.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 $trainer_lvl = [];
28 28
 // For all 3 teams
29 29
 for ($teamid = 1; $teamid <= 3; ++$teamid) {
30
-    $data = $manager->getTrainerLevelCount($teamid);
31
-    $trainer_lvl[$teamid] = $data;
30
+	$data = $manager->getTrainerLevelCount($teamid);
31
+	$trainer_lvl[$teamid] = $data;
32 32
 }
33 33
 
34 34
 ?>
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			borderColor: 'rgba(59,129,255,1)',
69 69
 			borderWidth: 1,
70 70
 			data: [<?php if (isset($trainer_lvl[1])) {
71
-    echo implode(',', $trainer_lvl[1]);
71
+	echo implode(',', $trainer_lvl[1]);
72 72
 } ?>],
73 73
 		},
74 74
 		{
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			borderColor: 'rgba(247,10,20,1)',
78 78
 			borderWidth: 1,
79 79
 			data: [<?php if (isset($trainer_lvl[2])) {
80
-    echo implode(',', $trainer_lvl[2]);
80
+	echo implode(',', $trainer_lvl[2]);
81 81
 } ?>],
82 82
 		},
83 83
 		{
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			borderColor: 'rgba(248,153,0,1)',
87 87
 			borderWidth: 1,
88 88
 			data: [<?php if (isset($trainer_lvl[3])) {
89
-    echo implode(',', $trainer_lvl[3]);
89
+	echo implode(',', $trainer_lvl[3]);
90 90
 } ?>],
91 91
 		}
92 92
 	]
Please login to merge, or discard this patch.
core/js/nests.maps.js.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-    // Send Javascript header
3
-    header('Content-type: text/javascript');
4
-
5
-    // Load variables and locales
6
-    include_once '../../config.php';
7
-    $variables = SYS_PATH.'/core/json/variables.json';
8
-    $config = json_decode(file_get_contents($variables));
9
-    include_once '../process/locales.loader.php';
10
-    include_once '../../functions.php';
2
+	// Send Javascript header
3
+	header('Content-type: text/javascript');
4
+
5
+	// Load variables and locales
6
+	include_once '../../config.php';
7
+	$variables = SYS_PATH.'/core/json/variables.json';
8
+	$config = json_decode(file_get_contents($variables));
9
+	include_once '../process/locales.loader.php';
10
+	include_once '../../functions.php';
11 11
 ?>
12 12
 
13 13
 /** global: google */
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
 var pokemon = {
17 17
 <?php
18
-    foreach ($pokemons->pokemon as $pokeid => $pokemon) {
19
-        echo $pokeid.':"'.$pokemon->name.'",';
20
-    }
18
+	foreach ($pokemons->pokemon as $pokeid => $pokemon) {
19
+		echo $pokeid.':"'.$pokemon->name.'",';
20
+	}
21 21
 ?>
22 22
 }
23 23
 var map;
Please login to merge, or discard this patch.
core/js/pokemon.graph.js.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 // Test to check if the file is called properly
4 4
 
5 5
 if (!isset($_GET['id'])) {
6
-    http_response_code(400);
7
-    echo 'Bad Request';
8
-    exit();
6
+	http_response_code(400);
7
+	echo 'Bad Request';
8
+	exit();
9 9
 }
10 10
 
11 11
 // Send Javascript header
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		<link href="core/css/font-awesome.min.css" rel="stylesheet">
22 22
 		<link href="<?php auto_ver('core/css/style.css'); ?>" rel="stylesheet">
23 23
 		<?php if ('pokemon' == $page) {
24
-    ?>
24
+	?>
25 25
 			<link href="<?php auto_ver('core/css/jQRangeSlider-bootstrap.min.css'); ?>" rel="stylesheet">
26 26
 		<?php
27 27
 } ?>
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 	<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
30 30
 
31 31
 		<?php
32
-        // Google Analytics
33
-        if (is_file('analyticstracking.php')) {
34
-            include_once 'analyticstracking.php';
35
-        }
36
-        ?>
32
+		// Google Analytics
33
+		if (is_file('analyticstracking.php')) {
34
+			include_once 'analyticstracking.php';
35
+		}
36
+		?>
37 37
 
38 38
 		<nav class="navbar navbar-default navbar-fixed-top">
39 39
 			<div class="container">
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 					<ul class="nav navbar-nav navbar-right">
54 54
 
55 55
 						<?php
56
-                        if (!isset($config->menu)) {
57
-                            echo 'Please update variables.json file with menu values';
58
-                            exit();
59
-                        }
56
+						if (!isset($config->menu)) {
57
+							echo 'Please update variables.json file with menu values';
58
+							exit();
59
+						}
60 60
 
61
-                        foreach ($config->menu as $menu) {
62
-                            printMenuitems($menu, 1, $locales);
63
-                        }
64
-                        ?>
61
+						foreach ($config->menu as $menu) {
62
+							printMenuitems($menu, 1, $locales);
63
+						}
64
+						?>
65 65
 
66 66
 					</ul>
67 67
 				</div> <!-- /.navbar-collapse -->
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 
71 71
 		<div class="container">
72 72
 			<?php
73
-            // Include the pages
74
-            if (!empty($_GET['page'])) {
75
-                $file = SYS_PATH.'/pages/'.$page.'.page.php';
76
-
77
-                if (is_file($file)) {
78
-                    echo '<!-- Page :: '.$page.' -->';
79
-                    include $file;
80
-                } else {
81
-                    include 'pages/home.page.php';
82
-                }
83
-            } else {
84
-                include 'pages/home.page.php';
85
-            }
86
-
87
-            ?>
73
+			// Include the pages
74
+			if (!empty($_GET['page'])) {
75
+				$file = SYS_PATH.'/pages/'.$page.'.page.php';
76
+
77
+				if (is_file($file)) {
78
+					echo '<!-- Page :: '.$page.' -->';
79
+					include $file;
80
+				} else {
81
+					include 'pages/home.page.php';
82
+				}
83
+			} else {
84
+				include 'pages/home.page.php';
85
+			}
86
+
87
+			?>
88 88
 		</div>
89 89
 
90 90
 		<footer>
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 		<script src="core/js/bootstrap.min.js"></script>
108 108
 
109 109
 		<?php // Load scripts only for page
110
-        if (empty($page)) {
111
-            ?>
110
+		if (empty($page)) {
111
+			?>
112 112
 
113 113
 			<script src="<?php auto_ver('core/js/home.script.js'); ?>"></script>
114 114
 
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 				updateCounter(<?= $home->teams->rocket; ?>,'.total-rocket-js');
125 125
 			</script>
126 126
 		<?php
127
-        } else {
128
-            switch ($page) {
129
-                case 'pokemon':
130
-                    ?>
127
+		} else {
128
+			switch ($page) {
129
+				case 'pokemon':
130
+					?>
131 131
 
132 132
 					<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
133 133
 					<script src="core/js/pokemon.graph.js.php?id=<?= $pokemon_id; ?>"></script>
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization&callback=initMap&v=3"></script>
142 142
 
143 143
 					<?php
144
-                    break;
144
+					break;
145 145
 
146
-                case 'pokestops':
147
-                    ?>
146
+				case 'pokestops':
147
+					?>
148 148
 
149 149
 					<script src="<?php auto_ver('core/js/pokestops.maps.js'); ?>"></script>
150 150
 					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization&callback=initMap&v=3"></script>
151 151
 
152 152
 					<?php
153
-                    break;
153
+					break;
154 154
 
155
-                case 'gym':
156
-                    ?>
155
+				case 'gym':
156
+					?>
157 157
 
158 158
 					<script src="<?php auto_ver('core/js/gym.script.js'); ?>"></script>
159 159
 					<script>
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization&callback=initMap&v=3"></script>
172 172
 
173 173
 					<?php
174
-                    break;
174
+					break;
175 175
 
176
-                case 'pokedex':
177
-                    ?>
176
+				case 'pokedex':
177
+					?>
178 178
 
179 179
 					<script src="core/js/holmes.min.js"></script>
180 180
 					<script>
@@ -191,56 +191,56 @@  discard block
 block discarded – undo
191 191
 					</script>
192 192
 
193 193
 					<?php
194
-                    break;
194
+					break;
195 195
 
196
-                case 'dashboard':
197
-                    ?>
196
+				case 'dashboard':
197
+					?>
198 198
 
199 199
 					<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
200 200
 					<script src="core/js/dashboard.graph.js.php"></script>
201 201
 
202 202
 					<?php
203
-                    break;
203
+					break;
204 204
 
205
-                case 'trainer':
206
-                    ?>
205
+				case 'trainer':
206
+					?>
207 207
 
208 208
 					<script src="<?php auto_ver('core/js/trainer.content.js'); ?>"></script>
209 209
 					<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
210 210
 					<script src="core/js/trainer.graph.js.php"></script>
211 211
 
212 212
 					<?php
213
-                    break;
213
+					break;
214 214
 
215
-                case 'nests':
216
-                    ?>
215
+				case 'nests':
216
+					?>
217 217
 
218 218
 					<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
219 219
 					<script src="core/js/nests.maps.js.php"></script>
220 220
 					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization,geometry&callback=initMap&v=3"></script>
221 221
 
222 222
 					<?php
223
-                    break;
223
+					break;
224 224
 
225
-                case 'raids':
226
-                    ?>
225
+				case 'raids':
226
+					?>
227 227
 
228 228
 					<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
229 229
 					<script src="<?php auto_ver('core/js/raids.content.js'); ?>"></script>
230 230
 
231 231
 					<?php
232
-                    break;
232
+					break;
233 233
 
234
-                case 'gymhistory':
235
-                    ?>
234
+				case 'gymhistory':
235
+					?>
236 236
 
237 237
 					<script src="<?php auto_ver('core/js/gymhistory.content.js'); ?>"></script>
238 238
 
239 239
 					<?php
240
-                    break;
241
-            }
242
-        }
243
-        ?>
240
+					break;
241
+			}
242
+		}
243
+		?>
244 244
 
245 245
 	</body>
246 246
 </html>
Please login to merge, or discard this patch.