@@ -7,14 +7,14 @@ |
||
7 | 7 | */ |
8 | 8 | class Predict_QTH |
9 | 9 | { |
10 | - public $name; /*!< Name, eg. callsign. */ |
|
11 | - public $loc; /*!< Location, eg City, Country. */ |
|
12 | - public $desc; /*!< Short description. */ |
|
13 | - public $lat; /*!< Latitude in dec. deg. North. */ |
|
14 | - public $lon; /*!< Longitude in dec. deg. East. */ |
|
15 | - public $alt; /*!< Altitude above sea level in meters. */ |
|
16 | - public $qra; /*!< QRA locator */ |
|
17 | - public $wx; /*!< Weather station code (4 chars). */ |
|
10 | + public $name; /*!< Name, eg. callsign. */ |
|
11 | + public $loc; /*!< Location, eg City, Country. */ |
|
12 | + public $desc; /*!< Short description. */ |
|
13 | + public $lat; /*!< Latitude in dec. deg. North. */ |
|
14 | + public $lon; /*!< Longitude in dec. deg. East. */ |
|
15 | + public $alt; /*!< Altitude above sea level in meters. */ |
|
16 | + public $qra; /*!< QRA locator */ |
|
17 | + public $wx; /*!< Weather station code (4 chars). */ |
|
18 | 18 | |
19 | - public $data; /*!< Raw data from cfg file. */ |
|
19 | + public $data; /*!< Raw data from cfg file. */ |
|
20 | 20 | } |
@@ -7,14 +7,14 @@ |
||
7 | 7 | */ |
8 | 8 | class Predict_QTH |
9 | 9 | { |
10 | - public $name; /*!< Name, eg. callsign. */ |
|
11 | - public $loc; /*!< Location, eg City, Country. */ |
|
12 | - public $desc; /*!< Short description. */ |
|
13 | - public $lat; /*!< Latitude in dec. deg. North. */ |
|
14 | - public $lon; /*!< Longitude in dec. deg. East. */ |
|
15 | - public $alt; /*!< Altitude above sea level in meters. */ |
|
16 | - public $qra; /*!< QRA locator */ |
|
17 | - public $wx; /*!< Weather station code (4 chars). */ |
|
10 | + public $name; /*!< Name, eg. callsign. */ |
|
11 | + public $loc; /*!< Location, eg City, Country. */ |
|
12 | + public $desc; /*!< Short description. */ |
|
13 | + public $lat; /*!< Latitude in dec. deg. North. */ |
|
14 | + public $lon; /*!< Longitude in dec. deg. East. */ |
|
15 | + public $alt; /*!< Altitude above sea level in meters. */ |
|
16 | + public $qra; /*!< QRA locator */ |
|
17 | + public $wx; /*!< Weather station code (4 chars). */ |
|
18 | 18 | |
19 | - public $data; /*!< Raw data from cfg file. */ |
|
19 | + public $data; /*!< Raw data from cfg file. */ |
|
20 | 20 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | */ |
7 | 7 | class Predict_Vector |
8 | 8 | { |
9 | - public $x = 0; |
|
10 | - public $y = 0; |
|
11 | - public $z = 0; |
|
12 | - public $w = 0; |
|
9 | + public $x = 0; |
|
10 | + public $y = 0; |
|
11 | + public $z = 0; |
|
12 | + public $w = 0; |
|
13 | 13 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | try { |
20 | 20 | $sth = $this->db->prepare($query); |
21 | 21 | $sth->execute(array(':name' => $name)); |
22 | - } catch(PDOException $e) { |
|
22 | + } catch (PDOException $e) { |
|
23 | 23 | echo $e->getMessage(); |
24 | 24 | } |
25 | 25 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | try { |
32 | 32 | $sth = $this->db->prepare($query); |
33 | 33 | $sth->execute(); |
34 | - } catch(PDOException $e) { |
|
34 | + } catch (PDOException $e) { |
|
35 | 35 | echo $e->getMessage(); |
36 | 36 | } |
37 | 37 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | try { |
44 | 44 | $sth = $this->db->prepare($query); |
45 | 45 | $sth->execute(); |
46 | - } catch(PDOException $e) { |
|
46 | + } catch (PDOException $e) { |
|
47 | 47 | echo $e->getMessage(); |
48 | 48 | } |
49 | 49 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | try { |
56 | 56 | $sth = $this->db->prepare($query); |
57 | 57 | $sth->execute(array(':type' => $type)); |
58 | - } catch(PDOException $e) { |
|
58 | + } catch (PDOException $e) { |
|
59 | 59 | echo $e->getMessage(); |
60 | 60 | } |
61 | 61 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -63,27 +63,27 @@ discard block |
||
63 | 63 | else return array(); |
64 | 64 | } |
65 | 65 | |
66 | - public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) { |
|
66 | + public function position_all($timestamp_begin = '', $timestamp_end = '', $second = 10) { |
|
67 | 67 | $all_sat = $this->get_tle_names(); |
68 | 68 | $result = array(); |
69 | 69 | foreach ($all_sat as $sat) { |
70 | - $position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second); |
|
71 | - $result = array_merge($position,$result); |
|
70 | + $position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second); |
|
71 | + $result = array_merge($position, $result); |
|
72 | 72 | } |
73 | 73 | return $result; |
74 | 74 | } |
75 | 75 | |
76 | - public function position_all_type($type,$timestamp_begin = '',$timestamp_end = '',$second = 10) { |
|
76 | + public function position_all_type($type, $timestamp_begin = '', $timestamp_end = '', $second = 10) { |
|
77 | 77 | $all_sat = $this->get_tle_names_type($type); |
78 | 78 | $result = array(); |
79 | 79 | foreach ($all_sat as $sat) { |
80 | - $position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second); |
|
81 | - $result = array_merge($position,$result); |
|
80 | + $position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second); |
|
81 | + $result = array_merge($position, $result); |
|
82 | 82 | } |
83 | 83 | return $result; |
84 | 84 | } |
85 | 85 | |
86 | - public function position($name,$timestamp_begin = '',$timestamp_end = '',$second = 10) { |
|
86 | + public function position($name, $timestamp_begin = '', $timestamp_end = '', $second = 10) { |
|
87 | 87 | $qth = new Predict_QTH(); |
88 | 88 | $qth->lat = 37.790252; |
89 | 89 | $qth->lon = -122.419968; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $tle_file = $this->get_tle($name); |
92 | 92 | //print_r($tle_file); |
93 | 93 | $type = $tle_file['tle_type']; |
94 | - $tle = new Predict_TLE($tle_file['tle_name'],$tle_file['tle_tle1'],$tle_file['tle_tle2']); |
|
94 | + $tle = new Predict_TLE($tle_file['tle_name'], $tle_file['tle_tle1'], $tle_file['tle_tle2']); |
|
95 | 95 | $sat = new Predict_Sat($tle); |
96 | 96 | $predict = new Predict(); |
97 | 97 | //if ($timestamp == '') $now = Predict_Time::get_current_daynum(); |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | if ($timestamp_end == '') { |
100 | 100 | $now = Predict_Time::unix2daynum($timestamp_begin); |
101 | 101 | //echo $now; |
102 | - $predict->predict_calc($sat,$qth,$now); |
|
103 | - return array('name' => $name, 'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp_begin,'type' => $type); |
|
102 | + $predict->predict_calc($sat, $qth, $now); |
|
103 | + return array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp_begin, 'type' => $type); |
|
104 | 104 | } else { |
105 | - for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp=$timestamp+$second) { |
|
105 | + for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp = $timestamp + $second) { |
|
106 | 106 | //echo $timestamp."\n"; |
107 | 107 | $now = Predict_Time::unix2daynum($timestamp); |
108 | 108 | //echo $now; |
109 | - $predict->predict_calc($sat,$qth,$now); |
|
110 | - $result[] = array('name' => $name,'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp,'type' => $type); |
|
109 | + $predict->predict_calc($sat, $qth, $now); |
|
110 | + $result[] = array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp, 'type' => $type); |
|
111 | 111 | } |
112 | 112 | return $result; |
113 | 113 | } |
@@ -23,8 +23,11 @@ discard block |
||
23 | 23 | echo $e->getMessage(); |
24 | 24 | } |
25 | 25 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
26 | - if (isset($result[0])) return $result[0]; |
|
27 | - else return array(); |
|
26 | + if (isset($result[0])) { |
|
27 | + return $result[0]; |
|
28 | + } else { |
|
29 | + return array(); |
|
30 | + } |
|
28 | 31 | } |
29 | 32 | public function get_tle_types() { |
30 | 33 | $query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type'; |
@@ -35,8 +38,11 @@ discard block |
||
35 | 38 | echo $e->getMessage(); |
36 | 39 | } |
37 | 40 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
38 | - if (isset($result[0])) return $result; |
|
39 | - else return array(); |
|
41 | + if (isset($result[0])) { |
|
42 | + return $result; |
|
43 | + } else { |
|
44 | + return array(); |
|
45 | + } |
|
40 | 46 | } |
41 | 47 | public function get_tle_names() { |
42 | 48 | $query = 'SELECT DISTINCT tle_name, tle_type FROM tle'; |
@@ -47,8 +53,11 @@ discard block |
||
47 | 53 | echo $e->getMessage(); |
48 | 54 | } |
49 | 55 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
50 | - if (isset($result[0])) return $result; |
|
51 | - else return array(); |
|
56 | + if (isset($result[0])) { |
|
57 | + return $result; |
|
58 | + } else { |
|
59 | + return array(); |
|
60 | + } |
|
52 | 61 | } |
53 | 62 | public function get_tle_names_type($type) { |
54 | 63 | $query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name'; |
@@ -59,8 +68,11 @@ discard block |
||
59 | 68 | echo $e->getMessage(); |
60 | 69 | } |
61 | 70 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
62 | - if (isset($result[0])) return $result; |
|
63 | - else return array(); |
|
71 | + if (isset($result[0])) { |
|
72 | + return $result; |
|
73 | + } else { |
|
74 | + return array(); |
|
75 | + } |
|
64 | 76 | } |
65 | 77 | |
66 | 78 | public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) { |
@@ -95,7 +107,9 @@ discard block |
||
95 | 107 | $sat = new Predict_Sat($tle); |
96 | 108 | $predict = new Predict(); |
97 | 109 | //if ($timestamp == '') $now = Predict_Time::get_current_daynum(); |
98 | - if ($timestamp_begin == '') $timestamp_begin = time(); |
|
110 | + if ($timestamp_begin == '') { |
|
111 | + $timestamp_begin = time(); |
|
112 | + } |
|
99 | 113 | if ($timestamp_end == '') { |
100 | 114 | $now = Predict_Time::unix2daynum($timestamp_begin); |
101 | 115 | //echo $now; |
@@ -1,48 +1,48 @@ |
||
1 | 1 | #!/usr/bin/php |
2 | 2 | <?php |
3 | - require_once('../require/settings.php'); |
|
4 | - if ($globalInstalled) { |
|
5 | - echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
6 | - exit; |
|
7 | - } |
|
8 | - require('class.update_db.php'); |
|
9 | - echo "Populate all tables...\n"; |
|
10 | - update_db::update_all(); |
|
11 | - echo "\nInstall waypoints...(VERY slow!)"; |
|
12 | - update_db::update_waypoints(); |
|
13 | - echo "Done !\n"; |
|
14 | - echo "Install airspace..."; |
|
15 | - update_db::update_airspace(); |
|
16 | - echo "Done !\n"; |
|
17 | - echo "Install countries..."; |
|
18 | - update_db::update_countries(); |
|
19 | - echo "Done !\n"; |
|
20 | - if (isset($globalOwner) && $globalOwner) { |
|
3 | + require_once('../require/settings.php'); |
|
4 | + if ($globalInstalled) { |
|
5 | + echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
6 | + exit; |
|
7 | + } |
|
8 | + require('class.update_db.php'); |
|
9 | + echo "Populate all tables...\n"; |
|
10 | + update_db::update_all(); |
|
11 | + echo "\nInstall waypoints...(VERY slow!)"; |
|
12 | + update_db::update_waypoints(); |
|
13 | + echo "Done !\n"; |
|
14 | + echo "Install airspace..."; |
|
15 | + update_db::update_airspace(); |
|
16 | + echo "Done !\n"; |
|
17 | + echo "Install countries..."; |
|
18 | + update_db::update_countries(); |
|
19 | + echo "Done !\n"; |
|
20 | + if (isset($globalOwner) && $globalOwner) { |
|
21 | 21 | echo "Install private owners..."; |
22 | 22 | update_db::update_owner(); |
23 | - echo "Done !\n"; |
|
24 | - } |
|
25 | - /* |
|
23 | + echo "Done !\n"; |
|
24 | + } |
|
25 | + /* |
|
26 | 26 | if (isset($globalIVAO) && $globalIVAO) { |
27 | 27 | echo "Install IVAO airlines and logos..."; |
28 | 28 | update_db::update_IVAO(); |
29 | 29 | echo "Done !\n"; |
30 | 30 | } |
31 | 31 | */ |
32 | - if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
|
32 | + if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
|
33 | 33 | echo "Install NOTAM from notaminfo.com..."; |
34 | - update_db:update_notam(); |
|
35 | - echo "Done !\n"; |
|
36 | - } |
|
37 | - if (isset($globalMap3D) && $globalMap3D) { |
|
34 | + update_db:update_notam(); |
|
35 | + echo "Done !\n"; |
|
36 | + } |
|
37 | + if (isset($globalMap3D) && $globalMap3D) { |
|
38 | 38 | echo "Install 3D models..."; |
39 | 39 | update_db::update_models(); |
40 | 40 | echo "Done !\n"; |
41 | 41 | if (isset($globalMapSatellites) && $globalMapSatellites) { |
42 | - echo "Install Space 3D models..."; |
|
43 | - update_db::update_space_models(); |
|
44 | - echo "Done !\n"; |
|
45 | - } |
|
46 | - } |
|
42 | + echo "Install Space 3D models..."; |
|
43 | + update_db::update_space_models(); |
|
44 | + echo "Done !\n"; |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | 48 | ?> |
49 | 49 | \ No newline at end of file |
@@ -5,8 +5,11 @@ discard block |
||
5 | 5 | $file_path = pathinfo($_SERVER['SCRIPT_NAME']); |
6 | 6 | $current_page = $file_path['filename']; |
7 | 7 | date_default_timezone_set($globalTimezone); |
8 | -if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType']; |
|
9 | -else $MapType = $globalMapProvider; |
|
8 | +if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') { |
|
9 | + $MapType = $_COOKIE['MapType']; |
|
10 | +} else { |
|
11 | + $MapType = $globalMapProvider; |
|
12 | +} |
|
10 | 13 | ?> |
11 | 14 | <!DOCTYPE html> |
12 | 15 | <html> |
@@ -181,7 +184,13 @@ discard block |
||
181 | 184 | <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script> |
182 | 185 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
183 | 186 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
184 | -<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
187 | +<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) { |
|
188 | + print '&latitude='.$latitude; |
|
189 | +} |
|
190 | +?><?php if(isset($longitude)) { |
|
191 | + print '&longitude='.$longitude; |
|
192 | +} |
|
193 | +?>&<?php print time(); ?>"></script> |
|
185 | 194 | <?php |
186 | 195 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
187 | 196 | ?> |
@@ -235,7 +244,13 @@ discard block |
||
235 | 244 | <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script> |
236 | 245 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
237 | 246 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
238 | -<script src="<?php print $globalURL; ?>/js/map.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> |
|
247 | +<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) { |
|
248 | + print '&latitude='.$latitude; |
|
249 | +} |
|
250 | +?><?php if(isset($longitude)) { |
|
251 | + print '&longitude='.$longitude; |
|
252 | +} |
|
253 | +?>&<?php print time(); ?>"></script> |
|
239 | 254 | <?php |
240 | 255 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
241 | 256 | ?> |
@@ -308,7 +323,12 @@ discard block |
||
308 | 323 | <span class="icon-bar"></span> |
309 | 324 | </button> |
310 | 325 | <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a> |
311 | - <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a> |
|
326 | + <a class="navbar-brand" href="<?php if ($globalURL == '') { |
|
327 | + print '/'; |
|
328 | +} else { |
|
329 | + print $globalURL; |
|
330 | +} |
|
331 | +?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a> |
|
312 | 332 | </div> |
313 | 333 | <div class="collapse navbar-collapse"> |
314 | 334 | <ul class="nav navbar-nav"> |
@@ -386,7 +406,9 @@ discard block |
||
386 | 406 | $alllang = $Language->getLanguages(); |
387 | 407 | foreach ($alllang as $key => $lang) { |
388 | 408 | print '<option value="'.$key.'"'; |
389 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
409 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) { |
|
410 | + print ' selected '; |
|
411 | + } |
|
390 | 412 | print '>'.$lang[0].'</option>'; |
391 | 413 | } |
392 | 414 | ?> |
@@ -533,4 +555,7 @@ discard block |
||
533 | 555 | |
534 | 556 | ?> |
535 | 557 | |
536 | -<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear"> |
|
558 | +<section class="container main-content <?php if (strtolower($current_page) == 'index') { |
|
559 | + print 'index '; |
|
560 | +} |
|
561 | +?>clear"> |
@@ -8,31 +8,31 @@ discard block |
||
8 | 8 | if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType']; |
9 | 9 | else $MapType = $globalMapProvider; |
10 | 10 | if (isset($_GET['3d'])) { |
11 | - setcookie('MapFormat','3d'); |
|
11 | + setcookie('MapFormat', '3d'); |
|
12 | 12 | } else if (isset($_GET['2d'])) { |
13 | - setcookie('MapFormat','2d'); |
|
13 | + setcookie('MapFormat', '2d'); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | if (isset($_POST['archive'])) { |
17 | - setcookie('archive','true'); |
|
18 | - setcookie('archive_begin',strtotime($_POST['start_date'])); |
|
19 | - setcookie('archive_end',strtotime($_POST['end_date'])); |
|
20 | - setcookie('archive_speed',$_POST['archivespeed']); |
|
17 | + setcookie('archive', 'true'); |
|
18 | + setcookie('archive_begin', strtotime($_POST['start_date'])); |
|
19 | + setcookie('archive_end', strtotime($_POST['end_date'])); |
|
20 | + setcookie('archive_speed', $_POST['archivespeed']); |
|
21 | 21 | } |
22 | 22 | if (isset($_POST['noarchive'])) { |
23 | - setcookie('archive','false',-1); |
|
24 | - setcookie('archive_begin','',-1); |
|
25 | - setcookie('archive_end','',-1); |
|
26 | - setcookie('archive_speed','',-1); |
|
23 | + setcookie('archive', 'false', -1); |
|
24 | + setcookie('archive_begin', '', -1); |
|
25 | + setcookie('archive_end', '', -1); |
|
26 | + setcookie('archive_speed', '', -1); |
|
27 | 27 | } |
28 | 28 | // When button "Remove all filters" is clicked |
29 | 29 | if (isset($_POST['removefilters'])) { |
30 | - $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
|
31 | - return strpos($key,'filter_') === 0; |
|
30 | + $allfilters = array_filter(array_keys($_COOKIE), function($key) { |
|
31 | + return strpos($key, 'filter_') === 0; |
|
32 | 32 | }); |
33 | 33 | foreach ($allfilters as $filt) { |
34 | 34 | unset($_COOKIE[$filt]); |
35 | - setcookie($filt,null,-1); |
|
35 | + setcookie($filt, null, -1); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script> |
217 | 217 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
218 | 218 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
219 | -<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
219 | +<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
220 | 220 | <?php |
221 | 221 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
222 | 222 | ?> |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script> |
271 | 271 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
272 | 272 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
273 | -<script src="<?php print $globalURL; ?>/js/map.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> |
|
273 | +<script src="<?php print $globalURL; ?>/js/map.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> |
|
274 | 274 | <?php |
275 | 275 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
276 | 276 | ?> |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ?> |
434 | 434 | <div class="search"> |
435 | 435 | <form action="<?php print $globalURL; ?>/search" method="get"> |
436 | - <input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button> |
|
436 | + <input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button> |
|
437 | 437 | </form> |
438 | 438 | </div> |
439 | 439 | <div class="social"> |
@@ -451,14 +451,14 @@ discard block |
||
451 | 451 | print '</div>'; |
452 | 452 | } |
453 | 453 | |
454 | -if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') { |
|
454 | +if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') { |
|
455 | 455 | ?> |
456 | 456 | <div class="top-header clear" role="main"> |
457 | 457 | <div id="archive-map"></div> |
458 | 458 | </div> |
459 | 459 | <?php |
460 | 460 | } |
461 | -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)) |
|
461 | +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)) |
|
462 | 462 | { |
463 | 463 | ?> |
464 | 464 | <div class="top-header clear" role="main"> |
@@ -471,15 +471,15 @@ discard block |
||
471 | 471 | var zoom = 13; |
472 | 472 | //create the map |
473 | 473 | <?php |
474 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
474 | + if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
475 | 475 | ?> |
476 | 476 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
477 | 477 | <?php |
478 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
478 | + } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) { |
|
479 | 479 | ?> |
480 | 480 | map = L.map('map', { zoomControl:true }); |
481 | 481 | <?php |
482 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
482 | + } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
483 | 483 | ?> |
484 | 484 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
485 | 485 | 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); |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | 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); |
488 | 488 | 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); |
489 | 489 | <?php |
490 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
490 | + } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
491 | 491 | ?> |
492 | 492 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
493 | 493 | <?php |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // When button "Remove all filters" is clicked |
29 | 29 | if (isset($_POST['removefilters'])) { |
30 | 30 | $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
31 | - return strpos($key,'filter_') === 0; |
|
31 | + return strpos($key,'filter_') === 0; |
|
32 | 32 | }); |
33 | 33 | foreach ($allfilters as $filt) { |
34 | 34 | unset($_COOKIE[$filt]); |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | } |
168 | 168 | ?> |
169 | 169 | <?php |
170 | - if (isset($_POST['archive'])) { |
|
170 | + if (isset($_POST['archive'])) { |
|
171 | 171 | ?> |
172 | 172 | <?php |
173 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
173 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
174 | 174 | ?> |
175 | 175 | |
176 | 176 | <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> |
177 | 177 | <?php |
178 | - } |
|
179 | - } else { |
|
178 | + } |
|
179 | + } else { |
|
180 | 180 | ?> |
181 | 181 | <?php |
182 | 182 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | */ |
189 | 189 | ?> |
190 | 190 | <?php |
191 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
191 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
192 | 192 | ?> |
193 | 193 | <script src="<?php print $globalURL; ?>/js/leaflet-playback.js"></script> |
194 | 194 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script> |
195 | 195 | <?php |
196 | - } |
|
196 | + } |
|
197 | 197 | ?> |
198 | 198 | <?php |
199 | 199 | // } |
200 | 200 | ?> |
201 | 201 | <?php |
202 | - } |
|
202 | + } |
|
203 | 203 | } |
204 | 204 | ?> |
205 | 205 | <?php |
@@ -359,23 +359,23 @@ discard block |
||
359 | 359 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
360 | 360 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
361 | 361 | <?php |
362 | - if ($globalACARS) { |
|
363 | - if (isset($globalDemo) && $globalDemo) { |
|
364 | - ?> |
|
362 | + if ($globalACARS) { |
|
363 | + if (isset($globalDemo) && $globalDemo) { |
|
364 | + ?> |
|
365 | 365 | <li><hr /></li> |
366 | 366 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
367 | 367 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
368 | 368 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
369 | 369 | <?php |
370 | - } else { |
|
371 | - ?> |
|
370 | + } else { |
|
371 | + ?> |
|
372 | 372 | <li><hr /></li> |
373 | 373 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
374 | 374 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
375 | 375 | <?php |
376 | - } |
|
377 | - } |
|
378 | - ?> |
|
376 | + } |
|
377 | + } |
|
378 | + ?> |
|
379 | 379 | <li><hr /></li> |
380 | 380 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
381 | 381 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
@@ -417,14 +417,14 @@ discard block |
||
417 | 417 | <form> |
418 | 418 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
419 | 419 | <?php |
420 | - $Language = new Language(); |
|
421 | - $alllang = $Language->getLanguages(); |
|
422 | - foreach ($alllang as $key => $lang) { |
|
423 | - print '<option value="'.$key.'"'; |
|
424 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
425 | - print '>'.$lang[0].'</option>'; |
|
426 | - } |
|
427 | - ?> |
|
420 | + $Language = new Language(); |
|
421 | + $alllang = $Language->getLanguages(); |
|
422 | + foreach ($alllang as $key => $lang) { |
|
423 | + print '<option value="'.$key.'"'; |
|
424 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
425 | + print '>'.$lang[0].'</option>'; |
|
426 | + } |
|
427 | + ?> |
|
428 | 428 | </select> |
429 | 429 | </form> |
430 | 430 | </div> |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | ?> |
456 | 456 | <div class="top-header clear" role="main"> |
457 | 457 | <?php |
458 | - if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
458 | + if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
459 | 459 | ?> |
460 | 460 | <div id="archive-map"></div> |
461 | 461 | <?php |
462 | - } |
|
462 | + } |
|
463 | 463 | ?> |
464 | 464 | </div> |
465 | 465 | <?php |
466 | 466 | } |
467 | 467 | 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)) |
468 | 468 | { |
469 | - ?> |
|
469 | + ?> |
|
470 | 470 | <div class="top-header clear" role="main"> |
471 | 471 | <div id="map"></div> |
472 | 472 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -477,15 +477,15 @@ discard block |
||
477 | 477 | var zoom = 13; |
478 | 478 | //create the map |
479 | 479 | <?php |
480 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
480 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
481 | 481 | ?> |
482 | 482 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
483 | 483 | <?php |
484 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
484 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
485 | 485 | ?> |
486 | 486 | map = L.map('map', { zoomControl:true }); |
487 | 487 | <?php |
488 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
488 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
489 | 489 | ?> |
490 | 490 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
491 | 491 | 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); |
@@ -493,22 +493,22 @@ discard block |
||
493 | 493 | 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); |
494 | 494 | 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); |
495 | 495 | <?php |
496 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
496 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
497 | 497 | ?> |
498 | 498 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
499 | 499 | <?php |
500 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
500 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
501 | 501 | ?> |
502 | 502 | map = L.map('map', { zoomControl:true }); |
503 | 503 | <?php |
504 | - } |
|
504 | + } |
|
505 | 505 | ?> |
506 | 506 | //initialize the layer group for the aircrft markers |
507 | 507 | var layer_data = L.layerGroup(); |
508 | 508 | |
509 | 509 | //a few title layers |
510 | 510 | <?php |
511 | - if ($globalMapProvider == 'Mapbox') { |
|
511 | + if ($globalMapProvider == 'Mapbox') { |
|
512 | 512 | ?> |
513 | 513 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
514 | 514 | maxZoom: 18, |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | token : '<?php print $globalMapboxToken; ?>' |
520 | 520 | }).addTo(map); |
521 | 521 | <?php |
522 | - } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
522 | + } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
523 | 523 | ?> |
524 | 524 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
525 | 525 | maxZoom: 18, |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>' |
528 | 528 | }).addTo(map); |
529 | 529 | <?php |
530 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
530 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
531 | 531 | ?> |
532 | 532 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
533 | 533 | maxZoom: 18, |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
537 | 537 | }).addTo(map); |
538 | 538 | <?php |
539 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
539 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
540 | 540 | ?> |
541 | 541 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
542 | 542 | maxZoom: 18, |
@@ -545,27 +545,27 @@ discard block |
||
545 | 545 | '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"' |
546 | 546 | }).addTo(map); |
547 | 547 | <?php |
548 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
548 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
549 | 549 | ?> |
550 | 550 | var googleLayer = new L.Google('ROADMAP'); |
551 | 551 | map.addLayer(googleLayer); |
552 | 552 | <?php |
553 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
553 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
554 | 554 | ?> |
555 | 555 | var googleLayer = new L.Google('SATELLITE'); |
556 | 556 | map.addLayer(googleLayer); |
557 | 557 | <?php |
558 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
558 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
559 | 559 | ?> |
560 | 560 | var googleLayer = new L.Google('HYBRID'); |
561 | 561 | map.addLayer(googleLayer); |
562 | 562 | <?php |
563 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
563 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
564 | 564 | ?> |
565 | 565 | var googleLayer = new L.Google('Terrain'); |
566 | 566 | map.addLayer(googleLayer); |
567 | 567 | <?php |
568 | - } |
|
568 | + } |
|
569 | 569 | ?> |
570 | 570 | </script> |
571 | 571 | </div> |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | |
21 | 21 | $spotter_array = array(); |
22 | 22 | if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') { |
23 | - $sattypes = explode(',',$_COOKIE['sattypes']); |
|
23 | + $sattypes = explode(',', $_COOKIE['sattypes']); |
|
24 | 24 | foreach ($sattypes as $sattype) { |
25 | - $spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array); |
|
25 | + $spotter_array = array_merge($Satellite->position_all_type($sattype, $timeb - $globalLiveInterval, $timeb), $spotter_array); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss']) { |
29 | - $spotter_array = array_merge($Satellite->position('ISS (ZARYA)',time()-$globalLiveInterval,time()),$spotter_array); |
|
30 | - $spotter_array = array_merge($Satellite->position('TIANGONG 1',time()-$globalLiveInterval,time()),$spotter_array); |
|
31 | - $spotter_array = array_merge($Satellite->position('TIANGONG-2',time()-$globalLiveInterval,time()),$spotter_array); |
|
29 | + $spotter_array = array_merge($Satellite->position('ISS (ZARYA)', time() - $globalLiveInterval, time()), $spotter_array); |
|
30 | + $spotter_array = array_merge($Satellite->position('TIANGONG 1', time() - $globalLiveInterval, time()), $spotter_array); |
|
31 | + $spotter_array = array_merge($Satellite->position('TIANGONG-2', time() - $globalLiveInterval, time()), $spotter_array); |
|
32 | 32 | } |
33 | -$spotter_array = array_unique($spotter_array,SORT_REGULAR); |
|
33 | +$spotter_array = array_unique($spotter_array, SORT_REGULAR); |
|
34 | 34 | /* |
35 | 35 | $modelsdb = array(); |
36 | 36 | if (file_exists('models/space/space_modelsdb')) { |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
55 | 55 | |
56 | 56 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
57 | -$output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
57 | +$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
58 | 58 | //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
59 | 59 | |
60 | 60 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
61 | 61 | $output .= '},'; |
62 | 62 | if (!empty($spotter_array) && is_array($spotter_array)) |
63 | 63 | { |
64 | - foreach($spotter_array as $spotter_item) |
|
64 | + foreach ($spotter_array as $spotter_item) |
|
65 | 65 | { |
66 | 66 | $j++; |
67 | 67 | date_default_timezone_set('UTC'); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $orientation = ''; |
77 | 77 | $prev_satname = $spotter_item['name']; |
78 | 78 | $output .= '{'; |
79 | - $output .= '"id": "'.trim(str_replace(array('[+]','[-]'),'',$spotter_item['name'])).'",'; |
|
79 | + $output .= '"id": "'.trim(str_replace(array('[+]', '[-]'), '', $spotter_item['name'])).'",'; |
|
80 | 80 | $output .= '"properties": {'; |
81 | 81 | // Not yet supported in CZML with Cesium |
82 | 82 | $output .= '},'; |
@@ -114,23 +114,23 @@ discard block |
||
114 | 114 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubiesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
115 | 115 | } elseif ($spotter_item['name'] == 'TERRA') { |
116 | 116 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/terra.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
117 | - } elseif (strpos($spotter_item['name'],'O3B') !== false) { |
|
117 | + } elseif (strpos($spotter_item['name'], 'O3B') !== false) { |
|
118 | 118 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/o3b.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
119 | - } elseif (strpos($spotter_item['name'],'GLOBALSTAR') !== false) { |
|
119 | + } elseif (strpos($spotter_item['name'], 'GLOBALSTAR') !== false) { |
|
120 | 120 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/globalstar.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
121 | - } elseif (strpos($spotter_item['name'],'GPS') !== false) { |
|
121 | + } elseif (strpos($spotter_item['name'], 'GPS') !== false) { |
|
122 | 122 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/gps.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
123 | - } elseif (strpos($spotter_item['name'],'GENESIS') !== false) { |
|
123 | + } elseif (strpos($spotter_item['name'], 'GENESIS') !== false) { |
|
124 | 124 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/genesis.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
125 | - } elseif (strpos($spotter_item['name'],'OSCAR 7') !== false) { |
|
125 | + } elseif (strpos($spotter_item['name'], 'OSCAR 7') !== false) { |
|
126 | 126 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/oscar7.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
127 | - } elseif (strpos($spotter_item['name'],'FLOCK') !== false) { |
|
127 | + } elseif (strpos($spotter_item['name'], 'FLOCK') !== false) { |
|
128 | 128 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
129 | - } elseif (strpos($spotter_item['name'],'PLEIADES') !== false) { |
|
129 | + } elseif (strpos($spotter_item['name'], 'PLEIADES') !== false) { |
|
130 | 130 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/pleiades.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
131 | - } elseif (strpos($spotter_item['name'],'DUCHIFAT') !== false) { |
|
131 | + } elseif (strpos($spotter_item['name'], 'DUCHIFAT') !== false) { |
|
132 | 132 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/duchifat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
133 | - } elseif (strpos($spotter_item['name'],'FORMOSAT-2') !== false) { |
|
133 | + } elseif (strpos($spotter_item['name'], 'FORMOSAT-2') !== false) { |
|
134 | 134 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/formosat2.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
135 | 135 | } elseif ($spotter_item['type'] == 'iridium') { |
136 | 136 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/iridium.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | // $output .= '"interpolationDegree" : 5,'; |
152 | 152 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
153 | 153 | $output .= '"cartographicDegrees": ['; |
154 | - $output .= '"'.date("c",$spotter_item['timestamp']).'", '; |
|
154 | + $output .= '"'.date("c", $spotter_item['timestamp']).'", '; |
|
155 | 155 | $output .= $spotter_item['longitude'].', '; |
156 | 156 | $output .= $spotter_item['latitude'].', '; |
157 | 157 | $output .= $spotter_item['altitude']*1000; |
158 | 158 | $orientation = '"orientation" : { '; |
159 | 159 | $orientation .= '"unitQuaternion": ['; |
160 | 160 | } else { |
161 | - $output .= ',"'.date("c",$spotter_item['timestamp']).'", '; |
|
161 | + $output .= ',"'.date("c", $spotter_item['timestamp']).'", '; |
|
162 | 162 | $output .= $spotter_item['longitude'].', '; |
163 | 163 | $output .= $spotter_item['latitude'].', '; |
164 | 164 | $output .= $spotter_item['altitude']*1000; |
@@ -13,6 +13,10 @@ discard block |
||
13 | 13 | $this->db = $Connection->db(); |
14 | 14 | } |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $type |
|
18 | + * @param string $stats_date |
|
19 | + */ |
|
16 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
17 | 21 | $query = "DELETE FROM config WHERE name = :type; |
18 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
@@ -578,6 +582,11 @@ discard block |
||
578 | 582 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
579 | 583 | return $all; |
580 | 584 | } |
585 | + |
|
586 | + /** |
|
587 | + * @param string $type |
|
588 | + * @param string $year |
|
589 | + */ |
|
581 | 590 | public function getSumStats($type,$year,$stats_airline = '') { |
582 | 591 | global $globalArchiveMonths, $globalDBdriver; |
583 | 592 | if ($globalDBdriver == 'mysql') { |
@@ -677,6 +686,10 @@ discard block |
||
677 | 686 | return $all[0]['total']; |
678 | 687 | } |
679 | 688 | |
689 | + /** |
|
690 | + * @param string $type |
|
691 | + * @param string $stats_date |
|
692 | + */ |
|
680 | 693 | public function addStat($type,$cnt,$stats_date,$stats_airline = '') { |
681 | 694 | global $globalDBdriver; |
682 | 695 | if ($globalDBdriver == 'mysql') { |
@@ -708,6 +721,10 @@ discard block |
||
708 | 721 | return "error : ".$e->getMessage(); |
709 | 722 | } |
710 | 723 | } |
724 | + |
|
725 | + /** |
|
726 | + * @param string $date |
|
727 | + */ |
|
711 | 728 | public function getStatsSource($date,$stats_type = '') { |
712 | 729 | if ($stats_type == '') { |
713 | 730 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -726,6 +743,9 @@ discard block |
||
726 | 743 | return $all; |
727 | 744 | } |
728 | 745 | |
746 | + /** |
|
747 | + * @param string $stats_type |
|
748 | + */ |
|
729 | 749 | public function addStatSource($data,$source_name,$stats_type,$date) { |
730 | 750 | global $globalDBdriver; |
731 | 751 | if ($globalDBdriver == 'mysql') { |
@@ -741,6 +761,10 @@ discard block |
||
741 | 761 | return "error : ".$e->getMessage(); |
742 | 762 | } |
743 | 763 | } |
764 | + |
|
765 | + /** |
|
766 | + * @param string $type |
|
767 | + */ |
|
744 | 768 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '') { |
745 | 769 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline) VALUES (:type,:flight_date,:cnt,:stats_airline)"; |
746 | 770 | $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline); |
@@ -927,6 +951,10 @@ discard block |
||
927 | 951 | return "error : ".$e->getMessage(); |
928 | 952 | } |
929 | 953 | } |
954 | + |
|
955 | + /** |
|
956 | + * @param string $type |
|
957 | + */ |
|
930 | 958 | public function deleteStatFlight($type) { |
931 | 959 | $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
932 | 960 | $query_values = array(':type' => $type); |
@@ -937,6 +965,10 @@ discard block |
||
937 | 965 | return "error : ".$e->getMessage(); |
938 | 966 | } |
939 | 967 | } |
968 | + |
|
969 | + /** |
|
970 | + * @param string $type |
|
971 | + */ |
|
940 | 972 | public function deleteStatAirport($type) { |
941 | 973 | $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
942 | 974 | $query_values = array(':type' => $type); |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | } |
60 | 62 | } |
61 | 63 | public function getAllAirlineNames($filter_name = '') { |
62 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
64 | + if ($filter_name == '') { |
|
65 | + $filter_name = $this->filter_name; |
|
66 | + } |
|
63 | 67 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
64 | 68 | try { |
65 | 69 | $sth = $this->db->prepare($query); |
@@ -71,7 +75,9 @@ discard block |
||
71 | 75 | return $all; |
72 | 76 | } |
73 | 77 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
74 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
78 | + if ($filter_name == '') { |
|
79 | + $filter_name = $this->filter_name; |
|
80 | + } |
|
75 | 81 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
76 | 82 | try { |
77 | 83 | $sth = $this->db->prepare($query); |
@@ -83,7 +89,9 @@ discard block |
||
83 | 89 | return $all; |
84 | 90 | } |
85 | 91 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
86 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
92 | + if ($filter_name == '') { |
|
93 | + $filter_name = $this->filter_name; |
|
94 | + } |
|
87 | 95 | $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"; |
88 | 96 | try { |
89 | 97 | $sth = $this->db->prepare($query); |
@@ -95,7 +103,9 @@ discard block |
||
95 | 103 | return $all; |
96 | 104 | } |
97 | 105 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
98 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
106 | + if ($filter_name == '') { |
|
107 | + $filter_name = $this->filter_name; |
|
108 | + } |
|
99 | 109 | $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"; |
100 | 110 | try { |
101 | 111 | $sth = $this->db->prepare($query); |
@@ -110,9 +120,14 @@ discard block |
||
110 | 120 | |
111 | 121 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
112 | 122 | global $globalStatsFilters; |
113 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
114 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
115 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
123 | + if ($filter_name == '') { |
|
124 | + $filter_name = $this->filter_name; |
|
125 | + } |
|
126 | + if ($limit) { |
|
127 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
128 | + } else { |
|
129 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
130 | + } |
|
116 | 131 | try { |
117 | 132 | $sth = $this->db->prepare($query); |
118 | 133 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -132,9 +147,14 @@ discard block |
||
132 | 147 | } |
133 | 148 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
134 | 149 | global $globalStatsFilters; |
135 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
136 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
137 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
150 | + if ($filter_name == '') { |
|
151 | + $filter_name = $this->filter_name; |
|
152 | + } |
|
153 | + if ($limit) { |
|
154 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
155 | + } else { |
|
156 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
157 | + } |
|
138 | 158 | try { |
139 | 159 | $sth = $this->db->prepare($query); |
140 | 160 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -154,9 +174,14 @@ discard block |
||
154 | 174 | } |
155 | 175 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
156 | 176 | global $globalStatsFilters; |
157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | - 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"; |
|
159 | - 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"; |
|
177 | + if ($filter_name == '') { |
|
178 | + $filter_name = $this->filter_name; |
|
179 | + } |
|
180 | + if ($limit) { |
|
181 | + $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"; |
|
182 | + } else { |
|
183 | + $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"; |
|
184 | + } |
|
160 | 185 | try { |
161 | 186 | $sth = $this->db->prepare($query); |
162 | 187 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -177,9 +202,14 @@ discard block |
||
177 | 202 | |
178 | 203 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
179 | 204 | global $globalStatsFilters; |
180 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
181 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
182 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
205 | + if ($filter_name == '') { |
|
206 | + $filter_name = $this->filter_name; |
|
207 | + } |
|
208 | + if ($limit) { |
|
209 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
210 | + } else { |
|
211 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
212 | + } |
|
183 | 213 | try { |
184 | 214 | $sth = $this->db->prepare($query); |
185 | 215 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -199,9 +229,14 @@ discard block |
||
199 | 229 | } |
200 | 230 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
201 | 231 | global $globalStatsFilters; |
202 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
203 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
204 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
232 | + if ($filter_name == '') { |
|
233 | + $filter_name = $this->filter_name; |
|
234 | + } |
|
235 | + if ($limit) { |
|
236 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
237 | + } else { |
|
238 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
239 | + } |
|
205 | 240 | try { |
206 | 241 | $sth = $this->db->prepare($query); |
207 | 242 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -222,9 +257,14 @@ discard block |
||
222 | 257 | |
223 | 258 | public function countAllAirlines($limit = true,$filter_name = '') { |
224 | 259 | global $globalStatsFilters; |
225 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
226 | - 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
227 | - 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 ORDER BY airline_count DESC"; |
|
260 | + if ($filter_name == '') { |
|
261 | + $filter_name = $this->filter_name; |
|
262 | + } |
|
263 | + if ($limit) { |
|
264 | + $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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
265 | + } else { |
|
266 | + $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 ORDER BY airline_count DESC"; |
|
267 | + } |
|
228 | 268 | try { |
229 | 269 | $sth = $this->db->prepare($query); |
230 | 270 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -245,9 +285,14 @@ discard block |
||
245 | 285 | } |
246 | 286 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
247 | 287 | global $globalStatsFilters; |
248 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
249 | - 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 aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
250 | - 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 aircraft_registration_count DESC"; |
|
288 | + if ($filter_name == '') { |
|
289 | + $filter_name = $this->filter_name; |
|
290 | + } |
|
291 | + if ($limit) { |
|
292 | + $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 aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
293 | + } else { |
|
294 | + $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 aircraft_registration_count DESC"; |
|
295 | + } |
|
251 | 296 | try { |
252 | 297 | $sth = $this->db->prepare($query); |
253 | 298 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -267,9 +312,14 @@ discard block |
||
267 | 312 | } |
268 | 313 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
269 | 314 | global $globalStatsFilters; |
270 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
271 | - 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"; |
|
272 | - 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"; |
|
315 | + if ($filter_name == '') { |
|
316 | + $filter_name = $this->filter_name; |
|
317 | + } |
|
318 | + if ($limit) { |
|
319 | + $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"; |
|
320 | + } else { |
|
321 | + $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"; |
|
322 | + } |
|
273 | 323 | try { |
274 | 324 | $sth = $this->db->prepare($query); |
275 | 325 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -289,10 +339,15 @@ discard block |
||
289 | 339 | } |
290 | 340 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
291 | 341 | $Connection = new Connection(); |
292 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
342 | + if ($filter_name == '') { |
|
343 | + $filter_name = $this->filter_name; |
|
344 | + } |
|
293 | 345 | if ($Connection->tableExists('countries')) { |
294 | - 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"; |
|
295 | - 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"; |
|
346 | + if ($limit) { |
|
347 | + $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"; |
|
348 | + } else { |
|
349 | + $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"; |
|
350 | + } |
|
296 | 351 | try { |
297 | 352 | $sth = $this->db->prepare($query); |
298 | 353 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -313,9 +368,14 @@ discard block |
||
313 | 368 | } |
314 | 369 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
315 | 370 | global $globalStatsFilters; |
316 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
317 | - 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"; |
|
318 | - 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"; |
|
371 | + if ($filter_name == '') { |
|
372 | + $filter_name = $this->filter_name; |
|
373 | + } |
|
374 | + if ($limit) { |
|
375 | + $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"; |
|
376 | + } else { |
|
377 | + $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"; |
|
378 | + } |
|
319 | 379 | try { |
320 | 380 | $sth = $this->db->prepare($query); |
321 | 381 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -335,9 +395,14 @@ discard block |
||
335 | 395 | } |
336 | 396 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
337 | 397 | global $globalStatsFilters; |
338 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
339 | - 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"; |
|
340 | - 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"; |
|
398 | + if ($filter_name == '') { |
|
399 | + $filter_name = $this->filter_name; |
|
400 | + } |
|
401 | + if ($limit) { |
|
402 | + $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"; |
|
403 | + } else { |
|
404 | + $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"; |
|
405 | + } |
|
341 | 406 | try { |
342 | 407 | $sth = $this->db->prepare($query); |
343 | 408 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -357,9 +422,14 @@ discard block |
||
357 | 422 | } |
358 | 423 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
359 | 424 | global $globalStatsFilters; |
360 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
361 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE 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"; |
|
362 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
425 | + if ($filter_name == '') { |
|
426 | + $filter_name = $this->filter_name; |
|
427 | + } |
|
428 | + if ($limit) { |
|
429 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE 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"; |
|
430 | + } else { |
|
431 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
432 | + } |
|
363 | 433 | try { |
364 | 434 | $sth = $this->db->prepare($query); |
365 | 435 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -385,7 +455,9 @@ discard block |
||
385 | 455 | $icao = $value['airport_departure_icao']; |
386 | 456 | if (isset($all[$icao])) { |
387 | 457 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
388 | - } else $all[$icao] = $value; |
|
458 | + } else { |
|
459 | + $all[$icao] = $value; |
|
460 | + } |
|
389 | 461 | } |
390 | 462 | $count = array(); |
391 | 463 | foreach ($all as $key => $row) { |
@@ -397,9 +469,14 @@ discard block |
||
397 | 469 | } |
398 | 470 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
399 | 471 | global $globalStatsFilters; |
400 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
401 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE 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"; |
|
402 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
472 | + if ($filter_name == '') { |
|
473 | + $filter_name = $this->filter_name; |
|
474 | + } |
|
475 | + if ($limit) { |
|
476 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE 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"; |
|
477 | + } else { |
|
478 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
479 | + } |
|
403 | 480 | try { |
404 | 481 | $sth = $this->db->prepare($query); |
405 | 482 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -425,7 +502,9 @@ discard block |
||
425 | 502 | $icao = $value['airport_arrival_icao']; |
426 | 503 | if (isset($all[$icao])) { |
427 | 504 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
428 | - } else $all[$icao] = $value; |
|
505 | + } else { |
|
506 | + $all[$icao] = $value; |
|
507 | + } |
|
429 | 508 | } |
430 | 509 | $count = array(); |
431 | 510 | foreach ($all as $key => $row) { |
@@ -438,13 +517,21 @@ discard block |
||
438 | 517 | } |
439 | 518 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
440 | 519 | global $globalDBdriver, $globalStatsFilters; |
441 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
520 | + if ($filter_name == '') { |
|
521 | + $filter_name = $this->filter_name; |
|
522 | + } |
|
442 | 523 | if ($globalDBdriver == 'mysql') { |
443 | - 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"; |
|
444 | - 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"; |
|
524 | + if ($limit) { |
|
525 | + $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"; |
|
526 | + } else { |
|
527 | + $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"; |
|
528 | + } |
|
445 | 529 | } else { |
446 | - 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"; |
|
447 | - 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"; |
|
530 | + if ($limit) { |
|
531 | + $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"; |
|
532 | + } else { |
|
533 | + $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"; |
|
534 | + } |
|
448 | 535 | } |
449 | 536 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
450 | 537 | try { |
@@ -468,7 +555,9 @@ discard block |
||
468 | 555 | |
469 | 556 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
470 | 557 | global $globalStatsFilters; |
471 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
558 | + if ($filter_name == '') { |
|
559 | + $filter_name = $this->filter_name; |
|
560 | + } |
|
472 | 561 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
473 | 562 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
474 | 563 | try { |
@@ -490,7 +579,9 @@ discard block |
||
490 | 579 | } |
491 | 580 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
492 | 581 | global $globalDBdriver, $globalStatsFilters; |
493 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
582 | + if ($filter_name == '') { |
|
583 | + $filter_name = $this->filter_name; |
|
584 | + } |
|
494 | 585 | if ($globalDBdriver == 'mysql') { |
495 | 586 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
496 | 587 | } else { |
@@ -516,7 +607,9 @@ discard block |
||
516 | 607 | } |
517 | 608 | public function countAllDates($stats_airline = '',$filter_name = '') { |
518 | 609 | global $globalStatsFilters; |
519 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
610 | + if ($filter_name == '') { |
|
611 | + $filter_name = $this->filter_name; |
|
612 | + } |
|
520 | 613 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
521 | 614 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
522 | 615 | try { |
@@ -538,7 +631,9 @@ discard block |
||
538 | 631 | } |
539 | 632 | public function countAllDatesByAirlines($filter_name = '') { |
540 | 633 | global $globalStatsFilters; |
541 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
634 | + if ($filter_name == '') { |
|
635 | + $filter_name = $this->filter_name; |
|
636 | + } |
|
542 | 637 | $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"; |
543 | 638 | $query_data = array('filter_name' => $filter_name); |
544 | 639 | try { |
@@ -560,7 +655,9 @@ discard block |
||
560 | 655 | } |
561 | 656 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
562 | 657 | global $globalStatsFilters; |
563 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
658 | + if ($filter_name == '') { |
|
659 | + $filter_name = $this->filter_name; |
|
660 | + } |
|
564 | 661 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
565 | 662 | try { |
566 | 663 | $sth = $this->db->prepare($query); |
@@ -581,7 +678,9 @@ discard block |
||
581 | 678 | } |
582 | 679 | public function countAllMilitaryMonths($filter_name = '') { |
583 | 680 | global $globalStatsFilters; |
584 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
681 | + if ($filter_name == '') { |
|
682 | + $filter_name = $this->filter_name; |
|
683 | + } |
|
585 | 684 | $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"; |
586 | 685 | try { |
587 | 686 | $sth = $this->db->prepare($query); |
@@ -602,9 +701,14 @@ discard block |
||
602 | 701 | } |
603 | 702 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
604 | 703 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
605 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
606 | - 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"; |
|
607 | - 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"; |
|
704 | + if ($filter_name == '') { |
|
705 | + $filter_name = $this->filter_name; |
|
706 | + } |
|
707 | + if ($limit) { |
|
708 | + $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"; |
|
709 | + } else { |
|
710 | + $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"; |
|
711 | + } |
|
608 | 712 | if ($orderby == 'hour') { |
609 | 713 | /* |
610 | 714 | if ($globalDBdriver == 'mysql') { |
@@ -613,7 +717,9 @@ discard block |
||
613 | 717 | */ |
614 | 718 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
615 | 719 | } |
616 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
720 | + if ($orderby == 'count') { |
|
721 | + $query .= " ORDER BY hour_count DESC"; |
|
722 | + } |
|
617 | 723 | try { |
618 | 724 | $sth = $this->db->prepare($query); |
619 | 725 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -634,7 +740,9 @@ discard block |
||
634 | 740 | |
635 | 741 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
636 | 742 | global $globalStatsFilters; |
637 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
743 | + if ($filter_name == '') { |
|
744 | + $filter_name = $this->filter_name; |
|
745 | + } |
|
638 | 746 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
639 | 747 | if (empty($all)) { |
640 | 748 | $filters = array('airlines' => array($stats_airline)); |
@@ -648,7 +756,9 @@ discard block |
||
648 | 756 | } |
649 | 757 | public function countOverallMilitaryFlights($filter_name = '') { |
650 | 758 | global $globalStatsFilters; |
651 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
759 | + if ($filter_name == '') { |
|
760 | + $filter_name = $this->filter_name; |
|
761 | + } |
|
652 | 762 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
653 | 763 | if (empty($all)) { |
654 | 764 | $filters = array(); |
@@ -662,7 +772,9 @@ discard block |
||
662 | 772 | } |
663 | 773 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
664 | 774 | global $globalStatsFilters; |
665 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
775 | + if ($filter_name == '') { |
|
776 | + $filter_name = $this->filter_name; |
|
777 | + } |
|
666 | 778 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
667 | 779 | if (empty($all)) { |
668 | 780 | $filters = array('airlines' => array($stats_airline)); |
@@ -676,7 +788,9 @@ discard block |
||
676 | 788 | } |
677 | 789 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
678 | 790 | global $globalStatsFilters; |
679 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
791 | + if ($filter_name == '') { |
|
792 | + $filter_name = $this->filter_name; |
|
793 | + } |
|
680 | 794 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
681 | 795 | if (empty($all)) { |
682 | 796 | $filters = array('airlines' => array($stats_airline)); |
@@ -690,7 +804,9 @@ discard block |
||
690 | 804 | } |
691 | 805 | public function countOverallAirlines($filter_name = '') { |
692 | 806 | global $globalStatsFilters; |
693 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
807 | + if ($filter_name == '') { |
|
808 | + $filter_name = $this->filter_name; |
|
809 | + } |
|
694 | 810 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
695 | 811 | try { |
696 | 812 | $sth = $this->db->prepare($query); |
@@ -713,7 +829,9 @@ discard block |
||
713 | 829 | } |
714 | 830 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
715 | 831 | global $globalStatsFilters; |
716 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
832 | + if ($filter_name == '') { |
|
833 | + $filter_name = $this->filter_name; |
|
834 | + } |
|
717 | 835 | /* |
718 | 836 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
719 | 837 | try { |
@@ -738,7 +856,9 @@ discard block |
||
738 | 856 | } |
739 | 857 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
740 | 858 | global $globalStatsFilters; |
741 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
859 | + if ($filter_name == '') { |
|
860 | + $filter_name = $this->filter_name; |
|
861 | + } |
|
742 | 862 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
743 | 863 | if (empty($all)) { |
744 | 864 | $filters = array('airlines' => array($stats_airline)); |
@@ -752,7 +872,9 @@ discard block |
||
752 | 872 | } |
753 | 873 | |
754 | 874 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
755 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
875 | + if ($filter_name == '') { |
|
876 | + $filter_name = $this->filter_name; |
|
877 | + } |
|
756 | 878 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
757 | 879 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
758 | 880 | try { |
@@ -765,7 +887,9 @@ discard block |
||
765 | 887 | return $all; |
766 | 888 | } |
767 | 889 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
768 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
890 | + if ($filter_name == '') { |
|
891 | + $filter_name = $this->filter_name; |
|
892 | + } |
|
769 | 893 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
770 | 894 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
771 | 895 | try { |
@@ -778,7 +902,9 @@ discard block |
||
778 | 902 | return $all; |
779 | 903 | } |
780 | 904 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
781 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
905 | + if ($filter_name == '') { |
|
906 | + $filter_name = $this->filter_name; |
|
907 | + } |
|
782 | 908 | global $globalArchiveMonths, $globalDBdriver; |
783 | 909 | if ($globalDBdriver == 'mysql') { |
784 | 910 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -797,7 +923,9 @@ discard block |
||
797 | 923 | } |
798 | 924 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
799 | 925 | global $globalArchiveMonths, $globalDBdriver; |
800 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
926 | + if ($filter_name == '') { |
|
927 | + $filter_name = $this->filter_name; |
|
928 | + } |
|
801 | 929 | if ($globalDBdriver == 'mysql') { |
802 | 930 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
803 | 931 | } else { |
@@ -815,7 +943,9 @@ discard block |
||
815 | 943 | } |
816 | 944 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
817 | 945 | global $globalArchiveMonths, $globalDBdriver; |
818 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
946 | + if ($filter_name == '') { |
|
947 | + $filter_name = $this->filter_name; |
|
948 | + } |
|
819 | 949 | if ($globalDBdriver == 'mysql') { |
820 | 950 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
821 | 951 | } else { |
@@ -832,7 +962,9 @@ discard block |
||
832 | 962 | } |
833 | 963 | public function getStatsAirlineTotal($filter_name = '') { |
834 | 964 | global $globalArchiveMonths, $globalDBdriver; |
835 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
965 | + if ($filter_name == '') { |
|
966 | + $filter_name = $this->filter_name; |
|
967 | + } |
|
836 | 968 | if ($globalDBdriver == 'mysql') { |
837 | 969 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
838 | 970 | } else { |
@@ -849,7 +981,9 @@ discard block |
||
849 | 981 | } |
850 | 982 | public function getStatsOwnerTotal($filter_name = '') { |
851 | 983 | global $globalArchiveMonths, $globalDBdriver; |
852 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
984 | + if ($filter_name == '') { |
|
985 | + $filter_name = $this->filter_name; |
|
986 | + } |
|
853 | 987 | if ($globalDBdriver == 'mysql') { |
854 | 988 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
855 | 989 | } else { |
@@ -866,7 +1000,9 @@ discard block |
||
866 | 1000 | } |
867 | 1001 | public function getStatsPilotTotal($filter_name = '') { |
868 | 1002 | global $globalArchiveMonths, $globalDBdriver; |
869 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1003 | + if ($filter_name == '') { |
|
1004 | + $filter_name = $this->filter_name; |
|
1005 | + } |
|
870 | 1006 | if ($globalDBdriver == 'mysql') { |
871 | 1007 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
872 | 1008 | } else { |
@@ -884,7 +1020,9 @@ discard block |
||
884 | 1020 | |
885 | 1021 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
886 | 1022 | global $globalDBdriver; |
887 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1023 | + if ($filter_name == '') { |
|
1024 | + $filter_name = $this->filter_name; |
|
1025 | + } |
|
888 | 1026 | if ($globalDBdriver == 'mysql') { |
889 | 1027 | $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"; |
890 | 1028 | } else { |
@@ -900,7 +1038,9 @@ discard block |
||
900 | 1038 | } |
901 | 1039 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
902 | 1040 | global $globalDBdriver; |
903 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1041 | + if ($filter_name == '') { |
|
1042 | + $filter_name = $this->filter_name; |
|
1043 | + } |
|
904 | 1044 | if ($globalDBdriver == 'mysql') { |
905 | 1045 | $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"; |
906 | 1046 | } else { |
@@ -1383,47 +1523,69 @@ discard block |
||
1383 | 1523 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
1384 | 1524 | } else { |
1385 | 1525 | */ |
1386 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1387 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1526 | + if ($globalDebug) { |
|
1527 | + echo 'Update stats !'."\n"; |
|
1528 | + } |
|
1529 | + if ($globalDebug) { |
|
1530 | + echo 'Count all aircraft types...'."\n"; |
|
1531 | + } |
|
1388 | 1532 | if (isset($last_update[0]['value'])) { |
1389 | 1533 | $last_update_day = $last_update[0]['value']; |
1390 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1534 | + } else { |
|
1535 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1536 | + } |
|
1391 | 1537 | $Spotter = new Spotter($this->db); |
1392 | 1538 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1393 | 1539 | foreach ($alldata as $number) { |
1394 | 1540 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
1395 | 1541 | } |
1396 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1542 | + if ($globalDebug) { |
|
1543 | + echo 'Count all airlines...'."\n"; |
|
1544 | + } |
|
1397 | 1545 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1398 | 1546 | foreach ($alldata as $number) { |
1399 | 1547 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
1400 | 1548 | } |
1401 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1549 | + if ($globalDebug) { |
|
1550 | + echo 'Count all registrations...'."\n"; |
|
1551 | + } |
|
1402 | 1552 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1403 | 1553 | foreach ($alldata as $number) { |
1404 | 1554 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
1405 | 1555 | } |
1406 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1556 | + if ($globalDebug) { |
|
1557 | + echo 'Count all callsigns...'."\n"; |
|
1558 | + } |
|
1407 | 1559 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1408 | 1560 | foreach ($alldata as $number) { |
1409 | 1561 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1410 | 1562 | } |
1411 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1563 | + if ($globalDebug) { |
|
1564 | + echo 'Count all owners...'."\n"; |
|
1565 | + } |
|
1412 | 1566 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1413 | 1567 | foreach ($alldata as $number) { |
1414 | 1568 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
1415 | 1569 | } |
1416 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1570 | + if ($globalDebug) { |
|
1571 | + echo 'Count all pilots...'."\n"; |
|
1572 | + } |
|
1417 | 1573 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1418 | 1574 | foreach ($alldata as $number) { |
1419 | 1575 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']); |
1420 | 1576 | } |
1421 | 1577 | |
1422 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1578 | + if ($globalDebug) { |
|
1579 | + echo 'Count all departure airports...'."\n"; |
|
1580 | + } |
|
1423 | 1581 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1424 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1582 | + if ($globalDebug) { |
|
1583 | + echo 'Count all detected departure airports...'."\n"; |
|
1584 | + } |
|
1425 | 1585 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1426 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1586 | + if ($globalDebug) { |
|
1587 | + echo 'Order departure airports...'."\n"; |
|
1588 | + } |
|
1427 | 1589 | $alldata = array(); |
1428 | 1590 | |
1429 | 1591 | foreach ($pall as $value) { |
@@ -1434,7 +1596,9 @@ discard block |
||
1434 | 1596 | $icao = $value['airport_departure_icao']; |
1435 | 1597 | if (isset($alldata[$icao])) { |
1436 | 1598 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1437 | - } else $alldata[$icao] = $value; |
|
1599 | + } else { |
|
1600 | + $alldata[$icao] = $value; |
|
1601 | + } |
|
1438 | 1602 | } |
1439 | 1603 | $count = array(); |
1440 | 1604 | foreach ($alldata as $key => $row) { |
@@ -1444,11 +1608,17 @@ discard block |
||
1444 | 1608 | foreach ($alldata as $number) { |
1445 | 1609 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1446 | 1610 | } |
1447 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1611 | + if ($globalDebug) { |
|
1612 | + echo 'Count all arrival airports...'."\n"; |
|
1613 | + } |
|
1448 | 1614 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1449 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1615 | + if ($globalDebug) { |
|
1616 | + echo 'Count all detected arrival airports...'."\n"; |
|
1617 | + } |
|
1450 | 1618 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1451 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1619 | + if ($globalDebug) { |
|
1620 | + echo 'Order arrival airports...'."\n"; |
|
1621 | + } |
|
1452 | 1622 | $alldata = array(); |
1453 | 1623 | foreach ($pall as $value) { |
1454 | 1624 | $icao = $value['airport_arrival_icao']; |
@@ -1458,7 +1628,9 @@ discard block |
||
1458 | 1628 | $icao = $value['airport_arrival_icao']; |
1459 | 1629 | if (isset($alldata[$icao])) { |
1460 | 1630 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1461 | - } else $alldata[$icao] = $value; |
|
1631 | + } else { |
|
1632 | + $alldata[$icao] = $value; |
|
1633 | + } |
|
1462 | 1634 | } |
1463 | 1635 | $count = array(); |
1464 | 1636 | foreach ($alldata as $key => $row) { |
@@ -1469,7 +1641,9 @@ discard block |
||
1469 | 1641 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1470 | 1642 | } |
1471 | 1643 | if ($Connection->tableExists('countries')) { |
1472 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1644 | + if ($globalDebug) { |
|
1645 | + echo 'Count all flights by countries...'."\n"; |
|
1646 | + } |
|
1473 | 1647 | $SpotterArchive = new SpotterArchive(); |
1474 | 1648 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1475 | 1649 | foreach ($alldata as $number) { |
@@ -1481,46 +1655,66 @@ discard block |
||
1481 | 1655 | // Add by month using getstat if month finish... |
1482 | 1656 | |
1483 | 1657 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1484 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1658 | + if ($globalDebug) { |
|
1659 | + echo 'Count all flights by months...'."\n"; |
|
1660 | + } |
|
1485 | 1661 | $Spotter = new Spotter($this->db); |
1486 | 1662 | $alldata = $Spotter->countAllMonths(); |
1487 | 1663 | $lastyear = false; |
1488 | 1664 | foreach ($alldata as $number) { |
1489 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1665 | + if ($number['year_name'] != date('Y')) { |
|
1666 | + $lastyear = true; |
|
1667 | + } |
|
1490 | 1668 | $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']))); |
1491 | 1669 | } |
1492 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1670 | + if ($globalDebug) { |
|
1671 | + echo 'Count all military flights by months...'."\n"; |
|
1672 | + } |
|
1493 | 1673 | $alldata = $Spotter->countAllMilitaryMonths(); |
1494 | 1674 | foreach ($alldata as $number) { |
1495 | 1675 | $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']))); |
1496 | 1676 | } |
1497 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1677 | + if ($globalDebug) { |
|
1678 | + echo 'Count all owners by months...'."\n"; |
|
1679 | + } |
|
1498 | 1680 | $alldata = $Spotter->countAllMonthsOwners(); |
1499 | 1681 | foreach ($alldata as $number) { |
1500 | 1682 | $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']))); |
1501 | 1683 | } |
1502 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1684 | + if ($globalDebug) { |
|
1685 | + echo 'Count all pilots by months...'."\n"; |
|
1686 | + } |
|
1503 | 1687 | $alldata = $Spotter->countAllMonthsPilots(); |
1504 | 1688 | foreach ($alldata as $number) { |
1505 | 1689 | $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']))); |
1506 | 1690 | } |
1507 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1691 | + if ($globalDebug) { |
|
1692 | + echo 'Count all airlines by months...'."\n"; |
|
1693 | + } |
|
1508 | 1694 | $alldata = $Spotter->countAllMonthsAirlines(); |
1509 | 1695 | foreach ($alldata as $number) { |
1510 | 1696 | $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']))); |
1511 | 1697 | } |
1512 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1698 | + if ($globalDebug) { |
|
1699 | + echo 'Count all aircrafts by months...'."\n"; |
|
1700 | + } |
|
1513 | 1701 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1514 | 1702 | foreach ($alldata as $number) { |
1515 | 1703 | $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']))); |
1516 | 1704 | } |
1517 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1705 | + if ($globalDebug) { |
|
1706 | + echo 'Count all real arrivals by months...'."\n"; |
|
1707 | + } |
|
1518 | 1708 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1519 | 1709 | foreach ($alldata as $number) { |
1520 | 1710 | $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']))); |
1521 | 1711 | } |
1522 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1523 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1712 | + if ($globalDebug) { |
|
1713 | + echo 'Airports data...'."\n"; |
|
1714 | + } |
|
1715 | + if ($globalDebug) { |
|
1716 | + echo '...Departure'."\n"; |
|
1717 | + } |
|
1524 | 1718 | $this->deleteStatAirport('daily'); |
1525 | 1719 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1526 | 1720 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1640,37 +1834,53 @@ discard block |
||
1640 | 1834 | |
1641 | 1835 | // Count by airlines |
1642 | 1836 | echo '--- Stats by airlines ---'."\n"; |
1643 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1837 | + if ($globalDebug) { |
|
1838 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1839 | + } |
|
1644 | 1840 | $Spotter = new Spotter($this->db); |
1645 | 1841 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1646 | 1842 | foreach ($alldata as $number) { |
1647 | 1843 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
1648 | 1844 | } |
1649 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1847 | + } |
|
1650 | 1848 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1651 | 1849 | foreach ($alldata as $number) { |
1652 | 1850 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
1653 | 1851 | } |
1654 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1852 | + if ($globalDebug) { |
|
1853 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1854 | + } |
|
1655 | 1855 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1656 | 1856 | foreach ($alldata as $number) { |
1657 | 1857 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1658 | 1858 | } |
1659 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo 'Count all owners by airlines...'."\n"; |
|
1861 | + } |
|
1660 | 1862 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1661 | 1863 | foreach ($alldata as $number) { |
1662 | 1864 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
1663 | 1865 | } |
1664 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1866 | + if ($globalDebug) { |
|
1867 | + echo 'Count all pilots by airlines...'."\n"; |
|
1868 | + } |
|
1665 | 1869 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1666 | 1870 | foreach ($alldata as $number) { |
1667 | 1871 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']); |
1668 | 1872 | } |
1669 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1873 | + if ($globalDebug) { |
|
1874 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1875 | + } |
|
1670 | 1876 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1671 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1877 | + if ($globalDebug) { |
|
1878 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1879 | + } |
|
1672 | 1880 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1673 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1881 | + if ($globalDebug) { |
|
1882 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1883 | + } |
|
1674 | 1884 | //$alldata = array(); |
1675 | 1885 | foreach ($dall as $value) { |
1676 | 1886 | $icao = $value['airport_departure_icao']; |
@@ -1691,11 +1901,17 @@ discard block |
||
1691 | 1901 | foreach ($alldata as $number) { |
1692 | 1902 | 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']); |
1693 | 1903 | } |
1694 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1904 | + if ($globalDebug) { |
|
1905 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1906 | + } |
|
1695 | 1907 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1696 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1908 | + if ($globalDebug) { |
|
1909 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1910 | + } |
|
1697 | 1911 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1698 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1912 | + if ($globalDebug) { |
|
1913 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1914 | + } |
|
1699 | 1915 | //$alldata = array(); |
1700 | 1916 | foreach ($dall as $value) { |
1701 | 1917 | $icao = $value['airport_arrival_icao']; |
@@ -1716,35 +1932,49 @@ discard block |
||
1716 | 1932 | foreach ($alldata as $number) { |
1717 | 1933 | 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']); |
1718 | 1934 | } |
1719 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1935 | + if ($globalDebug) { |
|
1936 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1937 | + } |
|
1720 | 1938 | $Spotter = new Spotter($this->db); |
1721 | 1939 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1722 | 1940 | $lastyear = false; |
1723 | 1941 | foreach ($alldata as $number) { |
1724 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1942 | + if ($number['year_name'] != date('Y')) { |
|
1943 | + $lastyear = true; |
|
1944 | + } |
|
1725 | 1945 | $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']); |
1726 | 1946 | } |
1727 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1947 | + if ($globalDebug) { |
|
1948 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1949 | + } |
|
1728 | 1950 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1729 | 1951 | foreach ($alldata as $number) { |
1730 | 1952 | $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']); |
1731 | 1953 | } |
1732 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1954 | + if ($globalDebug) { |
|
1955 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1956 | + } |
|
1733 | 1957 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1734 | 1958 | foreach ($alldata as $number) { |
1735 | 1959 | $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']); |
1736 | 1960 | } |
1737 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1961 | + if ($globalDebug) { |
|
1962 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1963 | + } |
|
1738 | 1964 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1739 | 1965 | foreach ($alldata as $number) { |
1740 | 1966 | $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']); |
1741 | 1967 | } |
1742 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1970 | + } |
|
1743 | 1971 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1744 | 1972 | foreach ($alldata as $number) { |
1745 | 1973 | $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']); |
1746 | 1974 | } |
1747 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1975 | + if ($globalDebug) { |
|
1976 | + echo '...Departure'."\n"; |
|
1977 | + } |
|
1748 | 1978 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1749 | 1979 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1750 | 1980 | foreach ($dall as $value) { |
@@ -1767,7 +1997,9 @@ discard block |
||
1767 | 1997 | foreach ($alldata as $number) { |
1768 | 1998 | $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']); |
1769 | 1999 | } |
1770 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2000 | + if ($globalDebug) { |
|
2001 | + echo '...Arrival'."\n"; |
|
2002 | + } |
|
1771 | 2003 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1772 | 2004 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1773 | 2005 | foreach ($dall as $value) { |
@@ -1791,13 +2023,19 @@ discard block |
||
1791 | 2023 | $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']); |
1792 | 2024 | } |
1793 | 2025 | |
1794 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1795 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2026 | + if ($globalDebug) { |
|
2027 | + echo 'Flights data...'."\n"; |
|
2028 | + } |
|
2029 | + if ($globalDebug) { |
|
2030 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2031 | + } |
|
1796 | 2032 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1797 | 2033 | foreach ($alldata as $number) { |
1798 | 2034 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1799 | 2035 | } |
1800 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2036 | + if ($globalDebug) { |
|
2037 | + echo '-> countAllDates...'."\n"; |
|
2038 | + } |
|
1801 | 2039 | //$previousdata = $this->countAllDatesByAirlines(); |
1802 | 2040 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1803 | 2041 | $values = array(); |
@@ -1810,14 +2048,18 @@ discard block |
||
1810 | 2048 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1811 | 2049 | } |
1812 | 2050 | |
1813 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2051 | + if ($globalDebug) { |
|
2052 | + echo '-> countAllHours...'."\n"; |
|
2053 | + } |
|
1814 | 2054 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1815 | 2055 | foreach ($alldata as $number) { |
1816 | 2056 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
1817 | 2057 | } |
1818 | 2058 | |
1819 | 2059 | |
1820 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2060 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2061 | + $globalStatsFilters = array(); |
|
2062 | + } |
|
1821 | 2063 | foreach ($globalStatsFilters as $name => $filter) { |
1822 | 2064 | //$filter_name = $filter['name']; |
1823 | 2065 | $filter_name = $name; |
@@ -1825,10 +2067,14 @@ discard block |
||
1825 | 2067 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1826 | 2068 | if (isset($last_update[0]['value'])) { |
1827 | 2069 | $last_update_day = $last_update[0]['value']; |
1828 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2070 | + } else { |
|
2071 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2072 | + } |
|
1829 | 2073 | |
1830 | 2074 | // Count by filter |
1831 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2075 | + if ($globalDebug) { |
|
2076 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2077 | + } |
|
1832 | 2078 | $Spotter = new Spotter($this->db); |
1833 | 2079 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1834 | 2080 | foreach ($alldata as $number) { |
@@ -1866,7 +2112,9 @@ discard block |
||
1866 | 2112 | $icao = $value['airport_departure_icao']; |
1867 | 2113 | if (isset($alldata[$icao])) { |
1868 | 2114 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1869 | - } else $alldata[$icao] = $value; |
|
2115 | + } else { |
|
2116 | + $alldata[$icao] = $value; |
|
2117 | + } |
|
1870 | 2118 | } |
1871 | 2119 | $count = array(); |
1872 | 2120 | foreach ($alldata as $key => $row) { |
@@ -1887,7 +2135,9 @@ discard block |
||
1887 | 2135 | $icao = $value['airport_arrival_icao']; |
1888 | 2136 | if (isset($alldata[$icao])) { |
1889 | 2137 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1890 | - } else $alldata[$icao] = $value; |
|
2138 | + } else { |
|
2139 | + $alldata[$icao] = $value; |
|
2140 | + } |
|
1891 | 2141 | } |
1892 | 2142 | $count = array(); |
1893 | 2143 | foreach ($alldata as $key => $row) { |
@@ -1901,7 +2151,9 @@ discard block |
||
1901 | 2151 | $alldata = $Spotter->countAllMonths($filter); |
1902 | 2152 | $lastyear = false; |
1903 | 2153 | foreach ($alldata as $number) { |
1904 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2154 | + if ($number['year_name'] != date('Y')) { |
|
2155 | + $lastyear = true; |
|
2156 | + } |
|
1905 | 2157 | $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); |
1906 | 2158 | } |
1907 | 2159 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -15,33 +15,33 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
43 | - public function deleteStats($filter_name = '') { |
|
44 | - /* |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | + public function deleteStats($filter_name = '') { |
|
44 | + /* |
|
45 | 45 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
46 | 46 | try { |
47 | 47 | $sth = $this->db->prepare($query); |
@@ -50,80 +50,80 @@ discard block |
||
50 | 50 | return "error : ".$e->getMessage(); |
51 | 51 | } |
52 | 52 | */ |
53 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | - try { |
|
55 | - $sth = $this->db->prepare($query); |
|
56 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - } |
|
61 | - public function deleteOldStats($filter_name = '') { |
|
53 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | + try { |
|
55 | + $sth = $this->db->prepare($query); |
|
56 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + } |
|
61 | + public function deleteOldStats($filter_name = '') { |
|
62 | 62 | |
63 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | - try { |
|
65 | - $sth = $this->db->prepare($query); |
|
66 | - $sth->execute(); |
|
67 | - } catch(PDOException $e) { |
|
68 | - return "error : ".$e->getMessage(); |
|
69 | - } |
|
63 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | + try { |
|
65 | + $sth = $this->db->prepare($query); |
|
66 | + $sth->execute(); |
|
67 | + } catch(PDOException $e) { |
|
68 | + return "error : ".$e->getMessage(); |
|
69 | + } |
|
70 | 70 | |
71 | - $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | - try { |
|
73 | - $sth = $this->db->prepare($query); |
|
74 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | - } catch(PDOException $e) { |
|
76 | - return "error : ".$e->getMessage(); |
|
77 | - } |
|
78 | - } |
|
71 | + $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | + try { |
|
73 | + $sth = $this->db->prepare($query); |
|
74 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | + } catch(PDOException $e) { |
|
76 | + return "error : ".$e->getMessage(); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | public function getAllAirlineNames($filter_name = '') { |
80 | 80 | if ($filter_name == '') $filter_name = $this->filter_name; |
81 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | - try { |
|
83 | - $sth = $this->db->prepare($query); |
|
84 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | - } catch(PDOException $e) { |
|
86 | - echo "error : ".$e->getMessage(); |
|
87 | - } |
|
88 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | - return $all; |
|
90 | - } |
|
81 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | + try { |
|
83 | + $sth = $this->db->prepare($query); |
|
84 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | + } catch(PDOException $e) { |
|
86 | + echo "error : ".$e->getMessage(); |
|
87 | + } |
|
88 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | + return $all; |
|
90 | + } |
|
91 | 91 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | - try { |
|
95 | - $sth = $this->db->prepare($query); |
|
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
98 | - echo "error : ".$e->getMessage(); |
|
99 | - } |
|
100 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | - return $all; |
|
102 | - } |
|
93 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | + try { |
|
95 | + $sth = $this->db->prepare($query); |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | + } catch(PDOException $e) { |
|
98 | + echo "error : ".$e->getMessage(); |
|
99 | + } |
|
100 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | + return $all; |
|
102 | + } |
|
103 | 103 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | - $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"; |
|
106 | - try { |
|
107 | - $sth = $this->db->prepare($query); |
|
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
110 | - echo "error : ".$e->getMessage(); |
|
111 | - } |
|
112 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | - return $all; |
|
114 | - } |
|
105 | + $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"; |
|
106 | + try { |
|
107 | + $sth = $this->db->prepare($query); |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | + } catch(PDOException $e) { |
|
110 | + echo "error : ".$e->getMessage(); |
|
111 | + } |
|
112 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | + return $all; |
|
114 | + } |
|
115 | 115 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | - $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"; |
|
118 | - try { |
|
119 | - $sth = $this->db->prepare($query); |
|
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
122 | - echo "error : ".$e->getMessage(); |
|
123 | - } |
|
124 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | - return $all; |
|
126 | - } |
|
117 | + $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"; |
|
118 | + try { |
|
119 | + $sth = $this->db->prepare($query); |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | + } catch(PDOException $e) { |
|
122 | + echo "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | + return $all; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -131,66 +131,66 @@ discard block |
||
131 | 131 | if ($filter_name == '') $filter_name = $this->filter_name; |
132 | 132 | if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
133 | 133 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
134 | - try { |
|
135 | - $sth = $this->db->prepare($query); |
|
136 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | - } catch(PDOException $e) { |
|
138 | - echo "error : ".$e->getMessage(); |
|
139 | - } |
|
140 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
141 | - if (empty($all)) { |
|
142 | - $filters = array('airlines' => array($stats_airline)); |
|
143 | - if ($filter_name != '') { |
|
144 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
145 | - } |
|
146 | - $Spotter = new Spotter($this->db); |
|
147 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
148 | - } |
|
149 | - return $all; |
|
134 | + try { |
|
135 | + $sth = $this->db->prepare($query); |
|
136 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | + } catch(PDOException $e) { |
|
138 | + echo "error : ".$e->getMessage(); |
|
139 | + } |
|
140 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
141 | + if (empty($all)) { |
|
142 | + $filters = array('airlines' => array($stats_airline)); |
|
143 | + if ($filter_name != '') { |
|
144 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
145 | + } |
|
146 | + $Spotter = new Spotter($this->db); |
|
147 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
148 | + } |
|
149 | + return $all; |
|
150 | 150 | } |
151 | 151 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
152 | 152 | global $globalStatsFilters; |
153 | 153 | if ($filter_name == '') $filter_name = $this->filter_name; |
154 | 154 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
155 | 155 | else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
156 | - try { |
|
157 | - $sth = $this->db->prepare($query); |
|
158 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
159 | - } catch(PDOException $e) { |
|
160 | - echo "error : ".$e->getMessage(); |
|
161 | - } |
|
162 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
163 | - if (empty($all)) { |
|
164 | - $Spotter = new Spotter($this->db); |
|
165 | - $filters = array(); |
|
166 | - if ($filter_name != '') { |
|
167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
168 | - } |
|
169 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
170 | - } |
|
171 | - return $all; |
|
156 | + try { |
|
157 | + $sth = $this->db->prepare($query); |
|
158 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
159 | + } catch(PDOException $e) { |
|
160 | + echo "error : ".$e->getMessage(); |
|
161 | + } |
|
162 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
163 | + if (empty($all)) { |
|
164 | + $Spotter = new Spotter($this->db); |
|
165 | + $filters = array(); |
|
166 | + if ($filter_name != '') { |
|
167 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
168 | + } |
|
169 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
170 | + } |
|
171 | + return $all; |
|
172 | 172 | } |
173 | 173 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
174 | 174 | global $globalStatsFilters; |
175 | 175 | if ($filter_name == '') $filter_name = $this->filter_name; |
176 | 176 | 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"; |
177 | 177 | 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"; |
178 | - try { |
|
179 | - $sth = $this->db->prepare($query); |
|
180 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | - } catch(PDOException $e) { |
|
182 | - echo "error : ".$e->getMessage(); |
|
183 | - } |
|
184 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | - if (empty($all)) { |
|
186 | - $filters = array('airlines' => array($stats_airline)); |
|
187 | - if ($filter_name != '') { |
|
188 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
178 | + try { |
|
179 | + $sth = $this->db->prepare($query); |
|
180 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | + } catch(PDOException $e) { |
|
182 | + echo "error : ".$e->getMessage(); |
|
183 | + } |
|
184 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | + if (empty($all)) { |
|
186 | + $filters = array('airlines' => array($stats_airline)); |
|
187 | + if ($filter_name != '') { |
|
188 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
189 | 189 | } |
190 | - $Spotter = new Spotter($this->db); |
|
190 | + $Spotter = new Spotter($this->db); |
|
191 | 191 | $all = $Spotter->countAllAircraftManufacturers($filters); |
192 | - } |
|
193 | - return $all; |
|
192 | + } |
|
193 | + return $all; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -198,44 +198,44 @@ discard block |
||
198 | 198 | if ($filter_name == '') $filter_name = $this->filter_name; |
199 | 199 | if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
200 | 200 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | - } catch(PDOException $e) { |
|
205 | - echo "error : ".$e->getMessage(); |
|
206 | - } |
|
207 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
208 | - if (empty($all)) { |
|
201 | + try { |
|
202 | + $sth = $this->db->prepare($query); |
|
203 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | + } catch(PDOException $e) { |
|
205 | + echo "error : ".$e->getMessage(); |
|
206 | + } |
|
207 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
208 | + if (empty($all)) { |
|
209 | 209 | $filters = array('airlines' => array($stats_airline)); |
210 | 210 | if ($filter_name != '') { |
211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
211 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
212 | 212 | } |
213 | 213 | $Spotter = new Spotter($this->db); |
214 | 214 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
215 | - } |
|
216 | - return $all; |
|
215 | + } |
|
216 | + return $all; |
|
217 | 217 | } |
218 | 218 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
219 | 219 | global $globalStatsFilters; |
220 | 220 | if ($filter_name == '') $filter_name = $this->filter_name; |
221 | 221 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
222 | 222 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
223 | - try { |
|
224 | - $sth = $this->db->prepare($query); |
|
225 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | - } catch(PDOException $e) { |
|
227 | - echo "error : ".$e->getMessage(); |
|
228 | - } |
|
229 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | - if (empty($all)) { |
|
223 | + try { |
|
224 | + $sth = $this->db->prepare($query); |
|
225 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | + } catch(PDOException $e) { |
|
227 | + echo "error : ".$e->getMessage(); |
|
228 | + } |
|
229 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | + if (empty($all)) { |
|
231 | 231 | $filters = array('airlines' => array($stats_airline)); |
232 | 232 | if ($filter_name != '') { |
233 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
233 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
234 | 234 | } |
235 | 235 | $Spotter = new Spotter($this->db); |
236 | 236 | $all = $Spotter->countAllDepartureCountries($filters); |
237 | - } |
|
238 | - return $all; |
|
237 | + } |
|
238 | + return $all; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -243,45 +243,45 @@ discard block |
||
243 | 243 | if ($filter_name == '') $filter_name = $this->filter_name; |
244 | 244 | 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
245 | 245 | 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 ORDER BY airline_count DESC"; |
246 | - try { |
|
247 | - $sth = $this->db->prepare($query); |
|
248 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
249 | - } catch(PDOException $e) { |
|
250 | - echo "error : ".$e->getMessage(); |
|
251 | - } |
|
252 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | - if (empty($all)) { |
|
254 | - $Spotter = new Spotter($this->db); |
|
255 | - $filters = array(); |
|
256 | - if ($filter_name != '') { |
|
257 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
246 | + try { |
|
247 | + $sth = $this->db->prepare($query); |
|
248 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
249 | + } catch(PDOException $e) { |
|
250 | + echo "error : ".$e->getMessage(); |
|
251 | + } |
|
252 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | + if (empty($all)) { |
|
254 | + $Spotter = new Spotter($this->db); |
|
255 | + $filters = array(); |
|
256 | + if ($filter_name != '') { |
|
257 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
258 | 258 | } |
259 | 259 | |
260 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
261 | - } |
|
262 | - return $all; |
|
260 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
261 | + } |
|
262 | + return $all; |
|
263 | 263 | } |
264 | 264 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
265 | 265 | global $globalStatsFilters; |
266 | 266 | if ($filter_name == '') $filter_name = $this->filter_name; |
267 | 267 | 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 aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
268 | 268 | 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 aircraft_registration_count DESC"; |
269 | - try { |
|
270 | - $sth = $this->db->prepare($query); |
|
271 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | - } catch(PDOException $e) { |
|
273 | - echo "error : ".$e->getMessage(); |
|
274 | - } |
|
275 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
276 | - if (empty($all)) { |
|
269 | + try { |
|
270 | + $sth = $this->db->prepare($query); |
|
271 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | + } catch(PDOException $e) { |
|
273 | + echo "error : ".$e->getMessage(); |
|
274 | + } |
|
275 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
276 | + if (empty($all)) { |
|
277 | 277 | $filters = array('airlines' => array($stats_airline)); |
278 | 278 | if ($filter_name != '') { |
279 | 279 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
280 | 280 | } |
281 | - $Spotter = new Spotter($this->db); |
|
282 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
283 | - } |
|
284 | - return $all; |
|
281 | + $Spotter = new Spotter($this->db); |
|
282 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
283 | + } |
|
284 | + return $all; |
|
285 | 285 | } |
286 | 286 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
287 | 287 | global $globalStatsFilters; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | echo "error : ".$e->getMessage(); |
319 | 319 | } |
320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
321 | - /* |
|
321 | + /* |
|
322 | 322 | if (empty($all)) { |
323 | 323 | $Spotter = new Spotter($this->db); |
324 | 324 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -334,84 +334,84 @@ discard block |
||
334 | 334 | if ($filter_name == '') $filter_name = $this->filter_name; |
335 | 335 | 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"; |
336 | 336 | 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"; |
337 | - try { |
|
338 | - $sth = $this->db->prepare($query); |
|
339 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | - } catch(PDOException $e) { |
|
341 | - echo "error : ".$e->getMessage(); |
|
342 | - } |
|
343 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | - if (empty($all)) { |
|
337 | + try { |
|
338 | + $sth = $this->db->prepare($query); |
|
339 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | + } catch(PDOException $e) { |
|
341 | + echo "error : ".$e->getMessage(); |
|
342 | + } |
|
343 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | + if (empty($all)) { |
|
345 | 345 | $filters = array('airlines' => array($stats_airline)); |
346 | 346 | if ($filter_name != '') { |
347 | 347 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
348 | 348 | } |
349 | - $Spotter = new Spotter($this->db); |
|
350 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
351 | - } |
|
352 | - return $all; |
|
349 | + $Spotter = new Spotter($this->db); |
|
350 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
351 | + } |
|
352 | + return $all; |
|
353 | 353 | } |
354 | 354 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
355 | 355 | global $globalStatsFilters; |
356 | 356 | if ($filter_name == '') $filter_name = $this->filter_name; |
357 | 357 | 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"; |
358 | 358 | 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"; |
359 | - try { |
|
360 | - $sth = $this->db->prepare($query); |
|
361 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | - } catch(PDOException $e) { |
|
363 | - echo "error : ".$e->getMessage(); |
|
364 | - } |
|
365 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
366 | - if (empty($all)) { |
|
359 | + try { |
|
360 | + $sth = $this->db->prepare($query); |
|
361 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | + } catch(PDOException $e) { |
|
363 | + echo "error : ".$e->getMessage(); |
|
364 | + } |
|
365 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
366 | + if (empty($all)) { |
|
367 | 367 | $filters = array('airlines' => array($stats_airline)); |
368 | 368 | if ($filter_name != '') { |
369 | 369 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
370 | 370 | } |
371 | - $Spotter = new Spotter($this->db); |
|
372 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
373 | - } |
|
374 | - return $all; |
|
371 | + $Spotter = new Spotter($this->db); |
|
372 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
373 | + } |
|
374 | + return $all; |
|
375 | 375 | } |
376 | 376 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
377 | 377 | global $globalStatsFilters; |
378 | 378 | if ($filter_name == '') $filter_name = $this->filter_name; |
379 | 379 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE 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"; |
380 | 380 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
381 | - try { |
|
382 | - $sth = $this->db->prepare($query); |
|
383 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | - } catch(PDOException $e) { |
|
385 | - echo "error : ".$e->getMessage(); |
|
386 | - } |
|
387 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
388 | - if (empty($all)) { |
|
381 | + try { |
|
382 | + $sth = $this->db->prepare($query); |
|
383 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | + } catch(PDOException $e) { |
|
385 | + echo "error : ".$e->getMessage(); |
|
386 | + } |
|
387 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
388 | + if (empty($all)) { |
|
389 | 389 | $filters = array('airlines' => array($stats_airline)); |
390 | - if ($filter_name != '') { |
|
391 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
392 | - } |
|
393 | - $Spotter = new Spotter($this->db); |
|
394 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
396 | - $all = array(); |
|
397 | - foreach ($pall as $value) { |
|
398 | - $icao = $value['airport_departure_icao']; |
|
399 | - $all[$icao] = $value; |
|
400 | - } |
|
390 | + if ($filter_name != '') { |
|
391 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
392 | + } |
|
393 | + $Spotter = new Spotter($this->db); |
|
394 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
396 | + $all = array(); |
|
397 | + foreach ($pall as $value) { |
|
398 | + $icao = $value['airport_departure_icao']; |
|
399 | + $all[$icao] = $value; |
|
400 | + } |
|
401 | 401 | |
402 | - foreach ($dall as $value) { |
|
403 | - $icao = $value['airport_departure_icao']; |
|
404 | - if (isset($all[$icao])) { |
|
405 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
406 | - } else $all[$icao] = $value; |
|
407 | - } |
|
408 | - $count = array(); |
|
409 | - foreach ($all as $key => $row) { |
|
410 | - $count[$key] = $row['airport_departure_icao_count']; |
|
411 | - } |
|
412 | - array_multisort($count,SORT_DESC,$all); |
|
413 | - } |
|
414 | - return $all; |
|
402 | + foreach ($dall as $value) { |
|
403 | + $icao = $value['airport_departure_icao']; |
|
404 | + if (isset($all[$icao])) { |
|
405 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
406 | + } else $all[$icao] = $value; |
|
407 | + } |
|
408 | + $count = array(); |
|
409 | + foreach ($all as $key => $row) { |
|
410 | + $count[$key] = $row['airport_departure_icao_count']; |
|
411 | + } |
|
412 | + array_multisort($count,SORT_DESC,$all); |
|
413 | + } |
|
414 | + return $all; |
|
415 | 415 | } |
416 | 416 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
417 | 417 | global $globalStatsFilters; |
@@ -433,26 +433,26 @@ discard block |
||
433 | 433 | $Spotter = new Spotter($this->db); |
434 | 434 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
435 | 435 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
436 | - $all = array(); |
|
437 | - foreach ($pall as $value) { |
|
438 | - $icao = $value['airport_arrival_icao']; |
|
439 | - $all[$icao] = $value; |
|
440 | - } |
|
436 | + $all = array(); |
|
437 | + foreach ($pall as $value) { |
|
438 | + $icao = $value['airport_arrival_icao']; |
|
439 | + $all[$icao] = $value; |
|
440 | + } |
|
441 | 441 | |
442 | - foreach ($dall as $value) { |
|
443 | - $icao = $value['airport_arrival_icao']; |
|
444 | - if (isset($all[$icao])) { |
|
445 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
446 | - } else $all[$icao] = $value; |
|
447 | - } |
|
448 | - $count = array(); |
|
449 | - foreach ($all as $key => $row) { |
|
450 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
451 | - } |
|
452 | - array_multisort($count,SORT_DESC,$all); |
|
453 | - } |
|
442 | + foreach ($dall as $value) { |
|
443 | + $icao = $value['airport_arrival_icao']; |
|
444 | + if (isset($all[$icao])) { |
|
445 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
446 | + } else $all[$icao] = $value; |
|
447 | + } |
|
448 | + $count = array(); |
|
449 | + foreach ($all as $key => $row) { |
|
450 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
451 | + } |
|
452 | + array_multisort($count,SORT_DESC,$all); |
|
453 | + } |
|
454 | 454 | |
455 | - return $all; |
|
455 | + return $all; |
|
456 | 456 | } |
457 | 457 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
458 | 458 | global $globalDBdriver, $globalStatsFilters; |
@@ -465,23 +465,23 @@ discard block |
||
465 | 465 | 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"; |
466 | 466 | } |
467 | 467 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
468 | - try { |
|
469 | - $sth = $this->db->prepare($query); |
|
470 | - $sth->execute($query_data); |
|
471 | - } catch(PDOException $e) { |
|
472 | - echo "error : ".$e->getMessage(); |
|
473 | - } |
|
474 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
475 | - if (empty($all)) { |
|
468 | + try { |
|
469 | + $sth = $this->db->prepare($query); |
|
470 | + $sth->execute($query_data); |
|
471 | + } catch(PDOException $e) { |
|
472 | + echo "error : ".$e->getMessage(); |
|
473 | + } |
|
474 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
475 | + if (empty($all)) { |
|
476 | 476 | $filters = array('airlines' => array($stats_airline)); |
477 | 477 | if ($filter_name != '') { |
478 | 478 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
479 | 479 | } |
480 | - $Spotter = new Spotter($this->db); |
|
481 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
482 | - } |
|
480 | + $Spotter = new Spotter($this->db); |
|
481 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
482 | + } |
|
483 | 483 | |
484 | - return $all; |
|
484 | + return $all; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -489,22 +489,22 @@ discard block |
||
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
491 | 491 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | - try { |
|
493 | - $sth = $this->db->prepare($query); |
|
494 | - $sth->execute($query_data); |
|
495 | - } catch(PDOException $e) { |
|
496 | - echo "error : ".$e->getMessage(); |
|
497 | - } |
|
498 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | - if (empty($all)) { |
|
492 | + try { |
|
493 | + $sth = $this->db->prepare($query); |
|
494 | + $sth->execute($query_data); |
|
495 | + } catch(PDOException $e) { |
|
496 | + echo "error : ".$e->getMessage(); |
|
497 | + } |
|
498 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | + if (empty($all)) { |
|
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | 502 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
503 | 503 | } |
504 | - $Spotter = new Spotter($this->db); |
|
505 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
506 | - } |
|
507 | - return $all; |
|
504 | + $Spotter = new Spotter($this->db); |
|
505 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
506 | + } |
|
507 | + return $all; |
|
508 | 508 | } |
509 | 509 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
510 | 510 | global $globalDBdriver, $globalStatsFilters; |
@@ -515,108 +515,108 @@ discard block |
||
515 | 515 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
516 | 516 | } |
517 | 517 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
518 | - try { |
|
519 | - $sth = $this->db->prepare($query); |
|
520 | - $sth->execute($query_data); |
|
521 | - } catch(PDOException $e) { |
|
522 | - echo "error : ".$e->getMessage(); |
|
523 | - } |
|
524 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
525 | - if (empty($all)) { |
|
518 | + try { |
|
519 | + $sth = $this->db->prepare($query); |
|
520 | + $sth->execute($query_data); |
|
521 | + } catch(PDOException $e) { |
|
522 | + echo "error : ".$e->getMessage(); |
|
523 | + } |
|
524 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
525 | + if (empty($all)) { |
|
526 | 526 | $filters = array('airlines' => array($stats_airline)); |
527 | 527 | if ($filter_name != '') { |
528 | 528 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
529 | 529 | } |
530 | - $Spotter = new Spotter($this->db); |
|
531 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
532 | - } |
|
533 | - return $all; |
|
530 | + $Spotter = new Spotter($this->db); |
|
531 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
532 | + } |
|
533 | + return $all; |
|
534 | 534 | } |
535 | 535 | public function countAllDates($stats_airline = '',$filter_name = '') { |
536 | 536 | global $globalStatsFilters; |
537 | 537 | if ($filter_name == '') $filter_name = $this->filter_name; |
538 | 538 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
539 | 539 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
540 | - try { |
|
541 | - $sth = $this->db->prepare($query); |
|
542 | - $sth->execute($query_data); |
|
543 | - } catch(PDOException $e) { |
|
544 | - echo "error : ".$e->getMessage(); |
|
545 | - } |
|
546 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
547 | - if (empty($all)) { |
|
540 | + try { |
|
541 | + $sth = $this->db->prepare($query); |
|
542 | + $sth->execute($query_data); |
|
543 | + } catch(PDOException $e) { |
|
544 | + echo "error : ".$e->getMessage(); |
|
545 | + } |
|
546 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
547 | + if (empty($all)) { |
|
548 | 548 | $filters = array('airlines' => array($stats_airline)); |
549 | 549 | if ($filter_name != '') { |
550 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
550 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
551 | 551 | } |
552 | - $Spotter = new Spotter($this->db); |
|
553 | - $all = $Spotter->countAllDates($filters); |
|
554 | - } |
|
555 | - return $all; |
|
552 | + $Spotter = new Spotter($this->db); |
|
553 | + $all = $Spotter->countAllDates($filters); |
|
554 | + } |
|
555 | + return $all; |
|
556 | 556 | } |
557 | 557 | public function countAllDatesByAirlines($filter_name = '') { |
558 | 558 | global $globalStatsFilters; |
559 | 559 | if ($filter_name == '') $filter_name = $this->filter_name; |
560 | 560 | $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"; |
561 | 561 | $query_data = array('filter_name' => $filter_name); |
562 | - try { |
|
563 | - $sth = $this->db->prepare($query); |
|
564 | - $sth->execute($query_data); |
|
565 | - } catch(PDOException $e) { |
|
566 | - echo "error : ".$e->getMessage(); |
|
567 | - } |
|
568 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
569 | - if (empty($all)) { |
|
570 | - $filters = array(); |
|
571 | - if ($filter_name != '') { |
|
572 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
573 | - } |
|
574 | - $Spotter = new Spotter($this->db); |
|
575 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
576 | - } |
|
577 | - return $all; |
|
562 | + try { |
|
563 | + $sth = $this->db->prepare($query); |
|
564 | + $sth->execute($query_data); |
|
565 | + } catch(PDOException $e) { |
|
566 | + echo "error : ".$e->getMessage(); |
|
567 | + } |
|
568 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
569 | + if (empty($all)) { |
|
570 | + $filters = array(); |
|
571 | + if ($filter_name != '') { |
|
572 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
573 | + } |
|
574 | + $Spotter = new Spotter($this->db); |
|
575 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
576 | + } |
|
577 | + return $all; |
|
578 | 578 | } |
579 | 579 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
580 | 580 | global $globalStatsFilters; |
581 | 581 | if ($filter_name == '') $filter_name = $this->filter_name; |
582 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
583 | - try { |
|
584 | - $sth = $this->db->prepare($query); |
|
585 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
586 | - } catch(PDOException $e) { |
|
587 | - echo "error : ".$e->getMessage(); |
|
588 | - } |
|
589 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
590 | - if (empty($all)) { |
|
582 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
583 | + try { |
|
584 | + $sth = $this->db->prepare($query); |
|
585 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
586 | + } catch(PDOException $e) { |
|
587 | + echo "error : ".$e->getMessage(); |
|
588 | + } |
|
589 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
590 | + if (empty($all)) { |
|
591 | 591 | $filters = array('airlines' => array($stats_airline)); |
592 | 592 | if ($filter_name != '') { |
593 | 593 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
594 | 594 | } |
595 | - $Spotter = new Spotter($this->db); |
|
596 | - $all = $Spotter->countAllMonths($filters); |
|
597 | - } |
|
598 | - return $all; |
|
595 | + $Spotter = new Spotter($this->db); |
|
596 | + $all = $Spotter->countAllMonths($filters); |
|
597 | + } |
|
598 | + return $all; |
|
599 | 599 | } |
600 | 600 | public function countAllMilitaryMonths($filter_name = '') { |
601 | 601 | global $globalStatsFilters; |
602 | 602 | if ($filter_name == '') $filter_name = $this->filter_name; |
603 | - $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"; |
|
604 | - try { |
|
605 | - $sth = $this->db->prepare($query); |
|
606 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
607 | - } catch(PDOException $e) { |
|
608 | - echo "error : ".$e->getMessage(); |
|
609 | - } |
|
610 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
611 | - if (empty($all)) { |
|
612 | - $filters = array(); |
|
613 | - if ($filter_name != '') { |
|
614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
615 | - } |
|
616 | - $Spotter = new Spotter($this->db); |
|
617 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
618 | - } |
|
619 | - return $all; |
|
603 | + $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"; |
|
604 | + try { |
|
605 | + $sth = $this->db->prepare($query); |
|
606 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
607 | + } catch(PDOException $e) { |
|
608 | + echo "error : ".$e->getMessage(); |
|
609 | + } |
|
610 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
611 | + if (empty($all)) { |
|
612 | + $filters = array(); |
|
613 | + if ($filter_name != '') { |
|
614 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
615 | + } |
|
616 | + $Spotter = new Spotter($this->db); |
|
617 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
618 | + } |
|
619 | + return $all; |
|
620 | 620 | } |
621 | 621 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
622 | 622 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -632,22 +632,22 @@ discard block |
||
632 | 632 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
633 | 633 | } |
634 | 634 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
635 | - try { |
|
636 | - $sth = $this->db->prepare($query); |
|
637 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
638 | - } catch(PDOException $e) { |
|
639 | - echo "error : ".$e->getMessage(); |
|
640 | - } |
|
641 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
642 | - if (empty($all)) { |
|
635 | + try { |
|
636 | + $sth = $this->db->prepare($query); |
|
637 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
638 | + } catch(PDOException $e) { |
|
639 | + echo "error : ".$e->getMessage(); |
|
640 | + } |
|
641 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
642 | + if (empty($all)) { |
|
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
645 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
646 | 646 | } |
647 | - $Spotter = new Spotter($this->db); |
|
648 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
649 | - } |
|
650 | - return $all; |
|
647 | + $Spotter = new Spotter($this->db); |
|
648 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
649 | + } |
|
650 | + return $all; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -669,9 +669,9 @@ discard block |
||
669 | 669 | if ($filter_name == '') $filter_name = $this->filter_name; |
670 | 670 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
671 | 671 | if (empty($all)) { |
672 | - $filters = array(); |
|
673 | - if ($filter_name != '') { |
|
674 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
672 | + $filters = array(); |
|
673 | + if ($filter_name != '') { |
|
674 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
675 | 675 | } |
676 | 676 | $Spotter = new Spotter($this->db); |
677 | 677 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -710,19 +710,19 @@ discard block |
||
710 | 710 | global $globalStatsFilters; |
711 | 711 | if ($filter_name == '') $filter_name = $this->filter_name; |
712 | 712 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
713 | - try { |
|
714 | - $sth = $this->db->prepare($query); |
|
715 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
716 | - } catch(PDOException $e) { |
|
717 | - echo "error : ".$e->getMessage(); |
|
718 | - } |
|
719 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | - $all = $result[0]['nb_airline']; |
|
713 | + try { |
|
714 | + $sth = $this->db->prepare($query); |
|
715 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
716 | + } catch(PDOException $e) { |
|
717 | + echo "error : ".$e->getMessage(); |
|
718 | + } |
|
719 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | + $all = $result[0]['nb_airline']; |
|
721 | 721 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
722 | 722 | if (empty($all)) { |
723 | - $filters = array(); |
|
724 | - if ($filter_name != '') { |
|
725 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
723 | + $filters = array(); |
|
724 | + if ($filter_name != '') { |
|
725 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
726 | 726 | } |
727 | 727 | $Spotter = new Spotter($this->db); |
728 | 728 | $all = $Spotter->countOverallAirlines($filters); |
@@ -773,166 +773,166 @@ discard block |
||
773 | 773 | if ($filter_name == '') $filter_name = $this->filter_name; |
774 | 774 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
775 | 775 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
776 | - try { |
|
777 | - $sth = $this->db->prepare($query); |
|
778 | - $sth->execute($query_values); |
|
779 | - } catch(PDOException $e) { |
|
780 | - echo "error : ".$e->getMessage(); |
|
781 | - } |
|
782 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
783 | - return $all; |
|
776 | + try { |
|
777 | + $sth = $this->db->prepare($query); |
|
778 | + $sth->execute($query_values); |
|
779 | + } catch(PDOException $e) { |
|
780 | + echo "error : ".$e->getMessage(); |
|
781 | + } |
|
782 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
783 | + return $all; |
|
784 | 784 | } |
785 | 785 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
786 | 786 | if ($filter_name == '') $filter_name = $this->filter_name; |
787 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
788 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | - try { |
|
790 | - $sth = $this->db->prepare($query); |
|
791 | - $sth->execute($query_values); |
|
792 | - } catch(PDOException $e) { |
|
793 | - echo "error : ".$e->getMessage(); |
|
794 | - } |
|
795 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | - return $all; |
|
797 | - } |
|
787 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
788 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | + try { |
|
790 | + $sth = $this->db->prepare($query); |
|
791 | + $sth->execute($query_values); |
|
792 | + } catch(PDOException $e) { |
|
793 | + echo "error : ".$e->getMessage(); |
|
794 | + } |
|
795 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | + return $all; |
|
797 | + } |
|
798 | 798 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
799 | 799 | if ($filter_name == '') $filter_name = $this->filter_name; |
800 | - global $globalArchiveMonths, $globalDBdriver; |
|
801 | - if ($globalDBdriver == 'mysql') { |
|
802 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
803 | - } else { |
|
804 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
805 | - } |
|
806 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
807 | - try { |
|
808 | - $sth = $this->db->prepare($query); |
|
809 | - $sth->execute($query_values); |
|
810 | - } catch(PDOException $e) { |
|
811 | - echo "error : ".$e->getMessage(); |
|
812 | - } |
|
813 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | - return $all[0]['total']; |
|
815 | - } |
|
800 | + global $globalArchiveMonths, $globalDBdriver; |
|
801 | + if ($globalDBdriver == 'mysql') { |
|
802 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
803 | + } else { |
|
804 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
805 | + } |
|
806 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
807 | + try { |
|
808 | + $sth = $this->db->prepare($query); |
|
809 | + $sth->execute($query_values); |
|
810 | + } catch(PDOException $e) { |
|
811 | + echo "error : ".$e->getMessage(); |
|
812 | + } |
|
813 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | + return $all[0]['total']; |
|
815 | + } |
|
816 | 816 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
817 | - global $globalArchiveMonths, $globalDBdriver; |
|
817 | + global $globalArchiveMonths, $globalDBdriver; |
|
818 | 818 | if ($filter_name == '') $filter_name = $this->filter_name; |
819 | - if ($globalDBdriver == 'mysql') { |
|
819 | + if ($globalDBdriver == 'mysql') { |
|
820 | 820 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
821 | 821 | } else { |
822 | 822 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
823 | - } |
|
824 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
825 | - try { |
|
826 | - $sth = $this->db->prepare($query); |
|
827 | - $sth->execute($query_values); |
|
828 | - } catch(PDOException $e) { |
|
829 | - echo "error : ".$e->getMessage(); |
|
830 | - } |
|
831 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
832 | - return $all[0]['total']; |
|
833 | - } |
|
823 | + } |
|
824 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
825 | + try { |
|
826 | + $sth = $this->db->prepare($query); |
|
827 | + $sth->execute($query_values); |
|
828 | + } catch(PDOException $e) { |
|
829 | + echo "error : ".$e->getMessage(); |
|
830 | + } |
|
831 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
832 | + return $all[0]['total']; |
|
833 | + } |
|
834 | 834 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
835 | - global $globalArchiveMonths, $globalDBdriver; |
|
835 | + global $globalArchiveMonths, $globalDBdriver; |
|
836 | 836 | if ($filter_name == '') $filter_name = $this->filter_name; |
837 | - if ($globalDBdriver == 'mysql') { |
|
837 | + if ($globalDBdriver == 'mysql') { |
|
838 | 838 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
839 | - } else { |
|
839 | + } else { |
|
840 | 840 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
841 | - } |
|
842 | - try { |
|
843 | - $sth = $this->db->prepare($query); |
|
844 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
845 | - } catch(PDOException $e) { |
|
846 | - echo "error : ".$e->getMessage(); |
|
847 | - } |
|
848 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
849 | - return $all[0]['total']; |
|
850 | - } |
|
841 | + } |
|
842 | + try { |
|
843 | + $sth = $this->db->prepare($query); |
|
844 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
845 | + } catch(PDOException $e) { |
|
846 | + echo "error : ".$e->getMessage(); |
|
847 | + } |
|
848 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
849 | + return $all[0]['total']; |
|
850 | + } |
|
851 | 851 | public function getStatsAirlineTotal($filter_name = '') { |
852 | - global $globalArchiveMonths, $globalDBdriver; |
|
852 | + global $globalArchiveMonths, $globalDBdriver; |
|
853 | 853 | if ($filter_name == '') $filter_name = $this->filter_name; |
854 | - if ($globalDBdriver == 'mysql') { |
|
854 | + if ($globalDBdriver == 'mysql') { |
|
855 | 855 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
856 | - } else { |
|
856 | + } else { |
|
857 | 857 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
858 | - } |
|
859 | - try { |
|
860 | - $sth = $this->db->prepare($query); |
|
861 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
862 | - } catch(PDOException $e) { |
|
863 | - echo "error : ".$e->getMessage(); |
|
864 | - } |
|
865 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
866 | - return $all[0]['total']; |
|
867 | - } |
|
858 | + } |
|
859 | + try { |
|
860 | + $sth = $this->db->prepare($query); |
|
861 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
862 | + } catch(PDOException $e) { |
|
863 | + echo "error : ".$e->getMessage(); |
|
864 | + } |
|
865 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
866 | + return $all[0]['total']; |
|
867 | + } |
|
868 | 868 | public function getStatsOwnerTotal($filter_name = '') { |
869 | - global $globalArchiveMonths, $globalDBdriver; |
|
869 | + global $globalArchiveMonths, $globalDBdriver; |
|
870 | 870 | if ($filter_name == '') $filter_name = $this->filter_name; |
871 | - if ($globalDBdriver == 'mysql') { |
|
871 | + if ($globalDBdriver == 'mysql') { |
|
872 | 872 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
873 | 873 | } else { |
874 | 874 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
875 | - } |
|
876 | - try { |
|
877 | - $sth = $this->db->prepare($query); |
|
878 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
879 | - } catch(PDOException $e) { |
|
880 | - echo "error : ".$e->getMessage(); |
|
881 | - } |
|
882 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
883 | - return $all[0]['total']; |
|
884 | - } |
|
875 | + } |
|
876 | + try { |
|
877 | + $sth = $this->db->prepare($query); |
|
878 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
879 | + } catch(PDOException $e) { |
|
880 | + echo "error : ".$e->getMessage(); |
|
881 | + } |
|
882 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
883 | + return $all[0]['total']; |
|
884 | + } |
|
885 | 885 | public function getStatsPilotTotal($filter_name = '') { |
886 | - global $globalArchiveMonths, $globalDBdriver; |
|
886 | + global $globalArchiveMonths, $globalDBdriver; |
|
887 | 887 | if ($filter_name == '') $filter_name = $this->filter_name; |
888 | - if ($globalDBdriver == 'mysql') { |
|
889 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
890 | - } else { |
|
891 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
892 | - } |
|
893 | - try { |
|
894 | - $sth = $this->db->prepare($query); |
|
895 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
896 | - } catch(PDOException $e) { |
|
897 | - echo "error : ".$e->getMessage(); |
|
898 | - } |
|
899 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
900 | - return $all[0]['total']; |
|
901 | - } |
|
888 | + if ($globalDBdriver == 'mysql') { |
|
889 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
890 | + } else { |
|
891 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
892 | + } |
|
893 | + try { |
|
894 | + $sth = $this->db->prepare($query); |
|
895 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
896 | + } catch(PDOException $e) { |
|
897 | + echo "error : ".$e->getMessage(); |
|
898 | + } |
|
899 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
900 | + return $all[0]['total']; |
|
901 | + } |
|
902 | 902 | |
903 | 903 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
904 | 904 | global $globalDBdriver; |
905 | 905 | if ($filter_name == '') $filter_name = $this->filter_name; |
906 | 906 | if ($globalDBdriver == 'mysql') { |
907 | 907 | $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"; |
908 | - } else { |
|
908 | + } else { |
|
909 | 909 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
910 | 910 | } |
911 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
912 | - try { |
|
913 | - $sth = $this->db->prepare($query); |
|
914 | - $sth->execute($query_values); |
|
915 | - } catch(PDOException $e) { |
|
916 | - return "error : ".$e->getMessage(); |
|
917 | - } |
|
918 | - } |
|
911 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
912 | + try { |
|
913 | + $sth = $this->db->prepare($query); |
|
914 | + $sth->execute($query_values); |
|
915 | + } catch(PDOException $e) { |
|
916 | + return "error : ".$e->getMessage(); |
|
917 | + } |
|
918 | + } |
|
919 | 919 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
920 | 920 | global $globalDBdriver; |
921 | 921 | if ($filter_name == '') $filter_name = $this->filter_name; |
922 | 922 | if ($globalDBdriver == 'mysql') { |
923 | 923 | $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"; |
924 | 924 | } else { |
925 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
925 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
926 | 926 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
927 | - } |
|
928 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
929 | - try { |
|
930 | - $sth = $this->db->prepare($query); |
|
931 | - $sth->execute($query_values); |
|
932 | - } catch(PDOException $e) { |
|
933 | - return "error : ".$e->getMessage(); |
|
934 | - } |
|
935 | - } |
|
927 | + } |
|
928 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
929 | + try { |
|
930 | + $sth = $this->db->prepare($query); |
|
931 | + $sth->execute($query_values); |
|
932 | + } catch(PDOException $e) { |
|
933 | + return "error : ".$e->getMessage(); |
|
934 | + } |
|
935 | + } |
|
936 | 936 | public function getStatsSource($date,$stats_type = '') { |
937 | 937 | if ($stats_type == '') { |
938 | 938 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -941,15 +941,15 @@ discard block |
||
941 | 941 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
942 | 942 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
943 | 943 | } |
944 | - try { |
|
945 | - $sth = $this->db->prepare($query); |
|
946 | - $sth->execute($query_values); |
|
947 | - } catch(PDOException $e) { |
|
948 | - echo "error : ".$e->getMessage(); |
|
949 | - } |
|
950 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
951 | - return $all; |
|
952 | - } |
|
944 | + try { |
|
945 | + $sth = $this->db->prepare($query); |
|
946 | + $sth->execute($query_values); |
|
947 | + } catch(PDOException $e) { |
|
948 | + echo "error : ".$e->getMessage(); |
|
949 | + } |
|
950 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
951 | + return $all; |
|
952 | + } |
|
953 | 953 | |
954 | 954 | public function addStatSource($data,$source_name,$stats_type,$date) { |
955 | 955 | global $globalDBdriver; |
@@ -957,25 +957,25 @@ discard block |
||
957 | 957 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
958 | 958 | } else { |
959 | 959 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
960 | - } |
|
961 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
962 | - try { |
|
963 | - $sth = $this->db->prepare($query); |
|
964 | - $sth->execute($query_values); |
|
965 | - } catch(PDOException $e) { |
|
966 | - return "error : ".$e->getMessage(); |
|
967 | - } |
|
968 | - } |
|
960 | + } |
|
961 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
962 | + try { |
|
963 | + $sth = $this->db->prepare($query); |
|
964 | + $sth->execute($query_values); |
|
965 | + } catch(PDOException $e) { |
|
966 | + return "error : ".$e->getMessage(); |
|
967 | + } |
|
968 | + } |
|
969 | 969 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
970 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
971 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
972 | - try { |
|
973 | - $sth = $this->db->prepare($query); |
|
974 | - $sth->execute($query_values); |
|
975 | - } catch(PDOException $e) { |
|
976 | - return "error : ".$e->getMessage(); |
|
977 | - } |
|
978 | - } |
|
970 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
971 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
972 | + try { |
|
973 | + $sth = $this->db->prepare($query); |
|
974 | + $sth->execute($query_values); |
|
975 | + } catch(PDOException $e) { |
|
976 | + return "error : ".$e->getMessage(); |
|
977 | + } |
|
978 | + } |
|
979 | 979 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
980 | 980 | global $globalDBdriver; |
981 | 981 | if ($globalDBdriver == 'mysql') { |
@@ -983,14 +983,14 @@ discard block |
||
983 | 983 | } else { |
984 | 984 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
985 | 985 | } |
986 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | - try { |
|
988 | - $sth = $this->db->prepare($query); |
|
989 | - $sth->execute($query_values); |
|
990 | - } catch(PDOException $e) { |
|
991 | - return "error : ".$e->getMessage(); |
|
992 | - } |
|
993 | - } |
|
986 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | + try { |
|
988 | + $sth = $this->db->prepare($query); |
|
989 | + $sth->execute($query_values); |
|
990 | + } catch(PDOException $e) { |
|
991 | + return "error : ".$e->getMessage(); |
|
992 | + } |
|
993 | + } |
|
994 | 994 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
995 | 995 | global $globalDBdriver; |
996 | 996 | if ($globalDBdriver == 'mysql') { |
@@ -998,14 +998,14 @@ discard block |
||
998 | 998 | } else { |
999 | 999 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1000 | 1000 | } |
1001 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | - try { |
|
1003 | - $sth = $this->db->prepare($query); |
|
1004 | - $sth->execute($query_values); |
|
1005 | - } catch(PDOException $e) { |
|
1006 | - return "error : ".$e->getMessage(); |
|
1007 | - } |
|
1008 | - } |
|
1001 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | + try { |
|
1003 | + $sth = $this->db->prepare($query); |
|
1004 | + $sth->execute($query_values); |
|
1005 | + } catch(PDOException $e) { |
|
1006 | + return "error : ".$e->getMessage(); |
|
1007 | + } |
|
1008 | + } |
|
1009 | 1009 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
1010 | 1010 | global $globalDBdriver; |
1011 | 1011 | if ($globalDBdriver == 'mysql') { |
@@ -1013,14 +1013,14 @@ discard block |
||
1013 | 1013 | } else { |
1014 | 1014 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
1015 | 1015 | } |
1016 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1017 | - try { |
|
1018 | - $sth = $this->db->prepare($query); |
|
1019 | - $sth->execute($query_values); |
|
1020 | - } catch(PDOException $e) { |
|
1021 | - return "error : ".$e->getMessage(); |
|
1022 | - } |
|
1023 | - } |
|
1016 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1017 | + try { |
|
1018 | + $sth = $this->db->prepare($query); |
|
1019 | + $sth->execute($query_values); |
|
1020 | + } catch(PDOException $e) { |
|
1021 | + return "error : ".$e->getMessage(); |
|
1022 | + } |
|
1023 | + } |
|
1024 | 1024 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
1025 | 1025 | global $globalDBdriver; |
1026 | 1026 | if ($globalDBdriver == 'mysql') { |
@@ -1028,14 +1028,14 @@ discard block |
||
1028 | 1028 | } else { |
1029 | 1029 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1030 | 1030 | } |
1031 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1032 | - try { |
|
1033 | - $sth = $this->db->prepare($query); |
|
1034 | - $sth->execute($query_values); |
|
1035 | - } catch(PDOException $e) { |
|
1036 | - return "error : ".$e->getMessage(); |
|
1037 | - } |
|
1038 | - } |
|
1031 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1032 | + try { |
|
1033 | + $sth = $this->db->prepare($query); |
|
1034 | + $sth->execute($query_values); |
|
1035 | + } catch(PDOException $e) { |
|
1036 | + return "error : ".$e->getMessage(); |
|
1037 | + } |
|
1038 | + } |
|
1039 | 1039 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
1040 | 1040 | global $globalDBdriver; |
1041 | 1041 | if ($globalDBdriver == 'mysql') { |
@@ -1043,14 +1043,14 @@ discard block |
||
1043 | 1043 | } else { |
1044 | 1044 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1045 | 1045 | } |
1046 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1047 | - try { |
|
1048 | - $sth = $this->db->prepare($query); |
|
1049 | - $sth->execute($query_values); |
|
1050 | - } catch(PDOException $e) { |
|
1051 | - return "error : ".$e->getMessage(); |
|
1052 | - } |
|
1053 | - } |
|
1046 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1047 | + try { |
|
1048 | + $sth = $this->db->prepare($query); |
|
1049 | + $sth->execute($query_values); |
|
1050 | + } catch(PDOException $e) { |
|
1051 | + return "error : ".$e->getMessage(); |
|
1052 | + } |
|
1053 | + } |
|
1054 | 1054 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
1055 | 1055 | global $globalDBdriver; |
1056 | 1056 | if ($globalDBdriver == 'mysql') { |
@@ -1058,14 +1058,14 @@ discard block |
||
1058 | 1058 | } else { |
1059 | 1059 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1060 | 1060 | } |
1061 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1062 | - try { |
|
1063 | - $sth = $this->db->prepare($query); |
|
1064 | - $sth->execute($query_values); |
|
1065 | - } catch(PDOException $e) { |
|
1066 | - return "error : ".$e->getMessage(); |
|
1067 | - } |
|
1068 | - } |
|
1061 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1062 | + try { |
|
1063 | + $sth = $this->db->prepare($query); |
|
1064 | + $sth->execute($query_values); |
|
1065 | + } catch(PDOException $e) { |
|
1066 | + return "error : ".$e->getMessage(); |
|
1067 | + } |
|
1068 | + } |
|
1069 | 1069 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
1070 | 1070 | global $globalDBdriver; |
1071 | 1071 | if ($globalDBdriver == 'mysql') { |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | } else { |
1074 | 1074 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1075 | 1075 | } |
1076 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1077 | - try { |
|
1078 | - $sth = $this->db->prepare($query); |
|
1079 | - $sth->execute($query_values); |
|
1080 | - } catch(PDOException $e) { |
|
1081 | - return "error : ".$e->getMessage(); |
|
1082 | - } |
|
1083 | - } |
|
1076 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1077 | + try { |
|
1078 | + $sth = $this->db->prepare($query); |
|
1079 | + $sth->execute($query_values); |
|
1080 | + } catch(PDOException $e) { |
|
1081 | + return "error : ".$e->getMessage(); |
|
1082 | + } |
|
1083 | + } |
|
1084 | 1084 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1085 | 1085 | global $globalDBdriver; |
1086 | 1086 | if ($globalDBdriver == 'mysql') { |
@@ -1088,14 +1088,14 @@ discard block |
||
1088 | 1088 | } else { |
1089 | 1089 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1090 | 1090 | } |
1091 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1092 | - try { |
|
1093 | - $sth = $this->db->prepare($query); |
|
1094 | - $sth->execute($query_values); |
|
1095 | - } catch(PDOException $e) { |
|
1096 | - return "error : ".$e->getMessage(); |
|
1097 | - } |
|
1098 | - } |
|
1091 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1092 | + try { |
|
1093 | + $sth = $this->db->prepare($query); |
|
1094 | + $sth->execute($query_values); |
|
1095 | + } catch(PDOException $e) { |
|
1096 | + return "error : ".$e->getMessage(); |
|
1097 | + } |
|
1098 | + } |
|
1099 | 1099 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1100 | 1100 | global $globalDBdriver; |
1101 | 1101 | if ($globalDBdriver == 'mysql') { |
@@ -1103,14 +1103,14 @@ discard block |
||
1103 | 1103 | } else { |
1104 | 1104 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1105 | 1105 | } |
1106 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1107 | - try { |
|
1108 | - $sth = $this->db->prepare($query); |
|
1109 | - $sth->execute($query_values); |
|
1110 | - } catch(PDOException $e) { |
|
1111 | - return "error : ".$e->getMessage(); |
|
1112 | - } |
|
1113 | - } |
|
1106 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1107 | + try { |
|
1108 | + $sth = $this->db->prepare($query); |
|
1109 | + $sth->execute($query_values); |
|
1110 | + } catch(PDOException $e) { |
|
1111 | + return "error : ".$e->getMessage(); |
|
1112 | + } |
|
1113 | + } |
|
1114 | 1114 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1115 | 1115 | global $globalDBdriver; |
1116 | 1116 | if ($globalDBdriver == 'mysql') { |
@@ -1118,14 +1118,14 @@ discard block |
||
1118 | 1118 | } else { |
1119 | 1119 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1120 | 1120 | } |
1121 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1122 | - try { |
|
1123 | - $sth = $this->db->prepare($query); |
|
1124 | - $sth->execute($query_values); |
|
1125 | - } catch(PDOException $e) { |
|
1126 | - return "error : ".$e->getMessage(); |
|
1127 | - } |
|
1128 | - } |
|
1121 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1122 | + try { |
|
1123 | + $sth = $this->db->prepare($query); |
|
1124 | + $sth->execute($query_values); |
|
1125 | + } catch(PDOException $e) { |
|
1126 | + return "error : ".$e->getMessage(); |
|
1127 | + } |
|
1128 | + } |
|
1129 | 1129 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1130 | 1130 | global $globalDBdriver; |
1131 | 1131 | if ($globalDBdriver == 'mysql') { |
@@ -1133,52 +1133,52 @@ discard block |
||
1133 | 1133 | } else { |
1134 | 1134 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1135 | 1135 | } |
1136 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1137 | - try { |
|
1138 | - $sth = $this->db->prepare($query); |
|
1139 | - $sth->execute($query_values); |
|
1140 | - } catch(PDOException $e) { |
|
1141 | - return "error : ".$e->getMessage(); |
|
1142 | - } |
|
1143 | - } |
|
1136 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1137 | + try { |
|
1138 | + $sth = $this->db->prepare($query); |
|
1139 | + $sth->execute($query_values); |
|
1140 | + } catch(PDOException $e) { |
|
1141 | + return "error : ".$e->getMessage(); |
|
1142 | + } |
|
1143 | + } |
|
1144 | 1144 | |
1145 | 1145 | public function deleteStat($id) { |
1146 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1147 | - $query_values = array(':id' => $id); |
|
1148 | - try { |
|
1149 | - $sth = $this->db->prepare($query); |
|
1150 | - $sth->execute($query_values); |
|
1151 | - } catch(PDOException $e) { |
|
1152 | - return "error : ".$e->getMessage(); |
|
1153 | - } |
|
1154 | - } |
|
1146 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1147 | + $query_values = array(':id' => $id); |
|
1148 | + try { |
|
1149 | + $sth = $this->db->prepare($query); |
|
1150 | + $sth->execute($query_values); |
|
1151 | + } catch(PDOException $e) { |
|
1152 | + return "error : ".$e->getMessage(); |
|
1153 | + } |
|
1154 | + } |
|
1155 | 1155 | public function deleteStatFlight($type) { |
1156 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1157 | - $query_values = array(':type' => $type); |
|
1158 | - try { |
|
1159 | - $sth = $this->db->prepare($query); |
|
1160 | - $sth->execute($query_values); |
|
1161 | - } catch(PDOException $e) { |
|
1162 | - return "error : ".$e->getMessage(); |
|
1163 | - } |
|
1164 | - } |
|
1156 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1157 | + $query_values = array(':type' => $type); |
|
1158 | + try { |
|
1159 | + $sth = $this->db->prepare($query); |
|
1160 | + $sth->execute($query_values); |
|
1161 | + } catch(PDOException $e) { |
|
1162 | + return "error : ".$e->getMessage(); |
|
1163 | + } |
|
1164 | + } |
|
1165 | 1165 | public function deleteStatAirport($type) { |
1166 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1167 | - $query_values = array(':type' => $type); |
|
1168 | - try { |
|
1169 | - $sth = $this->db->prepare($query); |
|
1170 | - $sth->execute($query_values); |
|
1171 | - } catch(PDOException $e) { |
|
1172 | - return "error : ".$e->getMessage(); |
|
1173 | - } |
|
1174 | - } |
|
1166 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1167 | + $query_values = array(':type' => $type); |
|
1168 | + try { |
|
1169 | + $sth = $this->db->prepare($query); |
|
1170 | + $sth->execute($query_values); |
|
1171 | + } catch(PDOException $e) { |
|
1172 | + return "error : ".$e->getMessage(); |
|
1173 | + } |
|
1174 | + } |
|
1175 | 1175 | |
1176 | - public function addOldStats() { |
|
1177 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1178 | - $Common = new Common(); |
|
1179 | - $Connection = new Connection(); |
|
1180 | - date_default_timezone_set('UTC'); |
|
1181 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1176 | + public function addOldStats() { |
|
1177 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1178 | + $Common = new Common(); |
|
1179 | + $Connection = new Connection(); |
|
1180 | + date_default_timezone_set('UTC'); |
|
1181 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1182 | 1182 | //print_r($last_update); |
1183 | 1183 | /* |
1184 | 1184 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1440,24 +1440,24 @@ discard block |
||
1440 | 1440 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1441 | 1441 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1442 | 1442 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1443 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1443 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1444 | 1444 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1445 | - $alldata = array(); |
|
1445 | + $alldata = array(); |
|
1446 | 1446 | |
1447 | - foreach ($pall as $value) { |
|
1448 | - $icao = $value['airport_departure_icao']; |
|
1449 | - $alldata[$icao] = $value; |
|
1450 | - } |
|
1451 | - foreach ($dall as $value) { |
|
1452 | - $icao = $value['airport_departure_icao']; |
|
1453 | - if (isset($alldata[$icao])) { |
|
1454 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1455 | - } else $alldata[$icao] = $value; |
|
1456 | - } |
|
1457 | - $count = array(); |
|
1458 | - foreach ($alldata as $key => $row) { |
|
1459 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1460 | - } |
|
1447 | + foreach ($pall as $value) { |
|
1448 | + $icao = $value['airport_departure_icao']; |
|
1449 | + $alldata[$icao] = $value; |
|
1450 | + } |
|
1451 | + foreach ($dall as $value) { |
|
1452 | + $icao = $value['airport_departure_icao']; |
|
1453 | + if (isset($alldata[$icao])) { |
|
1454 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1455 | + } else $alldata[$icao] = $value; |
|
1456 | + } |
|
1457 | + $count = array(); |
|
1458 | + foreach ($alldata as $key => $row) { |
|
1459 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1460 | + } |
|
1461 | 1461 | array_multisort($count,SORT_DESC,$alldata); |
1462 | 1462 | foreach ($alldata as $number) { |
1463 | 1463 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
@@ -1465,25 +1465,25 @@ discard block |
||
1465 | 1465 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1466 | 1466 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1467 | 1467 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1468 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1468 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1469 | 1469 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1470 | - $alldata = array(); |
|
1471 | - foreach ($pall as $value) { |
|
1472 | - $icao = $value['airport_arrival_icao']; |
|
1473 | - $alldata[$icao] = $value; |
|
1474 | - } |
|
1475 | - foreach ($dall as $value) { |
|
1476 | - $icao = $value['airport_arrival_icao']; |
|
1477 | - if (isset($alldata[$icao])) { |
|
1478 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1479 | - } else $alldata[$icao] = $value; |
|
1480 | - } |
|
1481 | - $count = array(); |
|
1482 | - foreach ($alldata as $key => $row) { |
|
1483 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1484 | - } |
|
1485 | - array_multisort($count,SORT_DESC,$alldata); |
|
1486 | - foreach ($alldata as $number) { |
|
1470 | + $alldata = array(); |
|
1471 | + foreach ($pall as $value) { |
|
1472 | + $icao = $value['airport_arrival_icao']; |
|
1473 | + $alldata[$icao] = $value; |
|
1474 | + } |
|
1475 | + foreach ($dall as $value) { |
|
1476 | + $icao = $value['airport_arrival_icao']; |
|
1477 | + if (isset($alldata[$icao])) { |
|
1478 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1479 | + } else $alldata[$icao] = $value; |
|
1480 | + } |
|
1481 | + $count = array(); |
|
1482 | + foreach ($alldata as $key => $row) { |
|
1483 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1484 | + } |
|
1485 | + array_multisort($count,SORT_DESC,$alldata); |
|
1486 | + foreach ($alldata as $number) { |
|
1487 | 1487 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1488 | 1488 | } |
1489 | 1489 | if ($Connection->tableExists('countries')) { |
@@ -1543,8 +1543,8 @@ discard block |
||
1543 | 1543 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1544 | 1544 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1545 | 1545 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1546 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1547 | - /* |
|
1546 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1547 | + /* |
|
1548 | 1548 | $alldata = array(); |
1549 | 1549 | foreach ($pall as $value) { |
1550 | 1550 | $icao = $value['departure_airport_icao']; |
@@ -1563,29 +1563,29 @@ discard block |
||
1563 | 1563 | } |
1564 | 1564 | array_multisort($count,SORT_DESC,$alldata); |
1565 | 1565 | */ |
1566 | - foreach ($dall as $value) { |
|
1567 | - $icao = $value['departure_airport_icao']; |
|
1568 | - $ddate = $value['date']; |
|
1569 | - $find = false; |
|
1570 | - foreach ($pall as $pvalue) { |
|
1571 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1572 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1573 | - $find = true; |
|
1574 | - break; |
|
1575 | - } |
|
1576 | - } |
|
1577 | - if ($find === false) { |
|
1578 | - $pall[] = $value; |
|
1579 | - } |
|
1580 | - } |
|
1581 | - $alldata = $pall; |
|
1566 | + foreach ($dall as $value) { |
|
1567 | + $icao = $value['departure_airport_icao']; |
|
1568 | + $ddate = $value['date']; |
|
1569 | + $find = false; |
|
1570 | + foreach ($pall as $pvalue) { |
|
1571 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1572 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1573 | + $find = true; |
|
1574 | + break; |
|
1575 | + } |
|
1576 | + } |
|
1577 | + if ($find === false) { |
|
1578 | + $pall[] = $value; |
|
1579 | + } |
|
1580 | + } |
|
1581 | + $alldata = $pall; |
|
1582 | 1582 | foreach ($alldata as $number) { |
1583 | 1583 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1584 | 1584 | } |
1585 | 1585 | echo '...Arrival'."\n"; |
1586 | 1586 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1587 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1588 | - /* |
|
1587 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1588 | + /* |
|
1589 | 1589 | $alldata = array(); |
1590 | 1590 | foreach ($pall as $value) { |
1591 | 1591 | $icao = $value['arrival_airport_icao']; |
@@ -1605,22 +1605,22 @@ discard block |
||
1605 | 1605 | */ |
1606 | 1606 | |
1607 | 1607 | |
1608 | - foreach ($dall as $value) { |
|
1609 | - $icao = $value['arrival_airport_icao']; |
|
1610 | - $ddate = $value['date']; |
|
1611 | - $find = false; |
|
1612 | - foreach ($pall as $pvalue) { |
|
1613 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1614 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1615 | - $find = true; |
|
1616 | - break; |
|
1617 | - } |
|
1618 | - } |
|
1619 | - if ($find === false) { |
|
1620 | - $pall[] = $value; |
|
1621 | - } |
|
1622 | - } |
|
1623 | - $alldata = $pall; |
|
1608 | + foreach ($dall as $value) { |
|
1609 | + $icao = $value['arrival_airport_icao']; |
|
1610 | + $ddate = $value['date']; |
|
1611 | + $find = false; |
|
1612 | + foreach ($pall as $pvalue) { |
|
1613 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1614 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1615 | + $find = true; |
|
1616 | + break; |
|
1617 | + } |
|
1618 | + } |
|
1619 | + if ($find === false) { |
|
1620 | + $pall[] = $value; |
|
1621 | + } |
|
1622 | + } |
|
1623 | + $alldata = $pall; |
|
1624 | 1624 | foreach ($alldata as $number) { |
1625 | 1625 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1626 | 1626 | } |
@@ -1687,51 +1687,51 @@ discard block |
||
1687 | 1687 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1688 | 1688 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1689 | 1689 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1690 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1690 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1691 | 1691 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1692 | - //$alldata = array(); |
|
1693 | - foreach ($dall as $value) { |
|
1694 | - $icao = $value['airport_departure_icao']; |
|
1695 | - $dicao = $value['airline_icao']; |
|
1696 | - $find = false; |
|
1697 | - foreach ($pall as $pvalue) { |
|
1698 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1699 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1700 | - $find = true; |
|
1701 | - break; |
|
1702 | - } |
|
1703 | - } |
|
1704 | - if ($find === false) { |
|
1705 | - $pall[] = $value; |
|
1706 | - } |
|
1707 | - } |
|
1708 | - $alldata = $pall; |
|
1692 | + //$alldata = array(); |
|
1693 | + foreach ($dall as $value) { |
|
1694 | + $icao = $value['airport_departure_icao']; |
|
1695 | + $dicao = $value['airline_icao']; |
|
1696 | + $find = false; |
|
1697 | + foreach ($pall as $pvalue) { |
|
1698 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1699 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1700 | + $find = true; |
|
1701 | + break; |
|
1702 | + } |
|
1703 | + } |
|
1704 | + if ($find === false) { |
|
1705 | + $pall[] = $value; |
|
1706 | + } |
|
1707 | + } |
|
1708 | + $alldata = $pall; |
|
1709 | 1709 | foreach ($alldata as $number) { |
1710 | 1710 | 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']); |
1711 | 1711 | } |
1712 | 1712 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1713 | 1713 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1714 | 1714 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1715 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1715 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1716 | 1716 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1717 | - //$alldata = array(); |
|
1718 | - foreach ($dall as $value) { |
|
1719 | - $icao = $value['airport_arrival_icao']; |
|
1720 | - $dicao = $value['airline_icao']; |
|
1721 | - $find = false; |
|
1722 | - foreach ($pall as $pvalue) { |
|
1723 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1724 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1725 | - $find = true; |
|
1726 | - break; |
|
1727 | - } |
|
1728 | - } |
|
1729 | - if ($find === false) { |
|
1730 | - $pall[] = $value; |
|
1731 | - } |
|
1732 | - } |
|
1733 | - $alldata = $pall; |
|
1734 | - foreach ($alldata as $number) { |
|
1717 | + //$alldata = array(); |
|
1718 | + foreach ($dall as $value) { |
|
1719 | + $icao = $value['airport_arrival_icao']; |
|
1720 | + $dicao = $value['airline_icao']; |
|
1721 | + $find = false; |
|
1722 | + foreach ($pall as $pvalue) { |
|
1723 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1724 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1725 | + $find = true; |
|
1726 | + break; |
|
1727 | + } |
|
1728 | + } |
|
1729 | + if ($find === false) { |
|
1730 | + $pall[] = $value; |
|
1731 | + } |
|
1732 | + } |
|
1733 | + $alldata = $pall; |
|
1734 | + foreach ($alldata as $number) { |
|
1735 | 1735 | 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']); |
1736 | 1736 | } |
1737 | 1737 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1764,47 +1764,47 @@ discard block |
||
1764 | 1764 | } |
1765 | 1765 | if ($globalDebug) echo '...Departure'."\n"; |
1766 | 1766 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1767 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1768 | - foreach ($dall as $value) { |
|
1769 | - $icao = $value['departure_airport_icao']; |
|
1770 | - $airline = $value['airline_icao']; |
|
1771 | - $ddate = $value['date']; |
|
1772 | - $find = false; |
|
1773 | - foreach ($pall as $pvalue) { |
|
1774 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1775 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1776 | - $find = true; |
|
1777 | - break; |
|
1778 | - } |
|
1779 | - } |
|
1780 | - if ($find === false) { |
|
1781 | - $pall[] = $value; |
|
1782 | - } |
|
1783 | - } |
|
1784 | - $alldata = $pall; |
|
1767 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1768 | + foreach ($dall as $value) { |
|
1769 | + $icao = $value['departure_airport_icao']; |
|
1770 | + $airline = $value['airline_icao']; |
|
1771 | + $ddate = $value['date']; |
|
1772 | + $find = false; |
|
1773 | + foreach ($pall as $pvalue) { |
|
1774 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1775 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1776 | + $find = true; |
|
1777 | + break; |
|
1778 | + } |
|
1779 | + } |
|
1780 | + if ($find === false) { |
|
1781 | + $pall[] = $value; |
|
1782 | + } |
|
1783 | + } |
|
1784 | + $alldata = $pall; |
|
1785 | 1785 | foreach ($alldata as $number) { |
1786 | 1786 | $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']); |
1787 | 1787 | } |
1788 | 1788 | if ($globalDebug) echo '...Arrival'."\n"; |
1789 | 1789 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1790 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1791 | - foreach ($dall as $value) { |
|
1792 | - $icao = $value['arrival_airport_icao']; |
|
1793 | - $airline = $value['airline_icao']; |
|
1794 | - $ddate = $value['date']; |
|
1795 | - $find = false; |
|
1796 | - foreach ($pall as $pvalue) { |
|
1797 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1798 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1799 | - $find = true; |
|
1800 | - break; |
|
1801 | - } |
|
1802 | - } |
|
1803 | - if ($find === false) { |
|
1804 | - $pall[] = $value; |
|
1805 | - } |
|
1806 | - } |
|
1807 | - $alldata = $pall; |
|
1790 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1791 | + foreach ($dall as $value) { |
|
1792 | + $icao = $value['arrival_airport_icao']; |
|
1793 | + $airline = $value['airline_icao']; |
|
1794 | + $ddate = $value['date']; |
|
1795 | + $find = false; |
|
1796 | + foreach ($pall as $pvalue) { |
|
1797 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1798 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1799 | + $find = true; |
|
1800 | + break; |
|
1801 | + } |
|
1802 | + } |
|
1803 | + if ($find === false) { |
|
1804 | + $pall[] = $value; |
|
1805 | + } |
|
1806 | + } |
|
1807 | + $alldata = $pall; |
|
1808 | 1808 | foreach ($alldata as $number) { |
1809 | 1809 | $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']); |
1810 | 1810 | } |
@@ -1873,44 +1873,44 @@ discard block |
||
1873 | 1873 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']); |
1874 | 1874 | } |
1875 | 1875 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1876 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1877 | - $alldata = array(); |
|
1878 | - foreach ($pall as $value) { |
|
1879 | - $icao = $value['airport_departure_icao']; |
|
1880 | - $alldata[$icao] = $value; |
|
1881 | - } |
|
1882 | - foreach ($dall as $value) { |
|
1883 | - $icao = $value['airport_departure_icao']; |
|
1884 | - if (isset($alldata[$icao])) { |
|
1885 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1886 | - } else $alldata[$icao] = $value; |
|
1887 | - } |
|
1888 | - $count = array(); |
|
1889 | - foreach ($alldata as $key => $row) { |
|
1890 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1891 | - } |
|
1876 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1877 | + $alldata = array(); |
|
1878 | + foreach ($pall as $value) { |
|
1879 | + $icao = $value['airport_departure_icao']; |
|
1880 | + $alldata[$icao] = $value; |
|
1881 | + } |
|
1882 | + foreach ($dall as $value) { |
|
1883 | + $icao = $value['airport_departure_icao']; |
|
1884 | + if (isset($alldata[$icao])) { |
|
1885 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1886 | + } else $alldata[$icao] = $value; |
|
1887 | + } |
|
1888 | + $count = array(); |
|
1889 | + foreach ($alldata as $key => $row) { |
|
1890 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1891 | + } |
|
1892 | 1892 | array_multisort($count,SORT_DESC,$alldata); |
1893 | 1893 | foreach ($alldata as $number) { |
1894 | - 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); |
|
1894 | + 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); |
|
1895 | 1895 | } |
1896 | 1896 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
1897 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1897 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1898 | 1898 | $alldata = array(); |
1899 | - foreach ($pall as $value) { |
|
1900 | - $icao = $value['airport_arrival_icao']; |
|
1901 | - $alldata[$icao] = $value; |
|
1902 | - } |
|
1903 | - foreach ($dall as $value) { |
|
1904 | - $icao = $value['airport_arrival_icao']; |
|
1905 | - if (isset($alldata[$icao])) { |
|
1906 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1907 | - } else $alldata[$icao] = $value; |
|
1908 | - } |
|
1909 | - $count = array(); |
|
1910 | - foreach ($alldata as $key => $row) { |
|
1911 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1912 | - } |
|
1913 | - array_multisort($count,SORT_DESC,$alldata); |
|
1899 | + foreach ($pall as $value) { |
|
1900 | + $icao = $value['airport_arrival_icao']; |
|
1901 | + $alldata[$icao] = $value; |
|
1902 | + } |
|
1903 | + foreach ($dall as $value) { |
|
1904 | + $icao = $value['airport_arrival_icao']; |
|
1905 | + if (isset($alldata[$icao])) { |
|
1906 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1907 | + } else $alldata[$icao] = $value; |
|
1908 | + } |
|
1909 | + $count = array(); |
|
1910 | + foreach ($alldata as $key => $row) { |
|
1911 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1912 | + } |
|
1913 | + array_multisort($count,SORT_DESC,$alldata); |
|
1914 | 1914 | foreach ($alldata as $number) { |
1915 | 1915 | 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); |
1916 | 1916 | } |
@@ -1943,45 +1943,45 @@ discard block |
||
1943 | 1943 | } |
1944 | 1944 | echo '...Departure'."\n"; |
1945 | 1945 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1946 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1946 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1947 | 1947 | foreach ($dall as $value) { |
1948 | - $icao = $value['departure_airport_icao']; |
|
1949 | - $ddate = $value['date']; |
|
1950 | - $find = false; |
|
1951 | - foreach ($pall as $pvalue) { |
|
1952 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1953 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1954 | - $find = true; |
|
1955 | - break; |
|
1956 | - } |
|
1957 | - } |
|
1958 | - if ($find === false) { |
|
1959 | - $pall[] = $value; |
|
1960 | - } |
|
1961 | - } |
|
1962 | - $alldata = $pall; |
|
1948 | + $icao = $value['departure_airport_icao']; |
|
1949 | + $ddate = $value['date']; |
|
1950 | + $find = false; |
|
1951 | + foreach ($pall as $pvalue) { |
|
1952 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1953 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1954 | + $find = true; |
|
1955 | + break; |
|
1956 | + } |
|
1957 | + } |
|
1958 | + if ($find === false) { |
|
1959 | + $pall[] = $value; |
|
1960 | + } |
|
1961 | + } |
|
1962 | + $alldata = $pall; |
|
1963 | 1963 | foreach ($alldata as $number) { |
1964 | 1964 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
1965 | 1965 | } |
1966 | 1966 | echo '...Arrival'."\n"; |
1967 | 1967 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1968 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1968 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1969 | 1969 | foreach ($dall as $value) { |
1970 | 1970 | $icao = $value['arrival_airport_icao']; |
1971 | 1971 | $ddate = $value['date']; |
1972 | - $find = false; |
|
1972 | + $find = false; |
|
1973 | 1973 | foreach ($pall as $pvalue) { |
1974 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1975 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1976 | - $find = true; |
|
1977 | - break; |
|
1978 | - } |
|
1979 | - } |
|
1980 | - if ($find === false) { |
|
1981 | - $pall[] = $value; |
|
1982 | - } |
|
1983 | - } |
|
1984 | - $alldata = $pall; |
|
1974 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1975 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1976 | + $find = true; |
|
1977 | + break; |
|
1978 | + } |
|
1979 | + } |
|
1980 | + if ($find === false) { |
|
1981 | + $pall[] = $value; |
|
1982 | + } |
|
1983 | + } |
|
1984 | + $alldata = $pall; |
|
1985 | 1985 | foreach ($alldata as $number) { |
1986 | 1986 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
1987 | 1987 | } |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | $this->db = $Connection->db(); |
18 | 18 | } |
19 | 19 | |
20 | - public function addLastStatsUpdate($type,$stats_date) { |
|
20 | + public function addLastStatsUpdate($type, $stats_date) { |
|
21 | 21 | $query = "DELETE FROM config WHERE name = :type; |
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
23 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
24 | 24 | try { |
25 | 25 | $sth = $this->db->prepare($query); |
26 | 26 | $sth->execute($query_values); |
27 | - } catch(PDOException $e) { |
|
27 | + } catch (PDOException $e) { |
|
28 | 28 | return "error : ".$e->getMessage(); |
29 | 29 | } |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | try { |
35 | 35 | $sth = $this->db->prepare($query); |
36 | 36 | $sth->execute(array(':type' => $type)); |
37 | - } catch(PDOException $e) { |
|
37 | + } catch (PDOException $e) { |
|
38 | 38 | echo "error : ".$e->getMessage(); |
39 | 39 | } |
40 | 40 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | try { |
55 | 55 | $sth = $this->db->prepare($query); |
56 | 56 | $sth->execute(array(':filter_name' => $filter_name)); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | try { |
65 | 65 | $sth = $this->db->prepare($query); |
66 | 66 | $sth->execute(); |
67 | - } catch(PDOException $e) { |
|
67 | + } catch (PDOException $e) { |
|
68 | 68 | return "error : ".$e->getMessage(); |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | try { |
73 | 73 | $sth = $this->db->prepare($query); |
74 | 74 | $sth->execute(array(':filter_name' => $filter_name)); |
75 | - } catch(PDOException $e) { |
|
75 | + } catch (PDOException $e) { |
|
76 | 76 | return "error : ".$e->getMessage(); |
77 | 77 | } |
78 | 78 | } |
@@ -82,43 +82,43 @@ discard block |
||
82 | 82 | try { |
83 | 83 | $sth = $this->db->prepare($query); |
84 | 84 | $sth->execute(array(':filter_name' => $filter_name)); |
85 | - } catch(PDOException $e) { |
|
85 | + } catch (PDOException $e) { |
|
86 | 86 | echo "error : ".$e->getMessage(); |
87 | 87 | } |
88 | 88 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
89 | 89 | return $all; |
90 | 90 | } |
91 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
91 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | 93 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
94 | 94 | try { |
95 | 95 | $sth = $this->db->prepare($query); |
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | echo "error : ".$e->getMessage(); |
99 | 99 | } |
100 | 100 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
101 | 101 | return $all; |
102 | 102 | } |
103 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
103 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | 105 | $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"; |
106 | 106 | try { |
107 | 107 | $sth = $this->db->prepare($query); |
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
109 | + } catch (PDOException $e) { |
|
110 | 110 | echo "error : ".$e->getMessage(); |
111 | 111 | } |
112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
113 | 113 | return $all; |
114 | 114 | } |
115 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
115 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | 117 | $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"; |
118 | 118 | try { |
119 | 119 | $sth = $this->db->prepare($query); |
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | echo "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
134 | 134 | try { |
135 | 135 | $sth = $this->db->prepare($query); |
136 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | - } catch(PDOException $e) { |
|
136 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | echo "error : ".$e->getMessage(); |
139 | 139 | } |
140 | 140 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
141 | 141 | if (empty($all)) { |
142 | 142 | $filters = array('airlines' => array($stats_airline)); |
143 | 143 | if ($filter_name != '') { |
144 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
144 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
145 | 145 | } |
146 | 146 | $Spotter = new Spotter($this->db); |
147 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
147 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
148 | 148 | } |
149 | 149 | return $all; |
150 | 150 | } |
151 | - public function countAllAirlineCountries($limit = true,$filter_name = '') { |
|
151 | + public function countAllAirlineCountries($limit = true, $filter_name = '') { |
|
152 | 152 | global $globalStatsFilters; |
153 | 153 | if ($filter_name == '') $filter_name = $this->filter_name; |
154 | 154 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | try { |
157 | 157 | $sth = $this->db->prepare($query); |
158 | 158 | $sth->execute(array(':filter_name' => $filter_name)); |
159 | - } catch(PDOException $e) { |
|
159 | + } catch (PDOException $e) { |
|
160 | 160 | echo "error : ".$e->getMessage(); |
161 | 161 | } |
162 | 162 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | $Spotter = new Spotter($this->db); |
165 | 165 | $filters = array(); |
166 | 166 | if ($filter_name != '') { |
167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
167 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
168 | 168 | } |
169 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
169 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
170 | 170 | } |
171 | 171 | return $all; |
172 | 172 | } |
173 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
|
173 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') { |
|
174 | 174 | global $globalStatsFilters; |
175 | 175 | if ($filter_name == '') $filter_name = $this->filter_name; |
176 | 176 | 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"; |
177 | 177 | 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"; |
178 | 178 | try { |
179 | 179 | $sth = $this->db->prepare($query); |
180 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | - } catch(PDOException $e) { |
|
180 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
181 | + } catch (PDOException $e) { |
|
182 | 182 | echo "error : ".$e->getMessage(); |
183 | 183 | } |
184 | 184 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
185 | 185 | if (empty($all)) { |
186 | 186 | $filters = array('airlines' => array($stats_airline)); |
187 | 187 | if ($filter_name != '') { |
188 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
188 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
189 | 189 | } |
190 | 190 | $Spotter = new Spotter($this->db); |
191 | 191 | $all = $Spotter->countAllAircraftManufacturers($filters); |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
201 | 201 | try { |
202 | 202 | $sth = $this->db->prepare($query); |
203 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | - } catch(PDOException $e) { |
|
203 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | echo "error : ".$e->getMessage(); |
206 | 206 | } |
207 | 207 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
208 | 208 | if (empty($all)) { |
209 | 209 | $filters = array('airlines' => array($stats_airline)); |
210 | 210 | if ($filter_name != '') { |
211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
211 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
212 | 212 | } |
213 | 213 | $Spotter = new Spotter($this->db); |
214 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
214 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
215 | 215 | } |
216 | 216 | return $all; |
217 | 217 | } |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
223 | 223 | try { |
224 | 224 | $sth = $this->db->prepare($query); |
225 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | - } catch(PDOException $e) { |
|
225 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
226 | + } catch (PDOException $e) { |
|
227 | 227 | echo "error : ".$e->getMessage(); |
228 | 228 | } |
229 | 229 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
230 | 230 | if (empty($all)) { |
231 | 231 | $filters = array('airlines' => array($stats_airline)); |
232 | 232 | if ($filter_name != '') { |
233 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
233 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
234 | 234 | } |
235 | 235 | $Spotter = new Spotter($this->db); |
236 | 236 | $all = $Spotter->countAllDepartureCountries($filters); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | return $all; |
239 | 239 | } |
240 | 240 | |
241 | - public function countAllAirlines($limit = true,$filter_name = '') { |
|
241 | + public function countAllAirlines($limit = true, $filter_name = '') { |
|
242 | 242 | global $globalStatsFilters; |
243 | 243 | if ($filter_name == '') $filter_name = $this->filter_name; |
244 | 244 | 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | try { |
247 | 247 | $sth = $this->db->prepare($query); |
248 | 248 | $sth->execute(array(':filter_name' => $filter_name)); |
249 | - } catch(PDOException $e) { |
|
249 | + } catch (PDOException $e) { |
|
250 | 250 | echo "error : ".$e->getMessage(); |
251 | 251 | } |
252 | 252 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -254,58 +254,58 @@ discard block |
||
254 | 254 | $Spotter = new Spotter($this->db); |
255 | 255 | $filters = array(); |
256 | 256 | if ($filter_name != '') { |
257 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
257 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
258 | 258 | } |
259 | 259 | |
260 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
260 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
261 | 261 | } |
262 | 262 | return $all; |
263 | 263 | } |
264 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
|
264 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') { |
|
265 | 265 | global $globalStatsFilters; |
266 | 266 | if ($filter_name == '') $filter_name = $this->filter_name; |
267 | 267 | 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 aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
268 | 268 | 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 aircraft_registration_count DESC"; |
269 | 269 | try { |
270 | 270 | $sth = $this->db->prepare($query); |
271 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | - } catch(PDOException $e) { |
|
271 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
272 | + } catch (PDOException $e) { |
|
273 | 273 | echo "error : ".$e->getMessage(); |
274 | 274 | } |
275 | 275 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
276 | 276 | if (empty($all)) { |
277 | 277 | $filters = array('airlines' => array($stats_airline)); |
278 | 278 | if ($filter_name != '') { |
279 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
279 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
280 | 280 | } |
281 | 281 | $Spotter = new Spotter($this->db); |
282 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
282 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
283 | 283 | } |
284 | 284 | return $all; |
285 | 285 | } |
286 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
|
286 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') { |
|
287 | 287 | global $globalStatsFilters; |
288 | 288 | if ($filter_name == '') $filter_name = $this->filter_name; |
289 | 289 | 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"; |
290 | 290 | 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"; |
291 | 291 | try { |
292 | 292 | $sth = $this->db->prepare($query); |
293 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
294 | - } catch(PDOException $e) { |
|
293 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
294 | + } catch (PDOException $e) { |
|
295 | 295 | echo "error : ".$e->getMessage(); |
296 | 296 | } |
297 | 297 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
298 | 298 | if (empty($all)) { |
299 | 299 | $filters = array('airlines' => array($stats_airline)); |
300 | 300 | if ($filter_name != '') { |
301 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
301 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
302 | 302 | } |
303 | 303 | $Spotter = new Spotter($this->db); |
304 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
304 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
305 | 305 | } |
306 | 306 | return $all; |
307 | 307 | } |
308 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
|
308 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') { |
|
309 | 309 | $Connection = new Connection(); |
310 | 310 | if ($filter_name == '') $filter_name = $this->filter_name; |
311 | 311 | if ($Connection->tableExists('countries')) { |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | 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"; |
314 | 314 | try { |
315 | 315 | $sth = $this->db->prepare($query); |
316 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
317 | - } catch(PDOException $e) { |
|
316 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
317 | + } catch (PDOException $e) { |
|
318 | 318 | echo "error : ".$e->getMessage(); |
319 | 319 | } |
320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -329,70 +329,70 @@ discard block |
||
329 | 329 | return array(); |
330 | 330 | } |
331 | 331 | } |
332 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
|
332 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') { |
|
333 | 333 | global $globalStatsFilters; |
334 | 334 | if ($filter_name == '') $filter_name = $this->filter_name; |
335 | 335 | 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"; |
336 | 336 | 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"; |
337 | 337 | try { |
338 | 338 | $sth = $this->db->prepare($query); |
339 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | - } catch(PDOException $e) { |
|
339 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
340 | + } catch (PDOException $e) { |
|
341 | 341 | echo "error : ".$e->getMessage(); |
342 | 342 | } |
343 | 343 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
344 | 344 | if (empty($all)) { |
345 | 345 | $filters = array('airlines' => array($stats_airline)); |
346 | 346 | if ($filter_name != '') { |
347 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
347 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
348 | 348 | } |
349 | 349 | $Spotter = new Spotter($this->db); |
350 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
350 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
351 | 351 | } |
352 | 352 | return $all; |
353 | 353 | } |
354 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
|
354 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') { |
|
355 | 355 | global $globalStatsFilters; |
356 | 356 | if ($filter_name == '') $filter_name = $this->filter_name; |
357 | 357 | 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"; |
358 | 358 | 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"; |
359 | 359 | try { |
360 | 360 | $sth = $this->db->prepare($query); |
361 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | - } catch(PDOException $e) { |
|
361 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | echo "error : ".$e->getMessage(); |
364 | 364 | } |
365 | 365 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
366 | 366 | if (empty($all)) { |
367 | 367 | $filters = array('airlines' => array($stats_airline)); |
368 | 368 | if ($filter_name != '') { |
369 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
369 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
370 | 370 | } |
371 | 371 | $Spotter = new Spotter($this->db); |
372 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
372 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
373 | 373 | } |
374 | 374 | return $all; |
375 | 375 | } |
376 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
376 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
377 | 377 | global $globalStatsFilters; |
378 | 378 | if ($filter_name == '') $filter_name = $this->filter_name; |
379 | 379 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE 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"; |
380 | 380 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
381 | 381 | try { |
382 | 382 | $sth = $this->db->prepare($query); |
383 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | - } catch(PDOException $e) { |
|
383 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
384 | + } catch (PDOException $e) { |
|
385 | 385 | echo "error : ".$e->getMessage(); |
386 | 386 | } |
387 | 387 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
388 | 388 | if (empty($all)) { |
389 | 389 | $filters = array('airlines' => array($stats_airline)); |
390 | 390 | if ($filter_name != '') { |
391 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
391 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
392 | 392 | } |
393 | 393 | $Spotter = new Spotter($this->db); |
394 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
394 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
395 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
396 | 396 | $all = array(); |
397 | 397 | foreach ($pall as $value) { |
398 | 398 | $icao = $value['airport_departure_icao']; |
@@ -409,30 +409,30 @@ discard block |
||
409 | 409 | foreach ($all as $key => $row) { |
410 | 410 | $count[$key] = $row['airport_departure_icao_count']; |
411 | 411 | } |
412 | - array_multisort($count,SORT_DESC,$all); |
|
412 | + array_multisort($count, SORT_DESC, $all); |
|
413 | 413 | } |
414 | 414 | return $all; |
415 | 415 | } |
416 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
416 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
417 | 417 | global $globalStatsFilters; |
418 | 418 | if ($filter_name == '') $filter_name = $this->filter_name; |
419 | 419 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE 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"; |
420 | 420 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
421 | 421 | try { |
422 | 422 | $sth = $this->db->prepare($query); |
423 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
424 | - } catch(PDOException $e) { |
|
423 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | echo "error : ".$e->getMessage(); |
426 | 426 | } |
427 | 427 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
428 | 428 | if (empty($all)) { |
429 | 429 | $filters = array('airlines' => array($stats_airline)); |
430 | 430 | if ($filter_name != '') { |
431 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
431 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
432 | 432 | } |
433 | 433 | $Spotter = new Spotter($this->db); |
434 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
435 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
434 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
435 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
436 | 436 | $all = array(); |
437 | 437 | foreach ($pall as $value) { |
438 | 438 | $icao = $value['airport_arrival_icao']; |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | foreach ($all as $key => $row) { |
450 | 450 | $count[$key] = $row['airport_arrival_icao_count']; |
451 | 451 | } |
452 | - array_multisort($count,SORT_DESC,$all); |
|
452 | + array_multisort($count, SORT_DESC, $all); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | return $all; |
456 | 456 | } |
457 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
457 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
458 | 458 | global $globalDBdriver, $globalStatsFilters; |
459 | 459 | if ($filter_name == '') $filter_name = $this->filter_name; |
460 | 460 | if ($globalDBdriver == 'mysql') { |
@@ -464,18 +464,18 @@ discard block |
||
464 | 464 | 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"; |
465 | 465 | 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"; |
466 | 466 | } |
467 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
467 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
468 | 468 | try { |
469 | 469 | $sth = $this->db->prepare($query); |
470 | 470 | $sth->execute($query_data); |
471 | - } catch(PDOException $e) { |
|
471 | + } catch (PDOException $e) { |
|
472 | 472 | echo "error : ".$e->getMessage(); |
473 | 473 | } |
474 | 474 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
475 | 475 | if (empty($all)) { |
476 | 476 | $filters = array('airlines' => array($stats_airline)); |
477 | 477 | if ($filter_name != '') { |
478 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
478 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
479 | 479 | } |
480 | 480 | $Spotter = new Spotter($this->db); |
481 | 481 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -484,29 +484,29 @@ discard block |
||
484 | 484 | return $all; |
485 | 485 | } |
486 | 486 | |
487 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
487 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
488 | 488 | global $globalStatsFilters; |
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
491 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
491 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
492 | 492 | try { |
493 | 493 | $sth = $this->db->prepare($query); |
494 | 494 | $sth->execute($query_data); |
495 | - } catch(PDOException $e) { |
|
495 | + } catch (PDOException $e) { |
|
496 | 496 | echo "error : ".$e->getMessage(); |
497 | 497 | } |
498 | 498 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
499 | 499 | if (empty($all)) { |
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
502 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
503 | 503 | } |
504 | 504 | $Spotter = new Spotter($this->db); |
505 | 505 | $all = $Spotter->countAllDatesLastMonth($filters); |
506 | 506 | } |
507 | 507 | return $all; |
508 | 508 | } |
509 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
509 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
510 | 510 | global $globalDBdriver, $globalStatsFilters; |
511 | 511 | if ($filter_name == '') $filter_name = $this->filter_name; |
512 | 512 | if ($globalDBdriver == 'mysql') { |
@@ -514,40 +514,40 @@ discard block |
||
514 | 514 | } else { |
515 | 515 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
516 | 516 | } |
517 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
517 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
518 | 518 | try { |
519 | 519 | $sth = $this->db->prepare($query); |
520 | 520 | $sth->execute($query_data); |
521 | - } catch(PDOException $e) { |
|
521 | + } catch (PDOException $e) { |
|
522 | 522 | echo "error : ".$e->getMessage(); |
523 | 523 | } |
524 | 524 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
525 | 525 | if (empty($all)) { |
526 | 526 | $filters = array('airlines' => array($stats_airline)); |
527 | 527 | if ($filter_name != '') { |
528 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
528 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
529 | 529 | } |
530 | 530 | $Spotter = new Spotter($this->db); |
531 | 531 | $all = $Spotter->countAllDatesLast7Days($filters); |
532 | 532 | } |
533 | 533 | return $all; |
534 | 534 | } |
535 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
535 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
536 | 536 | global $globalStatsFilters; |
537 | 537 | if ($filter_name == '') $filter_name = $this->filter_name; |
538 | 538 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
539 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
539 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
540 | 540 | try { |
541 | 541 | $sth = $this->db->prepare($query); |
542 | 542 | $sth->execute($query_data); |
543 | - } catch(PDOException $e) { |
|
543 | + } catch (PDOException $e) { |
|
544 | 544 | echo "error : ".$e->getMessage(); |
545 | 545 | } |
546 | 546 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
547 | 547 | if (empty($all)) { |
548 | 548 | $filters = array('airlines' => array($stats_airline)); |
549 | 549 | if ($filter_name != '') { |
550 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
550 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
551 | 551 | } |
552 | 552 | $Spotter = new Spotter($this->db); |
553 | 553 | $all = $Spotter->countAllDates($filters); |
@@ -562,35 +562,35 @@ discard block |
||
562 | 562 | try { |
563 | 563 | $sth = $this->db->prepare($query); |
564 | 564 | $sth->execute($query_data); |
565 | - } catch(PDOException $e) { |
|
565 | + } catch (PDOException $e) { |
|
566 | 566 | echo "error : ".$e->getMessage(); |
567 | 567 | } |
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | 569 | if (empty($all)) { |
570 | 570 | $filters = array(); |
571 | 571 | if ($filter_name != '') { |
572 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
572 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
573 | 573 | } |
574 | 574 | $Spotter = new Spotter($this->db); |
575 | 575 | $all = $Spotter->countAllDatesByAirlines($filters); |
576 | 576 | } |
577 | 577 | return $all; |
578 | 578 | } |
579 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
579 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
580 | 580 | global $globalStatsFilters; |
581 | 581 | if ($filter_name == '') $filter_name = $this->filter_name; |
582 | 582 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
583 | 583 | try { |
584 | 584 | $sth = $this->db->prepare($query); |
585 | 585 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
586 | - } catch(PDOException $e) { |
|
586 | + } catch (PDOException $e) { |
|
587 | 587 | echo "error : ".$e->getMessage(); |
588 | 588 | } |
589 | 589 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
590 | 590 | if (empty($all)) { |
591 | 591 | $filters = array('airlines' => array($stats_airline)); |
592 | 592 | if ($filter_name != '') { |
593 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
593 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
594 | 594 | } |
595 | 595 | $Spotter = new Spotter($this->db); |
596 | 596 | $all = $Spotter->countAllMonths($filters); |
@@ -604,21 +604,21 @@ discard block |
||
604 | 604 | try { |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':filter_name' => $filter_name)); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | echo "error : ".$e->getMessage(); |
609 | 609 | } |
610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
611 | 611 | if (empty($all)) { |
612 | 612 | $filters = array(); |
613 | 613 | if ($filter_name != '') { |
614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
614 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
615 | 615 | } |
616 | 616 | $Spotter = new Spotter($this->db); |
617 | 617 | $all = $Spotter->countAllMilitaryMonths($filters); |
618 | 618 | } |
619 | 619 | return $all; |
620 | 620 | } |
621 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
621 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
622 | 622 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
623 | 623 | if ($filter_name == '') $filter_name = $this->filter_name; |
624 | 624 | 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"; |
@@ -635,17 +635,17 @@ discard block |
||
635 | 635 | try { |
636 | 636 | $sth = $this->db->prepare($query); |
637 | 637 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
638 | - } catch(PDOException $e) { |
|
638 | + } catch (PDOException $e) { |
|
639 | 639 | echo "error : ".$e->getMessage(); |
640 | 640 | } |
641 | 641 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
642 | 642 | if (empty($all)) { |
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
645 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
646 | 646 | } |
647 | 647 | $Spotter = new Spotter($this->db); |
648 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
648 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
649 | 649 | } |
650 | 650 | return $all; |
651 | 651 | } |
@@ -653,11 +653,11 @@ discard block |
||
653 | 653 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
654 | 654 | global $globalStatsFilters; |
655 | 655 | if ($filter_name == '') $filter_name = $this->filter_name; |
656 | - $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
|
656 | + $all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name); |
|
657 | 657 | if (empty($all)) { |
658 | 658 | $filters = array('airlines' => array($stats_airline)); |
659 | 659 | if ($filter_name != '') { |
660 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
660 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
661 | 661 | } |
662 | 662 | $Spotter = new Spotter($this->db); |
663 | 663 | $all = $Spotter->countOverallFlights($filters); |
@@ -667,39 +667,39 @@ discard block |
||
667 | 667 | public function countOverallMilitaryFlights($filter_name = '') { |
668 | 668 | global $globalStatsFilters; |
669 | 669 | if ($filter_name == '') $filter_name = $this->filter_name; |
670 | - $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
|
670 | + $all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name); |
|
671 | 671 | if (empty($all)) { |
672 | 672 | $filters = array(); |
673 | 673 | if ($filter_name != '') { |
674 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
674 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
675 | 675 | } |
676 | 676 | $Spotter = new Spotter($this->db); |
677 | 677 | $all = $Spotter->countOverallMilitaryFlights($filters); |
678 | 678 | } |
679 | 679 | return $all; |
680 | 680 | } |
681 | - public function countOverallArrival($stats_airline = '',$filter_name = '') { |
|
681 | + public function countOverallArrival($stats_airline = '', $filter_name = '') { |
|
682 | 682 | global $globalStatsFilters; |
683 | 683 | if ($filter_name == '') $filter_name = $this->filter_name; |
684 | - $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
|
684 | + $all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name); |
|
685 | 685 | if (empty($all)) { |
686 | 686 | $filters = array('airlines' => array($stats_airline)); |
687 | 687 | if ($filter_name != '') { |
688 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
688 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
689 | 689 | } |
690 | 690 | $Spotter = new Spotter($this->db); |
691 | 691 | $all = $Spotter->countOverallArrival($filters); |
692 | 692 | } |
693 | 693 | return $all; |
694 | 694 | } |
695 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
|
695 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '') { |
|
696 | 696 | global $globalStatsFilters; |
697 | 697 | if ($filter_name == '') $filter_name = $this->filter_name; |
698 | - $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
|
698 | + $all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name); |
|
699 | 699 | if (empty($all)) { |
700 | 700 | $filters = array('airlines' => array($stats_airline)); |
701 | 701 | if ($filter_name != '') { |
702 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
702 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
703 | 703 | } |
704 | 704 | $Spotter = new Spotter($this->db); |
705 | 705 | $all = $Spotter->countOverallAircrafts($filters); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | try { |
714 | 714 | $sth = $this->db->prepare($query); |
715 | 715 | $sth->execute(array(':filter_name' => $filter_name)); |
716 | - } catch(PDOException $e) { |
|
716 | + } catch (PDOException $e) { |
|
717 | 717 | echo "error : ".$e->getMessage(); |
718 | 718 | } |
719 | 719 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -722,14 +722,14 @@ discard block |
||
722 | 722 | if (empty($all)) { |
723 | 723 | $filters = array(); |
724 | 724 | if ($filter_name != '') { |
725 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
725 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
726 | 726 | } |
727 | 727 | $Spotter = new Spotter($this->db); |
728 | 728 | $all = $Spotter->countOverallAirlines($filters); |
729 | 729 | } |
730 | 730 | return $all; |
731 | 731 | } |
732 | - public function countOverallOwners($stats_airline = '',$filter_name = '') { |
|
732 | + public function countOverallOwners($stats_airline = '', $filter_name = '') { |
|
733 | 733 | global $globalStatsFilters; |
734 | 734 | if ($filter_name == '') $filter_name = $this->filter_name; |
735 | 735 | /* |
@@ -743,25 +743,25 @@ discard block |
||
743 | 743 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
744 | 744 | $all = $result[0]['nb_owner']; |
745 | 745 | */ |
746 | - $all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name); |
|
746 | + $all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name); |
|
747 | 747 | if (empty($all)) { |
748 | 748 | $filters = array('airlines' => array($stats_airline)); |
749 | 749 | if ($filter_name != '') { |
750 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
750 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
751 | 751 | } |
752 | 752 | $Spotter = new Spotter($this->db); |
753 | 753 | $all = $Spotter->countOverallOwners($filters); |
754 | 754 | } |
755 | 755 | return $all; |
756 | 756 | } |
757 | - public function countOverallPilots($stats_airline = '',$filter_name = '') { |
|
757 | + public function countOverallPilots($stats_airline = '', $filter_name = '') { |
|
758 | 758 | global $globalStatsFilters; |
759 | 759 | if ($filter_name == '') $filter_name = $this->filter_name; |
760 | - $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
|
760 | + $all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name); |
|
761 | 761 | if (empty($all)) { |
762 | 762 | $filters = array('airlines' => array($stats_airline)); |
763 | 763 | if ($filter_name != '') { |
764 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
764 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
765 | 765 | } |
766 | 766 | $Spotter = new Spotter($this->db); |
767 | 767 | $all = $Spotter->countOverallPilots($filters); |
@@ -769,33 +769,33 @@ discard block |
||
769 | 769 | return $all; |
770 | 770 | } |
771 | 771 | |
772 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
772 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
773 | 773 | if ($filter_name == '') $filter_name = $this->filter_name; |
774 | 774 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
775 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
775 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
776 | 776 | try { |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute($query_values); |
779 | - } catch(PDOException $e) { |
|
779 | + } catch (PDOException $e) { |
|
780 | 780 | echo "error : ".$e->getMessage(); |
781 | 781 | } |
782 | 782 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
783 | 783 | return $all; |
784 | 784 | } |
785 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
785 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
786 | 786 | if ($filter_name == '') $filter_name = $this->filter_name; |
787 | 787 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
788 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
788 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
789 | 789 | try { |
790 | 790 | $sth = $this->db->prepare($query); |
791 | 791 | $sth->execute($query_values); |
792 | - } catch(PDOException $e) { |
|
792 | + } catch (PDOException $e) { |
|
793 | 793 | echo "error : ".$e->getMessage(); |
794 | 794 | } |
795 | 795 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
796 | 796 | return $all; |
797 | 797 | } |
798 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
|
798 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') { |
|
799 | 799 | if ($filter_name == '') $filter_name = $this->filter_name; |
800 | 800 | global $globalArchiveMonths, $globalDBdriver; |
801 | 801 | if ($globalDBdriver == 'mysql') { |
@@ -803,11 +803,11 @@ discard block |
||
803 | 803 | } else { |
804 | 804 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
805 | 805 | } |
806 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
806 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
807 | 807 | try { |
808 | 808 | $sth = $this->db->prepare($query); |
809 | 809 | $sth->execute($query_values); |
810 | - } catch(PDOException $e) { |
|
810 | + } catch (PDOException $e) { |
|
811 | 811 | echo "error : ".$e->getMessage(); |
812 | 812 | } |
813 | 813 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | try { |
826 | 826 | $sth = $this->db->prepare($query); |
827 | 827 | $sth->execute($query_values); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | echo "error : ".$e->getMessage(); |
830 | 830 | } |
831 | 831 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | try { |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
845 | - } catch(PDOException $e) { |
|
845 | + } catch (PDOException $e) { |
|
846 | 846 | echo "error : ".$e->getMessage(); |
847 | 847 | } |
848 | 848 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | try { |
860 | 860 | $sth = $this->db->prepare($query); |
861 | 861 | $sth->execute(array(':filter_name' => $filter_name)); |
862 | - } catch(PDOException $e) { |
|
862 | + } catch (PDOException $e) { |
|
863 | 863 | echo "error : ".$e->getMessage(); |
864 | 864 | } |
865 | 865 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | try { |
877 | 877 | $sth = $this->db->prepare($query); |
878 | 878 | $sth->execute(array(':filter_name' => $filter_name)); |
879 | - } catch(PDOException $e) { |
|
879 | + } catch (PDOException $e) { |
|
880 | 880 | echo "error : ".$e->getMessage(); |
881 | 881 | } |
882 | 882 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -893,14 +893,14 @@ discard block |
||
893 | 893 | try { |
894 | 894 | $sth = $this->db->prepare($query); |
895 | 895 | $sth->execute(array(':filter_name' => $filter_name)); |
896 | - } catch(PDOException $e) { |
|
896 | + } catch (PDOException $e) { |
|
897 | 897 | echo "error : ".$e->getMessage(); |
898 | 898 | } |
899 | 899 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
900 | 900 | return $all[0]['total']; |
901 | 901 | } |
902 | 902 | |
903 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
903 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
904 | 904 | global $globalDBdriver; |
905 | 905 | if ($filter_name == '') $filter_name = $this->filter_name; |
906 | 906 | if ($globalDBdriver == 'mysql') { |
@@ -908,15 +908,15 @@ discard block |
||
908 | 908 | } else { |
909 | 909 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
910 | 910 | } |
911 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
911 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
912 | 912 | try { |
913 | 913 | $sth = $this->db->prepare($query); |
914 | 914 | $sth->execute($query_values); |
915 | - } catch(PDOException $e) { |
|
915 | + } catch (PDOException $e) { |
|
916 | 916 | return "error : ".$e->getMessage(); |
917 | 917 | } |
918 | 918 | } |
919 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
919 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
920 | 920 | global $globalDBdriver; |
921 | 921 | if ($filter_name == '') $filter_name = $this->filter_name; |
922 | 922 | if ($globalDBdriver == 'mysql') { |
@@ -925,219 +925,219 @@ discard block |
||
925 | 925 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
926 | 926 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
927 | 927 | } |
928 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
928 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
929 | 929 | try { |
930 | 930 | $sth = $this->db->prepare($query); |
931 | 931 | $sth->execute($query_values); |
932 | - } catch(PDOException $e) { |
|
932 | + } catch (PDOException $e) { |
|
933 | 933 | return "error : ".$e->getMessage(); |
934 | 934 | } |
935 | 935 | } |
936 | - public function getStatsSource($date,$stats_type = '') { |
|
936 | + public function getStatsSource($date, $stats_type = '') { |
|
937 | 937 | if ($stats_type == '') { |
938 | 938 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
939 | 939 | $query_values = array(':date' => $date); |
940 | 940 | } else { |
941 | 941 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
942 | - $query_values = array(':date' => $date,':stats_type' => $stats_type); |
|
942 | + $query_values = array(':date' => $date, ':stats_type' => $stats_type); |
|
943 | 943 | } |
944 | 944 | try { |
945 | 945 | $sth = $this->db->prepare($query); |
946 | 946 | $sth->execute($query_values); |
947 | - } catch(PDOException $e) { |
|
947 | + } catch (PDOException $e) { |
|
948 | 948 | echo "error : ".$e->getMessage(); |
949 | 949 | } |
950 | 950 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
951 | 951 | return $all; |
952 | 952 | } |
953 | 953 | |
954 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
954 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
955 | 955 | global $globalDBdriver; |
956 | 956 | if ($globalDBdriver == 'mysql') { |
957 | 957 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
958 | 958 | } else { |
959 | 959 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
960 | 960 | } |
961 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
961 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
962 | 962 | try { |
963 | 963 | $sth = $this->db->prepare($query); |
964 | 964 | $sth->execute($query_values); |
965 | - } catch(PDOException $e) { |
|
965 | + } catch (PDOException $e) { |
|
966 | 966 | return "error : ".$e->getMessage(); |
967 | 967 | } |
968 | 968 | } |
969 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
969 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
970 | 970 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
971 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
971 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
972 | 972 | try { |
973 | 973 | $sth = $this->db->prepare($query); |
974 | 974 | $sth->execute($query_values); |
975 | - } catch(PDOException $e) { |
|
975 | + } catch (PDOException $e) { |
|
976 | 976 | return "error : ".$e->getMessage(); |
977 | 977 | } |
978 | 978 | } |
979 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
|
979 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') { |
|
980 | 980 | global $globalDBdriver; |
981 | 981 | if ($globalDBdriver == 'mysql') { |
982 | 982 | $query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
983 | 983 | } else { |
984 | 984 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
985 | 985 | } |
986 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
986 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | 987 | try { |
988 | 988 | $sth = $this->db->prepare($query); |
989 | 989 | $sth->execute($query_values); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error : ".$e->getMessage(); |
992 | 992 | } |
993 | 993 | } |
994 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
|
994 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') { |
|
995 | 995 | global $globalDBdriver; |
996 | 996 | if ($globalDBdriver == 'mysql') { |
997 | 997 | $query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
998 | 998 | } else { |
999 | 999 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1000 | 1000 | } |
1001 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1001 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | 1002 | try { |
1003 | 1003 | $sth = $this->db->prepare($query); |
1004 | 1004 | $sth->execute($query_values); |
1005 | - } catch(PDOException $e) { |
|
1005 | + } catch (PDOException $e) { |
|
1006 | 1006 | return "error : ".$e->getMessage(); |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
|
1009 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') { |
|
1010 | 1010 | global $globalDBdriver; |
1011 | 1011 | if ($globalDBdriver == 'mysql') { |
1012 | 1012 | $query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
1013 | 1013 | } else { |
1014 | 1014 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
1015 | 1015 | } |
1016 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1016 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1017 | 1017 | try { |
1018 | 1018 | $sth = $this->db->prepare($query); |
1019 | 1019 | $sth->execute($query_values); |
1020 | - } catch(PDOException $e) { |
|
1020 | + } catch (PDOException $e) { |
|
1021 | 1021 | return "error : ".$e->getMessage(); |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
1024 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
1025 | 1025 | global $globalDBdriver; |
1026 | 1026 | if ($globalDBdriver == 'mysql') { |
1027 | 1027 | $query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline"; |
1028 | 1028 | } else { |
1029 | 1029 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1030 | 1030 | } |
1031 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1031 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1032 | 1032 | try { |
1033 | 1033 | $sth = $this->db->prepare($query); |
1034 | 1034 | $sth->execute($query_values); |
1035 | - } catch(PDOException $e) { |
|
1035 | + } catch (PDOException $e) { |
|
1036 | 1036 | return "error : ".$e->getMessage(); |
1037 | 1037 | } |
1038 | 1038 | } |
1039 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
|
1039 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') { |
|
1040 | 1040 | global $globalDBdriver; |
1041 | 1041 | if ($globalDBdriver == 'mysql') { |
1042 | 1042 | $query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name"; |
1043 | 1043 | } else { |
1044 | 1044 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1045 | 1045 | } |
1046 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1046 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1047 | 1047 | try { |
1048 | 1048 | $sth = $this->db->prepare($query); |
1049 | 1049 | $sth->execute($query_values); |
1050 | - } catch(PDOException $e) { |
|
1050 | + } catch (PDOException $e) { |
|
1051 | 1051 | return "error : ".$e->getMessage(); |
1052 | 1052 | } |
1053 | 1053 | } |
1054 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
|
1054 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1055 | 1055 | global $globalDBdriver; |
1056 | 1056 | if ($globalDBdriver == 'mysql') { |
1057 | 1057 | $query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
1058 | 1058 | } else { |
1059 | 1059 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1060 | 1060 | } |
1061 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1061 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1062 | 1062 | try { |
1063 | 1063 | $sth = $this->db->prepare($query); |
1064 | 1064 | $sth->execute($query_values); |
1065 | - } catch(PDOException $e) { |
|
1065 | + } catch (PDOException $e) { |
|
1066 | 1066 | return "error : ".$e->getMessage(); |
1067 | 1067 | } |
1068 | 1068 | } |
1069 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
|
1069 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '') { |
|
1070 | 1070 | global $globalDBdriver; |
1071 | 1071 | if ($globalDBdriver == 'mysql') { |
1072 | 1072 | $query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name"; |
1073 | 1073 | } else { |
1074 | 1074 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1075 | 1075 | } |
1076 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1076 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
1077 | 1077 | try { |
1078 | 1078 | $sth = $this->db->prepare($query); |
1079 | 1079 | $sth->execute($query_values); |
1080 | - } catch(PDOException $e) { |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | return "error : ".$e->getMessage(); |
1082 | 1082 | } |
1083 | 1083 | } |
1084 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1084 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1085 | 1085 | global $globalDBdriver; |
1086 | 1086 | if ($globalDBdriver == 'mysql') { |
1087 | 1087 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = departure+:departure"; |
1088 | 1088 | } else { |
1089 | 1089 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1090 | 1090 | } |
1091 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1091 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1092 | 1092 | try { |
1093 | 1093 | $sth = $this->db->prepare($query); |
1094 | 1094 | $sth->execute($query_values); |
1095 | - } catch(PDOException $e) { |
|
1095 | + } catch (PDOException $e) { |
|
1096 | 1096 | return "error : ".$e->getMessage(); |
1097 | 1097 | } |
1098 | 1098 | } |
1099 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1099 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1100 | 1100 | global $globalDBdriver; |
1101 | 1101 | if ($globalDBdriver == 'mysql') { |
1102 | 1102 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = :departure"; |
1103 | 1103 | } else { |
1104 | 1104 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1105 | 1105 | } |
1106 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1106 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1107 | 1107 | try { |
1108 | 1108 | $sth = $this->db->prepare($query); |
1109 | 1109 | $sth->execute($query_values); |
1110 | - } catch(PDOException $e) { |
|
1110 | + } catch (PDOException $e) { |
|
1111 | 1111 | return "error : ".$e->getMessage(); |
1112 | 1112 | } |
1113 | 1113 | } |
1114 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1114 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1115 | 1115 | global $globalDBdriver; |
1116 | 1116 | if ($globalDBdriver == 'mysql') { |
1117 | 1117 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival"; |
1118 | 1118 | } else { |
1119 | 1119 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1120 | 1120 | } |
1121 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1121 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1122 | 1122 | try { |
1123 | 1123 | $sth = $this->db->prepare($query); |
1124 | 1124 | $sth->execute($query_values); |
1125 | - } catch(PDOException $e) { |
|
1125 | + } catch (PDOException $e) { |
|
1126 | 1126 | return "error : ".$e->getMessage(); |
1127 | 1127 | } |
1128 | 1128 | } |
1129 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1129 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1130 | 1130 | global $globalDBdriver; |
1131 | 1131 | if ($globalDBdriver == 'mysql') { |
1132 | 1132 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = :arrival"; |
1133 | 1133 | } else { |
1134 | 1134 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1135 | 1135 | } |
1136 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1136 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1137 | 1137 | try { |
1138 | 1138 | $sth = $this->db->prepare($query); |
1139 | 1139 | $sth->execute($query_values); |
1140 | - } catch(PDOException $e) { |
|
1140 | + } catch (PDOException $e) { |
|
1141 | 1141 | return "error : ".$e->getMessage(); |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | try { |
1149 | 1149 | $sth = $this->db->prepare($query); |
1150 | 1150 | $sth->execute($query_values); |
1151 | - } catch(PDOException $e) { |
|
1151 | + } catch (PDOException $e) { |
|
1152 | 1152 | return "error : ".$e->getMessage(); |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $sth = $this->db->prepare($query); |
1160 | 1160 | $sth->execute($query_values); |
1161 | - } catch(PDOException $e) { |
|
1161 | + } catch (PDOException $e) { |
|
1162 | 1162 | return "error : ".$e->getMessage(); |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1168,13 +1168,13 @@ discard block |
||
1168 | 1168 | try { |
1169 | 1169 | $sth = $this->db->prepare($query); |
1170 | 1170 | $sth->execute($query_values); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | public function addOldStats() { |
1177 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1177 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats; |
|
1178 | 1178 | $Common = new Common(); |
1179 | 1179 | $Connection = new Connection(); |
1180 | 1180 | date_default_timezone_set('UTC'); |
@@ -1407,40 +1407,40 @@ discard block |
||
1407 | 1407 | $last_update_day = $last_update[0]['value']; |
1408 | 1408 | } else $last_update_day = '2012-12-12 12:12:12'; |
1409 | 1409 | $Spotter = new Spotter($this->db); |
1410 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1410 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1411 | 1411 | foreach ($alldata as $number) { |
1412 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
|
1412 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']); |
|
1413 | 1413 | } |
1414 | 1414 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
1415 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1415 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1416 | 1416 | foreach ($alldata as $number) { |
1417 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
|
1417 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']); |
|
1418 | 1418 | } |
1419 | 1419 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
1420 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1420 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1421 | 1421 | foreach ($alldata as $number) { |
1422 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
|
1422 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']); |
|
1423 | 1423 | } |
1424 | 1424 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
1425 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1425 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1426 | 1426 | foreach ($alldata as $number) { |
1427 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1427 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1428 | 1428 | } |
1429 | 1429 | if ($globalDebug) echo 'Count all owners...'."\n"; |
1430 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1430 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1431 | 1431 | foreach ($alldata as $number) { |
1432 | - $this->addStatOwner($number['owner_name'],$number['owner_count']); |
|
1432 | + $this->addStatOwner($number['owner_name'], $number['owner_count']); |
|
1433 | 1433 | } |
1434 | 1434 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
1435 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1435 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1436 | 1436 | foreach ($alldata as $number) { |
1437 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']); |
|
1437 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source']); |
|
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1441 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1441 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1442 | 1442 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1443 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1443 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1444 | 1444 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1445 | 1445 | $alldata = array(); |
1446 | 1446 | |
@@ -1458,14 +1458,14 @@ discard block |
||
1458 | 1458 | foreach ($alldata as $key => $row) { |
1459 | 1459 | $count[$key] = $row['airport_departure_icao_count']; |
1460 | 1460 | } |
1461 | - array_multisort($count,SORT_DESC,$alldata); |
|
1461 | + array_multisort($count, SORT_DESC, $alldata); |
|
1462 | 1462 | foreach ($alldata as $number) { |
1463 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
|
1463 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']); |
|
1464 | 1464 | } |
1465 | 1465 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1466 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1466 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1467 | 1467 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1468 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1468 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1469 | 1469 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1470 | 1470 | $alldata = array(); |
1471 | 1471 | foreach ($pall as $value) { |
@@ -1482,16 +1482,16 @@ discard block |
||
1482 | 1482 | foreach ($alldata as $key => $row) { |
1483 | 1483 | $count[$key] = $row['airport_arrival_icao_count']; |
1484 | 1484 | } |
1485 | - array_multisort($count,SORT_DESC,$alldata); |
|
1485 | + array_multisort($count, SORT_DESC, $alldata); |
|
1486 | 1486 | foreach ($alldata as $number) { |
1487 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
|
1487 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']); |
|
1488 | 1488 | } |
1489 | 1489 | if ($Connection->tableExists('countries')) { |
1490 | 1490 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
1491 | 1491 | $SpotterArchive = new SpotterArchive(); |
1492 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
1492 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1493 | 1493 | foreach ($alldata as $number) { |
1494 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']); |
|
1494 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']); |
|
1495 | 1495 | } |
1496 | 1496 | } |
1497 | 1497 | |
@@ -1505,37 +1505,37 @@ discard block |
||
1505 | 1505 | $lastyear = false; |
1506 | 1506 | foreach ($alldata as $number) { |
1507 | 1507 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1508 | - $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']))); |
|
1508 | + $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']))); |
|
1509 | 1509 | } |
1510 | 1510 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
1511 | 1511 | $alldata = $Spotter->countAllMilitaryMonths(); |
1512 | 1512 | foreach ($alldata as $number) { |
1513 | - $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']))); |
|
1513 | + $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']))); |
|
1514 | 1514 | } |
1515 | 1515 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
1516 | 1516 | $alldata = $Spotter->countAllMonthsOwners(); |
1517 | 1517 | foreach ($alldata as $number) { |
1518 | - $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']))); |
|
1518 | + $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']))); |
|
1519 | 1519 | } |
1520 | 1520 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
1521 | 1521 | $alldata = $Spotter->countAllMonthsPilots(); |
1522 | 1522 | foreach ($alldata as $number) { |
1523 | - $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']))); |
|
1523 | + $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']))); |
|
1524 | 1524 | } |
1525 | 1525 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
1526 | 1526 | $alldata = $Spotter->countAllMonthsAirlines(); |
1527 | 1527 | foreach ($alldata as $number) { |
1528 | - $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']))); |
|
1528 | + $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']))); |
|
1529 | 1529 | } |
1530 | 1530 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
1531 | 1531 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1532 | 1532 | foreach ($alldata as $number) { |
1533 | - $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']))); |
|
1533 | + $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']))); |
|
1534 | 1534 | } |
1535 | 1535 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
1536 | 1536 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1537 | 1537 | foreach ($alldata as $number) { |
1538 | - $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']))); |
|
1538 | + $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']))); |
|
1539 | 1539 | } |
1540 | 1540 | if ($globalDebug) echo 'Airports data...'."\n"; |
1541 | 1541 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1580,7 +1580,7 @@ discard block |
||
1580 | 1580 | } |
1581 | 1581 | $alldata = $pall; |
1582 | 1582 | foreach ($alldata as $number) { |
1583 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1583 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1584 | 1584 | } |
1585 | 1585 | echo '...Arrival'."\n"; |
1586 | 1586 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | } |
1623 | 1623 | $alldata = $pall; |
1624 | 1624 | foreach ($alldata as $number) { |
1625 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1625 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | echo 'Flights data...'."\n"; |
@@ -1630,28 +1630,28 @@ discard block |
||
1630 | 1630 | echo '-> countAllDatesLastMonth...'."\n"; |
1631 | 1631 | $alldata = $Spotter->countAllDatesLastMonth(); |
1632 | 1632 | foreach ($alldata as $number) { |
1633 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1633 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1634 | 1634 | } |
1635 | 1635 | echo '-> countAllDates...'."\n"; |
1636 | 1636 | $previousdata = $this->countAllDates(); |
1637 | 1637 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
1638 | 1638 | $this->deleteStatFlight('date'); |
1639 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
1639 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
1640 | 1640 | $values = array(); |
1641 | 1641 | foreach ($alldata as $cnt) { |
1642 | 1642 | $values[] = $cnt['date_count']; |
1643 | 1643 | } |
1644 | - array_multisort($values,SORT_DESC,$alldata); |
|
1645 | - array_splice($alldata,11); |
|
1644 | + array_multisort($values, SORT_DESC, $alldata); |
|
1645 | + array_splice($alldata, 11); |
|
1646 | 1646 | foreach ($alldata as $number) { |
1647 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1647 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | $this->deleteStatFlight('hour'); |
1651 | 1651 | echo '-> countAllHours...'."\n"; |
1652 | 1652 | $alldata = $Spotter->countAllHours('hour'); |
1653 | 1653 | foreach ($alldata as $number) { |
1654 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1654 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | |
@@ -1660,34 +1660,34 @@ discard block |
||
1660 | 1660 | echo '--- Stats by airlines ---'."\n"; |
1661 | 1661 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
1662 | 1662 | $Spotter = new Spotter($this->db); |
1663 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1663 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1664 | 1664 | foreach ($alldata as $number) { |
1665 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
|
1665 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']); |
|
1666 | 1666 | } |
1667 | 1667 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
1668 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1668 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1669 | 1669 | foreach ($alldata as $number) { |
1670 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
|
1670 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']); |
|
1671 | 1671 | } |
1672 | 1672 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
1673 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1673 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1674 | 1674 | foreach ($alldata as $number) { |
1675 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1675 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1676 | 1676 | } |
1677 | 1677 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
1678 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1678 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1679 | 1679 | foreach ($alldata as $number) { |
1680 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
|
1680 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']); |
|
1681 | 1681 | } |
1682 | 1682 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
1683 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1683 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1684 | 1684 | foreach ($alldata as $number) { |
1685 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']); |
|
1685 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source']); |
|
1686 | 1686 | } |
1687 | 1687 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1688 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1688 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1689 | 1689 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1690 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1690 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1691 | 1691 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1692 | 1692 | //$alldata = array(); |
1693 | 1693 | foreach ($dall as $value) { |
@@ -1707,12 +1707,12 @@ discard block |
||
1707 | 1707 | } |
1708 | 1708 | $alldata = $pall; |
1709 | 1709 | foreach ($alldata as $number) { |
1710 | - 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']); |
|
1710 | + 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']); |
|
1711 | 1711 | } |
1712 | 1712 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1713 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1713 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1714 | 1714 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1715 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1715 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1716 | 1716 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1717 | 1717 | //$alldata = array(); |
1718 | 1718 | foreach ($dall as $value) { |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | } |
1733 | 1733 | $alldata = $pall; |
1734 | 1734 | foreach ($alldata as $number) { |
1735 | - 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']); |
|
1735 | + 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']); |
|
1736 | 1736 | } |
1737 | 1737 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
1738 | 1738 | $Spotter = new Spotter($this->db); |
@@ -1740,27 +1740,27 @@ discard block |
||
1740 | 1740 | $lastyear = false; |
1741 | 1741 | foreach ($alldata as $number) { |
1742 | 1742 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1743 | - $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']); |
|
1743 | + $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']); |
|
1744 | 1744 | } |
1745 | 1745 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
1746 | 1746 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1747 | 1747 | foreach ($alldata as $number) { |
1748 | - $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']); |
|
1748 | + $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']); |
|
1749 | 1749 | } |
1750 | 1750 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
1751 | 1751 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1752 | 1752 | foreach ($alldata as $number) { |
1753 | - $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']); |
|
1753 | + $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']); |
|
1754 | 1754 | } |
1755 | 1755 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
1756 | 1756 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1757 | 1757 | foreach ($alldata as $number) { |
1758 | - $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']); |
|
1758 | + $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']); |
|
1759 | 1759 | } |
1760 | 1760 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
1761 | 1761 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1762 | 1762 | foreach ($alldata as $number) { |
1763 | - $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']); |
|
1763 | + $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']); |
|
1764 | 1764 | } |
1765 | 1765 | if ($globalDebug) echo '...Departure'."\n"; |
1766 | 1766 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1783,7 +1783,7 @@ discard block |
||
1783 | 1783 | } |
1784 | 1784 | $alldata = $pall; |
1785 | 1785 | foreach ($alldata as $number) { |
1786 | - $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']); |
|
1786 | + $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']); |
|
1787 | 1787 | } |
1788 | 1788 | if ($globalDebug) echo '...Arrival'."\n"; |
1789 | 1789 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1806,32 +1806,32 @@ discard block |
||
1806 | 1806 | } |
1807 | 1807 | $alldata = $pall; |
1808 | 1808 | foreach ($alldata as $number) { |
1809 | - $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']); |
|
1809 | + $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']); |
|
1810 | 1810 | } |
1811 | 1811 | |
1812 | 1812 | if ($globalDebug) echo 'Flights data...'."\n"; |
1813 | 1813 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
1814 | 1814 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1815 | 1815 | foreach ($alldata as $number) { |
1816 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1816 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1817 | 1817 | } |
1818 | 1818 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
1819 | 1819 | //$previousdata = $this->countAllDatesByAirlines(); |
1820 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
|
1820 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines()); |
|
1821 | 1821 | $values = array(); |
1822 | 1822 | foreach ($alldata as $cnt) { |
1823 | 1823 | $values[] = $cnt['date_count']; |
1824 | 1824 | } |
1825 | - array_multisort($values,SORT_DESC,$alldata); |
|
1826 | - array_splice($alldata,11); |
|
1825 | + array_multisort($values, SORT_DESC, $alldata); |
|
1826 | + array_splice($alldata, 11); |
|
1827 | 1827 | foreach ($alldata as $number) { |
1828 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1828 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1829 | 1829 | } |
1830 | 1830 | |
1831 | 1831 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
1832 | 1832 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1833 | 1833 | foreach ($alldata as $number) { |
1834 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1834 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | |
@@ -1848,32 +1848,32 @@ discard block |
||
1848 | 1848 | // Count by filter |
1849 | 1849 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
1850 | 1850 | $Spotter = new Spotter($this->db); |
1851 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
1851 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
1852 | 1852 | foreach ($alldata as $number) { |
1853 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name); |
|
1853 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name); |
|
1854 | 1854 | } |
1855 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
1855 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
1856 | 1856 | foreach ($alldata as $number) { |
1857 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name); |
|
1857 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name); |
|
1858 | 1858 | } |
1859 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
1859 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
1860 | 1860 | foreach ($alldata as $number) { |
1861 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name); |
|
1861 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name); |
|
1862 | 1862 | } |
1863 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
1863 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
1864 | 1864 | foreach ($alldata as $number) { |
1865 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name); |
|
1865 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name); |
|
1866 | 1866 | } |
1867 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
1867 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
1868 | 1868 | foreach ($alldata as $number) { |
1869 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name); |
|
1869 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name); |
|
1870 | 1870 | } |
1871 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
1871 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
1872 | 1872 | foreach ($alldata as $number) { |
1873 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']); |
|
1873 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source']); |
|
1874 | 1874 | } |
1875 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
1876 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1875 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
1876 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
1877 | 1877 | $alldata = array(); |
1878 | 1878 | foreach ($pall as $value) { |
1879 | 1879 | $icao = $value['airport_departure_icao']; |
@@ -1889,12 +1889,12 @@ discard block |
||
1889 | 1889 | foreach ($alldata as $key => $row) { |
1890 | 1890 | $count[$key] = $row['airport_departure_icao_count']; |
1891 | 1891 | } |
1892 | - array_multisort($count,SORT_DESC,$alldata); |
|
1892 | + array_multisort($count, SORT_DESC, $alldata); |
|
1893 | 1893 | foreach ($alldata as $number) { |
1894 | - 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); |
|
1894 | + 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); |
|
1895 | 1895 | } |
1896 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
|
1897 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1896 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter); |
|
1897 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter); |
|
1898 | 1898 | $alldata = array(); |
1899 | 1899 | foreach ($pall as $value) { |
1900 | 1900 | $icao = $value['airport_arrival_icao']; |
@@ -1910,40 +1910,40 @@ discard block |
||
1910 | 1910 | foreach ($alldata as $key => $row) { |
1911 | 1911 | $count[$key] = $row['airport_arrival_icao_count']; |
1912 | 1912 | } |
1913 | - array_multisort($count,SORT_DESC,$alldata); |
|
1913 | + array_multisort($count, SORT_DESC, $alldata); |
|
1914 | 1914 | foreach ($alldata as $number) { |
1915 | - 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); |
|
1915 | + 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); |
|
1916 | 1916 | } |
1917 | 1917 | $Spotter = new Spotter($this->db); |
1918 | 1918 | $alldata = $Spotter->countAllMonths($filter); |
1919 | 1919 | $lastyear = false; |
1920 | 1920 | foreach ($alldata as $number) { |
1921 | 1921 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1922 | - $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); |
|
1922 | + $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); |
|
1923 | 1923 | } |
1924 | 1924 | $alldata = $Spotter->countAllMonthsOwners($filter); |
1925 | 1925 | foreach ($alldata as $number) { |
1926 | - $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); |
|
1926 | + $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); |
|
1927 | 1927 | } |
1928 | 1928 | $alldata = $Spotter->countAllMonthsPilots($filter); |
1929 | 1929 | foreach ($alldata as $number) { |
1930 | - $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); |
|
1930 | + $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); |
|
1931 | 1931 | } |
1932 | 1932 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
1933 | 1933 | foreach ($alldata as $number) { |
1934 | - $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); |
|
1934 | + $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); |
|
1935 | 1935 | } |
1936 | 1936 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
1937 | 1937 | foreach ($alldata as $number) { |
1938 | - $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); |
|
1938 | + $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); |
|
1939 | 1939 | } |
1940 | 1940 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
1941 | 1941 | foreach ($alldata as $number) { |
1942 | - $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); |
|
1942 | + $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); |
|
1943 | 1943 | } |
1944 | 1944 | echo '...Departure'."\n"; |
1945 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
1946 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1945 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
1946 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
1947 | 1947 | foreach ($dall as $value) { |
1948 | 1948 | $icao = $value['departure_airport_icao']; |
1949 | 1949 | $ddate = $value['date']; |
@@ -1961,11 +1961,11 @@ discard block |
||
1961 | 1961 | } |
1962 | 1962 | $alldata = $pall; |
1963 | 1963 | foreach ($alldata as $number) { |
1964 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
1964 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
1965 | 1965 | } |
1966 | 1966 | echo '...Arrival'."\n"; |
1967 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
1968 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1967 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
1968 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
1969 | 1969 | foreach ($dall as $value) { |
1970 | 1970 | $icao = $value['arrival_airport_icao']; |
1971 | 1971 | $ddate = $value['date']; |
@@ -1983,40 +1983,40 @@ discard block |
||
1983 | 1983 | } |
1984 | 1984 | $alldata = $pall; |
1985 | 1985 | foreach ($alldata as $number) { |
1986 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
1986 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
1987 | 1987 | } |
1988 | 1988 | |
1989 | 1989 | echo 'Flights data...'."\n"; |
1990 | 1990 | echo '-> countAllDatesLastMonth...'."\n"; |
1991 | 1991 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
1992 | 1992 | foreach ($alldata as $number) { |
1993 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
1993 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1994 | 1994 | } |
1995 | 1995 | echo '-> countAllDates...'."\n"; |
1996 | - $previousdata = $this->countAllDates('',$filter_name); |
|
1997 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
1996 | + $previousdata = $this->countAllDates('', $filter_name); |
|
1997 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
1998 | 1998 | $values = array(); |
1999 | 1999 | foreach ($alldata as $cnt) { |
2000 | 2000 | $values[] = $cnt['date_count']; |
2001 | 2001 | } |
2002 | - array_multisort($values,SORT_DESC,$alldata); |
|
2003 | - array_splice($alldata,11); |
|
2002 | + array_multisort($values, SORT_DESC, $alldata); |
|
2003 | + array_splice($alldata, 11); |
|
2004 | 2004 | foreach ($alldata as $number) { |
2005 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
2005 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2006 | 2006 | } |
2007 | 2007 | |
2008 | 2008 | echo '-> countAllHours...'."\n"; |
2009 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
2009 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
2010 | 2010 | foreach ($alldata as $number) { |
2011 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
2011 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
2012 | 2012 | } |
2013 | 2013 | echo 'Insert last stats update date...'."\n"; |
2014 | 2014 | date_default_timezone_set('UTC'); |
2015 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
2015 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
2016 | 2016 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
2017 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2017 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2018 | 2018 | $this->deleteOldStats($filter_name); |
2019 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
2019 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
2020 | 2020 | } |
2021 | 2021 | } |
2022 | 2022 | |
@@ -2029,16 +2029,16 @@ discard block |
||
2029 | 2029 | // SUM all previous month to put as year |
2030 | 2030 | $previous_year = date('Y'); |
2031 | 2031 | $previous_year--; |
2032 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2033 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2034 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2035 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2032 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2033 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2034 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2035 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2036 | 2036 | $allairlines = $this->getAllAirlineNames(); |
2037 | 2037 | foreach ($allairlines as $data) { |
2038 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2039 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2040 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2041 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2038 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2039 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2040 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2041 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2042 | 2042 | } |
2043 | 2043 | |
2044 | 2044 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2047,7 +2047,7 @@ discard block |
||
2047 | 2047 | try { |
2048 | 2048 | $sth = $this->db->prepare($query); |
2049 | 2049 | $sth->execute(); |
2050 | - } catch(PDOException $e) { |
|
2050 | + } catch (PDOException $e) { |
|
2051 | 2051 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2052 | 2052 | } |
2053 | 2053 | } |
@@ -2056,15 +2056,15 @@ discard block |
||
2056 | 2056 | try { |
2057 | 2057 | $sth = $this->db->prepare($query); |
2058 | 2058 | $sth->execute(); |
2059 | - } catch(PDOException $e) { |
|
2059 | + } catch (PDOException $e) { |
|
2060 | 2060 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2061 | 2061 | } |
2062 | 2062 | } |
2063 | 2063 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
2064 | 2064 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2065 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
2065 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
2066 | 2066 | $this->deleteOldStats(); |
2067 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
2067 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
2068 | 2068 | $lastyearupdate = true; |
2069 | 2069 | } |
2070 | 2070 | } |
@@ -2086,7 +2086,7 @@ discard block |
||
2086 | 2086 | try { |
2087 | 2087 | $sth = $this->db->prepare($query); |
2088 | 2088 | $sth->execute(); |
2089 | - } catch(PDOException $e) { |
|
2089 | + } catch (PDOException $e) { |
|
2090 | 2090 | return "error : ".$e->getMessage(); |
2091 | 2091 | } |
2092 | 2092 | } |
@@ -2100,14 +2100,14 @@ discard block |
||
2100 | 2100 | try { |
2101 | 2101 | $sth = $this->db->prepare($query); |
2102 | 2102 | $sth->execute(); |
2103 | - } catch(PDOException $e) { |
|
2103 | + } catch (PDOException $e) { |
|
2104 | 2104 | return "error : ".$e->getMessage(); |
2105 | 2105 | } |
2106 | 2106 | } |
2107 | 2107 | if (!isset($lastyearupdate)) { |
2108 | 2108 | echo 'Insert last stats update date...'."\n"; |
2109 | 2109 | date_default_timezone_set('UTC'); |
2110 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2110 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2111 | 2111 | } |
2112 | 2112 | //} |
2113 | 2113 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter; |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) { |
|
30 | + $filter = array_merge($filter,$globalFilter); |
|
31 | + } |
|
30 | 32 | $filter_query_join = ''; |
31 | 33 | $filter_query_where = ''; |
32 | 34 | foreach($filters as $flt) { |
@@ -71,8 +73,11 @@ discard block |
||
71 | 73 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
72 | 74 | } |
73 | 75 | } |
74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
76 | + if ($filter_query_where == '' && $where) { |
|
77 | + $filter_query_where = ' WHERE'; |
|
78 | + } elseif ($filter_query_where != '' && $and) { |
|
79 | + $filter_query_where .= ' AND'; |
|
80 | + } |
|
76 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
77 | 82 | return $filter_query; |
78 | 83 | } |
@@ -108,7 +113,9 @@ discard block |
||
108 | 113 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
109 | 114 | } |
110 | 115 | |
111 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
116 | + if (!isset($globalLiveInterval)) { |
|
117 | + $globalLiveInterval = '200'; |
|
118 | + } |
|
112 | 119 | if ($globalDBdriver == 'mysql') { |
113 | 120 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
114 | 121 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -133,7 +140,9 @@ discard block |
||
133 | 140 | |
134 | 141 | $filter_query = $this->getFilter($filter,true,true); |
135 | 142 | |
136 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
143 | + if (!isset($globalLiveInterval)) { |
|
144 | + $globalLiveInterval = '200'; |
|
145 | + } |
|
137 | 146 | if ($globalDBdriver == 'mysql') { |
138 | 147 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
139 | 148 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -180,7 +189,9 @@ discard block |
||
180 | 189 | |
181 | 190 | $filter_query = $this->getFilter($filter,true,true); |
182 | 191 | |
183 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
192 | + if (!isset($globalLiveInterval)) { |
|
193 | + $globalLiveInterval = '200'; |
|
194 | + } |
|
184 | 195 | if ($globalDBdriver == 'mysql') { |
185 | 196 | |
186 | 197 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -220,7 +231,9 @@ discard block |
||
220 | 231 | global $globalDBdriver, $globalLiveInterval; |
221 | 232 | $filter_query = $this->getFilter($filter,true,true); |
222 | 233 | |
223 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
234 | + if (!isset($globalLiveInterval)) { |
|
235 | + $globalLiveInterval = '200'; |
|
236 | + } |
|
224 | 237 | if ($globalDBdriver == 'mysql') { |
225 | 238 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
226 | 239 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -250,7 +263,9 @@ discard block |
||
250 | 263 | { |
251 | 264 | global $globalDBdriver, $globalLiveInterval; |
252 | 265 | $Spotter = new Spotter($this->db); |
253 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
266 | + if (!isset($globalLiveInterval)) { |
|
267 | + $globalLiveInterval = '200'; |
|
268 | + } |
|
254 | 269 | $filter_query = $this->getFilter($filter); |
255 | 270 | |
256 | 271 | if (is_array($coord)) { |
@@ -258,7 +273,9 @@ discard block |
||
258 | 273 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
259 | 274 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
260 | 275 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
261 | - } else return array(); |
|
276 | + } else { |
|
277 | + return array(); |
|
278 | + } |
|
262 | 279 | if ($globalDBdriver == 'mysql') { |
263 | 280 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
264 | 281 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -449,11 +466,15 @@ discard block |
||
449 | 466 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
450 | 467 | if ($globalDBdriver == 'mysql') { |
451 | 468 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
452 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
469 | + if ($liveinterval) { |
|
470 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
471 | + } |
|
453 | 472 | $query .= ' ORDER BY date'; |
454 | 473 | } else { |
455 | 474 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
456 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
475 | + if ($liveinterval) { |
|
476 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
477 | + } |
|
457 | 478 | $query .= ' ORDER BY date'; |
458 | 479 | } |
459 | 480 | |
@@ -548,7 +569,9 @@ discard block |
||
548 | 569 | $i++; |
549 | 570 | $j++; |
550 | 571 | if ($j == 30) { |
551 | - if ($globalDebug) echo "."; |
|
572 | + if ($globalDebug) { |
|
573 | + echo "."; |
|
574 | + } |
|
552 | 575 | try { |
553 | 576 | |
554 | 577 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -856,7 +879,9 @@ discard block |
||
856 | 879 | { |
857 | 880 | return false; |
858 | 881 | } |
859 | - } else return ''; |
|
882 | + } else { |
|
883 | + return ''; |
|
884 | + } |
|
860 | 885 | |
861 | 886 | if ($longitude != '') |
862 | 887 | { |
@@ -864,7 +889,9 @@ discard block |
||
864 | 889 | { |
865 | 890 | return false; |
866 | 891 | } |
867 | - } else return ''; |
|
892 | + } else { |
|
893 | + return ''; |
|
894 | + } |
|
868 | 895 | |
869 | 896 | if ($waypoints != '') |
870 | 897 | { |
@@ -880,7 +907,9 @@ discard block |
||
880 | 907 | { |
881 | 908 | return false; |
882 | 909 | } |
883 | - } else $altitude = 0; |
|
910 | + } else { |
|
911 | + $altitude = 0; |
|
912 | + } |
|
884 | 913 | |
885 | 914 | if ($heading != '') |
886 | 915 | { |
@@ -888,7 +917,9 @@ discard block |
||
888 | 917 | { |
889 | 918 | return false; |
890 | 919 | } |
891 | - } else $heading = 0; |
|
920 | + } else { |
|
921 | + $heading = 0; |
|
922 | + } |
|
892 | 923 | |
893 | 924 | if ($groundspeed != '') |
894 | 925 | { |
@@ -896,9 +927,13 @@ discard block |
||
896 | 927 | { |
897 | 928 | return false; |
898 | 929 | } |
899 | - } else $groundspeed = 0; |
|
930 | + } else { |
|
931 | + $groundspeed = 0; |
|
932 | + } |
|
900 | 933 | date_default_timezone_set('UTC'); |
901 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
934 | + if ($date == '') { |
|
935 | + $date = date("Y-m-d H:i:s", time()); |
|
936 | + } |
|
902 | 937 | |
903 | 938 | |
904 | 939 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -942,10 +977,18 @@ discard block |
||
942 | 977 | $arrival_airport_country = ''; |
943 | 978 | |
944 | 979 | |
945 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
946 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
947 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
948 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
980 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
981 | + $squawk = NULL; |
|
982 | + } |
|
983 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
984 | + $verticalrate = NULL; |
|
985 | + } |
|
986 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
987 | + $groundspeed = 0; |
|
988 | + } |
|
989 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
990 | + $heading = 0; |
|
991 | + } |
|
949 | 992 | |
950 | 993 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
951 | 994 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -960,9 +1003,13 @@ discard block |
||
960 | 1003 | return "error : ".$e->getMessage(); |
961 | 1004 | } |
962 | 1005 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
963 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1006 | + if ($globalDebug) { |
|
1007 | + echo '(Add to SBS archive : '; |
|
1008 | + } |
|
964 | 1009 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
965 | - if ($globalDebug) echo $result.')'; |
|
1010 | + if ($globalDebug) { |
|
1011 | + echo $result.')'; |
|
1012 | + } |
|
966 | 1013 | } |
967 | 1014 | return "success"; |
968 | 1015 |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
21 | 21 | $filters = array(); |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Gets all the spotter information based on the latest data entry |
|
87 | - * |
|
88 | - * @return Array the spotter information |
|
89 | - * |
|
90 | - */ |
|
86 | + * Gets all the spotter information based on the latest data entry |
|
87 | + * |
|
88 | + * @return Array the spotter information |
|
89 | + * |
|
90 | + */ |
|
91 | 91 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
92 | 92 | { |
93 | 93 | global $globalDBdriver, $globalLiveInterval; |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | - * Gets Minimal Live Spotter data |
|
130 | - * |
|
131 | - * @return Array the spotter information |
|
132 | - * |
|
133 | - */ |
|
129 | + * Gets Minimal Live Spotter data |
|
130 | + * |
|
131 | + * @return Array the spotter information |
|
132 | + * |
|
133 | + */ |
|
134 | 134 | public function getMinLiveSpotterData($filter = array()) |
135 | 135 | { |
136 | 136 | global $globalDBdriver, $globalLiveInterval; |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | - * Gets Minimal Live Spotter data since xx seconds |
|
185 | - * |
|
186 | - * @return Array the spotter information |
|
187 | - * |
|
188 | - */ |
|
184 | + * Gets Minimal Live Spotter data since xx seconds |
|
185 | + * |
|
186 | + * @return Array the spotter information |
|
187 | + * |
|
188 | + */ |
|
189 | 189 | public function getMinLastLiveSpotterData($filter = array()) |
190 | 190 | { |
191 | 191 | global $globalDBdriver, $globalLiveInterval; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
200 | 200 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
201 | 201 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
202 | - } else { |
|
202 | + } else { |
|
203 | 203 | /* |
204 | 204 | $query = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
205 | 205 | FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // echo $query; |
212 | 212 | } |
213 | 213 | |
214 | - try { |
|
214 | + try { |
|
215 | 215 | $sth = $this->db->prepare($query); |
216 | 216 | $sth->execute(); |
217 | 217 | } catch(PDOException $e) { |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | - * Gets number of latest data entry |
|
227 | - * |
|
228 | - * @return String number of entry |
|
229 | - * |
|
230 | - */ |
|
226 | + * Gets number of latest data entry |
|
227 | + * |
|
228 | + * @return String number of entry |
|
229 | + * |
|
230 | + */ |
|
231 | 231 | public function getLiveSpotterCount($filter = array()) |
232 | 232 | { |
233 | 233 | global $globalDBdriver, $globalLiveInterval; |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
257 | - * Gets all the spotter information based on the latest data entry and coord |
|
258 | - * |
|
259 | - * @return Array the spotter information |
|
260 | - * |
|
261 | - */ |
|
257 | + * Gets all the spotter information based on the latest data entry and coord |
|
258 | + * |
|
259 | + * @return Array the spotter information |
|
260 | + * |
|
261 | + */ |
|
262 | 262 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
263 | 263 | { |
264 | 264 | global $globalDBdriver, $globalLiveInterval; |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * Gets all the spotter information based on a user's latitude and longitude |
|
287 | - * |
|
288 | - * @return Array the spotter information |
|
289 | - * |
|
290 | - */ |
|
286 | + * Gets all the spotter information based on a user's latitude and longitude |
|
287 | + * |
|
288 | + * @return Array the spotter information |
|
289 | + * |
|
290 | + */ |
|
291 | 291 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
292 | 292 | { |
293 | 293 | $Spotter = new Spotter($this->db); |
@@ -297,145 +297,145 @@ discard block |
||
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | } |
300 | - if ($lng != '') |
|
301 | - { |
|
302 | - if (!is_numeric($lng)) |
|
303 | - { |
|
304 | - return false; |
|
305 | - } |
|
306 | - } |
|
307 | - |
|
308 | - if ($radius != '') |
|
309 | - { |
|
310 | - if (!is_numeric($radius)) |
|
311 | - { |
|
312 | - return false; |
|
313 | - } |
|
314 | - } |
|
300 | + if ($lng != '') |
|
301 | + { |
|
302 | + if (!is_numeric($lng)) |
|
303 | + { |
|
304 | + return false; |
|
305 | + } |
|
306 | + } |
|
307 | + |
|
308 | + if ($radius != '') |
|
309 | + { |
|
310 | + if (!is_numeric($radius)) |
|
311 | + { |
|
312 | + return false; |
|
313 | + } |
|
314 | + } |
|
315 | 315 | $additional_query = ''; |
316 | - if ($interval != '') |
|
317 | - { |
|
318 | - if (!is_string($interval)) |
|
319 | - { |
|
320 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
321 | - return false; |
|
322 | - } else { |
|
323 | - if ($interval == '1m') |
|
324 | - { |
|
325 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
326 | - } else if ($interval == '15m'){ |
|
327 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
328 | - } |
|
329 | - } |
|
330 | - } else { |
|
331 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
332 | - } |
|
333 | - |
|
334 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
316 | + if ($interval != '') |
|
317 | + { |
|
318 | + if (!is_string($interval)) |
|
319 | + { |
|
320 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
321 | + return false; |
|
322 | + } else { |
|
323 | + if ($interval == '1m') |
|
324 | + { |
|
325 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
326 | + } else if ($interval == '15m'){ |
|
327 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
328 | + } |
|
329 | + } |
|
330 | + } else { |
|
331 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
332 | + } |
|
333 | + |
|
334 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
335 | 335 | WHERE spotter_live.latitude <> '' |
336 | 336 | AND spotter_live.longitude <> '' |
337 | 337 | ".$additional_query." |
338 | 338 | HAVING distance < :radius |
339 | 339 | ORDER BY distance"; |
340 | 340 | |
341 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
341 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
342 | 342 | |
343 | - return $spotter_array; |
|
344 | - } |
|
343 | + return $spotter_array; |
|
344 | + } |
|
345 | 345 | |
346 | 346 | |
347 | - /** |
|
348 | - * Gets all the spotter information based on a particular callsign |
|
349 | - * |
|
350 | - * @return Array the spotter information |
|
351 | - * |
|
352 | - */ |
|
347 | + /** |
|
348 | + * Gets all the spotter information based on a particular callsign |
|
349 | + * |
|
350 | + * @return Array the spotter information |
|
351 | + * |
|
352 | + */ |
|
353 | 353 | public function getLastLiveSpotterDataByIdent($ident) |
354 | 354 | { |
355 | 355 | $Spotter = new Spotter($this->db); |
356 | 356 | date_default_timezone_set('UTC'); |
357 | 357 | |
358 | 358 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
359 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
359 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
360 | 360 | |
361 | 361 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
362 | 362 | |
363 | 363 | return $spotter_array; |
364 | 364 | } |
365 | 365 | |
366 | - /** |
|
367 | - * Gets all the spotter information based on a particular callsign |
|
368 | - * |
|
369 | - * @return Array the spotter information |
|
370 | - * |
|
371 | - */ |
|
366 | + /** |
|
367 | + * Gets all the spotter information based on a particular callsign |
|
368 | + * |
|
369 | + * @return Array the spotter information |
|
370 | + * |
|
371 | + */ |
|
372 | 372 | public function getDateLiveSpotterDataByIdent($ident,$date) |
373 | 373 | { |
374 | 374 | $Spotter = new Spotter($this->db); |
375 | 375 | date_default_timezone_set('UTC'); |
376 | 376 | |
377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
378 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
378 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
379 | 379 | |
380 | - $date = date('c',$date); |
|
380 | + $date = date('c',$date); |
|
381 | 381 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
382 | 382 | |
383 | 383 | return $spotter_array; |
384 | 384 | } |
385 | 385 | |
386 | - /** |
|
387 | - * Gets last spotter information based on a particular callsign |
|
388 | - * |
|
389 | - * @return Array the spotter information |
|
390 | - * |
|
391 | - */ |
|
386 | + /** |
|
387 | + * Gets last spotter information based on a particular callsign |
|
388 | + * |
|
389 | + * @return Array the spotter information |
|
390 | + * |
|
391 | + */ |
|
392 | 392 | public function getLastLiveSpotterDataById($id) |
393 | 393 | { |
394 | 394 | $Spotter = new Spotter($this->db); |
395 | 395 | date_default_timezone_set('UTC'); |
396 | 396 | |
397 | 397 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
398 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
398 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
399 | 399 | |
400 | 400 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
401 | 401 | |
402 | 402 | return $spotter_array; |
403 | 403 | } |
404 | 404 | |
405 | - /** |
|
406 | - * Gets last spotter information based on a particular callsign |
|
407 | - * |
|
408 | - * @return Array the spotter information |
|
409 | - * |
|
410 | - */ |
|
405 | + /** |
|
406 | + * Gets last spotter information based on a particular callsign |
|
407 | + * |
|
408 | + * @return Array the spotter information |
|
409 | + * |
|
410 | + */ |
|
411 | 411 | public function getDateLiveSpotterDataById($id,$date) |
412 | 412 | { |
413 | 413 | $Spotter = new Spotter($this->db); |
414 | 414 | date_default_timezone_set('UTC'); |
415 | 415 | |
416 | 416 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
417 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
418 | - $date = date('c',$date); |
|
417 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
418 | + $date = date('c',$date); |
|
419 | 419 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
420 | 420 | |
421 | 421 | return $spotter_array; |
422 | 422 | } |
423 | 423 | |
424 | - /** |
|
425 | - * Gets altitude information based on a particular callsign |
|
426 | - * |
|
427 | - * @return Array the spotter information |
|
428 | - * |
|
429 | - */ |
|
424 | + /** |
|
425 | + * Gets altitude information based on a particular callsign |
|
426 | + * |
|
427 | + * @return Array the spotter information |
|
428 | + * |
|
429 | + */ |
|
430 | 430 | public function getAltitudeLiveSpotterDataByIdent($ident) |
431 | 431 | { |
432 | 432 | |
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
436 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
436 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
437 | 437 | |
438 | - try { |
|
438 | + try { |
|
439 | 439 | |
440 | 440 | $sth = $this->db->prepare($query); |
441 | 441 | $sth->execute(array(':ident' => $ident)); |
@@ -448,12 +448,12 @@ discard block |
||
448 | 448 | return $spotter_array; |
449 | 449 | } |
450 | 450 | |
451 | - /** |
|
452 | - * Gets all the spotter information based on a particular id |
|
453 | - * |
|
454 | - * @return Array the spotter information |
|
455 | - * |
|
456 | - */ |
|
451 | + /** |
|
452 | + * Gets all the spotter information based on a particular id |
|
453 | + * |
|
454 | + * @return Array the spotter information |
|
455 | + * |
|
456 | + */ |
|
457 | 457 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
458 | 458 | { |
459 | 459 | global $globalDBdriver, $globalLiveInterval; |
@@ -481,18 +481,18 @@ discard block |
||
481 | 481 | return $spotter_array; |
482 | 482 | } |
483 | 483 | |
484 | - /** |
|
485 | - * Gets all the spotter information based on a particular ident |
|
486 | - * |
|
487 | - * @return Array the spotter information |
|
488 | - * |
|
489 | - */ |
|
484 | + /** |
|
485 | + * Gets all the spotter information based on a particular ident |
|
486 | + * |
|
487 | + * @return Array the spotter information |
|
488 | + * |
|
489 | + */ |
|
490 | 490 | public function getAllLiveSpotterDataByIdent($ident) |
491 | 491 | { |
492 | 492 | date_default_timezone_set('UTC'); |
493 | 493 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
494 | 494 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
495 | - try { |
|
495 | + try { |
|
496 | 496 | |
497 | 497 | $sth = $this->db->prepare($query); |
498 | 498 | $sth->execute(array(':ident' => $ident)); |
@@ -506,23 +506,23 @@ discard block |
||
506 | 506 | |
507 | 507 | |
508 | 508 | /** |
509 | - * Deletes all info in the table |
|
510 | - * |
|
511 | - * @return String success or false |
|
512 | - * |
|
513 | - */ |
|
509 | + * Deletes all info in the table |
|
510 | + * |
|
511 | + * @return String success or false |
|
512 | + * |
|
513 | + */ |
|
514 | 514 | public function deleteLiveSpotterData() |
515 | 515 | { |
516 | 516 | global $globalDBdriver; |
517 | 517 | if ($globalDBdriver == 'mysql') { |
518 | 518 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
519 | 519 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
520 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
520 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
521 | 521 | } else { |
522 | 522 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
523 | 523 | } |
524 | 524 | |
525 | - try { |
|
525 | + try { |
|
526 | 526 | |
527 | 527 | $sth = $this->db->prepare($query); |
528 | 528 | $sth->execute(); |
@@ -534,18 +534,18 @@ discard block |
||
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
537 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
538 | - * |
|
539 | - * @return String success or false |
|
540 | - * |
|
541 | - */ |
|
537 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
538 | + * |
|
539 | + * @return String success or false |
|
540 | + * |
|
541 | + */ |
|
542 | 542 | public function deleteLiveSpotterDataNotUpdated() |
543 | 543 | { |
544 | 544 | global $globalDBdriver, $globalDebug; |
545 | 545 | if ($globalDBdriver == 'mysql') { |
546 | 546 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
547 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
548 | - try { |
|
547 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
548 | + try { |
|
549 | 549 | |
550 | 550 | $sth = $this->db->prepare($query); |
551 | 551 | $sth->execute(); |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | return "error"; |
554 | 554 | } |
555 | 555 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
556 | - $i = 0; |
|
557 | - $j =0; |
|
556 | + $i = 0; |
|
557 | + $j =0; |
|
558 | 558 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
559 | 559 | foreach($all as $row) |
560 | 560 | { |
@@ -562,20 +562,20 @@ discard block |
||
562 | 562 | $j++; |
563 | 563 | if ($j == 30) { |
564 | 564 | if ($globalDebug) echo "."; |
565 | - try { |
|
565 | + try { |
|
566 | 566 | |
567 | 567 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
568 | 568 | $sth->execute(); |
569 | 569 | } catch(PDOException $e) { |
570 | 570 | return "error"; |
571 | 571 | } |
572 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
573 | - $j = 0; |
|
572 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
573 | + $j = 0; |
|
574 | 574 | } |
575 | 575 | $query_delete .= "'".$row['flightaware_id']."',"; |
576 | 576 | } |
577 | 577 | if ($i > 0) { |
578 | - try { |
|
578 | + try { |
|
579 | 579 | |
580 | 580 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
581 | 581 | $sth->execute(); |
@@ -586,9 +586,9 @@ discard block |
||
586 | 586 | return "success"; |
587 | 587 | } elseif ($globalDBdriver == 'pgsql') { |
588 | 588 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
589 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
590 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
591 | - try { |
|
589 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
590 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
591 | + try { |
|
592 | 592 | |
593 | 593 | $sth = $this->db->prepare($query); |
594 | 594 | $sth->execute(); |
@@ -632,17 +632,17 @@ discard block |
||
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
635 | - * Deletes all info in the table for an ident |
|
636 | - * |
|
637 | - * @return String success or false |
|
638 | - * |
|
639 | - */ |
|
635 | + * Deletes all info in the table for an ident |
|
636 | + * |
|
637 | + * @return String success or false |
|
638 | + * |
|
639 | + */ |
|
640 | 640 | public function deleteLiveSpotterDataByIdent($ident) |
641 | 641 | { |
642 | 642 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
643 | 643 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
644 | 644 | |
645 | - try { |
|
645 | + try { |
|
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(array(':ident' => $ident)); |
@@ -654,17 +654,17 @@ discard block |
||
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
657 | - * Deletes all info in the table for an id |
|
658 | - * |
|
659 | - * @return String success or false |
|
660 | - * |
|
661 | - */ |
|
657 | + * Deletes all info in the table for an id |
|
658 | + * |
|
659 | + * @return String success or false |
|
660 | + * |
|
661 | + */ |
|
662 | 662 | public function deleteLiveSpotterDataById($id) |
663 | 663 | { |
664 | 664 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
665 | 665 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
666 | 666 | |
667 | - try { |
|
667 | + try { |
|
668 | 668 | |
669 | 669 | $sth = $this->db->prepare($query); |
670 | 670 | $sth->execute(array(':id' => $id)); |
@@ -677,11 +677,11 @@ discard block |
||
677 | 677 | |
678 | 678 | |
679 | 679 | /** |
680 | - * Gets the aircraft ident within the last hour |
|
681 | - * |
|
682 | - * @return String the ident |
|
683 | - * |
|
684 | - */ |
|
680 | + * Gets the aircraft ident within the last hour |
|
681 | + * |
|
682 | + * @return String the ident |
|
683 | + * |
|
684 | + */ |
|
685 | 685 | public function getIdentFromLastHour($ident) |
686 | 686 | { |
687 | 687 | global $globalDBdriver, $globalTimezone; |
@@ -707,14 +707,14 @@ discard block |
||
707 | 707 | $ident_result = $row['ident']; |
708 | 708 | } |
709 | 709 | return $ident_result; |
710 | - } |
|
710 | + } |
|
711 | 711 | |
712 | 712 | /** |
713 | - * Check recent aircraft |
|
714 | - * |
|
715 | - * @return String the ident |
|
716 | - * |
|
717 | - */ |
|
713 | + * Check recent aircraft |
|
714 | + * |
|
715 | + * @return String the ident |
|
716 | + * |
|
717 | + */ |
|
718 | 718 | public function checkIdentRecent($ident) |
719 | 719 | { |
720 | 720 | global $globalDBdriver, $globalTimezone; |
@@ -740,14 +740,14 @@ discard block |
||
740 | 740 | $ident_result = $row['flightaware_id']; |
741 | 741 | } |
742 | 742 | return $ident_result; |
743 | - } |
|
743 | + } |
|
744 | 744 | |
745 | 745 | /** |
746 | - * Check recent aircraft by id |
|
747 | - * |
|
748 | - * @return String the ident |
|
749 | - * |
|
750 | - */ |
|
746 | + * Check recent aircraft by id |
|
747 | + * |
|
748 | + * @return String the ident |
|
749 | + * |
|
750 | + */ |
|
751 | 751 | public function checkIdRecent($id) |
752 | 752 | { |
753 | 753 | global $globalDBdriver, $globalTimezone; |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | $ident_result = $row['flightaware_id']; |
774 | 774 | } |
775 | 775 | return $ident_result; |
776 | - } |
|
776 | + } |
|
777 | 777 | |
778 | 778 | /** |
779 | - * Check recent aircraft by ModeS |
|
780 | - * |
|
781 | - * @return String the ModeS |
|
782 | - * |
|
783 | - */ |
|
779 | + * Check recent aircraft by ModeS |
|
780 | + * |
|
781 | + * @return String the ModeS |
|
782 | + * |
|
783 | + */ |
|
784 | 784 | public function checkModeSRecent($modes) |
785 | 785 | { |
786 | 786 | global $globalDBdriver, $globalTimezone; |
@@ -807,19 +807,19 @@ discard block |
||
807 | 807 | $ident_result = $row['flightaware_id']; |
808 | 808 | } |
809 | 809 | return $ident_result; |
810 | - } |
|
810 | + } |
|
811 | 811 | |
812 | 812 | /** |
813 | - * Adds a new spotter data |
|
814 | - * |
|
815 | - * @param String $flightaware_id the ID from flightaware |
|
816 | - * @param String $ident the flight ident |
|
817 | - * @param String $aircraft_icao the aircraft type |
|
818 | - * @param String $departure_airport_icao the departure airport |
|
819 | - * @param String $arrival_airport_icao the arrival airport |
|
820 | - * @return String success or false |
|
821 | - * |
|
822 | - */ |
|
813 | + * Adds a new spotter data |
|
814 | + * |
|
815 | + * @param String $flightaware_id the ID from flightaware |
|
816 | + * @param String $ident the flight ident |
|
817 | + * @param String $aircraft_icao the aircraft type |
|
818 | + * @param String $departure_airport_icao the departure airport |
|
819 | + * @param String $arrival_airport_icao the arrival airport |
|
820 | + * @return String success or false |
|
821 | + * |
|
822 | + */ |
|
823 | 823 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
824 | 824 | { |
825 | 825 | global $globalURL, $globalArchive, $globalDebug; |
@@ -954,10 +954,10 @@ discard block |
||
954 | 954 | $arrival_airport_country = ''; |
955 | 955 | |
956 | 956 | |
957 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
958 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
959 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
960 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
957 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
958 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
959 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
960 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
961 | 961 | |
962 | 962 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
963 | 963 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -967,14 +967,14 @@ discard block |
||
967 | 967 | |
968 | 968 | $sth = $this->db->prepare($query); |
969 | 969 | $sth->execute($query_values); |
970 | - } catch(PDOException $e) { |
|
971 | - return "error : ".$e->getMessage(); |
|
972 | - } |
|
970 | + } catch(PDOException $e) { |
|
971 | + return "error : ".$e->getMessage(); |
|
972 | + } |
|
973 | 973 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
974 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
975 | - $SpotterArchive = new SpotterArchive($this->db); |
|
976 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
977 | - if ($globalDebug) echo $result.')'; |
|
974 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
975 | + $SpotterArchive = new SpotterArchive($this->db); |
|
976 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
977 | + if ($globalDebug) echo $result.')'; |
|
978 | 978 | } |
979 | 979 | return "success"; |
980 | 980 |
@@ -16,64 +16,64 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
55 | 55 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
56 | 56 | if ($filter['airlines'][0] != '') { |
57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
61 | 61 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
62 | 62 | } |
63 | 63 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
65 | 65 | } |
66 | 66 | if (isset($filter['source']) && !empty($filter['source'])) { |
67 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
67 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
68 | 68 | } |
69 | 69 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
70 | 70 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
71 | 71 | } |
72 | 72 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
73 | 73 | if ($filter_query_where == '') { |
74 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } else { |
76 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
76 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | if ($limit != '') |
100 | 100 | { |
101 | 101 | $limit_array = explode(',', $limit); |
102 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
103 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
102 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
103 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
104 | 104 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
105 | 105 | { |
106 | 106 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } else { |
121 | 121 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
122 | 122 | } |
123 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
123 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
124 | 124 | |
125 | 125 | return $spotter_array; |
126 | 126 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | global $globalDBdriver, $globalLiveInterval; |
137 | 137 | date_default_timezone_set('UTC'); |
138 | 138 | |
139 | - $filter_query = $this->getFilter($filter,true,true); |
|
139 | + $filter_query = $this->getFilter($filter, true, true); |
|
140 | 140 | |
141 | 141 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
142 | 142 | if ($globalDBdriver == 'mysql') { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
148 | 148 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
149 | 149 | */ |
150 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
150 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
151 | 151 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
152 | 152 | |
153 | 153 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
163 | 163 | */ |
164 | 164 | |
165 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
165 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
166 | 166 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
167 | 167 | |
168 | 168 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | try { |
174 | 174 | $sth = $this->db->prepare($query); |
175 | 175 | $sth->execute(); |
176 | - } catch(PDOException $e) { |
|
176 | + } catch (PDOException $e) { |
|
177 | 177 | echo $e->getMessage(); |
178 | 178 | die; |
179 | 179 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | global $globalDBdriver, $globalLiveInterval; |
194 | 194 | date_default_timezone_set('UTC'); |
195 | 195 | |
196 | - $filter_query = $this->getFilter($filter,true,true); |
|
196 | + $filter_query = $this->getFilter($filter, true, true); |
|
197 | 197 | |
198 | 198 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
199 | 199 | if ($globalDBdriver == 'mysql') { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
203 | 203 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
204 | 204 | */ |
205 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
205 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
206 | 206 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
207 | 207 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
208 | 208 | } else { |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
212 | 212 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
213 | 213 | */ |
214 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
214 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
215 | 215 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
216 | 216 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
217 | 217 | // echo $query; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | try { |
221 | 221 | $sth = $this->db->prepare($query); |
222 | 222 | $sth->execute(); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | echo $e->getMessage(); |
225 | 225 | die; |
226 | 226 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | public function getLiveSpotterCount($filter = array()) |
238 | 238 | { |
239 | 239 | global $globalDBdriver, $globalLiveInterval; |
240 | - $filter_query = $this->getFilter($filter,true,true); |
|
240 | + $filter_query = $this->getFilter($filter, true, true); |
|
241 | 241 | |
242 | 242 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
243 | 243 | if ($globalDBdriver == 'mysql') { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $this->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | echo $e->getMessage(); |
255 | 255 | die; |
256 | 256 | } |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | $filter_query = $this->getFilter($filter); |
274 | 274 | |
275 | 275 | if (is_array($coord)) { |
276 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
277 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
278 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
279 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
276 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
277 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
278 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
279 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
280 | 280 | } else return array(); |
281 | 281 | if ($globalDBdriver == 'mysql') { |
282 | 282 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ($interval == '1m') |
330 | 330 | { |
331 | 331 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
332 | - } else if ($interval == '15m'){ |
|
332 | + } else if ($interval == '15m') { |
|
333 | 333 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
334 | 334 | } |
335 | 335 | } |
@@ -337,14 +337,14 @@ discard block |
||
337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
338 | 338 | } |
339 | 339 | |
340 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
340 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
341 | 341 | WHERE spotter_live.latitude <> '' |
342 | 342 | AND spotter_live.longitude <> '' |
343 | 343 | ".$additional_query." |
344 | 344 | HAVING distance < :radius |
345 | 345 | ORDER BY distance"; |
346 | 346 | |
347 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
347 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
348 | 348 | |
349 | 349 | return $spotter_array; |
350 | 350 | } |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | date_default_timezone_set('UTC'); |
363 | 363 | |
364 | 364 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
365 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
365 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
366 | 366 | |
367 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
367 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
368 | 368 | |
369 | 369 | return $spotter_array; |
370 | 370 | } |
@@ -375,16 +375,16 @@ discard block |
||
375 | 375 | * @return Array the spotter information |
376 | 376 | * |
377 | 377 | */ |
378 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
378 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
379 | 379 | { |
380 | 380 | $Spotter = new Spotter($this->db); |
381 | 381 | date_default_timezone_set('UTC'); |
382 | 382 | |
383 | 383 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
384 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
384 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
385 | 385 | |
386 | - $date = date('c',$date); |
|
387 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
386 | + $date = date('c', $date); |
|
387 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
388 | 388 | |
389 | 389 | return $spotter_array; |
390 | 390 | } |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | date_default_timezone_set('UTC'); |
402 | 402 | |
403 | 403 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
404 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
404 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
405 | 405 | |
406 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
406 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
407 | 407 | |
408 | 408 | return $spotter_array; |
409 | 409 | } |
@@ -414,15 +414,15 @@ discard block |
||
414 | 414 | * @return Array the spotter information |
415 | 415 | * |
416 | 416 | */ |
417 | - public function getDateLiveSpotterDataById($id,$date) |
|
417 | + public function getDateLiveSpotterDataById($id, $date) |
|
418 | 418 | { |
419 | 419 | $Spotter = new Spotter($this->db); |
420 | 420 | date_default_timezone_set('UTC'); |
421 | 421 | |
422 | 422 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
423 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
424 | - $date = date('c',$date); |
|
425 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
423 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
424 | + $date = date('c', $date); |
|
425 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
426 | 426 | |
427 | 427 | return $spotter_array; |
428 | 428 | } |
@@ -439,13 +439,13 @@ discard block |
||
439 | 439 | date_default_timezone_set('UTC'); |
440 | 440 | |
441 | 441 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
442 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
442 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
443 | 443 | |
444 | 444 | try { |
445 | 445 | |
446 | 446 | $sth = $this->db->prepare($query); |
447 | 447 | $sth->execute(array(':ident' => $ident)); |
448 | - } catch(PDOException $e) { |
|
448 | + } catch (PDOException $e) { |
|
449 | 449 | echo $e->getMessage(); |
450 | 450 | die; |
451 | 451 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return Array the spotter information |
461 | 461 | * |
462 | 462 | */ |
463 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
463 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
464 | 464 | { |
465 | 465 | global $globalDBdriver, $globalLiveInterval; |
466 | 466 | date_default_timezone_set('UTC'); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | try { |
480 | 480 | $sth = $this->db->prepare($query); |
481 | 481 | $sth->execute(array(':id' => $id)); |
482 | - } catch(PDOException $e) { |
|
482 | + } catch (PDOException $e) { |
|
483 | 483 | echo $e->getMessage(); |
484 | 484 | die; |
485 | 485 | } |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | { |
498 | 498 | date_default_timezone_set('UTC'); |
499 | 499 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
500 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
500 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
501 | 501 | try { |
502 | 502 | |
503 | 503 | $sth = $this->db->prepare($query); |
504 | 504 | $sth->execute(array(':ident' => $ident)); |
505 | - } catch(PDOException $e) { |
|
505 | + } catch (PDOException $e) { |
|
506 | 506 | echo $e->getMessage(); |
507 | 507 | die; |
508 | 508 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | |
533 | 533 | $sth = $this->db->prepare($query); |
534 | 534 | $sth->execute(); |
535 | - } catch(PDOException $e) { |
|
535 | + } catch (PDOException $e) { |
|
536 | 536 | return "error"; |
537 | 537 | } |
538 | 538 | |
@@ -555,14 +555,14 @@ discard block |
||
555 | 555 | |
556 | 556 | $sth = $this->db->prepare($query); |
557 | 557 | $sth->execute(); |
558 | - } catch(PDOException $e) { |
|
558 | + } catch (PDOException $e) { |
|
559 | 559 | return "error"; |
560 | 560 | } |
561 | 561 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
562 | 562 | $i = 0; |
563 | - $j =0; |
|
563 | + $j = 0; |
|
564 | 564 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
565 | - foreach($all as $row) |
|
565 | + foreach ($all as $row) |
|
566 | 566 | { |
567 | 567 | $i++; |
568 | 568 | $j++; |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | if ($globalDebug) echo "."; |
571 | 571 | try { |
572 | 572 | |
573 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
573 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
574 | 574 | $sth->execute(); |
575 | - } catch(PDOException $e) { |
|
575 | + } catch (PDOException $e) { |
|
576 | 576 | return "error"; |
577 | 577 | } |
578 | 578 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -583,9 +583,9 @@ discard block |
||
583 | 583 | if ($i > 0) { |
584 | 584 | try { |
585 | 585 | |
586 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
586 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
587 | 587 | $sth->execute(); |
588 | - } catch(PDOException $e) { |
|
588 | + } catch (PDOException $e) { |
|
589 | 589 | return "error"; |
590 | 590 | } |
591 | 591 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | |
599 | 599 | $sth = $this->db->prepare($query); |
600 | 600 | $sth->execute(); |
601 | - } catch(PDOException $e) { |
|
601 | + } catch (PDOException $e) { |
|
602 | 602 | return "error"; |
603 | 603 | } |
604 | 604 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -646,13 +646,13 @@ discard block |
||
646 | 646 | public function deleteLiveSpotterDataByIdent($ident) |
647 | 647 | { |
648 | 648 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
649 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
649 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
650 | 650 | |
651 | 651 | try { |
652 | 652 | |
653 | 653 | $sth = $this->db->prepare($query); |
654 | 654 | $sth->execute(array(':ident' => $ident)); |
655 | - } catch(PDOException $e) { |
|
655 | + } catch (PDOException $e) { |
|
656 | 656 | return "error"; |
657 | 657 | } |
658 | 658 | |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | public function deleteLiveSpotterDataById($id) |
669 | 669 | { |
670 | 670 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
671 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
671 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
672 | 672 | |
673 | 673 | try { |
674 | 674 | |
675 | 675 | $sth = $this->db->prepare($query); |
676 | 676 | $sth->execute(array(':id' => $id)); |
677 | - } catch(PDOException $e) { |
|
677 | + } catch (PDOException $e) { |
|
678 | 678 | return "error"; |
679 | 679 | } |
680 | 680 | |
@@ -692,13 +692,13 @@ discard block |
||
692 | 692 | { |
693 | 693 | global $globalDBdriver, $globalTimezone; |
694 | 694 | if ($globalDBdriver == 'mysql') { |
695 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
695 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
696 | 696 | WHERE spotter_live.ident = :ident |
697 | 697 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
698 | 698 | AND spotter_live.date < UTC_TIMESTAMP()'; |
699 | 699 | $query_data = array(':ident' => $ident); |
700 | 700 | } else { |
701 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
701 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
702 | 702 | WHERE spotter_live.ident = :ident |
703 | 703 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
704 | 704 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | |
708 | 708 | $sth = $this->db->prepare($query); |
709 | 709 | $sth->execute($query_data); |
710 | - $ident_result=''; |
|
711 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
710 | + $ident_result = ''; |
|
711 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
712 | 712 | { |
713 | 713 | $ident_result = $row['ident']; |
714 | 714 | } |
@@ -725,13 +725,13 @@ discard block |
||
725 | 725 | { |
726 | 726 | global $globalDBdriver, $globalTimezone; |
727 | 727 | if ($globalDBdriver == 'mysql') { |
728 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
728 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
729 | 729 | WHERE spotter_live.ident = :ident |
730 | 730 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
731 | 731 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
732 | 732 | $query_data = array(':ident' => $ident); |
733 | 733 | } else { |
734 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
734 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
735 | 735 | WHERE spotter_live.ident = :ident |
736 | 736 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
737 | 737 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | |
741 | 741 | $sth = $this->db->prepare($query); |
742 | 742 | $sth->execute($query_data); |
743 | - $ident_result=''; |
|
744 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
743 | + $ident_result = ''; |
|
744 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
745 | 745 | { |
746 | 746 | $ident_result = $row['flightaware_id']; |
747 | 747 | } |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | { |
759 | 759 | global $globalDBdriver, $globalTimezone; |
760 | 760 | if ($globalDBdriver == 'mysql') { |
761 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
761 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
762 | 762 | WHERE spotter_live.flightaware_id = :id |
763 | 763 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
764 | 764 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
765 | 765 | $query_data = array(':id' => $id); |
766 | 766 | } else { |
767 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
767 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
768 | 768 | WHERE spotter_live.flightaware_id = :id |
769 | 769 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
770 | 770 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | |
774 | 774 | $sth = $this->db->prepare($query); |
775 | 775 | $sth->execute($query_data); |
776 | - $ident_result=''; |
|
777 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
776 | + $ident_result = ''; |
|
777 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
778 | 778 | { |
779 | 779 | $ident_result = $row['flightaware_id']; |
780 | 780 | } |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | { |
792 | 792 | global $globalDBdriver, $globalTimezone; |
793 | 793 | if ($globalDBdriver == 'mysql') { |
794 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
794 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
795 | 795 | WHERE spotter_live.ModeS = :modes |
796 | 796 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
797 | 797 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
798 | 798 | $query_data = array(':modes' => $modes); |
799 | 799 | } else { |
800 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
800 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
801 | 801 | WHERE spotter_live.ModeS = :modes |
802 | 802 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
803 | 803 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -806,8 +806,8 @@ discard block |
||
806 | 806 | |
807 | 807 | $sth = $this->db->prepare($query); |
808 | 808 | $sth->execute($query_data); |
809 | - $ident_result=''; |
|
810 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
809 | + $ident_result = ''; |
|
810 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
811 | 811 | { |
812 | 812 | //$ident_result = $row['spotter_live_id']; |
813 | 813 | $ident_result = $row['flightaware_id']; |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | * @return String success or false |
827 | 827 | * |
828 | 828 | */ |
829 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
829 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
830 | 830 | { |
831 | 831 | global $globalURL, $globalArchive, $globalDebug; |
832 | 832 | $Common = new Common(); |
@@ -919,26 +919,26 @@ discard block |
||
919 | 919 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
920 | 920 | |
921 | 921 | |
922 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
923 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
924 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
925 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
926 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
927 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
928 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
929 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
930 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
931 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
932 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
933 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
934 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
935 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
936 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
937 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
938 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
939 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
940 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
941 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
922 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
923 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
924 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
925 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
926 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
927 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
928 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
929 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
930 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
931 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
932 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
933 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
935 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
936 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
937 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
938 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
939 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
940 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
941 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
942 | 942 | |
943 | 943 | $airline_name = ''; |
944 | 944 | $airline_icao = ''; |
@@ -960,26 +960,26 @@ discard block |
||
960 | 960 | $arrival_airport_country = ''; |
961 | 961 | |
962 | 962 | |
963 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
964 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
965 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
966 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
963 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
964 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
965 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
966 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
967 | 967 | |
968 | - $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
968 | + $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
969 | 969 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
970 | 970 | |
971 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
971 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
972 | 972 | try { |
973 | 973 | |
974 | 974 | $sth = $this->db->prepare($query); |
975 | 975 | $sth->execute($query_values); |
976 | - } catch(PDOException $e) { |
|
976 | + } catch (PDOException $e) { |
|
977 | 977 | return "error : ".$e->getMessage(); |
978 | 978 | } |
979 | 979 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
980 | 980 | if ($globalDebug) echo '(Add to SBS archive : '; |
981 | 981 | $SpotterArchive = new SpotterArchive($this->db); |
982 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
982 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
983 | 983 | if ($globalDebug) echo $result.')'; |
984 | 984 | } |
985 | 985 | return "success"; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | |
989 | 989 | public function getOrderBy() |
990 | 990 | { |
991 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
991 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
992 | 992 | return $orderby; |
993 | 993 | } |
994 | 994 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | } else { |
14 | 14 | print '<option value="">All</option>'; |
15 | 15 | } |
16 | - foreach($airlines as $airline) { |
|
16 | + foreach ($airlines as $airline) { |
|
17 | 17 | if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) { |
18 | 18 | print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>'; |
19 | 19 | } else { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | <div class="sub-menu sub-menu-container"> |
29 | 29 | <ul class="nav"> |
30 | 30 | <li class="dropdown"> |
31 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
31 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
32 | 32 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
33 | 33 | </a> |
34 | 34 | <ul class="dropdown-menu"> |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | </ul> |
40 | 40 | </li> |
41 | 41 | <li class="dropdown"> |
42 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
42 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
43 | 43 | <?php echo _("Airline"); ?> <span class="caret"></span> |
44 | 44 | </a> |
45 | 45 | <ul class="dropdown-menu" role="menu"> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | </ul> |
50 | 50 | </li> |
51 | 51 | <li class="dropdown"> |
52 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
52 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
53 | 53 | <?php echo _("Airport"); ?> <span class="caret"></span> |
54 | 54 | </a> |
55 | 55 | <ul class="dropdown-menu" role="menu"> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | </ul> |
61 | 61 | </li> |
62 | 62 | <li class="dropdown"> |
63 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
63 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
64 | 64 | <?php echo _("Route"); ?> <span class="caret"></span> |
65 | 65 | </a> |
66 | 66 | <ul class="dropdown-menu" role="menu"> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | </ul> |
70 | 70 | </li> |
71 | 71 | <li class="dropdown"> |
72 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
72 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
73 | 73 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
74 | 74 | </a> |
75 | 75 | <ul class="dropdown-menu" role="menu"> |
@@ -7,7 +7,9 @@ |
||
7 | 7 | <?php |
8 | 8 | require_once('require/class.Stats.php'); |
9 | 9 | $Stats = new Stats(); |
10 | - if (!isset($filter_name)) $filter_name = ''; |
|
10 | + if (!isset($filter_name)) { |
|
11 | + $filter_name = ''; |
|
12 | + } |
|
11 | 13 | $airlines = $Stats->getAllAirlineNames($filter_name); |
12 | 14 | if (isset($airline_icao) && ($airline_icao == '' || $airline_icao == 'all')) { |
13 | 15 | print '<option value="all" selected>All</option>'; |