@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | public function __construct($dbc = null) { |
21 | 21 | $Connection = new Connection($dbc); |
22 | 22 | $this->db = $Connection->db(); |
23 | - if ($this->db === null) die('Error: No DB connection. (Accident)'); |
|
23 | + if ($this->db === null) { |
|
24 | + die('Error: No DB connection. (Accident)'); |
|
25 | + } |
|
24 | 26 | } |
25 | 27 | |
26 | 28 | /* |
@@ -123,8 +125,11 @@ discard block |
||
123 | 125 | $data = array(); |
124 | 126 | if ($row['registration'] != '') { |
125 | 127 | $image_array = $Image->getSpotterImage($row['registration']); |
126 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
127 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
128 | + if (count($image_array) > 0) { |
|
129 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
130 | + } else { |
|
131 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
132 | + } |
|
128 | 133 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
129 | 134 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
130 | 135 | if (!empty($aircraft_info)) { |
@@ -140,17 +145,30 @@ discard block |
||
140 | 145 | $data['aircraft_base'] = $owner_data['base']; |
141 | 146 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
142 | 147 | } |
143 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
144 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
145 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
148 | + } else { |
|
149 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
150 | + } |
|
151 | + if ($row['registration'] == '') { |
|
152 | + $row['registration'] = 'NA'; |
|
153 | + } |
|
154 | + if ($row['ident'] == '') { |
|
155 | + $row['ident'] = 'NA'; |
|
156 | + } |
|
146 | 157 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
147 | 158 | if (isset($identicao[0])) { |
148 | 159 | if (substr($row['ident'],0,2) == 'AF') { |
149 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
150 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
151 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
160 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
161 | + $icao = $row['ident']; |
|
162 | + } else { |
|
163 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
164 | + } |
|
165 | + } else { |
|
166 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
167 | + } |
|
152 | 168 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
153 | - } else $icao = $row['ident']; |
|
169 | + } else { |
|
170 | + $icao = $row['ident']; |
|
171 | + } |
|
154 | 172 | $icao = $Translation->checkTranslation($icao,false); |
155 | 173 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
156 | 174 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -165,10 +183,14 @@ discard block |
||
165 | 183 | //else echo 'No data...'."\n"; |
166 | 184 | } |
167 | 185 | $data = array_merge($row,$data); |
168 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
186 | + if ($data['ident'] == null) { |
|
187 | + $data['ident'] = $icao; |
|
188 | + } |
|
169 | 189 | if ($data['title'] == null) { |
170 | 190 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
171 | - } else $data['message'] = strtolower($data['title']); |
|
191 | + } else { |
|
192 | + $data['message'] = strtolower($data['title']); |
|
193 | + } |
|
172 | 194 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
173 | 195 | $date = $data['date']; |
174 | 196 | if (isset($ids[$date])) { |
@@ -187,8 +209,9 @@ discard block |
||
187 | 209 | if (isset($result)) { |
188 | 210 | $result[0]['query_number_rows'] = $i; |
189 | 211 | return $result; |
212 | + } else { |
|
213 | + return array(); |
|
190 | 214 | } |
191 | - else return array(); |
|
192 | 215 | } |
193 | 216 | |
194 | 217 | /* |
@@ -233,7 +256,9 @@ discard block |
||
233 | 256 | */ |
234 | 257 | public function import($file) { |
235 | 258 | global $globalTransaction, $globalDebug; |
236 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
259 | + if ($globalDebug) { |
|
260 | + echo 'Import '.$file."\n"; |
|
261 | + } |
|
237 | 262 | $result = array(); |
238 | 263 | if (file_exists($file)) { |
239 | 264 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -244,8 +269,11 @@ discard block |
||
244 | 269 | } |
245 | 270 | fclose($handle); |
246 | 271 | } |
247 | - if (!empty($result)) $this->add($result,true); |
|
248 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
272 | + if (!empty($result)) { |
|
273 | + $this->add($result,true); |
|
274 | + } elseif ($globalDebug) { |
|
275 | + echo 'Nothing to import'; |
|
276 | + } |
|
249 | 277 | } |
250 | 278 | } |
251 | 279 | |
@@ -281,14 +309,23 @@ discard block |
||
281 | 309 | } |
282 | 310 | } |
283 | 311 | fclose($handle); |
284 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
285 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
312 | + } elseif ($globalDebug) { |
|
313 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
314 | + } |
|
315 | + } elseif ($globalDebug) { |
|
316 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
317 | + } |
|
286 | 318 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
287 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
319 | + if (empty($result) && $globalDebug) { |
|
320 | + echo 'Nothing to update'; |
|
321 | + } |
|
288 | 322 | foreach ($result as $file => $md5) { |
289 | 323 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
290 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
291 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
324 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
325 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
326 | + } elseif ($globalDebug) { |
|
327 | + echo 'Download '.$file.' failed'; |
|
328 | + } |
|
292 | 329 | } |
293 | 330 | } |
294 | 331 | |
@@ -305,13 +342,17 @@ discard block |
||
305 | 342 | $Image = new Image($this->db); |
306 | 343 | $Spotter = new Spotter($this->db); |
307 | 344 | |
308 | - if (empty($crash)) return false; |
|
345 | + if (empty($crash)) { |
|
346 | + return false; |
|
347 | + } |
|
309 | 348 | if (!$new) { |
310 | 349 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
311 | 350 | $sthd = $Connection->db->prepare($query_delete); |
312 | 351 | $sthd->execute(array(':source' => $crash[0]['source'])); |
313 | 352 | } |
314 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
353 | + if ($globalTransaction) { |
|
354 | + $Connection->db->beginTransaction(); |
|
355 | + } |
|
315 | 356 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
316 | 357 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
317 | 358 | $sth_check = $Connection->db->prepare($query_check); |
@@ -326,7 +367,9 @@ discard block |
||
326 | 367 | return $value === "" ? NULL : $value; |
327 | 368 | }, $cr); |
328 | 369 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
329 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
370 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
371 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
372 | + } |
|
330 | 373 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
331 | 374 | $sth_check->execute($query_check_values); |
332 | 375 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -336,13 +379,19 @@ discard block |
||
336 | 379 | if ($cr['date'] > time()-(30*86400)) { |
337 | 380 | $imgchk = $Image->getSpotterImage($cr['registration']); |
338 | 381 | if (empty($imgchk)) { |
339 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
382 | + if ($globalDebug) { |
|
383 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
384 | + } |
|
340 | 385 | $Image->addSpotterImage($cr['registration']); |
341 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
386 | + if ($globalDebug) { |
|
387 | + echo "\t".'Done'."\n"; |
|
388 | + } |
|
342 | 389 | } |
343 | 390 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
344 | 391 | } |
345 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
392 | + if ($cr['title'] == '') { |
|
393 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
394 | + } |
|
346 | 395 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
347 | 396 | } |
348 | 397 | } |
@@ -351,9 +400,13 @@ discard block |
||
351 | 400 | $Connection->db->beginTransaction(); |
352 | 401 | } |
353 | 402 | } |
354 | - if ($globalTransaction) $Connection->db->commit(); |
|
403 | + if ($globalTransaction) { |
|
404 | + $Connection->db->commit(); |
|
405 | + } |
|
355 | 406 | } catch(PDOException $e) { |
356 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
407 | + if ($globalTransaction) { |
|
408 | + $Connection->db->rollBack(); |
|
409 | + } |
|
357 | 410 | echo $e->getMessage(); |
358 | 411 | } |
359 | 412 | $sth_check->closeCursor(); |
@@ -392,8 +445,11 @@ discard block |
||
392 | 445 | return "error : ".$e->getMessage(); |
393 | 446 | } |
394 | 447 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
395 | - if ($row['nb'] > 0) return false; |
|
396 | - else return true; |
|
448 | + if ($row['nb'] > 0) { |
|
449 | + return false; |
|
450 | + } else { |
|
451 | + return true; |
|
452 | + } |
|
397 | 453 | } |
398 | 454 | |
399 | 455 | public static function insert_last_accidents_update() { |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $gpx .= '<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&apos;sch-heim" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">'; |
42 | 42 | $gpx .= '<trk>'; |
43 | 43 | $gpx .= '<trkseg>'; |
44 | - foreach($spotter_history_array as $spotter_data) { |
|
45 | - $gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">'; |
|
46 | - $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
47 | - $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>'; |
|
44 | + foreach ($spotter_history_array as $spotter_data) { |
|
45 | + $gpx .= '<trkpt lat="'.sprintf("%.8f", $spotter_data['latitude']).'" lon="'.sprintf("%.8f", $spotter_data['longitude']).'">'; |
|
46 | + $gpx .= '<ele>'.sprintf("%.6f", $spotter_data['altitude']).'</ele>'; |
|
47 | + $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z", strtotime($spotter_data['date'])).'</time>'; |
|
48 | 48 | $gpx .= '</trkpt>'; |
49 | 49 | } |
50 | 50 | $gpx .= '</trkseg>'; |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
82 | 82 | if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
83 | 83 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
84 | - if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
84 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
85 | 85 | $data = $this->create_gpx($spotter_history_array); |
86 | 86 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
87 | 87 | $Common = new Common(); |
88 | - $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml','Accept: application/json')); |
|
89 | - $matching = json_decode($matching,true); |
|
88 | + $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml', 'Accept: application/json')); |
|
89 | + $matching = json_decode($matching, true); |
|
90 | 90 | if (isset($matching['diary']['entries'][0]['route']['links'])) { |
91 | 91 | $spotter_history_array = array(); |
92 | 92 | foreach ($matching['diary']['entries'][0]['route']['links'] as $match) { |
93 | 93 | if (isset($match['wpts'])) { |
94 | 94 | foreach ($match['wpts'] as $coord) { |
95 | - $spotter_history_array[] = array('longitude' => $coord['x'],'latitude' => $coord['y']); |
|
95 | + $spotter_history_array[] = array('longitude' => $coord['x'], 'latitude' => $coord['y']); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
@@ -111,22 +111,22 @@ discard block |
||
111 | 111 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
112 | 112 | $spotter_history_initial_array = array(); |
113 | 113 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
114 | - $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
115 | - $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
114 | + $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
115 | + $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
116 | 116 | } |
117 | 117 | $data = $this->create_gpx($spotter_history_array); |
118 | 118 | $url = 'https://graphhopper.com/api/1/match?vehicle=car&points_encoded=0&key='.$globalGraphHopperKey; |
119 | 119 | $Common = new Common(); |
120 | - $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml')); |
|
121 | - $matching = json_decode($matching,true); |
|
120 | + $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml')); |
|
121 | + $matching = json_decode($matching, true); |
|
122 | 122 | if (isset($matching['paths'][0]['points']['coordinates'])) { |
123 | 123 | $spotter_history_array = array(); |
124 | 124 | foreach ($matching['paths'][0]['points']['coordinates'] as $match) { |
125 | 125 | $coord = $match; |
126 | - $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
126 | + $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
127 | 127 | } |
128 | 128 | } |
129 | - $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
129 | + $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
130 | 130 | return $spotter_history_array; |
131 | 131 | } |
132 | 132 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
142 | 142 | $spotter_history_initial_array = array(); |
143 | 143 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
144 | - $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
145 | - $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
144 | + $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
145 | + $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
146 | 146 | } |
147 | 147 | $coord = ''; |
148 | 148 | $ts = ''; |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
159 | 159 | $Common = new Common(); |
160 | 160 | $matching = $Common->getData($url); |
161 | - $matching = json_decode($matching,true); |
|
161 | + $matching = json_decode($matching, true); |
|
162 | 162 | if (isset($matching['matchings'][0]['geometry']['coordinates'])) { |
163 | 163 | $spotter_history_array = array(); |
164 | 164 | foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) { |
165 | 165 | $coord = $match; |
166 | - $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
166 | + $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
167 | 167 | } |
168 | 168 | } |
169 | - $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
169 | + $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
170 | 170 | return $spotter_history_array; |
171 | 171 | } |
172 | 172 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
182 | 182 | $spotter_history_initial_array = array(); |
183 | 183 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
184 | - $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
185 | - $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
184 | + $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
185 | + $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
186 | 186 | } |
187 | 187 | $coord = ''; |
188 | 188 | $ts = ''; |
@@ -199,15 +199,15 @@ discard block |
||
199 | 199 | $url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson'; |
200 | 200 | $Common = new Common(); |
201 | 201 | $matching = $Common->getData($url); |
202 | - $matching = json_decode($matching,true); |
|
202 | + $matching = json_decode($matching, true); |
|
203 | 203 | if (isset($matching['matchings'][0]['geometry']['coordinates'])) { |
204 | 204 | $spotter_history_array = array(); |
205 | 205 | foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) { |
206 | 206 | $coord = $match; |
207 | - $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
207 | + $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
208 | 208 | } |
209 | 209 | } |
210 | - $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
210 | + $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
211 | 211 | return $spotter_history_array; |
212 | 212 | } |
213 | 213 |
@@ -79,9 +79,15 @@ discard block |
||
79 | 79 | |
80 | 80 | public function TrackMatching($spotter_history_array) { |
81 | 81 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
82 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
83 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
84 | - if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
82 | + if (!isset($globalMapMatchingMaxPts)) { |
|
83 | + $globalMapMatchingMaxPts = 100; |
|
84 | + } |
|
85 | + if (count($spotter_history_array) < 2) { |
|
86 | + return $spotter_history_array; |
|
87 | + } |
|
88 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
89 | + $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
90 | + } |
|
85 | 91 | $data = $this->create_gpx($spotter_history_array); |
86 | 92 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
87 | 93 | $Common = new Common(); |
@@ -107,8 +113,12 @@ discard block |
||
107 | 113 | */ |
108 | 114 | public function GraphHopper($spotter_history_array) { |
109 | 115 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
110 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
111 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
116 | + if (!isset($globalMapMatchingMaxPts)) { |
|
117 | + $globalMapMatchingMaxPts = 100; |
|
118 | + } |
|
119 | + if (count($spotter_history_array) < 2) { |
|
120 | + return $spotter_history_array; |
|
121 | + } |
|
112 | 122 | $spotter_history_initial_array = array(); |
113 | 123 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
114 | 124 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -137,8 +147,12 @@ discard block |
||
137 | 147 | */ |
138 | 148 | public function osmr($spotter_history_array) { |
139 | 149 | global $globalMapMatchingMaxPts; |
140 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50; |
|
141 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
150 | + if (!isset($globalMapMatchingMaxPts)) { |
|
151 | + $globalMapMatchingMaxPts = 50; |
|
152 | + } |
|
153 | + if (count($spotter_history_array) < 2) { |
|
154 | + return $spotter_history_array; |
|
155 | + } |
|
142 | 156 | $spotter_history_initial_array = array(); |
143 | 157 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
144 | 158 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -148,11 +162,17 @@ discard block |
||
148 | 162 | $ts = ''; |
149 | 163 | $rd = ''; |
150 | 164 | foreach ($spotter_history_array as $spotter_data) { |
151 | - if ($coord != '') $coord .= ';'; |
|
165 | + if ($coord != '') { |
|
166 | + $coord .= ';'; |
|
167 | + } |
|
152 | 168 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
153 | - if ($ts != '') $ts .= ';'; |
|
169 | + if ($ts != '') { |
|
170 | + $ts .= ';'; |
|
171 | + } |
|
154 | 172 | $ts .= strtotime($spotter_data['date']); |
155 | - if ($rd != '') $rd .= ';'; |
|
173 | + if ($rd != '') { |
|
174 | + $rd .= ';'; |
|
175 | + } |
|
156 | 176 | $rd .= '20'; |
157 | 177 | } |
158 | 178 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
@@ -177,8 +197,12 @@ discard block |
||
177 | 197 | */ |
178 | 198 | public function mapbox($spotter_history_array) { |
179 | 199 | global $globalMapMatchingMaxPts, $globalMapboxToken; |
180 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60; |
|
181 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
200 | + if (!isset($globalMapMatchingMaxPts)) { |
|
201 | + $globalMapMatchingMaxPts = 60; |
|
202 | + } |
|
203 | + if (count($spotter_history_array) < 2) { |
|
204 | + return $spotter_history_array; |
|
205 | + } |
|
182 | 206 | $spotter_history_initial_array = array(); |
183 | 207 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
184 | 208 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -188,11 +212,17 @@ discard block |
||
188 | 212 | $ts = ''; |
189 | 213 | $rd = ''; |
190 | 214 | foreach ($spotter_history_array as $spotter_data) { |
191 | - if ($coord != '') $coord .= ';'; |
|
215 | + if ($coord != '') { |
|
216 | + $coord .= ';'; |
|
217 | + } |
|
192 | 218 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
193 | - if ($ts != '') $ts .= ';'; |
|
219 | + if ($ts != '') { |
|
220 | + $ts .= ';'; |
|
221 | + } |
|
194 | 222 | $ts .= strtotime($spotter_data['date']); |
195 | - if ($rd != '') $rd .= ';'; |
|
223 | + if ($rd != '') { |
|
224 | + $rd .= ';'; |
|
225 | + } |
|
196 | 226 | $rd .= '20'; |
197 | 227 | } |
198 | 228 | //$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd; |
@@ -25,11 +25,11 @@ |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | - * Change IATA to ICAO value for ident |
|
29 | - * |
|
30 | - * @param String $ident ident |
|
31 | - * @return String the icao |
|
32 | - */ |
|
28 | + * Change IATA to ICAO value for ident |
|
29 | + * |
|
30 | + * @param String $ident ident |
|
31 | + * @return String the icao |
|
32 | + */ |
|
33 | 33 | public function ident2icao($ident) { |
34 | 34 | $Spotter = new Spotter(); |
35 | 35 | if (!is_numeric(substr($ident, 0, 3))) { |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | - * Add schedule data to database |
|
31 | - * @param String $ident aircraft ident |
|
32 | - * @param String $departure_airport_icao departure airport icao |
|
33 | - * @param String $departure_airport_time departure airport time |
|
34 | - * @param String $arrival_airport_icao arrival airport icao |
|
35 | - * @param String $arrival_airport_time arrival airport time |
|
30 | + * Add schedule data to database |
|
31 | + * @param String $ident aircraft ident |
|
32 | + * @param String $departure_airport_icao departure airport icao |
|
33 | + * @param String $departure_airport_time departure airport time |
|
34 | + * @param String $arrival_airport_icao arrival airport icao |
|
35 | + * @param String $arrival_airport_time arrival airport time |
|
36 | 36 | / @param String $source source of data |
37 | - */ |
|
37 | + */ |
|
38 | 38 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
39 | 39 | date_default_timezone_set('UTC'); |
40 | 40 | $date = date("Y-m-d H:i:s",time()); |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | } |
51 | 51 | if ($sth->fetchColumn() > 0) { |
52 | 52 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
53 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
54 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
53 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
54 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
55 | 55 | } elseif ($arrival_airport_time == '') { |
56 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
57 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
56 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
57 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
58 | 58 | } elseif ($departure_airport_time == '') { |
59 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
60 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
59 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
60 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
61 | 61 | } else { |
62 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
63 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
64 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
62 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
63 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
64 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
65 | 65 | } |
66 | 66 | try { |
67 | 67 | $sth = $this->db->prepare($query); |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function checkSchedule($ident) { |
150 | 150 | global $globalDBdriver; |
151 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
152 | - if ($globalDBdriver == 'mysql') { |
|
151 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
152 | + if ($globalDBdriver == 'mysql') { |
|
153 | 153 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1"; |
154 | 154 | } else { |
155 | 155 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident |
156 | 156 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
157 | 157 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
158 | 158 | } |
159 | - $query_values = array(':ident' => $ident); |
|
159 | + $query_values = array(':ident' => $ident); |
|
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute($query_values); |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | - * Get flight info from Air France |
|
173 | - * @param String $callsign The callsign |
|
174 | - * @param String $date date we want flight number info |
|
175 | - * @param String $carrier IATA code |
|
176 | - * @return Flight departure and arrival airports and time |
|
177 | - */ |
|
172 | + * Get flight info from Air France |
|
173 | + * @param String $callsign The callsign |
|
174 | + * @param String $date date we want flight number info |
|
175 | + * @param String $carrier IATA code |
|
176 | + * @return Flight departure and arrival airports and time |
|
177 | + */ |
|
178 | 178 | private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
179 | 179 | $Common = new Common(); |
180 | 180 | $check_date = new Datetime($date); |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | - * Get flight info from EasyJet |
|
214 | - * @param String $callsign The callsign |
|
215 | - * @param String $date date we want flight number info |
|
216 | - * @return Flight departure and arrival airports and time |
|
217 | - */ |
|
213 | + * Get flight info from EasyJet |
|
214 | + * @param String $callsign The callsign |
|
215 | + * @param String $date date we want flight number info |
|
216 | + * @return Flight departure and arrival airports and time |
|
217 | + */ |
|
218 | 218 | private function getEasyJet($callsign, $date = 'NOW') { |
219 | 219 | global $globalTimezone; |
220 | 220 | $Common = new Common(); |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
241 | - * Get flight info from Ryanair |
|
242 | - * @param String $callsign The callsign |
|
243 | - * @return Flight departure and arrival airports and time |
|
244 | - */ |
|
241 | + * Get flight info from Ryanair |
|
242 | + * @param String $callsign The callsign |
|
243 | + * @return Flight departure and arrival airports and time |
|
244 | + */ |
|
245 | 245 | private function getRyanair($callsign) { |
246 | 246 | $Common = new Common(); |
247 | 247 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | - * Get flight info from Swiss |
|
268 | - * @param String $callsign The callsign |
|
269 | - * @return Flight departure and arrival airports and time |
|
270 | - */ |
|
267 | + * Get flight info from Swiss |
|
268 | + * @param String $callsign The callsign |
|
269 | + * @return Flight departure and arrival airports and time |
|
270 | + */ |
|
271 | 271 | private function getSwiss($callsign) { |
272 | 272 | $Common = new Common(); |
273 | 273 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
299 | - * Get flight info from British Airways API |
|
300 | - * @param String $callsign The callsign |
|
301 | - * @param String $date date we want flight number info |
|
302 | - * @return Flight departure and arrival airports and time |
|
303 | - */ |
|
299 | + * Get flight info from British Airways API |
|
300 | + * @param String $callsign The callsign |
|
301 | + * @param String $date date we want flight number info |
|
302 | + * @return Flight departure and arrival airports and time |
|
303 | + */ |
|
304 | 304 | public function getBritishAirways($callsign, $date = 'NOW') { |
305 | 305 | global $globalBritishAirwaysKey; |
306 | 306 | $Common = new Common(); |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | - * Get flight info from Lutfhansa API |
|
328 | - * @param String $callsign The callsign |
|
329 | - * @param String $date date we want flight number info |
|
330 | - * @return Flight departure and arrival airports and time |
|
331 | - */ |
|
327 | + * Get flight info from Lutfhansa API |
|
328 | + * @param String $callsign The callsign |
|
329 | + * @param String $date date we want flight number info |
|
330 | + * @return Flight departure and arrival airports and time |
|
331 | + */ |
|
332 | 332 | public function getLufthansa($callsign, $date = 'NOW') { |
333 | 333 | global $globalLufthansaKey; |
334 | 334 | $Common = new Common(); |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
361 | - * Get flight info from Transavia API |
|
362 | - * @param String $callsign The callsign |
|
363 | - * @param String $date date we want flight number info |
|
364 | - * @return Flight departure and arrival airports and time |
|
365 | - */ |
|
361 | + * Get flight info from Transavia API |
|
362 | + * @param String $callsign The callsign |
|
363 | + * @param String $date date we want flight number info |
|
364 | + * @return Flight departure and arrival airports and time |
|
365 | + */ |
|
366 | 366 | public function getTransavia($callsign, $date = 'NOW') { |
367 | 367 | global $globalTransaviaKey; |
368 | 368 | $Common = new Common(); |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
391 | - * Get flight info from Tunisair |
|
392 | - * @param String $callsign The callsign |
|
393 | - * @return Flight departure and arrival airports and time |
|
394 | - */ |
|
391 | + * Get flight info from Tunisair |
|
392 | + * @param String $callsign The callsign |
|
393 | + * @return Flight departure and arrival airports and time |
|
394 | + */ |
|
395 | 395 | public function getTunisair($callsign) { |
396 | 396 | $Common = new Common(); |
397 | 397 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
411 | - * Get flight info from Vueling |
|
412 | - * @param String $callsign The callsign |
|
413 | - * @return Flight departure and arrival airports and time |
|
414 | - */ |
|
411 | + * Get flight info from Vueling |
|
412 | + * @param String $callsign The callsign |
|
413 | + * @return Flight departure and arrival airports and time |
|
414 | + */ |
|
415 | 415 | public function getVueling($callsign,$date = 'NOW') { |
416 | 416 | $Common = new Common(); |
417 | 417 | $check_date = new Datetime($date); |
@@ -433,11 +433,11 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
436 | - * Get flight info from Iberia |
|
437 | - * @param String $callsign The callsign |
|
438 | - * @param String $date date we want flight number info |
|
439 | - * @return Flight departure and arrival airports and time |
|
440 | - */ |
|
436 | + * Get flight info from Iberia |
|
437 | + * @param String $callsign The callsign |
|
438 | + * @param String $date date we want flight number info |
|
439 | + * @return Flight departure and arrival airports and time |
|
440 | + */ |
|
441 | 441 | public function getIberia($callsign, $date = 'NOW') { |
442 | 442 | $Common = new Common(); |
443 | 443 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -467,11 +467,11 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
470 | - * Get flight info from Star Alliance |
|
471 | - * @param String $callsign The callsign |
|
472 | - * @param String $date date we want flight number info |
|
473 | - * @return Flight departure and arrival airports and time |
|
474 | - */ |
|
470 | + * Get flight info from Star Alliance |
|
471 | + * @param String $callsign The callsign |
|
472 | + * @param String $date date we want flight number info |
|
473 | + * @return Flight departure and arrival airports and time |
|
474 | + */ |
|
475 | 475 | |
476 | 476 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
477 | 477 | $Common = new Common(); |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | |
504 | 504 | |
505 | 505 | /** |
506 | - * Get flight info from Alitalia |
|
507 | - * @param String $callsign The callsign |
|
508 | - * @param String $date date we want flight number info |
|
509 | - * @return Flight departure and arrival airports and time |
|
510 | - */ |
|
506 | + * Get flight info from Alitalia |
|
507 | + * @param String $callsign The callsign |
|
508 | + * @param String $date date we want flight number info |
|
509 | + * @return Flight departure and arrival airports and time |
|
510 | + */ |
|
511 | 511 | private function getAlitalia($callsign, $date = 'NOW') { |
512 | 512 | $Common = new Common(); |
513 | 513 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -526,11 +526,11 @@ discard block |
||
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
529 | - * Get flight info from Brussels airlines |
|
530 | - * @param String $callsign The callsign |
|
531 | - * @param String $date date we want flight number info |
|
532 | - * @return Flight departure and arrival airports and time |
|
533 | - */ |
|
529 | + * Get flight info from Brussels airlines |
|
530 | + * @param String $callsign The callsign |
|
531 | + * @param String $date date we want flight number info |
|
532 | + * @return Flight departure and arrival airports and time |
|
533 | + */ |
|
534 | 534 | private function getBrussels($callsign, $date = 'NOW') { |
535 | 535 | $Common = new Common(); |
536 | 536 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -540,24 +540,24 @@ discard block |
||
540 | 540 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
541 | 541 | $data = $Common->getData($url); |
542 | 542 | if ($data != '') { |
543 | - //echo $data; |
|
544 | - $parsed_json = json_decode($data,true); |
|
545 | - if (isset($parsed_json[0]['FromAirportCode'])) { |
|
543 | + //echo $data; |
|
544 | + $parsed_json = json_decode($data,true); |
|
545 | + if (isset($parsed_json[0]['FromAirportCode'])) { |
|
546 | 546 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
547 | 547 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
548 | 548 | $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
549 | 549 | $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
550 | 550 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
551 | - } |
|
551 | + } |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
556 | - * Get flight info from FlightRadar24 |
|
557 | - * @param String $callsign The callsign |
|
558 | - * @param String $date date we want flight number info |
|
559 | - * @return Flight departure and arrival airports and time |
|
560 | - */ |
|
556 | + * Get flight info from FlightRadar24 |
|
557 | + * @param String $callsign The callsign |
|
558 | + * @param String $date date we want flight number info |
|
559 | + * @return Flight departure and arrival airports and time |
|
560 | + */ |
|
561 | 561 | /* |
562 | 562 | public function getFlightRadar24($callsign, $date = 'NOW') { |
563 | 563 | $Common = new Common(); |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | } |
587 | 587 | */ |
588 | 588 | /** |
589 | - * Get flight info from Lufthansa |
|
590 | - * @param String $callsign The callsign |
|
591 | - * @param String $date date we want flight number info |
|
592 | - * @return Flight departure and arrival airports and time |
|
593 | - */ |
|
589 | + * Get flight info from Lufthansa |
|
590 | + * @param String $callsign The callsign |
|
591 | + * @param String $date date we want flight number info |
|
592 | + * @return Flight departure and arrival airports and time |
|
593 | + */ |
|
594 | 594 | |
595 | 595 | /* private function getLufthansa($callsign, $date = 'NOW') { |
596 | 596 | $Common = new Common(); |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | } |
619 | 619 | */ |
620 | 620 | /** |
621 | - * Get flight info from flytap |
|
622 | - * @param String $callsign The callsign |
|
623 | - * @return Flight departure and arrival airports and time |
|
624 | - */ |
|
621 | + * Get flight info from flytap |
|
622 | + * @param String $callsign The callsign |
|
623 | + * @return Flight departure and arrival airports and time |
|
624 | + */ |
|
625 | 625 | private function getFlyTap($callsign) { |
626 | 626 | $Common = new Common(); |
627 | 627 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -644,10 +644,10 @@ discard block |
||
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
647 | - * Get flight info from flightmapper |
|
648 | - * @param String $callsign The callsign |
|
649 | - * @return Flight departure and arrival airports and time |
|
650 | - */ |
|
647 | + * Get flight info from flightmapper |
|
648 | + * @param String $callsign The callsign |
|
649 | + * @return Flight departure and arrival airports and time |
|
650 | + */ |
|
651 | 651 | public function getFlightMapper($callsign) { |
652 | 652 | $Common = new Common(); |
653 | 653 | $airline_icao = ''; |
@@ -675,11 +675,11 @@ discard block |
||
675 | 675 | $aarr = ''; |
676 | 676 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
677 | 677 | if ($n == 7) { |
678 | - $departureTime = $dhour; |
|
679 | - $arrivalTime = $ahour; |
|
680 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
681 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
682 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
678 | + $departureTime = $dhour; |
|
679 | + $arrivalTime = $ahour; |
|
680 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
681 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
682 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | } |
@@ -687,10 +687,10 @@ discard block |
||
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
690 | - * Get flight info from flightaware |
|
691 | - * @param String $callsign The callsign |
|
692 | - * @return Flight departure and arrival airports and time |
|
693 | - */ |
|
690 | + * Get flight info from flightaware |
|
691 | + * @param String $callsign The callsign |
|
692 | + * @return Flight departure and arrival airports and time |
|
693 | + */ |
|
694 | 694 | public function getFlightAware($callsign) { |
695 | 695 | global $globalFlightAwareUsername, $globalFlightAwarePassword; |
696 | 696 | date_default_timezone_set('UTC'); |
@@ -715,11 +715,11 @@ discard block |
||
715 | 715 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
716 | 716 | if (isset($flight['origin'])) { |
717 | 717 | return array( |
718 | - 'DepartureAirportIATA' => $flight['origin']['alternate_ident'], |
|
719 | - 'DepartureTime' => $flight['filed_departure_time']['time'], |
|
720 | - 'ArrivalAirportIATA' => $flight['destination']['alternate_ident'], |
|
721 | - 'ArrivalTime' => $flight['filed_arrival_time']['time'], |
|
722 | - 'Source' => 'website_flightaware'); |
|
718 | + 'DepartureAirportIATA' => $flight['origin']['alternate_ident'], |
|
719 | + 'DepartureTime' => $flight['filed_departure_time']['time'], |
|
720 | + 'ArrivalAirportIATA' => $flight['destination']['alternate_ident'], |
|
721 | + 'ArrivalTime' => $flight['filed_arrival_time']['time'], |
|
722 | + 'Source' => 'website_flightaware'); |
|
723 | 723 | } |
724 | 724 | } |
725 | 725 | } |
@@ -732,21 +732,21 @@ discard block |
||
732 | 732 | $flight = reset($flights['flights']); |
733 | 733 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
734 | 734 | return array( |
735 | - 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
|
736 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
737 | - 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
|
738 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
739 | - 'Source' => 'website_flightaware'); |
|
735 | + 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
|
736 | + 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
737 | + 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
|
738 | + 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
739 | + 'Source' => 'website_flightaware'); |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | return array(); |
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
746 | - * Get flight info from CostToTravel |
|
747 | - * @param String $callsign The callsign |
|
748 | - * @return Flight departure and arrival airports and time |
|
749 | - */ |
|
746 | + * Get flight info from CostToTravel |
|
747 | + * @param String $callsign The callsign |
|
748 | + * @return Flight departure and arrival airports and time |
|
749 | + */ |
|
750 | 750 | public function getCostToTravel($callsign) { |
751 | 751 | $Common = new Common(); |
752 | 752 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -769,11 +769,11 @@ discard block |
||
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
772 | - * Get flight info from Air Canada |
|
773 | - * @param String $callsign The callsign |
|
774 | - * @param String $date date we want flight number info |
|
775 | - * @return Flight departure and arrival airports and time |
|
776 | - */ |
|
772 | + * Get flight info from Air Canada |
|
773 | + * @param String $callsign The callsign |
|
774 | + * @param String $date date we want flight number info |
|
775 | + * @return Flight departure and arrival airports and time |
|
776 | + */ |
|
777 | 777 | private function getAirCanada($callsign,$date = 'NOW') { |
778 | 778 | $Common = new Common(); |
779 | 779 | if (class_exists("DomDocument") === FALSE) return array(); |
@@ -798,11 +798,11 @@ discard block |
||
798 | 798 | } |
799 | 799 | |
800 | 800 | /** |
801 | - * Get flight info from Vietnam Airlines |
|
802 | - * @param String $callsign The callsign |
|
803 | - * @param String $date date we want flight number info |
|
804 | - * @return Flight departure and arrival airports and time |
|
805 | - */ |
|
801 | + * Get flight info from Vietnam Airlines |
|
802 | + * @param String $callsign The callsign |
|
803 | + * @param String $date date we want flight number info |
|
804 | + * @return Flight departure and arrival airports and time |
|
805 | + */ |
|
806 | 806 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
807 | 807 | $Common = new Common(); |
808 | 808 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
827 | - * Get flight info from Air Berlin |
|
828 | - * @param String $callsign The callsign |
|
829 | - * @param String $date date we want flight number info |
|
830 | - * @param String $carrier airline code |
|
831 | - * @return Flight departure and arrival airports and time |
|
832 | - */ |
|
827 | + * Get flight info from Air Berlin |
|
828 | + * @param String $callsign The callsign |
|
829 | + * @param String $date date we want flight number info |
|
830 | + * @param String $carrier airline code |
|
831 | + * @return Flight departure and arrival airports and time |
|
832 | + */ |
|
833 | 833 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
834 | 834 | $Common = new Common(); |
835 | 835 | date_default_timezone_set('UTC'); |
@@ -858,11 +858,11 @@ discard block |
||
858 | 858 | $table = $Common->table2array($data); |
859 | 859 | $flight = $table; |
860 | 860 | if (isset($flight[5][4])) { |
861 | - $arrivalTime = $flight[5][4]; |
|
862 | - $arrivalAirport = $flight[5][3]; |
|
861 | + $arrivalTime = $flight[5][4]; |
|
862 | + $arrivalAirport = $flight[5][3]; |
|
863 | 863 | } else { |
864 | - $arrivalTime = ''; |
|
865 | - $arrivalAirport = ''; |
|
864 | + $arrivalTime = ''; |
|
865 | + $arrivalAirport = ''; |
|
866 | 866 | } |
867 | 867 | } else return array(); |
868 | 868 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param String $arrival_airport_time arrival airport time |
36 | 36 | / @param String $source source of data |
37 | 37 | */ |
38 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
38 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
39 | 39 | date_default_timezone_set('UTC'); |
40 | - $date = date("Y-m-d H:i:s",time()); |
|
40 | + $date = date("Y-m-d H:i:s", time()); |
|
41 | 41 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
42 | 42 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
43 | 43 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -45,69 +45,69 @@ discard block |
||
45 | 45 | try { |
46 | 46 | $sth = $this->db->prepare($query); |
47 | 47 | $sth->execute($query_values); |
48 | - } catch(PDOException $e) { |
|
48 | + } catch (PDOException $e) { |
|
49 | 49 | return "error : ".$e->getMessage(); |
50 | 50 | } |
51 | 51 | if ($sth->fetchColumn() > 0) { |
52 | 52 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
53 | 53 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
54 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
54 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
55 | 55 | } elseif ($arrival_airport_time == '') { |
56 | 56 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
57 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
57 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
58 | 58 | } elseif ($departure_airport_time == '') { |
59 | 59 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
60 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
60 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
61 | 61 | } else { |
62 | 62 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
63 | 63 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
64 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
64 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
65 | 65 | } |
66 | 66 | try { |
67 | 67 | $sth = $this->db->prepare($query); |
68 | 68 | $sth->execute($query_values); |
69 | - } catch(PDOException $e) { |
|
69 | + } catch (PDOException $e) { |
|
70 | 70 | return "error : ".$e->getMessage(); |
71 | 71 | } |
72 | 72 | if ($sth->fetchColumn() == 0) { |
73 | 73 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
74 | 74 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
75 | 75 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
76 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
76 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
77 | 77 | } elseif ($arrival_airport_time == '') { |
78 | 78 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
79 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
79 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
80 | 80 | } elseif ($departure_airport_time == '') { |
81 | 81 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
82 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
82 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
83 | 83 | } else { |
84 | 84 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
85 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
85 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
86 | 86 | } |
87 | 87 | try { |
88 | 88 | $sth = $this->db->prepare($query); |
89 | 89 | $sth->execute($query_values); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | } else { |
94 | 94 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
95 | 95 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
96 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
96 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
97 | 97 | try { |
98 | 98 | $sth = $this->db->prepare($query); |
99 | 99 | $sth->execute($query_values); |
100 | - } catch(PDOException $e) { |
|
100 | + } catch (PDOException $e) { |
|
101 | 101 | return "error : ".$e->getMessage(); |
102 | 102 | } |
103 | 103 | } |
104 | 104 | } else { |
105 | 105 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
106 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
106 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
107 | 107 | try { |
108 | 108 | $sth = $this->db->prepare($query); |
109 | 109 | $sth->execute($query_values); |
110 | - } catch(PDOException $e) { |
|
110 | + } catch (PDOException $e) { |
|
111 | 111 | return "error : ".$e->getMessage(); |
112 | 112 | } |
113 | 113 | } |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getSchedule($ident) { |
122 | 122 | $Translation = new Translation($this->db); |
123 | - $operator = $Translation->checkTranslation($ident,false); |
|
123 | + $operator = $Translation->checkTranslation($ident, false); |
|
124 | 124 | if ($ident != $operator) { |
125 | 125 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
126 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
126 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
127 | 127 | } else { |
128 | 128 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
129 | 129 | $query_values = array(':ident' => $ident); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | try { |
132 | 132 | $sth = $this->db->prepare($query); |
133 | 133 | $sth->execute($query_values); |
134 | - } catch(PDOException $e) { |
|
134 | + } catch (PDOException $e) { |
|
135 | 135 | return "error : ".$e->getMessage(); |
136 | 136 | } |
137 | 137 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute($query_values); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | return "error : ".$e->getMessage(); |
165 | 165 | } |
166 | 166 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | * @param String $carrier IATA code |
176 | 176 | * @return Flight departure and arrival airports and time |
177 | 177 | */ |
178 | - private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
178 | + private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
179 | 179 | $Common = new Common(); |
180 | 180 | $check_date = new Datetime($date); |
181 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
182 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
181 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
182 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
183 | 183 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
184 | 184 | $json = $Common->getData($url); |
185 | 185 | |
186 | 186 | $parsed_json = json_decode($json); |
187 | - if (property_exists($parsed_json,'errors') === false) { |
|
187 | + if (property_exists($parsed_json, 'errors') === false) { |
|
188 | 188 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
189 | 189 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
190 | 190 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
195 | 195 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
196 | 196 | |
197 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
197 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
198 | 198 | $DepartureAirportIata = $originiata[1]; |
199 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
199 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
200 | 200 | $ArrivalAirportIata = $destinationiata[1]; |
201 | 201 | |
202 | 202 | /* |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
206 | 206 | */ |
207 | 207 | |
208 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
208 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
209 | 209 | } else return array(); |
210 | 210 | } |
211 | 211 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | $Common = new Common(); |
221 | 221 | date_default_timezone_set($globalTimezone); |
222 | 222 | $check_date = new Datetime($date); |
223 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
224 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
223 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
224 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
225 | 225 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
226 | 226 | $json = $Common->getData($url); |
227 | 227 | $parsed_json = json_decode($json); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
234 | 234 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
235 | 235 | |
236 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
236 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
237 | 237 | } else return array(); |
238 | 238 | } |
239 | 239 | |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | private function getRyanair($callsign) { |
246 | 246 | $Common = new Common(); |
247 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
248 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
247 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
248 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
249 | 249 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
250 | 250 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
251 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
252 | - $json = $Common->getData($url,'post',$post,$headers); |
|
251 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
252 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
253 | 253 | $parsed_json = json_decode($json); |
254 | 254 | if (isset($parsed_json->{'flightInfo'})) { |
255 | 255 | $flights = $parsed_json->{'flightInfo'}; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
259 | 259 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
260 | 260 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
261 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
261 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
262 | 262 | } else return array(); |
263 | 263 | } else return array(); |
264 | 264 | } |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | */ |
271 | 271 | private function getSwiss($callsign) { |
272 | 272 | $Common = new Common(); |
273 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
274 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
273 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
274 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
275 | 275 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
276 | 276 | $json = $Common->getData($url); |
277 | 277 | $parsed_json = json_decode($json); |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
286 | 286 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
287 | 287 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
288 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
289 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
288 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
289 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
293 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
293 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
294 | 294 | } else return array(); |
295 | 295 | } else return array(); |
296 | 296 | } |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | global $globalBritishAirwaysKey; |
306 | 306 | $Common = new Common(); |
307 | 307 | $check_date = new Datetime($date); |
308 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
309 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
308 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
309 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
310 | 310 | if ($globalBritishAirwaysKey == '') return array(); |
311 | 311 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
312 | 312 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
313 | - $json = $Common->getData($url,'get','',$headers); |
|
313 | + $json = $Common->getData($url, 'get', '', $headers); |
|
314 | 314 | if ($json == '') return array(); |
315 | 315 | $parsed_json = json_decode($json); |
316 | 316 | $flights = $parsed_json->{'FlightsResponse'}; |
317 | 317 | if (count($flights) > 0) { |
318 | 318 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
319 | 319 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
320 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
321 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
322 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
320 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
321 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
322 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
323 | 323 | } else return array(); |
324 | 324 | } |
325 | 325 | |
@@ -333,27 +333,27 @@ discard block |
||
333 | 333 | global $globalLufthansaKey; |
334 | 334 | $Common = new Common(); |
335 | 335 | $check_date = new Datetime($date); |
336 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
337 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
336 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
337 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
338 | 338 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
339 | 339 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
340 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
341 | - $data = $Common->getData($url,'post',$post); |
|
340 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
341 | + $data = $Common->getData($url, 'post', $post); |
|
342 | 342 | $parsed_data = json_decode($data); |
343 | 343 | if (!isset($parsed_data->{'access_token'})) return array(); |
344 | 344 | $token = $parsed_data->{'access_token'}; |
345 | 345 | |
346 | 346 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
347 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
348 | - $json = $Common->getData($url,'get','',$headers); |
|
347 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
348 | + $json = $Common->getData($url, 'get', '', $headers); |
|
349 | 349 | if ($json == '') return array(); |
350 | 350 | $parsed_json = json_decode($json); |
351 | 351 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
352 | 352 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
353 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
353 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
354 | 354 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
355 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
356 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
355 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
356 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
357 | 357 | } else return array(); |
358 | 358 | } |
359 | 359 | |
@@ -367,23 +367,23 @@ discard block |
||
367 | 367 | global $globalTransaviaKey; |
368 | 368 | $Common = new Common(); |
369 | 369 | $check_date = new Datetime($date); |
370 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
371 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
370 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
371 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
372 | 372 | if ($globalTransaviaKey == '') return array(); |
373 | 373 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
374 | 374 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
375 | 375 | $headers = array('apikey: '.$globalTransaviaKey); |
376 | - $json = $Common->getData($url,'get','',$headers); |
|
376 | + $json = $Common->getData($url, 'get', '', $headers); |
|
377 | 377 | //echo 'result : '.$json; |
378 | 378 | if ($json == '') return array(); |
379 | 379 | $parsed_json = json_decode($json); |
380 | 380 | |
381 | 381 | if (isset($parsed_json->{'data'}[0])) { |
382 | 382 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
383 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
383 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
384 | 384 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
385 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
386 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
385 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
386 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
387 | 387 | } else return array(); |
388 | 388 | } |
389 | 389 | |
@@ -394,14 +394,14 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function getTunisair($callsign) { |
396 | 396 | $Common = new Common(); |
397 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
398 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
397 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
398 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
399 | 399 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
400 | 400 | $data = $Common->getData($url); |
401 | 401 | $table = $Common->table2array($data); |
402 | 402 | foreach ($table as $flight) { |
403 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
404 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
403 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
404 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | return array(); |
@@ -412,21 +412,21 @@ discard block |
||
412 | 412 | * @param String $callsign The callsign |
413 | 413 | * @return Flight departure and arrival airports and time |
414 | 414 | */ |
415 | - public function getVueling($callsign,$date = 'NOW') { |
|
415 | + public function getVueling($callsign, $date = 'NOW') { |
|
416 | 416 | $Common = new Common(); |
417 | 417 | $check_date = new Datetime($date); |
418 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
419 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
420 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
418 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
419 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
420 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
421 | 421 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
422 | 422 | $data = $Common->getData($url); |
423 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
423 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
424 | 424 | if ($data != '') { |
425 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
426 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
427 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
428 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
429 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
425 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
426 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
427 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
428 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
429 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
430 | 430 | else return array(); |
431 | 431 | } |
432 | 432 | return array(); |
@@ -440,27 +440,27 @@ discard block |
||
440 | 440 | */ |
441 | 441 | public function getIberia($callsign, $date = 'NOW') { |
442 | 442 | $Common = new Common(); |
443 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
443 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
444 | 444 | $check_date = new Datetime($date); |
445 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
445 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
446 | 446 | $url = "https://www.iberia.com/web/flightDetail.do"; |
447 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
448 | - $data = $Common->getData($url,'post',$post); |
|
447 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
448 | + $data = $Common->getData($url, 'post', $post); |
|
449 | 449 | if ($data != '') { |
450 | 450 | $table = $Common->table2array($data); |
451 | 451 | //print_r($table); |
452 | 452 | if (count($table) > 0) { |
453 | 453 | $flight = $table; |
454 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
455 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
454 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
455 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
456 | 456 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
457 | 457 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
458 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
459 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
458 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
459 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
460 | 460 | if ($arrivalTime == 'Hora estimada de llegada') { |
461 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
462 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
463 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
461 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
462 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
463 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | return array(); |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | * @return Flight departure and arrival airports and time |
474 | 474 | */ |
475 | 475 | |
476 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
476 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
477 | 477 | $Common = new Common(); |
478 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
478 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
479 | 479 | $check_date = new Datetime($date); |
480 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
480 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
481 | 481 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
482 | 482 | $data = $Common->getData($url); |
483 | 483 | if ($data != '') { |
@@ -486,13 +486,13 @@ discard block |
||
486 | 486 | $flight = $table; |
487 | 487 | //print_r($table); |
488 | 488 | if (isset($flight[25]) && isset($flight[29])) { |
489 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
490 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
489 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
490 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
491 | 491 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
492 | 492 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
493 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
494 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
495 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
493 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
494 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
495 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
496 | 496 | } else return array(); |
497 | 497 | } |
498 | 498 | |
@@ -510,10 +510,10 @@ discard block |
||
510 | 510 | */ |
511 | 511 | private function getAlitalia($callsign, $date = 'NOW') { |
512 | 512 | $Common = new Common(); |
513 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
513 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
514 | 514 | $check_date = new Datetime($date); |
515 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
516 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
515 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
516 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
517 | 517 | $data = $Common->getData($url); |
518 | 518 | if ($data != '') { |
519 | 519 | $table = $Common->text2array($data); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | $ArrivalAirportIata = ''; |
522 | 522 | $departureTime = $table[4]; |
523 | 523 | $arrivalTime = $table[5]; |
524 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
524 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
@@ -533,21 +533,21 @@ discard block |
||
533 | 533 | */ |
534 | 534 | private function getBrussels($callsign, $date = 'NOW') { |
535 | 535 | $Common = new Common(); |
536 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
536 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
537 | 537 | $check_date = new Datetime($date); |
538 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
538 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
539 | 539 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
540 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
540 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
541 | 541 | $data = $Common->getData($url); |
542 | 542 | if ($data != '') { |
543 | 543 | //echo $data; |
544 | - $parsed_json = json_decode($data,true); |
|
544 | + $parsed_json = json_decode($data, true); |
|
545 | 545 | if (isset($parsed_json[0]['FromAirportCode'])) { |
546 | 546 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
547 | 547 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
548 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
549 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
550 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
548 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
549 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
550 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -624,21 +624,21 @@ discard block |
||
624 | 624 | */ |
625 | 625 | private function getFlyTap($callsign) { |
626 | 626 | $Common = new Common(); |
627 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
628 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
627 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
628 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
629 | 629 | //$check_date = new Datetime($date); |
630 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
631 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
632 | - $data = $Common->getData($url,'post',$post); |
|
630 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
631 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
632 | + $data = $Common->getData($url, 'post', $post); |
|
633 | 633 | if ($data != '') { |
634 | 634 | $table = $Common->table2array($data); |
635 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
636 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
637 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
638 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
635 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
636 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
637 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
638 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
639 | 639 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
640 | 640 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
641 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
641 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
642 | 642 | } |
643 | 643 | return array(); |
644 | 644 | } |
@@ -660,10 +660,10 @@ discard block |
||
660 | 660 | } |
661 | 661 | } |
662 | 662 | if ($airline_icao == '') return array(); |
663 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
664 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
663 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
664 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
665 | 665 | //$check_date = new Datetime($date); |
666 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
666 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
667 | 667 | $data = $Common->getData($url); |
668 | 668 | if ($data != '') { |
669 | 669 | $table = $Common->table2array($data); |
@@ -673,13 +673,13 @@ discard block |
||
673 | 673 | $darr = ''; |
674 | 674 | $ahour = ''; |
675 | 675 | $aarr = ''; |
676 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
676 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
677 | 677 | if ($n == 7) { |
678 | 678 | $departureTime = $dhour; |
679 | 679 | $arrivalTime = $ahour; |
680 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
681 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
682 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
680 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
681 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
682 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | } |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | $url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign; |
712 | 712 | $data = $Common->getData($url); |
713 | 713 | if ($data != '') { |
714 | - $result = json_decode($data,true); |
|
714 | + $result = json_decode($data, true); |
|
715 | 715 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
716 | 716 | if (isset($flight['origin'])) { |
717 | 717 | return array( |
@@ -724,18 +724,18 @@ discard block |
||
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
727 | - $url= "http://flightaware.com/live/flight/".$callsign; |
|
727 | + $url = "http://flightaware.com/live/flight/".$callsign; |
|
728 | 728 | $data = $Common->getData($url); |
729 | 729 | if ($data != '') { |
730 | - preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result); |
|
731 | - $flights = json_decode($result[1],true); |
|
730 | + preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result); |
|
731 | + $flights = json_decode($result[1], true); |
|
732 | 732 | $flight = reset($flights['flights']); |
733 | 733 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
734 | 734 | return array( |
735 | 735 | 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
736 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
736 | + 'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
737 | 737 | 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
738 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
738 | + 'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
739 | 739 | 'Source' => 'website_flightaware'); |
740 | 740 | } |
741 | 741 | } |
@@ -749,20 +749,20 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function getCostToTravel($callsign) { |
751 | 751 | $Common = new Common(); |
752 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
752 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
753 | 753 | //$check_date = new Datetime($date); |
754 | 754 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
755 | 755 | $data = $Common->getData($url); |
756 | 756 | if ($data != '') { |
757 | 757 | $table = $Common->table2array($data); |
758 | 758 | if (isset($table[11][1])) { |
759 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
759 | + if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5); |
|
760 | 760 | else $departureTime = ''; |
761 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
761 | + if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5); |
|
762 | 762 | else $arrivalTime = ''; |
763 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
764 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
765 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
763 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
764 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
765 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | return array(); |
@@ -774,14 +774,14 @@ discard block |
||
774 | 774 | * @param String $date date we want flight number info |
775 | 775 | * @return Flight departure and arrival airports and time |
776 | 776 | */ |
777 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
777 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
778 | 778 | $Common = new Common(); |
779 | 779 | if (class_exists("DomDocument") === FALSE) return array(); |
780 | 780 | date_default_timezone_set('UTC'); |
781 | 781 | $check_date = new Datetime($date); |
782 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
783 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
784 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
782 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
783 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
784 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
785 | 785 | $data = $Common->getData($url); |
786 | 786 | $dom = new DomDocument(); |
787 | 787 | $dom->loadXML($data); |
@@ -789,11 +789,11 @@ discard block |
||
789 | 789 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
790 | 790 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
791 | 791 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
792 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
792 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
793 | 793 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
794 | 794 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
795 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
796 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
795 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
796 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
797 | 797 | } else return array(); |
798 | 798 | } |
799 | 799 | |
@@ -805,21 +805,21 @@ discard block |
||
805 | 805 | */ |
806 | 806 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
807 | 807 | $Common = new Common(); |
808 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
808 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
809 | 809 | $check_date = new Datetime($date); |
810 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
811 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
810 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
811 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
812 | 812 | $data = $Common->getData($url); |
813 | 813 | if ($data != '') { |
814 | 814 | $table = $Common->table2array($data); |
815 | 815 | $flight = $table; |
816 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
817 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
816 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
817 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
818 | 818 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
819 | 819 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
820 | 820 | $departureTime = $flight[5][1]; |
821 | 821 | $arrivalTime = $flight[23][1]; |
822 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
822 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
823 | 823 | } |
824 | 824 | } |
825 | 825 | |
@@ -830,16 +830,16 @@ discard block |
||
830 | 830 | * @param String $carrier airline code |
831 | 831 | * @return Flight departure and arrival airports and time |
832 | 832 | */ |
833 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
833 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
834 | 834 | $Common = new Common(); |
835 | 835 | date_default_timezone_set('UTC'); |
836 | 836 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
837 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
837 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
838 | 838 | $check_date = new Datetime($date); |
839 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
840 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
841 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
842 | - $data = $Common->getData($url,'post',$post); |
|
839 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
840 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
841 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
842 | + $data = $Common->getData($url, 'post', $post); |
|
843 | 843 | //echo $data; |
844 | 844 | $DepartureAirportIata = ''; |
845 | 845 | $ArrivalAirportIata = ''; |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
853 | 853 | else $departureAirport = ''; |
854 | 854 | } else return array(); |
855 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
856 | - $data = $Common->getData($url,'post',$post); |
|
855 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
856 | + $data = $Common->getData($url, 'post', $post); |
|
857 | 857 | if ($data != '') { |
858 | 858 | $table = $Common->table2array($data); |
859 | 859 | $flight = $table; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | } |
882 | 882 | } |
883 | 883 | if (isset($DepartureAirportIata)) { |
884 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
884 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
885 | 885 | } else return array(); |
886 | 886 | } |
887 | 887 | |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * @param String $date Date |
892 | 892 | * @return Array Schedules info |
893 | 893 | */ |
894 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
894 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
895 | 895 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline; |
896 | 896 | //$Common = new Common(); |
897 | 897 | if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | // Brussels Airlines |
962 | 962 | case "BEL": |
963 | 963 | case "SN": |
964 | - return $this->getBrussels($ident,$date); |
|
964 | + return $this->getBrussels($ident, $date); |
|
965 | 965 | /* |
966 | 966 | // Copa Airlines |
967 | 967 | case "CMP": |
@@ -1046,17 +1046,17 @@ discard block |
||
1046 | 1046 | // Air France |
1047 | 1047 | case "AF": |
1048 | 1048 | case "AFR": |
1049 | - return $this->getAirFrance($ident,$date,'AF'); |
|
1049 | + return $this->getAirFrance($ident, $date, 'AF'); |
|
1050 | 1050 | // HOP |
1051 | 1051 | case "A5": |
1052 | 1052 | case "HOP": |
1053 | - return $this->getAirFrance($ident,$date,'A5'); |
|
1053 | + return $this->getAirFrance($ident, $date, 'A5'); |
|
1054 | 1054 | // EasyJet |
1055 | 1055 | case "U2": |
1056 | 1056 | case "DS": |
1057 | 1057 | case "EZY": |
1058 | 1058 | case "EZS": |
1059 | - return $this->getEasyJet($ident,$date); |
|
1059 | + return $this->getEasyJet($ident, $date); |
|
1060 | 1060 | // Ryanair |
1061 | 1061 | case "FR": |
1062 | 1062 | case "RYR": |
@@ -1106,25 +1106,25 @@ discard block |
||
1106 | 1106 | return $this->getIberia($ident); |
1107 | 1107 | // Vietnam Airlines |
1108 | 1108 | case "HVN": |
1109 | - return $this->getVietnamAirlines($ident,$date); |
|
1109 | + return $this->getVietnamAirlines($ident, $date); |
|
1110 | 1110 | // Air Berlin |
1111 | 1111 | case "AB": |
1112 | 1112 | case "BER": |
1113 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
1113 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
1114 | 1114 | // NIKI |
1115 | 1115 | case "HG": |
1116 | 1116 | case "NLY": |
1117 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
1117 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
1118 | 1118 | // BelAir |
1119 | 1119 | case "4T": |
1120 | 1120 | case "BHP": |
1121 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
1121 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
1122 | 1122 | default: |
1123 | 1123 | // Randomly use a generic function to get hours |
1124 | 1124 | if (strlen($airline_icao) == 2) { |
1125 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1125 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1126 | 1126 | if (count($globalSchedulesSources) > 0) { |
1127 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
1127 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
1128 | 1128 | $source = $globalSchedulesSources[$rand]; |
1129 | 1129 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
1130 | 1130 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | public function __construct($dbc = null) { |
24 | 24 | $Connection = new Connection($dbc); |
25 | 25 | $this->db = $Connection->db(); |
26 | - if ($this->db === null) die('Error: No DB connection.'); |
|
26 | + if ($this->db === null) { |
|
27 | + die('Error: No DB connection.'); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | /** |
@@ -138,7 +140,9 @@ discard block |
||
138 | 140 | $sth->closeCursor(); |
139 | 141 | if (count($row) > 0) { |
140 | 142 | return $row; |
141 | - } else return array(); |
|
143 | + } else { |
|
144 | + return array(); |
|
145 | + } |
|
142 | 146 | } |
143 | 147 | |
144 | 148 | /* |
@@ -179,7 +183,9 @@ discard block |
||
179 | 183 | $Common = new Common(); |
180 | 184 | $check_date = new Datetime($date); |
181 | 185 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
182 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
186 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
187 | + return array(); |
|
188 | + } |
|
183 | 189 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
184 | 190 | $json = $Common->getData($url); |
185 | 191 | |
@@ -206,7 +212,9 @@ discard block |
||
206 | 212 | */ |
207 | 213 | |
208 | 214 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
209 | - } else return array(); |
|
215 | + } else { |
|
216 | + return array(); |
|
217 | + } |
|
210 | 218 | } |
211 | 219 | |
212 | 220 | /** |
@@ -221,7 +229,9 @@ discard block |
||
221 | 229 | date_default_timezone_set($globalTimezone); |
222 | 230 | $check_date = new Datetime($date); |
223 | 231 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
224 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
232 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
233 | + return array(); |
|
234 | + } |
|
225 | 235 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
226 | 236 | $json = $Common->getData($url); |
227 | 237 | $parsed_json = json_decode($json); |
@@ -234,7 +244,9 @@ discard block |
||
234 | 244 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
235 | 245 | |
236 | 246 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
237 | - } else return array(); |
|
247 | + } else { |
|
248 | + return array(); |
|
249 | + } |
|
238 | 250 | } |
239 | 251 | |
240 | 252 | /** |
@@ -245,7 +257,9 @@ discard block |
||
245 | 257 | private function getRyanair($callsign) { |
246 | 258 | $Common = new Common(); |
247 | 259 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
248 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
260 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
261 | + return array(); |
|
262 | + } |
|
249 | 263 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
250 | 264 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
251 | 265 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -259,8 +273,12 @@ discard block |
||
259 | 273 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
260 | 274 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
261 | 275 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
262 | - } else return array(); |
|
263 | - } else return array(); |
|
276 | + } else { |
|
277 | + return array(); |
|
278 | + } |
|
279 | + } else { |
|
280 | + return array(); |
|
281 | + } |
|
264 | 282 | } |
265 | 283 | |
266 | 284 | /** |
@@ -271,7 +289,9 @@ discard block |
||
271 | 289 | private function getSwiss($callsign) { |
272 | 290 | $Common = new Common(); |
273 | 291 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
274 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
292 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
293 | + return array(); |
|
294 | + } |
|
275 | 295 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
276 | 296 | $json = $Common->getData($url); |
277 | 297 | $parsed_json = json_decode($json); |
@@ -291,8 +311,12 @@ discard block |
||
291 | 311 | } |
292 | 312 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
293 | 313 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
294 | - } else return array(); |
|
295 | - } else return array(); |
|
314 | + } else { |
|
315 | + return array(); |
|
316 | + } |
|
317 | + } else { |
|
318 | + return array(); |
|
319 | + } |
|
296 | 320 | } |
297 | 321 | |
298 | 322 | /** |
@@ -306,12 +330,18 @@ discard block |
||
306 | 330 | $Common = new Common(); |
307 | 331 | $check_date = new Datetime($date); |
308 | 332 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
309 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
310 | - if ($globalBritishAirwaysKey == '') return array(); |
|
333 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
334 | + return array(); |
|
335 | + } |
|
336 | + if ($globalBritishAirwaysKey == '') { |
|
337 | + return array(); |
|
338 | + } |
|
311 | 339 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
312 | 340 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
313 | 341 | $json = $Common->getData($url,'get','',$headers); |
314 | - if ($json == '') return array(); |
|
342 | + if ($json == '') { |
|
343 | + return array(); |
|
344 | + } |
|
315 | 345 | $parsed_json = json_decode($json); |
316 | 346 | $flights = $parsed_json->{'FlightsResponse'}; |
317 | 347 | if (count($flights) > 0) { |
@@ -320,7 +350,9 @@ discard block |
||
320 | 350 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
321 | 351 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
322 | 352 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
323 | - } else return array(); |
|
353 | + } else { |
|
354 | + return array(); |
|
355 | + } |
|
324 | 356 | } |
325 | 357 | |
326 | 358 | /** |
@@ -334,19 +366,27 @@ discard block |
||
334 | 366 | $Common = new Common(); |
335 | 367 | $check_date = new Datetime($date); |
336 | 368 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
337 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
338 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
369 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
370 | + return array(); |
|
371 | + } |
|
372 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
373 | + return array(); |
|
374 | + } |
|
339 | 375 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
340 | 376 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
341 | 377 | $data = $Common->getData($url,'post',$post); |
342 | 378 | $parsed_data = json_decode($data); |
343 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
379 | + if (!isset($parsed_data->{'access_token'})) { |
|
380 | + return array(); |
|
381 | + } |
|
344 | 382 | $token = $parsed_data->{'access_token'}; |
345 | 383 | |
346 | 384 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
347 | 385 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
348 | 386 | $json = $Common->getData($url,'get','',$headers); |
349 | - if ($json == '') return array(); |
|
387 | + if ($json == '') { |
|
388 | + return array(); |
|
389 | + } |
|
350 | 390 | $parsed_json = json_decode($json); |
351 | 391 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
352 | 392 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -354,7 +394,9 @@ discard block |
||
354 | 394 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
355 | 395 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
356 | 396 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
357 | - } else return array(); |
|
397 | + } else { |
|
398 | + return array(); |
|
399 | + } |
|
358 | 400 | } |
359 | 401 | |
360 | 402 | /** |
@@ -368,14 +410,20 @@ discard block |
||
368 | 410 | $Common = new Common(); |
369 | 411 | $check_date = new Datetime($date); |
370 | 412 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
371 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
372 | - if ($globalTransaviaKey == '') return array(); |
|
413 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
414 | + return array(); |
|
415 | + } |
|
416 | + if ($globalTransaviaKey == '') { |
|
417 | + return array(); |
|
418 | + } |
|
373 | 419 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
374 | 420 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
375 | 421 | $headers = array('apikey: '.$globalTransaviaKey); |
376 | 422 | $json = $Common->getData($url,'get','',$headers); |
377 | 423 | //echo 'result : '.$json; |
378 | - if ($json == '') return array(); |
|
424 | + if ($json == '') { |
|
425 | + return array(); |
|
426 | + } |
|
379 | 427 | $parsed_json = json_decode($json); |
380 | 428 | |
381 | 429 | if (isset($parsed_json->{'data'}[0])) { |
@@ -384,7 +432,9 @@ discard block |
||
384 | 432 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
385 | 433 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
386 | 434 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
387 | - } else return array(); |
|
435 | + } else { |
|
436 | + return array(); |
|
437 | + } |
|
388 | 438 | } |
389 | 439 | |
390 | 440 | /** |
@@ -395,7 +445,9 @@ discard block |
||
395 | 445 | public function getTunisair($callsign) { |
396 | 446 | $Common = new Common(); |
397 | 447 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
398 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
448 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
449 | + return array(); |
|
450 | + } |
|
399 | 451 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
400 | 452 | $data = $Common->getData($url); |
401 | 453 | $table = $Common->table2array($data); |
@@ -416,7 +468,9 @@ discard block |
||
416 | 468 | $Common = new Common(); |
417 | 469 | $check_date = new Datetime($date); |
418 | 470 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
419 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
471 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
472 | + return array(); |
|
473 | + } |
|
420 | 474 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
421 | 475 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
422 | 476 | $data = $Common->getData($url); |
@@ -426,8 +480,11 @@ discard block |
||
426 | 480 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
427 | 481 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
428 | 482 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
429 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
430 | - else return array(); |
|
483 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
484 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
485 | + } else { |
|
486 | + return array(); |
|
487 | + } |
|
431 | 488 | } |
432 | 489 | return array(); |
433 | 490 | } |
@@ -442,7 +499,9 @@ discard block |
||
442 | 499 | $Common = new Common(); |
443 | 500 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
444 | 501 | $check_date = new Datetime($date); |
445 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
502 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
503 | + return array(); |
|
504 | + } |
|
446 | 505 | $url = "https://www.iberia.com/web/flightDetail.do"; |
447 | 506 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
448 | 507 | $data = $Common->getData($url,'post',$post); |
@@ -459,7 +518,9 @@ discard block |
||
459 | 518 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
460 | 519 | if ($arrivalTime == 'Hora estimada de llegada') { |
461 | 520 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
462 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
521 | + } else { |
|
522 | + $arrivalTime = substr($arrivalTime,0,5); |
|
523 | + } |
|
463 | 524 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
464 | 525 | } |
465 | 526 | } |
@@ -477,7 +538,9 @@ discard block |
||
477 | 538 | $Common = new Common(); |
478 | 539 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
479 | 540 | $check_date = new Datetime($date); |
480 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
541 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
542 | + return array(); |
|
543 | + } |
|
481 | 544 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
482 | 545 | $data = $Common->getData($url); |
483 | 546 | if ($data != '') { |
@@ -493,7 +556,9 @@ discard block |
||
493 | 556 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
494 | 557 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
495 | 558 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
496 | - } else return array(); |
|
559 | + } else { |
|
560 | + return array(); |
|
561 | + } |
|
497 | 562 | } |
498 | 563 | |
499 | 564 | |
@@ -513,7 +578,9 @@ discard block |
||
513 | 578 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
514 | 579 | $check_date = new Datetime($date); |
515 | 580 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
516 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
581 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
582 | + return array(); |
|
583 | + } |
|
517 | 584 | $data = $Common->getData($url); |
518 | 585 | if ($data != '') { |
519 | 586 | $table = $Common->text2array($data); |
@@ -537,7 +604,9 @@ discard block |
||
537 | 604 | $check_date = new Datetime($date); |
538 | 605 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
539 | 606 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
540 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
607 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
608 | + return array(); |
|
609 | + } |
|
541 | 610 | $data = $Common->getData($url); |
542 | 611 | if ($data != '') { |
543 | 612 | //echo $data; |
@@ -627,7 +696,9 @@ discard block |
||
627 | 696 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
628 | 697 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
629 | 698 | //$check_date = new Datetime($date); |
630 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
699 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
700 | + return array(); |
|
701 | + } |
|
631 | 702 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
632 | 703 | $data = $Common->getData($url,'post',$post); |
633 | 704 | if ($data != '') { |
@@ -659,11 +730,15 @@ discard block |
||
659 | 730 | $airline_icao = substr($callsign, 0, 3); |
660 | 731 | } |
661 | 732 | } |
662 | - if ($airline_icao == '') return array(); |
|
733 | + if ($airline_icao == '') { |
|
734 | + return array(); |
|
735 | + } |
|
663 | 736 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
664 | 737 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
665 | 738 | //$check_date = new Datetime($date); |
666 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
739 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
740 | + return array(); |
|
741 | + } |
|
667 | 742 | $data = $Common->getData($url); |
668 | 743 | if ($data != '') { |
669 | 744 | $table = $Common->table2array($data); |
@@ -756,10 +831,16 @@ discard block |
||
756 | 831 | if ($data != '') { |
757 | 832 | $table = $Common->table2array($data); |
758 | 833 | if (isset($table[11][1])) { |
759 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
760 | - else $departureTime = ''; |
|
761 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
762 | - else $arrivalTime = ''; |
|
834 | + if (is_numeric(substr($table[11][1],0,1))) { |
|
835 | + $departureTime = substr($table[11][1],0,5); |
|
836 | + } else { |
|
837 | + $departureTime = ''; |
|
838 | + } |
|
839 | + if (is_numeric(substr($table[17][1],0,1))) { |
|
840 | + $arrivalTime = substr($table[17][1],0,5); |
|
841 | + } else { |
|
842 | + $arrivalTime = ''; |
|
843 | + } |
|
763 | 844 | $DepartureAirportIata = substr($table[13][1],0,3); |
764 | 845 | $ArrivalAirportIata = substr($table[15][1],0,3); |
765 | 846 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
@@ -776,16 +857,22 @@ discard block |
||
776 | 857 | */ |
777 | 858 | private function getAirCanada($callsign,$date = 'NOW') { |
778 | 859 | $Common = new Common(); |
779 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
860 | + if (class_exists("DomDocument") === FALSE) { |
|
861 | + return array(); |
|
862 | + } |
|
780 | 863 | date_default_timezone_set('UTC'); |
781 | 864 | $check_date = new Datetime($date); |
782 | 865 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
783 | 866 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
784 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
867 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
868 | + return array(); |
|
869 | + } |
|
785 | 870 | $data = $Common->getData($url); |
786 | 871 | $dom = new DomDocument(); |
787 | 872 | $dom->loadXML($data); |
788 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
873 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
874 | + return array(); |
|
875 | + } |
|
789 | 876 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
790 | 877 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
791 | 878 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -794,7 +881,9 @@ discard block |
||
794 | 881 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
795 | 882 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
796 | 883 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
797 | - } else return array(); |
|
884 | + } else { |
|
885 | + return array(); |
|
886 | + } |
|
798 | 887 | } |
799 | 888 | |
800 | 889 | /** |
@@ -808,7 +897,9 @@ discard block |
||
808 | 897 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
809 | 898 | $check_date = new Datetime($date); |
810 | 899 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
811 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
900 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
901 | + return array(); |
|
902 | + } |
|
812 | 903 | $data = $Common->getData($url); |
813 | 904 | if ($data != '') { |
814 | 905 | $table = $Common->table2array($data); |
@@ -837,7 +928,9 @@ discard block |
||
837 | 928 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
838 | 929 | $check_date = new Datetime($date); |
839 | 930 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
840 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
931 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
932 | + return array(); |
|
933 | + } |
|
841 | 934 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
842 | 935 | $data = $Common->getData($url,'post',$post); |
843 | 936 | //echo $data; |
@@ -847,11 +940,19 @@ discard block |
||
847 | 940 | if ($data != '') { |
848 | 941 | $table = $Common->table2array($data); |
849 | 942 | $flight = $table; |
850 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
851 | - else $departureTime = ''; |
|
852 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
853 | - else $departureAirport = ''; |
|
854 | - } else return array(); |
|
943 | + if (isset($flight[5][4])) { |
|
944 | + $departureTime = $flight[5][4]; |
|
945 | + } else { |
|
946 | + $departureTime = ''; |
|
947 | + } |
|
948 | + if (isset($flight[5][2])) { |
|
949 | + $departureAirport = $flight[5][2]; |
|
950 | + } else { |
|
951 | + $departureAirport = ''; |
|
952 | + } |
|
953 | + } else { |
|
954 | + return array(); |
|
955 | + } |
|
855 | 956 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
856 | 957 | $data = $Common->getData($url,'post',$post); |
857 | 958 | if ($data != '') { |
@@ -864,10 +965,14 @@ discard block |
||
864 | 965 | $arrivalTime = ''; |
865 | 966 | $arrivalAirport = ''; |
866 | 967 | } |
867 | - } else return array(); |
|
968 | + } else { |
|
969 | + return array(); |
|
970 | + } |
|
868 | 971 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
869 | 972 | $json = $Common->getData($url); |
870 | - if ($json == '') return array(); |
|
973 | + if ($json == '') { |
|
974 | + return array(); |
|
975 | + } |
|
871 | 976 | $parsed_json = json_decode($json); |
872 | 977 | $airports = $parsed_json->{'suggestList'}; |
873 | 978 | if (count($airports) > 0) { |
@@ -882,7 +987,9 @@ discard block |
||
882 | 987 | } |
883 | 988 | if (isset($DepartureAirportIata)) { |
884 | 989 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
885 | - } else return array(); |
|
990 | + } else { |
|
991 | + return array(); |
|
992 | + } |
|
886 | 993 | } |
887 | 994 | |
888 | 995 | /* |
@@ -894,7 +1001,9 @@ discard block |
||
894 | 1001 | public function fetchSchedule($ident,$date = 'NOW') { |
895 | 1002 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline; |
896 | 1003 | //$Common = new Common(); |
897 | - if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
|
1004 | + if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
1005 | + return array(); |
|
1006 | + } |
|
898 | 1007 | $airline_icao = ''; |
899 | 1008 | if (!is_numeric(substr($ident, 0, 3))) |
900 | 1009 | { |
@@ -1122,14 +1231,21 @@ discard block |
||
1122 | 1231 | default: |
1123 | 1232 | // Randomly use a generic function to get hours |
1124 | 1233 | if (strlen($airline_icao) == 2) { |
1125 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1234 | + if (!isset($globalSchedulesSources)) { |
|
1235 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1236 | + } |
|
1126 | 1237 | if (count($globalSchedulesSources) > 0) { |
1127 | 1238 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
1128 | 1239 | $source = $globalSchedulesSources[$rand]; |
1129 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
1130 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
1240 | + if ($source == 'flightmapper') { |
|
1241 | + return $this->getFlightMapper($ident); |
|
1242 | + } elseif ($source == 'costtotravel') { |
|
1243 | + return $this->getCostToTravel($ident); |
|
1244 | + } |
|
1131 | 1245 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
1132 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
1246 | + elseif ($source == 'flightaware') { |
|
1247 | + return $this->getFlightAware($ident); |
|
1248 | + } |
|
1133 | 1249 | } |
1134 | 1250 | } |
1135 | 1251 | } |
@@ -22,10 +22,14 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct($dbc = null) { |
24 | 24 | global $globalFilterName; |
25 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
25 | + if (isset($globalFilterName)) { |
|
26 | + $this->filter_name = $globalFilterName; |
|
27 | + } |
|
26 | 28 | $Connection = new Connection($dbc); |
27 | 29 | $this->db = $Connection->db(); |
28 | - if ($this->db === null) die('Error: No DB connection. (Stats)'); |
|
30 | + if ($this->db === null) { |
|
31 | + die('Error: No DB connection. (Stats)'); |
|
32 | + } |
|
29 | 33 | } |
30 | 34 | |
31 | 35 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | |
94 | 98 | public function getAllAirlineNames($filter_name = '') { |
95 | 99 | global $globalStatsFilters; |
96 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
100 | + if ($filter_name == '') { |
|
101 | + $filter_name = $this->filter_name; |
|
102 | + } |
|
97 | 103 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
98 | 104 | try { |
99 | 105 | $sth = $this->db->prepare($query); |
@@ -113,7 +119,9 @@ discard block |
||
113 | 119 | return $all; |
114 | 120 | } |
115 | 121 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
122 | + if ($filter_name == '') { |
|
123 | + $filter_name = $this->filter_name; |
|
124 | + } |
|
117 | 125 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
118 | 126 | try { |
119 | 127 | $sth = $this->db->prepare($query); |
@@ -125,7 +133,9 @@ discard block |
||
125 | 133 | return $all; |
126 | 134 | } |
127 | 135 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
128 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
136 | + if ($filter_name == '') { |
|
137 | + $filter_name = $this->filter_name; |
|
138 | + } |
|
129 | 139 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
130 | 140 | try { |
131 | 141 | $sth = $this->db->prepare($query); |
@@ -137,7 +147,9 @@ discard block |
||
137 | 147 | return $all; |
138 | 148 | } |
139 | 149 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
140 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
150 | + if ($filter_name == '') { |
|
151 | + $filter_name = $this->filter_name; |
|
152 | + } |
|
141 | 153 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
142 | 154 | try { |
143 | 155 | $sth = $this->db->prepare($query); |
@@ -150,7 +162,9 @@ discard block |
||
150 | 162 | } |
151 | 163 | |
152 | 164 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
153 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
165 | + if ($filter_name == '') { |
|
166 | + $filter_name = $this->filter_name; |
|
167 | + } |
|
154 | 168 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
155 | 169 | try { |
156 | 170 | $sth = $this->db->prepare($query); |
@@ -163,7 +177,9 @@ discard block |
||
163 | 177 | } |
164 | 178 | |
165 | 179 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
166 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
180 | + if ($filter_name == '') { |
|
181 | + $filter_name = $this->filter_name; |
|
182 | + } |
|
167 | 183 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
168 | 184 | try { |
169 | 185 | $sth = $this->db->prepare($query); |
@@ -178,7 +194,9 @@ discard block |
||
178 | 194 | |
179 | 195 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
180 | 196 | global $globalStatsFilters; |
181 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
197 | + if ($filter_name == '') { |
|
198 | + $filter_name = $this->filter_name; |
|
199 | + } |
|
182 | 200 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
183 | 201 | $Spotter = new Spotter($this->db); |
184 | 202 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -187,8 +205,11 @@ discard block |
||
187 | 205 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
188 | 206 | } |
189 | 207 | if ($year == '' && $month == '') { |
190 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
191 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
208 | + if ($limit) { |
|
209 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
210 | + } else { |
|
211 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
212 | + } |
|
192 | 213 | try { |
193 | 214 | $sth = $this->db->prepare($query); |
194 | 215 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -196,11 +217,16 @@ discard block |
||
196 | 217 | echo "error : ".$e->getMessage(); |
197 | 218 | } |
198 | 219 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
199 | - } else $all = array(); |
|
220 | + } else { |
|
221 | + $all = array(); |
|
222 | + } |
|
200 | 223 | } else { |
201 | 224 | if ($year == '' && $month == '') { |
202 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
203 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
225 | + if ($limit) { |
|
226 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
227 | + } else { |
|
228 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
229 | + } |
|
204 | 230 | try { |
205 | 231 | $sth = $this->db->prepare($query); |
206 | 232 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -208,7 +234,9 @@ discard block |
||
208 | 234 | echo "error : ".$e->getMessage(); |
209 | 235 | } |
210 | 236 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
211 | - } else $all = array(); |
|
237 | + } else { |
|
238 | + $all = array(); |
|
239 | + } |
|
212 | 240 | } |
213 | 241 | if (empty($all)) { |
214 | 242 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -227,10 +255,15 @@ discard block |
||
227 | 255 | } |
228 | 256 | public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
229 | 257 | global $globalStatsFilters; |
230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
258 | + if ($filter_name == '') { |
|
259 | + $filter_name = $this->filter_name; |
|
260 | + } |
|
231 | 261 | if ($year == '' && $month == '') { |
232 | - if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
233 | - else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
262 | + if ($limit) { |
|
263 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
264 | + } else { |
|
265 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
266 | + } |
|
234 | 267 | try { |
235 | 268 | $sth = $this->db->prepare($query); |
236 | 269 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -238,7 +271,9 @@ discard block |
||
238 | 271 | echo "error : ".$e->getMessage(); |
239 | 272 | } |
240 | 273 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
241 | - } else $all = array(); |
|
274 | + } else { |
|
275 | + $all = array(); |
|
276 | + } |
|
242 | 277 | if (empty($all)) { |
243 | 278 | $filters = array('year' => $year,'month' => $month); |
244 | 279 | if ($filter_name != '') { |
@@ -252,10 +287,15 @@ discard block |
||
252 | 287 | } |
253 | 288 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
254 | 289 | global $globalStatsFilters; |
255 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
290 | + if ($filter_name == '') { |
|
291 | + $filter_name = $this->filter_name; |
|
292 | + } |
|
256 | 293 | if ($year == '' && $month == '') { |
257 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
258 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
294 | + if ($limit) { |
|
295 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
296 | + } else { |
|
297 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
298 | + } |
|
259 | 299 | try { |
260 | 300 | $sth = $this->db->prepare($query); |
261 | 301 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -263,7 +303,9 @@ discard block |
||
263 | 303 | echo "error : ".$e->getMessage(); |
264 | 304 | } |
265 | 305 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
266 | - } else $all = array(); |
|
306 | + } else { |
|
307 | + $all = array(); |
|
308 | + } |
|
267 | 309 | if (empty($all)) { |
268 | 310 | $Spotter = new Spotter($this->db); |
269 | 311 | $filters = array(); |
@@ -278,7 +320,9 @@ discard block |
||
278 | 320 | } |
279 | 321 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
280 | 322 | global $globalStatsFilters; |
281 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
323 | + if ($filter_name == '') { |
|
324 | + $filter_name = $this->filter_name; |
|
325 | + } |
|
282 | 326 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
283 | 327 | $Spotter = new Spotter($this->db); |
284 | 328 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -287,8 +331,11 @@ discard block |
||
287 | 331 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
288 | 332 | } |
289 | 333 | if ($year == '' && $month == '') { |
290 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
291 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
334 | + if ($limit) { |
|
335 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
336 | + } else { |
|
337 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
338 | + } |
|
292 | 339 | try { |
293 | 340 | $sth = $this->db->prepare($query); |
294 | 341 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -296,11 +343,16 @@ discard block |
||
296 | 343 | echo "error : ".$e->getMessage(); |
297 | 344 | } |
298 | 345 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
299 | - } else $all = array(); |
|
346 | + } else { |
|
347 | + $all = array(); |
|
348 | + } |
|
300 | 349 | } else { |
301 | 350 | if ($year == '' && $month == '') { |
302 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
303 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
351 | + if ($limit) { |
|
352 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
353 | + } else { |
|
354 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
355 | + } |
|
304 | 356 | try { |
305 | 357 | $sth = $this->db->prepare($query); |
306 | 358 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -308,7 +360,9 @@ discard block |
||
308 | 360 | echo "error : ".$e->getMessage(); |
309 | 361 | } |
310 | 362 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
311 | - } else $all = array(); |
|
363 | + } else { |
|
364 | + $all = array(); |
|
365 | + } |
|
312 | 366 | } |
313 | 367 | if (empty($all)) { |
314 | 368 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -328,7 +382,9 @@ discard block |
||
328 | 382 | |
329 | 383 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
330 | 384 | global $globalStatsFilters; |
331 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
385 | + if ($filter_name == '') { |
|
386 | + $filter_name = $this->filter_name; |
|
387 | + } |
|
332 | 388 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
333 | 389 | $Spotter = new Spotter($this->db); |
334 | 390 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -337,8 +393,11 @@ discard block |
||
337 | 393 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
338 | 394 | } |
339 | 395 | if ($year == '' && $month == '') { |
340 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
341 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
396 | + if ($limit) { |
|
397 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
398 | + } else { |
|
399 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
400 | + } |
|
342 | 401 | try { |
343 | 402 | $sth = $this->db->prepare($query); |
344 | 403 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -346,11 +405,16 @@ discard block |
||
346 | 405 | echo "error : ".$e->getMessage(); |
347 | 406 | } |
348 | 407 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
349 | - } else $all = array(); |
|
408 | + } else { |
|
409 | + $all = array(); |
|
410 | + } |
|
350 | 411 | } else { |
351 | 412 | if ($year == '' && $month == '') { |
352 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
353 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
413 | + if ($limit) { |
|
414 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
415 | + } else { |
|
416 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
417 | + } |
|
354 | 418 | try { |
355 | 419 | $sth = $this->db->prepare($query); |
356 | 420 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -358,7 +422,9 @@ discard block |
||
358 | 422 | echo "error : ".$e->getMessage(); |
359 | 423 | } |
360 | 424 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
361 | - } else $all = array(); |
|
425 | + } else { |
|
426 | + $all = array(); |
|
427 | + } |
|
362 | 428 | } |
363 | 429 | if (empty($all)) { |
364 | 430 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -377,7 +443,9 @@ discard block |
||
377 | 443 | } |
378 | 444 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
379 | 445 | global $globalStatsFilters; |
380 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
446 | + if ($filter_name == '') { |
|
447 | + $filter_name = $this->filter_name; |
|
448 | + } |
|
381 | 449 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
382 | 450 | $Spotter = new Spotter($this->db); |
383 | 451 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -385,12 +453,18 @@ discard block |
||
385 | 453 | foreach ($airlines as $airline) { |
386 | 454 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
387 | 455 | } |
388 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
389 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
456 | + if ($limit) { |
|
457 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
458 | + } else { |
|
459 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
460 | + } |
|
390 | 461 | $query_values = array(':filter_name' => $filter_name); |
391 | 462 | } else { |
392 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
393 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
463 | + if ($limit) { |
|
464 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
465 | + } else { |
|
466 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
467 | + } |
|
394 | 468 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
395 | 469 | } |
396 | 470 | try { |
@@ -418,17 +492,29 @@ discard block |
||
418 | 492 | |
419 | 493 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
420 | 494 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
421 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
495 | + if ($filter_name == '') { |
|
496 | + $filter_name = $this->filter_name; |
|
497 | + } |
|
422 | 498 | if ($year == '' && $month == '') { |
423 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
424 | - if ($globalIVAO) $forsource = 'ivao'; |
|
499 | + if ($globalVATSIM) { |
|
500 | + $forsource = 'vatsim'; |
|
501 | + } |
|
502 | + if ($globalIVAO) { |
|
503 | + $forsource = 'ivao'; |
|
504 | + } |
|
425 | 505 | if (isset($forsource)) { |
426 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
427 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
506 | + if ($limit) { |
|
507 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
508 | + } else { |
|
509 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
510 | + } |
|
428 | 511 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
429 | 512 | } else { |
430 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
431 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
513 | + if ($limit) { |
|
514 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
515 | + } else { |
|
516 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
517 | + } |
|
432 | 518 | $query_values = array(':filter_name' => $filter_name); |
433 | 519 | } |
434 | 520 | try { |
@@ -438,7 +524,9 @@ discard block |
||
438 | 524 | echo "error : ".$e->getMessage(); |
439 | 525 | } |
440 | 526 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
441 | - } else $all = array(); |
|
527 | + } else { |
|
528 | + $all = array(); |
|
529 | + } |
|
442 | 530 | if (empty($all)) { |
443 | 531 | $Spotter = new Spotter($this->db); |
444 | 532 | $filters = array(); |
@@ -453,7 +541,9 @@ discard block |
||
453 | 541 | } |
454 | 542 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
455 | 543 | global $globalStatsFilters; |
456 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
544 | + if ($filter_name == '') { |
|
545 | + $filter_name = $this->filter_name; |
|
546 | + } |
|
457 | 547 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
458 | 548 | $Spotter = new Spotter($this->db); |
459 | 549 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -462,8 +552,11 @@ discard block |
||
462 | 552 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
463 | 553 | } |
464 | 554 | if ($year == '' && $month == '') { |
465 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
466 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
555 | + if ($limit) { |
|
556 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
557 | + } else { |
|
558 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
559 | + } |
|
467 | 560 | try { |
468 | 561 | $sth = $this->db->prepare($query); |
469 | 562 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -471,11 +564,16 @@ discard block |
||
471 | 564 | echo "error : ".$e->getMessage(); |
472 | 565 | } |
473 | 566 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
474 | - } else $all = array(); |
|
567 | + } else { |
|
568 | + $all = array(); |
|
569 | + } |
|
475 | 570 | } else { |
476 | 571 | if ($year == '' && $month == '') { |
477 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
478 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
572 | + if ($limit) { |
|
573 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
574 | + } else { |
|
575 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
576 | + } |
|
479 | 577 | try { |
480 | 578 | $sth = $this->db->prepare($query); |
481 | 579 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -483,7 +581,9 @@ discard block |
||
483 | 581 | echo "error : ".$e->getMessage(); |
484 | 582 | } |
485 | 583 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
486 | - } else $all = array(); |
|
584 | + } else { |
|
585 | + $all = array(); |
|
586 | + } |
|
487 | 587 | } |
488 | 588 | if (empty($all)) { |
489 | 589 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -502,7 +602,9 @@ discard block |
||
502 | 602 | } |
503 | 603 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
504 | 604 | global $globalStatsFilters; |
505 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
605 | + if ($filter_name == '') { |
|
606 | + $filter_name = $this->filter_name; |
|
607 | + } |
|
506 | 608 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
507 | 609 | $Spotter = new Spotter($this->db); |
508 | 610 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -511,8 +613,11 @@ discard block |
||
511 | 613 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
512 | 614 | } |
513 | 615 | if ($year == '' && $month == '') { |
514 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
515 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
616 | + if ($limit) { |
|
617 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
618 | + } else { |
|
619 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
620 | + } |
|
516 | 621 | try { |
517 | 622 | $sth = $this->db->prepare($query); |
518 | 623 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -520,11 +625,16 @@ discard block |
||
520 | 625 | echo "error : ".$e->getMessage(); |
521 | 626 | } |
522 | 627 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
523 | - } else $all = array(); |
|
628 | + } else { |
|
629 | + $all = array(); |
|
630 | + } |
|
524 | 631 | } else { |
525 | 632 | if ($year == '' && $month == '') { |
526 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
527 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
633 | + if ($limit) { |
|
634 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
635 | + } else { |
|
636 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
637 | + } |
|
528 | 638 | try { |
529 | 639 | $sth = $this->db->prepare($query); |
530 | 640 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -532,7 +642,9 @@ discard block |
||
532 | 642 | echo "error : ".$e->getMessage(); |
533 | 643 | } |
534 | 644 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
535 | - } else $all = array(); |
|
645 | + } else { |
|
646 | + $all = array(); |
|
647 | + } |
|
536 | 648 | } |
537 | 649 | if (empty($all)) { |
538 | 650 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -551,7 +663,9 @@ discard block |
||
551 | 663 | } |
552 | 664 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
553 | 665 | $Connection = new Connection($this->db); |
554 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
666 | + if ($filter_name == '') { |
|
667 | + $filter_name = $this->filter_name; |
|
668 | + } |
|
555 | 669 | if ($Connection->tableExists('countries')) { |
556 | 670 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
557 | 671 | $Spotter = new Spotter($this->db); |
@@ -561,8 +675,11 @@ discard block |
||
561 | 675 | foreach ($airlines as $airline) { |
562 | 676 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
563 | 677 | } |
564 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
565 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
678 | + if ($limit) { |
|
679 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
680 | + } else { |
|
681 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
682 | + } |
|
566 | 683 | try { |
567 | 684 | $sth = $this->db->prepare($query); |
568 | 685 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -571,11 +688,16 @@ discard block |
||
571 | 688 | } |
572 | 689 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
573 | 690 | return $all; |
574 | - } else return array(); |
|
691 | + } else { |
|
692 | + return array(); |
|
693 | + } |
|
575 | 694 | } else { |
576 | 695 | if ($year == '' && $month == '') { |
577 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
578 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
696 | + if ($limit) { |
|
697 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
698 | + } else { |
|
699 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
700 | + } |
|
579 | 701 | try { |
580 | 702 | $sth = $this->db->prepare($query); |
581 | 703 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -584,20 +706,29 @@ discard block |
||
584 | 706 | } |
585 | 707 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
586 | 708 | return $all; |
587 | - } else return array(); |
|
709 | + } else { |
|
710 | + return array(); |
|
711 | + } |
|
588 | 712 | } |
589 | 713 | $Spotter = new Spotter($this->db); |
590 | 714 | return $Spotter->countAllFlightOverCountries($limit); |
591 | - } else return array(); |
|
715 | + } else { |
|
716 | + return array(); |
|
717 | + } |
|
592 | 718 | } |
593 | 719 | public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
594 | 720 | $Connection = new Connection($this->db); |
595 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
721 | + if ($filter_name == '') { |
|
722 | + $filter_name = $this->filter_name; |
|
723 | + } |
|
596 | 724 | if ($Connection->tableExists('countries')) { |
597 | 725 | $all = array(); |
598 | 726 | if ($year == '' && $month == '') { |
599 | - if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
600 | - else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
727 | + if ($limit) { |
|
728 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
729 | + } else { |
|
730 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
731 | + } |
|
601 | 732 | try { |
602 | 733 | $sth = $this->db->prepare($query); |
603 | 734 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -615,17 +746,24 @@ discard block |
||
615 | 746 | $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
616 | 747 | } |
617 | 748 | return $all; |
618 | - } else return array(); |
|
749 | + } else { |
|
750 | + return array(); |
|
751 | + } |
|
619 | 752 | } |
620 | 753 | public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
621 | 754 | global $globalStatsFilters; |
622 | 755 | $Connection = new Connection($this->db); |
623 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
756 | + if ($filter_name == '') { |
|
757 | + $filter_name = $this->filter_name; |
|
758 | + } |
|
624 | 759 | if ($Connection->tableExists('countries')) { |
625 | 760 | $all = array(); |
626 | 761 | if ($year == '' && $month == '') { |
627 | - if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
628 | - else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
762 | + if ($limit) { |
|
763 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
764 | + } else { |
|
765 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
766 | + } |
|
629 | 767 | try { |
630 | 768 | $sth = $this->db->prepare($query); |
631 | 769 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -644,14 +782,21 @@ discard block |
||
644 | 782 | $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
645 | 783 | } |
646 | 784 | return $all; |
647 | - } else return array(); |
|
785 | + } else { |
|
786 | + return array(); |
|
787 | + } |
|
648 | 788 | } |
649 | 789 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
650 | 790 | global $globalStatsFilters; |
651 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
791 | + if ($filter_name == '') { |
|
792 | + $filter_name = $this->filter_name; |
|
793 | + } |
|
652 | 794 | if ($year == '' && $month == '') { |
653 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
654 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
795 | + if ($limit) { |
|
796 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
797 | + } else { |
|
798 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
799 | + } |
|
655 | 800 | try { |
656 | 801 | $sth = $this->db->prepare($query); |
657 | 802 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -659,7 +804,9 @@ discard block |
||
659 | 804 | echo "error : ".$e->getMessage(); |
660 | 805 | } |
661 | 806 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
662 | - } else $all = array(); |
|
807 | + } else { |
|
808 | + $all = array(); |
|
809 | + } |
|
663 | 810 | if (empty($all)) { |
664 | 811 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
665 | 812 | if ($filter_name != '') { |
@@ -674,7 +821,9 @@ discard block |
||
674 | 821 | |
675 | 822 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
676 | 823 | global $globalStatsFilters; |
677 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
824 | + if ($filter_name == '') { |
|
825 | + $filter_name = $this->filter_name; |
|
826 | + } |
|
678 | 827 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
679 | 828 | $Spotter = new Spotter($this->db); |
680 | 829 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -683,8 +832,11 @@ discard block |
||
683 | 832 | foreach ($airlines as $airline) { |
684 | 833 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
685 | 834 | } |
686 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
687 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
835 | + if ($limit) { |
|
836 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
837 | + } else { |
|
838 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
839 | + } |
|
688 | 840 | try { |
689 | 841 | $sth = $this->db->prepare($query); |
690 | 842 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -692,11 +844,16 @@ discard block |
||
692 | 844 | echo "error : ".$e->getMessage(); |
693 | 845 | } |
694 | 846 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
695 | - } else $all = array(); |
|
847 | + } else { |
|
848 | + $all = array(); |
|
849 | + } |
|
696 | 850 | } else { |
697 | 851 | if ($year == '' && $month == '') { |
698 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
699 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
852 | + if ($limit) { |
|
853 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
854 | + } else { |
|
855 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
856 | + } |
|
700 | 857 | try { |
701 | 858 | $sth = $this->db->prepare($query); |
702 | 859 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -704,7 +861,9 @@ discard block |
||
704 | 861 | echo "error : ".$e->getMessage(); |
705 | 862 | } |
706 | 863 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
707 | - } else $all = array(); |
|
864 | + } else { |
|
865 | + $all = array(); |
|
866 | + } |
|
708 | 867 | } |
709 | 868 | if (empty($all)) { |
710 | 869 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -723,7 +882,9 @@ discard block |
||
723 | 882 | } |
724 | 883 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
725 | 884 | global $globalStatsFilters; |
726 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
885 | + if ($filter_name == '') { |
|
886 | + $filter_name = $this->filter_name; |
|
887 | + } |
|
727 | 888 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
728 | 889 | $Spotter = new Spotter($this->db); |
729 | 890 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -732,8 +893,11 @@ discard block |
||
732 | 893 | foreach ($airlines as $airline) { |
733 | 894 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
734 | 895 | } |
735 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
736 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
896 | + if ($limit) { |
|
897 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
898 | + } else { |
|
899 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
900 | + } |
|
737 | 901 | try { |
738 | 902 | $sth = $this->db->prepare($query); |
739 | 903 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -741,11 +905,16 @@ discard block |
||
741 | 905 | echo "error : ".$e->getMessage(); |
742 | 906 | } |
743 | 907 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
744 | - } else $all = array(); |
|
908 | + } else { |
|
909 | + $all = array(); |
|
910 | + } |
|
745 | 911 | } else { |
746 | 912 | if ($year == '' && $month == '') { |
747 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
748 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
913 | + if ($limit) { |
|
914 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
915 | + } else { |
|
916 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
917 | + } |
|
749 | 918 | try { |
750 | 919 | $sth = $this->db->prepare($query); |
751 | 920 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -753,7 +922,9 @@ discard block |
||
753 | 922 | echo "error : ".$e->getMessage(); |
754 | 923 | } |
755 | 924 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
756 | - } else $all = array(); |
|
925 | + } else { |
|
926 | + $all = array(); |
|
927 | + } |
|
757 | 928 | } |
758 | 929 | if (empty($all)) { |
759 | 930 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -778,7 +949,9 @@ discard block |
||
778 | 949 | $icao = $value['airport_departure_icao']; |
779 | 950 | if (isset($all[$icao])) { |
780 | 951 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
781 | - } else $all[$icao] = $value; |
|
952 | + } else { |
|
953 | + $all[$icao] = $value; |
|
954 | + } |
|
782 | 955 | } |
783 | 956 | $count = array(); |
784 | 957 | foreach ($all as $key => $row) { |
@@ -790,7 +963,9 @@ discard block |
||
790 | 963 | } |
791 | 964 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
792 | 965 | global $globalStatsFilters; |
793 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
966 | + if ($filter_name == '') { |
|
967 | + $filter_name = $this->filter_name; |
|
968 | + } |
|
794 | 969 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
795 | 970 | $Spotter = new Spotter($this->db); |
796 | 971 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -799,8 +974,11 @@ discard block |
||
799 | 974 | foreach ($airlines as $airline) { |
800 | 975 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
801 | 976 | } |
802 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
803 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
977 | + if ($limit) { |
|
978 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
979 | + } else { |
|
980 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
981 | + } |
|
804 | 982 | try { |
805 | 983 | $sth = $this->db->prepare($query); |
806 | 984 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -808,11 +986,16 @@ discard block |
||
808 | 986 | echo "error : ".$e->getMessage(); |
809 | 987 | } |
810 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
811 | - } else $all = array(); |
|
989 | + } else { |
|
990 | + $all = array(); |
|
991 | + } |
|
812 | 992 | } else { |
813 | 993 | if ($year == '' && $month == '') { |
814 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
815 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
994 | + if ($limit) { |
|
995 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
996 | + } else { |
|
997 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
998 | + } |
|
816 | 999 | try { |
817 | 1000 | $sth = $this->db->prepare($query); |
818 | 1001 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -820,7 +1003,9 @@ discard block |
||
820 | 1003 | echo "error : ".$e->getMessage(); |
821 | 1004 | } |
822 | 1005 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
823 | - } else $all = array(); |
|
1006 | + } else { |
|
1007 | + $all = array(); |
|
1008 | + } |
|
824 | 1009 | } |
825 | 1010 | if (empty($all)) { |
826 | 1011 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -845,7 +1030,9 @@ discard block |
||
845 | 1030 | $icao = $value['airport_arrival_icao']; |
846 | 1031 | if (isset($all[$icao])) { |
847 | 1032 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
848 | - } else $all[$icao] = $value; |
|
1033 | + } else { |
|
1034 | + $all[$icao] = $value; |
|
1035 | + } |
|
849 | 1036 | } |
850 | 1037 | $count = array(); |
851 | 1038 | foreach ($all as $key => $row) { |
@@ -857,7 +1044,9 @@ discard block |
||
857 | 1044 | } |
858 | 1045 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
859 | 1046 | global $globalDBdriver, $globalStatsFilters; |
860 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1047 | + if ($filter_name == '') { |
|
1048 | + $filter_name = $this->filter_name; |
|
1049 | + } |
|
861 | 1050 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
862 | 1051 | $Spotter = new Spotter($this->db); |
863 | 1052 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -866,20 +1055,32 @@ discard block |
||
866 | 1055 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
867 | 1056 | } |
868 | 1057 | if ($globalDBdriver == 'mysql') { |
869 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
870 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1058 | + if ($limit) { |
|
1059 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1060 | + } else { |
|
1061 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1062 | + } |
|
871 | 1063 | } else { |
872 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
873 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1064 | + if ($limit) { |
|
1065 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1066 | + } else { |
|
1067 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1068 | + } |
|
874 | 1069 | } |
875 | 1070 | $query_data = array(':filter_name' => $filter_name); |
876 | 1071 | } else { |
877 | 1072 | if ($globalDBdriver == 'mysql') { |
878 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
879 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1073 | + if ($limit) { |
|
1074 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1075 | + } else { |
|
1076 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1077 | + } |
|
880 | 1078 | } else { |
881 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
882 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1079 | + if ($limit) { |
|
1080 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1081 | + } else { |
|
1082 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1083 | + } |
|
883 | 1084 | } |
884 | 1085 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
885 | 1086 | } |
@@ -907,13 +1108,21 @@ discard block |
||
907 | 1108 | |
908 | 1109 | public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') { |
909 | 1110 | global $globalDBdriver, $globalStatsFilters; |
910 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1111 | + if ($filter_name == '') { |
|
1112 | + $filter_name = $this->filter_name; |
|
1113 | + } |
|
911 | 1114 | if ($globalDBdriver == 'mysql') { |
912 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
913 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1115 | + if ($limit) { |
|
1116 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
1117 | + } else { |
|
1118 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1119 | + } |
|
914 | 1120 | } else { |
915 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
916 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1121 | + if ($limit) { |
|
1122 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
1123 | + } else { |
|
1124 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1125 | + } |
|
917 | 1126 | } |
918 | 1127 | $query_data = array(':filter_name' => $filter_name); |
919 | 1128 | try { |
@@ -936,13 +1145,21 @@ discard block |
||
936 | 1145 | |
937 | 1146 | public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') { |
938 | 1147 | global $globalDBdriver, $globalStatsFilters; |
939 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1148 | + if ($filter_name == '') { |
|
1149 | + $filter_name = $this->filter_name; |
|
1150 | + } |
|
940 | 1151 | if ($globalDBdriver == 'mysql') { |
941 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
942 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1152 | + if ($limit) { |
|
1153 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
1154 | + } else { |
|
1155 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1156 | + } |
|
943 | 1157 | } else { |
944 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
945 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1158 | + if ($limit) { |
|
1159 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
1160 | + } else { |
|
1161 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1162 | + } |
|
946 | 1163 | } |
947 | 1164 | $query_data = array(':filter_name' => $filter_name); |
948 | 1165 | try { |
@@ -965,7 +1182,9 @@ discard block |
||
965 | 1182 | |
966 | 1183 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
967 | 1184 | global $globalStatsFilters; |
968 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1185 | + if ($filter_name == '') { |
|
1186 | + $filter_name = $this->filter_name; |
|
1187 | + } |
|
969 | 1188 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
970 | 1189 | $Spotter = new Spotter($this->db); |
971 | 1190 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1002,7 +1221,9 @@ discard block |
||
1002 | 1221 | } |
1003 | 1222 | public function countAllMarineDatesLastMonth($filter_name = '') { |
1004 | 1223 | global $globalStatsFilters; |
1005 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1224 | + if ($filter_name == '') { |
|
1225 | + $filter_name = $this->filter_name; |
|
1226 | + } |
|
1006 | 1227 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name"; |
1007 | 1228 | $query_data = array(':filter_name' => $filter_name); |
1008 | 1229 | try { |
@@ -1024,7 +1245,9 @@ discard block |
||
1024 | 1245 | } |
1025 | 1246 | public function countAllTrackerDatesLastMonth($filter_name = '') { |
1026 | 1247 | global $globalStatsFilters; |
1027 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1248 | + if ($filter_name == '') { |
|
1249 | + $filter_name = $this->filter_name; |
|
1250 | + } |
|
1028 | 1251 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name"; |
1029 | 1252 | $query_data = array(':filter_name' => $filter_name); |
1030 | 1253 | try { |
@@ -1046,7 +1269,9 @@ discard block |
||
1046 | 1269 | } |
1047 | 1270 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
1048 | 1271 | global $globalDBdriver, $globalStatsFilters; |
1049 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1272 | + if ($filter_name == '') { |
|
1273 | + $filter_name = $this->filter_name; |
|
1274 | + } |
|
1050 | 1275 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1051 | 1276 | $Spotter = new Spotter($this->db); |
1052 | 1277 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1091,7 +1316,9 @@ discard block |
||
1091 | 1316 | } |
1092 | 1317 | public function countAllMarineDatesLast7Days($filter_name = '') { |
1093 | 1318 | global $globalDBdriver, $globalStatsFilters; |
1094 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1319 | + if ($filter_name == '') { |
|
1320 | + $filter_name = $this->filter_name; |
|
1321 | + } |
|
1095 | 1322 | if ($globalDBdriver == 'mysql') { |
1096 | 1323 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
1097 | 1324 | } else { |
@@ -1117,7 +1344,9 @@ discard block |
||
1117 | 1344 | } |
1118 | 1345 | public function countAllTrackerDatesLast7Days($filter_name = '') { |
1119 | 1346 | global $globalDBdriver, $globalStatsFilters; |
1120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1347 | + if ($filter_name == '') { |
|
1348 | + $filter_name = $this->filter_name; |
|
1349 | + } |
|
1121 | 1350 | if ($globalDBdriver == 'mysql') { |
1122 | 1351 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
1123 | 1352 | } else { |
@@ -1143,7 +1372,9 @@ discard block |
||
1143 | 1372 | } |
1144 | 1373 | public function countAllDates($stats_airline = '',$filter_name = '') { |
1145 | 1374 | global $globalStatsFilters; |
1146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1375 | + if ($filter_name == '') { |
|
1376 | + $filter_name = $this->filter_name; |
|
1377 | + } |
|
1147 | 1378 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1148 | 1379 | $Spotter = new Spotter($this->db); |
1149 | 1380 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1180,7 +1411,9 @@ discard block |
||
1180 | 1411 | } |
1181 | 1412 | public function countAllDatesMarine($filter_name = '') { |
1182 | 1413 | global $globalStatsFilters; |
1183 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1414 | + if ($filter_name == '') { |
|
1415 | + $filter_name = $this->filter_name; |
|
1416 | + } |
|
1184 | 1417 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
1185 | 1418 | $query_data = array(':filter_name' => $filter_name); |
1186 | 1419 | try { |
@@ -1202,7 +1435,9 @@ discard block |
||
1202 | 1435 | } |
1203 | 1436 | public function countAllDatesTracker($filter_name = '') { |
1204 | 1437 | global $globalStatsFilters; |
1205 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1438 | + if ($filter_name == '') { |
|
1439 | + $filter_name = $this->filter_name; |
|
1440 | + } |
|
1206 | 1441 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
1207 | 1442 | $query_data = array(':filter_name' => $filter_name); |
1208 | 1443 | try { |
@@ -1224,7 +1459,9 @@ discard block |
||
1224 | 1459 | } |
1225 | 1460 | public function countAllDatesByAirlines($filter_name = '') { |
1226 | 1461 | global $globalStatsFilters; |
1227 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1462 | + if ($filter_name == '') { |
|
1463 | + $filter_name = $this->filter_name; |
|
1464 | + } |
|
1228 | 1465 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
1229 | 1466 | $query_data = array('filter_name' => $filter_name); |
1230 | 1467 | try { |
@@ -1246,7 +1483,9 @@ discard block |
||
1246 | 1483 | } |
1247 | 1484 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
1248 | 1485 | global $globalStatsFilters, $globalDBdriver; |
1249 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1486 | + if ($filter_name == '') { |
|
1487 | + $filter_name = $this->filter_name; |
|
1488 | + } |
|
1250 | 1489 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1251 | 1490 | $Spotter = new Spotter($this->db); |
1252 | 1491 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1331,7 +1570,9 @@ discard block |
||
1331 | 1570 | } |
1332 | 1571 | public function countAllMilitaryMonths($filter_name = '') { |
1333 | 1572 | global $globalStatsFilters; |
1334 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1573 | + if ($filter_name == '') { |
|
1574 | + $filter_name = $this->filter_name; |
|
1575 | + } |
|
1335 | 1576 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
1336 | 1577 | try { |
1337 | 1578 | $sth = $this->db->prepare($query); |
@@ -1352,7 +1593,9 @@ discard block |
||
1352 | 1593 | } |
1353 | 1594 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
1354 | 1595 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1355 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1596 | + if ($filter_name == '') { |
|
1597 | + $filter_name = $this->filter_name; |
|
1598 | + } |
|
1356 | 1599 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1357 | 1600 | $Spotter = new Spotter($this->db); |
1358 | 1601 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1360,12 +1603,18 @@ discard block |
||
1360 | 1603 | foreach ($airlines as $airline) { |
1361 | 1604 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
1362 | 1605 | } |
1363 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1364 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1606 | + if ($limit) { |
|
1607 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1608 | + } else { |
|
1609 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1610 | + } |
|
1365 | 1611 | $query_data = array(':filter_name' => $filter_name); |
1366 | 1612 | } else { |
1367 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1368 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1613 | + if ($limit) { |
|
1614 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1615 | + } else { |
|
1616 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1617 | + } |
|
1369 | 1618 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
1370 | 1619 | } |
1371 | 1620 | if ($orderby == 'hour') { |
@@ -1375,7 +1624,9 @@ discard block |
||
1375 | 1624 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
1376 | 1625 | } |
1377 | 1626 | } |
1378 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1627 | + if ($orderby == 'count') { |
|
1628 | + $query .= " ORDER BY hour_count DESC"; |
|
1629 | + } |
|
1379 | 1630 | try { |
1380 | 1631 | $sth = $this->db->prepare($query); |
1381 | 1632 | $sth->execute($query_data); |
@@ -1399,9 +1650,14 @@ discard block |
||
1399 | 1650 | } |
1400 | 1651 | public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') { |
1401 | 1652 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1402 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1403 | - if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1404 | - else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1653 | + if ($filter_name == '') { |
|
1654 | + $filter_name = $this->filter_name; |
|
1655 | + } |
|
1656 | + if ($limit) { |
|
1657 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1658 | + } else { |
|
1659 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1660 | + } |
|
1405 | 1661 | $query_data = array(':filter_name' => $filter_name); |
1406 | 1662 | if ($orderby == 'hour') { |
1407 | 1663 | if ($globalDBdriver == 'mysql') { |
@@ -1410,7 +1666,9 @@ discard block |
||
1410 | 1666 | $query .= " ORDER BY CAST(marine_date AS integer) ASC"; |
1411 | 1667 | } |
1412 | 1668 | } |
1413 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1669 | + if ($orderby == 'count') { |
|
1670 | + $query .= " ORDER BY hour_count DESC"; |
|
1671 | + } |
|
1414 | 1672 | try { |
1415 | 1673 | $sth = $this->db->prepare($query); |
1416 | 1674 | $sth->execute($query_data); |
@@ -1430,9 +1688,14 @@ discard block |
||
1430 | 1688 | } |
1431 | 1689 | public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') { |
1432 | 1690 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1433 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1434 | - if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1435 | - else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1691 | + if ($filter_name == '') { |
|
1692 | + $filter_name = $this->filter_name; |
|
1693 | + } |
|
1694 | + if ($limit) { |
|
1695 | + $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1696 | + } else { |
|
1697 | + $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1698 | + } |
|
1436 | 1699 | $query_data = array(':filter_name' => $filter_name); |
1437 | 1700 | if ($orderby == 'hour') { |
1438 | 1701 | if ($globalDBdriver == 'mysql') { |
@@ -1441,7 +1704,9 @@ discard block |
||
1441 | 1704 | $query .= " ORDER BY CAST(tracker_date AS integer) ASC"; |
1442 | 1705 | } |
1443 | 1706 | } |
1444 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1707 | + if ($orderby == 'count') { |
|
1708 | + $query .= " ORDER BY hour_count DESC"; |
|
1709 | + } |
|
1445 | 1710 | try { |
1446 | 1711 | $sth = $this->db->prepare($query); |
1447 | 1712 | $sth->execute($query_data); |
@@ -1461,8 +1726,12 @@ discard block |
||
1461 | 1726 | } |
1462 | 1727 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
1463 | 1728 | global $globalStatsFilters; |
1464 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1465 | - if ($year == '') $year = date('Y'); |
|
1729 | + if ($filter_name == '') { |
|
1730 | + $filter_name = $this->filter_name; |
|
1731 | + } |
|
1732 | + if ($year == '') { |
|
1733 | + $year = date('Y'); |
|
1734 | + } |
|
1466 | 1735 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
1467 | 1736 | if (empty($all)) { |
1468 | 1737 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1481,8 +1750,12 @@ discard block |
||
1481 | 1750 | } |
1482 | 1751 | public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
1483 | 1752 | global $globalStatsFilters; |
1484 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1485 | - if ($year == '') $year = date('Y'); |
|
1753 | + if ($filter_name == '') { |
|
1754 | + $filter_name = $this->filter_name; |
|
1755 | + } |
|
1756 | + if ($year == '') { |
|
1757 | + $year = date('Y'); |
|
1758 | + } |
|
1486 | 1759 | $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
1487 | 1760 | if (empty($all)) { |
1488 | 1761 | $filters = array('year' => $year,'month' => $month); |
@@ -1497,8 +1770,12 @@ discard block |
||
1497 | 1770 | } |
1498 | 1771 | public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
1499 | 1772 | global $globalStatsFilters; |
1500 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1501 | - if ($year == '') $year = date('Y'); |
|
1773 | + if ($filter_name == '') { |
|
1774 | + $filter_name = $this->filter_name; |
|
1775 | + } |
|
1776 | + if ($year == '') { |
|
1777 | + $year = date('Y'); |
|
1778 | + } |
|
1502 | 1779 | $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
1503 | 1780 | if (empty($all)) { |
1504 | 1781 | $filters = array('year' => $year,'month' => $month); |
@@ -1513,8 +1790,12 @@ discard block |
||
1513 | 1790 | } |
1514 | 1791 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
1515 | 1792 | global $globalStatsFilters; |
1516 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1517 | - if ($year == '') $year = date('Y'); |
|
1793 | + if ($filter_name == '') { |
|
1794 | + $filter_name = $this->filter_name; |
|
1795 | + } |
|
1796 | + if ($year == '') { |
|
1797 | + $year = date('Y'); |
|
1798 | + } |
|
1518 | 1799 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
1519 | 1800 | if (empty($all)) { |
1520 | 1801 | $filters = array(); |
@@ -1530,8 +1811,12 @@ discard block |
||
1530 | 1811 | } |
1531 | 1812 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
1532 | 1813 | global $globalStatsFilters; |
1533 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1534 | - if ($year == '') $year = date('Y'); |
|
1814 | + if ($filter_name == '') { |
|
1815 | + $filter_name = $this->filter_name; |
|
1816 | + } |
|
1817 | + if ($year == '') { |
|
1818 | + $year = date('Y'); |
|
1819 | + } |
|
1535 | 1820 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
1536 | 1821 | if (empty($all)) { |
1537 | 1822 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1550,7 +1835,9 @@ discard block |
||
1550 | 1835 | } |
1551 | 1836 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1552 | 1837 | global $globalStatsFilters; |
1553 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1838 | + if ($filter_name == '') { |
|
1839 | + $filter_name = $this->filter_name; |
|
1840 | + } |
|
1554 | 1841 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1555 | 1842 | $Spotter = new Spotter($this->db); |
1556 | 1843 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1568,7 +1855,9 @@ discard block |
||
1568 | 1855 | } |
1569 | 1856 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1570 | 1857 | $all = $result[0]['nb']; |
1571 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1858 | + } else { |
|
1859 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1860 | + } |
|
1572 | 1861 | } else { |
1573 | 1862 | if ($year == '' && $month == '') { |
1574 | 1863 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1580,7 +1869,9 @@ discard block |
||
1580 | 1869 | } |
1581 | 1870 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1582 | 1871 | $all = $result[0]['nb']; |
1583 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1872 | + } else { |
|
1873 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1874 | + } |
|
1584 | 1875 | } |
1585 | 1876 | if (empty($all)) { |
1586 | 1877 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1599,7 +1890,9 @@ discard block |
||
1599 | 1890 | } |
1600 | 1891 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
1601 | 1892 | global $globalStatsFilters; |
1602 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1893 | + if ($filter_name == '') { |
|
1894 | + $filter_name = $this->filter_name; |
|
1895 | + } |
|
1603 | 1896 | if ($year == '' && $month == '') { |
1604 | 1897 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
1605 | 1898 | try { |
@@ -1610,7 +1903,9 @@ discard block |
||
1610 | 1903 | } |
1611 | 1904 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1612 | 1905 | $all = $result[0]['nb_airline']; |
1613 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1906 | + } else { |
|
1907 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1908 | + } |
|
1614 | 1909 | if (empty($all)) { |
1615 | 1910 | $filters = array(); |
1616 | 1911 | $filters = array('year' => $year,'month' => $month); |
@@ -1625,7 +1920,9 @@ discard block |
||
1625 | 1920 | } |
1626 | 1921 | public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
1627 | 1922 | global $globalStatsFilters; |
1628 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1923 | + if ($filter_name == '') { |
|
1924 | + $filter_name = $this->filter_name; |
|
1925 | + } |
|
1629 | 1926 | $all = array(); |
1630 | 1927 | if ($year == '' && $month == '') { |
1631 | 1928 | $query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name"; |
@@ -1652,7 +1949,9 @@ discard block |
||
1652 | 1949 | } |
1653 | 1950 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1654 | 1951 | global $globalStatsFilters; |
1655 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1952 | + if ($filter_name == '') { |
|
1953 | + $filter_name = $this->filter_name; |
|
1954 | + } |
|
1656 | 1955 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1657 | 1956 | $Spotter = new Spotter($this->db); |
1658 | 1957 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1707,7 +2006,9 @@ discard block |
||
1707 | 2006 | } |
1708 | 2007 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
1709 | 2008 | global $globalStatsFilters; |
1710 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2009 | + if ($filter_name == '') { |
|
2010 | + $filter_name = $this->filter_name; |
|
2011 | + } |
|
1711 | 2012 | //if ($year == '') $year = date('Y'); |
1712 | 2013 | if ($year == '' && $month == '') { |
1713 | 2014 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1736,7 +2037,9 @@ discard block |
||
1736 | 2037 | } |
1737 | 2038 | |
1738 | 2039 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
1739 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2040 | + if ($filter_name == '') { |
|
2041 | + $filter_name = $this->filter_name; |
|
2042 | + } |
|
1740 | 2043 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1741 | 2044 | $Spotter = new Spotter($this->db); |
1742 | 2045 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1760,7 +2063,9 @@ discard block |
||
1760 | 2063 | return $all; |
1761 | 2064 | } |
1762 | 2065 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
1763 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2066 | + if ($filter_name == '') { |
|
2067 | + $filter_name = $this->filter_name; |
|
2068 | + } |
|
1764 | 2069 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
1765 | 2070 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1766 | 2071 | try { |
@@ -1773,7 +2078,9 @@ discard block |
||
1773 | 2078 | return $all; |
1774 | 2079 | } |
1775 | 2080 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
1776 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2081 | + if ($filter_name == '') { |
|
2082 | + $filter_name = $this->filter_name; |
|
2083 | + } |
|
1777 | 2084 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1778 | 2085 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1779 | 2086 | try { |
@@ -1784,7 +2091,9 @@ discard block |
||
1784 | 2091 | } |
1785 | 2092 | } |
1786 | 2093 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
1787 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2094 | + if ($filter_name == '') { |
|
2095 | + $filter_name = $this->filter_name; |
|
2096 | + } |
|
1788 | 2097 | global $globalArchiveMonths, $globalDBdriver; |
1789 | 2098 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1790 | 2099 | $Spotter = new Spotter($this->db); |
@@ -1840,7 +2149,9 @@ discard block |
||
1840 | 2149 | } |
1841 | 2150 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1842 | 2151 | global $globalArchiveMonths, $globalDBdriver; |
1843 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2152 | + if ($filter_name == '') { |
|
2153 | + $filter_name = $this->filter_name; |
|
2154 | + } |
|
1844 | 2155 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1845 | 2156 | $Spotter = new Spotter($this->db); |
1846 | 2157 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1873,7 +2184,9 @@ discard block |
||
1873 | 2184 | } |
1874 | 2185 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1875 | 2186 | global $globalArchiveMonths, $globalDBdriver; |
1876 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2187 | + if ($filter_name == '') { |
|
2188 | + $filter_name = $this->filter_name; |
|
2189 | + } |
|
1877 | 2190 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1878 | 2191 | $Spotter = new Spotter($this->db); |
1879 | 2192 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1904,7 +2217,9 @@ discard block |
||
1904 | 2217 | } |
1905 | 2218 | public function getStatsAirlineTotal($filter_name = '') { |
1906 | 2219 | global $globalArchiveMonths, $globalDBdriver; |
1907 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2220 | + if ($filter_name == '') { |
|
2221 | + $filter_name = $this->filter_name; |
|
2222 | + } |
|
1908 | 2223 | if ($globalDBdriver == 'mysql') { |
1909 | 2224 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1910 | 2225 | } else { |
@@ -1921,7 +2236,9 @@ discard block |
||
1921 | 2236 | } |
1922 | 2237 | public function getStatsOwnerTotal($filter_name = '') { |
1923 | 2238 | global $globalArchiveMonths, $globalDBdriver; |
1924 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2239 | + if ($filter_name == '') { |
|
2240 | + $filter_name = $this->filter_name; |
|
2241 | + } |
|
1925 | 2242 | if ($globalDBdriver == 'mysql') { |
1926 | 2243 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1927 | 2244 | } else { |
@@ -1938,7 +2255,9 @@ discard block |
||
1938 | 2255 | } |
1939 | 2256 | public function getStatsOwner($owner_name,$filter_name = '') { |
1940 | 2257 | global $globalArchiveMonths, $globalDBdriver; |
1941 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2258 | + if ($filter_name == '') { |
|
2259 | + $filter_name = $this->filter_name; |
|
2260 | + } |
|
1942 | 2261 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1943 | 2262 | try { |
1944 | 2263 | $sth = $this->db->prepare($query); |
@@ -1947,12 +2266,17 @@ discard block |
||
1947 | 2266 | echo "error : ".$e->getMessage(); |
1948 | 2267 | } |
1949 | 2268 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1950 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1951 | - else return 0; |
|
2269 | + if (isset($all[0]['cnt'])) { |
|
2270 | + return $all[0]['cnt']; |
|
2271 | + } else { |
|
2272 | + return 0; |
|
2273 | + } |
|
1952 | 2274 | } |
1953 | 2275 | public function getStatsPilotTotal($filter_name = '') { |
1954 | 2276 | global $globalArchiveMonths, $globalDBdriver; |
1955 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2277 | + if ($filter_name == '') { |
|
2278 | + $filter_name = $this->filter_name; |
|
2279 | + } |
|
1956 | 2280 | if ($globalDBdriver == 'mysql') { |
1957 | 2281 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1958 | 2282 | } else { |
@@ -1969,7 +2293,9 @@ discard block |
||
1969 | 2293 | } |
1970 | 2294 | public function getStatsPilot($pilot,$filter_name = '') { |
1971 | 2295 | global $globalArchiveMonths, $globalDBdriver; |
1972 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2296 | + if ($filter_name == '') { |
|
2297 | + $filter_name = $this->filter_name; |
|
2298 | + } |
|
1973 | 2299 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1974 | 2300 | try { |
1975 | 2301 | $sth = $this->db->prepare($query); |
@@ -1978,13 +2304,18 @@ discard block |
||
1978 | 2304 | echo "error : ".$e->getMessage(); |
1979 | 2305 | } |
1980 | 2306 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1981 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1982 | - else return 0; |
|
2307 | + if (isset($all[0]['cnt'])) { |
|
2308 | + return $all[0]['cnt']; |
|
2309 | + } else { |
|
2310 | + return 0; |
|
2311 | + } |
|
1983 | 2312 | } |
1984 | 2313 | |
1985 | 2314 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1986 | 2315 | global $globalDBdriver; |
1987 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2316 | + if ($filter_name == '') { |
|
2317 | + $filter_name = $this->filter_name; |
|
2318 | + } |
|
1988 | 2319 | if ($globalDBdriver == 'mysql') { |
1989 | 2320 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
1990 | 2321 | } else { |
@@ -2000,7 +2331,9 @@ discard block |
||
2000 | 2331 | } |
2001 | 2332 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
2002 | 2333 | global $globalDBdriver; |
2003 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2334 | + if ($filter_name == '') { |
|
2335 | + $filter_name = $this->filter_name; |
|
2336 | + } |
|
2004 | 2337 | if ($globalDBdriver == 'mysql') { |
2005 | 2338 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
2006 | 2339 | } else { |
@@ -2519,27 +2852,37 @@ discard block |
||
2519 | 2852 | date_default_timezone_set('UTC'); |
2520 | 2853 | if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) { |
2521 | 2854 | $last_update = $this->getLastStatsUpdate('last_update_stats_marine'); |
2522 | - if ($globalDebug) echo '!!! Update Marine stats !!!'."\n"; |
|
2855 | + if ($globalDebug) { |
|
2856 | + echo '!!! Update Marine stats !!!'."\n"; |
|
2857 | + } |
|
2523 | 2858 | if (isset($last_update[0]['value'])) { |
2524 | 2859 | $last_update_day = $last_update[0]['value']; |
2525 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2860 | + } else { |
|
2861 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2862 | + } |
|
2526 | 2863 | $reset = false; |
2527 | 2864 | $Marine = new Marine($this->db); |
2528 | 2865 | $filtername = 'marine'; |
2529 | 2866 | if ($Connection->tableExists('countries')) { |
2530 | - if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
|
2867 | + if ($globalDebug) { |
|
2868 | + echo 'Count all vessels by countries...'."\n"; |
|
2869 | + } |
|
2531 | 2870 | $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
2532 | 2871 | foreach ($alldata as $number) { |
2533 | 2872 | echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
2534 | 2873 | } |
2535 | 2874 | } |
2536 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
2875 | + if ($globalDebug) { |
|
2876 | + echo 'Count all vessels by months...'."\n"; |
|
2877 | + } |
|
2537 | 2878 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2538 | 2879 | $filter_last_month = array('since_date' => $last_month); |
2539 | 2880 | $alldata = $Marine->countAllMonths($filter_last_month); |
2540 | 2881 | $lastyear = false; |
2541 | 2882 | foreach ($alldata as $number) { |
2542 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2883 | + if ($number['year_name'] != date('Y')) { |
|
2884 | + $lastyear = true; |
|
2885 | + } |
|
2543 | 2886 | $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2544 | 2887 | } |
2545 | 2888 | echo 'Marine data...'."\n"; |
@@ -2569,7 +2912,9 @@ discard block |
||
2569 | 2912 | foreach ($alldata as $number) { |
2570 | 2913 | $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
2571 | 2914 | } |
2572 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
2915 | + if ($globalDebug) { |
|
2916 | + echo 'Count all types...'."\n"; |
|
2917 | + } |
|
2573 | 2918 | $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
2574 | 2919 | foreach ($alldata as $number) { |
2575 | 2920 | $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
@@ -2581,26 +2926,36 @@ discard block |
||
2581 | 2926 | } |
2582 | 2927 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
2583 | 2928 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
2584 | - if ($globalDebug) echo '!!! Update tracker stats !!!'."\n"; |
|
2929 | + if ($globalDebug) { |
|
2930 | + echo '!!! Update tracker stats !!!'."\n"; |
|
2931 | + } |
|
2585 | 2932 | if (isset($last_update[0]['value'])) { |
2586 | 2933 | $last_update_day = $last_update[0]['value']; |
2587 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2934 | + } else { |
|
2935 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2936 | + } |
|
2588 | 2937 | $reset = false; |
2589 | 2938 | $Tracker = new Tracker($this->db); |
2590 | 2939 | if ($Connection->tableExists('countries')) { |
2591 | - if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
|
2940 | + if ($globalDebug) { |
|
2941 | + echo 'Count all trackers by countries...'."\n"; |
|
2942 | + } |
|
2592 | 2943 | $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
2593 | 2944 | foreach ($alldata as $number) { |
2594 | 2945 | $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
2595 | 2946 | } |
2596 | 2947 | } |
2597 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
2948 | + if ($globalDebug) { |
|
2949 | + echo 'Count all vessels by months...'."\n"; |
|
2950 | + } |
|
2598 | 2951 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2599 | 2952 | $filter_last_month = array('since_date' => $last_month); |
2600 | 2953 | $alldata = $Tracker->countAllMonths($filter_last_month); |
2601 | 2954 | $lastyear = false; |
2602 | 2955 | foreach ($alldata as $number) { |
2603 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2956 | + if ($number['year_name'] != date('Y')) { |
|
2957 | + $lastyear = true; |
|
2958 | + } |
|
2604 | 2959 | $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2605 | 2960 | } |
2606 | 2961 | echo 'Tracker data...'."\n"; |
@@ -2630,7 +2985,9 @@ discard block |
||
2630 | 2985 | foreach ($alldata as $number) { |
2631 | 2986 | $this->addStatTracker('hour',$number['hour_name'],$number['hour_count']); |
2632 | 2987 | } |
2633 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
2988 | + if ($globalDebug) { |
|
2989 | + echo 'Count all types...'."\n"; |
|
2990 | + } |
|
2634 | 2991 | $alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day); |
2635 | 2992 | foreach ($alldata as $number) { |
2636 | 2993 | $this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset); |
@@ -2642,10 +2999,14 @@ discard block |
||
2642 | 2999 | |
2643 | 3000 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
2644 | 3001 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2645 | - if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n"; |
|
3002 | + if ($globalDebug) { |
|
3003 | + echo '!!! Update aicraft stats !!!'."\n"; |
|
3004 | + } |
|
2646 | 3005 | if (isset($last_update[0]['value'])) { |
2647 | 3006 | $last_update_day = $last_update[0]['value']; |
2648 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
3007 | + } else { |
|
3008 | + $last_update_day = '2012-12-12 12:12:12'; |
|
3009 | + } |
|
2649 | 3010 | $reset = false; |
2650 | 3011 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
2651 | 3012 | if ($globalStatsResetYear) { |
@@ -2654,43 +3015,63 @@ discard block |
||
2654 | 3015 | } |
2655 | 3016 | $Spotter = new Spotter($this->db); |
2656 | 3017 | |
2657 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
3018 | + if ($globalDebug) { |
|
3019 | + echo 'Count all aircraft types...'."\n"; |
|
3020 | + } |
|
2658 | 3021 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
2659 | 3022 | foreach ($alldata as $number) { |
2660 | 3023 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
2661 | 3024 | } |
2662 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
3025 | + if ($globalDebug) { |
|
3026 | + echo 'Count all airlines...'."\n"; |
|
3027 | + } |
|
2663 | 3028 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
2664 | 3029 | foreach ($alldata as $number) { |
2665 | 3030 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
2666 | 3031 | } |
2667 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
3032 | + if ($globalDebug) { |
|
3033 | + echo 'Count all registrations...'."\n"; |
|
3034 | + } |
|
2668 | 3035 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
2669 | 3036 | foreach ($alldata as $number) { |
2670 | 3037 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
2671 | 3038 | } |
2672 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
3039 | + if ($globalDebug) { |
|
3040 | + echo 'Count all callsigns...'."\n"; |
|
3041 | + } |
|
2673 | 3042 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
2674 | 3043 | foreach ($alldata as $number) { |
2675 | 3044 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2676 | 3045 | } |
2677 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
3046 | + if ($globalDebug) { |
|
3047 | + echo 'Count all owners...'."\n"; |
|
3048 | + } |
|
2678 | 3049 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
2679 | 3050 | foreach ($alldata as $number) { |
2680 | 3051 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
2681 | 3052 | } |
2682 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
3053 | + if ($globalDebug) { |
|
3054 | + echo 'Count all pilots...'."\n"; |
|
3055 | + } |
|
2683 | 3056 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
2684 | 3057 | foreach ($alldata as $number) { |
2685 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
3058 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
3059 | + $number['pilot_id'] = $number['pilot_name']; |
|
3060 | + } |
|
2686 | 3061 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
2687 | 3062 | } |
2688 | 3063 | |
2689 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
3064 | + if ($globalDebug) { |
|
3065 | + echo 'Count all departure airports...'."\n"; |
|
3066 | + } |
|
2690 | 3067 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
2691 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
3068 | + if ($globalDebug) { |
|
3069 | + echo 'Count all detected departure airports...'."\n"; |
|
3070 | + } |
|
2692 | 3071 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
2693 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
3072 | + if ($globalDebug) { |
|
3073 | + echo 'Order departure airports...'."\n"; |
|
3074 | + } |
|
2694 | 3075 | $alldata = array(); |
2695 | 3076 | foreach ($pall as $value) { |
2696 | 3077 | $icao = $value['airport_departure_icao']; |
@@ -2700,7 +3081,9 @@ discard block |
||
2700 | 3081 | $icao = $value['airport_departure_icao']; |
2701 | 3082 | if (isset($alldata[$icao])) { |
2702 | 3083 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2703 | - } else $alldata[$icao] = $value; |
|
3084 | + } else { |
|
3085 | + $alldata[$icao] = $value; |
|
3086 | + } |
|
2704 | 3087 | } |
2705 | 3088 | $count = array(); |
2706 | 3089 | foreach ($alldata as $key => $row) { |
@@ -2710,11 +3093,17 @@ discard block |
||
2710 | 3093 | foreach ($alldata as $number) { |
2711 | 3094 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
2712 | 3095 | } |
2713 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
3096 | + if ($globalDebug) { |
|
3097 | + echo 'Count all arrival airports...'."\n"; |
|
3098 | + } |
|
2714 | 3099 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
2715 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
3100 | + if ($globalDebug) { |
|
3101 | + echo 'Count all detected arrival airports...'."\n"; |
|
3102 | + } |
|
2716 | 3103 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
2717 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
3104 | + if ($globalDebug) { |
|
3105 | + echo 'Order arrival airports...'."\n"; |
|
3106 | + } |
|
2718 | 3107 | $alldata = array(); |
2719 | 3108 | foreach ($pall as $value) { |
2720 | 3109 | $icao = $value['airport_arrival_icao']; |
@@ -2724,7 +3113,9 @@ discard block |
||
2724 | 3113 | $icao = $value['airport_arrival_icao']; |
2725 | 3114 | if (isset($alldata[$icao])) { |
2726 | 3115 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2727 | - } else $alldata[$icao] = $value; |
|
3116 | + } else { |
|
3117 | + $alldata[$icao] = $value; |
|
3118 | + } |
|
2728 | 3119 | } |
2729 | 3120 | $count = array(); |
2730 | 3121 | foreach ($alldata as $key => $row) { |
@@ -2735,7 +3126,9 @@ discard block |
||
2735 | 3126 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
2736 | 3127 | } |
2737 | 3128 | if ($Connection->tableExists('countries')) { |
2738 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
3129 | + if ($globalDebug) { |
|
3130 | + echo 'Count all flights by countries...'."\n"; |
|
3131 | + } |
|
2739 | 3132 | //$SpotterArchive = new SpotterArchive(); |
2740 | 3133 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
2741 | 3134 | $Spotter = new Spotter($this->db); |
@@ -2746,7 +3139,9 @@ discard block |
||
2746 | 3139 | } |
2747 | 3140 | |
2748 | 3141 | if (isset($globalAccidents) && $globalAccidents) { |
2749 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
3142 | + if ($globalDebug) { |
|
3143 | + echo 'Count fatalities stats...'."\n"; |
|
3144 | + } |
|
2750 | 3145 | $Accident = new Accident($this->db); |
2751 | 3146 | $this->deleteStatsByType('fatalities_byyear'); |
2752 | 3147 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2762,48 +3157,68 @@ discard block |
||
2762 | 3157 | |
2763 | 3158 | // Add by month using getstat if month finish... |
2764 | 3159 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
2765 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
3160 | + if ($globalDebug) { |
|
3161 | + echo 'Count all flights by months...'."\n"; |
|
3162 | + } |
|
2766 | 3163 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2767 | 3164 | $filter_last_month = array('since_date' => $last_month); |
2768 | 3165 | $Spotter = new Spotter($this->db); |
2769 | 3166 | $alldata = $Spotter->countAllMonths($filter_last_month); |
2770 | 3167 | $lastyear = false; |
2771 | 3168 | foreach ($alldata as $number) { |
2772 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3169 | + if ($number['year_name'] != date('Y')) { |
|
3170 | + $lastyear = true; |
|
3171 | + } |
|
2773 | 3172 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2774 | 3173 | } |
2775 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
3174 | + if ($globalDebug) { |
|
3175 | + echo 'Count all military flights by months...'."\n"; |
|
3176 | + } |
|
2776 | 3177 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
2777 | 3178 | foreach ($alldata as $number) { |
2778 | 3179 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2779 | 3180 | } |
2780 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
3181 | + if ($globalDebug) { |
|
3182 | + echo 'Count all owners by months...'."\n"; |
|
3183 | + } |
|
2781 | 3184 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
2782 | 3185 | foreach ($alldata as $number) { |
2783 | 3186 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2784 | 3187 | } |
2785 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
3188 | + if ($globalDebug) { |
|
3189 | + echo 'Count all pilots by months...'."\n"; |
|
3190 | + } |
|
2786 | 3191 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
2787 | 3192 | foreach ($alldata as $number) { |
2788 | 3193 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2789 | 3194 | } |
2790 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
3195 | + if ($globalDebug) { |
|
3196 | + echo 'Count all airlines by months...'."\n"; |
|
3197 | + } |
|
2791 | 3198 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
2792 | 3199 | foreach ($alldata as $number) { |
2793 | 3200 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2794 | 3201 | } |
2795 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
3202 | + if ($globalDebug) { |
|
3203 | + echo 'Count all aircrafts by months...'."\n"; |
|
3204 | + } |
|
2796 | 3205 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
2797 | 3206 | foreach ($alldata as $number) { |
2798 | 3207 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2799 | 3208 | } |
2800 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
3209 | + if ($globalDebug) { |
|
3210 | + echo 'Count all real arrivals by months...'."\n"; |
|
3211 | + } |
|
2801 | 3212 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
2802 | 3213 | foreach ($alldata as $number) { |
2803 | 3214 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2804 | 3215 | } |
2805 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
2806 | - if ($globalDebug) echo '...Departure'."\n"; |
|
3216 | + if ($globalDebug) { |
|
3217 | + echo 'Airports data...'."\n"; |
|
3218 | + } |
|
3219 | + if ($globalDebug) { |
|
3220 | + echo '...Departure'."\n"; |
|
3221 | + } |
|
2807 | 3222 | $this->deleteStatAirport('daily'); |
2808 | 3223 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
2809 | 3224 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2921,7 +3336,9 @@ discard block |
||
2921 | 3336 | // Count by airlines |
2922 | 3337 | echo '--- Stats by airlines ---'."\n"; |
2923 | 3338 | if ($Connection->tableExists('countries')) { |
2924 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
3339 | + if ($globalDebug) { |
|
3340 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
3341 | + } |
|
2925 | 3342 | $SpotterArchive = new SpotterArchive($this->db); |
2926 | 3343 | //$Spotter = new Spotter($this->db); |
2927 | 3344 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2930,37 +3347,53 @@ discard block |
||
2930 | 3347 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
2931 | 3348 | } |
2932 | 3349 | } |
2933 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
3350 | + if ($globalDebug) { |
|
3351 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
3352 | + } |
|
2934 | 3353 | $Spotter = new Spotter($this->db); |
2935 | 3354 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
2936 | 3355 | foreach ($alldata as $number) { |
2937 | 3356 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
2938 | 3357 | } |
2939 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
3358 | + if ($globalDebug) { |
|
3359 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
3360 | + } |
|
2940 | 3361 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
2941 | 3362 | foreach ($alldata as $number) { |
2942 | 3363 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
2943 | 3364 | } |
2944 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
3365 | + if ($globalDebug) { |
|
3366 | + echo 'Count all callsigns by airlines...'."\n"; |
|
3367 | + } |
|
2945 | 3368 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
2946 | 3369 | foreach ($alldata as $number) { |
2947 | 3370 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2948 | 3371 | } |
2949 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
3372 | + if ($globalDebug) { |
|
3373 | + echo 'Count all owners by airlines...'."\n"; |
|
3374 | + } |
|
2950 | 3375 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
2951 | 3376 | foreach ($alldata as $number) { |
2952 | 3377 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
2953 | 3378 | } |
2954 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
3379 | + if ($globalDebug) { |
|
3380 | + echo 'Count all pilots by airlines...'."\n"; |
|
3381 | + } |
|
2955 | 3382 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
2956 | 3383 | foreach ($alldata as $number) { |
2957 | 3384 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
2958 | 3385 | } |
2959 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
3386 | + if ($globalDebug) { |
|
3387 | + echo 'Count all departure airports by airlines...'."\n"; |
|
3388 | + } |
|
2960 | 3389 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
2961 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
3390 | + if ($globalDebug) { |
|
3391 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
3392 | + } |
|
2962 | 3393 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
2963 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
3394 | + if ($globalDebug) { |
|
3395 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
3396 | + } |
|
2964 | 3397 | //$alldata = array(); |
2965 | 3398 | foreach ($dall as $value) { |
2966 | 3399 | $icao = $value['airport_departure_icao']; |
@@ -2981,11 +3414,17 @@ discard block |
||
2981 | 3414 | foreach ($alldata as $number) { |
2982 | 3415 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
2983 | 3416 | } |
2984 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
3417 | + if ($globalDebug) { |
|
3418 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
3419 | + } |
|
2985 | 3420 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
2986 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
3421 | + if ($globalDebug) { |
|
3422 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
3423 | + } |
|
2987 | 3424 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
2988 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
3425 | + if ($globalDebug) { |
|
3426 | + echo 'Order arrival airports by airlines...'."\n"; |
|
3427 | + } |
|
2989 | 3428 | //$alldata = array(); |
2990 | 3429 | foreach ($dall as $value) { |
2991 | 3430 | $icao = $value['airport_arrival_icao']; |
@@ -3004,37 +3443,53 @@ discard block |
||
3004 | 3443 | } |
3005 | 3444 | $alldata = $pall; |
3006 | 3445 | foreach ($alldata as $number) { |
3007 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
3446 | + if ($number['airline_icao'] != '') { |
|
3447 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
3448 | + } |
|
3449 | + } |
|
3450 | + if ($globalDebug) { |
|
3451 | + echo 'Count all flights by months by airlines...'."\n"; |
|
3008 | 3452 | } |
3009 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
3010 | 3453 | $Spotter = new Spotter($this->db); |
3011 | 3454 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
3012 | 3455 | $lastyear = false; |
3013 | 3456 | foreach ($alldata as $number) { |
3014 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3457 | + if ($number['year_name'] != date('Y')) { |
|
3458 | + $lastyear = true; |
|
3459 | + } |
|
3015 | 3460 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3016 | 3461 | } |
3017 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
3462 | + if ($globalDebug) { |
|
3463 | + echo 'Count all owners by months by airlines...'."\n"; |
|
3464 | + } |
|
3018 | 3465 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
3019 | 3466 | foreach ($alldata as $number) { |
3020 | 3467 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3021 | 3468 | } |
3022 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
3469 | + if ($globalDebug) { |
|
3470 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
3471 | + } |
|
3023 | 3472 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
3024 | 3473 | foreach ($alldata as $number) { |
3025 | 3474 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3026 | 3475 | } |
3027 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
3476 | + if ($globalDebug) { |
|
3477 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
3478 | + } |
|
3028 | 3479 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
3029 | 3480 | foreach ($alldata as $number) { |
3030 | 3481 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3031 | 3482 | } |
3032 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
3483 | + if ($globalDebug) { |
|
3484 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
3485 | + } |
|
3033 | 3486 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
3034 | 3487 | foreach ($alldata as $number) { |
3035 | 3488 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3036 | 3489 | } |
3037 | - if ($globalDebug) echo '...Departure'."\n"; |
|
3490 | + if ($globalDebug) { |
|
3491 | + echo '...Departure'."\n"; |
|
3492 | + } |
|
3038 | 3493 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
3039 | 3494 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
3040 | 3495 | foreach ($dall as $value) { |
@@ -3057,7 +3512,9 @@ discard block |
||
3057 | 3512 | foreach ($alldata as $number) { |
3058 | 3513 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
3059 | 3514 | } |
3060 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
3515 | + if ($globalDebug) { |
|
3516 | + echo '...Arrival'."\n"; |
|
3517 | + } |
|
3061 | 3518 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
3062 | 3519 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
3063 | 3520 | foreach ($dall as $value) { |
@@ -3081,13 +3538,19 @@ discard block |
||
3081 | 3538 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
3082 | 3539 | } |
3083 | 3540 | |
3084 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
3085 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
3541 | + if ($globalDebug) { |
|
3542 | + echo 'Flights data...'."\n"; |
|
3543 | + } |
|
3544 | + if ($globalDebug) { |
|
3545 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
3546 | + } |
|
3086 | 3547 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
3087 | 3548 | foreach ($alldata as $number) { |
3088 | 3549 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
3089 | 3550 | } |
3090 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
3551 | + if ($globalDebug) { |
|
3552 | + echo '-> countAllDates...'."\n"; |
|
3553 | + } |
|
3091 | 3554 | //$previousdata = $this->countAllDatesByAirlines(); |
3092 | 3555 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
3093 | 3556 | $values = array(); |
@@ -3100,14 +3563,18 @@ discard block |
||
3100 | 3563 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
3101 | 3564 | } |
3102 | 3565 | |
3103 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
3566 | + if ($globalDebug) { |
|
3567 | + echo '-> countAllHours...'."\n"; |
|
3568 | + } |
|
3104 | 3569 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
3105 | 3570 | foreach ($alldata as $number) { |
3106 | 3571 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
3107 | 3572 | } |
3108 | 3573 | |
3109 | 3574 | // Stats by filters |
3110 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
3575 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
3576 | + $globalStatsFilters = array(); |
|
3577 | + } |
|
3111 | 3578 | foreach ($globalStatsFilters as $name => $filter) { |
3112 | 3579 | if (!empty($filter)) { |
3113 | 3580 | //$filter_name = $filter['name']; |
@@ -3115,7 +3582,9 @@ discard block |
||
3115 | 3582 | $reset = false; |
3116 | 3583 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
3117 | 3584 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
3118 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
3585 | + if ($globalDebug) { |
|
3586 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
3587 | + } |
|
3119 | 3588 | $this->deleteOldStats($filter_name); |
3120 | 3589 | unset($last_update); |
3121 | 3590 | } |
@@ -3132,39 +3601,55 @@ discard block |
||
3132 | 3601 | $reset = true; |
3133 | 3602 | } |
3134 | 3603 | // Count by filter |
3135 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
3604 | + if ($globalDebug) { |
|
3605 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
3606 | + } |
|
3136 | 3607 | $Spotter = new Spotter($this->db); |
3137 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
3608 | + if ($globalDebug) { |
|
3609 | + echo 'Count all aircraft types...'."\n"; |
|
3610 | + } |
|
3138 | 3611 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
3139 | 3612 | foreach ($alldata as $number) { |
3140 | 3613 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
3141 | 3614 | } |
3142 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
3615 | + if ($globalDebug) { |
|
3616 | + echo 'Count all airlines...'."\n"; |
|
3617 | + } |
|
3143 | 3618 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
3144 | 3619 | foreach ($alldata as $number) { |
3145 | 3620 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
3146 | 3621 | } |
3147 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
3622 | + if ($globalDebug) { |
|
3623 | + echo 'Count all aircraft registrations...'."\n"; |
|
3624 | + } |
|
3148 | 3625 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
3149 | 3626 | foreach ($alldata as $number) { |
3150 | 3627 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
3151 | 3628 | } |
3152 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
3629 | + if ($globalDebug) { |
|
3630 | + echo 'Count all callsigns...'."\n"; |
|
3631 | + } |
|
3153 | 3632 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
3154 | 3633 | foreach ($alldata as $number) { |
3155 | 3634 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
3156 | 3635 | } |
3157 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
3636 | + if ($globalDebug) { |
|
3637 | + echo 'Count all owners...'."\n"; |
|
3638 | + } |
|
3158 | 3639 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
3159 | 3640 | foreach ($alldata as $number) { |
3160 | 3641 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
3161 | 3642 | } |
3162 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
3643 | + if ($globalDebug) { |
|
3644 | + echo 'Count all pilots...'."\n"; |
|
3645 | + } |
|
3163 | 3646 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
3164 | 3647 | foreach ($alldata as $number) { |
3165 | 3648 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
3166 | 3649 | } |
3167 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
3650 | + if ($globalDebug) { |
|
3651 | + echo 'Count departure airports...'."\n"; |
|
3652 | + } |
|
3168 | 3653 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
3169 | 3654 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
3170 | 3655 | $alldata = array(); |
@@ -3176,7 +3661,9 @@ discard block |
||
3176 | 3661 | $icao = $value['airport_departure_icao']; |
3177 | 3662 | if (isset($alldata[$icao])) { |
3178 | 3663 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
3179 | - } else $alldata[$icao] = $value; |
|
3664 | + } else { |
|
3665 | + $alldata[$icao] = $value; |
|
3666 | + } |
|
3180 | 3667 | } |
3181 | 3668 | $count = array(); |
3182 | 3669 | foreach ($alldata as $key => $row) { |
@@ -3186,7 +3673,9 @@ discard block |
||
3186 | 3673 | foreach ($alldata as $number) { |
3187 | 3674 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
3188 | 3675 | } |
3189 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
3676 | + if ($globalDebug) { |
|
3677 | + echo 'Count all arrival airports...'."\n"; |
|
3678 | + } |
|
3190 | 3679 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
3191 | 3680 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
3192 | 3681 | $alldata = array(); |
@@ -3198,7 +3687,9 @@ discard block |
||
3198 | 3687 | $icao = $value['airport_arrival_icao']; |
3199 | 3688 | if (isset($alldata[$icao])) { |
3200 | 3689 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
3201 | - } else $alldata[$icao] = $value; |
|
3690 | + } else { |
|
3691 | + $alldata[$icao] = $value; |
|
3692 | + } |
|
3202 | 3693 | } |
3203 | 3694 | $count = array(); |
3204 | 3695 | foreach ($alldata as $key => $row) { |
@@ -3208,35 +3699,49 @@ discard block |
||
3208 | 3699 | foreach ($alldata as $number) { |
3209 | 3700 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
3210 | 3701 | } |
3211 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
3702 | + if ($globalDebug) { |
|
3703 | + echo 'Count all months...'."\n"; |
|
3704 | + } |
|
3212 | 3705 | $Spotter = new Spotter($this->db); |
3213 | 3706 | $alldata = $Spotter->countAllMonths($filter); |
3214 | 3707 | $lastyear = false; |
3215 | 3708 | foreach ($alldata as $number) { |
3216 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3709 | + if ($number['year_name'] != date('Y')) { |
|
3710 | + $lastyear = true; |
|
3711 | + } |
|
3217 | 3712 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3218 | 3713 | } |
3219 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
3714 | + if ($globalDebug) { |
|
3715 | + echo 'Count all owners by months...'."\n"; |
|
3716 | + } |
|
3220 | 3717 | $alldata = $Spotter->countAllMonthsOwners($filter); |
3221 | 3718 | foreach ($alldata as $number) { |
3222 | 3719 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3223 | 3720 | } |
3224 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
3721 | + if ($globalDebug) { |
|
3722 | + echo 'Count all pilots by months...'."\n"; |
|
3723 | + } |
|
3225 | 3724 | $alldata = $Spotter->countAllMonthsPilots($filter); |
3226 | 3725 | foreach ($alldata as $number) { |
3227 | 3726 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3228 | 3727 | } |
3229 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
3728 | + if ($globalDebug) { |
|
3729 | + echo 'Count all military by months...'."\n"; |
|
3730 | + } |
|
3230 | 3731 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
3231 | 3732 | foreach ($alldata as $number) { |
3232 | 3733 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3233 | 3734 | } |
3234 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
3735 | + if ($globalDebug) { |
|
3736 | + echo 'Count all aircrafts by months...'."\n"; |
|
3737 | + } |
|
3235 | 3738 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
3236 | 3739 | foreach ($alldata as $number) { |
3237 | 3740 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3238 | 3741 | } |
3239 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
3742 | + if ($globalDebug) { |
|
3743 | + echo 'Count all real arrivals by months...'."\n"; |
|
3744 | + } |
|
3240 | 3745 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
3241 | 3746 | foreach ($alldata as $number) { |
3242 | 3747 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -95,8 +98,9 @@ discard block |
||
95 | 98 | private function curlResponseHeaderCallback($ch, $headerLine) { |
96 | 99 | //global $cookies; |
97 | 100 | $cookies = array(); |
98 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
99 | - $cookies[] = $cookie; |
|
101 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
102 | + $cookies[] = $cookie; |
|
103 | + } |
|
100 | 104 | return strlen($headerLine); // Needed by curl |
101 | 105 | } |
102 | 106 | |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | curl_setopt($ch, CURLOPT_URL, $url); |
108 | 112 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
109 | 113 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
110 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
114 | + if ($referer != '') { |
|
115 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
116 | + } |
|
111 | 117 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
112 | 118 | if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
113 | 119 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
@@ -119,7 +125,9 @@ discard block |
||
119 | 125 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
120 | 126 | curl_setopt($ch, CURLOPT_FILE, $fp); |
121 | 127 | curl_exec($ch); |
122 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
128 | + if (curl_errno($ch) && $globalDebug) { |
|
129 | + echo 'Download error: '.curl_error($ch); |
|
130 | + } |
|
123 | 131 | curl_close($ch); |
124 | 132 | fclose($fp); |
125 | 133 | } |
@@ -127,12 +135,16 @@ discard block |
||
127 | 135 | public static function gunzip($in_file,$out_file_name = '') { |
128 | 136 | //echo $in_file.' -> '.$out_file_name."\n"; |
129 | 137 | $buffer_size = 4096; // read 4kb at a time |
130 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
138 | + if ($out_file_name == '') { |
|
139 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
140 | + } |
|
131 | 141 | if ($in_file != '' && file_exists($in_file)) { |
132 | 142 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
133 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
134 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
135 | - else { |
|
143 | + if (function_exists('gzopen')) { |
|
144 | + $file = gzopen($in_file,'rb'); |
|
145 | + } elseif (function_exists('gzopen64')) { |
|
146 | + $file = gzopen64($in_file,'rb'); |
|
147 | + } else { |
|
136 | 148 | echo 'gzopen not available'; |
137 | 149 | die; |
138 | 150 | } |
@@ -148,11 +160,14 @@ discard block |
||
148 | 160 | public static function bunzip2($in_file,$out_file_name = '') { |
149 | 161 | //echo $in_file.' -> '.$out_file_name."\n"; |
150 | 162 | $buffer_size = 4096; // read 4kb at a time |
151 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
163 | + if ($out_file_name == '') { |
|
164 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
165 | + } |
|
152 | 166 | if ($in_file != '' && file_exists($in_file)) { |
153 | 167 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
154 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
155 | - else { |
|
168 | + if (function_exists('bzopen')) { |
|
169 | + $file = bzopen($in_file,'rb'); |
|
170 | + } else { |
|
156 | 171 | echo 'bzopen not available'; |
157 | 172 | die; |
158 | 173 | } |
@@ -171,10 +186,16 @@ discard block |
||
171 | 186 | * @return Array array of the tables in HTML page |
172 | 187 | */ |
173 | 188 | public function table2array($data) { |
174 | - if (!is_string($data)) return array(); |
|
175 | - if ($data == '') return array(); |
|
189 | + if (!is_string($data)) { |
|
190 | + return array(); |
|
191 | + } |
|
192 | + if ($data == '') { |
|
193 | + return array(); |
|
194 | + } |
|
176 | 195 | $html = str_get_html($data); |
177 | - if ($html === false) return array(); |
|
196 | + if ($html === false) { |
|
197 | + return array(); |
|
198 | + } |
|
178 | 199 | $tabledata=array(); |
179 | 200 | foreach($html->find('tr') as $element) |
180 | 201 | { |
@@ -209,7 +230,9 @@ discard block |
||
209 | 230 | */ |
210 | 231 | public function text2array($data) { |
211 | 232 | $html = str_get_html($data); |
212 | - if ($html === false) return array(); |
|
233 | + if ($html === false) { |
|
234 | + return array(); |
|
235 | + } |
|
213 | 236 | $tabledata=array(); |
214 | 237 | foreach($html->find('p') as $element) |
215 | 238 | { |
@@ -230,7 +253,9 @@ discard block |
||
230 | 253 | * @return Float Distance in $unit |
231 | 254 | */ |
232 | 255 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
233 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
256 | + if ($lat == $latc && $lon == $lonc) { |
|
257 | + return 0; |
|
258 | + } |
|
234 | 259 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
235 | 260 | if ($unit == "km") { |
236 | 261 | return round($dist * 1.609344); |
@@ -269,7 +294,9 @@ discard block |
||
269 | 294 | $dX = $latc - $lat; |
270 | 295 | $dY = $lonc - $lon; |
271 | 296 | $azimuth = rad2deg(atan2($dY,$dX)); |
272 | - if ($azimuth < 0) return $azimuth+360; |
|
297 | + if ($azimuth < 0) { |
|
298 | + return $azimuth+360; |
|
299 | + } |
|
273 | 300 | return $azimuth; |
274 | 301 | } |
275 | 302 | |
@@ -283,10 +310,16 @@ discard block |
||
283 | 310 | public function withinThreshold ($timeDifference, $distance) { |
284 | 311 | $x = abs($timeDifference); |
285 | 312 | $d = abs($distance); |
286 | - if ($x == 0 || $d == 0) return true; |
|
313 | + if ($x == 0 || $d == 0) { |
|
314 | + return true; |
|
315 | + } |
|
287 | 316 | // may be due to Internet jitter; distance is realistic |
288 | - if ($x < 0.7 && $d < 2000) return true; |
|
289 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
317 | + if ($x < 0.7 && $d < 2000) { |
|
318 | + return true; |
|
319 | + } else { |
|
320 | + return $d/$x < 1500*0.27778; |
|
321 | + } |
|
322 | + // 1500 km/h max |
|
290 | 323 | } |
291 | 324 | |
292 | 325 | |
@@ -314,11 +347,17 @@ discard block |
||
314 | 347 | |
315 | 348 | public function convertDM($coord,$latlong) { |
316 | 349 | if ($latlong == 'latitude') { |
317 | - if ($coord < 0) $NSEW = 'S'; |
|
318 | - else $NSEW = 'N'; |
|
350 | + if ($coord < 0) { |
|
351 | + $NSEW = 'S'; |
|
352 | + } else { |
|
353 | + $NSEW = 'N'; |
|
354 | + } |
|
319 | 355 | } else { |
320 | - if ($coord < 0) $NSEW = 'W'; |
|
321 | - else $NSEW = 'E'; |
|
356 | + if ($coord < 0) { |
|
357 | + $NSEW = 'W'; |
|
358 | + } else { |
|
359 | + $NSEW = 'E'; |
|
360 | + } |
|
322 | 361 | } |
323 | 362 | $coord = abs($coord); |
324 | 363 | $deg = floor($coord); |
@@ -361,7 +400,9 @@ discard block |
||
361 | 400 | public function hex2str($hex) { |
362 | 401 | $str = ''; |
363 | 402 | $hexln = strlen($hex); |
364 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
403 | + for($i=0;$i<$hexln;$i+=2) { |
|
404 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
405 | + } |
|
365 | 406 | return $str; |
366 | 407 | } |
367 | 408 | |
@@ -398,8 +439,11 @@ discard block |
||
398 | 439 | $b = $lat2 - $lat1; |
399 | 440 | $c = -($a*$lat1+$b*$lon1); |
400 | 441 | $d = $a*$lat3+$b*$lon3+$c; |
401 | - if ($d > -$approx && $d < $approx) return true; |
|
402 | - else return false; |
|
442 | + if ($d > -$approx && $d < $approx) { |
|
443 | + return true; |
|
444 | + } else { |
|
445 | + return false; |
|
446 | + } |
|
403 | 447 | } |
404 | 448 | |
405 | 449 | public function array_merge_noappend() { |
@@ -458,7 +502,9 @@ discard block |
||
458 | 502 | return $result; |
459 | 503 | } |
460 | 504 | $handle = @opendir('./locale'); |
461 | - if ($handle === false) return $result; |
|
505 | + if ($handle === false) { |
|
506 | + return $result; |
|
507 | + } |
|
462 | 508 | while (false !== ($file = readdir($handle))) { |
463 | 509 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
464 | 510 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -529,8 +575,9 @@ discard block |
||
529 | 575 | $error = false; |
530 | 576 | if ($fp_out = gzopen($dest, $mode)) { |
531 | 577 | if ($fp_in = fopen($source,'rb')) { |
532 | - while (!feof($fp_in)) |
|
533 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
578 | + while (!feof($fp_in)) { |
|
579 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
580 | + } |
|
534 | 581 | fclose($fp_in); |
535 | 582 | } else { |
536 | 583 | $error = true; |
@@ -539,14 +586,17 @@ discard block |
||
539 | 586 | } else { |
540 | 587 | $error = true; |
541 | 588 | } |
542 | - if ($error) |
|
543 | - return false; |
|
544 | - else |
|
545 | - return $dest; |
|
589 | + if ($error) { |
|
590 | + return false; |
|
591 | + } else { |
|
592 | + return $dest; |
|
593 | + } |
|
546 | 594 | } |
547 | 595 | |
548 | 596 | public function remove_accents($string) { |
549 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
597 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
598 | + return $string; |
|
599 | + } |
|
550 | 600 | $chars = array( |
551 | 601 | // Decompositions for Latin-1 Supplement |
552 | 602 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -670,7 +720,9 @@ discard block |
||
670 | 720 | $ip = gethostbyname($host); |
671 | 721 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
672 | 722 | $r = @socket_connect($s, $ip, $port); |
673 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
723 | + if (!socket_set_nonblock($s)) { |
|
724 | + echo "Unable to set nonblock on socket\n"; |
|
725 | + } |
|
674 | 726 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
675 | 727 | return $s; |
676 | 728 | } |
@@ -715,18 +767,22 @@ discard block |
||
715 | 767 | //NOTE: use a trailing slash for folders!!! |
716 | 768 | //see http://bugs.php.net/bug.php?id=27609 |
717 | 769 | //see http://bugs.php.net/bug.php?id=30931 |
718 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
770 | + if ($path{strlen($path)-1}=='/') { |
|
771 | + // recursively return a temporary file path |
|
719 | 772 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
720 | - else if (is_dir($path)) |
|
721 | - return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
773 | + } else if (is_dir($path)) { |
|
774 | + return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
775 | + } |
|
722 | 776 | // check tmp file for read/write capabilities |
723 | 777 | $rm = file_exists($path); |
724 | 778 | $f = @fopen($path, 'a'); |
725 | - if ($f===false) |
|
726 | - return false; |
|
779 | + if ($f===false) { |
|
780 | + return false; |
|
781 | + } |
|
727 | 782 | fclose($f); |
728 | - if (!$rm) |
|
729 | - unlink($path); |
|
783 | + if (!$rm) { |
|
784 | + unlink($path); |
|
785 | + } |
|
730 | 786 | return true; |
731 | 787 | } |
732 | 788 | } |
@@ -14,23 +14,23 @@ discard block |
||
14 | 14 | $marine = false; |
15 | 15 | $usecoord = false; |
16 | 16 | if (isset($_GET['tracker'])) { |
17 | - $tracker = true; |
|
17 | + $tracker = true; |
|
18 | 18 | } |
19 | 19 | if (isset($_GET['marine'])) { |
20 | - $marine = true; |
|
20 | + $marine = true; |
|
21 | 21 | } |
22 | 22 | if ($tracker) { |
23 | - require_once('require/class.Tracker.php'); |
|
24 | - require_once('require/class.TrackerLive.php'); |
|
25 | - require_once('require/class.TrackerArchive.php'); |
|
23 | + require_once('require/class.Tracker.php'); |
|
24 | + require_once('require/class.TrackerLive.php'); |
|
25 | + require_once('require/class.TrackerArchive.php'); |
|
26 | 26 | } elseif ($marine) { |
27 | - require_once('require/class.Marine.php'); |
|
28 | - require_once('require/class.MarineLive.php'); |
|
29 | - require_once('require/class.MarineArchive.php'); |
|
27 | + require_once('require/class.Marine.php'); |
|
28 | + require_once('require/class.MarineLive.php'); |
|
29 | + require_once('require/class.MarineArchive.php'); |
|
30 | 30 | } else { |
31 | - require_once('require/class.Spotter.php'); |
|
32 | - require_once('require/class.SpotterLive.php'); |
|
33 | - require_once('require/class.SpotterArchive.php'); |
|
31 | + require_once('require/class.Spotter.php'); |
|
32 | + require_once('require/class.SpotterLive.php'); |
|
33 | + require_once('require/class.SpotterArchive.php'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $begintime = microtime(true); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $Common = new Common(); |
51 | 51 | |
52 | 52 | if (isset($_GET['download'])) { |
53 | - if ($_GET['download'] == "true") |
|
54 | - { |
|
53 | + if ($_GET['download'] == "true") |
|
54 | + { |
|
55 | 55 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | header('Content-Type: text/javascript'); |
59 | 59 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $usecoord = true; |
118 | 118 | $coord = explode(',',$_GET['coord']); |
119 | 119 | if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
120 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
120 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
121 | 121 | if ($tracker) { |
122 | 122 | $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
123 | 123 | } elseif ($marine) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $usecoord = true; |
131 | 131 | $coord = explode(',',$_GET['coord']); |
132 | 132 | if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
133 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
133 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
134 | 134 | if ($tracker) { |
135 | 135 | $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
136 | 136 | } elseif ($marine) { |
@@ -634,17 +634,17 @@ discard block |
||
634 | 634 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
635 | 635 | |
636 | 636 | if ( |
637 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
638 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
637 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
638 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
639 | 639 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
640 | 640 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
641 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
642 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
643 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
644 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
645 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
646 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
647 | - ) { |
|
641 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
642 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
643 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
644 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
645 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
646 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
647 | + ) { |
|
648 | 648 | if ($tracker) { |
649 | 649 | if ($from_archive || $globalArchive) { |
650 | 650 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
653 | 653 | } |
654 | 654 | if ($globalMapMatching === TRUE && |
655 | - isset($spotter_item['type']) && ( |
|
655 | + isset($spotter_item['type']) && ( |
|
656 | 656 | $spotter_item['type'] == 'Firetruck' || |
657 | 657 | $spotter_item['type'] == 'Ambulance' || |
658 | 658 | $spotter_item['type'] == 'Truck (18 Wheeler)' || |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | $spotter_item['type'] == 'Jeep' || |
665 | 665 | $spotter_item['type'] == 'Motorcycle' || |
666 | 666 | $spotter_item['type'] == 'Car' |
667 | - ) |
|
667 | + ) |
|
668 | 668 | ) { |
669 | 669 | require(dirname(__FILE__).'/require/class.MapMatching.php'); |
670 | 670 | $MapMatching = new MapMatching(); |
@@ -753,65 +753,65 @@ discard block |
||
753 | 753 | } |
754 | 754 | |
755 | 755 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
756 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
757 | - && (isset($spotter_item['departure_airport']) |
|
758 | - && $spotter_item['departure_airport'] != 'NA' |
|
759 | - && isset($spotter_item['arrival_airport']) |
|
760 | - && $spotter_item['arrival_airport'] != 'NA' |
|
761 | - && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
762 | - || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
763 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
764 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
765 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
756 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
757 | + && (isset($spotter_item['departure_airport']) |
|
758 | + && $spotter_item['departure_airport'] != 'NA' |
|
759 | + && isset($spotter_item['arrival_airport']) |
|
760 | + && $spotter_item['arrival_airport'] != 'NA' |
|
761 | + && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
762 | + || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
763 | + if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
764 | + else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
765 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
766 | 766 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
767 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
767 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
768 | 768 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
769 | 769 | if (isset($dairport[0]['latitude'])) { |
770 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
770 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
771 | 771 | } |
772 | - } |
|
773 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
772 | + } |
|
773 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
774 | 774 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],'; |
775 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
775 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
776 | 776 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
777 | 777 | if (isset($aairport[0]['latitude'])) { |
778 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
778 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
779 | 779 | } |
780 | - } |
|
781 | - $output_air = substr($output_air, 0, -1); |
|
782 | - $output_air .= ']}},'; |
|
783 | - $output .= $output_air; |
|
784 | - unset($output_air); |
|
780 | + } |
|
781 | + $output_air = substr($output_air, 0, -1); |
|
782 | + $output_air .= ']}},'; |
|
783 | + $output .= $output_air; |
|
784 | + unset($output_air); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
788 | 788 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
789 | 789 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
790 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
791 | - && (isset($spotter_item['arrival_airport']) |
|
792 | - && $spotter_item['arrival_airport'] != 'NA' |
|
793 | - && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
794 | - || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
|
795 | - || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
796 | - $havedata = false; |
|
797 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
798 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
799 | - $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
790 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
791 | + && (isset($spotter_item['arrival_airport']) |
|
792 | + && $spotter_item['arrival_airport'] != 'NA' |
|
793 | + && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
794 | + || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
|
795 | + || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
796 | + $havedata = false; |
|
797 | + if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
798 | + else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
799 | + $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
800 | 800 | |
801 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
801 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
802 | 802 | $output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
803 | 803 | $havedata = true; |
804 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
804 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
805 | 805 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
806 | 806 | if (isset($aairport[0]['latitude'])) { |
807 | - $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
808 | - $havedata = true; |
|
807 | + $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
808 | + $havedata = true; |
|
809 | 809 | } |
810 | - } |
|
811 | - //$output_dest = substr($output_dest, 0, -1); |
|
812 | - $output_dest .= ']}},'; |
|
813 | - if ($havedata) $output .= $output_dest; |
|
814 | - unset($output_dest); |
|
810 | + } |
|
811 | + //$output_dest = substr($output_dest, 0, -1); |
|
812 | + $output_dest .= ']}},'; |
|
813 | + if ($havedata) $output .= $output_dest; |
|
814 | + unset($output_dest); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | $output = substr($output, 0, -1); |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | $min = true; |
65 | 65 | $allhistory = false; |
66 | 66 | $filter['source'] = array(); |
67 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
70 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
72 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
73 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
74 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
75 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
76 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
68 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
69 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
71 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
72 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
73 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
74 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
75 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
76 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
77 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
78 | 78 | |
79 | 79 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
80 | 80 | $min = true; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $spotter_array = array(); |
84 | 84 | |
85 | 85 | if (isset($_GET['ident'])) { |
86 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
86 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
87 | 87 | if ($tracker) { |
88 | 88 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
89 | 89 | } elseif ($marine) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['flightaware_id'])) { |
100 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
100 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
101 | 101 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
102 | 102 | if (empty($spotter_array)) { |
103 | 103 | $from_archive = true; |
@@ -105,38 +105,38 @@ discard block |
||
105 | 105 | } |
106 | 106 | $allhistory = true; |
107 | 107 | } elseif (isset($_GET['famtrack_id'])) { |
108 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
108 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
109 | 109 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
110 | 110 | $allhistory = true; |
111 | 111 | } elseif (isset($_GET['fammarine_id'])) { |
112 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
112 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
113 | 113 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
114 | 114 | $allhistory = true; |
115 | 115 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
116 | 116 | //} elseif (isset($_GET['coord'])) { |
117 | 117 | $usecoord = true; |
118 | - $coord = explode(',',$_GET['coord']); |
|
119 | - if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
118 | + $coord = explode(',', $_GET['coord']); |
|
119 | + if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
120 | 120 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
121 | 121 | if ($tracker) { |
122 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
123 | 123 | } elseif ($marine) { |
124 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
124 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
125 | 125 | } else { |
126 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
126 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
130 | 130 | $usecoord = true; |
131 | - $coord = explode(',',$_GET['coord']); |
|
132 | - if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
131 | + $coord = explode(',', $_GET['coord']); |
|
132 | + if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
133 | 133 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
134 | 134 | if ($tracker) { |
135 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
135 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
136 | 136 | } elseif ($marine) { |
137 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
137 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
138 | 138 | } else { |
139 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
139 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
140 | 140 | } |
141 | 141 | } else { |
142 | 142 | if ($tracker) { |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | $from_archive = true; |
152 | 152 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
153 | 153 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
154 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
155 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
156 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
157 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
158 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
159 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
154 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
155 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
156 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
157 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
158 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
159 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
160 | 160 | } elseif ($min) { |
161 | 161 | if ($tracker) { |
162 | 162 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | # $min = true; |
169 | 169 | } else { |
170 | 170 | if ($tracker) { |
171 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
171 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
172 | 172 | } elseif ($marine) { |
173 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
173 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
174 | 174 | } else { |
175 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
175 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | 179 | if ($usecoord) { |
180 | 180 | if (isset($_GET['archive'])) { |
181 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
181 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
182 | 182 | } else { |
183 | 183 | if ($tracker) { |
184 | 184 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | if ($flightcnt == '') $flightcnt = 0; |
192 | 192 | } else $flightcnt = 0; |
193 | 193 | |
194 | -$sqltime = round(microtime(true)-$begintime,2); |
|
194 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
195 | 195 | |
196 | -$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
196 | +$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
197 | 197 | if ($currenttime != '') $currenttime = round($currenttime/1000); |
198 | 198 | |
199 | 199 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | if (!empty($spotter_array) && is_array($spotter_array)) |
213 | 213 | { |
214 | 214 | $output .= '"features": ['; |
215 | - foreach($spotter_array as $spotter_item) |
|
215 | + foreach ($spotter_array as $spotter_item) |
|
216 | 216 | { |
217 | 217 | $j++; |
218 | 218 | unset($idistance); |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | */ |
270 | 270 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
271 | 271 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
272 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
273 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
272 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
273 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
274 | 274 | //" |
275 | 275 | } else { |
276 | 276 | if ($compress) $output .= '"c": "NA",'; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
280 | 280 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
281 | 281 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
282 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
282 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
283 | 283 | } elseif (isset($spotter_item['aircraft_type'])) { |
284 | 284 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
285 | 285 | } elseif (!$min) { |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | if (isset($archivespeed) || $usenextlatlon) { |
423 | 423 | if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
424 | 424 | if (isset($spotter_item['arrival_airport_latitude'])) { |
425 | - $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
|
426 | - $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
|
425 | + $cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']); |
|
426 | + $idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']); |
|
427 | 427 | $farr_lat = $spotter_item['arrival_airport_latitude']; |
428 | 428 | $farr_lon = $spotter_item['arrival_airport_longitude']; |
429 | 429 | } else { |
430 | 430 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
431 | 431 | if (isset($aairport[0]['latitude'])) { |
432 | - $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
|
433 | - $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
|
432 | + $cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']); |
|
433 | + $idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']); |
|
434 | 434 | $farr_lat = $aairport[0]['latitude']; |
435 | 435 | $farr_lon = $aairport[0]['longitude']; |
436 | 436 | } |
@@ -443,59 +443,59 @@ discard block |
||
443 | 443 | if ($currenttime != '') { |
444 | 444 | if (strtotime($spotter_item['date']) < $currenttime) { |
445 | 445 | if (isset($archivespeed)) { |
446 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
447 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
446 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
447 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
448 | 448 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
449 | 449 | else { |
450 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
451 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
450 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
451 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
452 | 452 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
453 | 453 | else { |
454 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
454 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
455 | 455 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } elseif ($usenextlatlon) { |
459 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
460 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
459 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
460 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
461 | 461 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
462 | 462 | else { |
463 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
464 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
463 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
464 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
465 | 465 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
466 | 466 | else { |
467 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
467 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
468 | 468 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
469 | 469 | } |
470 | 470 | } |
471 | 471 | } |
472 | 472 | } else { |
473 | 473 | if (isset($archivespeed)) { |
474 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
474 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
475 | 475 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
476 | 476 | } elseif ($usenextlatlon) { |
477 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
477 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
478 | 478 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
479 | 479 | } |
480 | 480 | } |
481 | 481 | } else { |
482 | 482 | if (isset($archivespeed)) { |
483 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
484 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
483 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
484 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
485 | 485 | if (!isset($idistance) || $fdistance < $idistance) { |
486 | 486 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
487 | 487 | } else { |
488 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed); |
|
488 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed); |
|
489 | 489 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
490 | 490 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
491 | 491 | } |
492 | 492 | } elseif ($usenextlatlon) { |
493 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
494 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
493 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
494 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
495 | 495 | if (!isset($idistance) || $fdistance < $idistance) { |
496 | 496 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
497 | 497 | } else { |
498 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading); |
|
498 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading); |
|
499 | 499 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
500 | 500 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
501 | 501 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | if (!$min) $output .= '"image": "'.$image.'",'; |
506 | 506 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
507 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
507 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
508 | 508 | } |
509 | 509 | if (isset($spotter_item['image_source_website'])) { |
510 | 510 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
527 | 527 | } |
528 | 528 | if (isset($spotter_item['acars'])) { |
529 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
529 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
530 | 530 | } |
531 | 531 | // type when not aircraft ? |
532 | 532 | if (isset($spotter_item['type'])) { |
@@ -546,12 +546,12 @@ discard block |
||
546 | 546 | if ($currenttime != '') { |
547 | 547 | if (strtotime($spotter_item['date']) < $currenttime) { |
548 | 548 | if (!isset($archivespeed)) $archivespeed = 1; |
549 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
|
550 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
549 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']))); |
|
550 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
551 | 551 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
552 | 552 | else { |
553 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
|
554 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
553 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']))); |
|
554 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
555 | 555 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
556 | 556 | else { |
557 | 557 | $output .= $spotter_item['longitude'].', '; |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | |
631 | 631 | } |
632 | 632 | */ |
633 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
633 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
634 | 634 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
635 | 635 | |
636 | 636 | if ( |
@@ -638,11 +638,11 @@ discard block |
||
638 | 638 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
639 | 639 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
640 | 640 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
641 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
641 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
642 | 642 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
643 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
643 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
644 | 644 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
645 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
645 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
646 | 646 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
647 | 647 | ) { |
648 | 648 | if ($tracker) { |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
699 | 699 | } |
700 | 700 | $output_history .= '['; |
701 | - $output_history .= $spotter_history['longitude'].', '; |
|
702 | - $output_history .= $spotter_history['latitude'].', '; |
|
703 | - $output_history .= $spotter_history['altitude']*30.48; |
|
701 | + $output_history .= $spotter_history['longitude'].', '; |
|
702 | + $output_history .= $spotter_history['latitude'].', '; |
|
703 | + $output_history .= $spotter_history['altitude']*30.48; |
|
704 | 704 | $output_history .= '],'; |
705 | 705 | /* |
706 | 706 | if ($from_archive === false) { |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | $d = true; |
720 | 720 | } |
721 | 721 | $output_history .= '['; |
722 | - $output_history .= $spotter_history['longitude'].', '; |
|
723 | - $output_history .= $spotter_history['latitude']; |
|
722 | + $output_history .= $spotter_history['longitude'].', '; |
|
723 | + $output_history .= $spotter_history['latitude']; |
|
724 | 724 | $output_history .= '],'; |
725 | 725 | /* |
726 | 726 | if ($from_archive === false) { |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | //echo $output_history; |
737 | 737 | if ($from_archive === false) { |
738 | 738 | $output_historyd = '['; |
739 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
740 | - $output_historyd .= $spotter_item['latitude']; |
|
741 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
739 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
740 | + $output_historyd .= $spotter_item['latitude']; |
|
741 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
742 | 742 | $output_historyd .= '],'; |
743 | 743 | //$output_history = $output_historyd.$output_history; |
744 | 744 | $output_history = $output_history.$output_historyd; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | } |
753 | 753 | } |
754 | 754 | |
755 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
755 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
756 | 756 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
757 | 757 | && (isset($spotter_item['departure_airport']) |
758 | 758 | && $spotter_item['departure_airport'] != 'NA' |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
788 | 788 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
789 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
789 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
790 | 790 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
791 | 791 | && (isset($spotter_item['arrival_airport']) |
792 | 792 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | $output = substr($output, 0, -1); |
818 | 818 | $output .= ']'; |
819 | 819 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
820 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
820 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
821 | 821 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
822 | 822 | $output .= '"fc": "'.$j.'"'; |
823 | 823 | } else { |
@@ -57,28 +57,55 @@ discard block |
||
57 | 57 | } |
58 | 58 | header('Content-Type: text/javascript'); |
59 | 59 | |
60 | -if (!isset($globalJsonCompress)) $compress = true; |
|
61 | -else $compress = $globalJsonCompress; |
|
60 | +if (!isset($globalJsonCompress)) { |
|
61 | + $compress = true; |
|
62 | +} else { |
|
63 | + $compress = $globalJsonCompress; |
|
64 | +} |
|
62 | 65 | |
63 | 66 | $from_archive = false; |
64 | 67 | $min = true; |
65 | 68 | $allhistory = false; |
66 | 69 | $filter['source'] = array(); |
67 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
70 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
72 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
73 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
74 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
75 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
76 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
70 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
71 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
72 | +} |
|
73 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
74 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
75 | +} |
|
76 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
77 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
78 | +} |
|
79 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
80 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
81 | +} |
|
82 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
83 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
84 | +} |
|
85 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
86 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
87 | +} |
|
88 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') { |
|
89 | + $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
90 | +} |
|
91 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
92 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
93 | +} |
|
94 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
95 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
96 | +} |
|
97 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
98 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
99 | +} |
|
100 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
101 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
102 | +} |
|
78 | 103 | |
79 | 104 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
80 | 105 | $min = true; |
81 | -} else $min = false; |
|
106 | +} else { |
|
107 | + $min = false; |
|
108 | +} |
|
82 | 109 | |
83 | 110 | $spotter_array = array(); |
84 | 111 | |
@@ -188,24 +215,38 @@ discard block |
||
188 | 215 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
189 | 216 | } |
190 | 217 | } |
191 | - if ($flightcnt == '') $flightcnt = 0; |
|
192 | -} else $flightcnt = 0; |
|
218 | + if ($flightcnt == '') { |
|
219 | + $flightcnt = 0; |
|
220 | + } |
|
221 | + } else { |
|
222 | + $flightcnt = 0; |
|
223 | +} |
|
193 | 224 | |
194 | 225 | $sqltime = round(microtime(true)-$begintime,2); |
195 | 226 | |
196 | 227 | $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
197 | -if ($currenttime != '') $currenttime = round($currenttime/1000); |
|
228 | +if ($currenttime != '') { |
|
229 | + $currenttime = round($currenttime/1000); |
|
230 | +} |
|
198 | 231 | |
199 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
200 | -else $usenextlatlon = true; |
|
201 | -if ($usenextlatlon === false) $currenttime = ''; |
|
232 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
233 | + $usenextlatlon = false; |
|
234 | +} else { |
|
235 | + $usenextlatlon = true; |
|
236 | +} |
|
237 | +if ($usenextlatlon === false) { |
|
238 | + $currenttime = ''; |
|
239 | +} |
|
202 | 240 | $j = 0; |
203 | 241 | $prev_flightaware_id = ''; |
204 | 242 | $aircrafts_shadow = array(); |
205 | 243 | $output = '{'; |
206 | 244 | $output .= '"type": "FeatureCollection",'; |
207 | - if ($min) $output .= '"minimal": "true",'; |
|
208 | - else $output .= '"minimal": "false",'; |
|
245 | + if ($min) { |
|
246 | + $output .= '"minimal": "true",'; |
|
247 | + } else { |
|
248 | + $output .= '"minimal": "false",'; |
|
249 | + } |
|
209 | 250 | //$output .= '"fc": "'.$flightcnt.'",'; |
210 | 251 | $output .= '"sqt": "'.$sqltime.'",'; |
211 | 252 | |
@@ -250,18 +291,29 @@ discard block |
||
250 | 291 | } |
251 | 292 | $output .= '"properties": {'; |
252 | 293 | if (isset($spotter_item['flightaware_id'])) { |
253 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
254 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
294 | + if ($compress) { |
|
295 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
296 | + } else { |
|
297 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
298 | + } |
|
255 | 299 | } elseif (isset($spotter_item['famtrackid'])) { |
256 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
257 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
300 | + if ($compress) { |
|
301 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
302 | + } else { |
|
303 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
304 | + } |
|
258 | 305 | } elseif (isset($spotter_item['fammarine_id'])) { |
259 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
260 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
306 | + if ($compress) { |
|
307 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
308 | + } else { |
|
309 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
310 | + } |
|
261 | 311 | } |
262 | 312 | $output .= '"fc": "'.$flightcnt.'",'; |
263 | 313 | $output .= '"sqt": "'.$sqltime.'",'; |
264 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
314 | + if (isset($begindate)) { |
|
315 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
316 | + } |
|
265 | 317 | |
266 | 318 | /* |
267 | 319 | if ($min) $output .= '"minimal": "true",'; |
@@ -269,14 +321,22 @@ discard block |
||
269 | 321 | */ |
270 | 322 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
271 | 323 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
272 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
273 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
324 | + if ($compress) { |
|
325 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
326 | + } else { |
|
327 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
328 | + } |
|
274 | 329 | //" |
275 | 330 | } else { |
276 | - if ($compress) $output .= '"c": "NA",'; |
|
277 | - else $output .= '"callsign": "NA",'; |
|
331 | + if ($compress) { |
|
332 | + $output .= '"c": "NA",'; |
|
333 | + } else { |
|
334 | + $output .= '"callsign": "NA",'; |
|
335 | + } |
|
336 | + } |
|
337 | + if (isset($spotter_item['registration'])) { |
|
338 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
278 | 339 | } |
279 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
280 | 340 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
281 | 341 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
282 | 342 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -289,16 +349,23 @@ discard block |
||
289 | 349 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
290 | 350 | } |
291 | 351 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
292 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
293 | - else { |
|
352 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
353 | + $spotter_item['aircraft_shadow'] = ''; |
|
354 | + } else { |
|
294 | 355 | $aircraft_icao = $spotter_item['aircraft_icao']; |
295 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
296 | - else { |
|
356 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
357 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
358 | + } else { |
|
297 | 359 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
298 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
299 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
300 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
301 | - else $spotter_item['aircraft_shadow'] = ''; |
|
360 | + if (count($aircraft_info) > 0) { |
|
361 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
362 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
363 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
364 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
365 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
366 | + } else { |
|
367 | + $spotter_item['aircraft_shadow'] = ''; |
|
368 | + } |
|
302 | 369 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
303 | 370 | } |
304 | 371 | } |
@@ -306,73 +373,139 @@ discard block |
||
306 | 373 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
307 | 374 | if ($tracker) { |
308 | 375 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
309 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
310 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
376 | + if ($compress) { |
|
377 | + $output .= '"as": "ambulance.png",'; |
|
378 | + } else { |
|
379 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
380 | + } |
|
311 | 381 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
312 | - if ($compress) $output .= '"as": "police.png",'; |
|
313 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
382 | + if ($compress) { |
|
383 | + $output .= '"as": "police.png",'; |
|
384 | + } else { |
|
385 | + $output .= '"aircraft_shadow": "police.png",'; |
|
386 | + } |
|
314 | 387 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
315 | - if ($compress) $output .= '"as": "ship.png",'; |
|
316 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
388 | + if ($compress) { |
|
389 | + $output .= '"as": "ship.png",'; |
|
390 | + } else { |
|
391 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
392 | + } |
|
317 | 393 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
318 | - if ($compress) $output .= '"as": "ship.png",'; |
|
319 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
394 | + if ($compress) { |
|
395 | + $output .= '"as": "ship.png",'; |
|
396 | + } else { |
|
397 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
398 | + } |
|
320 | 399 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
321 | - if ($compress) $output .= '"as": "ship.png",'; |
|
322 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
400 | + if ($compress) { |
|
401 | + $output .= '"as": "ship.png",'; |
|
402 | + } else { |
|
403 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
404 | + } |
|
323 | 405 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
324 | - if ($compress) $output .= '"as": "truck.png",'; |
|
325 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
406 | + if ($compress) { |
|
407 | + $output .= '"as": "truck.png",'; |
|
408 | + } else { |
|
409 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
410 | + } |
|
326 | 411 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
327 | - if ($compress) $output .= '"as": "truck.png",'; |
|
328 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
412 | + if ($compress) { |
|
413 | + $output .= '"as": "truck.png",'; |
|
414 | + } else { |
|
415 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
416 | + } |
|
329 | 417 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
330 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
331 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
418 | + if ($compress) { |
|
419 | + $output .= '"as": "aircraft.png",'; |
|
420 | + } else { |
|
421 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
422 | + } |
|
332 | 423 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
333 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
334 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
424 | + if ($compress) { |
|
425 | + $output .= '"as": "aircraft.png",'; |
|
426 | + } else { |
|
427 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
428 | + } |
|
335 | 429 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
336 | - if ($compress) $output .= '"as": "helico.png",'; |
|
337 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
430 | + if ($compress) { |
|
431 | + $output .= '"as": "helico.png",'; |
|
432 | + } else { |
|
433 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
434 | + } |
|
338 | 435 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
339 | - if ($compress) $output .= '"as": "rail.png",'; |
|
340 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
436 | + if ($compress) { |
|
437 | + $output .= '"as": "rail.png",'; |
|
438 | + } else { |
|
439 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
440 | + } |
|
341 | 441 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
342 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
343 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
442 | + if ($compress) { |
|
443 | + $output .= '"as": "firetruck.png",'; |
|
444 | + } else { |
|
445 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
446 | + } |
|
344 | 447 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
345 | - if ($compress) $output .= '"as": "bus.png",'; |
|
346 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
448 | + if ($compress) { |
|
449 | + $output .= '"as": "bus.png",'; |
|
450 | + } else { |
|
451 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
452 | + } |
|
347 | 453 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
348 | - if ($compress) $output .= '"as": "phone.png",'; |
|
349 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
454 | + if ($compress) { |
|
455 | + $output .= '"as": "phone.png",'; |
|
456 | + } else { |
|
457 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
458 | + } |
|
350 | 459 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
351 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
352 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
460 | + if ($compress) { |
|
461 | + $output .= '"as": "jogger.png",'; |
|
462 | + } else { |
|
463 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
464 | + } |
|
353 | 465 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
354 | - if ($compress) $output .= '"as": "bike.png",'; |
|
355 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
466 | + if ($compress) { |
|
467 | + $output .= '"as": "bike.png",'; |
|
468 | + } else { |
|
469 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
470 | + } |
|
356 | 471 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
357 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
358 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
472 | + if ($compress) { |
|
473 | + $output .= '"as": "motorcycle.png",'; |
|
474 | + } else { |
|
475 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
476 | + } |
|
359 | 477 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
360 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
361 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
478 | + if ($compress) { |
|
479 | + $output .= '"as": "balloon.png",'; |
|
480 | + } else { |
|
481 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
482 | + } |
|
362 | 483 | } else { |
363 | - if ($compress) $output .= '"as": "car.png",'; |
|
364 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
484 | + if ($compress) { |
|
485 | + $output .= '"as": "car.png",'; |
|
486 | + } else { |
|
487 | + $output .= '"aircraft_shadow": "car.png",'; |
|
488 | + } |
|
365 | 489 | } |
366 | 490 | } elseif ($marine) { |
367 | - if ($compress) $output .= '"as": "ship.png",'; |
|
368 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
491 | + if ($compress) { |
|
492 | + $output .= '"as": "ship.png",'; |
|
493 | + } else { |
|
494 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
495 | + } |
|
369 | 496 | } else { |
370 | - if ($compress) $output .= '"as": "default.png",'; |
|
371 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
497 | + if ($compress) { |
|
498 | + $output .= '"as": "default.png",'; |
|
499 | + } else { |
|
500 | + $output .= '"aircraft_shadow": "default.png",'; |
|
501 | + } |
|
372 | 502 | } |
373 | 503 | } else { |
374 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
375 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
504 | + if ($compress) { |
|
505 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
506 | + } else { |
|
507 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
508 | + } |
|
376 | 509 | } |
377 | 510 | if (isset($spotter_item['airline_name'])) { |
378 | 511 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -380,8 +513,11 @@ discard block |
||
380 | 513 | $output .= '"airline_name": "NA",'; |
381 | 514 | } |
382 | 515 | if (isset($spotter_item['departure_airport'])) { |
383 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
384 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
516 | + if ($compress) { |
|
517 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
518 | + } else { |
|
519 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
520 | + } |
|
385 | 521 | } |
386 | 522 | if (isset($spotter_item['departure_airport_city'])) { |
387 | 523 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -393,8 +529,11 @@ discard block |
||
393 | 529 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
394 | 530 | } |
395 | 531 | if (isset($spotter_item['arrival_airport'])) { |
396 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
397 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
532 | + if ($compress) { |
|
533 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
534 | + } else { |
|
535 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
536 | + } |
|
398 | 537 | } |
399 | 538 | if (isset($spotter_item['arrival_airport_city'])) { |
400 | 539 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -413,8 +552,11 @@ discard block |
||
413 | 552 | } |
414 | 553 | |
415 | 554 | if (isset($spotter_item['altitude'])) { |
416 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
417 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
555 | + if ($compress) { |
|
556 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
557 | + } else { |
|
558 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
559 | + } |
|
418 | 560 | } |
419 | 561 | |
420 | 562 | $heading = $spotter_item['heading']; |
@@ -438,19 +580,24 @@ discard block |
||
438 | 580 | } |
439 | 581 | } |
440 | 582 | |
441 | - if ($compress)$output .= '"h": "'.$heading.'",'; |
|
442 | - else $output .= '"heading": "'.$heading.'",'; |
|
583 | + if ($compress) { |
|
584 | + $output .= '"h": "'.$heading.'",'; |
|
585 | + } else { |
|
586 | + $output .= '"heading": "'.$heading.'",'; |
|
587 | + } |
|
443 | 588 | if ($currenttime != '') { |
444 | 589 | if (strtotime($spotter_item['date']) < $currenttime) { |
445 | 590 | if (isset($archivespeed)) { |
446 | 591 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
447 | 592 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
448 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
449 | - else { |
|
593 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
594 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
595 | + } else { |
|
450 | 596 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
451 | 597 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
452 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
453 | - else { |
|
598 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
599 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
600 | + } else { |
|
454 | 601 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
455 | 602 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
456 | 603 | } |
@@ -458,12 +605,14 @@ discard block |
||
458 | 605 | } elseif ($usenextlatlon) { |
459 | 606 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
460 | 607 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
461 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
462 | - else { |
|
608 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
609 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
610 | + } else { |
|
463 | 611 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
464 | 612 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
465 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
466 | - else { |
|
613 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
614 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
615 | + } else { |
|
467 | 616 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
468 | 617 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
469 | 618 | } |
@@ -502,7 +651,9 @@ discard block |
||
502 | 651 | } |
503 | 652 | } |
504 | 653 | |
505 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
654 | + if (!$min) { |
|
655 | + $output .= '"image": "'.$image.'",'; |
|
656 | + } |
|
506 | 657 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
507 | 658 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
508 | 659 | } |
@@ -510,8 +661,11 @@ discard block |
||
510 | 661 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
511 | 662 | } |
512 | 663 | if (isset($spotter_item['squawk'])) { |
513 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
514 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
664 | + if ($compress) { |
|
665 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
666 | + } else { |
|
667 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
668 | + } |
|
515 | 669 | } |
516 | 670 | if (isset($spotter_item['squawk_usage'])) { |
517 | 671 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -530,14 +684,23 @@ discard block |
||
530 | 684 | } |
531 | 685 | // type when not aircraft ? |
532 | 686 | if (isset($spotter_item['type'])) { |
533 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
534 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
687 | + if ($compress) { |
|
688 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
689 | + } else { |
|
690 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
691 | + } |
|
535 | 692 | } elseif ($marine) { |
536 | - if ($compress) $output .= '"t": "ship"'; |
|
537 | - else $output .= '"type": "ship"'; |
|
693 | + if ($compress) { |
|
694 | + $output .= '"t": "ship"'; |
|
695 | + } else { |
|
696 | + $output .= '"type": "ship"'; |
|
697 | + } |
|
538 | 698 | } else { |
539 | - if ($compress) $output .= '"t": "aircraft"'; |
|
540 | - else $output .= '"type": "aircraft"'; |
|
699 | + if ($compress) { |
|
700 | + $output .= '"t": "aircraft"'; |
|
701 | + } else { |
|
702 | + $output .= '"type": "aircraft"'; |
|
703 | + } |
|
541 | 704 | } |
542 | 705 | $output .= '},'; |
543 | 706 | $output .= '"geometry": {'; |
@@ -545,15 +708,19 @@ discard block |
||
545 | 708 | $output .= '"coordinates": ['; |
546 | 709 | if ($currenttime != '') { |
547 | 710 | if (strtotime($spotter_item['date']) < $currenttime) { |
548 | - if (!isset($archivespeed)) $archivespeed = 1; |
|
711 | + if (!isset($archivespeed)) { |
|
712 | + $archivespeed = 1; |
|
713 | + } |
|
549 | 714 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
550 | 715 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
551 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
552 | - else { |
|
716 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
717 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
718 | + } else { |
|
553 | 719 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
554 | 720 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
555 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
556 | - else { |
|
721 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
722 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
723 | + } else { |
|
557 | 724 | $output .= $spotter_item['longitude'].', '; |
558 | 725 | $output .= $spotter_item['latitude']; |
559 | 726 | } |
@@ -631,7 +798,9 @@ discard block |
||
631 | 798 | } |
632 | 799 | */ |
633 | 800 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
634 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
801 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
802 | + $history = $_COOKIE['history']; |
|
803 | + } |
|
635 | 804 | |
636 | 805 | if ( |
637 | 806 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -694,8 +863,11 @@ discard block |
||
694 | 863 | $output_history .= ']}},'; |
695 | 864 | $output .= $output_history; |
696 | 865 | } |
697 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
698 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
866 | + if ($compress) { |
|
867 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
868 | + } else { |
|
869 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
870 | + } |
|
699 | 871 | } |
700 | 872 | $output_history .= '['; |
701 | 873 | $output_history .= $spotter_history['longitude'].', '; |
@@ -714,8 +886,11 @@ discard block |
||
714 | 886 | $prev_alt = $alt; |
715 | 887 | } else { |
716 | 888 | if ($d == false) { |
717 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
718 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
889 | + if ($compress) { |
|
890 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
891 | + } else { |
|
892 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
893 | + } |
|
719 | 894 | $d = true; |
720 | 895 | } |
721 | 896 | $output_history .= '['; |
@@ -738,7 +913,9 @@ discard block |
||
738 | 913 | $output_historyd = '['; |
739 | 914 | $output_historyd .= $spotter_item['longitude'].', '; |
740 | 915 | $output_historyd .= $spotter_item['latitude']; |
741 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
916 | + if (isset($spotter_history['altitude'])) { |
|
917 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
918 | + } |
|
742 | 919 | $output_historyd .= '],'; |
743 | 920 | //$output_history = $output_historyd.$output_history; |
744 | 921 | $output_history = $output_history.$output_historyd; |
@@ -760,8 +937,11 @@ discard block |
||
760 | 937 | && $spotter_item['arrival_airport'] != 'NA' |
761 | 938 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
762 | 939 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
763 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
764 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
940 | + if ($compress) { |
|
941 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
942 | + } else { |
|
943 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
944 | + } |
|
765 | 945 | if (isset($spotter_item['departure_airport_latitude'])) { |
766 | 946 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
767 | 947 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -794,8 +974,11 @@ discard block |
||
794 | 974 | || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
795 | 975 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
796 | 976 | $havedata = false; |
797 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
798 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
977 | + if ($compress) { |
|
978 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
979 | + } else { |
|
980 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
981 | + } |
|
799 | 982 | $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
800 | 983 | |
801 | 984 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -810,7 +993,9 @@ discard block |
||
810 | 993 | } |
811 | 994 | //$output_dest = substr($output_dest, 0, -1); |
812 | 995 | $output_dest .= ']}},'; |
813 | - if ($havedata) $output .= $output_dest; |
|
996 | + if ($havedata) { |
|
997 | + $output .= $output_dest; |
|
998 | + } |
|
814 | 999 | unset($output_dest); |
815 | 1000 | } |
816 | 1001 | } |
@@ -818,7 +1003,9 @@ discard block |
||
818 | 1003 | $output .= ']'; |
819 | 1004 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
820 | 1005 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
821 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
1006 | + if (isset($begindate)) { |
|
1007 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
1008 | + } |
|
822 | 1009 | $output .= '"fc": "'.$j.'"'; |
823 | 1010 | } else { |
824 | 1011 | $output .= '"features": '; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | // When button "Remove all filters" is clicked |
39 | 39 | if (isset($_POST['removefilters'])) { |
40 | 40 | $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
41 | - return strpos($key,'filter_') === 0; |
|
41 | + return strpos($key,'filter_') === 0; |
|
42 | 42 | }); |
43 | 43 | foreach ($allfilters as $filt) { |
44 | 44 | unset($_COOKIE[$filt]); |
@@ -188,17 +188,17 @@ discard block |
||
188 | 188 | } |
189 | 189 | ?> |
190 | 190 | <?php |
191 | - if (isset($_POST['archive'])) { |
|
191 | + if (isset($_POST['archive'])) { |
|
192 | 192 | ?> |
193 | 193 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
194 | 194 | <?php |
195 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
195 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
196 | 196 | ?> |
197 | 197 | |
198 | 198 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script> |
199 | 199 | <?php |
200 | - } |
|
201 | - } else { |
|
200 | + } |
|
201 | + } else { |
|
202 | 202 | ?> |
203 | 203 | <?php |
204 | 204 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | ?> |
212 | 212 | <?php |
213 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
213 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
214 | 214 | ?> |
215 | 215 | <?php |
216 | 216 | // if (isset($globalBeta) && $globalBeta) { |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | <script src="<?php print $globalURL; ?>/js/map-satellite.2d.js.php?<?php print time(); ?>"></script> |
242 | 242 | <?php |
243 | 243 | } |
244 | - } |
|
244 | + } |
|
245 | 245 | ?> |
246 | 246 | <?php |
247 | 247 | // } |
248 | 248 | ?> |
249 | 249 | <?php |
250 | - } |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | ?> |
253 | 253 | <?php |
@@ -424,34 +424,34 @@ discard block |
||
424 | 424 | |
425 | 425 | <ul class="nav navbar-nav"> |
426 | 426 | <?php |
427 | - if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) { |
|
427 | + if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) { |
|
428 | 428 | ?> |
429 | 429 | <li><a href="<?php print $globalURL; ?>/news"><?php echo _("News"); ?></a></li> |
430 | 430 | <?php |
431 | - } |
|
431 | + } |
|
432 | 432 | ?> |
433 | 433 | |
434 | 434 | <?php |
435 | - $sub = false; |
|
436 | - if ( |
|
435 | + $sub = false; |
|
436 | + if ( |
|
437 | 437 | ( |
438 | - (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE)) |
|
438 | + (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE)) |
|
439 | 439 | ) || |
440 | 440 | ( |
441 | - isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE)) |
|
441 | + isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE)) |
|
442 | 442 | ) || |
443 | 443 | ( |
444 | - isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE)) |
|
444 | + isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE)) |
|
445 | 445 | ) || |
446 | 446 | ( |
447 | - isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE)) |
|
447 | + isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE)) |
|
448 | 448 | ) |
449 | - ) { |
|
449 | + ) { |
|
450 | 450 | $sub = true; |
451 | - } |
|
451 | + } |
|
452 | 452 | ?> |
453 | 453 | <?php |
454 | - if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
454 | + if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
455 | 455 | ?> |
456 | 456 | <li class="dropdown"> |
457 | 457 | <?php |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | <ul class="dropdown-menu multi-level"> |
463 | 463 | <li class="dropdown-submenu"> |
464 | 464 | <?php |
465 | - } |
|
465 | + } |
|
466 | 466 | ?> |
467 | 467 | <?php |
468 | 468 | if (isset($globalNewsFeeds['aircraft']) && !empty($globalNewsFeeds['aircraft'])) { |
@@ -477,25 +477,25 @@ discard block |
||
477 | 477 | <ul class="dropdown-menu"> |
478 | 478 | <li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li> |
479 | 479 | <?php |
480 | - if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) { |
|
480 | + if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) { |
|
481 | 481 | ?> |
482 | 482 | <li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li> |
483 | 483 | <?php |
484 | - } |
|
484 | + } |
|
485 | 485 | ?> |
486 | 486 | <li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li> |
487 | 487 | <?php |
488 | - if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) { |
|
488 | + if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) { |
|
489 | 489 | ?> |
490 | 490 | <li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li> |
491 | 491 | <?php |
492 | - } |
|
493 | - if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
|
492 | + } |
|
493 | + if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
|
494 | 494 | |
495 | 495 | ?> |
496 | 496 | <li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li> |
497 | 497 | <?php |
498 | - } |
|
498 | + } |
|
499 | 499 | ?> |
500 | 500 | <li><hr /></li> |
501 | 501 | <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li> |
@@ -503,43 +503,43 @@ discard block |
||
503 | 503 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
504 | 504 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
505 | 505 | <?php |
506 | - if ($globalACARS) { |
|
507 | - if (isset($globalDemo) && $globalDemo) { |
|
508 | - ?> |
|
506 | + if ($globalACARS) { |
|
507 | + if (isset($globalDemo) && $globalDemo) { |
|
508 | + ?> |
|
509 | 509 | <li><hr /></li> |
510 | 510 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
511 | 511 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
512 | 512 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
513 | 513 | <?php |
514 | - } else { |
|
515 | - ?> |
|
514 | + } else { |
|
515 | + ?> |
|
516 | 516 | <li><hr /></li> |
517 | 517 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
518 | 518 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
519 | 519 | <?php |
520 | - } |
|
521 | - } |
|
522 | - ?> |
|
520 | + } |
|
521 | + } |
|
522 | + ?> |
|
523 | 523 | <?php |
524 | - if (isset($globalAccidents) && $globalAccidents) { |
|
525 | - ?> |
|
524 | + if (isset($globalAccidents) && $globalAccidents) { |
|
525 | + ?> |
|
526 | 526 | <li><hr /></li> |
527 | 527 | <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li> |
528 | 528 | <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li> |
529 | 529 | <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li> |
530 | 530 | <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li> |
531 | 531 | <?php |
532 | - } |
|
533 | - ?> |
|
532 | + } |
|
533 | + ?> |
|
534 | 534 | <li><hr /></li> |
535 | 535 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
536 | 536 | <?php |
537 | 537 | if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) { |
538 | - ?> |
|
538 | + ?> |
|
539 | 539 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
540 | 540 | <?php |
541 | 541 | } |
542 | - ?> |
|
542 | + ?> |
|
543 | 543 | </ul> |
544 | 544 | </li> |
545 | 545 | <li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li> |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | </ul> |
567 | 567 | <?php |
568 | 568 | } |
569 | - } |
|
569 | + } |
|
570 | 570 | ?> |
571 | 571 | <?php |
572 | - if (isset($globalMarine) && $globalMarine) { |
|
572 | + if (isset($globalMarine) && $globalMarine) { |
|
573 | 573 | ?> |
574 | 574 | <li class="dropdown"> |
575 | 575 | <?php |
576 | - if ($sub) { |
|
576 | + if ($sub) { |
|
577 | 577 | ?> |
578 | 578 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Marines"); ?> <b class="caret"></b></a> |
579 | 579 | <ul class="dropdown-menu multi-level"> |
@@ -607,14 +607,14 @@ discard block |
||
607 | 607 | } |
608 | 608 | ?> |
609 | 609 | <?php |
610 | - } |
|
610 | + } |
|
611 | 611 | ?> |
612 | 612 | <?php |
613 | - if (isset($globalTracker) && $globalTracker) { |
|
613 | + if (isset($globalTracker) && $globalTracker) { |
|
614 | 614 | ?> |
615 | 615 | <li class="dropdown"> |
616 | 616 | <?php |
617 | - if ($sub) { |
|
617 | + if ($sub) { |
|
618 | 618 | ?> |
619 | 619 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a> |
620 | 620 | <ul class="dropdown-menu multi-level"> |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | } |
649 | 649 | ?> |
650 | 650 | <?php |
651 | - } |
|
651 | + } |
|
652 | 652 | ?> |
653 | 653 | <?php |
654 | - if (isset($globalSatellite) && $globalSatellite) { |
|
654 | + if (isset($globalSatellite) && $globalSatellite) { |
|
655 | 655 | ?> |
656 | 656 | <li class="dropdown"> |
657 | 657 | <?php |
658 | - if ($sub) { |
|
658 | + if ($sub) { |
|
659 | 659 | ?> |
660 | 660 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellites"); ?> <b class="caret"></b></a> |
661 | 661 | <ul class="dropdown-menu multi-level"> |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | } |
692 | 692 | ?> |
693 | 693 | <?php |
694 | - } |
|
694 | + } |
|
695 | 695 | ?> |
696 | 696 | |
697 | 697 | <li class="dropdown"> |
@@ -700,12 +700,12 @@ discard block |
||
700 | 700 | <li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li> |
701 | 701 | <li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li> |
702 | 702 | <?php |
703 | - if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
703 | + if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
704 | 704 | ?> |
705 | 705 | <li><hr /></li> |
706 | 706 | <li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li> |
707 | 707 | <?php |
708 | - } |
|
708 | + } |
|
709 | 709 | ?> |
710 | 710 | <?php if (isset($globalContribute) && $globalContribute) { ?> |
711 | 711 | <li><hr /></li> |
@@ -726,14 +726,14 @@ discard block |
||
726 | 726 | <form> |
727 | 727 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
728 | 728 | <?php |
729 | - $Language = new Language(); |
|
730 | - $alllang = $Language->getLanguages(); |
|
731 | - foreach ($alllang as $key => $lang) { |
|
732 | - print '<option value="'.$key.'"'; |
|
733 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
734 | - print '>'.$lang[0].'</option>'; |
|
735 | - } |
|
736 | - ?> |
|
729 | + $Language = new Language(); |
|
730 | + $alllang = $Language->getLanguages(); |
|
731 | + foreach ($alllang as $key => $lang) { |
|
732 | + print '<option value="'.$key.'"'; |
|
733 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
734 | + print '>'.$lang[0].'</option>'; |
|
735 | + } |
|
736 | + ?> |
|
737 | 737 | </select> |
738 | 738 | </form> |
739 | 739 | </div> |
@@ -765,18 +765,18 @@ discard block |
||
765 | 765 | ?> |
766 | 766 | <div class="top-header clear" role="main"> |
767 | 767 | <?php |
768 | - if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
768 | + if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
769 | 769 | ?> |
770 | 770 | <div id="archive-map"></div> |
771 | 771 | <?php |
772 | - } |
|
772 | + } |
|
773 | 773 | ?> |
774 | 774 | </div> |
775 | 775 | <?php |
776 | 776 | } |
777 | 777 | if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false)) |
778 | 778 | { |
779 | - ?> |
|
779 | + ?> |
|
780 | 780 | <div class="top-header clear" role="main"> |
781 | 781 | <div id="map"></div> |
782 | 782 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -787,15 +787,15 @@ discard block |
||
787 | 787 | var zoom = 13; |
788 | 788 | //create the map |
789 | 789 | <?php |
790 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
790 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
791 | 791 | ?> |
792 | 792 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
793 | 793 | <?php |
794 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
794 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
795 | 795 | ?> |
796 | 796 | map = L.map('map', { zoomControl:true }); |
797 | 797 | <?php |
798 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
798 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
799 | 799 | ?> |
800 | 800 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
801 | 801 | var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map); |
@@ -803,22 +803,22 @@ discard block |
||
803 | 803 | var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
804 | 804 | var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
805 | 805 | <?php |
806 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) { |
|
806 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) { |
|
807 | 807 | ?> |
808 | 808 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
809 | 809 | <?php |
810 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
810 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
811 | 811 | ?> |
812 | 812 | map = L.map('map', { zoomControl:true }); |
813 | 813 | <?php |
814 | - } |
|
814 | + } |
|
815 | 815 | ?> |
816 | 816 | //initialize the layer group for the aircrft markers |
817 | 817 | var layer_data = L.layerGroup(); |
818 | 818 | |
819 | 819 | //a few title layers |
820 | 820 | <?php |
821 | - if ($globalMapProvider == 'Mapbox') { |
|
821 | + if ($globalMapProvider == 'Mapbox') { |
|
822 | 822 | ?> |
823 | 823 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
824 | 824 | maxZoom: 18, |
@@ -829,14 +829,14 @@ discard block |
||
829 | 829 | token : '<?php print $globalMapboxToken; ?>' |
830 | 830 | }).addTo(map); |
831 | 831 | <?php |
832 | - } elseif ($globalMapProvider == 'Mapbox-GL') { |
|
832 | + } elseif ($globalMapProvider == 'Mapbox-GL') { |
|
833 | 833 | ?> |
834 | 834 | L.mapboxGL({ |
835 | 835 | accessToken: '<?php print $globalMapboxToken; ?>', |
836 | 836 | style: 'mapbox://styles/mapbox/bright-v8' |
837 | 837 | }).addTo(map); |
838 | 838 | <?php |
839 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
839 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
840 | 840 | ?> |
841 | 841 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
842 | 842 | maxZoom: 18, |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
846 | 846 | }).addTo(map); |
847 | 847 | <?php |
848 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
848 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
849 | 849 | ?> |
850 | 850 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
851 | 851 | maxZoom: 18, |
@@ -854,27 +854,27 @@ discard block |
||
854 | 854 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"' |
855 | 855 | }).addTo(map); |
856 | 856 | <?php |
857 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
857 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
858 | 858 | ?> |
859 | 859 | var googleLayer = new L.Google('ROADMAP'); |
860 | 860 | map.addLayer(googleLayer); |
861 | 861 | <?php |
862 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
862 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
863 | 863 | ?> |
864 | 864 | var googleLayer = new L.Google('SATELLITE'); |
865 | 865 | map.addLayer(googleLayer); |
866 | 866 | <?php |
867 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
867 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
868 | 868 | ?> |
869 | 869 | var googleLayer = new L.Google('HYBRID'); |
870 | 870 | map.addLayer(googleLayer); |
871 | 871 | <?php |
872 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
872 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
873 | 873 | ?> |
874 | 874 | var googleLayer = new L.Google('Terrain'); |
875 | 875 | map.addLayer(googleLayer); |
876 | 876 | <?php |
877 | - } elseif (isset($globalMapCustomLayer[$globalMapProvider])) { |
|
877 | + } elseif (isset($globalMapCustomLayer[$globalMapProvider])) { |
|
878 | 878 | $customid = $globalMapProvider; |
879 | 879 | ?> |
880 | 880 | L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', { |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
885 | 885 | }).addTo(map); |
886 | 886 | <?php |
887 | - } elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) { |
|
887 | + } elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) { |
|
888 | 888 | ?> |
889 | 889 | var center = map.getCenter(); |
890 | 890 | map.options.crs = L.CRS.EPSG4326; |
@@ -899,8 +899,8 @@ discard block |
||
899 | 899 | attribution: 'Natural Earth' |
900 | 900 | }).addTo(map); |
901 | 901 | <?php |
902 | - //} elseif ($globalMapProvider == 'OpenStreetMap') { |
|
903 | - } else { |
|
902 | + //} elseif ($globalMapProvider == 'OpenStreetMap') { |
|
903 | + } else { |
|
904 | 904 | ?> |
905 | 905 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
906 | 906 | maxZoom: 18, |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | }).addTo(map); |
910 | 910 | |
911 | 911 | <?php |
912 | - } |
|
912 | + } |
|
913 | 913 | ?> |
914 | 914 | </script> |
915 | 915 | </div> |
@@ -6,12 +6,19 @@ discard block |
||
6 | 6 | //gets the page file and stores it in a variable |
7 | 7 | $file_path = pathinfo($_SERVER['SCRIPT_NAME']); |
8 | 8 | $current_page = $file_path['filename']; |
9 | -if ($globalTimezone == '') $globalTimezone = 'UTC'; |
|
9 | +if ($globalTimezone == '') { |
|
10 | + $globalTimezone = 'UTC'; |
|
11 | +} |
|
10 | 12 | date_default_timezone_set($globalTimezone); |
11 | -if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType']; |
|
12 | -else $MapType = $globalMapProvider; |
|
13 | +if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') { |
|
14 | + $MapType = $_COOKIE['MapType']; |
|
15 | +} else { |
|
16 | + $MapType = $globalMapProvider; |
|
17 | +} |
|
13 | 18 | |
14 | -if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline'; |
|
19 | +if (isset($globalMapOffline) && $globalMapOffline) { |
|
20 | + $MapType = 'offline'; |
|
21 | +} |
|
15 | 22 | |
16 | 23 | if (isset($_GET['3d'])) { |
17 | 24 | setcookie('MapFormat','3d'); |
@@ -219,7 +226,10 @@ discard block |
||
219 | 226 | <?php |
220 | 227 | // } |
221 | 228 | ?> |
222 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script> |
|
229 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) { |
|
230 | + print '&tsk='.$tsk; |
|
231 | +} |
|
232 | +?>"></script> |
|
223 | 233 | <?php |
224 | 234 | if (!isset($globalAircraft) || $globalAircraft) { |
225 | 235 | ?> |
@@ -264,7 +274,13 @@ discard block |
||
264 | 274 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
265 | 275 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
266 | 276 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
267 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
277 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) { |
|
278 | + print '&latitude='.$latitude; |
|
279 | +} |
|
280 | +?><?php if(isset($longitude)) { |
|
281 | + print '&longitude='.$longitude; |
|
282 | +} |
|
283 | +?>&<?php print time(); ?>"></script> |
|
268 | 284 | <?php |
269 | 285 | if (!isset($type) || $type == 'aircraft') { |
270 | 286 | ?> |
@@ -337,7 +353,13 @@ discard block |
||
337 | 353 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
338 | 354 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
339 | 355 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
340 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
356 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) { |
|
357 | + print '&latitude='.$latitude; |
|
358 | +} |
|
359 | +?><?php if(isset($longitude)) { |
|
360 | + print '&longitude='.$longitude; |
|
361 | +} |
|
362 | +?>&<?php print time(); ?>"></script> |
|
341 | 363 | <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script> |
342 | 364 | <?php |
343 | 365 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
@@ -418,7 +440,12 @@ discard block |
||
418 | 440 | <span class="icon-bar"></span> |
419 | 441 | </button> |
420 | 442 | <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a> |
421 | - <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a> |
|
443 | + <a class="navbar-brand" href="<?php if ($globalURL == '') { |
|
444 | + print '/'; |
|
445 | +} else { |
|
446 | + print $globalURL; |
|
447 | +} |
|
448 | +?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a> |
|
422 | 449 | </div> |
423 | 450 | <div class="collapse navbar-collapse"> |
424 | 451 | |
@@ -473,7 +500,10 @@ discard block |
||
473 | 500 | } |
474 | 501 | ?> |
475 | 502 | |
476 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
503 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
504 | + echo 'right-'; |
|
505 | +} |
|
506 | +?>caret"></b></a> |
|
477 | 507 | <ul class="dropdown-menu"> |
478 | 508 | <li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li> |
479 | 509 | <?php |
@@ -544,8 +574,14 @@ discard block |
||
544 | 574 | </li> |
545 | 575 | <li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li> |
546 | 576 | <li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li> |
547 | - <li class="dropdown<?php if ($sub) echo '-submenu'; ?>"> |
|
548 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
577 | + <li class="dropdown<?php if ($sub) { |
|
578 | + echo '-submenu'; |
|
579 | +} |
|
580 | +?>"> |
|
581 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) { |
|
582 | + echo 'right-'; |
|
583 | +} |
|
584 | +?>caret"></b></a> |
|
549 | 585 | <ul class="dropdown-menu"> |
550 | 586 | <li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li> |
551 | 587 | <li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li> |
@@ -589,7 +625,10 @@ discard block |
||
589 | 625 | <?php |
590 | 626 | } |
591 | 627 | ?> |
592 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
628 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
629 | + echo 'right-'; |
|
630 | +} |
|
631 | +?>caret"></b></a> |
|
593 | 632 | <ul class="dropdown-menu"> |
594 | 633 | <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li> |
595 | 634 | <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li> |
@@ -630,7 +669,10 @@ discard block |
||
630 | 669 | <?php |
631 | 670 | } |
632 | 671 | ?> |
633 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
672 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
673 | + echo 'right-'; |
|
674 | +} |
|
675 | +?>caret"></b></a> |
|
634 | 676 | <ul class="dropdown-menu"> |
635 | 677 | <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li> |
636 | 678 | <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li> |
@@ -673,7 +715,10 @@ discard block |
||
673 | 715 | ?> |
674 | 716 | |
675 | 717 | <!-- |
676 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
718 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
719 | + echo 'right-'; |
|
720 | +} |
|
721 | +?>caret"></b></a> |
|
677 | 722 | <ul class="dropdown-menu"> |
678 | 723 | <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li> |
679 | 724 | <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li> |
@@ -730,7 +775,9 @@ discard block |
||
730 | 775 | $alllang = $Language->getLanguages(); |
731 | 776 | foreach ($alllang as $key => $lang) { |
732 | 777 | print '<option value="'.$key.'"'; |
733 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
778 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) { |
|
779 | + print ' selected '; |
|
780 | + } |
|
734 | 781 | print '>'.$lang[0].'</option>'; |
735 | 782 | } |
736 | 783 | ?> |
@@ -878,9 +925,24 @@ discard block |
||
878 | 925 | $customid = $globalMapProvider; |
879 | 926 | ?> |
880 | 927 | L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', { |
881 | - maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>, |
|
882 | - minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>, |
|
883 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
928 | + maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) { |
|
929 | + print $globalMapCustomLayer[$customid]['maxZoom']; |
|
930 | +} else { |
|
931 | + print '18'; |
|
932 | +} |
|
933 | +?>, |
|
934 | + minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) { |
|
935 | + print $globalMapCustomLayer[$customid]['minZoom']; |
|
936 | +} else { |
|
937 | + print '0'; |
|
938 | +} |
|
939 | +?>, |
|
940 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
941 | + print 'false'; |
|
942 | +} else { |
|
943 | + print 'true'; |
|
944 | +} |
|
945 | +?>, |
|
884 | 946 | attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
885 | 947 | }).addTo(map); |
886 | 948 | <?php |
@@ -895,7 +957,12 @@ discard block |
||
895 | 957 | maxZoom: 5, |
896 | 958 | tms : true, |
897 | 959 | zindex : 3, |
898 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
960 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
961 | + print 'false'; |
|
962 | +} else { |
|
963 | + print 'true'; |
|
964 | +} |
|
965 | +?>, |
|
899 | 966 | attribution: 'Natural Earth' |
900 | 967 | }).addTo(map); |
901 | 968 | <?php |
@@ -918,4 +985,7 @@ discard block |
||
918 | 985 | |
919 | 986 | ?> |
920 | 987 | |
921 | -<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear"> |
|
988 | +<section class="container main-content <?php if (strtolower($current_page) == 'index') { |
|
989 | + print 'index '; |
|
990 | +} |
|
991 | +?>clear"> |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $limit_start = 0; |
16 | 16 | $limit_end = 25; |
17 | 17 | $absolute_difference = 25; |
18 | - } else { |
|
18 | + } else { |
|
19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
20 | 20 | $limit_start = $limit_explode[0]; |
21 | 21 | $limit_end = $limit_explode[1]; |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | $METAR = new METAR(); |
48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
49 | 49 | //print_r($metar_info); |
50 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
50 | + if (isset($metar_info[0]['metar'])) { |
|
51 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
52 | + } |
|
51 | 53 | //print_r($metar_parse); |
52 | 54 | } |
53 | 55 | |
@@ -61,7 +63,9 @@ discard block |
||
61 | 63 | print '<option></option>'; |
62 | 64 | $Stats = new Stats(); |
63 | 65 | $airport_names = $Stats->getAllAirportNames(); |
64 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
66 | + if (empty($airport_names)) { |
|
67 | + $airport_names = $Spotter->getAllAirportNames(); |
|
68 | + } |
|
65 | 69 | ksort($airport_names); |
66 | 70 | foreach($airport_names as $airport_name) |
67 | 71 | { |
@@ -95,7 +99,9 @@ discard block |
||
95 | 99 | print '</div>'; |
96 | 100 | print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>'; |
97 | 101 | print '<div><span class="label">'._("Live Air Traffic").'</span><a href="http://www.liveatc.net/search/?icao='.$airport_array[0]['icao'].'" target="_blank">LiveATC.net<i class="fa fa-angle-double-right"></i></a></div>'; |
98 | - if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
102 | + if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') { |
|
103 | + print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
104 | + } |
|
99 | 105 | print '</div>'; |
100 | 106 | |
101 | 107 | $Stats = new Stats(); |
@@ -103,7 +109,9 @@ discard block |
||
103 | 109 | // Use spotter also |
104 | 110 | if (isset($globalTimezone)) { |
105 | 111 | date_default_timezone_set($globalTimezone); |
106 | - } else date_default_timezone_set('UTC'); |
|
112 | + } else { |
|
113 | + date_default_timezone_set('UTC'); |
|
114 | + } |
|
107 | 115 | if (count($all_data) > 0) { |
108 | 116 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
109 | 117 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |