@@ -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; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | <button type="button" class="close">×</button> |
8 | 8 | <?php |
9 | 9 | |
10 | -$sat = filter_input(INPUT_GET,'sat',FILTER_SANITIZE_STRING); |
|
10 | +$sat = filter_input(INPUT_GET, 'sat', FILTER_SANITIZE_STRING); |
|
11 | 11 | $sat = urldecode($sat); |
12 | 12 | |
13 | 13 | if ($sat == 'ISS (ZARYA)') { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $aircraft_name = 'INTEGRAL'; |
43 | 43 | // $ground_speed = 14970; |
44 | 44 | $launch_date = '17 October 2002'; |
45 | -} elseif (strpos($sat,'IRIDIUM') !== false) { |
|
45 | +} elseif (strpos($sat, 'IRIDIUM') !== false) { |
|
46 | 46 | $image = 'https://upload.wikimedia.org/wikipedia/commons/b/b6/Iridium_Satellite.jpg'; |
47 | 47 | $image_copyright = 'Cliff'; |
48 | 48 | $ident = 'Iridium satellite constellation'; |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | $aircraft_name = $sat; |
51 | 51 | // $ground_speed = 14970; |
52 | 52 | // $launch_date = '29 september 2011'; |
53 | -} elseif (strpos($sat,'ORBCOMM') !== false) { |
|
53 | +} elseif (strpos($sat, 'ORBCOMM') !== false) { |
|
54 | 54 | $ident = 'Orbcomm'; |
55 | 55 | $aircraft_wiki = 'https://en.wikipedia.org/wiki/Orbcomm_(satellite)'; |
56 | 56 | $aircraft_name = $sat; |
57 | -} elseif (strpos($sat,'GLOBALSTAR') !== false) { |
|
57 | +} elseif (strpos($sat, 'GLOBALSTAR') !== false) { |
|
58 | 58 | $ident = 'Globalstar'; |
59 | 59 | $aircraft_wiki = 'https://en.wikipedia.org/wiki/Globalstar'; |
60 | 60 | $aircraft_name = $sat; |
61 | -} elseif (strpos($sat,'OSCAR 7') !== false) { |
|
61 | +} elseif (strpos($sat, 'OSCAR 7') !== false) { |
|
62 | 62 | $image = 'https://upload.wikimedia.org/wikipedia/en/a/ad/AMSAT-OSCAR_7.jpg'; |
63 | 63 | $image_copyright = 'Amsat.org'; |
64 | 64 | $ident = 'AMSAT-OSCAR 7'; |
@@ -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,9 +8,9 @@ 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 | ?> |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script> |
188 | 188 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
189 | 189 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
190 | -<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> |
|
190 | +<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> |
|
191 | 191 | <?php |
192 | 192 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
193 | 193 | ?> |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script> |
242 | 242 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
243 | 243 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
244 | -<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> |
|
244 | +<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> |
|
245 | 245 | <?php |
246 | 246 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
247 | 247 | ?> |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | ?> |
405 | 405 | <div class="search"> |
406 | 406 | <form action="<?php print $globalURL; ?>/search" method="get"> |
407 | - <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> |
|
407 | + <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> |
|
408 | 408 | </form> |
409 | 409 | </div> |
410 | 410 | <div class="social"> |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | print '</div>'; |
423 | 423 | } |
424 | 424 | |
425 | -if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') { |
|
425 | +if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') { |
|
426 | 426 | ?> |
427 | 427 | <div class="top-header clear" role="main"> |
428 | 428 | <div id="archive-map"></div> |
429 | 429 | </div> |
430 | 430 | <?php |
431 | 431 | } |
432 | -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)) |
|
432 | +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)) |
|
433 | 433 | { |
434 | 434 | ?> |
435 | 435 | <div class="top-header clear" role="main"> |
@@ -442,15 +442,15 @@ discard block |
||
442 | 442 | var zoom = 13; |
443 | 443 | //create the map |
444 | 444 | <?php |
445 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
445 | + if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
446 | 446 | ?> |
447 | 447 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
448 | 448 | <?php |
449 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
449 | + } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) { |
|
450 | 450 | ?> |
451 | 451 | map = L.map('map', { zoomControl:true }); |
452 | 452 | <?php |
453 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
453 | + } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
454 | 454 | ?> |
455 | 455 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
456 | 456 | 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); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | 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); |
459 | 459 | 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); |
460 | 460 | <?php |
461 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
461 | + } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
462 | 462 | ?> |
463 | 463 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
464 | 464 | <?php |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | ?> |
146 | 146 | <?php |
147 | - if (isset($_POST['archive'])) { |
|
147 | + if (isset($_POST['archive'])) { |
|
148 | 148 | ?> |
149 | 149 | <?php |
150 | 150 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // } |
162 | 162 | ?> |
163 | 163 | <?php |
164 | - } else { |
|
164 | + } else { |
|
165 | 165 | ?> |
166 | 166 | <?php |
167 | 167 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | */ |
174 | 174 | ?> |
175 | 175 | <?php |
176 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
176 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
177 | 177 | ?> |
178 | 178 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script> |
179 | 179 | <?php |
180 | - } |
|
180 | + } |
|
181 | 181 | ?> |
182 | 182 | <?php |
183 | 183 | // } |
184 | 184 | ?> |
185 | 185 | <?php |
186 | - } |
|
186 | + } |
|
187 | 187 | } |
188 | 188 | ?> |
189 | 189 | <?php |
@@ -343,23 +343,23 @@ discard block |
||
343 | 343 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
344 | 344 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
345 | 345 | <?php |
346 | - if ($globalACARS) { |
|
347 | - if (isset($globalDemo) && $globalDemo) { |
|
348 | - ?> |
|
346 | + if ($globalACARS) { |
|
347 | + if (isset($globalDemo) && $globalDemo) { |
|
348 | + ?> |
|
349 | 349 | <li><hr /></li> |
350 | 350 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
351 | 351 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
352 | 352 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
353 | 353 | <?php |
354 | - } else { |
|
355 | - ?> |
|
354 | + } else { |
|
355 | + ?> |
|
356 | 356 | <li><hr /></li> |
357 | 357 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
358 | 358 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
359 | 359 | <?php |
360 | - } |
|
361 | - } |
|
362 | - ?> |
|
360 | + } |
|
361 | + } |
|
362 | + ?> |
|
363 | 363 | <li><hr /></li> |
364 | 364 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
365 | 365 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | <form> |
402 | 402 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
403 | 403 | <?php |
404 | - $Language = new Language(); |
|
405 | - $alllang = $Language->getLanguages(); |
|
406 | - foreach ($alllang as $key => $lang) { |
|
407 | - print '<option value="'.$key.'"'; |
|
408 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
409 | - print '>'.$lang[0].'</option>'; |
|
410 | - } |
|
411 | - ?> |
|
404 | + $Language = new Language(); |
|
405 | + $alllang = $Language->getLanguages(); |
|
406 | + foreach ($alllang as $key => $lang) { |
|
407 | + print '<option value="'.$key.'"'; |
|
408 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
409 | + print '>'.$lang[0].'</option>'; |
|
410 | + } |
|
411 | + ?> |
|
412 | 412 | </select> |
413 | 413 | </form> |
414 | 414 | </div> |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | } |
445 | 445 | 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)) |
446 | 446 | { |
447 | - ?> |
|
447 | + ?> |
|
448 | 448 | <div class="top-header clear" role="main"> |
449 | 449 | <div id="map"></div> |
450 | 450 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -455,15 +455,15 @@ discard block |
||
455 | 455 | var zoom = 13; |
456 | 456 | //create the map |
457 | 457 | <?php |
458 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
458 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
459 | 459 | ?> |
460 | 460 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
461 | 461 | <?php |
462 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
462 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
463 | 463 | ?> |
464 | 464 | map = L.map('map', { zoomControl:true }); |
465 | 465 | <?php |
466 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
466 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
467 | 467 | ?> |
468 | 468 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
469 | 469 | 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); |
@@ -471,22 +471,22 @@ discard block |
||
471 | 471 | 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); |
472 | 472 | 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); |
473 | 473 | <?php |
474 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
474 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
475 | 475 | ?> |
476 | 476 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
477 | 477 | <?php |
478 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
478 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
479 | 479 | ?> |
480 | 480 | map = L.map('map', { zoomControl:true }); |
481 | 481 | <?php |
482 | - } |
|
482 | + } |
|
483 | 483 | ?> |
484 | 484 | //initialize the layer group for the aircrft markers |
485 | 485 | var layer_data = L.layerGroup(); |
486 | 486 | |
487 | 487 | //a few title layers |
488 | 488 | <?php |
489 | - if ($globalMapProvider == 'Mapbox') { |
|
489 | + if ($globalMapProvider == 'Mapbox') { |
|
490 | 490 | ?> |
491 | 491 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
492 | 492 | maxZoom: 18, |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | token : '<?php print $globalMapboxToken; ?>' |
498 | 498 | }).addTo(map); |
499 | 499 | <?php |
500 | - } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
500 | + } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
501 | 501 | ?> |
502 | 502 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
503 | 503 | maxZoom: 18, |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>' |
506 | 506 | }).addTo(map); |
507 | 507 | <?php |
508 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
508 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
509 | 509 | ?> |
510 | 510 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
511 | 511 | maxZoom: 18, |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
515 | 515 | }).addTo(map); |
516 | 516 | <?php |
517 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
517 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
518 | 518 | ?> |
519 | 519 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
520 | 520 | maxZoom: 18, |
@@ -523,27 +523,27 @@ discard block |
||
523 | 523 | '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"' |
524 | 524 | }).addTo(map); |
525 | 525 | <?php |
526 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
526 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
527 | 527 | ?> |
528 | 528 | var googleLayer = new L.Google('ROADMAP'); |
529 | 529 | map.addLayer(googleLayer); |
530 | 530 | <?php |
531 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
531 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
532 | 532 | ?> |
533 | 533 | var googleLayer = new L.Google('SATELLITE'); |
534 | 534 | map.addLayer(googleLayer); |
535 | 535 | <?php |
536 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
536 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
537 | 537 | ?> |
538 | 538 | var googleLayer = new L.Google('HYBRID'); |
539 | 539 | map.addLayer(googleLayer); |
540 | 540 | <?php |
541 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
541 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
542 | 542 | ?> |
543 | 543 | var googleLayer = new L.Google('Terrain'); |
544 | 544 | map.addLayer(googleLayer); |
545 | 545 | <?php |
546 | - } |
|
546 | + } |
|
547 | 547 | ?> |
548 | 548 | </script> |
549 | 549 | </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; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | require_once('require/class.Satellite.php'); |
6 | 6 | |
7 | -$trackident = filter_input(INPUT_GET,'trackid',FILTER_SANITIZE_STRING); |
|
7 | +$trackident = filter_input(INPUT_GET, 'trackid', FILTER_SANITIZE_STRING); |
|
8 | 8 | if ($trackident != '') { |
9 | 9 | require_once('require/class.SpotterLive.php'); |
10 | 10 | $SpotterLive = new SpotterLive(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $spotterid = $Spotter->getSpotterIDBasedOnFlightAwareID($trackident); |
15 | 15 | header('Location: '.$globalURL.'/flightid/'.$spotterid); |
16 | 16 | } else { |
17 | - setcookie('MapTrack',$resulttrackident[0]['flightaware_id']); |
|
17 | + setcookie('MapTrack', $resulttrackident[0]['flightaware_id']); |
|
18 | 18 | } |
19 | 19 | } else { |
20 | 20 | unset($_COOKIE['MapTrack']); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | <div class="form-group"> |
119 | 119 | <label>From (UTC):</label> |
120 | 120 | <div class='input-group date' id='datetimepicker1'> |
121 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
121 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a", $_COOKIE['archive_begin']); ?>" required /> |
|
122 | 122 | <span class="input-group-addon"> |
123 | 123 | <span class="glyphicon glyphicon-calendar"></span> |
124 | 124 | </span> |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <div class="form-group"> |
128 | 128 | <label>To (UTC):</label> |
129 | 129 | <div class='input-group date' id='datetimepicker2'> |
130 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
130 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a", $_COOKIE['archive_end']); ?>" /> |
|
131 | 131 | <span class="input-group-addon"> |
132 | 132 | <span class="glyphicon glyphicon-calendar"></span> |
133 | 133 | </span> |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | <li><?php echo _("Type of Terrain:"); ?> |
249 | 249 | <select class="selectpicker" onchange="terrainType(this);"> |
250 | 250 | <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
251 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
252 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
251 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected'; ?>>ellipsoid</option> |
|
252 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected'; ?>>vr terrain</option> |
|
253 | 253 | </select> |
254 | 254 | </li> |
255 | 255 | <?php |
@@ -346,10 +346,10 @@ discard block |
||
346 | 346 | <select class="selectpicker" multiple onchange="airlines(this);"> |
347 | 347 | <?php |
348 | 348 | $Spotter = new Spotter(); |
349 | - foreach($Spotter->getAllAirlineNames() as $airline) { |
|
349 | + foreach ($Spotter->getAllAirlineNames() as $airline) { |
|
350 | 350 | $airline_name = $airline['airline_name']; |
351 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
352 | - if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['Airlines']))) { |
|
351 | + if (strlen($airline_name) > 30) $airline_name = substr($airline_name, 0, 30).'...'; |
|
352 | + if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'], explode(',', $_COOKIE['Airlines']))) { |
|
353 | 353 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
354 | 354 | } else { |
355 | 355 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | <select class="selectpicker" multiple onchange="sources(this);"> |
366 | 366 | <?php |
367 | 367 | $Spotter = new Spotter(); |
368 | - foreach($Spotter->getAllSourceName('aprs') as $source) { |
|
369 | - if (isset($_COOKIE['Sources']) && in_array($source['source_name'],explode(',',$_COOKIE['Sources']))) { |
|
368 | + foreach ($Spotter->getAllSourceName('aprs') as $source) { |
|
369 | + if (isset($_COOKIE['Sources']) && in_array($source['source_name'], explode(',', $_COOKIE['Sources']))) { |
|
370 | 370 | echo '<option value="'.$source['source_name'].'" selected>'.$source['source_name'].'</option>'; |
371 | 371 | } else { |
372 | 372 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
452 | 452 | else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
453 | 453 | |
454 | - if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
|
454 | + if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'], explode(',', $_COOKIE['sattypes']))) { |
|
455 | 455 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
456 | 456 | } else { |
457 | 457 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | <div id="showdetails" class="showdetails"></div> |
35 | 35 | <div id="infobox" class="infobox"></div> |
36 | 36 | <?php |
37 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
37 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
38 | 38 | |
39 | 39 | ?> |
40 | 40 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
41 | 41 | <?php |
42 | - } |
|
42 | + } |
|
43 | 43 | ?> |
44 | 44 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
45 | 45 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -53,31 +53,31 @@ discard block |
||
53 | 53 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
54 | 54 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
55 | 55 | <?php |
56 | - if (isset($globalArchive) && $globalArchive == TRUE && (isset($globalBeta) && $globalBeta == TRUE)) { |
|
56 | + if (isset($globalArchive) && $globalArchive == TRUE && (isset($globalBeta) && $globalBeta == TRUE)) { |
|
57 | 57 | ?> |
58 | 58 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
59 | 59 | <?php |
60 | - } |
|
60 | + } |
|
61 | 61 | ?> |
62 | 62 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
63 | 63 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
64 | 64 | <?php |
65 | - if (isset($globalMap3D) && $globalMap3D) { |
|
65 | + if (isset($globalMap3D) && $globalMap3D) { |
|
66 | 66 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
67 | 67 | ?> |
68 | 68 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
69 | 69 | <?php |
70 | - } else { |
|
71 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
70 | + } else { |
|
71 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
72 | 72 | ?> |
73 | 73 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
74 | 74 | <?php |
75 | - } |
|
75 | + } |
|
76 | 76 | ?> |
77 | 77 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
78 | 78 | <?php |
79 | 79 | } |
80 | - } |
|
80 | + } |
|
81 | 81 | ?> |
82 | 82 | </ul> |
83 | 83 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ?> |
110 | 110 | </div> |
111 | 111 | <?php |
112 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
112 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
113 | 113 | ?> |
114 | 114 | <div class="sidebar-pane" id="archive"> |
115 | 115 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | </form> |
166 | 166 | </div> |
167 | 167 | <?php |
168 | - } |
|
168 | + } |
|
169 | 169 | ?> |
170 | 170 | <div class="sidebar-pane" id="settings"> |
171 | 171 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -176,56 +176,56 @@ discard block |
||
176 | 176 | <?php |
177 | 177 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
178 | 178 | else $MapType = $_COOKIE['MapType']; |
179 | - ?> |
|
179 | + ?> |
|
180 | 180 | <?php |
181 | 181 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
182 | - ?> |
|
182 | + ?> |
|
183 | 183 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
184 | 184 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
185 | 185 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
186 | 186 | <?php |
187 | 187 | } |
188 | - ?> |
|
188 | + ?> |
|
189 | 189 | <?php |
190 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
191 | - ?> |
|
190 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
191 | + ?> |
|
192 | 192 | <?php |
193 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
194 | - ?> |
|
193 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
194 | + ?> |
|
195 | 195 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
196 | 196 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
197 | 197 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
198 | 198 | <?php |
199 | - } |
|
200 | - ?> |
|
199 | + } |
|
200 | + ?> |
|
201 | 201 | <?php |
202 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
203 | - ?> |
|
202 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
203 | + ?> |
|
204 | 204 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
205 | 205 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
206 | 206 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
207 | 207 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
208 | 208 | <?php |
209 | - } |
|
210 | - ?> |
|
209 | + } |
|
210 | + ?> |
|
211 | 211 | <?php |
212 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
213 | - ?> |
|
212 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
213 | + ?> |
|
214 | 214 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
215 | 215 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
216 | 216 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
217 | 217 | <?php |
218 | - } |
|
219 | - ?> |
|
218 | + } |
|
219 | + ?> |
|
220 | 220 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
221 | 221 | <?php |
222 | 222 | } |
223 | - ?> |
|
223 | + ?> |
|
224 | 224 | <?php |
225 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
225 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
226 | 226 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
227 | 227 | else $MapBoxId = $_COOKIE['MapTypeId']; |
228 | - ?> |
|
228 | + ?> |
|
229 | 229 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
230 | 230 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
231 | 231 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
240 | 240 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
241 | 241 | <?php |
242 | - } |
|
243 | - ?> |
|
242 | + } |
|
243 | + ?> |
|
244 | 244 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
245 | 245 | </select> |
246 | 246 | </li> |
247 | 247 | <?php |
248 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
248 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
249 | 249 | ?> |
250 | 250 | <li><?php echo _("Type of Terrain:"); ?> |
251 | 251 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | </select> |
256 | 256 | </li> |
257 | 257 | <?php |
258 | - } |
|
258 | + } |
|
259 | 259 | ?> |
260 | 260 | <?php |
261 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
261 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
262 | 262 | ?> |
263 | 263 | |
264 | 264 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -266,54 +266,54 @@ discard block |
||
266 | 266 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
267 | 267 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
268 | 268 | <?php |
269 | - } |
|
269 | + } |
|
270 | 270 | ?> |
271 | 271 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
272 | 272 | <?php |
273 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
273 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
274 | 274 | ?> |
275 | 275 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
276 | 276 | <?php |
277 | - } |
|
277 | + } |
|
278 | 278 | ?> |
279 | 279 | |
280 | 280 | <?php |
281 | 281 | if (function_exists('array_column')) { |
282 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
283 | - ?> |
|
282 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
283 | + ?> |
|
284 | 284 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
285 | 285 | <?php |
286 | - } |
|
286 | + } |
|
287 | 287 | } elseif (isset($globalSources)) { |
288 | - $dispolar = false; |
|
289 | - foreach ($globalSources as $testsource) { |
|
290 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
291 | - } |
|
292 | - if ($dispolar) { |
|
293 | - ?> |
|
288 | + $dispolar = false; |
|
289 | + foreach ($globalSources as $testsource) { |
|
290 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
291 | + } |
|
292 | + if ($dispolar) { |
|
293 | + ?> |
|
294 | 294 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
295 | 295 | <?php |
296 | - } |
|
297 | - } |
|
298 | - ?> |
|
296 | + } |
|
297 | + } |
|
298 | + ?> |
|
299 | 299 | <?php |
300 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
300 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
301 | 301 | ?> |
302 | 302 | |
303 | 303 | <?php |
304 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
305 | - ?> |
|
304 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
305 | + ?> |
|
306 | 306 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
307 | 307 | <?php |
308 | 308 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
309 | - ?> |
|
309 | + ?> |
|
310 | 310 | <li><?php echo _("Aircraft icon color:"); ?> |
311 | 311 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
312 | 312 | </li> |
313 | 313 | <?php |
314 | - } |
|
315 | - } |
|
316 | - ?> |
|
314 | + } |
|
315 | + } |
|
316 | + ?> |
|
317 | 317 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
318 | 318 | <div class="range"> |
319 | 319 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -321,20 +321,20 @@ discard block |
||
321 | 321 | </div> |
322 | 322 | </li> |
323 | 323 | <?php |
324 | - } |
|
324 | + } |
|
325 | 325 | ?> |
326 | 326 | <?php |
327 | 327 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
328 | - ?> |
|
328 | + ?> |
|
329 | 329 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
330 | 330 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
331 | 331 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
332 | 332 | <?php |
333 | 333 | } |
334 | - ?> |
|
334 | + ?> |
|
335 | 335 | <?php |
336 | 336 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
337 | - ?> |
|
337 | + ?> |
|
338 | 338 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
339 | 339 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
340 | 340 | <?php } ?> |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | <?php } ?> |
344 | 344 | <?php |
345 | 345 | } |
346 | - ?> |
|
346 | + ?> |
|
347 | 347 | <li><?php echo _("Display airlines:"); ?> |
348 | 348 | <select class="selectpicker" multiple onchange="airlines(this);"> |
349 | 349 | <?php |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
358 | 358 | } |
359 | 359 | } |
360 | - ?> |
|
360 | + ?> |
|
361 | 361 | </select> |
362 | 362 | </li> |
363 | 363 | <?php |
364 | 364 | if (isset($globalAPRS) && $globalAPRS) { |
365 | - ?> |
|
365 | + ?> |
|
366 | 366 | <li><?php echo _("Display APRS sources name:"); ?> |
367 | 367 | <select class="selectpicker" multiple onchange="sources(this);"> |
368 | 368 | <?php |
@@ -374,15 +374,15 @@ discard block |
||
374 | 374 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
375 | 375 | } |
376 | 376 | } |
377 | - ?> |
|
377 | + ?> |
|
378 | 378 | </select> |
379 | 379 | </li> |
380 | 380 | <?php |
381 | 381 | } |
382 | - ?> |
|
382 | + ?> |
|
383 | 383 | <?php |
384 | 384 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
385 | - ?> |
|
385 | + ?> |
|
386 | 386 | <li><?php echo _("Display airlines of type:"); ?> |
387 | 387 | <select class="selectpicker" onchange="airlinestype(this);"> |
388 | 388 | <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | </li> |
394 | 394 | <?php |
395 | 395 | } |
396 | - ?> |
|
396 | + ?> |
|
397 | 397 | <li><?php echo _("Distance unit:"); ?> |
398 | 398 | <select class="selectpicker" onchange="unitdistance(this);"> |
399 | 399 | <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option> |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | <p><?php echo _("Any change in settings reload page"); ?></p> |
420 | 420 | </div> |
421 | 421 | <?php |
422 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
422 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
423 | 423 | ?> |
424 | 424 | <div class="sidebar-pane" id="satellites"> |
425 | 425 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -459,14 +459,14 @@ discard block |
||
459 | 459 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
460 | 460 | } |
461 | 461 | } |
462 | - ?> |
|
462 | + ?> |
|
463 | 463 | </select> |
464 | 464 | </li> |
465 | 465 | </ul> |
466 | 466 | </form> |
467 | 467 | </div> |
468 | 468 | <?php |
469 | - } |
|
469 | + } |
|
470 | 470 | ?> |
471 | 471 | </div> |
472 | 472 | </div> |
@@ -108,11 +108,26 @@ discard block |
||
108 | 108 | <li><div class="checkbox"><label><input type="checkbox" name="notam" value="1" onclick="showNotam();" /><?php echo _("NOTAM"); ?></label></div></li> |
109 | 109 | <li><?php echo _("NOTAM scope:"); ?> |
110 | 110 | <select class="selectpicker" onchange="notamscope(this);"> |
111 | - <option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option> |
|
112 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option> |
|
113 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option> |
|
114 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option> |
|
115 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option> |
|
111 | + <option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') { |
|
112 | + print ' selected'; |
|
113 | +} |
|
114 | +?>>All</option> |
|
115 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') { |
|
116 | + print ' selected'; |
|
117 | +} |
|
118 | +?>>Airport/Enroute warning</option> |
|
119 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') { |
|
120 | + print ' selected'; |
|
121 | +} |
|
122 | +?>>Airport warning</option> |
|
123 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') { |
|
124 | + print ' selected'; |
|
125 | +} |
|
126 | +?>>Navigation warning</option> |
|
127 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') { |
|
128 | + print ' selected'; |
|
129 | +} |
|
130 | +?>>Enroute warning</option> |
|
116 | 131 | </select |
117 | 132 | </li> |
118 | 133 | <?php |
@@ -133,7 +148,10 @@ discard block |
||
133 | 148 | <div class="form-group"> |
134 | 149 | <label>From (UTC):</label> |
135 | 150 | <div class='input-group date' id='datetimepicker1'> |
136 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
151 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) { |
|
152 | + print date("d/m/Y h:i a",$_COOKIE['archive_begin']); |
|
153 | +} |
|
154 | +?>" required /> |
|
137 | 155 | <span class="input-group-addon"> |
138 | 156 | <span class="glyphicon glyphicon-calendar"></span> |
139 | 157 | </span> |
@@ -142,7 +160,10 @@ discard block |
||
142 | 160 | <div class="form-group"> |
143 | 161 | <label>To (UTC):</label> |
144 | 162 | <div class='input-group date' id='datetimepicker2'> |
145 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
163 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) { |
|
164 | + print date("d/m/Y h:i a",$_COOKIE['archive_end']); |
|
165 | +} |
|
166 | +?>" /> |
|
146 | 167 | <span class="input-group-addon"> |
147 | 168 | <span class="glyphicon glyphicon-calendar"></span> |
148 | 169 | </span> |
@@ -165,8 +186,18 @@ discard block |
||
165 | 186 | |
166 | 187 | <li><?php echo _("Playback speed:"); ?> |
167 | 188 | <div class="range"> |
168 | - <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>"> |
|
169 | - <output id="archivespeedrange"><?php if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output> |
|
189 | + <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php if (isset($_COOKIE['archive_speed'])) { |
|
190 | + print $_COOKIE['archive_speed']; |
|
191 | +} else { |
|
192 | + print '1'; |
|
193 | +} |
|
194 | +?>"> |
|
195 | + <output id="archivespeedrange"><?php if (isset($_COOKIE['archive_speed'])) { |
|
196 | + print $_COOKIE['archive_speed']; |
|
197 | +} else { |
|
198 | + print '1'; |
|
199 | +} |
|
200 | +?></output> |
|
170 | 201 | </div> |
171 | 202 | </li> |
172 | 203 | |
@@ -187,15 +218,27 @@ discard block |
||
187 | 218 | <li><?php echo _("Type of Map:"); ?> |
188 | 219 | <select class="selectpicker" onchange="mapType(this);"> |
189 | 220 | <?php |
190 | - if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
|
191 | - else $MapType = $_COOKIE['MapType']; |
|
221 | + if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') { |
|
222 | + $MapType = $globalMapProvider; |
|
223 | + } else { |
|
224 | + $MapType = $_COOKIE['MapType']; |
|
225 | + } |
|
192 | 226 | ?> |
193 | 227 | <?php |
194 | 228 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
195 | 229 | ?> |
196 | - <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
|
197 | - <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
|
198 | - <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
|
230 | + <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') { |
|
231 | + print ' selected'; |
|
232 | +} |
|
233 | +?>>Bing-Aerial</option> |
|
234 | + <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') { |
|
235 | + print ' selected'; |
|
236 | +} |
|
237 | +?>>Bing-Hybrid</option> |
|
238 | + <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') { |
|
239 | + print ' selected'; |
|
240 | +} |
|
241 | +?>>Bing-Road</option> |
|
199 | 242 | <?php |
200 | 243 | } |
201 | 244 | ?> |
@@ -205,56 +248,131 @@ discard block |
||
205 | 248 | <?php |
206 | 249 | if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
207 | 250 | ?> |
208 | - <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
|
209 | - <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
|
210 | - <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
|
251 | + <option value="Here-Aerial"<?php if ($MapType == 'Here') { |
|
252 | + print ' selected'; |
|
253 | +} |
|
254 | +?>>Here-Aerial</option> |
|
255 | + <option value="Here-Hybrid"<?php if ($MapType == 'Here') { |
|
256 | + print ' selected'; |
|
257 | +} |
|
258 | +?>>Here-Hybrid</option> |
|
259 | + <option value="Here-Road"<?php if ($MapType == 'Here') { |
|
260 | + print ' selected'; |
|
261 | +} |
|
262 | +?>>Here-Road</option> |
|
211 | 263 | <?php |
212 | 264 | } |
213 | 265 | ?> |
214 | 266 | <?php |
215 | 267 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
216 | 268 | ?> |
217 | - <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
|
218 | - <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
|
219 | - <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
|
220 | - <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
|
269 | + <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') { |
|
270 | + print ' selected'; |
|
271 | +} |
|
272 | +?>>Google Roadmap</option> |
|
273 | + <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') { |
|
274 | + print ' selected'; |
|
275 | +} |
|
276 | +?>>Google Satellite</option> |
|
277 | + <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') { |
|
278 | + print ' selected'; |
|
279 | +} |
|
280 | +?>>Google Hybrid</option> |
|
281 | + <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') { |
|
282 | + print ' selected'; |
|
283 | +} |
|
284 | +?>>Google Terrain</option> |
|
221 | 285 | <?php |
222 | 286 | } |
223 | 287 | ?> |
224 | 288 | <?php |
225 | 289 | if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
226 | 290 | ?> |
227 | - <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
|
228 | - <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
|
229 | - <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
|
291 | + <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') { |
|
292 | + print ' selected'; |
|
293 | +} |
|
294 | +?>>MapQuest-OSM</option> |
|
295 | + <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') { |
|
296 | + print ' selected'; |
|
297 | +} |
|
298 | +?>>MapQuest-Aerial</option> |
|
299 | + <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') { |
|
300 | + print ' selected'; |
|
301 | +} |
|
302 | +?>>MapQuest-Hybrid</option> |
|
230 | 303 | <?php |
231 | 304 | } |
232 | 305 | ?> |
233 | - <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
|
306 | + <option value="Yandex"<?php if ($MapType == 'Yandex') { |
|
307 | + print ' selected'; |
|
308 | +} |
|
309 | +?>>Yandex</option> |
|
234 | 310 | <?php |
235 | 311 | } |
236 | 312 | ?> |
237 | 313 | <?php |
238 | 314 | if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
239 | - if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
|
240 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
315 | + if (!isset($_COOKIE['MapTypeId'])) { |
|
316 | + $MapBoxId = 'default'; |
|
317 | + } else { |
|
318 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
319 | + } |
|
241 | 320 | ?> |
242 | - <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
|
243 | - <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
|
244 | - <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
|
245 | - <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option> |
|
246 | - <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option> |
|
247 | - <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option> |
|
248 | - <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option> |
|
249 | - <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option> |
|
250 | - <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option> |
|
251 | - <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option> |
|
252 | - <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
|
253 | - <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
|
321 | + <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') { |
|
322 | + print ' selected'; |
|
323 | +} |
|
324 | +?>>Mapbox default</option> |
|
325 | + <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') { |
|
326 | + print ' selected'; |
|
327 | +} |
|
328 | +?>>Mapbox streets</option> |
|
329 | + <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') { |
|
330 | + print ' selected'; |
|
331 | +} |
|
332 | +?>>Mapbox light</option> |
|
333 | + <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') { |
|
334 | + print ' selected'; |
|
335 | +} |
|
336 | +?>>Mapbox dark</option> |
|
337 | + <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') { |
|
338 | + print ' selected'; |
|
339 | +} |
|
340 | +?>>Mapbox satellite</option> |
|
341 | + <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') { |
|
342 | + print ' selected'; |
|
343 | +} |
|
344 | +?>>Mapbox streets-satellite</option> |
|
345 | + <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') { |
|
346 | + print ' selected'; |
|
347 | +} |
|
348 | +?>>Mapbox streets-basic</option> |
|
349 | + <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') { |
|
350 | + print ' selected'; |
|
351 | +} |
|
352 | +?>>Mapbox comic</option> |
|
353 | + <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') { |
|
354 | + print ' selected'; |
|
355 | +} |
|
356 | +?>>Mapbox outdoors</option> |
|
357 | + <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') { |
|
358 | + print ' selected'; |
|
359 | +} |
|
360 | +?>>Mapbox pencil</option> |
|
361 | + <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') { |
|
362 | + print ' selected'; |
|
363 | +} |
|
364 | +?>>Mapbox pirates</option> |
|
365 | + <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') { |
|
366 | + print ' selected'; |
|
367 | +} |
|
368 | +?>>Mapbox emerald</option> |
|
254 | 369 | <?php |
255 | 370 | } |
256 | 371 | ?> |
257 | - <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
|
372 | + <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') { |
|
373 | + print ' selected'; |
|
374 | +} |
|
375 | +?>>OpenStreetMap</option> |
|
258 | 376 | </select> |
259 | 377 | </li> |
260 | 378 | <?php |
@@ -262,9 +380,18 @@ discard block |
||
262 | 380 | ?> |
263 | 381 | <li><?php echo _("Type of Terrain:"); ?> |
264 | 382 | <select class="selectpicker" onchange="terrainType(this);"> |
265 | - <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
|
266 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
267 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
383 | + <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') { |
|
384 | + print ' selected'; |
|
385 | +} |
|
386 | +?>>stk terrain</option> |
|
387 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') { |
|
388 | + print ' selected'; |
|
389 | +} |
|
390 | +?>>ellipsoid</option> |
|
391 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') { |
|
392 | + print ' selected'; |
|
393 | +} |
|
394 | +?>>vr terrain</option> |
|
268 | 395 | </select> |
269 | 396 | </li> |
270 | 397 | <?php |
@@ -274,18 +401,36 @@ discard block |
||
274 | 401 | if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
275 | 402 | ?> |
276 | 403 | |
277 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
|
278 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li> |
|
279 | - <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
|
280 | - <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
|
404 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') { |
|
405 | + print 'checked'; |
|
406 | +} |
|
407 | +?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
|
408 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) { |
|
409 | + print 'checked'; |
|
410 | +} |
|
411 | +?> ><?php echo _("Display flight path"); ?></label></div></li> |
|
412 | + <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) { |
|
413 | + print 'checked'; |
|
414 | +} |
|
415 | +?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
|
416 | + <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) { |
|
417 | + print 'checked'; |
|
418 | +} |
|
419 | +?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
|
281 | 420 | <?php |
282 | 421 | } |
283 | 422 | ?> |
284 | - <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
|
423 | + <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') { |
|
424 | + print 'checked'; |
|
425 | +} |
|
426 | +?> ><?php echo _("Display airports on map"); ?></label></div></li> |
|
285 | 427 | <?php |
286 | 428 | if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
287 | 429 | ?> |
288 | - <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
|
430 | + <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) { |
|
431 | + print 'checked'; |
|
432 | +} |
|
433 | +?> ><?php echo _("Show mini-map"); ?></label></div></li> |
|
289 | 434 | <?php |
290 | 435 | } |
291 | 436 | ?> |
@@ -294,17 +439,25 @@ discard block |
||
294 | 439 | if (function_exists('array_column')) { |
295 | 440 | if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
296 | 441 | ?> |
297 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
442 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
|
443 | + print 'checked'; |
|
444 | +} |
|
445 | +?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
298 | 446 | <?php |
299 | 447 | } |
300 | 448 | } elseif (isset($globalSources)) { |
301 | 449 | $dispolar = false; |
302 | 450 | foreach ($globalSources as $testsource) { |
303 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
451 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) { |
|
452 | + $dispolar = true; |
|
453 | + } |
|
304 | 454 | } |
305 | 455 | if ($dispolar) { |
306 | 456 | ?> |
307 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
457 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
|
458 | + print 'checked'; |
|
459 | +} |
|
460 | +?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
308 | 461 | <?php |
309 | 462 | } |
310 | 463 | } |
@@ -316,12 +469,22 @@ discard block |
||
316 | 469 | <?php |
317 | 470 | if (extension_loaded('gd') && function_exists('gd_info')) { |
318 | 471 | ?> |
319 | - <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
|
472 | + <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') { |
|
473 | + print 'checked'; |
|
474 | +} |
|
475 | +?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
|
320 | 476 | <?php |
321 | 477 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
322 | 478 | ?> |
323 | 479 | <li><?php echo _("Aircraft icon color:"); ?> |
324 | - <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
|
480 | + <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) { |
|
481 | + print $_COOKIE['IconColor']; |
|
482 | +} elseif (isset($globalAircraftIconColor)) { |
|
483 | + print $globalAircraftIconColor; |
|
484 | +} else { |
|
485 | + print '1a3151'; |
|
486 | +} |
|
487 | +?>"> |
|
325 | 488 | </li> |
326 | 489 | <?php |
327 | 490 | } |
@@ -329,8 +492,22 @@ discard block |
||
329 | 492 | ?> |
330 | 493 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
331 | 494 | <div class="range"> |
332 | - <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
|
333 | - <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output> |
|
495 | + <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) { |
|
496 | + print $_COOKIE['AirportZoom']; |
|
497 | +} elseif (isset($globalAirportZoom)) { |
|
498 | + print $globalAirportZoom; |
|
499 | +} else { |
|
500 | + print '7'; |
|
501 | +} |
|
502 | +?>"> |
|
503 | + <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) { |
|
504 | + print $_COOKIE['AirportZoom']; |
|
505 | +} elseif (isset($globalAirportZoom)) { |
|
506 | + print $globalAirportZoom; |
|
507 | +} else { |
|
508 | + print '7'; |
|
509 | +} |
|
510 | +?></output> |
|
334 | 511 | </div> |
335 | 512 | </li> |
336 | 513 | <?php |
@@ -339,9 +516,18 @@ discard block |
||
339 | 516 | <?php |
340 | 517 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
341 | 518 | ?> |
342 | - <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
|
343 | - <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
|
344 | - <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
|
519 | + <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) { |
|
520 | + print 'checked'; |
|
521 | +} |
|
522 | +?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
|
523 | + <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) { |
|
524 | + print 'checked'; |
|
525 | +} |
|
526 | +?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
|
527 | + <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) { |
|
528 | + print 'checked'; |
|
529 | +} |
|
530 | +?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
|
345 | 531 | <?php |
346 | 532 | } |
347 | 533 | ?> |
@@ -349,10 +535,16 @@ discard block |
||
349 | 535 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
350 | 536 | ?> |
351 | 537 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
352 | - <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
|
538 | + <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) { |
|
539 | + print 'checked'; |
|
540 | +} |
|
541 | +?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
|
353 | 542 | <?php } ?> |
354 | 543 | <?php if (isset($globalAPRS) && $globalAPRS) { ?> |
355 | - <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li> |
|
544 | + <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) { |
|
545 | + print 'checked'; |
|
546 | +} |
|
547 | +?> ><?php echo _("Display APRS data"); ?></label></div></li> |
|
356 | 548 | <?php } ?> |
357 | 549 | <?php |
358 | 550 | } |
@@ -363,7 +555,9 @@ discard block |
||
363 | 555 | $Spotter = new Spotter(); |
364 | 556 | foreach($Spotter->getAllAirlineNames() as $airline) { |
365 | 557 | $airline_name = $airline['airline_name']; |
366 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
558 | + if (strlen($airline_name) > 30) { |
|
559 | + $airline_name = substr($airline_name,0,30).'...'; |
|
560 | + } |
|
367 | 561 | if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['Airlines']))) { |
368 | 562 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
369 | 563 | } else { |
@@ -398,10 +592,22 @@ discard block |
||
398 | 592 | ?> |
399 | 593 | <li><?php echo _("Display airlines of type:"); ?> |
400 | 594 | <select class="selectpicker" onchange="airlinestype(this);"> |
401 | - <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
|
402 | - <option value="passenger"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option> |
|
403 | - <option value="cargo"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option> |
|
404 | - <option value="military"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option> |
|
595 | + <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') { |
|
596 | + echo ' selected'; |
|
597 | +} |
|
598 | +?>><?php echo _("All"); ?></option> |
|
599 | + <option value="passenger"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'passenger') { |
|
600 | + echo ' selected'; |
|
601 | +} |
|
602 | +?>><?php echo _("Passenger"); ?></option> |
|
603 | + <option value="cargo"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'cargo') { |
|
604 | + echo ' selected'; |
|
605 | +} |
|
606 | +?>><?php echo _("Cargo"); ?></option> |
|
607 | + <option value="military"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'military') { |
|
608 | + echo ' selected'; |
|
609 | +} |
|
610 | +?>><?php echo _("Military"); ?></option> |
|
405 | 611 | </select> |
406 | 612 | </li> |
407 | 613 | <?php |
@@ -409,22 +615,46 @@ discard block |
||
409 | 615 | ?> |
410 | 616 | <li><?php echo _("Distance unit:"); ?> |
411 | 617 | <select class="selectpicker" onchange="unitdistance(this);"> |
412 | - <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option> |
|
413 | - <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option> |
|
414 | - <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option> |
|
618 | + <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
619 | + echo ' selected'; |
|
620 | +} |
|
621 | +?>>km</option> |
|
622 | + <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
623 | + echo ' selected'; |
|
624 | +} |
|
625 | +?>>nm</option> |
|
626 | + <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
627 | + echo ' selected'; |
|
628 | +} |
|
629 | +?>>mi</option> |
|
415 | 630 | </select> |
416 | 631 | </li> |
417 | 632 | <li><?php echo _("Altitude unit:"); ?> |
418 | 633 | <select class="selectpicker" onchange="unitaltitude(this);"> |
419 | - <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option> |
|
420 | - <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option> |
|
634 | + <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) { |
|
635 | + echo ' selected'; |
|
636 | +} |
|
637 | +?>>m</option> |
|
638 | + <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
639 | + echo ' selected'; |
|
640 | +} |
|
641 | +?>>feet</option> |
|
421 | 642 | </select> |
422 | 643 | </li> |
423 | 644 | <li><?php echo _("Speed unit:"); ?> |
424 | 645 | <select class="selectpicker" onchange="unitspeed(this);"> |
425 | - <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option> |
|
426 | - <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option> |
|
427 | - <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option> |
|
646 | + <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) { |
|
647 | + echo ' selected'; |
|
648 | +} |
|
649 | +?>>km/h</option> |
|
650 | + <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
|
651 | + echo ' selected'; |
|
652 | +} |
|
653 | +?>>mph</option> |
|
654 | + <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) { |
|
655 | + echo ' selected'; |
|
656 | +} |
|
657 | +?>>knots</option> |
|
428 | 658 | </select> |
429 | 659 | </li> |
430 | 660 | </ul> |
@@ -438,7 +668,10 @@ discard block |
||
438 | 668 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
439 | 669 | <form> |
440 | 670 | <ul> |
441 | - <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li> |
|
671 | + <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') { |
|
672 | + print 'checked'; |
|
673 | +} |
|
674 | +?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li> |
|
442 | 675 | <li><?php echo _("Type:"); ?> |
443 | 676 | <select class="selectpicker" multiple onchange="sattypes(this);"> |
444 | 677 | <?php |
@@ -446,25 +679,45 @@ discard block |
||
446 | 679 | $types = $Satellite->get_tle_types(); |
447 | 680 | foreach ($types as $type) { |
448 | 681 | $type_name = $type['tle_type']; |
449 | - if ($type_name == 'musson') $type_name = 'Russian LEO Navigation'; |
|
450 | - else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System'; |
|
451 | - else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System'; |
|
452 | - else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational'; |
|
453 | - else if ($type_name == 'gps-ops') $type_name = 'GPS Operational'; |
|
454 | - else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System'; |
|
455 | - else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System'; |
|
456 | - else if ($type_name == 'sarsat') $type_name = 'Search & Rescue'; |
|
457 | - else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring'; |
|
458 | - else if ($type_name == 'resource') $type_name = 'Earth Resources'; |
|
459 | - else if ($type_name == 'stations') $type_name = 'Space Stations'; |
|
460 | - else if ($type_name == 'geo') $type_name = 'Geostationary'; |
|
461 | - else if ($type_name == 'amateur') $type_name = 'Amateur Radio'; |
|
462 | - else if ($type_name == 'x-comm') $type_name = 'Experimental'; |
|
463 | - else if ($type_name == 'other-comm') $type_name = 'Other Comm'; |
|
464 | - else if ($type_name == 'science') $type_name = 'Space & Earth Science'; |
|
465 | - else if ($type_name == 'military') $type_name = 'Miscellaneous Military'; |
|
466 | - else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
|
467 | - else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
|
682 | + if ($type_name == 'musson') { |
|
683 | + $type_name = 'Russian LEO Navigation'; |
|
684 | + } else if ($type_name == 'nnss') { |
|
685 | + $type_name = 'Navi Navigation Satellite System'; |
|
686 | + } else if ($type_name == 'sbas') { |
|
687 | + $type_name = 'Satellite-Based Augmentation System'; |
|
688 | + } else if ($type_name == 'glo-ops') { |
|
689 | + $type_name = 'Glonass Operational'; |
|
690 | + } else if ($type_name == 'gps-ops') { |
|
691 | + $type_name = 'GPS Operational'; |
|
692 | + } else if ($type_name == 'argos') { |
|
693 | + $type_name = 'ARGOS Data Collection System'; |
|
694 | + } else if ($type_name == 'tdrss') { |
|
695 | + $type_name = 'Tracking and Data Relay Satellite System'; |
|
696 | + } else if ($type_name == 'sarsat') { |
|
697 | + $type_name = 'Search & Rescue'; |
|
698 | + } else if ($type_name == 'dmc') { |
|
699 | + $type_name = 'Disaster Monitoring'; |
|
700 | + } else if ($type_name == 'resource') { |
|
701 | + $type_name = 'Earth Resources'; |
|
702 | + } else if ($type_name == 'stations') { |
|
703 | + $type_name = 'Space Stations'; |
|
704 | + } else if ($type_name == 'geo') { |
|
705 | + $type_name = 'Geostationary'; |
|
706 | + } else if ($type_name == 'amateur') { |
|
707 | + $type_name = 'Amateur Radio'; |
|
708 | + } else if ($type_name == 'x-comm') { |
|
709 | + $type_name = 'Experimental'; |
|
710 | + } else if ($type_name == 'other-comm') { |
|
711 | + $type_name = 'Other Comm'; |
|
712 | + } else if ($type_name == 'science') { |
|
713 | + $type_name = 'Space & Earth Science'; |
|
714 | + } else if ($type_name == 'military') { |
|
715 | + $type_name = 'Miscellaneous Military'; |
|
716 | + } else if ($type_name == 'radar') { |
|
717 | + $type_name = 'Radar Calibration'; |
|
718 | + } else if ($type_name == 'tle-new') { |
|
719 | + $type_name = 'Last 30 days launches'; |
|
720 | + } |
|
468 | 721 | |
469 | 722 | if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
470 | 723 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
@@ -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); |
@@ -11,215 +11,215 @@ discard block |
||
11 | 11 | public function __construct($dbc = null) { |
12 | 12 | $Connection = new Connection($dbc); |
13 | 13 | $this->db = $Connection->db(); |
14 | - } |
|
14 | + } |
|
15 | 15 | |
16 | 16 | public function addLastStatsUpdate($type,$stats_date) { |
17 | - $query = "DELETE FROM config WHERE name = :type; |
|
17 | + $query = "DELETE FROM config WHERE name = :type; |
|
18 | 18 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
19 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
20 | - try { |
|
21 | - $sth = $this->db->prepare($query); |
|
22 | - $sth->execute($query_values); |
|
23 | - } catch(PDOException $e) { |
|
24 | - return "error : ".$e->getMessage(); |
|
25 | - } |
|
26 | - } |
|
19 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
20 | + try { |
|
21 | + $sth = $this->db->prepare($query); |
|
22 | + $sth->execute($query_values); |
|
23 | + } catch(PDOException $e) { |
|
24 | + return "error : ".$e->getMessage(); |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | 28 | public function getLastStatsUpdate($type = 'last_update_stats') { |
29 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
30 | - try { |
|
31 | - $sth = $this->db->prepare($query); |
|
32 | - $sth->execute(array(':type' => $type)); |
|
33 | - } catch(PDOException $e) { |
|
34 | - echo "error : ".$e->getMessage(); |
|
35 | - } |
|
36 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
37 | - return $all; |
|
38 | - } |
|
29 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
30 | + try { |
|
31 | + $sth = $this->db->prepare($query); |
|
32 | + $sth->execute(array(':type' => $type)); |
|
33 | + } catch(PDOException $e) { |
|
34 | + echo "error : ".$e->getMessage(); |
|
35 | + } |
|
36 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
37 | + return $all; |
|
38 | + } |
|
39 | 39 | public function getAllAirlineNames($filter_name = '') { |
40 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
41 | - try { |
|
42 | - $sth = $this->db->prepare($query); |
|
43 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
44 | - } catch(PDOException $e) { |
|
45 | - echo "error : ".$e->getMessage(); |
|
46 | - } |
|
47 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
48 | - return $all; |
|
49 | - } |
|
40 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
41 | + try { |
|
42 | + $sth = $this->db->prepare($query); |
|
43 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
44 | + } catch(PDOException $e) { |
|
45 | + echo "error : ".$e->getMessage(); |
|
46 | + } |
|
47 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
48 | + return $all; |
|
49 | + } |
|
50 | 50 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
51 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
52 | - try { |
|
53 | - $sth = $this->db->prepare($query); |
|
54 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
55 | - } catch(PDOException $e) { |
|
56 | - echo "error : ".$e->getMessage(); |
|
57 | - } |
|
58 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
59 | - return $all; |
|
60 | - } |
|
51 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
52 | + try { |
|
53 | + $sth = $this->db->prepare($query); |
|
54 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
55 | + } catch(PDOException $e) { |
|
56 | + echo "error : ".$e->getMessage(); |
|
57 | + } |
|
58 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
59 | + return $all; |
|
60 | + } |
|
61 | 61 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
62 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
63 | - try { |
|
64 | - $sth = $this->db->prepare($query); |
|
65 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
66 | - } catch(PDOException $e) { |
|
67 | - echo "error : ".$e->getMessage(); |
|
68 | - } |
|
69 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
70 | - return $all; |
|
71 | - } |
|
62 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
63 | + try { |
|
64 | + $sth = $this->db->prepare($query); |
|
65 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
66 | + } catch(PDOException $e) { |
|
67 | + echo "error : ".$e->getMessage(); |
|
68 | + } |
|
69 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
70 | + return $all; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | 74 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
75 | 75 | global $globalStatsFilters; |
76 | 76 | 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"; |
77 | 77 | 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"; |
78 | - try { |
|
79 | - $sth = $this->db->prepare($query); |
|
80 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
81 | - } catch(PDOException $e) { |
|
82 | - echo "error : ".$e->getMessage(); |
|
83 | - } |
|
84 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
85 | - if (empty($all)) { |
|
86 | - $filters = array('airlines' => array($stats_airline)); |
|
87 | - if ($filter_name != '') { |
|
88 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
89 | - } |
|
90 | - $Spotter = new Spotter($this->db); |
|
91 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
92 | - } |
|
93 | - return $all; |
|
78 | + try { |
|
79 | + $sth = $this->db->prepare($query); |
|
80 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
81 | + } catch(PDOException $e) { |
|
82 | + echo "error : ".$e->getMessage(); |
|
83 | + } |
|
84 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
85 | + if (empty($all)) { |
|
86 | + $filters = array('airlines' => array($stats_airline)); |
|
87 | + if ($filter_name != '') { |
|
88 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
89 | + } |
|
90 | + $Spotter = new Spotter($this->db); |
|
91 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
92 | + } |
|
93 | + return $all; |
|
94 | 94 | } |
95 | 95 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
96 | 96 | global $globalStatsFilters; |
97 | 97 | 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"; |
98 | 98 | 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"; |
99 | - try { |
|
100 | - $sth = $this->db->prepare($query); |
|
101 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
102 | - } catch(PDOException $e) { |
|
103 | - echo "error : ".$e->getMessage(); |
|
104 | - } |
|
105 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
106 | - if (empty($all)) { |
|
107 | - $Spotter = new Spotter($this->db); |
|
108 | - $filters = array(); |
|
109 | - if ($filter_name != '') { |
|
110 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
111 | - } |
|
112 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
113 | - } |
|
114 | - return $all; |
|
99 | + try { |
|
100 | + $sth = $this->db->prepare($query); |
|
101 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
102 | + } catch(PDOException $e) { |
|
103 | + echo "error : ".$e->getMessage(); |
|
104 | + } |
|
105 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
106 | + if (empty($all)) { |
|
107 | + $Spotter = new Spotter($this->db); |
|
108 | + $filters = array(); |
|
109 | + if ($filter_name != '') { |
|
110 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
111 | + } |
|
112 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
113 | + } |
|
114 | + return $all; |
|
115 | 115 | } |
116 | 116 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
117 | 117 | global $globalStatsFilters; |
118 | 118 | 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"; |
119 | 119 | 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"; |
120 | - try { |
|
121 | - $sth = $this->db->prepare($query); |
|
122 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
123 | - } catch(PDOException $e) { |
|
124 | - echo "error : ".$e->getMessage(); |
|
125 | - } |
|
126 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
127 | - if (empty($all)) { |
|
128 | - $filters = array('airlines' => array($stats_airline)); |
|
129 | - if ($filter_name != '') { |
|
130 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | + try { |
|
121 | + $sth = $this->db->prepare($query); |
|
122 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
123 | + } catch(PDOException $e) { |
|
124 | + echo "error : ".$e->getMessage(); |
|
125 | + } |
|
126 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
127 | + if (empty($all)) { |
|
128 | + $filters = array('airlines' => array($stats_airline)); |
|
129 | + if ($filter_name != '') { |
|
130 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
131 | 131 | } |
132 | - $Spotter = new Spotter($this->db); |
|
132 | + $Spotter = new Spotter($this->db); |
|
133 | 133 | $all = $Spotter->countAllAircraftManufacturers($filters); |
134 | - } |
|
135 | - return $all; |
|
134 | + } |
|
135 | + return $all; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
139 | 139 | global $globalStatsFilters; |
140 | 140 | 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"; |
141 | 141 | 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"; |
142 | - try { |
|
143 | - $sth = $this->db->prepare($query); |
|
144 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
145 | - } catch(PDOException $e) { |
|
146 | - echo "error : ".$e->getMessage(); |
|
147 | - } |
|
148 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
149 | - if (empty($all)) { |
|
142 | + try { |
|
143 | + $sth = $this->db->prepare($query); |
|
144 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
145 | + } catch(PDOException $e) { |
|
146 | + echo "error : ".$e->getMessage(); |
|
147 | + } |
|
148 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
149 | + if (empty($all)) { |
|
150 | 150 | $filters = array('airlines' => array($stats_airline)); |
151 | 151 | if ($filter_name != '') { |
152 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
152 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
153 | 153 | } |
154 | 154 | $Spotter = new Spotter($this->db); |
155 | 155 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
156 | - } |
|
157 | - return $all; |
|
156 | + } |
|
157 | + return $all; |
|
158 | 158 | } |
159 | 159 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
160 | 160 | global $globalStatsFilters; |
161 | 161 | 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"; |
162 | 162 | 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"; |
163 | - try { |
|
164 | - $sth = $this->db->prepare($query); |
|
165 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
166 | - } catch(PDOException $e) { |
|
167 | - echo "error : ".$e->getMessage(); |
|
168 | - } |
|
169 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
170 | - if (empty($all)) { |
|
163 | + try { |
|
164 | + $sth = $this->db->prepare($query); |
|
165 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
166 | + } catch(PDOException $e) { |
|
167 | + echo "error : ".$e->getMessage(); |
|
168 | + } |
|
169 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
170 | + if (empty($all)) { |
|
171 | 171 | $filters = array('airlines' => array($stats_airline)); |
172 | 172 | if ($filter_name != '') { |
173 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
173 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
174 | 174 | } |
175 | 175 | $Spotter = new Spotter($this->db); |
176 | 176 | $all = $Spotter->countAllDepartureCountries($filters); |
177 | - } |
|
178 | - return $all; |
|
177 | + } |
|
178 | + return $all; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | public function countAllAirlines($limit = true,$filter_name = '') { |
182 | 182 | global $globalStatsFilters; |
183 | 183 | 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"; |
184 | 184 | 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"; |
185 | - try { |
|
186 | - $sth = $this->db->prepare($query); |
|
187 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
188 | - } catch(PDOException $e) { |
|
189 | - echo "error : ".$e->getMessage(); |
|
190 | - } |
|
191 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
192 | - if (empty($all)) { |
|
193 | - $Spotter = new Spotter($this->db); |
|
194 | - $filters = array(); |
|
195 | - if ($filter_name != '') { |
|
196 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
185 | + try { |
|
186 | + $sth = $this->db->prepare($query); |
|
187 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
188 | + } catch(PDOException $e) { |
|
189 | + echo "error : ".$e->getMessage(); |
|
190 | + } |
|
191 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
192 | + if (empty($all)) { |
|
193 | + $Spotter = new Spotter($this->db); |
|
194 | + $filters = array(); |
|
195 | + if ($filter_name != '') { |
|
196 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
197 | 197 | } |
198 | 198 | |
199 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
200 | - } |
|
201 | - return $all; |
|
199 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
200 | + } |
|
201 | + return $all; |
|
202 | 202 | } |
203 | 203 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
204 | 204 | global $globalStatsFilters; |
205 | 205 | 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"; |
206 | 206 | 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"; |
207 | - try { |
|
208 | - $sth = $this->db->prepare($query); |
|
209 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
210 | - } catch(PDOException $e) { |
|
211 | - echo "error : ".$e->getMessage(); |
|
212 | - } |
|
213 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
214 | - if (empty($all)) { |
|
207 | + try { |
|
208 | + $sth = $this->db->prepare($query); |
|
209 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
210 | + } catch(PDOException $e) { |
|
211 | + echo "error : ".$e->getMessage(); |
|
212 | + } |
|
213 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
214 | + if (empty($all)) { |
|
215 | 215 | $filters = array('airlines' => array($stats_airline)); |
216 | 216 | if ($filter_name != '') { |
217 | 217 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
218 | 218 | } |
219 | - $Spotter = new Spotter($this->db); |
|
220 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
221 | - } |
|
222 | - return $all; |
|
219 | + $Spotter = new Spotter($this->db); |
|
220 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
221 | + } |
|
222 | + return $all; |
|
223 | 223 | } |
224 | 224 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
225 | 225 | global $globalStatsFilters; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | echo "error : ".$e->getMessage(); |
255 | 255 | } |
256 | 256 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
257 | - /* |
|
257 | + /* |
|
258 | 258 | if (empty($all)) { |
259 | 259 | $Spotter = new Spotter($this->db); |
260 | 260 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -269,82 +269,82 @@ discard block |
||
269 | 269 | global $globalStatsFilters; |
270 | 270 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
271 | 271 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
272 | - try { |
|
273 | - $sth = $this->db->prepare($query); |
|
274 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
275 | - } catch(PDOException $e) { |
|
276 | - echo "error : ".$e->getMessage(); |
|
277 | - } |
|
278 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
279 | - if (empty($all)) { |
|
272 | + try { |
|
273 | + $sth = $this->db->prepare($query); |
|
274 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
275 | + } catch(PDOException $e) { |
|
276 | + echo "error : ".$e->getMessage(); |
|
277 | + } |
|
278 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
279 | + if (empty($all)) { |
|
280 | 280 | $filters = array('airlines' => array($stats_airline)); |
281 | 281 | if ($filter_name != '') { |
282 | 282 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
283 | 283 | } |
284 | - $Spotter = new Spotter($this->db); |
|
285 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
286 | - } |
|
287 | - return $all; |
|
284 | + $Spotter = new Spotter($this->db); |
|
285 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
286 | + } |
|
287 | + return $all; |
|
288 | 288 | } |
289 | 289 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
290 | 290 | global $globalStatsFilters; |
291 | 291 | 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"; |
292 | 292 | 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"; |
293 | - try { |
|
294 | - $sth = $this->db->prepare($query); |
|
295 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
296 | - } catch(PDOException $e) { |
|
297 | - echo "error : ".$e->getMessage(); |
|
298 | - } |
|
299 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
300 | - if (empty($all)) { |
|
293 | + try { |
|
294 | + $sth = $this->db->prepare($query); |
|
295 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
296 | + } catch(PDOException $e) { |
|
297 | + echo "error : ".$e->getMessage(); |
|
298 | + } |
|
299 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
300 | + if (empty($all)) { |
|
301 | 301 | $filters = array('airlines' => array($stats_airline)); |
302 | 302 | if ($filter_name != '') { |
303 | 303 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
304 | 304 | } |
305 | - $Spotter = new Spotter($this->db); |
|
306 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
307 | - } |
|
308 | - return $all; |
|
305 | + $Spotter = new Spotter($this->db); |
|
306 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
307 | + } |
|
308 | + return $all; |
|
309 | 309 | } |
310 | 310 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
311 | 311 | global $globalStatsFilters; |
312 | 312 | 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
313 | 313 | 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
314 | - try { |
|
315 | - $sth = $this->db->prepare($query); |
|
316 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
317 | - } catch(PDOException $e) { |
|
318 | - echo "error : ".$e->getMessage(); |
|
319 | - } |
|
320 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
321 | - if (empty($all)) { |
|
314 | + try { |
|
315 | + $sth = $this->db->prepare($query); |
|
316 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
317 | + } catch(PDOException $e) { |
|
318 | + echo "error : ".$e->getMessage(); |
|
319 | + } |
|
320 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
321 | + if (empty($all)) { |
|
322 | 322 | $filters = array('airlines' => array($stats_airline)); |
323 | - if ($filter_name != '') { |
|
324 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
325 | - } |
|
326 | - $Spotter = new Spotter($this->db); |
|
327 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
328 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
329 | - $all = array(); |
|
330 | - foreach ($pall as $value) { |
|
331 | - $icao = $value['airport_departure_icao']; |
|
332 | - $all[$icao] = $value; |
|
333 | - } |
|
323 | + if ($filter_name != '') { |
|
324 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
325 | + } |
|
326 | + $Spotter = new Spotter($this->db); |
|
327 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
328 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
329 | + $all = array(); |
|
330 | + foreach ($pall as $value) { |
|
331 | + $icao = $value['airport_departure_icao']; |
|
332 | + $all[$icao] = $value; |
|
333 | + } |
|
334 | 334 | |
335 | - foreach ($dall as $value) { |
|
336 | - $icao = $value['airport_departure_icao']; |
|
337 | - if (isset($all[$icao])) { |
|
338 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
339 | - } else $all[$icao] = $value; |
|
340 | - } |
|
341 | - $count = array(); |
|
342 | - foreach ($all as $key => $row) { |
|
343 | - $count[$key] = $row['airport_departure_icao_count']; |
|
344 | - } |
|
345 | - array_multisort($count,SORT_DESC,$all); |
|
346 | - } |
|
347 | - return $all; |
|
335 | + foreach ($dall as $value) { |
|
336 | + $icao = $value['airport_departure_icao']; |
|
337 | + if (isset($all[$icao])) { |
|
338 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
339 | + } else $all[$icao] = $value; |
|
340 | + } |
|
341 | + $count = array(); |
|
342 | + foreach ($all as $key => $row) { |
|
343 | + $count[$key] = $row['airport_departure_icao_count']; |
|
344 | + } |
|
345 | + array_multisort($count,SORT_DESC,$all); |
|
346 | + } |
|
347 | + return $all; |
|
348 | 348 | } |
349 | 349 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
350 | 350 | global $globalStatsFilters; |
@@ -365,26 +365,26 @@ discard block |
||
365 | 365 | $Spotter = new Spotter($this->db); |
366 | 366 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
367 | 367 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
368 | - $all = array(); |
|
369 | - foreach ($pall as $value) { |
|
370 | - $icao = $value['airport_arrival_icao']; |
|
371 | - $all[$icao] = $value; |
|
372 | - } |
|
368 | + $all = array(); |
|
369 | + foreach ($pall as $value) { |
|
370 | + $icao = $value['airport_arrival_icao']; |
|
371 | + $all[$icao] = $value; |
|
372 | + } |
|
373 | 373 | |
374 | - foreach ($dall as $value) { |
|
375 | - $icao = $value['airport_arrival_icao']; |
|
376 | - if (isset($all[$icao])) { |
|
377 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
378 | - } else $all[$icao] = $value; |
|
379 | - } |
|
380 | - $count = array(); |
|
381 | - foreach ($all as $key => $row) { |
|
382 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
383 | - } |
|
384 | - array_multisort($count,SORT_DESC,$all); |
|
385 | - } |
|
374 | + foreach ($dall as $value) { |
|
375 | + $icao = $value['airport_arrival_icao']; |
|
376 | + if (isset($all[$icao])) { |
|
377 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
378 | + } else $all[$icao] = $value; |
|
379 | + } |
|
380 | + $count = array(); |
|
381 | + foreach ($all as $key => $row) { |
|
382 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
383 | + } |
|
384 | + array_multisort($count,SORT_DESC,$all); |
|
385 | + } |
|
386 | 386 | |
387 | - return $all; |
|
387 | + return $all; |
|
388 | 388 | } |
389 | 389 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
390 | 390 | global $globalDBdriver, $globalStatsFilters; |
@@ -396,45 +396,45 @@ discard block |
||
396 | 396 | 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"; |
397 | 397 | } |
398 | 398 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
399 | - try { |
|
400 | - $sth = $this->db->prepare($query); |
|
401 | - $sth->execute($query_data); |
|
402 | - } catch(PDOException $e) { |
|
403 | - echo "error : ".$e->getMessage(); |
|
404 | - } |
|
405 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
406 | - if (empty($all)) { |
|
399 | + try { |
|
400 | + $sth = $this->db->prepare($query); |
|
401 | + $sth->execute($query_data); |
|
402 | + } catch(PDOException $e) { |
|
403 | + echo "error : ".$e->getMessage(); |
|
404 | + } |
|
405 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
406 | + if (empty($all)) { |
|
407 | 407 | $filters = array('airlines' => array($stats_airline)); |
408 | 408 | if ($filter_name != '') { |
409 | 409 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
410 | 410 | } |
411 | - $Spotter = new Spotter($this->db); |
|
412 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
413 | - } |
|
411 | + $Spotter = new Spotter($this->db); |
|
412 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
413 | + } |
|
414 | 414 | |
415 | - return $all; |
|
415 | + return $all; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
419 | 419 | global $globalStatsFilters; |
420 | 420 | $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"; |
421 | 421 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
422 | - try { |
|
423 | - $sth = $this->db->prepare($query); |
|
424 | - $sth->execute($query_data); |
|
425 | - } catch(PDOException $e) { |
|
426 | - echo "error : ".$e->getMessage(); |
|
427 | - } |
|
428 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
429 | - if (empty($all)) { |
|
422 | + try { |
|
423 | + $sth = $this->db->prepare($query); |
|
424 | + $sth->execute($query_data); |
|
425 | + } catch(PDOException $e) { |
|
426 | + echo "error : ".$e->getMessage(); |
|
427 | + } |
|
428 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
429 | + if (empty($all)) { |
|
430 | 430 | $filters = array('airlines' => array($stats_airline)); |
431 | 431 | if ($filter_name != '') { |
432 | 432 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
433 | 433 | } |
434 | - $Spotter = new Spotter($this->db); |
|
435 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
436 | - } |
|
437 | - return $all; |
|
434 | + $Spotter = new Spotter($this->db); |
|
435 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
436 | + } |
|
437 | + return $all; |
|
438 | 438 | } |
439 | 439 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
440 | 440 | global $globalDBdriver, $globalStatsFilters; |
@@ -444,103 +444,103 @@ discard block |
||
444 | 444 | $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"; |
445 | 445 | } |
446 | 446 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
447 | - try { |
|
448 | - $sth = $this->db->prepare($query); |
|
449 | - $sth->execute($query_data); |
|
450 | - } catch(PDOException $e) { |
|
451 | - echo "error : ".$e->getMessage(); |
|
452 | - } |
|
453 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
454 | - if (empty($all)) { |
|
447 | + try { |
|
448 | + $sth = $this->db->prepare($query); |
|
449 | + $sth->execute($query_data); |
|
450 | + } catch(PDOException $e) { |
|
451 | + echo "error : ".$e->getMessage(); |
|
452 | + } |
|
453 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
454 | + if (empty($all)) { |
|
455 | 455 | $filters = array('airlines' => array($stats_airline)); |
456 | 456 | if ($filter_name != '') { |
457 | 457 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
458 | 458 | } |
459 | - $Spotter = new Spotter($this->db); |
|
460 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
461 | - } |
|
462 | - return $all; |
|
459 | + $Spotter = new Spotter($this->db); |
|
460 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
461 | + } |
|
462 | + return $all; |
|
463 | 463 | } |
464 | 464 | public function countAllDates($stats_airline = '',$filter_name = '') { |
465 | 465 | global $globalStatsFilters; |
466 | 466 | $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"; |
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 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
478 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
479 | 479 | } |
480 | - $Spotter = new Spotter($this->db); |
|
481 | - $all = $Spotter->countAllDates($filters); |
|
482 | - } |
|
483 | - return $all; |
|
480 | + $Spotter = new Spotter($this->db); |
|
481 | + $all = $Spotter->countAllDates($filters); |
|
482 | + } |
|
483 | + return $all; |
|
484 | 484 | } |
485 | 485 | public function countAllDatesByAirlines($filter_name = '') { |
486 | 486 | $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"; |
487 | 487 | $query_data = array('filter_name' => $filter_name); |
488 | - try { |
|
489 | - $sth = $this->db->prepare($query); |
|
490 | - $sth->execute($query_data); |
|
491 | - } catch(PDOException $e) { |
|
492 | - echo "error : ".$e->getMessage(); |
|
493 | - } |
|
494 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
495 | - if (empty($all)) { |
|
496 | - $filters = array(); |
|
497 | - if ($filter_name != '') { |
|
498 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
499 | - } |
|
500 | - $Spotter = new Spotter($this->db); |
|
501 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
502 | - } |
|
503 | - return $all; |
|
488 | + try { |
|
489 | + $sth = $this->db->prepare($query); |
|
490 | + $sth->execute($query_data); |
|
491 | + } catch(PDOException $e) { |
|
492 | + echo "error : ".$e->getMessage(); |
|
493 | + } |
|
494 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
495 | + if (empty($all)) { |
|
496 | + $filters = array(); |
|
497 | + if ($filter_name != '') { |
|
498 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
499 | + } |
|
500 | + $Spotter = new Spotter($this->db); |
|
501 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
502 | + } |
|
503 | + return $all; |
|
504 | 504 | } |
505 | 505 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
506 | 506 | global $globalStatsFilters; |
507 | - $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"; |
|
508 | - try { |
|
509 | - $sth = $this->db->prepare($query); |
|
510 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
511 | - } catch(PDOException $e) { |
|
512 | - echo "error : ".$e->getMessage(); |
|
513 | - } |
|
514 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
515 | - if (empty($all)) { |
|
507 | + $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"; |
|
508 | + try { |
|
509 | + $sth = $this->db->prepare($query); |
|
510 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
511 | + } catch(PDOException $e) { |
|
512 | + echo "error : ".$e->getMessage(); |
|
513 | + } |
|
514 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
515 | + if (empty($all)) { |
|
516 | 516 | $filters = array('airlines' => array($stats_airline)); |
517 | 517 | if ($filter_name != '') { |
518 | 518 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
519 | 519 | } |
520 | - $Spotter = new Spotter($this->db); |
|
521 | - $all = $Spotter->countAllMonths($filters); |
|
522 | - } |
|
523 | - return $all; |
|
520 | + $Spotter = new Spotter($this->db); |
|
521 | + $all = $Spotter->countAllMonths($filters); |
|
522 | + } |
|
523 | + return $all; |
|
524 | 524 | } |
525 | 525 | public function countAllMilitaryMonths($filter_name = '') { |
526 | 526 | global $globalStatsFilters; |
527 | - $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"; |
|
528 | - try { |
|
529 | - $sth = $this->db->prepare($query); |
|
530 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
531 | - } catch(PDOException $e) { |
|
532 | - echo "error : ".$e->getMessage(); |
|
533 | - } |
|
534 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
535 | - if (empty($all)) { |
|
536 | - $filters = array(); |
|
537 | - if ($filter_name != '') { |
|
538 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
539 | - } |
|
540 | - $Spotter = new Spotter($this->db); |
|
541 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
542 | - } |
|
543 | - return $all; |
|
527 | + $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"; |
|
528 | + try { |
|
529 | + $sth = $this->db->prepare($query); |
|
530 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
531 | + } catch(PDOException $e) { |
|
532 | + echo "error : ".$e->getMessage(); |
|
533 | + } |
|
534 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
535 | + if (empty($all)) { |
|
536 | + $filters = array(); |
|
537 | + if ($filter_name != '') { |
|
538 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
539 | + } |
|
540 | + $Spotter = new Spotter($this->db); |
|
541 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
542 | + } |
|
543 | + return $all; |
|
544 | 544 | } |
545 | 545 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
546 | 546 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -555,22 +555,22 @@ discard block |
||
555 | 555 | } |
556 | 556 | } |
557 | 557 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
558 | - try { |
|
559 | - $sth = $this->db->prepare($query); |
|
560 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
561 | - } catch(PDOException $e) { |
|
562 | - echo "error : ".$e->getMessage(); |
|
563 | - } |
|
564 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
565 | - if (empty($all)) { |
|
558 | + try { |
|
559 | + $sth = $this->db->prepare($query); |
|
560 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
561 | + } catch(PDOException $e) { |
|
562 | + echo "error : ".$e->getMessage(); |
|
563 | + } |
|
564 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
565 | + if (empty($all)) { |
|
566 | 566 | $filters = array('airlines' => array($stats_airline)); |
567 | 567 | if ($filter_name != '') { |
568 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
568 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
569 | 569 | } |
570 | - $Spotter = new Spotter($this->db); |
|
571 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
572 | - } |
|
573 | - return $all; |
|
570 | + $Spotter = new Spotter($this->db); |
|
571 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
572 | + } |
|
573 | + return $all; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | public function countOverallMilitaryFlights($filter_name = '') { |
590 | 590 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
591 | 591 | if (empty($all)) { |
592 | - $filters = array(); |
|
593 | - if ($filter_name != '') { |
|
594 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
592 | + $filters = array(); |
|
593 | + if ($filter_name != '') { |
|
594 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
595 | 595 | } |
596 | 596 | $Spotter = new Spotter($this->db); |
597 | 597 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -626,19 +626,19 @@ discard block |
||
626 | 626 | } |
627 | 627 | public function countOverallAirlines($filter_name = '') { |
628 | 628 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
629 | - try { |
|
630 | - $sth = $this->db->prepare($query); |
|
631 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
632 | - } catch(PDOException $e) { |
|
633 | - echo "error : ".$e->getMessage(); |
|
634 | - } |
|
635 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
636 | - $all = $result[0]['nb_airline']; |
|
629 | + try { |
|
630 | + $sth = $this->db->prepare($query); |
|
631 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
632 | + } catch(PDOException $e) { |
|
633 | + echo "error : ".$e->getMessage(); |
|
634 | + } |
|
635 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
636 | + $all = $result[0]['nb_airline']; |
|
637 | 637 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
638 | 638 | if (empty($all)) { |
639 | - $filters = array(); |
|
640 | - if ($filter_name != '') { |
|
641 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
639 | + $filters = array(); |
|
640 | + if ($filter_name != '') { |
|
641 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
642 | 642 | } |
643 | 643 | $Spotter = new Spotter($this->db); |
644 | 644 | $all = $Spotter->countOverallAirlines($filters); |
@@ -686,157 +686,157 @@ discard block |
||
686 | 686 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
687 | 687 | $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"; |
688 | 688 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
689 | - try { |
|
690 | - $sth = $this->db->prepare($query); |
|
691 | - $sth->execute($query_values); |
|
692 | - } catch(PDOException $e) { |
|
693 | - echo "error : ".$e->getMessage(); |
|
694 | - } |
|
695 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
696 | - return $all; |
|
689 | + try { |
|
690 | + $sth = $this->db->prepare($query); |
|
691 | + $sth->execute($query_values); |
|
692 | + } catch(PDOException $e) { |
|
693 | + echo "error : ".$e->getMessage(); |
|
694 | + } |
|
695 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
696 | + return $all; |
|
697 | 697 | } |
698 | 698 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
699 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
700 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
701 | - try { |
|
702 | - $sth = $this->db->prepare($query); |
|
703 | - $sth->execute($query_values); |
|
704 | - } catch(PDOException $e) { |
|
705 | - echo "error : ".$e->getMessage(); |
|
706 | - } |
|
707 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
708 | - return $all; |
|
709 | - } |
|
699 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
700 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
701 | + try { |
|
702 | + $sth = $this->db->prepare($query); |
|
703 | + $sth->execute($query_values); |
|
704 | + } catch(PDOException $e) { |
|
705 | + echo "error : ".$e->getMessage(); |
|
706 | + } |
|
707 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
708 | + return $all; |
|
709 | + } |
|
710 | 710 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
711 | - global $globalArchiveMonths, $globalDBdriver; |
|
712 | - if ($globalDBdriver == 'mysql') { |
|
713 | - $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"; |
|
714 | - } else { |
|
715 | - $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"; |
|
716 | - } |
|
717 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
718 | - try { |
|
719 | - $sth = $this->db->prepare($query); |
|
720 | - $sth->execute($query_values); |
|
721 | - } catch(PDOException $e) { |
|
722 | - echo "error : ".$e->getMessage(); |
|
723 | - } |
|
724 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
725 | - return $all[0]['total']; |
|
726 | - } |
|
711 | + global $globalArchiveMonths, $globalDBdriver; |
|
712 | + if ($globalDBdriver == 'mysql') { |
|
713 | + $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"; |
|
714 | + } else { |
|
715 | + $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"; |
|
716 | + } |
|
717 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
718 | + try { |
|
719 | + $sth = $this->db->prepare($query); |
|
720 | + $sth->execute($query_values); |
|
721 | + } catch(PDOException $e) { |
|
722 | + echo "error : ".$e->getMessage(); |
|
723 | + } |
|
724 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
725 | + return $all[0]['total']; |
|
726 | + } |
|
727 | 727 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
728 | - global $globalArchiveMonths, $globalDBdriver; |
|
729 | - if ($globalDBdriver == 'mysql') { |
|
728 | + global $globalArchiveMonths, $globalDBdriver; |
|
729 | + if ($globalDBdriver == 'mysql') { |
|
730 | 730 | $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"; |
731 | 731 | } else { |
732 | 732 | $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"; |
733 | - } |
|
734 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
735 | - try { |
|
736 | - $sth = $this->db->prepare($query); |
|
737 | - $sth->execute($query_values); |
|
738 | - } catch(PDOException $e) { |
|
739 | - echo "error : ".$e->getMessage(); |
|
740 | - } |
|
741 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
742 | - return $all[0]['total']; |
|
743 | - } |
|
733 | + } |
|
734 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
735 | + try { |
|
736 | + $sth = $this->db->prepare($query); |
|
737 | + $sth->execute($query_values); |
|
738 | + } catch(PDOException $e) { |
|
739 | + echo "error : ".$e->getMessage(); |
|
740 | + } |
|
741 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
742 | + return $all[0]['total']; |
|
743 | + } |
|
744 | 744 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
745 | - global $globalArchiveMonths, $globalDBdriver; |
|
746 | - if ($globalDBdriver == 'mysql') { |
|
745 | + global $globalArchiveMonths, $globalDBdriver; |
|
746 | + if ($globalDBdriver == 'mysql') { |
|
747 | 747 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
748 | - } else { |
|
748 | + } else { |
|
749 | 749 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
750 | - } |
|
751 | - try { |
|
752 | - $sth = $this->db->prepare($query); |
|
753 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
754 | - } catch(PDOException $e) { |
|
755 | - echo "error : ".$e->getMessage(); |
|
756 | - } |
|
757 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
758 | - return $all[0]['total']; |
|
759 | - } |
|
750 | + } |
|
751 | + try { |
|
752 | + $sth = $this->db->prepare($query); |
|
753 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
754 | + } catch(PDOException $e) { |
|
755 | + echo "error : ".$e->getMessage(); |
|
756 | + } |
|
757 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
758 | + return $all[0]['total']; |
|
759 | + } |
|
760 | 760 | public function getStatsAirlineTotal($filter_name = '') { |
761 | - global $globalArchiveMonths, $globalDBdriver; |
|
762 | - if ($globalDBdriver == 'mysql') { |
|
761 | + global $globalArchiveMonths, $globalDBdriver; |
|
762 | + if ($globalDBdriver == 'mysql') { |
|
763 | 763 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
764 | - } else { |
|
764 | + } else { |
|
765 | 765 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
766 | - } |
|
767 | - try { |
|
768 | - $sth = $this->db->prepare($query); |
|
769 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
770 | - } catch(PDOException $e) { |
|
771 | - echo "error : ".$e->getMessage(); |
|
772 | - } |
|
773 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
774 | - return $all[0]['total']; |
|
775 | - } |
|
766 | + } |
|
767 | + try { |
|
768 | + $sth = $this->db->prepare($query); |
|
769 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
770 | + } catch(PDOException $e) { |
|
771 | + echo "error : ".$e->getMessage(); |
|
772 | + } |
|
773 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
774 | + return $all[0]['total']; |
|
775 | + } |
|
776 | 776 | public function getStatsOwnerTotal($filter_name = '') { |
777 | - global $globalArchiveMonths, $globalDBdriver; |
|
778 | - if ($globalDBdriver == 'mysql') { |
|
777 | + global $globalArchiveMonths, $globalDBdriver; |
|
778 | + if ($globalDBdriver == 'mysql') { |
|
779 | 779 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
780 | 780 | } else { |
781 | 781 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
782 | - } |
|
783 | - try { |
|
784 | - $sth = $this->db->prepare($query); |
|
785 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
786 | - } catch(PDOException $e) { |
|
787 | - echo "error : ".$e->getMessage(); |
|
788 | - } |
|
789 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
790 | - return $all[0]['total']; |
|
791 | - } |
|
782 | + } |
|
783 | + try { |
|
784 | + $sth = $this->db->prepare($query); |
|
785 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
786 | + } catch(PDOException $e) { |
|
787 | + echo "error : ".$e->getMessage(); |
|
788 | + } |
|
789 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
790 | + return $all[0]['total']; |
|
791 | + } |
|
792 | 792 | public function getStatsPilotTotal($filter_name = '') { |
793 | - global $globalArchiveMonths, $globalDBdriver; |
|
794 | - if ($globalDBdriver == 'mysql') { |
|
795 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
796 | - } else { |
|
797 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
798 | - } |
|
799 | - try { |
|
800 | - $sth = $this->db->prepare($query); |
|
801 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
802 | - } catch(PDOException $e) { |
|
803 | - echo "error : ".$e->getMessage(); |
|
804 | - } |
|
805 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
806 | - return $all[0]['total']; |
|
807 | - } |
|
793 | + global $globalArchiveMonths, $globalDBdriver; |
|
794 | + if ($globalDBdriver == 'mysql') { |
|
795 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
796 | + } else { |
|
797 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
798 | + } |
|
799 | + try { |
|
800 | + $sth = $this->db->prepare($query); |
|
801 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
802 | + } catch(PDOException $e) { |
|
803 | + echo "error : ".$e->getMessage(); |
|
804 | + } |
|
805 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
806 | + return $all[0]['total']; |
|
807 | + } |
|
808 | 808 | |
809 | 809 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
810 | 810 | global $globalDBdriver; |
811 | 811 | if ($globalDBdriver == 'mysql') { |
812 | 812 | $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"; |
813 | - } else { |
|
813 | + } else { |
|
814 | 814 | $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);"; |
815 | 815 | } |
816 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
817 | - try { |
|
818 | - $sth = $this->db->prepare($query); |
|
819 | - $sth->execute($query_values); |
|
820 | - } catch(PDOException $e) { |
|
821 | - return "error : ".$e->getMessage(); |
|
822 | - } |
|
823 | - } |
|
816 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
817 | + try { |
|
818 | + $sth = $this->db->prepare($query); |
|
819 | + $sth->execute($query_values); |
|
820 | + } catch(PDOException $e) { |
|
821 | + return "error : ".$e->getMessage(); |
|
822 | + } |
|
823 | + } |
|
824 | 824 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
825 | 825 | global $globalDBdriver; |
826 | 826 | if ($globalDBdriver == 'mysql') { |
827 | 827 | $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"; |
828 | 828 | } else { |
829 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
829 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
830 | 830 | $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);"; |
831 | - } |
|
832 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
833 | - try { |
|
834 | - $sth = $this->db->prepare($query); |
|
835 | - $sth->execute($query_values); |
|
836 | - } catch(PDOException $e) { |
|
837 | - return "error : ".$e->getMessage(); |
|
838 | - } |
|
839 | - } |
|
831 | + } |
|
832 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
833 | + try { |
|
834 | + $sth = $this->db->prepare($query); |
|
835 | + $sth->execute($query_values); |
|
836 | + } catch(PDOException $e) { |
|
837 | + return "error : ".$e->getMessage(); |
|
838 | + } |
|
839 | + } |
|
840 | 840 | public function getStatsSource($date,$stats_type = '') { |
841 | 841 | if ($stats_type == '') { |
842 | 842 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -845,15 +845,15 @@ discard block |
||
845 | 845 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
846 | 846 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
847 | 847 | } |
848 | - try { |
|
849 | - $sth = $this->db->prepare($query); |
|
850 | - $sth->execute($query_values); |
|
851 | - } catch(PDOException $e) { |
|
852 | - echo "error : ".$e->getMessage(); |
|
853 | - } |
|
854 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
855 | - return $all; |
|
856 | - } |
|
848 | + try { |
|
849 | + $sth = $this->db->prepare($query); |
|
850 | + $sth->execute($query_values); |
|
851 | + } catch(PDOException $e) { |
|
852 | + echo "error : ".$e->getMessage(); |
|
853 | + } |
|
854 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
855 | + return $all; |
|
856 | + } |
|
857 | 857 | |
858 | 858 | public function addStatSource($data,$source_name,$stats_type,$date) { |
859 | 859 | global $globalDBdriver; |
@@ -861,25 +861,25 @@ discard block |
||
861 | 861 | $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"; |
862 | 862 | } else { |
863 | 863 | $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);"; |
864 | - } |
|
865 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
866 | - try { |
|
867 | - $sth = $this->db->prepare($query); |
|
868 | - $sth->execute($query_values); |
|
869 | - } catch(PDOException $e) { |
|
870 | - return "error : ".$e->getMessage(); |
|
871 | - } |
|
872 | - } |
|
864 | + } |
|
865 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
866 | + try { |
|
867 | + $sth = $this->db->prepare($query); |
|
868 | + $sth->execute($query_values); |
|
869 | + } catch(PDOException $e) { |
|
870 | + return "error : ".$e->getMessage(); |
|
871 | + } |
|
872 | + } |
|
873 | 873 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
874 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
875 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
876 | - try { |
|
877 | - $sth = $this->db->prepare($query); |
|
878 | - $sth->execute($query_values); |
|
879 | - } catch(PDOException $e) { |
|
880 | - return "error : ".$e->getMessage(); |
|
881 | - } |
|
882 | - } |
|
874 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
875 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
876 | + try { |
|
877 | + $sth = $this->db->prepare($query); |
|
878 | + $sth->execute($query_values); |
|
879 | + } catch(PDOException $e) { |
|
880 | + return "error : ".$e->getMessage(); |
|
881 | + } |
|
882 | + } |
|
883 | 883 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
884 | 884 | global $globalDBdriver; |
885 | 885 | if ($globalDBdriver == 'mysql') { |
@@ -887,14 +887,14 @@ discard block |
||
887 | 887 | } else { |
888 | 888 | $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);"; |
889 | 889 | } |
890 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
891 | - try { |
|
892 | - $sth = $this->db->prepare($query); |
|
893 | - $sth->execute($query_values); |
|
894 | - } catch(PDOException $e) { |
|
895 | - return "error : ".$e->getMessage(); |
|
896 | - } |
|
897 | - } |
|
890 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
891 | + try { |
|
892 | + $sth = $this->db->prepare($query); |
|
893 | + $sth->execute($query_values); |
|
894 | + } catch(PDOException $e) { |
|
895 | + return "error : ".$e->getMessage(); |
|
896 | + } |
|
897 | + } |
|
898 | 898 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
899 | 899 | global $globalDBdriver; |
900 | 900 | if ($globalDBdriver == 'mysql') { |
@@ -902,14 +902,14 @@ discard block |
||
902 | 902 | } else { |
903 | 903 | $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);"; |
904 | 904 | } |
905 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
906 | - try { |
|
907 | - $sth = $this->db->prepare($query); |
|
908 | - $sth->execute($query_values); |
|
909 | - } catch(PDOException $e) { |
|
910 | - return "error : ".$e->getMessage(); |
|
911 | - } |
|
912 | - } |
|
905 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
906 | + try { |
|
907 | + $sth = $this->db->prepare($query); |
|
908 | + $sth->execute($query_values); |
|
909 | + } catch(PDOException $e) { |
|
910 | + return "error : ".$e->getMessage(); |
|
911 | + } |
|
912 | + } |
|
913 | 913 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
914 | 914 | global $globalDBdriver; |
915 | 915 | if ($globalDBdriver == 'mysql') { |
@@ -917,14 +917,14 @@ discard block |
||
917 | 917 | } else { |
918 | 918 | $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);"; |
919 | 919 | } |
920 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
921 | - try { |
|
922 | - $sth = $this->db->prepare($query); |
|
923 | - $sth->execute($query_values); |
|
924 | - } catch(PDOException $e) { |
|
925 | - return "error : ".$e->getMessage(); |
|
926 | - } |
|
927 | - } |
|
920 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
921 | + try { |
|
922 | + $sth = $this->db->prepare($query); |
|
923 | + $sth->execute($query_values); |
|
924 | + } catch(PDOException $e) { |
|
925 | + return "error : ".$e->getMessage(); |
|
926 | + } |
|
927 | + } |
|
928 | 928 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
929 | 929 | global $globalDBdriver; |
930 | 930 | if ($globalDBdriver == 'mysql') { |
@@ -932,14 +932,14 @@ discard block |
||
932 | 932 | } else { |
933 | 933 | $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);"; |
934 | 934 | } |
935 | - $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); |
|
936 | - try { |
|
937 | - $sth = $this->db->prepare($query); |
|
938 | - $sth->execute($query_values); |
|
939 | - } catch(PDOException $e) { |
|
940 | - return "error : ".$e->getMessage(); |
|
941 | - } |
|
942 | - } |
|
935 | + $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); |
|
936 | + try { |
|
937 | + $sth = $this->db->prepare($query); |
|
938 | + $sth->execute($query_values); |
|
939 | + } catch(PDOException $e) { |
|
940 | + return "error : ".$e->getMessage(); |
|
941 | + } |
|
942 | + } |
|
943 | 943 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
944 | 944 | global $globalDBdriver; |
945 | 945 | if ($globalDBdriver == 'mysql') { |
@@ -947,14 +947,14 @@ discard block |
||
947 | 947 | } else { |
948 | 948 | $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);"; |
949 | 949 | } |
950 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
951 | - try { |
|
952 | - $sth = $this->db->prepare($query); |
|
953 | - $sth->execute($query_values); |
|
954 | - } catch(PDOException $e) { |
|
955 | - return "error : ".$e->getMessage(); |
|
956 | - } |
|
957 | - } |
|
950 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
951 | + try { |
|
952 | + $sth = $this->db->prepare($query); |
|
953 | + $sth->execute($query_values); |
|
954 | + } catch(PDOException $e) { |
|
955 | + return "error : ".$e->getMessage(); |
|
956 | + } |
|
957 | + } |
|
958 | 958 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
959 | 959 | global $globalDBdriver; |
960 | 960 | if ($globalDBdriver == 'mysql') { |
@@ -962,14 +962,14 @@ discard block |
||
962 | 962 | } else { |
963 | 963 | $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);"; |
964 | 964 | } |
965 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
966 | - try { |
|
967 | - $sth = $this->db->prepare($query); |
|
968 | - $sth->execute($query_values); |
|
969 | - } catch(PDOException $e) { |
|
970 | - return "error : ".$e->getMessage(); |
|
971 | - } |
|
972 | - } |
|
965 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
966 | + try { |
|
967 | + $sth = $this->db->prepare($query); |
|
968 | + $sth->execute($query_values); |
|
969 | + } catch(PDOException $e) { |
|
970 | + return "error : ".$e->getMessage(); |
|
971 | + } |
|
972 | + } |
|
973 | 973 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') { |
974 | 974 | global $globalDBdriver; |
975 | 975 | if ($globalDBdriver == 'mysql') { |
@@ -977,14 +977,14 @@ discard block |
||
977 | 977 | } else { |
978 | 978 | $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; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
979 | 979 | } |
980 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
981 | - try { |
|
982 | - $sth = $this->db->prepare($query); |
|
983 | - $sth->execute($query_values); |
|
984 | - } catch(PDOException $e) { |
|
985 | - return "error : ".$e->getMessage(); |
|
986 | - } |
|
987 | - } |
|
980 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
981 | + try { |
|
982 | + $sth = $this->db->prepare($query); |
|
983 | + $sth->execute($query_values); |
|
984 | + } catch(PDOException $e) { |
|
985 | + return "error : ".$e->getMessage(); |
|
986 | + } |
|
987 | + } |
|
988 | 988 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
989 | 989 | global $globalDBdriver; |
990 | 990 | if ($globalDBdriver == 'mysql') { |
@@ -992,14 +992,14 @@ discard block |
||
992 | 992 | } else { |
993 | 993 | $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);"; |
994 | 994 | } |
995 | - $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); |
|
996 | - try { |
|
997 | - $sth = $this->db->prepare($query); |
|
998 | - $sth->execute($query_values); |
|
999 | - } catch(PDOException $e) { |
|
1000 | - return "error : ".$e->getMessage(); |
|
1001 | - } |
|
1002 | - } |
|
995 | + $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); |
|
996 | + try { |
|
997 | + $sth = $this->db->prepare($query); |
|
998 | + $sth->execute($query_values); |
|
999 | + } catch(PDOException $e) { |
|
1000 | + return "error : ".$e->getMessage(); |
|
1001 | + } |
|
1002 | + } |
|
1003 | 1003 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1004 | 1004 | global $globalDBdriver; |
1005 | 1005 | if ($globalDBdriver == 'mysql') { |
@@ -1007,14 +1007,14 @@ discard block |
||
1007 | 1007 | } else { |
1008 | 1008 | $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);"; |
1009 | 1009 | } |
1010 | - $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); |
|
1011 | - try { |
|
1012 | - $sth = $this->db->prepare($query); |
|
1013 | - $sth->execute($query_values); |
|
1014 | - } catch(PDOException $e) { |
|
1015 | - return "error : ".$e->getMessage(); |
|
1016 | - } |
|
1017 | - } |
|
1010 | + $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); |
|
1011 | + try { |
|
1012 | + $sth = $this->db->prepare($query); |
|
1013 | + $sth->execute($query_values); |
|
1014 | + } catch(PDOException $e) { |
|
1015 | + return "error : ".$e->getMessage(); |
|
1016 | + } |
|
1017 | + } |
|
1018 | 1018 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1019 | 1019 | global $globalDBdriver; |
1020 | 1020 | if ($globalDBdriver == 'mysql') { |
@@ -1022,14 +1022,14 @@ discard block |
||
1022 | 1022 | } else { |
1023 | 1023 | $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);"; |
1024 | 1024 | } |
1025 | - $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); |
|
1026 | - try { |
|
1027 | - $sth = $this->db->prepare($query); |
|
1028 | - $sth->execute($query_values); |
|
1029 | - } catch(PDOException $e) { |
|
1030 | - return "error : ".$e->getMessage(); |
|
1031 | - } |
|
1032 | - } |
|
1025 | + $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); |
|
1026 | + try { |
|
1027 | + $sth = $this->db->prepare($query); |
|
1028 | + $sth->execute($query_values); |
|
1029 | + } catch(PDOException $e) { |
|
1030 | + return "error : ".$e->getMessage(); |
|
1031 | + } |
|
1032 | + } |
|
1033 | 1033 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1034 | 1034 | global $globalDBdriver; |
1035 | 1035 | if ($globalDBdriver == 'mysql') { |
@@ -1037,52 +1037,52 @@ discard block |
||
1037 | 1037 | } else { |
1038 | 1038 | $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);"; |
1039 | 1039 | } |
1040 | - $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); |
|
1041 | - try { |
|
1042 | - $sth = $this->db->prepare($query); |
|
1043 | - $sth->execute($query_values); |
|
1044 | - } catch(PDOException $e) { |
|
1045 | - return "error : ".$e->getMessage(); |
|
1046 | - } |
|
1047 | - } |
|
1040 | + $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); |
|
1041 | + try { |
|
1042 | + $sth = $this->db->prepare($query); |
|
1043 | + $sth->execute($query_values); |
|
1044 | + } catch(PDOException $e) { |
|
1045 | + return "error : ".$e->getMessage(); |
|
1046 | + } |
|
1047 | + } |
|
1048 | 1048 | |
1049 | 1049 | public function deleteStat($id) { |
1050 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1051 | - $query_values = array(':id' => $id); |
|
1052 | - try { |
|
1053 | - $sth = $this->db->prepare($query); |
|
1054 | - $sth->execute($query_values); |
|
1055 | - } catch(PDOException $e) { |
|
1056 | - return "error : ".$e->getMessage(); |
|
1057 | - } |
|
1058 | - } |
|
1050 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1051 | + $query_values = array(':id' => $id); |
|
1052 | + try { |
|
1053 | + $sth = $this->db->prepare($query); |
|
1054 | + $sth->execute($query_values); |
|
1055 | + } catch(PDOException $e) { |
|
1056 | + return "error : ".$e->getMessage(); |
|
1057 | + } |
|
1058 | + } |
|
1059 | 1059 | public function deleteStatFlight($type) { |
1060 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1061 | - $query_values = array(':type' => $type); |
|
1062 | - try { |
|
1063 | - $sth = $this->db->prepare($query); |
|
1064 | - $sth->execute($query_values); |
|
1065 | - } catch(PDOException $e) { |
|
1066 | - return "error : ".$e->getMessage(); |
|
1067 | - } |
|
1068 | - } |
|
1060 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1061 | + $query_values = array(':type' => $type); |
|
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 deleteStatAirport($type) { |
1070 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1071 | - $query_values = array(':type' => $type); |
|
1072 | - try { |
|
1073 | - $sth = $this->db->prepare($query); |
|
1074 | - $sth->execute($query_values); |
|
1075 | - } catch(PDOException $e) { |
|
1076 | - return "error : ".$e->getMessage(); |
|
1077 | - } |
|
1078 | - } |
|
1070 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1071 | + $query_values = array(':type' => $type); |
|
1072 | + try { |
|
1073 | + $sth = $this->db->prepare($query); |
|
1074 | + $sth->execute($query_values); |
|
1075 | + } catch(PDOException $e) { |
|
1076 | + return "error : ".$e->getMessage(); |
|
1077 | + } |
|
1078 | + } |
|
1079 | 1079 | |
1080 | - public function addOldStats() { |
|
1081 | - global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1082 | - $Common = new Common(); |
|
1083 | - $Connection = new Connection(); |
|
1084 | - date_default_timezone_set('UTC'); |
|
1085 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1080 | + public function addOldStats() { |
|
1081 | + global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1082 | + $Common = new Common(); |
|
1083 | + $Connection = new Connection(); |
|
1084 | + date_default_timezone_set('UTC'); |
|
1085 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1086 | 1086 | //print_r($last_update); |
1087 | 1087 | /* |
1088 | 1088 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1336,46 +1336,46 @@ discard block |
||
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1339 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1340 | - $alldata = array(); |
|
1339 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1340 | + $alldata = array(); |
|
1341 | 1341 | |
1342 | - foreach ($pall as $value) { |
|
1343 | - $icao = $value['airport_departure_icao']; |
|
1344 | - $alldata[$icao] = $value; |
|
1345 | - } |
|
1346 | - foreach ($dall as $value) { |
|
1347 | - $icao = $value['airport_departure_icao']; |
|
1348 | - if (isset($alldata[$icao])) { |
|
1349 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1350 | - } else $alldata[$icao] = $value; |
|
1351 | - } |
|
1352 | - $count = array(); |
|
1353 | - foreach ($alldata as $key => $row) { |
|
1354 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1355 | - } |
|
1342 | + foreach ($pall as $value) { |
|
1343 | + $icao = $value['airport_departure_icao']; |
|
1344 | + $alldata[$icao] = $value; |
|
1345 | + } |
|
1346 | + foreach ($dall as $value) { |
|
1347 | + $icao = $value['airport_departure_icao']; |
|
1348 | + if (isset($alldata[$icao])) { |
|
1349 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1350 | + } else $alldata[$icao] = $value; |
|
1351 | + } |
|
1352 | + $count = array(); |
|
1353 | + foreach ($alldata as $key => $row) { |
|
1354 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1355 | + } |
|
1356 | 1356 | array_multisort($count,SORT_DESC,$alldata); |
1357 | 1357 | foreach ($alldata as $number) { |
1358 | 1358 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1359 | 1359 | } |
1360 | 1360 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1361 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1362 | - $alldata = array(); |
|
1363 | - foreach ($pall as $value) { |
|
1364 | - $icao = $value['airport_arrival_icao']; |
|
1365 | - $alldata[$icao] = $value; |
|
1366 | - } |
|
1367 | - foreach ($dall as $value) { |
|
1368 | - $icao = $value['airport_arrival_icao']; |
|
1369 | - if (isset($alldata[$icao])) { |
|
1370 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1371 | - } else $alldata[$icao] = $value; |
|
1372 | - } |
|
1373 | - $count = array(); |
|
1374 | - foreach ($alldata as $key => $row) { |
|
1375 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1376 | - } |
|
1377 | - array_multisort($count,SORT_DESC,$alldata); |
|
1378 | - foreach ($alldata as $number) { |
|
1361 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1362 | + $alldata = array(); |
|
1363 | + foreach ($pall as $value) { |
|
1364 | + $icao = $value['airport_arrival_icao']; |
|
1365 | + $alldata[$icao] = $value; |
|
1366 | + } |
|
1367 | + foreach ($dall as $value) { |
|
1368 | + $icao = $value['airport_arrival_icao']; |
|
1369 | + if (isset($alldata[$icao])) { |
|
1370 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1371 | + } else $alldata[$icao] = $value; |
|
1372 | + } |
|
1373 | + $count = array(); |
|
1374 | + foreach ($alldata as $key => $row) { |
|
1375 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1376 | + } |
|
1377 | + array_multisort($count,SORT_DESC,$alldata); |
|
1378 | + foreach ($alldata as $number) { |
|
1379 | 1379 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1380 | 1380 | } |
1381 | 1381 | if ($Connection->tableExists('countries')) { |
@@ -1427,8 +1427,8 @@ discard block |
||
1427 | 1427 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1428 | 1428 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1429 | 1429 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1430 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1431 | - /* |
|
1430 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1431 | + /* |
|
1432 | 1432 | $alldata = array(); |
1433 | 1433 | foreach ($pall as $value) { |
1434 | 1434 | $icao = $value['departure_airport_icao']; |
@@ -1447,29 +1447,29 @@ discard block |
||
1447 | 1447 | } |
1448 | 1448 | array_multisort($count,SORT_DESC,$alldata); |
1449 | 1449 | */ |
1450 | - foreach ($dall as $value) { |
|
1451 | - $icao = $value['departure_airport_icao']; |
|
1452 | - $ddate = $value['date']; |
|
1453 | - $find = false; |
|
1454 | - foreach ($pall as $pvalue) { |
|
1455 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1456 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1457 | - $find = true; |
|
1458 | - break; |
|
1459 | - } |
|
1460 | - } |
|
1461 | - if ($find === false) { |
|
1462 | - $pall[] = $value; |
|
1463 | - } |
|
1464 | - } |
|
1465 | - $alldata = $pall; |
|
1450 | + foreach ($dall as $value) { |
|
1451 | + $icao = $value['departure_airport_icao']; |
|
1452 | + $ddate = $value['date']; |
|
1453 | + $find = false; |
|
1454 | + foreach ($pall as $pvalue) { |
|
1455 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1456 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1457 | + $find = true; |
|
1458 | + break; |
|
1459 | + } |
|
1460 | + } |
|
1461 | + if ($find === false) { |
|
1462 | + $pall[] = $value; |
|
1463 | + } |
|
1464 | + } |
|
1465 | + $alldata = $pall; |
|
1466 | 1466 | foreach ($alldata as $number) { |
1467 | 1467 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1468 | 1468 | } |
1469 | 1469 | echo '...Arrival'."\n"; |
1470 | 1470 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1471 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1472 | - /* |
|
1471 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1472 | + /* |
|
1473 | 1473 | $alldata = array(); |
1474 | 1474 | foreach ($pall as $value) { |
1475 | 1475 | $icao = $value['arrival_airport_icao']; |
@@ -1489,22 +1489,22 @@ discard block |
||
1489 | 1489 | */ |
1490 | 1490 | |
1491 | 1491 | |
1492 | - foreach ($dall as $value) { |
|
1493 | - $icao = $value['arrival_airport_icao']; |
|
1494 | - $ddate = $value['date']; |
|
1495 | - $find = false; |
|
1496 | - foreach ($pall as $pvalue) { |
|
1497 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1498 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1499 | - $find = true; |
|
1500 | - break; |
|
1501 | - } |
|
1502 | - } |
|
1503 | - if ($find === false) { |
|
1504 | - $pall[] = $value; |
|
1505 | - } |
|
1506 | - } |
|
1507 | - $alldata = $pall; |
|
1492 | + foreach ($dall as $value) { |
|
1493 | + $icao = $value['arrival_airport_icao']; |
|
1494 | + $ddate = $value['date']; |
|
1495 | + $find = false; |
|
1496 | + foreach ($pall as $pvalue) { |
|
1497 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1498 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1499 | + $find = true; |
|
1500 | + break; |
|
1501 | + } |
|
1502 | + } |
|
1503 | + if ($find === false) { |
|
1504 | + $pall[] = $value; |
|
1505 | + } |
|
1506 | + } |
|
1507 | + $alldata = $pall; |
|
1508 | 1508 | foreach ($alldata as $number) { |
1509 | 1509 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1510 | 1510 | } |
@@ -1564,47 +1564,47 @@ discard block |
||
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1567 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1568 | - //$alldata = array(); |
|
1569 | - foreach ($dall as $value) { |
|
1570 | - $icao = $value['airport_departure_icao']; |
|
1571 | - $dicao = $value['airline_icap']; |
|
1572 | - $find = false; |
|
1573 | - foreach ($pall as $pvalue) { |
|
1574 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1575 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1576 | - $find = true; |
|
1577 | - break; |
|
1578 | - } |
|
1579 | - } |
|
1580 | - if ($find === false) { |
|
1581 | - $pall[] = $value; |
|
1582 | - } |
|
1583 | - } |
|
1584 | - $alldata = $pall; |
|
1567 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1568 | + //$alldata = array(); |
|
1569 | + foreach ($dall as $value) { |
|
1570 | + $icao = $value['airport_departure_icao']; |
|
1571 | + $dicao = $value['airline_icap']; |
|
1572 | + $find = false; |
|
1573 | + foreach ($pall as $pvalue) { |
|
1574 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1575 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1576 | + $find = true; |
|
1577 | + break; |
|
1578 | + } |
|
1579 | + } |
|
1580 | + if ($find === false) { |
|
1581 | + $pall[] = $value; |
|
1582 | + } |
|
1583 | + } |
|
1584 | + $alldata = $pall; |
|
1585 | 1585 | foreach ($alldata as $number) { |
1586 | 1586 | 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']); |
1587 | 1587 | } |
1588 | 1588 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1589 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1590 | - //$alldata = array(); |
|
1591 | - foreach ($dall as $value) { |
|
1592 | - $icao = $value['airport_arrival_icao']; |
|
1593 | - $dicao = $value['airline_icao']; |
|
1594 | - $find = false; |
|
1595 | - foreach ($pall as $pvalue) { |
|
1596 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1597 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1598 | - $find = true; |
|
1599 | - break; |
|
1600 | - } |
|
1601 | - } |
|
1602 | - if ($find === false) { |
|
1603 | - $pall[] = $value; |
|
1604 | - } |
|
1605 | - } |
|
1606 | - $alldata = $pall; |
|
1607 | - foreach ($alldata as $number) { |
|
1589 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1590 | + //$alldata = array(); |
|
1591 | + foreach ($dall as $value) { |
|
1592 | + $icao = $value['airport_arrival_icao']; |
|
1593 | + $dicao = $value['airline_icao']; |
|
1594 | + $find = false; |
|
1595 | + foreach ($pall as $pvalue) { |
|
1596 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1597 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1598 | + $find = true; |
|
1599 | + break; |
|
1600 | + } |
|
1601 | + } |
|
1602 | + if ($find === false) { |
|
1603 | + $pall[] = $value; |
|
1604 | + } |
|
1605 | + } |
|
1606 | + $alldata = $pall; |
|
1607 | + foreach ($alldata as $number) { |
|
1608 | 1608 | 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']); |
1609 | 1609 | } |
1610 | 1610 | $Spotter = new Spotter($this->db); |
@@ -1632,47 +1632,47 @@ discard block |
||
1632 | 1632 | } |
1633 | 1633 | echo '...Departure'."\n"; |
1634 | 1634 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1635 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1636 | - foreach ($dall as $value) { |
|
1637 | - $icao = $value['departure_airport_icao']; |
|
1638 | - $airline = $value['airline_icao']; |
|
1639 | - $ddate = $value['date']; |
|
1640 | - $find = false; |
|
1641 | - foreach ($pall as $pvalue) { |
|
1642 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1643 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1644 | - $find = true; |
|
1645 | - break; |
|
1646 | - } |
|
1647 | - } |
|
1648 | - if ($find === false) { |
|
1649 | - $pall[] = $value; |
|
1650 | - } |
|
1651 | - } |
|
1652 | - $alldata = $pall; |
|
1635 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1636 | + foreach ($dall as $value) { |
|
1637 | + $icao = $value['departure_airport_icao']; |
|
1638 | + $airline = $value['airline_icao']; |
|
1639 | + $ddate = $value['date']; |
|
1640 | + $find = false; |
|
1641 | + foreach ($pall as $pvalue) { |
|
1642 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1643 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1644 | + $find = true; |
|
1645 | + break; |
|
1646 | + } |
|
1647 | + } |
|
1648 | + if ($find === false) { |
|
1649 | + $pall[] = $value; |
|
1650 | + } |
|
1651 | + } |
|
1652 | + $alldata = $pall; |
|
1653 | 1653 | foreach ($alldata as $number) { |
1654 | 1654 | $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']); |
1655 | 1655 | } |
1656 | 1656 | echo '...Arrival'."\n"; |
1657 | 1657 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1658 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1659 | - foreach ($dall as $value) { |
|
1660 | - $icao = $value['arrival_airport_icao']; |
|
1661 | - $airline = $value['airline_icao']; |
|
1662 | - $ddate = $value['date']; |
|
1663 | - $find = false; |
|
1664 | - foreach ($pall as $pvalue) { |
|
1665 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1666 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1667 | - $find = true; |
|
1668 | - break; |
|
1669 | - } |
|
1670 | - } |
|
1671 | - if ($find === false) { |
|
1672 | - $pall[] = $value; |
|
1673 | - } |
|
1674 | - } |
|
1675 | - $alldata = $pall; |
|
1658 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1659 | + foreach ($dall as $value) { |
|
1660 | + $icao = $value['arrival_airport_icao']; |
|
1661 | + $airline = $value['airline_icao']; |
|
1662 | + $ddate = $value['date']; |
|
1663 | + $find = false; |
|
1664 | + foreach ($pall as $pvalue) { |
|
1665 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1666 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1667 | + $find = true; |
|
1668 | + break; |
|
1669 | + } |
|
1670 | + } |
|
1671 | + if ($find === false) { |
|
1672 | + $pall[] = $value; |
|
1673 | + } |
|
1674 | + } |
|
1675 | + $alldata = $pall; |
|
1676 | 1676 | foreach ($alldata as $number) { |
1677 | 1677 | $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']); |
1678 | 1678 | } |
@@ -1732,45 +1732,45 @@ discard block |
||
1732 | 1732 | } |
1733 | 1733 | |
1734 | 1734 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1735 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1736 | - //$alldata = array(); |
|
1737 | - foreach ($dall as $value) { |
|
1738 | - $icao = $value['airport_departure_icao']; |
|
1739 | - $dicao = $value['airline_icap']; |
|
1740 | - $find = false; |
|
1741 | - foreach ($pall as $pvalue) { |
|
1742 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1743 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1744 | - $find = true; |
|
1745 | - break; |
|
1746 | - } |
|
1747 | - } |
|
1748 | - if ($find === false) { |
|
1749 | - $pall[] = $value; |
|
1750 | - } |
|
1751 | - } |
|
1752 | - $alldata = $pall; |
|
1735 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1736 | + //$alldata = array(); |
|
1737 | + foreach ($dall as $value) { |
|
1738 | + $icao = $value['airport_departure_icao']; |
|
1739 | + $dicao = $value['airline_icap']; |
|
1740 | + $find = false; |
|
1741 | + foreach ($pall as $pvalue) { |
|
1742 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1743 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1744 | + $find = true; |
|
1745 | + break; |
|
1746 | + } |
|
1747 | + } |
|
1748 | + if ($find === false) { |
|
1749 | + $pall[] = $value; |
|
1750 | + } |
|
1751 | + } |
|
1752 | + $alldata = $pall; |
|
1753 | 1753 | foreach ($alldata as $number) { |
1754 | - 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); |
|
1754 | + 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); |
|
1755 | 1755 | } |
1756 | 1756 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
1757 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1758 | - //$alldata = array(); |
|
1757 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1758 | + //$alldata = array(); |
|
1759 | 1759 | foreach ($dall as $value) { |
1760 | - $icao = $value['airport_arrival_icao']; |
|
1761 | - $dicao = $value['airline_icao']; |
|
1762 | - $find = false; |
|
1763 | - foreach ($pall as $pvalue) { |
|
1764 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1760 | + $icao = $value['airport_arrival_icao']; |
|
1761 | + $dicao = $value['airline_icao']; |
|
1762 | + $find = false; |
|
1763 | + foreach ($pall as $pvalue) { |
|
1764 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1765 | 1765 | $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1766 | 1766 | $find = true; |
1767 | 1767 | break; |
1768 | - } |
|
1768 | + } |
|
1769 | 1769 | } |
1770 | 1770 | if ($find === false) { |
1771 | 1771 | $pall[] = $value; |
1772 | 1772 | } |
1773 | - } |
|
1773 | + } |
|
1774 | 1774 | $alldata = $pall; |
1775 | 1775 | foreach ($alldata as $number) { |
1776 | 1776 | 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); |
@@ -1800,47 +1800,47 @@ discard block |
||
1800 | 1800 | } |
1801 | 1801 | echo '...Departure'."\n"; |
1802 | 1802 | $pall = $Spotter->getLast7DaysAirportsDeparture($filter); |
1803 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture($filter); |
|
1804 | - foreach ($dall as $value) { |
|
1805 | - $icao = $value['departure_airport_icao']; |
|
1806 | - $airline = $value['airline_icao']; |
|
1807 | - $ddate = $value['date']; |
|
1808 | - $find = false; |
|
1809 | - foreach ($pall as $pvalue) { |
|
1810 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1811 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1812 | - $find = true; |
|
1813 | - break; |
|
1814 | - } |
|
1815 | - } |
|
1803 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture($filter); |
|
1804 | + foreach ($dall as $value) { |
|
1805 | + $icao = $value['departure_airport_icao']; |
|
1806 | + $airline = $value['airline_icao']; |
|
1807 | + $ddate = $value['date']; |
|
1808 | + $find = false; |
|
1809 | + foreach ($pall as $pvalue) { |
|
1810 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1811 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1812 | + $find = true; |
|
1813 | + break; |
|
1814 | + } |
|
1815 | + } |
|
1816 | 1816 | if ($find === false) { |
1817 | - $pall[] = $value; |
|
1818 | - } |
|
1819 | - } |
|
1820 | - $alldata = $pall; |
|
1817 | + $pall[] = $value; |
|
1818 | + } |
|
1819 | + } |
|
1820 | + $alldata = $pall; |
|
1821 | 1821 | foreach ($alldata as $number) { |
1822 | 1822 | $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); |
1823 | 1823 | } |
1824 | 1824 | echo '...Arrival'."\n"; |
1825 | 1825 | $pall = $Spotter->getLast7DaysAirportsArrival($filter); |
1826 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival($filter); |
|
1826 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival($filter); |
|
1827 | 1827 | foreach ($dall as $value) { |
1828 | 1828 | $icao = $value['arrival_airport_icao']; |
1829 | 1829 | $airline = $value['airline_icao']; |
1830 | 1830 | $ddate = $value['date']; |
1831 | - $find = false; |
|
1831 | + $find = false; |
|
1832 | 1832 | foreach ($pall as $pvalue) { |
1833 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1834 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1835 | - $find = true; |
|
1836 | - break; |
|
1837 | - } |
|
1838 | - } |
|
1839 | - if ($find === false) { |
|
1840 | - $pall[] = $value; |
|
1841 | - } |
|
1842 | - } |
|
1843 | - $alldata = $pall; |
|
1833 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1834 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1835 | + $find = true; |
|
1836 | + break; |
|
1837 | + } |
|
1838 | + } |
|
1839 | + if ($find === false) { |
|
1840 | + $pall[] = $value; |
|
1841 | + } |
|
1842 | + } |
|
1843 | + $alldata = $pall; |
|
1844 | 1844 | foreach ($alldata as $number) { |
1845 | 1845 | $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); |
1846 | 1846 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | $this->db = $Connection->db(); |
14 | 14 | } |
15 | 15 | |
16 | - public function addLastStatsUpdate($type,$stats_date) { |
|
16 | + public function addLastStatsUpdate($type, $stats_date) { |
|
17 | 17 | $query = "DELETE FROM config WHERE name = :type; |
18 | 18 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
19 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
19 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
20 | 20 | try { |
21 | 21 | $sth = $this->db->prepare($query); |
22 | 22 | $sth->execute($query_values); |
23 | - } catch(PDOException $e) { |
|
23 | + } catch (PDOException $e) { |
|
24 | 24 | return "error : ".$e->getMessage(); |
25 | 25 | } |
26 | 26 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | try { |
31 | 31 | $sth = $this->db->prepare($query); |
32 | 32 | $sth->execute(array(':type' => $type)); |
33 | - } catch(PDOException $e) { |
|
33 | + } catch (PDOException $e) { |
|
34 | 34 | echo "error : ".$e->getMessage(); |
35 | 35 | } |
36 | 36 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | try { |
42 | 42 | $sth = $this->db->prepare($query); |
43 | 43 | $sth->execute(array(':filter_name' => $filter_name)); |
44 | - } catch(PDOException $e) { |
|
44 | + } catch (PDOException $e) { |
|
45 | 45 | echo "error : ".$e->getMessage(); |
46 | 46 | } |
47 | 47 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
48 | 48 | return $all; |
49 | 49 | } |
50 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
50 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
51 | 51 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
52 | 52 | try { |
53 | 53 | $sth = $this->db->prepare($query); |
54 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
55 | - } catch(PDOException $e) { |
|
54 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
55 | + } catch (PDOException $e) { |
|
56 | 56 | echo "error : ".$e->getMessage(); |
57 | 57 | } |
58 | 58 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
59 | 59 | return $all; |
60 | 60 | } |
61 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
61 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
62 | 62 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
63 | 63 | try { |
64 | 64 | $sth = $this->db->prepare($query); |
65 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
66 | - } catch(PDOException $e) { |
|
65 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
66 | + } catch (PDOException $e) { |
|
67 | 67 | echo "error : ".$e->getMessage(); |
68 | 68 | } |
69 | 69 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -77,29 +77,29 @@ discard block |
||
77 | 77 | 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"; |
78 | 78 | try { |
79 | 79 | $sth = $this->db->prepare($query); |
80 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
81 | - } catch(PDOException $e) { |
|
80 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
81 | + } catch (PDOException $e) { |
|
82 | 82 | echo "error : ".$e->getMessage(); |
83 | 83 | } |
84 | 84 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
85 | 85 | if (empty($all)) { |
86 | 86 | $filters = array('airlines' => array($stats_airline)); |
87 | 87 | if ($filter_name != '') { |
88 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
88 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
89 | 89 | } |
90 | 90 | $Spotter = new Spotter($this->db); |
91 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
91 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
92 | 92 | } |
93 | 93 | return $all; |
94 | 94 | } |
95 | - public function countAllAirlineCountries($limit = true,$filter_name = '') { |
|
95 | + public function countAllAirlineCountries($limit = true, $filter_name = '') { |
|
96 | 96 | global $globalStatsFilters; |
97 | 97 | 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"; |
98 | 98 | 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"; |
99 | 99 | try { |
100 | 100 | $sth = $this->db->prepare($query); |
101 | 101 | $sth->execute(array(':filter_name' => $filter_name)); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | echo "error : ".$e->getMessage(); |
104 | 104 | } |
105 | 105 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -107,27 +107,27 @@ discard block |
||
107 | 107 | $Spotter = new Spotter($this->db); |
108 | 108 | $filters = array(); |
109 | 109 | if ($filter_name != '') { |
110 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
110 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
111 | 111 | } |
112 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
112 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
113 | 113 | } |
114 | 114 | return $all; |
115 | 115 | } |
116 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
|
116 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') { |
|
117 | 117 | global $globalStatsFilters; |
118 | 118 | 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"; |
119 | 119 | 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"; |
120 | 120 | try { |
121 | 121 | $sth = $this->db->prepare($query); |
122 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
123 | - } catch(PDOException $e) { |
|
122 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
123 | + } catch (PDOException $e) { |
|
124 | 124 | echo "error : ".$e->getMessage(); |
125 | 125 | } |
126 | 126 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
127 | 127 | if (empty($all)) { |
128 | 128 | $filters = array('airlines' => array($stats_airline)); |
129 | 129 | if ($filter_name != '') { |
130 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
130 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
131 | 131 | } |
132 | 132 | $Spotter = new Spotter($this->db); |
133 | 133 | $all = $Spotter->countAllAircraftManufacturers($filters); |
@@ -141,18 +141,18 @@ discard block |
||
141 | 141 | 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"; |
142 | 142 | try { |
143 | 143 | $sth = $this->db->prepare($query); |
144 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
145 | - } catch(PDOException $e) { |
|
144 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
145 | + } catch (PDOException $e) { |
|
146 | 146 | echo "error : ".$e->getMessage(); |
147 | 147 | } |
148 | 148 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
149 | 149 | if (empty($all)) { |
150 | 150 | $filters = array('airlines' => array($stats_airline)); |
151 | 151 | if ($filter_name != '') { |
152 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
152 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
153 | 153 | } |
154 | 154 | $Spotter = new Spotter($this->db); |
155 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
155 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
156 | 156 | } |
157 | 157 | return $all; |
158 | 158 | } |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | 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"; |
163 | 163 | try { |
164 | 164 | $sth = $this->db->prepare($query); |
165 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
166 | - } catch(PDOException $e) { |
|
165 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
166 | + } catch (PDOException $e) { |
|
167 | 167 | echo "error : ".$e->getMessage(); |
168 | 168 | } |
169 | 169 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
170 | 170 | if (empty($all)) { |
171 | 171 | $filters = array('airlines' => array($stats_airline)); |
172 | 172 | if ($filter_name != '') { |
173 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
173 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
174 | 174 | } |
175 | 175 | $Spotter = new Spotter($this->db); |
176 | 176 | $all = $Spotter->countAllDepartureCountries($filters); |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | return $all; |
179 | 179 | } |
180 | 180 | |
181 | - public function countAllAirlines($limit = true,$filter_name = '') { |
|
181 | + public function countAllAirlines($limit = true, $filter_name = '') { |
|
182 | 182 | global $globalStatsFilters; |
183 | 183 | 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"; |
184 | 184 | 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"; |
185 | 185 | try { |
186 | 186 | $sth = $this->db->prepare($query); |
187 | 187 | $sth->execute(array(':filter_name' => $filter_name)); |
188 | - } catch(PDOException $e) { |
|
188 | + } catch (PDOException $e) { |
|
189 | 189 | echo "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -193,64 +193,64 @@ discard block |
||
193 | 193 | $Spotter = new Spotter($this->db); |
194 | 194 | $filters = array(); |
195 | 195 | if ($filter_name != '') { |
196 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
196 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
197 | 197 | } |
198 | 198 | |
199 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
199 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
200 | 200 | } |
201 | 201 | return $all; |
202 | 202 | } |
203 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
|
203 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') { |
|
204 | 204 | global $globalStatsFilters; |
205 | 205 | 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"; |
206 | 206 | 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"; |
207 | 207 | try { |
208 | 208 | $sth = $this->db->prepare($query); |
209 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
210 | - } catch(PDOException $e) { |
|
209 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | echo "error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
214 | 214 | if (empty($all)) { |
215 | 215 | $filters = array('airlines' => array($stats_airline)); |
216 | 216 | if ($filter_name != '') { |
217 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
217 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
218 | 218 | } |
219 | 219 | $Spotter = new Spotter($this->db); |
220 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
220 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
221 | 221 | } |
222 | 222 | return $all; |
223 | 223 | } |
224 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
|
224 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') { |
|
225 | 225 | global $globalStatsFilters; |
226 | 226 | 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"; |
227 | 227 | 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"; |
228 | 228 | try { |
229 | 229 | $sth = $this->db->prepare($query); |
230 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
231 | - } catch(PDOException $e) { |
|
230 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
231 | + } catch (PDOException $e) { |
|
232 | 232 | echo "error : ".$e->getMessage(); |
233 | 233 | } |
234 | 234 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
235 | 235 | if (empty($all)) { |
236 | 236 | $filters = array('airlines' => array($stats_airline)); |
237 | 237 | if ($filter_name != '') { |
238 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
238 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
239 | 239 | } |
240 | 240 | $Spotter = new Spotter($this->db); |
241 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
241 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
242 | 242 | } |
243 | 243 | return $all; |
244 | 244 | } |
245 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
|
245 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') { |
|
246 | 246 | $Connection = new Connection(); |
247 | 247 | if ($Connection->tableExists('countries')) { |
248 | 248 | 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"; |
249 | 249 | 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"; |
250 | 250 | try { |
251 | 251 | $sth = $this->db->prepare($query); |
252 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
253 | - } catch(PDOException $e) { |
|
252 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | echo "error : ".$e->getMessage(); |
255 | 255 | } |
256 | 256 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -265,67 +265,67 @@ discard block |
||
265 | 265 | return array(); |
266 | 266 | } |
267 | 267 | } |
268 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
|
268 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') { |
|
269 | 269 | global $globalStatsFilters; |
270 | 270 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
271 | 271 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
272 | 272 | try { |
273 | 273 | $sth = $this->db->prepare($query); |
274 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
275 | - } catch(PDOException $e) { |
|
274 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
275 | + } catch (PDOException $e) { |
|
276 | 276 | echo "error : ".$e->getMessage(); |
277 | 277 | } |
278 | 278 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
279 | 279 | if (empty($all)) { |
280 | 280 | $filters = array('airlines' => array($stats_airline)); |
281 | 281 | if ($filter_name != '') { |
282 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
282 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
283 | 283 | } |
284 | 284 | $Spotter = new Spotter($this->db); |
285 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
285 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
286 | 286 | } |
287 | 287 | return $all; |
288 | 288 | } |
289 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
|
289 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') { |
|
290 | 290 | global $globalStatsFilters; |
291 | 291 | 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"; |
292 | 292 | 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"; |
293 | 293 | try { |
294 | 294 | $sth = $this->db->prepare($query); |
295 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
296 | - } catch(PDOException $e) { |
|
295 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
296 | + } catch (PDOException $e) { |
|
297 | 297 | echo "error : ".$e->getMessage(); |
298 | 298 | } |
299 | 299 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
300 | 300 | if (empty($all)) { |
301 | 301 | $filters = array('airlines' => array($stats_airline)); |
302 | 302 | if ($filter_name != '') { |
303 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
303 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
304 | 304 | } |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
306 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
307 | 307 | } |
308 | 308 | return $all; |
309 | 309 | } |
310 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
310 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
311 | 311 | global $globalStatsFilters; |
312 | 312 | 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
313 | 313 | 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_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); |
321 | 321 | if (empty($all)) { |
322 | 322 | $filters = array('airlines' => array($stats_airline)); |
323 | 323 | if ($filter_name != '') { |
324 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
324 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
325 | 325 | } |
326 | 326 | $Spotter = new Spotter($this->db); |
327 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
328 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
327 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
328 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
329 | 329 | $all = array(); |
330 | 330 | foreach ($pall as $value) { |
331 | 331 | $icao = $value['airport_departure_icao']; |
@@ -342,29 +342,29 @@ discard block |
||
342 | 342 | foreach ($all as $key => $row) { |
343 | 343 | $count[$key] = $row['airport_departure_icao_count']; |
344 | 344 | } |
345 | - array_multisort($count,SORT_DESC,$all); |
|
345 | + array_multisort($count, SORT_DESC, $all); |
|
346 | 346 | } |
347 | 347 | return $all; |
348 | 348 | } |
349 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
349 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
350 | 350 | global $globalStatsFilters; |
351 | 351 | 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
352 | 352 | 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
353 | 353 | try { |
354 | 354 | $sth = $this->db->prepare($query); |
355 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
356 | - } catch(PDOException $e) { |
|
355 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | echo "error : ".$e->getMessage(); |
358 | 358 | } |
359 | 359 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
360 | 360 | if (empty($all)) { |
361 | 361 | $filters = array('airlines' => array($stats_airline)); |
362 | 362 | if ($filter_name != '') { |
363 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
363 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
364 | 364 | } |
365 | 365 | $Spotter = new Spotter($this->db); |
366 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
367 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
366 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
367 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
368 | 368 | $all = array(); |
369 | 369 | foreach ($pall as $value) { |
370 | 370 | $icao = $value['airport_arrival_icao']; |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | foreach ($all as $key => $row) { |
382 | 382 | $count[$key] = $row['airport_arrival_icao_count']; |
383 | 383 | } |
384 | - array_multisort($count,SORT_DESC,$all); |
|
384 | + array_multisort($count, SORT_DESC, $all); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | return $all; |
388 | 388 | } |
389 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
389 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
390 | 390 | global $globalDBdriver, $globalStatsFilters; |
391 | 391 | if ($globalDBdriver == 'mysql') { |
392 | 392 | 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"; |
@@ -395,18 +395,18 @@ discard block |
||
395 | 395 | 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"; |
396 | 396 | 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"; |
397 | 397 | } |
398 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
398 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
399 | 399 | try { |
400 | 400 | $sth = $this->db->prepare($query); |
401 | 401 | $sth->execute($query_data); |
402 | - } catch(PDOException $e) { |
|
402 | + } catch (PDOException $e) { |
|
403 | 403 | echo "error : ".$e->getMessage(); |
404 | 404 | } |
405 | 405 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
406 | 406 | if (empty($all)) { |
407 | 407 | $filters = array('airlines' => array($stats_airline)); |
408 | 408 | if ($filter_name != '') { |
409 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
409 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
410 | 410 | } |
411 | 411 | $Spotter = new Spotter($this->db); |
412 | 412 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -415,67 +415,67 @@ discard block |
||
415 | 415 | return $all; |
416 | 416 | } |
417 | 417 | |
418 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
418 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
419 | 419 | global $globalStatsFilters; |
420 | 420 | $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"; |
421 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
421 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
422 | 422 | try { |
423 | 423 | $sth = $this->db->prepare($query); |
424 | 424 | $sth->execute($query_data); |
425 | - } catch(PDOException $e) { |
|
425 | + } catch (PDOException $e) { |
|
426 | 426 | echo "error : ".$e->getMessage(); |
427 | 427 | } |
428 | 428 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
429 | 429 | if (empty($all)) { |
430 | 430 | $filters = array('airlines' => array($stats_airline)); |
431 | 431 | if ($filter_name != '') { |
432 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
432 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
433 | 433 | } |
434 | 434 | $Spotter = new Spotter($this->db); |
435 | 435 | $all = $Spotter->countAllDatesLastMonth($filters); |
436 | 436 | } |
437 | 437 | return $all; |
438 | 438 | } |
439 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
439 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
440 | 440 | global $globalDBdriver, $globalStatsFilters; |
441 | 441 | if ($globalDBdriver == 'mysql') { |
442 | 442 | $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"; |
443 | 443 | } else { |
444 | 444 | $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"; |
445 | 445 | } |
446 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
446 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
447 | 447 | try { |
448 | 448 | $sth = $this->db->prepare($query); |
449 | 449 | $sth->execute($query_data); |
450 | - } catch(PDOException $e) { |
|
450 | + } catch (PDOException $e) { |
|
451 | 451 | echo "error : ".$e->getMessage(); |
452 | 452 | } |
453 | 453 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
454 | 454 | if (empty($all)) { |
455 | 455 | $filters = array('airlines' => array($stats_airline)); |
456 | 456 | if ($filter_name != '') { |
457 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
457 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
458 | 458 | } |
459 | 459 | $Spotter = new Spotter($this->db); |
460 | 460 | $all = $Spotter->countAllDatesLast7Days($filters); |
461 | 461 | } |
462 | 462 | return $all; |
463 | 463 | } |
464 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
464 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
465 | 465 | global $globalStatsFilters; |
466 | 466 | $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"; |
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->countAllDates($filters); |
@@ -488,34 +488,34 @@ discard block |
||
488 | 488 | try { |
489 | 489 | $sth = $this->db->prepare($query); |
490 | 490 | $sth->execute($query_data); |
491 | - } catch(PDOException $e) { |
|
491 | + } catch (PDOException $e) { |
|
492 | 492 | echo "error : ".$e->getMessage(); |
493 | 493 | } |
494 | 494 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
495 | 495 | if (empty($all)) { |
496 | 496 | $filters = array(); |
497 | 497 | if ($filter_name != '') { |
498 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
498 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
499 | 499 | } |
500 | 500 | $Spotter = new Spotter($this->db); |
501 | 501 | $all = $Spotter->countAllDatesByAirlines($filters); |
502 | 502 | } |
503 | 503 | return $all; |
504 | 504 | } |
505 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
505 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
506 | 506 | global $globalStatsFilters; |
507 | 507 | $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"; |
508 | 508 | try { |
509 | 509 | $sth = $this->db->prepare($query); |
510 | 510 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
511 | - } catch(PDOException $e) { |
|
511 | + } catch (PDOException $e) { |
|
512 | 512 | echo "error : ".$e->getMessage(); |
513 | 513 | } |
514 | 514 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
515 | 515 | if (empty($all)) { |
516 | 516 | $filters = array('airlines' => array($stats_airline)); |
517 | 517 | if ($filter_name != '') { |
518 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
518 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
519 | 519 | } |
520 | 520 | $Spotter = new Spotter($this->db); |
521 | 521 | $all = $Spotter->countAllMonths($filters); |
@@ -528,21 +528,21 @@ discard block |
||
528 | 528 | try { |
529 | 529 | $sth = $this->db->prepare($query); |
530 | 530 | $sth->execute(array(':filter_name' => $filter_name)); |
531 | - } catch(PDOException $e) { |
|
531 | + } catch (PDOException $e) { |
|
532 | 532 | echo "error : ".$e->getMessage(); |
533 | 533 | } |
534 | 534 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
535 | 535 | if (empty($all)) { |
536 | 536 | $filters = array(); |
537 | 537 | if ($filter_name != '') { |
538 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
538 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
539 | 539 | } |
540 | 540 | $Spotter = new Spotter($this->db); |
541 | 541 | $all = $Spotter->countAllMilitaryMonths($filters); |
542 | 542 | } |
543 | 543 | return $all; |
544 | 544 | } |
545 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
545 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
546 | 546 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
547 | 547 | |
548 | 548 | 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"; |
@@ -558,28 +558,28 @@ discard block |
||
558 | 558 | try { |
559 | 559 | $sth = $this->db->prepare($query); |
560 | 560 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
561 | - } catch(PDOException $e) { |
|
561 | + } catch (PDOException $e) { |
|
562 | 562 | echo "error : ".$e->getMessage(); |
563 | 563 | } |
564 | 564 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
565 | 565 | if (empty($all)) { |
566 | 566 | $filters = array('airlines' => array($stats_airline)); |
567 | 567 | if ($filter_name != '') { |
568 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
568 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
569 | 569 | } |
570 | 570 | $Spotter = new Spotter($this->db); |
571 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
571 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
572 | 572 | } |
573 | 573 | return $all; |
574 | 574 | } |
575 | 575 | |
576 | 576 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
577 | 577 | global $globalStatsFilters; |
578 | - $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
|
578 | + $all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name); |
|
579 | 579 | if (empty($all)) { |
580 | 580 | $filters = array('airlines' => array($stats_airline)); |
581 | 581 | if ($filter_name != '') { |
582 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
582 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
583 | 583 | } |
584 | 584 | $Spotter = new Spotter($this->db); |
585 | 585 | $all = $Spotter->countOverallFlights($filters); |
@@ -587,37 +587,37 @@ discard block |
||
587 | 587 | return $all; |
588 | 588 | } |
589 | 589 | public function countOverallMilitaryFlights($filter_name = '') { |
590 | - $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
|
590 | + $all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name); |
|
591 | 591 | if (empty($all)) { |
592 | 592 | $filters = array(); |
593 | 593 | if ($filter_name != '') { |
594 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
594 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
595 | 595 | } |
596 | 596 | $Spotter = new Spotter($this->db); |
597 | 597 | $all = $Spotter->countOverallMilitaryFlights($filters); |
598 | 598 | } |
599 | 599 | return $all; |
600 | 600 | } |
601 | - public function countOverallArrival($stats_airline = '',$filter_name = '') { |
|
601 | + public function countOverallArrival($stats_airline = '', $filter_name = '') { |
|
602 | 602 | global $globalStatsFilters; |
603 | - $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
|
603 | + $all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name); |
|
604 | 604 | if (empty($all)) { |
605 | 605 | $filters = array('airlines' => array($stats_airline)); |
606 | 606 | if ($filter_name != '') { |
607 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
607 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
608 | 608 | } |
609 | 609 | $Spotter = new Spotter($this->db); |
610 | 610 | $all = $Spotter->countOverallArrival($filters); |
611 | 611 | } |
612 | 612 | return $all; |
613 | 613 | } |
614 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
|
614 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '') { |
|
615 | 615 | global $globalStatsFilters; |
616 | - $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
|
616 | + $all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name); |
|
617 | 617 | if (empty($all)) { |
618 | 618 | $filters = array('airlines' => array($stats_airline)); |
619 | 619 | if ($filter_name != '') { |
620 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
620 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
621 | 621 | } |
622 | 622 | $Spotter = new Spotter($this->db); |
623 | 623 | $all = $Spotter->countOverallAircrafts($filters); |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $this->db->prepare($query); |
631 | 631 | $sth->execute(array(':filter_name' => $filter_name)); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | echo "error : ".$e->getMessage(); |
634 | 634 | } |
635 | 635 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -638,14 +638,14 @@ discard block |
||
638 | 638 | if (empty($all)) { |
639 | 639 | $filters = array(); |
640 | 640 | if ($filter_name != '') { |
641 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
641 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
642 | 642 | } |
643 | 643 | $Spotter = new Spotter($this->db); |
644 | 644 | $all = $Spotter->countOverallAirlines($filters); |
645 | 645 | } |
646 | 646 | return $all; |
647 | 647 | } |
648 | - public function countOverallOwners($stats_airline = '',$filter_name = '') { |
|
648 | + public function countOverallOwners($stats_airline = '', $filter_name = '') { |
|
649 | 649 | global $globalStatsFilters; |
650 | 650 | /* |
651 | 651 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
@@ -658,24 +658,24 @@ discard block |
||
658 | 658 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
659 | 659 | $all = $result[0]['nb_owner']; |
660 | 660 | */ |
661 | - $all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name); |
|
661 | + $all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name); |
|
662 | 662 | if (empty($all)) { |
663 | 663 | $filters = array('airlines' => array($stats_airline)); |
664 | 664 | if ($filter_name != '') { |
665 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
665 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
666 | 666 | } |
667 | 667 | $Spotter = new Spotter($this->db); |
668 | 668 | $all = $Spotter->countOverallOwners($filters); |
669 | 669 | } |
670 | 670 | return $all; |
671 | 671 | } |
672 | - public function countOverallPilots($stats_airline = '',$filter_name = '') { |
|
672 | + public function countOverallPilots($stats_airline = '', $filter_name = '') { |
|
673 | 673 | global $globalStatsFilters; |
674 | - $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
|
674 | + $all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name); |
|
675 | 675 | if (empty($all)) { |
676 | 676 | $filters = array('airlines' => array($stats_airline)); |
677 | 677 | if ($filter_name != '') { |
678 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
678 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
679 | 679 | } |
680 | 680 | $Spotter = new Spotter($this->db); |
681 | 681 | $all = $Spotter->countOverallPilots($filters); |
@@ -683,42 +683,42 @@ discard block |
||
683 | 683 | return $all; |
684 | 684 | } |
685 | 685 | |
686 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
686 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
687 | 687 | $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"; |
688 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
688 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
689 | 689 | try { |
690 | 690 | $sth = $this->db->prepare($query); |
691 | 691 | $sth->execute($query_values); |
692 | - } catch(PDOException $e) { |
|
692 | + } catch (PDOException $e) { |
|
693 | 693 | echo "error : ".$e->getMessage(); |
694 | 694 | } |
695 | 695 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
696 | 696 | return $all; |
697 | 697 | } |
698 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
698 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
699 | 699 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
700 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
700 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
701 | 701 | try { |
702 | 702 | $sth = $this->db->prepare($query); |
703 | 703 | $sth->execute($query_values); |
704 | - } catch(PDOException $e) { |
|
704 | + } catch (PDOException $e) { |
|
705 | 705 | echo "error : ".$e->getMessage(); |
706 | 706 | } |
707 | 707 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
708 | 708 | return $all; |
709 | 709 | } |
710 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
|
710 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') { |
|
711 | 711 | global $globalArchiveMonths, $globalDBdriver; |
712 | 712 | if ($globalDBdriver == 'mysql') { |
713 | 713 | $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"; |
714 | 714 | } else { |
715 | 715 | $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"; |
716 | 716 | } |
717 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
717 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
718 | 718 | try { |
719 | 719 | $sth = $this->db->prepare($query); |
720 | 720 | $sth->execute($query_values); |
721 | - } catch(PDOException $e) { |
|
721 | + } catch (PDOException $e) { |
|
722 | 722 | echo "error : ".$e->getMessage(); |
723 | 723 | } |
724 | 724 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | try { |
736 | 736 | $sth = $this->db->prepare($query); |
737 | 737 | $sth->execute($query_values); |
738 | - } catch(PDOException $e) { |
|
738 | + } catch (PDOException $e) { |
|
739 | 739 | echo "error : ".$e->getMessage(); |
740 | 740 | } |
741 | 741 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | try { |
752 | 752 | $sth = $this->db->prepare($query); |
753 | 753 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
754 | - } catch(PDOException $e) { |
|
754 | + } catch (PDOException $e) { |
|
755 | 755 | echo "error : ".$e->getMessage(); |
756 | 756 | } |
757 | 757 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | try { |
768 | 768 | $sth = $this->db->prepare($query); |
769 | 769 | $sth->execute(array(':filter_name' => $filter_name)); |
770 | - } catch(PDOException $e) { |
|
770 | + } catch (PDOException $e) { |
|
771 | 771 | echo "error : ".$e->getMessage(); |
772 | 772 | } |
773 | 773 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | try { |
784 | 784 | $sth = $this->db->prepare($query); |
785 | 785 | $sth->execute(array(':filter_name' => $filter_name)); |
786 | - } catch(PDOException $e) { |
|
786 | + } catch (PDOException $e) { |
|
787 | 787 | echo "error : ".$e->getMessage(); |
788 | 788 | } |
789 | 789 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -799,29 +799,29 @@ discard block |
||
799 | 799 | try { |
800 | 800 | $sth = $this->db->prepare($query); |
801 | 801 | $sth->execute(array(':filter_name' => $filter_name)); |
802 | - } catch(PDOException $e) { |
|
802 | + } catch (PDOException $e) { |
|
803 | 803 | echo "error : ".$e->getMessage(); |
804 | 804 | } |
805 | 805 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
806 | 806 | return $all[0]['total']; |
807 | 807 | } |
808 | 808 | |
809 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
809 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
810 | 810 | global $globalDBdriver; |
811 | 811 | if ($globalDBdriver == 'mysql') { |
812 | 812 | $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"; |
813 | 813 | } else { |
814 | 814 | $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);"; |
815 | 815 | } |
816 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
816 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
817 | 817 | try { |
818 | 818 | $sth = $this->db->prepare($query); |
819 | 819 | $sth->execute($query_values); |
820 | - } catch(PDOException $e) { |
|
820 | + } catch (PDOException $e) { |
|
821 | 821 | return "error : ".$e->getMessage(); |
822 | 822 | } |
823 | 823 | } |
824 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
824 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
825 | 825 | global $globalDBdriver; |
826 | 826 | if ($globalDBdriver == 'mysql') { |
827 | 827 | $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"; |
@@ -829,219 +829,219 @@ discard block |
||
829 | 829 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
830 | 830 | $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);"; |
831 | 831 | } |
832 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
832 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
833 | 833 | try { |
834 | 834 | $sth = $this->db->prepare($query); |
835 | 835 | $sth->execute($query_values); |
836 | - } catch(PDOException $e) { |
|
836 | + } catch (PDOException $e) { |
|
837 | 837 | return "error : ".$e->getMessage(); |
838 | 838 | } |
839 | 839 | } |
840 | - public function getStatsSource($date,$stats_type = '') { |
|
840 | + public function getStatsSource($date, $stats_type = '') { |
|
841 | 841 | if ($stats_type == '') { |
842 | 842 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
843 | 843 | $query_values = array(':date' => $date); |
844 | 844 | } else { |
845 | 845 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
846 | - $query_values = array(':date' => $date,':stats_type' => $stats_type); |
|
846 | + $query_values = array(':date' => $date, ':stats_type' => $stats_type); |
|
847 | 847 | } |
848 | 848 | try { |
849 | 849 | $sth = $this->db->prepare($query); |
850 | 850 | $sth->execute($query_values); |
851 | - } catch(PDOException $e) { |
|
851 | + } catch (PDOException $e) { |
|
852 | 852 | echo "error : ".$e->getMessage(); |
853 | 853 | } |
854 | 854 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
855 | 855 | return $all; |
856 | 856 | } |
857 | 857 | |
858 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
858 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
859 | 859 | global $globalDBdriver; |
860 | 860 | if ($globalDBdriver == 'mysql') { |
861 | 861 | $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"; |
862 | 862 | } else { |
863 | 863 | $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);"; |
864 | 864 | } |
865 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
865 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
866 | 866 | try { |
867 | 867 | $sth = $this->db->prepare($query); |
868 | 868 | $sth->execute($query_values); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error : ".$e->getMessage(); |
871 | 871 | } |
872 | 872 | } |
873 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
873 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
874 | 874 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
875 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
875 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
876 | 876 | try { |
877 | 877 | $sth = $this->db->prepare($query); |
878 | 878 | $sth->execute($query_values); |
879 | - } catch(PDOException $e) { |
|
879 | + } catch (PDOException $e) { |
|
880 | 880 | return "error : ".$e->getMessage(); |
881 | 881 | } |
882 | 882 | } |
883 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
|
883 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') { |
|
884 | 884 | global $globalDBdriver; |
885 | 885 | if ($globalDBdriver == 'mysql') { |
886 | 886 | $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"; |
887 | 887 | } else { |
888 | 888 | $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);"; |
889 | 889 | } |
890 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
890 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
891 | 891 | try { |
892 | 892 | $sth = $this->db->prepare($query); |
893 | 893 | $sth->execute($query_values); |
894 | - } catch(PDOException $e) { |
|
894 | + } catch (PDOException $e) { |
|
895 | 895 | return "error : ".$e->getMessage(); |
896 | 896 | } |
897 | 897 | } |
898 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
|
898 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') { |
|
899 | 899 | global $globalDBdriver; |
900 | 900 | if ($globalDBdriver == 'mysql') { |
901 | 901 | $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"; |
902 | 902 | } else { |
903 | 903 | $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);"; |
904 | 904 | } |
905 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
905 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
906 | 906 | try { |
907 | 907 | $sth = $this->db->prepare($query); |
908 | 908 | $sth->execute($query_values); |
909 | - } catch(PDOException $e) { |
|
909 | + } catch (PDOException $e) { |
|
910 | 910 | return "error : ".$e->getMessage(); |
911 | 911 | } |
912 | 912 | } |
913 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
|
913 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') { |
|
914 | 914 | global $globalDBdriver; |
915 | 915 | if ($globalDBdriver == 'mysql') { |
916 | 916 | $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"; |
917 | 917 | } else { |
918 | 918 | $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);"; |
919 | 919 | } |
920 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
920 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
921 | 921 | try { |
922 | 922 | $sth = $this->db->prepare($query); |
923 | 923 | $sth->execute($query_values); |
924 | - } catch(PDOException $e) { |
|
924 | + } catch (PDOException $e) { |
|
925 | 925 | return "error : ".$e->getMessage(); |
926 | 926 | } |
927 | 927 | } |
928 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
928 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
929 | 929 | global $globalDBdriver; |
930 | 930 | if ($globalDBdriver == 'mysql') { |
931 | 931 | $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"; |
932 | 932 | } else { |
933 | 933 | $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);"; |
934 | 934 | } |
935 | - $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); |
|
935 | + $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); |
|
936 | 936 | try { |
937 | 937 | $sth = $this->db->prepare($query); |
938 | 938 | $sth->execute($query_values); |
939 | - } catch(PDOException $e) { |
|
939 | + } catch (PDOException $e) { |
|
940 | 940 | return "error : ".$e->getMessage(); |
941 | 941 | } |
942 | 942 | } |
943 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
|
943 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') { |
|
944 | 944 | global $globalDBdriver; |
945 | 945 | if ($globalDBdriver == 'mysql') { |
946 | 946 | $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"; |
947 | 947 | } else { |
948 | 948 | $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);"; |
949 | 949 | } |
950 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
950 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
951 | 951 | try { |
952 | 952 | $sth = $this->db->prepare($query); |
953 | 953 | $sth->execute($query_values); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error : ".$e->getMessage(); |
956 | 956 | } |
957 | 957 | } |
958 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
|
958 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
959 | 959 | global $globalDBdriver; |
960 | 960 | if ($globalDBdriver == 'mysql') { |
961 | 961 | $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"; |
962 | 962 | } else { |
963 | 963 | $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);"; |
964 | 964 | } |
965 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
965 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
966 | 966 | try { |
967 | 967 | $sth = $this->db->prepare($query); |
968 | 968 | $sth->execute($query_values); |
969 | - } catch(PDOException $e) { |
|
969 | + } catch (PDOException $e) { |
|
970 | 970 | return "error : ".$e->getMessage(); |
971 | 971 | } |
972 | 972 | } |
973 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') { |
|
973 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '') { |
|
974 | 974 | global $globalDBdriver; |
975 | 975 | if ($globalDBdriver == 'mysql') { |
976 | 976 | $query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name"; |
977 | 977 | } else { |
978 | 978 | $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; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
979 | 979 | } |
980 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
980 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
981 | 981 | try { |
982 | 982 | $sth = $this->db->prepare($query); |
983 | 983 | $sth->execute($query_values); |
984 | - } catch(PDOException $e) { |
|
984 | + } catch (PDOException $e) { |
|
985 | 985 | return "error : ".$e->getMessage(); |
986 | 986 | } |
987 | 987 | } |
988 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
988 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
989 | 989 | global $globalDBdriver; |
990 | 990 | if ($globalDBdriver == 'mysql') { |
991 | 991 | $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"; |
992 | 992 | } else { |
993 | 993 | $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);"; |
994 | 994 | } |
995 | - $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); |
|
995 | + $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); |
|
996 | 996 | try { |
997 | 997 | $sth = $this->db->prepare($query); |
998 | 998 | $sth->execute($query_values); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error : ".$e->getMessage(); |
1001 | 1001 | } |
1002 | 1002 | } |
1003 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1003 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1004 | 1004 | global $globalDBdriver; |
1005 | 1005 | if ($globalDBdriver == 'mysql') { |
1006 | 1006 | $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"; |
1007 | 1007 | } else { |
1008 | 1008 | $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);"; |
1009 | 1009 | } |
1010 | - $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); |
|
1010 | + $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); |
|
1011 | 1011 | try { |
1012 | 1012 | $sth = $this->db->prepare($query); |
1013 | 1013 | $sth->execute($query_values); |
1014 | - } catch(PDOException $e) { |
|
1014 | + } catch (PDOException $e) { |
|
1015 | 1015 | return "error : ".$e->getMessage(); |
1016 | 1016 | } |
1017 | 1017 | } |
1018 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1018 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1019 | 1019 | global $globalDBdriver; |
1020 | 1020 | if ($globalDBdriver == 'mysql') { |
1021 | 1021 | $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"; |
1022 | 1022 | } else { |
1023 | 1023 | $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);"; |
1024 | 1024 | } |
1025 | - $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); |
|
1025 | + $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); |
|
1026 | 1026 | try { |
1027 | 1027 | $sth = $this->db->prepare($query); |
1028 | 1028 | $sth->execute($query_values); |
1029 | - } catch(PDOException $e) { |
|
1029 | + } catch (PDOException $e) { |
|
1030 | 1030 | return "error : ".$e->getMessage(); |
1031 | 1031 | } |
1032 | 1032 | } |
1033 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1033 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1034 | 1034 | global $globalDBdriver; |
1035 | 1035 | if ($globalDBdriver == 'mysql') { |
1036 | 1036 | $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"; |
1037 | 1037 | } else { |
1038 | 1038 | $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);"; |
1039 | 1039 | } |
1040 | - $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); |
|
1040 | + $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); |
|
1041 | 1041 | try { |
1042 | 1042 | $sth = $this->db->prepare($query); |
1043 | 1043 | $sth->execute($query_values); |
1044 | - } catch(PDOException $e) { |
|
1044 | + } catch (PDOException $e) { |
|
1045 | 1045 | return "error : ".$e->getMessage(); |
1046 | 1046 | } |
1047 | 1047 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | try { |
1053 | 1053 | $sth = $this->db->prepare($query); |
1054 | 1054 | $sth->execute($query_values); |
1055 | - } catch(PDOException $e) { |
|
1055 | + } catch (PDOException $e) { |
|
1056 | 1056 | return "error : ".$e->getMessage(); |
1057 | 1057 | } |
1058 | 1058 | } |
@@ -1062,7 +1062,7 @@ discard block |
||
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 | } |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | try { |
1073 | 1073 | $sth = $this->db->prepare($query); |
1074 | 1074 | $sth->execute($query_values); |
1075 | - } catch(PDOException $e) { |
|
1075 | + } catch (PDOException $e) { |
|
1076 | 1076 | return "error : ".$e->getMessage(); |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1310,33 +1310,33 @@ discard block |
||
1310 | 1310 | $last_update_day = $last_update[0]['value']; |
1311 | 1311 | } else $last_update_day = '2012-12-12 12:12:12'; |
1312 | 1312 | $Spotter = new Spotter($this->db); |
1313 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1313 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1314 | 1314 | foreach ($alldata as $number) { |
1315 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
|
1315 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']); |
|
1316 | 1316 | } |
1317 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1317 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1318 | 1318 | foreach ($alldata as $number) { |
1319 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
|
1319 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']); |
|
1320 | 1320 | } |
1321 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1321 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1322 | 1322 | foreach ($alldata as $number) { |
1323 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
|
1323 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']); |
|
1324 | 1324 | } |
1325 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1325 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1326 | 1326 | foreach ($alldata as $number) { |
1327 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1327 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1328 | 1328 | } |
1329 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1329 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1330 | 1330 | foreach ($alldata as $number) { |
1331 | - $this->addStatOwner($number['owner_name'],$number['owner_count']); |
|
1331 | + $this->addStatOwner($number['owner_name'], $number['owner_count']); |
|
1332 | 1332 | } |
1333 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1333 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1334 | 1334 | foreach ($alldata as $number) { |
1335 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
|
1335 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name']); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1339 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1338 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1339 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1340 | 1340 | $alldata = array(); |
1341 | 1341 | |
1342 | 1342 | foreach ($pall as $value) { |
@@ -1353,12 +1353,12 @@ discard block |
||
1353 | 1353 | foreach ($alldata as $key => $row) { |
1354 | 1354 | $count[$key] = $row['airport_departure_icao_count']; |
1355 | 1355 | } |
1356 | - array_multisort($count,SORT_DESC,$alldata); |
|
1356 | + array_multisort($count, SORT_DESC, $alldata); |
|
1357 | 1357 | foreach ($alldata as $number) { |
1358 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
|
1358 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']); |
|
1359 | 1359 | } |
1360 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1361 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1360 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1361 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1362 | 1362 | $alldata = array(); |
1363 | 1363 | foreach ($pall as $value) { |
1364 | 1364 | $icao = $value['airport_arrival_icao']; |
@@ -1374,15 +1374,15 @@ discard block |
||
1374 | 1374 | foreach ($alldata as $key => $row) { |
1375 | 1375 | $count[$key] = $row['airport_arrival_icao_count']; |
1376 | 1376 | } |
1377 | - array_multisort($count,SORT_DESC,$alldata); |
|
1377 | + array_multisort($count, SORT_DESC, $alldata); |
|
1378 | 1378 | foreach ($alldata as $number) { |
1379 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
|
1379 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']); |
|
1380 | 1380 | } |
1381 | 1381 | if ($Connection->tableExists('countries')) { |
1382 | 1382 | $SpotterArchive = new SpotterArchive(); |
1383 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
1383 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1384 | 1384 | foreach ($alldata as $number) { |
1385 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']); |
|
1385 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']); |
|
1386 | 1386 | } |
1387 | 1387 | } |
1388 | 1388 | |
@@ -1395,31 +1395,31 @@ discard block |
||
1395 | 1395 | $lastyear = false; |
1396 | 1396 | foreach ($alldata as $number) { |
1397 | 1397 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1398 | - $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']))); |
|
1398 | + $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']))); |
|
1399 | 1399 | } |
1400 | 1400 | $alldata = $Spotter->countAllMilitaryMonths(); |
1401 | 1401 | foreach ($alldata as $number) { |
1402 | - $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']))); |
|
1402 | + $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']))); |
|
1403 | 1403 | } |
1404 | 1404 | $alldata = $Spotter->countAllMonthsOwners(); |
1405 | 1405 | foreach ($alldata as $number) { |
1406 | - $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']))); |
|
1406 | + $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']))); |
|
1407 | 1407 | } |
1408 | 1408 | $alldata = $Spotter->countAllMonthsPilots(); |
1409 | 1409 | foreach ($alldata as $number) { |
1410 | - $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']))); |
|
1410 | + $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']))); |
|
1411 | 1411 | } |
1412 | 1412 | $alldata = $Spotter->countAllMonthsAirlines(); |
1413 | 1413 | foreach ($alldata as $number) { |
1414 | - $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']))); |
|
1414 | + $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']))); |
|
1415 | 1415 | } |
1416 | 1416 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1417 | 1417 | foreach ($alldata as $number) { |
1418 | - $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']))); |
|
1418 | + $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']))); |
|
1419 | 1419 | } |
1420 | 1420 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1421 | 1421 | foreach ($alldata as $number) { |
1422 | - $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']))); |
|
1422 | + $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']))); |
|
1423 | 1423 | } |
1424 | 1424 | echo 'Airports data...'."\n"; |
1425 | 1425 | echo '...Departure'."\n"; |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | } |
1465 | 1465 | $alldata = $pall; |
1466 | 1466 | foreach ($alldata as $number) { |
1467 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1467 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1468 | 1468 | } |
1469 | 1469 | echo '...Arrival'."\n"; |
1470 | 1470 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | } |
1507 | 1507 | $alldata = $pall; |
1508 | 1508 | foreach ($alldata as $number) { |
1509 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1509 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | 1512 | echo 'Flights data...'."\n"; |
@@ -1514,27 +1514,27 @@ discard block |
||
1514 | 1514 | echo '-> countAllDatesLastMonth...'."\n"; |
1515 | 1515 | $alldata = $Spotter->countAllDatesLastMonth(); |
1516 | 1516 | foreach ($alldata as $number) { |
1517 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1517 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1518 | 1518 | } |
1519 | 1519 | echo '-> countAllDates...'."\n"; |
1520 | 1520 | $previousdata = $this->countAllDates(); |
1521 | 1521 | $this->deleteStatFlight('date'); |
1522 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
1522 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
1523 | 1523 | $values = array(); |
1524 | 1524 | foreach ($alldata as $cnt) { |
1525 | 1525 | $values[] = $cnt['date_count']; |
1526 | 1526 | } |
1527 | - array_multisort($values,SORT_DESC,$alldata); |
|
1528 | - array_splice($alldata,11); |
|
1527 | + array_multisort($values, SORT_DESC, $alldata); |
|
1528 | + array_splice($alldata, 11); |
|
1529 | 1529 | foreach ($alldata as $number) { |
1530 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1530 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | $this->deleteStatFlight('hour'); |
1534 | 1534 | echo '-> countAllHours...'."\n"; |
1535 | 1535 | $alldata = $Spotter->countAllHours('hour'); |
1536 | 1536 | foreach ($alldata as $number) { |
1537 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1537 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | |
@@ -1542,29 +1542,29 @@ discard block |
||
1542 | 1542 | // Count by airlines |
1543 | 1543 | echo '--- Stats by airlines ---'."\n"; |
1544 | 1544 | $Spotter = new Spotter($this->db); |
1545 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1545 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1546 | 1546 | foreach ($alldata as $number) { |
1547 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
|
1547 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']); |
|
1548 | 1548 | } |
1549 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1549 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1550 | 1550 | foreach ($alldata as $number) { |
1551 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
|
1551 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']); |
|
1552 | 1552 | } |
1553 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1553 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1554 | 1554 | foreach ($alldata as $number) { |
1555 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1555 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1556 | 1556 | } |
1557 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1557 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1558 | 1558 | foreach ($alldata as $number) { |
1559 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
|
1559 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']); |
|
1560 | 1560 | } |
1561 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1561 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1562 | 1562 | foreach ($alldata as $number) { |
1563 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
|
1563 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao']); |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1567 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1566 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1567 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1568 | 1568 | //$alldata = array(); |
1569 | 1569 | foreach ($dall as $value) { |
1570 | 1570 | $icao = $value['airport_departure_icao']; |
@@ -1583,10 +1583,10 @@ discard block |
||
1583 | 1583 | } |
1584 | 1584 | $alldata = $pall; |
1585 | 1585 | foreach ($alldata as $number) { |
1586 | - 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']); |
|
1586 | + 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']); |
|
1587 | 1587 | } |
1588 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1589 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1588 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1589 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1590 | 1590 | //$alldata = array(); |
1591 | 1591 | foreach ($dall as $value) { |
1592 | 1592 | $icao = $value['airport_arrival_icao']; |
@@ -1605,30 +1605,30 @@ discard block |
||
1605 | 1605 | } |
1606 | 1606 | $alldata = $pall; |
1607 | 1607 | foreach ($alldata as $number) { |
1608 | - 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']); |
|
1608 | + 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']); |
|
1609 | 1609 | } |
1610 | 1610 | $Spotter = new Spotter($this->db); |
1611 | 1611 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1612 | 1612 | $lastyear = false; |
1613 | 1613 | foreach ($alldata as $number) { |
1614 | 1614 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1615 | - $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']); |
|
1615 | + $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']); |
|
1616 | 1616 | } |
1617 | 1617 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1618 | 1618 | foreach ($alldata as $number) { |
1619 | - $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']); |
|
1619 | + $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']); |
|
1620 | 1620 | } |
1621 | 1621 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1622 | 1622 | foreach ($alldata as $number) { |
1623 | - $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']); |
|
1623 | + $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']); |
|
1624 | 1624 | } |
1625 | 1625 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1626 | 1626 | foreach ($alldata as $number) { |
1627 | - $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']); |
|
1627 | + $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']); |
|
1628 | 1628 | } |
1629 | 1629 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1630 | 1630 | foreach ($alldata as $number) { |
1631 | - $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']); |
|
1631 | + $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']); |
|
1632 | 1632 | } |
1633 | 1633 | echo '...Departure'."\n"; |
1634 | 1634 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | } |
1652 | 1652 | $alldata = $pall; |
1653 | 1653 | foreach ($alldata as $number) { |
1654 | - $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']); |
|
1654 | + $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']); |
|
1655 | 1655 | } |
1656 | 1656 | echo '...Arrival'."\n"; |
1657 | 1657 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1674,32 +1674,32 @@ discard block |
||
1674 | 1674 | } |
1675 | 1675 | $alldata = $pall; |
1676 | 1676 | foreach ($alldata as $number) { |
1677 | - $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']); |
|
1677 | + $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']); |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | echo 'Flights data...'."\n"; |
1681 | 1681 | echo '-> countAllDatesLastMonth...'."\n"; |
1682 | 1682 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1683 | 1683 | foreach ($alldata as $number) { |
1684 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1684 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1685 | 1685 | } |
1686 | 1686 | echo '-> countAllDates...'."\n"; |
1687 | 1687 | $previousdata = $this->countAllDatesByAirlines(); |
1688 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDatesByAirlines()); |
|
1688 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDatesByAirlines()); |
|
1689 | 1689 | $values = array(); |
1690 | 1690 | foreach ($alldata as $cnt) { |
1691 | 1691 | $values[] = $cnt['date_count']; |
1692 | 1692 | } |
1693 | - array_multisort($values,SORT_DESC,$alldata); |
|
1694 | - array_splice($alldata,11); |
|
1693 | + array_multisort($values, SORT_DESC, $alldata); |
|
1694 | + array_splice($alldata, 11); |
|
1695 | 1695 | foreach ($alldata as $number) { |
1696 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1696 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | echo '-> countAllHours...'."\n"; |
1700 | 1700 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1701 | 1701 | foreach ($alldata as $number) { |
1702 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1702 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | |
@@ -1710,29 +1710,29 @@ discard block |
||
1710 | 1710 | // Count by filter |
1711 | 1711 | echo '--- Stats by airlines ---'."\n"; |
1712 | 1712 | $Spotter = new Spotter($this->db); |
1713 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
1713 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
1714 | 1714 | foreach ($alldata as $number) { |
1715 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name); |
|
1715 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name); |
|
1716 | 1716 | } |
1717 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
1717 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
1718 | 1718 | foreach ($alldata as $number) { |
1719 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name); |
|
1719 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name); |
|
1720 | 1720 | } |
1721 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
1721 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
1722 | 1722 | foreach ($alldata as $number) { |
1723 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name); |
|
1723 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name); |
|
1724 | 1724 | } |
1725 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
1725 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
1726 | 1726 | foreach ($alldata as $number) { |
1727 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name); |
|
1727 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name); |
|
1728 | 1728 | } |
1729 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
1729 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
1730 | 1730 | foreach ($alldata as $number) { |
1731 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name); |
|
1731 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name); |
|
1732 | 1732 | } |
1733 | 1733 | |
1734 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
1735 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1734 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
1735 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
1736 | 1736 | //$alldata = array(); |
1737 | 1737 | foreach ($dall as $value) { |
1738 | 1738 | $icao = $value['airport_departure_icao']; |
@@ -1751,10 +1751,10 @@ discard block |
||
1751 | 1751 | } |
1752 | 1752 | $alldata = $pall; |
1753 | 1753 | foreach ($alldata as $number) { |
1754 | - 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); |
|
1754 | + 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); |
|
1755 | 1755 | } |
1756 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
|
1757 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1756 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter); |
|
1757 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter); |
|
1758 | 1758 | //$alldata = array(); |
1759 | 1759 | foreach ($dall as $value) { |
1760 | 1760 | $icao = $value['airport_arrival_icao']; |
@@ -1773,30 +1773,30 @@ discard block |
||
1773 | 1773 | } |
1774 | 1774 | $alldata = $pall; |
1775 | 1775 | foreach ($alldata as $number) { |
1776 | - 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); |
|
1776 | + 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); |
|
1777 | 1777 | } |
1778 | 1778 | $Spotter = new Spotter($this->db); |
1779 | 1779 | $alldata = $Spotter->countAllMonths($filter); |
1780 | 1780 | $lastyear = false; |
1781 | 1781 | foreach ($alldata as $number) { |
1782 | 1782 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1783 | - $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); |
|
1783 | + $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); |
|
1784 | 1784 | } |
1785 | 1785 | $alldata = $Spotter->countAllMonthsOwners($filter); |
1786 | 1786 | foreach ($alldata as $number) { |
1787 | - $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); |
|
1787 | + $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); |
|
1788 | 1788 | } |
1789 | 1789 | $alldata = $Spotter->countAllMonthsPilots($filter); |
1790 | 1790 | foreach ($alldata as $number) { |
1791 | - $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); |
|
1791 | + $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); |
|
1792 | 1792 | } |
1793 | 1793 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
1794 | 1794 | foreach ($alldata as $number) { |
1795 | - $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); |
|
1795 | + $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); |
|
1796 | 1796 | } |
1797 | 1797 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
1798 | 1798 | foreach ($alldata as $number) { |
1799 | - $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); |
|
1799 | + $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); |
|
1800 | 1800 | } |
1801 | 1801 | echo '...Departure'."\n"; |
1802 | 1802 | $pall = $Spotter->getLast7DaysAirportsDeparture($filter); |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | } |
1820 | 1820 | $alldata = $pall; |
1821 | 1821 | foreach ($alldata as $number) { |
1822 | - $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); |
|
1822 | + $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); |
|
1823 | 1823 | } |
1824 | 1824 | echo '...Arrival'."\n"; |
1825 | 1825 | $pall = $Spotter->getLast7DaysAirportsArrival($filter); |
@@ -1842,32 +1842,32 @@ discard block |
||
1842 | 1842 | } |
1843 | 1843 | $alldata = $pall; |
1844 | 1844 | foreach ($alldata as $number) { |
1845 | - $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); |
|
1845 | + $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); |
|
1846 | 1846 | } |
1847 | 1847 | |
1848 | 1848 | echo 'Flights data...'."\n"; |
1849 | 1849 | echo '-> countAllDatesLastMonth...'."\n"; |
1850 | 1850 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
1851 | 1851 | foreach ($alldata as $number) { |
1852 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
1852 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1853 | 1853 | } |
1854 | 1854 | echo '-> countAllDates...'."\n"; |
1855 | 1855 | $previousdata = $this->countAllDates($filter); |
1856 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
1856 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
1857 | 1857 | $values = array(); |
1858 | 1858 | foreach ($alldata as $cnt) { |
1859 | 1859 | $values[] = $cnt['date_count']; |
1860 | 1860 | } |
1861 | - array_multisort($values,SORT_DESC,$alldata); |
|
1862 | - array_splice($alldata,11); |
|
1861 | + array_multisort($values, SORT_DESC, $alldata); |
|
1862 | + array_splice($alldata, 11); |
|
1863 | 1863 | foreach ($alldata as $number) { |
1864 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
1864 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1865 | 1865 | } |
1866 | 1866 | |
1867 | 1867 | echo '-> countAllHours...'."\n"; |
1868 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
1868 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
1869 | 1869 | foreach ($alldata as $number) { |
1870 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
1870 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
1871 | 1871 | } |
1872 | 1872 | } |
1873 | 1873 | |
@@ -1878,16 +1878,16 @@ discard block |
||
1878 | 1878 | // SUM all previous month to put as year |
1879 | 1879 | $previous_year = date('Y'); |
1880 | 1880 | $previous_year--; |
1881 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1882 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1883 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1884 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1881 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1882 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1883 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1884 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1885 | 1885 | $allairlines = $this->getAllAirlineNames(); |
1886 | 1886 | foreach ($allairlines as $data) { |
1887 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1888 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1889 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1890 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1887 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1888 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1889 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1890 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | try { |
1897 | 1897 | $sth = $this->db->prepare($query); |
1898 | 1898 | $sth->execute(); |
1899 | - } catch(PDOException $e) { |
|
1899 | + } catch (PDOException $e) { |
|
1900 | 1900 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
1901 | 1901 | } |
1902 | 1902 | } |
@@ -1905,7 +1905,7 @@ discard block |
||
1905 | 1905 | try { |
1906 | 1906 | $sth = $this->db->prepare($query); |
1907 | 1907 | $sth->execute(); |
1908 | - } catch(PDOException $e) { |
|
1908 | + } catch (PDOException $e) { |
|
1909 | 1909 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
1910 | 1910 | } |
1911 | 1911 | } |
@@ -1927,7 +1927,7 @@ discard block |
||
1927 | 1927 | try { |
1928 | 1928 | $sth = $this->db->prepare($query); |
1929 | 1929 | $sth->execute(); |
1930 | - } catch(PDOException $e) { |
|
1930 | + } catch (PDOException $e) { |
|
1931 | 1931 | return "error : ".$e->getMessage(); |
1932 | 1932 | } |
1933 | 1933 | } |
@@ -1941,13 +1941,13 @@ discard block |
||
1941 | 1941 | try { |
1942 | 1942 | $sth = $this->db->prepare($query); |
1943 | 1943 | $sth->execute(); |
1944 | - } catch(PDOException $e) { |
|
1944 | + } catch (PDOException $e) { |
|
1945 | 1945 | return "error : ".$e->getMessage(); |
1946 | 1946 | } |
1947 | 1947 | } |
1948 | 1948 | echo 'Insert last stats update date...'."\n"; |
1949 | 1949 | date_default_timezone_set('UTC'); |
1950 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
1950 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
1951 | 1951 | //} |
1952 | 1952 | } |
1953 | 1953 | } |
@@ -73,8 +73,11 @@ discard block |
||
73 | 73 | |
74 | 74 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
75 | 75 | global $globalStatsFilters; |
76 | - 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"; |
|
77 | - 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"; |
|
76 | + if ($limit) { |
|
77 | + $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"; |
|
78 | + } else { |
|
79 | + $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"; |
|
80 | + } |
|
78 | 81 | try { |
79 | 82 | $sth = $this->db->prepare($query); |
80 | 83 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -94,8 +97,11 @@ discard block |
||
94 | 97 | } |
95 | 98 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
96 | 99 | global $globalStatsFilters; |
97 | - 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"; |
|
98 | - 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"; |
|
100 | + if ($limit) { |
|
101 | + $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"; |
|
102 | + } else { |
|
103 | + $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"; |
|
104 | + } |
|
99 | 105 | try { |
100 | 106 | $sth = $this->db->prepare($query); |
101 | 107 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -115,8 +121,11 @@ discard block |
||
115 | 121 | } |
116 | 122 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
117 | 123 | global $globalStatsFilters; |
118 | - 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"; |
|
119 | - 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"; |
|
124 | + if ($limit) { |
|
125 | + $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"; |
|
126 | + } else { |
|
127 | + $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"; |
|
128 | + } |
|
120 | 129 | try { |
121 | 130 | $sth = $this->db->prepare($query); |
122 | 131 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -137,8 +146,11 @@ discard block |
||
137 | 146 | |
138 | 147 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
139 | 148 | global $globalStatsFilters; |
140 | - 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"; |
|
141 | - 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"; |
|
149 | + if ($limit) { |
|
150 | + $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"; |
|
151 | + } else { |
|
152 | + $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"; |
|
153 | + } |
|
142 | 154 | try { |
143 | 155 | $sth = $this->db->prepare($query); |
144 | 156 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -158,8 +170,11 @@ discard block |
||
158 | 170 | } |
159 | 171 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
160 | 172 | global $globalStatsFilters; |
161 | - 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"; |
|
162 | - 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"; |
|
173 | + if ($limit) { |
|
174 | + $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"; |
|
175 | + } else { |
|
176 | + $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"; |
|
177 | + } |
|
163 | 178 | try { |
164 | 179 | $sth = $this->db->prepare($query); |
165 | 180 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -180,8 +195,11 @@ discard block |
||
180 | 195 | |
181 | 196 | public function countAllAirlines($limit = true,$filter_name = '') { |
182 | 197 | global $globalStatsFilters; |
183 | - 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"; |
|
184 | - 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"; |
|
198 | + if ($limit) { |
|
199 | + $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"; |
|
200 | + } else { |
|
201 | + $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"; |
|
202 | + } |
|
185 | 203 | try { |
186 | 204 | $sth = $this->db->prepare($query); |
187 | 205 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -202,8 +220,11 @@ discard block |
||
202 | 220 | } |
203 | 221 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
204 | 222 | global $globalStatsFilters; |
205 | - 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"; |
|
206 | - 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"; |
|
223 | + if ($limit) { |
|
224 | + $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"; |
|
225 | + } else { |
|
226 | + $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"; |
|
227 | + } |
|
207 | 228 | try { |
208 | 229 | $sth = $this->db->prepare($query); |
209 | 230 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -223,8 +244,11 @@ discard block |
||
223 | 244 | } |
224 | 245 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
225 | 246 | global $globalStatsFilters; |
226 | - 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"; |
|
227 | - 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"; |
|
247 | + if ($limit) { |
|
248 | + $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"; |
|
249 | + } else { |
|
250 | + $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"; |
|
251 | + } |
|
228 | 252 | try { |
229 | 253 | $sth = $this->db->prepare($query); |
230 | 254 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -245,8 +269,11 @@ discard block |
||
245 | 269 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
246 | 270 | $Connection = new Connection(); |
247 | 271 | if ($Connection->tableExists('countries')) { |
248 | - 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"; |
|
249 | - 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"; |
|
272 | + if ($limit) { |
|
273 | + $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"; |
|
274 | + } else { |
|
275 | + $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"; |
|
276 | + } |
|
250 | 277 | try { |
251 | 278 | $sth = $this->db->prepare($query); |
252 | 279 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -267,8 +294,11 @@ discard block |
||
267 | 294 | } |
268 | 295 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
269 | 296 | global $globalStatsFilters; |
270 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
271 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
297 | + if ($limit) { |
|
298 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
299 | + } else { |
|
300 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
301 | + } |
|
272 | 302 | try { |
273 | 303 | $sth = $this->db->prepare($query); |
274 | 304 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -288,8 +318,11 @@ discard block |
||
288 | 318 | } |
289 | 319 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
290 | 320 | global $globalStatsFilters; |
291 | - 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"; |
|
292 | - 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"; |
|
321 | + if ($limit) { |
|
322 | + $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"; |
|
323 | + } else { |
|
324 | + $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"; |
|
325 | + } |
|
293 | 326 | try { |
294 | 327 | $sth = $this->db->prepare($query); |
295 | 328 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -309,8 +342,11 @@ discard block |
||
309 | 342 | } |
310 | 343 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
311 | 344 | global $globalStatsFilters; |
312 | - 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
313 | - 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
345 | + if ($limit) { |
|
346 | + $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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
347 | + } else { |
|
348 | + $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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
349 | + } |
|
314 | 350 | try { |
315 | 351 | $sth = $this->db->prepare($query); |
316 | 352 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -336,7 +372,9 @@ discard block |
||
336 | 372 | $icao = $value['airport_departure_icao']; |
337 | 373 | if (isset($all[$icao])) { |
338 | 374 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
339 | - } else $all[$icao] = $value; |
|
375 | + } else { |
|
376 | + $all[$icao] = $value; |
|
377 | + } |
|
340 | 378 | } |
341 | 379 | $count = array(); |
342 | 380 | foreach ($all as $key => $row) { |
@@ -348,8 +386,11 @@ discard block |
||
348 | 386 | } |
349 | 387 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
350 | 388 | global $globalStatsFilters; |
351 | - 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
352 | - 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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
389 | + if ($limit) { |
|
390 | + $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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
391 | + } else { |
|
392 | + $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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
393 | + } |
|
353 | 394 | try { |
354 | 395 | $sth = $this->db->prepare($query); |
355 | 396 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -375,7 +416,9 @@ discard block |
||
375 | 416 | $icao = $value['airport_arrival_icao']; |
376 | 417 | if (isset($all[$icao])) { |
377 | 418 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
378 | - } else $all[$icao] = $value; |
|
419 | + } else { |
|
420 | + $all[$icao] = $value; |
|
421 | + } |
|
379 | 422 | } |
380 | 423 | $count = array(); |
381 | 424 | foreach ($all as $key => $row) { |
@@ -389,11 +432,17 @@ discard block |
||
389 | 432 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
390 | 433 | global $globalDBdriver, $globalStatsFilters; |
391 | 434 | if ($globalDBdriver == 'mysql') { |
392 | - 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"; |
|
393 | - 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"; |
|
435 | + if ($limit) { |
|
436 | + $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"; |
|
437 | + } else { |
|
438 | + $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"; |
|
439 | + } |
|
394 | 440 | } else { |
395 | - 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"; |
|
396 | - 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"; |
|
441 | + if ($limit) { |
|
442 | + $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"; |
|
443 | + } else { |
|
444 | + $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"; |
|
445 | + } |
|
397 | 446 | } |
398 | 447 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
399 | 448 | try { |
@@ -545,8 +594,11 @@ discard block |
||
545 | 594 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
546 | 595 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
547 | 596 | |
548 | - 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"; |
|
549 | - 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"; |
|
597 | + if ($limit) { |
|
598 | + $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"; |
|
599 | + } else { |
|
600 | + $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"; |
|
601 | + } |
|
550 | 602 | if ($orderby == 'hour') { |
551 | 603 | if ($globalDBdriver == 'mysql') { |
552 | 604 | $query .= " ORDER BY flight_date ASC"; |
@@ -554,7 +606,9 @@ discard block |
||
554 | 606 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
555 | 607 | } |
556 | 608 | } |
557 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
609 | + if ($orderby == 'count') { |
|
610 | + $query .= " ORDER BY hour_count DESC"; |
|
611 | + } |
|
558 | 612 | try { |
559 | 613 | $sth = $this->db->prepare($query); |
560 | 614 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -1308,7 +1362,9 @@ discard block |
||
1308 | 1362 | echo 'Update stats !'."\n"; |
1309 | 1363 | if (isset($last_update[0]['value'])) { |
1310 | 1364 | $last_update_day = $last_update[0]['value']; |
1311 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1365 | + } else { |
|
1366 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1367 | + } |
|
1312 | 1368 | $Spotter = new Spotter($this->db); |
1313 | 1369 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1314 | 1370 | foreach ($alldata as $number) { |
@@ -1347,7 +1403,9 @@ discard block |
||
1347 | 1403 | $icao = $value['airport_departure_icao']; |
1348 | 1404 | if (isset($alldata[$icao])) { |
1349 | 1405 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1350 | - } else $alldata[$icao] = $value; |
|
1406 | + } else { |
|
1407 | + $alldata[$icao] = $value; |
|
1408 | + } |
|
1351 | 1409 | } |
1352 | 1410 | $count = array(); |
1353 | 1411 | foreach ($alldata as $key => $row) { |
@@ -1368,7 +1426,9 @@ discard block |
||
1368 | 1426 | $icao = $value['airport_arrival_icao']; |
1369 | 1427 | if (isset($alldata[$icao])) { |
1370 | 1428 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1371 | - } else $alldata[$icao] = $value; |
|
1429 | + } else { |
|
1430 | + $alldata[$icao] = $value; |
|
1431 | + } |
|
1372 | 1432 | } |
1373 | 1433 | $count = array(); |
1374 | 1434 | foreach ($alldata as $key => $row) { |
@@ -1394,7 +1454,9 @@ discard block |
||
1394 | 1454 | $alldata = $Spotter->countAllMonths(); |
1395 | 1455 | $lastyear = false; |
1396 | 1456 | foreach ($alldata as $number) { |
1397 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1457 | + if ($number['year_name'] != date('Y')) { |
|
1458 | + $lastyear = true; |
|
1459 | + } |
|
1398 | 1460 | $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']))); |
1399 | 1461 | } |
1400 | 1462 | $alldata = $Spotter->countAllMilitaryMonths(); |
@@ -1611,7 +1673,9 @@ discard block |
||
1611 | 1673 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1612 | 1674 | $lastyear = false; |
1613 | 1675 | foreach ($alldata as $number) { |
1614 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1676 | + if ($number['year_name'] != date('Y')) { |
|
1677 | + $lastyear = true; |
|
1678 | + } |
|
1615 | 1679 | $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']); |
1616 | 1680 | } |
1617 | 1681 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
@@ -1703,7 +1767,9 @@ discard block |
||
1703 | 1767 | } |
1704 | 1768 | |
1705 | 1769 | |
1706 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
1770 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
1771 | + $globalStatsFilters = array(); |
|
1772 | + } |
|
1707 | 1773 | foreach ($globalStatsFilters as $name => $filter) { |
1708 | 1774 | //$filter_name = $filter['name']; |
1709 | 1775 | $filter_name = $name; |
@@ -1779,7 +1845,9 @@ discard block |
||
1779 | 1845 | $alldata = $Spotter->countAllMonths($filter); |
1780 | 1846 | $lastyear = false; |
1781 | 1847 | foreach ($alldata as $number) { |
1782 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1848 | + if ($number['year_name'] != date('Y')) { |
|
1849 | + $lastyear = true; |
|
1850 | + } |
|
1783 | 1851 | $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); |
1784 | 1852 | } |
1785 | 1853 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -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; |
@@ -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; |
21 | 21 | if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | - * Gets all the spotter information based on the latest data entry |
|
54 | - * |
|
55 | - * @return Array the spotter information |
|
56 | - * |
|
57 | - */ |
|
53 | + * Gets all the spotter information based on the latest data entry |
|
54 | + * |
|
55 | + * @return Array the spotter information |
|
56 | + * |
|
57 | + */ |
|
58 | 58 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
59 | 59 | { |
60 | 60 | global $globalDBdriver, $globalLiveInterval; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | - * Gets Minimal Live Spotter data |
|
97 | - * |
|
98 | - * @return Array the spotter information |
|
99 | - * |
|
100 | - */ |
|
96 | + * Gets Minimal Live Spotter data |
|
97 | + * |
|
98 | + * @return Array the spotter information |
|
99 | + * |
|
100 | + */ |
|
101 | 101 | public function getMinLiveSpotterData($filter = array()) |
102 | 102 | { |
103 | 103 | global $globalDBdriver, $globalLiveInterval; |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * Gets Minimal Live Spotter data since xx seconds |
|
146 | - * |
|
147 | - * @return Array the spotter information |
|
148 | - * |
|
149 | - */ |
|
145 | + * Gets Minimal Live Spotter data since xx seconds |
|
146 | + * |
|
147 | + * @return Array the spotter information |
|
148 | + * |
|
149 | + */ |
|
150 | 150 | public function getMinLastLiveSpotterData($filter = array()) |
151 | 151 | { |
152 | 152 | global $globalDBdriver, $globalLiveInterval; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $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 |
161 | 161 | 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 |
162 | 162 | ORDER BY spotter_live.flightaware_id, spotter_live.date'; |
163 | - } else { |
|
163 | + } else { |
|
164 | 164 | /* |
165 | 165 | $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 |
166 | 166 | FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // echo $query; |
173 | 173 | } |
174 | 174 | |
175 | - try { |
|
175 | + try { |
|
176 | 176 | $sth = $this->db->prepare($query); |
177 | 177 | $sth->execute(); |
178 | 178 | } catch(PDOException $e) { |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | - * Gets number of latest data entry |
|
188 | - * |
|
189 | - * @return String number of entry |
|
190 | - * |
|
191 | - */ |
|
187 | + * Gets number of latest data entry |
|
188 | + * |
|
189 | + * @return String number of entry |
|
190 | + * |
|
191 | + */ |
|
192 | 192 | public function getLiveSpotterCount($filter = array()) |
193 | 193 | { |
194 | 194 | global $globalDBdriver, $globalLiveInterval; |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
217 | - * Gets all the spotter information based on the latest data entry and coord |
|
218 | - * |
|
219 | - * @return Array the spotter information |
|
220 | - * |
|
221 | - */ |
|
217 | + * Gets all the spotter information based on the latest data entry and coord |
|
218 | + * |
|
219 | + * @return Array the spotter information |
|
220 | + * |
|
221 | + */ |
|
222 | 222 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
223 | 223 | { |
224 | 224 | global $globalDBdriver, $globalLiveInterval; |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * Gets all the spotter information based on a user's latitude and longitude |
|
247 | - * |
|
248 | - * @return Array the spotter information |
|
249 | - * |
|
250 | - */ |
|
246 | + * Gets all the spotter information based on a user's latitude and longitude |
|
247 | + * |
|
248 | + * @return Array the spotter information |
|
249 | + * |
|
250 | + */ |
|
251 | 251 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
252 | 252 | { |
253 | 253 | $Spotter = new Spotter($this->db); |
@@ -257,145 +257,145 @@ discard block |
||
257 | 257 | return false; |
258 | 258 | } |
259 | 259 | } |
260 | - if ($lng != '') |
|
261 | - { |
|
262 | - if (!is_numeric($lng)) |
|
263 | - { |
|
264 | - return false; |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - if ($radius != '') |
|
269 | - { |
|
270 | - if (!is_numeric($radius)) |
|
271 | - { |
|
272 | - return false; |
|
273 | - } |
|
274 | - } |
|
260 | + if ($lng != '') |
|
261 | + { |
|
262 | + if (!is_numeric($lng)) |
|
263 | + { |
|
264 | + return false; |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + if ($radius != '') |
|
269 | + { |
|
270 | + if (!is_numeric($radius)) |
|
271 | + { |
|
272 | + return false; |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $additional_query = ''; |
276 | - if ($interval != '') |
|
277 | - { |
|
278 | - if (!is_string($interval)) |
|
279 | - { |
|
280 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
281 | - return false; |
|
282 | - } else { |
|
283 | - if ($interval == '1m') |
|
284 | - { |
|
285 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
286 | - } else if ($interval == '15m'){ |
|
287 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
288 | - } |
|
289 | - } |
|
290 | - } else { |
|
291 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
292 | - } |
|
293 | - |
|
294 | - $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 |
|
276 | + if ($interval != '') |
|
277 | + { |
|
278 | + if (!is_string($interval)) |
|
279 | + { |
|
280 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
281 | + return false; |
|
282 | + } else { |
|
283 | + if ($interval == '1m') |
|
284 | + { |
|
285 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
286 | + } else if ($interval == '15m'){ |
|
287 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
288 | + } |
|
289 | + } |
|
290 | + } else { |
|
291 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
292 | + } |
|
293 | + |
|
294 | + $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 |
|
295 | 295 | WHERE spotter_live.latitude <> '' |
296 | 296 | AND spotter_live.longitude <> '' |
297 | 297 | ".$additional_query." |
298 | 298 | HAVING distance < :radius |
299 | 299 | ORDER BY distance"; |
300 | 300 | |
301 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
301 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
302 | 302 | |
303 | - return $spotter_array; |
|
304 | - } |
|
303 | + return $spotter_array; |
|
304 | + } |
|
305 | 305 | |
306 | 306 | |
307 | - /** |
|
308 | - * Gets all the spotter information based on a particular callsign |
|
309 | - * |
|
310 | - * @return Array the spotter information |
|
311 | - * |
|
312 | - */ |
|
307 | + /** |
|
308 | + * Gets all the spotter information based on a particular callsign |
|
309 | + * |
|
310 | + * @return Array the spotter information |
|
311 | + * |
|
312 | + */ |
|
313 | 313 | public function getLastLiveSpotterDataByIdent($ident) |
314 | 314 | { |
315 | 315 | $Spotter = new Spotter($this->db); |
316 | 316 | date_default_timezone_set('UTC'); |
317 | 317 | |
318 | 318 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
319 | - $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'; |
|
319 | + $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'; |
|
320 | 320 | |
321 | 321 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
322 | 322 | |
323 | 323 | return $spotter_array; |
324 | 324 | } |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the spotter information based on a particular callsign |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
326 | + /** |
|
327 | + * Gets all the spotter information based on a particular callsign |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getDateLiveSpotterDataByIdent($ident,$date) |
333 | 333 | { |
334 | 334 | $Spotter = new Spotter($this->db); |
335 | 335 | date_default_timezone_set('UTC'); |
336 | 336 | |
337 | 337 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
338 | - $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'; |
|
338 | + $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'; |
|
339 | 339 | |
340 | - $date = date('c',$date); |
|
340 | + $date = date('c',$date); |
|
341 | 341 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
342 | 342 | |
343 | 343 | return $spotter_array; |
344 | 344 | } |
345 | 345 | |
346 | - /** |
|
347 | - * Gets last spotter information based on a particular callsign |
|
348 | - * |
|
349 | - * @return Array the spotter information |
|
350 | - * |
|
351 | - */ |
|
346 | + /** |
|
347 | + * Gets last spotter information based on a particular callsign |
|
348 | + * |
|
349 | + * @return Array the spotter information |
|
350 | + * |
|
351 | + */ |
|
352 | 352 | public function getLastLiveSpotterDataById($id) |
353 | 353 | { |
354 | 354 | $Spotter = new Spotter($this->db); |
355 | 355 | date_default_timezone_set('UTC'); |
356 | 356 | |
357 | 357 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
358 | - $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'; |
|
358 | + $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'; |
|
359 | 359 | |
360 | 360 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
361 | 361 | |
362 | 362 | return $spotter_array; |
363 | 363 | } |
364 | 364 | |
365 | - /** |
|
366 | - * Gets last spotter information based on a particular callsign |
|
367 | - * |
|
368 | - * @return Array the spotter information |
|
369 | - * |
|
370 | - */ |
|
365 | + /** |
|
366 | + * Gets last spotter information based on a particular callsign |
|
367 | + * |
|
368 | + * @return Array the spotter information |
|
369 | + * |
|
370 | + */ |
|
371 | 371 | public function getDateLiveSpotterDataById($id,$date) |
372 | 372 | { |
373 | 373 | $Spotter = new Spotter($this->db); |
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | |
376 | 376 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
377 | - $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'; |
|
378 | - $date = date('c',$date); |
|
377 | + $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'; |
|
378 | + $date = date('c',$date); |
|
379 | 379 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
380 | 380 | |
381 | 381 | return $spotter_array; |
382 | 382 | } |
383 | 383 | |
384 | - /** |
|
385 | - * Gets altitude information based on a particular callsign |
|
386 | - * |
|
387 | - * @return Array the spotter information |
|
388 | - * |
|
389 | - */ |
|
384 | + /** |
|
385 | + * Gets altitude information based on a particular callsign |
|
386 | + * |
|
387 | + * @return Array the spotter information |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getAltitudeLiveSpotterDataByIdent($ident) |
391 | 391 | { |
392 | 392 | |
393 | 393 | date_default_timezone_set('UTC'); |
394 | 394 | |
395 | 395 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
396 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
396 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
397 | 397 | |
398 | - try { |
|
398 | + try { |
|
399 | 399 | |
400 | 400 | $sth = $this->db->prepare($query); |
401 | 401 | $sth->execute(array(':ident' => $ident)); |
@@ -408,12 +408,12 @@ discard block |
||
408 | 408 | return $spotter_array; |
409 | 409 | } |
410 | 410 | |
411 | - /** |
|
412 | - * Gets all the spotter information based on a particular id |
|
413 | - * |
|
414 | - * @return Array the spotter information |
|
415 | - * |
|
416 | - */ |
|
411 | + /** |
|
412 | + * Gets all the spotter information based on a particular id |
|
413 | + * |
|
414 | + * @return Array the spotter information |
|
415 | + * |
|
416 | + */ |
|
417 | 417 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
418 | 418 | { |
419 | 419 | global $globalDBdriver, $globalLiveInterval; |
@@ -441,18 +441,18 @@ discard block |
||
441 | 441 | return $spotter_array; |
442 | 442 | } |
443 | 443 | |
444 | - /** |
|
445 | - * Gets all the spotter information based on a particular ident |
|
446 | - * |
|
447 | - * @return Array the spotter information |
|
448 | - * |
|
449 | - */ |
|
444 | + /** |
|
445 | + * Gets all the spotter information based on a particular ident |
|
446 | + * |
|
447 | + * @return Array the spotter information |
|
448 | + * |
|
449 | + */ |
|
450 | 450 | public function getAllLiveSpotterDataByIdent($ident) |
451 | 451 | { |
452 | 452 | date_default_timezone_set('UTC'); |
453 | 453 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
454 | 454 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
455 | - try { |
|
455 | + try { |
|
456 | 456 | |
457 | 457 | $sth = $this->db->prepare($query); |
458 | 458 | $sth->execute(array(':ident' => $ident)); |
@@ -466,23 +466,23 @@ discard block |
||
466 | 466 | |
467 | 467 | |
468 | 468 | /** |
469 | - * Deletes all info in the table |
|
470 | - * |
|
471 | - * @return String success or false |
|
472 | - * |
|
473 | - */ |
|
469 | + * Deletes all info in the table |
|
470 | + * |
|
471 | + * @return String success or false |
|
472 | + * |
|
473 | + */ |
|
474 | 474 | public function deleteLiveSpotterData() |
475 | 475 | { |
476 | 476 | global $globalDBdriver; |
477 | 477 | if ($globalDBdriver == 'mysql') { |
478 | 478 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
479 | 479 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
480 | - //$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)"; |
|
480 | + //$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)"; |
|
481 | 481 | } else { |
482 | 482 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
483 | 483 | } |
484 | 484 | |
485 | - try { |
|
485 | + try { |
|
486 | 486 | |
487 | 487 | $sth = $this->db->prepare($query); |
488 | 488 | $sth->execute(); |
@@ -494,18 +494,18 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
497 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
498 | - * |
|
499 | - * @return String success or false |
|
500 | - * |
|
501 | - */ |
|
497 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
498 | + * |
|
499 | + * @return String success or false |
|
500 | + * |
|
501 | + */ |
|
502 | 502 | public function deleteLiveSpotterDataNotUpdated() |
503 | 503 | { |
504 | 504 | global $globalDBdriver, $globalDebug; |
505 | 505 | if ($globalDBdriver == 'mysql') { |
506 | 506 | //$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'; |
507 | - $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"; |
|
508 | - try { |
|
507 | + $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"; |
|
508 | + try { |
|
509 | 509 | |
510 | 510 | $sth = $this->db->prepare($query); |
511 | 511 | $sth->execute(); |
@@ -513,8 +513,8 @@ discard block |
||
513 | 513 | return "error"; |
514 | 514 | } |
515 | 515 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
516 | - $i = 0; |
|
517 | - $j =0; |
|
516 | + $i = 0; |
|
517 | + $j =0; |
|
518 | 518 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
519 | 519 | foreach($all as $row) |
520 | 520 | { |
@@ -522,20 +522,20 @@ discard block |
||
522 | 522 | $j++; |
523 | 523 | if ($j == 30) { |
524 | 524 | if ($globalDebug) echo "."; |
525 | - try { |
|
525 | + try { |
|
526 | 526 | |
527 | 527 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
528 | 528 | $sth->execute(); |
529 | 529 | } catch(PDOException $e) { |
530 | 530 | return "error"; |
531 | 531 | } |
532 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
533 | - $j = 0; |
|
532 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
533 | + $j = 0; |
|
534 | 534 | } |
535 | 535 | $query_delete .= "'".$row['flightaware_id']."',"; |
536 | 536 | } |
537 | 537 | if ($i > 0) { |
538 | - try { |
|
538 | + try { |
|
539 | 539 | |
540 | 540 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
541 | 541 | $sth->execute(); |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | return "success"; |
547 | 547 | } elseif ($globalDBdriver == 'pgsql') { |
548 | 548 | //$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"; |
549 | - //$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"; |
|
550 | - $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)"; |
|
551 | - try { |
|
549 | + //$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"; |
|
550 | + $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)"; |
|
551 | + try { |
|
552 | 552 | |
553 | 553 | $sth = $this->db->prepare($query); |
554 | 554 | $sth->execute(); |
@@ -592,17 +592,17 @@ discard block |
||
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
595 | - * Deletes all info in the table for an ident |
|
596 | - * |
|
597 | - * @return String success or false |
|
598 | - * |
|
599 | - */ |
|
595 | + * Deletes all info in the table for an ident |
|
596 | + * |
|
597 | + * @return String success or false |
|
598 | + * |
|
599 | + */ |
|
600 | 600 | public function deleteLiveSpotterDataByIdent($ident) |
601 | 601 | { |
602 | 602 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
603 | 603 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
604 | 604 | |
605 | - try { |
|
605 | + try { |
|
606 | 606 | |
607 | 607 | $sth = $this->db->prepare($query); |
608 | 608 | $sth->execute(array(':ident' => $ident)); |
@@ -614,17 +614,17 @@ discard block |
||
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
617 | - * Deletes all info in the table for an id |
|
618 | - * |
|
619 | - * @return String success or false |
|
620 | - * |
|
621 | - */ |
|
617 | + * Deletes all info in the table for an id |
|
618 | + * |
|
619 | + * @return String success or false |
|
620 | + * |
|
621 | + */ |
|
622 | 622 | public function deleteLiveSpotterDataById($id) |
623 | 623 | { |
624 | 624 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
625 | 625 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
626 | 626 | |
627 | - try { |
|
627 | + try { |
|
628 | 628 | |
629 | 629 | $sth = $this->db->prepare($query); |
630 | 630 | $sth->execute(array(':id' => $id)); |
@@ -637,11 +637,11 @@ discard block |
||
637 | 637 | |
638 | 638 | |
639 | 639 | /** |
640 | - * Gets the aircraft ident within the last hour |
|
641 | - * |
|
642 | - * @return String the ident |
|
643 | - * |
|
644 | - */ |
|
640 | + * Gets the aircraft ident within the last hour |
|
641 | + * |
|
642 | + * @return String the ident |
|
643 | + * |
|
644 | + */ |
|
645 | 645 | public function getIdentFromLastHour($ident) |
646 | 646 | { |
647 | 647 | global $globalDBdriver, $globalTimezone; |
@@ -667,14 +667,14 @@ discard block |
||
667 | 667 | $ident_result = $row['ident']; |
668 | 668 | } |
669 | 669 | return $ident_result; |
670 | - } |
|
670 | + } |
|
671 | 671 | |
672 | 672 | /** |
673 | - * Check recent aircraft |
|
674 | - * |
|
675 | - * @return String the ident |
|
676 | - * |
|
677 | - */ |
|
673 | + * Check recent aircraft |
|
674 | + * |
|
675 | + * @return String the ident |
|
676 | + * |
|
677 | + */ |
|
678 | 678 | public function checkIdentRecent($ident) |
679 | 679 | { |
680 | 680 | global $globalDBdriver, $globalTimezone; |
@@ -700,14 +700,14 @@ discard block |
||
700 | 700 | $ident_result = $row['flightaware_id']; |
701 | 701 | } |
702 | 702 | return $ident_result; |
703 | - } |
|
703 | + } |
|
704 | 704 | |
705 | 705 | /** |
706 | - * Check recent aircraft by id |
|
707 | - * |
|
708 | - * @return String the ident |
|
709 | - * |
|
710 | - */ |
|
706 | + * Check recent aircraft by id |
|
707 | + * |
|
708 | + * @return String the ident |
|
709 | + * |
|
710 | + */ |
|
711 | 711 | public function checkIdRecent($id) |
712 | 712 | { |
713 | 713 | global $globalDBdriver, $globalTimezone; |
@@ -733,14 +733,14 @@ discard block |
||
733 | 733 | $ident_result = $row['flightaware_id']; |
734 | 734 | } |
735 | 735 | return $ident_result; |
736 | - } |
|
736 | + } |
|
737 | 737 | |
738 | 738 | /** |
739 | - * Check recent aircraft by ModeS |
|
740 | - * |
|
741 | - * @return String the ModeS |
|
742 | - * |
|
743 | - */ |
|
739 | + * Check recent aircraft by ModeS |
|
740 | + * |
|
741 | + * @return String the ModeS |
|
742 | + * |
|
743 | + */ |
|
744 | 744 | public function checkModeSRecent($modes) |
745 | 745 | { |
746 | 746 | global $globalDBdriver, $globalTimezone; |
@@ -767,19 +767,19 @@ discard block |
||
767 | 767 | $ident_result = $row['flightaware_id']; |
768 | 768 | } |
769 | 769 | return $ident_result; |
770 | - } |
|
770 | + } |
|
771 | 771 | |
772 | 772 | /** |
773 | - * Adds a new spotter data |
|
774 | - * |
|
775 | - * @param String $flightaware_id the ID from flightaware |
|
776 | - * @param String $ident the flight ident |
|
777 | - * @param String $aircraft_icao the aircraft type |
|
778 | - * @param String $departure_airport_icao the departure airport |
|
779 | - * @param String $arrival_airport_icao the arrival airport |
|
780 | - * @return String success or false |
|
781 | - * |
|
782 | - */ |
|
773 | + * Adds a new spotter data |
|
774 | + * |
|
775 | + * @param String $flightaware_id the ID from flightaware |
|
776 | + * @param String $ident the flight ident |
|
777 | + * @param String $aircraft_icao the aircraft type |
|
778 | + * @param String $departure_airport_icao the departure airport |
|
779 | + * @param String $arrival_airport_icao the arrival airport |
|
780 | + * @return String success or false |
|
781 | + * |
|
782 | + */ |
|
783 | 783 | 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 = '') |
784 | 784 | { |
785 | 785 | global $globalURL, $globalArchive, $globalDebug; |
@@ -915,10 +915,10 @@ discard block |
||
915 | 915 | $arrival_airport_country = ''; |
916 | 916 | |
917 | 917 | |
918 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
919 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
920 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
921 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
918 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
919 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
920 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
921 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
922 | 922 | |
923 | 923 | $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) |
924 | 924 | 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)'; |
@@ -929,13 +929,13 @@ discard block |
||
929 | 929 | |
930 | 930 | $sth = $this->db->prepare($query); |
931 | 931 | $sth->execute($query_values); |
932 | - } catch(PDOException $e) { |
|
933 | - return "error : ".$e->getMessage(); |
|
934 | - } |
|
932 | + } catch(PDOException $e) { |
|
933 | + return "error : ".$e->getMessage(); |
|
934 | + } |
|
935 | 935 | if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) { |
936 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
937 | - $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); |
|
938 | - if ($globalDebug) echo $result.')'; |
|
936 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
937 | + $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); |
|
938 | + if ($globalDebug) echo $result.')'; |
|
939 | 939 | } |
940 | 940 | return "success"; |
941 | 941 |
@@ -16,14 +16,14 @@ 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; |
21 | - if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
21 | + if (is_array($globalFilter)) $filter = array_merge($globalFilter, $filter); |
|
22 | 22 | $filter_query_join = ''; |
23 | 23 | $filter_query_where = ''; |
24 | 24 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
25 | 25 | if ($filter['airlines'][0] != '') { |
26 | - $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_output.flightaware_id"; |
|
26 | + $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_output.flightaware_id"; |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id "; |
32 | 32 | } |
33 | 33 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
34 | - $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_output.flightaware_id"; |
|
34 | + $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_output.flightaware_id"; |
|
35 | 35 | } |
36 | 36 | if (isset($filter['source']) && !empty($filter['source'])) { |
37 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
37 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
38 | 38 | } |
39 | 39 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
40 | 40 | if ($filter_query_where == '') { |
41 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
41 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
42 | 42 | } else { |
43 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
43 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if ($limit != '') |
67 | 67 | { |
68 | 68 | $limit_array = explode(',', $limit); |
69 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
70 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
69 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
70 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
71 | 71 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
72 | 72 | { |
73 | 73 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // $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'; |
112 | 112 | // $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 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; |
113 | 113 | |
114 | - $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 |
|
114 | + $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 |
|
115 | 115 | FROM spotter_live |
116 | 116 | 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.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'; |
117 | 117 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
123 | 123 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
124 | 124 | //$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 '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
125 | - $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 |
|
125 | + $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 |
|
126 | 126 | FROM spotter_live |
127 | 127 | 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.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'; |
128 | 128 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | try { |
133 | 133 | $sth = $this->db->prepare($query); |
134 | 134 | $sth->execute(); |
135 | - } catch(PDOException $e) { |
|
135 | + } catch (PDOException $e) { |
|
136 | 136 | echo $e->getMessage(); |
137 | 137 | die; |
138 | 138 | } |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | global $globalDBdriver, $globalLiveInterval; |
153 | 153 | date_default_timezone_set('UTC'); |
154 | 154 | |
155 | - $filter_query = $this->getFilter($filter,true,true); |
|
155 | + $filter_query = $this->getFilter($filter, true, true); |
|
156 | 156 | |
157 | 157 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
158 | 158 | if ($globalDBdriver == 'mysql') { |
159 | 159 | |
160 | - $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 |
|
160 | + $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 |
|
161 | 161 | 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 |
162 | 162 | ORDER BY spotter_live.flightaware_id, spotter_live.date'; |
163 | 163 | } else { |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
167 | 167 | ".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao ORDER BY spotter_live.flightaware_id, spotter_live.date'; |
168 | 168 | */ |
169 | - $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 |
|
169 | + $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 |
|
170 | 170 | 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 |
171 | 171 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
172 | 172 | // echo $query; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | try { |
176 | 176 | $sth = $this->db->prepare($query); |
177 | 177 | $sth->execute(); |
178 | - } catch(PDOException $e) { |
|
178 | + } catch (PDOException $e) { |
|
179 | 179 | echo $e->getMessage(); |
180 | 180 | die; |
181 | 181 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | try { |
206 | 206 | $sth = $this->db->prepare($query); |
207 | 207 | $sth->execute(); |
208 | - } catch(PDOException $e) { |
|
208 | + } catch (PDOException $e) { |
|
209 | 209 | echo $e->getMessage(); |
210 | 210 | die; |
211 | 211 | } |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | $filter_query = $this->getFilter($filter); |
228 | 228 | |
229 | 229 | if (is_array($coord)) { |
230 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
231 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
232 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
233 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
230 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
231 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
232 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
233 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
234 | 234 | } else return array(); |
235 | 235 | if ($globalDBdriver == 'mysql') { |
236 | 236 | //$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.")"; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | if ($interval == '1m') |
284 | 284 | { |
285 | 285 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
286 | - } else if ($interval == '15m'){ |
|
286 | + } else if ($interval == '15m') { |
|
287 | 287 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
288 | 288 | } |
289 | 289 | } |
@@ -291,14 +291,14 @@ discard block |
||
291 | 291 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
292 | 292 | } |
293 | 293 | |
294 | - $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 |
|
294 | + $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 |
|
295 | 295 | WHERE spotter_live.latitude <> '' |
296 | 296 | AND spotter_live.longitude <> '' |
297 | 297 | ".$additional_query." |
298 | 298 | HAVING distance < :radius |
299 | 299 | ORDER BY distance"; |
300 | 300 | |
301 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
301 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
302 | 302 | |
303 | 303 | return $spotter_array; |
304 | 304 | } |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | date_default_timezone_set('UTC'); |
317 | 317 | |
318 | 318 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
319 | - $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'; |
|
319 | + $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'; |
|
320 | 320 | |
321 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
321 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
322 | 322 | |
323 | 323 | return $spotter_array; |
324 | 324 | } |
@@ -329,16 +329,16 @@ discard block |
||
329 | 329 | * @return Array the spotter information |
330 | 330 | * |
331 | 331 | */ |
332 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
332 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
333 | 333 | { |
334 | 334 | $Spotter = new Spotter($this->db); |
335 | 335 | date_default_timezone_set('UTC'); |
336 | 336 | |
337 | 337 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
338 | - $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'; |
|
338 | + $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'; |
|
339 | 339 | |
340 | - $date = date('c',$date); |
|
341 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
340 | + $date = date('c', $date); |
|
341 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
342 | 342 | |
343 | 343 | return $spotter_array; |
344 | 344 | } |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | date_default_timezone_set('UTC'); |
356 | 356 | |
357 | 357 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
358 | - $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'; |
|
358 | + $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'; |
|
359 | 359 | |
360 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
360 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
361 | 361 | |
362 | 362 | return $spotter_array; |
363 | 363 | } |
@@ -368,15 +368,15 @@ discard block |
||
368 | 368 | * @return Array the spotter information |
369 | 369 | * |
370 | 370 | */ |
371 | - public function getDateLiveSpotterDataById($id,$date) |
|
371 | + public function getDateLiveSpotterDataById($id, $date) |
|
372 | 372 | { |
373 | 373 | $Spotter = new Spotter($this->db); |
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | |
376 | 376 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
377 | - $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'; |
|
378 | - $date = date('c',$date); |
|
379 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
377 | + $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'; |
|
378 | + $date = date('c', $date); |
|
379 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
380 | 380 | |
381 | 381 | return $spotter_array; |
382 | 382 | } |
@@ -393,13 +393,13 @@ discard block |
||
393 | 393 | date_default_timezone_set('UTC'); |
394 | 394 | |
395 | 395 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
396 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
396 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
397 | 397 | |
398 | 398 | try { |
399 | 399 | |
400 | 400 | $sth = $this->db->prepare($query); |
401 | 401 | $sth->execute(array(':ident' => $ident)); |
402 | - } catch(PDOException $e) { |
|
402 | + } catch (PDOException $e) { |
|
403 | 403 | echo $e->getMessage(); |
404 | 404 | die; |
405 | 405 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @return Array the spotter information |
415 | 415 | * |
416 | 416 | */ |
417 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
417 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
418 | 418 | { |
419 | 419 | global $globalDBdriver, $globalLiveInterval; |
420 | 420 | date_default_timezone_set('UTC'); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | try { |
434 | 434 | $sth = $this->db->prepare($query); |
435 | 435 | $sth->execute(array(':id' => $id)); |
436 | - } catch(PDOException $e) { |
|
436 | + } catch (PDOException $e) { |
|
437 | 437 | echo $e->getMessage(); |
438 | 438 | die; |
439 | 439 | } |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | { |
452 | 452 | date_default_timezone_set('UTC'); |
453 | 453 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
454 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
454 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
455 | 455 | try { |
456 | 456 | |
457 | 457 | $sth = $this->db->prepare($query); |
458 | 458 | $sth->execute(array(':ident' => $ident)); |
459 | - } catch(PDOException $e) { |
|
459 | + } catch (PDOException $e) { |
|
460 | 460 | echo $e->getMessage(); |
461 | 461 | die; |
462 | 462 | } |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | $sth = $this->db->prepare($query); |
488 | 488 | $sth->execute(); |
489 | - } catch(PDOException $e) { |
|
489 | + } catch (PDOException $e) { |
|
490 | 490 | return "error"; |
491 | 491 | } |
492 | 492 | |
@@ -509,14 +509,14 @@ discard block |
||
509 | 509 | |
510 | 510 | $sth = $this->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error"; |
514 | 514 | } |
515 | 515 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
516 | 516 | $i = 0; |
517 | - $j =0; |
|
517 | + $j = 0; |
|
518 | 518 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
519 | - foreach($all as $row) |
|
519 | + foreach ($all as $row) |
|
520 | 520 | { |
521 | 521 | $i++; |
522 | 522 | $j++; |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | if ($globalDebug) echo "."; |
525 | 525 | try { |
526 | 526 | |
527 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
527 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
528 | 528 | $sth->execute(); |
529 | - } catch(PDOException $e) { |
|
529 | + } catch (PDOException $e) { |
|
530 | 530 | return "error"; |
531 | 531 | } |
532 | 532 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | if ($i > 0) { |
538 | 538 | try { |
539 | 539 | |
540 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
540 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
541 | 541 | $sth->execute(); |
542 | - } catch(PDOException $e) { |
|
542 | + } catch (PDOException $e) { |
|
543 | 543 | return "error"; |
544 | 544 | } |
545 | 545 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $sth = $this->db->prepare($query); |
554 | 554 | $sth->execute(); |
555 | - } catch(PDOException $e) { |
|
555 | + } catch (PDOException $e) { |
|
556 | 556 | return "error"; |
557 | 557 | } |
558 | 558 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -600,13 +600,13 @@ discard block |
||
600 | 600 | public function deleteLiveSpotterDataByIdent($ident) |
601 | 601 | { |
602 | 602 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
603 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
603 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
604 | 604 | |
605 | 605 | try { |
606 | 606 | |
607 | 607 | $sth = $this->db->prepare($query); |
608 | 608 | $sth->execute(array(':ident' => $ident)); |
609 | - } catch(PDOException $e) { |
|
609 | + } catch (PDOException $e) { |
|
610 | 610 | return "error"; |
611 | 611 | } |
612 | 612 | |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | public function deleteLiveSpotterDataById($id) |
623 | 623 | { |
624 | 624 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
625 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
625 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
626 | 626 | |
627 | 627 | try { |
628 | 628 | |
629 | 629 | $sth = $this->db->prepare($query); |
630 | 630 | $sth->execute(array(':id' => $id)); |
631 | - } catch(PDOException $e) { |
|
631 | + } catch (PDOException $e) { |
|
632 | 632 | return "error"; |
633 | 633 | } |
634 | 634 | |
@@ -646,13 +646,13 @@ discard block |
||
646 | 646 | { |
647 | 647 | global $globalDBdriver, $globalTimezone; |
648 | 648 | if ($globalDBdriver == 'mysql') { |
649 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
649 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
650 | 650 | WHERE spotter_live.ident = :ident |
651 | 651 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
652 | 652 | AND spotter_live.date < UTC_TIMESTAMP()'; |
653 | 653 | $query_data = array(':ident' => $ident); |
654 | 654 | } else { |
655 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
655 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
656 | 656 | WHERE spotter_live.ident = :ident |
657 | 657 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
658 | 658 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | |
662 | 662 | $sth = $this->db->prepare($query); |
663 | 663 | $sth->execute($query_data); |
664 | - $ident_result=''; |
|
665 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
664 | + $ident_result = ''; |
|
665 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
666 | 666 | { |
667 | 667 | $ident_result = $row['ident']; |
668 | 668 | } |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | { |
680 | 680 | global $globalDBdriver, $globalTimezone; |
681 | 681 | if ($globalDBdriver == 'mysql') { |
682 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
682 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
683 | 683 | WHERE spotter_live.ident = :ident |
684 | 684 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
685 | 685 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
686 | 686 | $query_data = array(':ident' => $ident); |
687 | 687 | } else { |
688 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
688 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
689 | 689 | WHERE spotter_live.ident = :ident |
690 | 690 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
691 | 691 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | |
695 | 695 | $sth = $this->db->prepare($query); |
696 | 696 | $sth->execute($query_data); |
697 | - $ident_result=''; |
|
698 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
697 | + $ident_result = ''; |
|
698 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
699 | 699 | { |
700 | 700 | $ident_result = $row['flightaware_id']; |
701 | 701 | } |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | { |
713 | 713 | global $globalDBdriver, $globalTimezone; |
714 | 714 | if ($globalDBdriver == 'mysql') { |
715 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
715 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
716 | 716 | WHERE spotter_live.flightaware_id = :id |
717 | 717 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
718 | 718 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
719 | 719 | $query_data = array(':id' => $id); |
720 | 720 | } else { |
721 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
721 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
722 | 722 | WHERE spotter_live.flightaware_id = :id |
723 | 723 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
724 | 724 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | |
728 | 728 | $sth = $this->db->prepare($query); |
729 | 729 | $sth->execute($query_data); |
730 | - $ident_result=''; |
|
731 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
730 | + $ident_result = ''; |
|
731 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
732 | 732 | { |
733 | 733 | $ident_result = $row['flightaware_id']; |
734 | 734 | } |
@@ -745,13 +745,13 @@ discard block |
||
745 | 745 | { |
746 | 746 | global $globalDBdriver, $globalTimezone; |
747 | 747 | if ($globalDBdriver == 'mysql') { |
748 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
748 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
749 | 749 | WHERE spotter_live.ModeS = :modes |
750 | 750 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
751 | 751 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
752 | 752 | $query_data = array(':modes' => $modes); |
753 | 753 | } else { |
754 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
754 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
755 | 755 | WHERE spotter_live.ModeS = :modes |
756 | 756 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
757 | 757 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -760,8 +760,8 @@ discard block |
||
760 | 760 | |
761 | 761 | $sth = $this->db->prepare($query); |
762 | 762 | $sth->execute($query_data); |
763 | - $ident_result=''; |
|
764 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
763 | + $ident_result = ''; |
|
764 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
765 | 765 | { |
766 | 766 | //$ident_result = $row['spotter_live_id']; |
767 | 767 | $ident_result = $row['flightaware_id']; |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * @return String success or false |
781 | 781 | * |
782 | 782 | */ |
783 | - 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 = '') |
|
783 | + 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 = '') |
|
784 | 784 | { |
785 | 785 | global $globalURL, $globalArchive, $globalDebug; |
786 | 786 | $Common = new Common(); |
@@ -874,26 +874,26 @@ discard block |
||
874 | 874 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
875 | 875 | |
876 | 876 | |
877 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
878 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
879 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
880 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
881 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
882 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
883 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
884 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
885 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
886 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
887 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
888 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
889 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
890 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
891 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
892 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
893 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
894 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
895 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
896 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
877 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
878 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
879 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
880 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
881 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
882 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
883 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
884 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
885 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
886 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
887 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
888 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
889 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
890 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
891 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
892 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
893 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
894 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
895 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
896 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
897 | 897 | |
898 | 898 | $airline_name = ''; |
899 | 899 | $airline_icao = ''; |
@@ -915,26 +915,26 @@ discard block |
||
915 | 915 | $arrival_airport_country = ''; |
916 | 916 | |
917 | 917 | |
918 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
919 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
920 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
921 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
918 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
919 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
920 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
921 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
922 | 922 | |
923 | - $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) |
|
923 | + $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) |
|
924 | 924 | 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)'; |
925 | 925 | |
926 | - $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); |
|
926 | + $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); |
|
927 | 927 | //$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'],':airline_country' => $airline_array[0]['country'],':airline_type' => $airline_array[0]['type'],':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_array[0]['type'],':aircraft_manufacturer' => $aircraft_array[0]['manufacturer'],':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date); |
928 | 928 | try { |
929 | 929 | |
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 | if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) { |
936 | 936 | if ($globalDebug) echo '(Add to SBS archive : '; |
937 | - $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); |
|
937 | + $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); |
|
938 | 938 | if ($globalDebug) echo $result.')'; |
939 | 939 | } |
940 | 940 | return "success"; |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | |
944 | 944 | public function getOrderBy() |
945 | 945 | { |
946 | - $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")); |
|
946 | + $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")); |
|
947 | 947 | return $orderby; |
948 | 948 | } |
949 | 949 |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter; |
21 | - if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
21 | + if (is_array($globalFilter)) { |
|
22 | + $filter = array_merge($globalFilter,$filter); |
|
23 | + } |
|
22 | 24 | $filter_query_join = ''; |
23 | 25 | $filter_query_where = ''; |
24 | 26 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
@@ -43,8 +45,11 @@ discard block |
||
43 | 45 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
44 | 46 | } |
45 | 47 | } |
46 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
47 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
48 | + if ($filter_query_where == '' && $where) { |
|
49 | + $filter_query_where = ' WHERE'; |
|
50 | + } elseif ($filter_query_where != '' && $and) { |
|
51 | + $filter_query_where .= ' AND'; |
|
52 | + } |
|
48 | 53 | $filter_query = $filter_query_join.$filter_query_where; |
49 | 54 | return $filter_query; |
50 | 55 | } |
@@ -80,7 +85,9 @@ discard block |
||
80 | 85 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
81 | 86 | } |
82 | 87 | |
83 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
88 | + if (!isset($globalLiveInterval)) { |
|
89 | + $globalLiveInterval = '200'; |
|
90 | + } |
|
84 | 91 | if ($globalDBdriver == 'mysql') { |
85 | 92 | //$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"; |
86 | 93 | $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; |
@@ -105,7 +112,9 @@ discard block |
||
105 | 112 | |
106 | 113 | $filter_query = $this->getFilter($filter); |
107 | 114 | |
108 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
115 | + if (!isset($globalLiveInterval)) { |
|
116 | + $globalLiveInterval = '200'; |
|
117 | + } |
|
109 | 118 | if ($globalDBdriver == 'mysql') { |
110 | 119 | // $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"; |
111 | 120 | // $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'; |
@@ -154,7 +163,9 @@ discard block |
||
154 | 163 | |
155 | 164 | $filter_query = $this->getFilter($filter,true,true); |
156 | 165 | |
157 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
166 | + if (!isset($globalLiveInterval)) { |
|
167 | + $globalLiveInterval = '200'; |
|
168 | + } |
|
158 | 169 | if ($globalDBdriver == 'mysql') { |
159 | 170 | |
160 | 171 | $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 |
@@ -194,7 +205,9 @@ discard block |
||
194 | 205 | global $globalDBdriver, $globalLiveInterval; |
195 | 206 | $filter_query = $this->getFilter($filter); |
196 | 207 | |
197 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
208 | + if (!isset($globalLiveInterval)) { |
|
209 | + $globalLiveInterval = '200'; |
|
210 | + } |
|
198 | 211 | if ($globalDBdriver == 'mysql') { |
199 | 212 | //$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; |
200 | 213 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'.$filter_query; |
@@ -223,7 +236,9 @@ discard block |
||
223 | 236 | { |
224 | 237 | global $globalDBdriver, $globalLiveInterval; |
225 | 238 | $Spotter = new Spotter($this->db); |
226 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
239 | + if (!isset($globalLiveInterval)) { |
|
240 | + $globalLiveInterval = '200'; |
|
241 | + } |
|
227 | 242 | $filter_query = $this->getFilter($filter); |
228 | 243 | |
229 | 244 | if (is_array($coord)) { |
@@ -231,7 +246,9 @@ discard block |
||
231 | 246 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
232 | 247 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
233 | 248 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
234 | - } else return array(); |
|
249 | + } else { |
|
250 | + return array(); |
|
251 | + } |
|
235 | 252 | if ($globalDBdriver == 'mysql') { |
236 | 253 | //$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.")"; |
237 | 254 | $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; |
@@ -422,11 +439,15 @@ discard block |
||
422 | 439 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
423 | 440 | if ($globalDBdriver == 'mysql') { |
424 | 441 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
425 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
442 | + if ($liveinterval) { |
|
443 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
444 | + } |
|
426 | 445 | $query .= ' ORDER BY date'; |
427 | 446 | } else { |
428 | 447 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
429 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
448 | + if ($liveinterval) { |
|
449 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
450 | + } |
|
430 | 451 | $query .= ' ORDER BY date'; |
431 | 452 | } |
432 | 453 | |
@@ -521,7 +542,9 @@ discard block |
||
521 | 542 | $i++; |
522 | 543 | $j++; |
523 | 544 | if ($j == 30) { |
524 | - if ($globalDebug) echo "."; |
|
545 | + if ($globalDebug) { |
|
546 | + echo "."; |
|
547 | + } |
|
525 | 548 | try { |
526 | 549 | |
527 | 550 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -853,7 +876,9 @@ discard block |
||
853 | 876 | { |
854 | 877 | return false; |
855 | 878 | } |
856 | - } else $altitude = 0; |
|
879 | + } else { |
|
880 | + $altitude = 0; |
|
881 | + } |
|
857 | 882 | |
858 | 883 | if ($heading != '') |
859 | 884 | { |
@@ -861,7 +886,9 @@ discard block |
||
861 | 886 | { |
862 | 887 | return false; |
863 | 888 | } |
864 | - } else $heading = 0; |
|
889 | + } else { |
|
890 | + $heading = 0; |
|
891 | + } |
|
865 | 892 | |
866 | 893 | if ($groundspeed != '') |
867 | 894 | { |
@@ -869,9 +896,13 @@ discard block |
||
869 | 896 | { |
870 | 897 | return false; |
871 | 898 | } |
872 | - } else $groundspeed = 0; |
|
899 | + } else { |
|
900 | + $groundspeed = 0; |
|
901 | + } |
|
873 | 902 | date_default_timezone_set('UTC'); |
874 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
903 | + if ($date == '') { |
|
904 | + $date = date("Y-m-d H:i:s", time()); |
|
905 | + } |
|
875 | 906 | |
876 | 907 | |
877 | 908 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -915,10 +946,18 @@ discard block |
||
915 | 946 | $arrival_airport_country = ''; |
916 | 947 | |
917 | 948 | |
918 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
919 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
920 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
921 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
949 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
950 | + $squawk = NULL; |
|
951 | + } |
|
952 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
953 | + $verticalrate = NULL; |
|
954 | + } |
|
955 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
956 | + $groundspeed = 0; |
|
957 | + } |
|
958 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
959 | + $heading = 0; |
|
960 | + } |
|
922 | 961 | |
923 | 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) |
924 | 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)'; |
@@ -933,9 +972,13 @@ discard block |
||
933 | 972 | return "error : ".$e->getMessage(); |
934 | 973 | } |
935 | 974 | if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) { |
936 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
975 | + if ($globalDebug) { |
|
976 | + echo '(Add to SBS archive : '; |
|
977 | + } |
|
937 | 978 | $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); |
938 | - if ($globalDebug) echo $result.')'; |
|
979 | + if ($globalDebug) { |
|
980 | + echo $result.')'; |
|
981 | + } |
|
939 | 982 | } |
940 | 983 | return "success"; |
941 | 984 |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1102,8 +1160,11 @@ discard block |
||
1102 | 1160 | if ($Connection->tableExists('aircraft')) { |
1103 | 1161 | if (!$Connection->tableExists('config')) { |
1104 | 1162 | $version = '1'; |
1105 | - if ($update) return self::update_from_1(); |
|
1106 | - else return $version; |
|
1163 | + if ($update) { |
|
1164 | + return self::update_from_1(); |
|
1165 | + } else { |
|
1166 | + return $version; |
|
1167 | + } |
|
1107 | 1168 | } else { |
1108 | 1169 | $Connection = new Connection(); |
1109 | 1170 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1117,106 +1178,183 @@ discard block |
||
1117 | 1178 | if ($update) { |
1118 | 1179 | if ($result['value'] == '2') { |
1119 | 1180 | $error = self::update_from_2(); |
1120 | - if ($error != '') return $error; |
|
1121 | - else return self::check_version(true); |
|
1181 | + if ($error != '') { |
|
1182 | + return $error; |
|
1183 | + } else { |
|
1184 | + return self::check_version(true); |
|
1185 | + } |
|
1122 | 1186 | } elseif ($result['value'] == '3') { |
1123 | 1187 | $error = self::update_from_3(); |
1124 | - if ($error != '') return $error; |
|
1125 | - else return self::check_version(true); |
|
1188 | + if ($error != '') { |
|
1189 | + return $error; |
|
1190 | + } else { |
|
1191 | + return self::check_version(true); |
|
1192 | + } |
|
1126 | 1193 | } elseif ($result['value'] == '4') { |
1127 | 1194 | $error = self::update_from_4(); |
1128 | - if ($error != '') return $error; |
|
1129 | - else return self::check_version(true); |
|
1195 | + if ($error != '') { |
|
1196 | + return $error; |
|
1197 | + } else { |
|
1198 | + return self::check_version(true); |
|
1199 | + } |
|
1130 | 1200 | } elseif ($result['value'] == '5') { |
1131 | 1201 | $error = self::update_from_5(); |
1132 | - if ($error != '') return $error; |
|
1133 | - else return self::check_version(true); |
|
1202 | + if ($error != '') { |
|
1203 | + return $error; |
|
1204 | + } else { |
|
1205 | + return self::check_version(true); |
|
1206 | + } |
|
1134 | 1207 | } elseif ($result['value'] == '6') { |
1135 | 1208 | $error = self::update_from_6(); |
1136 | - if ($error != '') return $error; |
|
1137 | - else return self::check_version(true); |
|
1209 | + if ($error != '') { |
|
1210 | + return $error; |
|
1211 | + } else { |
|
1212 | + return self::check_version(true); |
|
1213 | + } |
|
1138 | 1214 | } elseif ($result['value'] == '7') { |
1139 | 1215 | $error = self::update_from_7(); |
1140 | - if ($error != '') return $error; |
|
1141 | - else return self::check_version(true); |
|
1216 | + if ($error != '') { |
|
1217 | + return $error; |
|
1218 | + } else { |
|
1219 | + return self::check_version(true); |
|
1220 | + } |
|
1142 | 1221 | } elseif ($result['value'] == '8') { |
1143 | 1222 | $error = self::update_from_8(); |
1144 | - if ($error != '') return $error; |
|
1145 | - else return self::check_version(true); |
|
1223 | + if ($error != '') { |
|
1224 | + return $error; |
|
1225 | + } else { |
|
1226 | + return self::check_version(true); |
|
1227 | + } |
|
1146 | 1228 | } elseif ($result['value'] == '9') { |
1147 | 1229 | $error = self::update_from_9(); |
1148 | - if ($error != '') return $error; |
|
1149 | - else return self::check_version(true); |
|
1230 | + if ($error != '') { |
|
1231 | + return $error; |
|
1232 | + } else { |
|
1233 | + return self::check_version(true); |
|
1234 | + } |
|
1150 | 1235 | } elseif ($result['value'] == '10') { |
1151 | 1236 | $error = self::update_from_10(); |
1152 | - if ($error != '') return $error; |
|
1153 | - else return self::check_version(true); |
|
1237 | + if ($error != '') { |
|
1238 | + return $error; |
|
1239 | + } else { |
|
1240 | + return self::check_version(true); |
|
1241 | + } |
|
1154 | 1242 | } elseif ($result['value'] == '11') { |
1155 | 1243 | $error = self::update_from_11(); |
1156 | - if ($error != '') return $error; |
|
1157 | - else return self::check_version(true); |
|
1244 | + if ($error != '') { |
|
1245 | + return $error; |
|
1246 | + } else { |
|
1247 | + return self::check_version(true); |
|
1248 | + } |
|
1158 | 1249 | } elseif ($result['value'] == '12') { |
1159 | 1250 | $error = self::update_from_12(); |
1160 | - if ($error != '') return $error; |
|
1161 | - else return self::check_version(true); |
|
1251 | + if ($error != '') { |
|
1252 | + return $error; |
|
1253 | + } else { |
|
1254 | + return self::check_version(true); |
|
1255 | + } |
|
1162 | 1256 | } elseif ($result['value'] == '13') { |
1163 | 1257 | $error = self::update_from_13(); |
1164 | - if ($error != '') return $error; |
|
1165 | - else return self::check_version(true); |
|
1258 | + if ($error != '') { |
|
1259 | + return $error; |
|
1260 | + } else { |
|
1261 | + return self::check_version(true); |
|
1262 | + } |
|
1166 | 1263 | } elseif ($result['value'] == '14') { |
1167 | 1264 | $error = self::update_from_14(); |
1168 | - if ($error != '') return $error; |
|
1169 | - else return self::check_version(true); |
|
1265 | + if ($error != '') { |
|
1266 | + return $error; |
|
1267 | + } else { |
|
1268 | + return self::check_version(true); |
|
1269 | + } |
|
1170 | 1270 | } elseif ($result['value'] == '15') { |
1171 | 1271 | $error = self::update_from_15(); |
1172 | - if ($error != '') return $error; |
|
1173 | - else return self::check_version(true); |
|
1272 | + if ($error != '') { |
|
1273 | + return $error; |
|
1274 | + } else { |
|
1275 | + return self::check_version(true); |
|
1276 | + } |
|
1174 | 1277 | } elseif ($result['value'] == '16') { |
1175 | 1278 | $error = self::update_from_16(); |
1176 | - if ($error != '') return $error; |
|
1177 | - else return self::check_version(true); |
|
1279 | + if ($error != '') { |
|
1280 | + return $error; |
|
1281 | + } else { |
|
1282 | + return self::check_version(true); |
|
1283 | + } |
|
1178 | 1284 | } elseif ($result['value'] == '17') { |
1179 | 1285 | $error = self::update_from_17(); |
1180 | - if ($error != '') return $error; |
|
1181 | - else return self::check_version(true); |
|
1286 | + if ($error != '') { |
|
1287 | + return $error; |
|
1288 | + } else { |
|
1289 | + return self::check_version(true); |
|
1290 | + } |
|
1182 | 1291 | } elseif ($result['value'] == '18') { |
1183 | 1292 | $error = self::update_from_18(); |
1184 | - if ($error != '') return $error; |
|
1185 | - else return self::check_version(true); |
|
1293 | + if ($error != '') { |
|
1294 | + return $error; |
|
1295 | + } else { |
|
1296 | + return self::check_version(true); |
|
1297 | + } |
|
1186 | 1298 | } elseif ($result['value'] == '19') { |
1187 | 1299 | $error = self::update_from_19(); |
1188 | - if ($error != '') return $error; |
|
1189 | - else return self::check_version(true); |
|
1300 | + if ($error != '') { |
|
1301 | + return $error; |
|
1302 | + } else { |
|
1303 | + return self::check_version(true); |
|
1304 | + } |
|
1190 | 1305 | } elseif ($result['value'] == '20') { |
1191 | 1306 | $error = self::update_from_20(); |
1192 | - if ($error != '') return $error; |
|
1193 | - else return self::check_version(true); |
|
1307 | + if ($error != '') { |
|
1308 | + return $error; |
|
1309 | + } else { |
|
1310 | + return self::check_version(true); |
|
1311 | + } |
|
1194 | 1312 | } elseif ($result['value'] == '21') { |
1195 | 1313 | $error = self::update_from_21(); |
1196 | - if ($error != '') return $error; |
|
1197 | - else return self::check_version(true); |
|
1314 | + if ($error != '') { |
|
1315 | + return $error; |
|
1316 | + } else { |
|
1317 | + return self::check_version(true); |
|
1318 | + } |
|
1198 | 1319 | } elseif ($result['value'] == '22') { |
1199 | 1320 | $error = self::update_from_22(); |
1200 | - if ($error != '') return $error; |
|
1201 | - else return self::check_version(true); |
|
1321 | + if ($error != '') { |
|
1322 | + return $error; |
|
1323 | + } else { |
|
1324 | + return self::check_version(true); |
|
1325 | + } |
|
1202 | 1326 | } elseif ($result['value'] == '23') { |
1203 | 1327 | $error = self::update_from_23(); |
1204 | - if ($error != '') return $error; |
|
1205 | - else return self::check_version(true); |
|
1328 | + if ($error != '') { |
|
1329 | + return $error; |
|
1330 | + } else { |
|
1331 | + return self::check_version(true); |
|
1332 | + } |
|
1206 | 1333 | } elseif ($result['value'] == '24') { |
1207 | 1334 | $error = self::update_from_24(); |
1208 | - if ($error != '') return $error; |
|
1209 | - else return self::check_version(true); |
|
1335 | + if ($error != '') { |
|
1336 | + return $error; |
|
1337 | + } else { |
|
1338 | + return self::check_version(true); |
|
1339 | + } |
|
1210 | 1340 | } elseif ($result['value'] == '25') { |
1211 | 1341 | $error = self::update_from_25(); |
1212 | - if ($error != '') return $error; |
|
1213 | - else return self::check_version(true); |
|
1214 | - } else return ''; |
|
1342 | + if ($error != '') { |
|
1343 | + return $error; |
|
1344 | + } else { |
|
1345 | + return self::check_version(true); |
|
1346 | + } |
|
1347 | + } else { |
|
1348 | + return ''; |
|
1349 | + } |
|
1350 | + } else { |
|
1351 | + return $result['value']; |
|
1215 | 1352 | } |
1216 | - else return $result['value']; |
|
1217 | 1353 | } |
1218 | 1354 | |
1219 | - } else return $version; |
|
1355 | + } else { |
|
1356 | + return $version; |
|
1357 | + } |
|
1220 | 1358 | } |
1221 | 1359 | |
1222 | 1360 | } |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
416 | + $sth->execute(); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1112,129 +1112,129 @@ discard block |
||
1112 | 1112 | |
1113 | 1113 | |
1114 | 1114 | |
1115 | - public static function check_version($update = false) { |
|
1116 | - global $globalDBname; |
|
1117 | - $version = 0; |
|
1118 | - $Connection = new Connection(); |
|
1119 | - if ($Connection->tableExists('aircraft')) { |
|
1120 | - if (!$Connection->tableExists('config')) { |
|
1121 | - $version = '1'; |
|
1122 | - if ($update) return self::update_from_1(); |
|
1123 | - else return $version; |
|
1115 | + public static function check_version($update = false) { |
|
1116 | + global $globalDBname; |
|
1117 | + $version = 0; |
|
1118 | + $Connection = new Connection(); |
|
1119 | + if ($Connection->tableExists('aircraft')) { |
|
1120 | + if (!$Connection->tableExists('config')) { |
|
1121 | + $version = '1'; |
|
1122 | + if ($update) return self::update_from_1(); |
|
1123 | + else return $version; |
|
1124 | 1124 | } else { |
1125 | - $Connection = new Connection(); |
|
1126 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1127 | - try { |
|
1128 | - $sth = $Connection->db->prepare($query); |
|
1129 | - $sth->execute(); |
|
1130 | - } catch(PDOException $e) { |
|
1125 | + $Connection = new Connection(); |
|
1126 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1127 | + try { |
|
1128 | + $sth = $Connection->db->prepare($query); |
|
1129 | + $sth->execute(); |
|
1130 | + } catch(PDOException $e) { |
|
1131 | 1131 | return "error : ".$e->getMessage()."\n"; |
1132 | - } |
|
1133 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1134 | - if ($update) { |
|
1135 | - if ($result['value'] == '2') { |
|
1136 | - $error = self::update_from_2(); |
|
1137 | - if ($error != '') return $error; |
|
1138 | - else return self::check_version(true); |
|
1139 | - } elseif ($result['value'] == '3') { |
|
1140 | - $error = self::update_from_3(); |
|
1141 | - if ($error != '') return $error; |
|
1142 | - else return self::check_version(true); |
|
1143 | - } elseif ($result['value'] == '4') { |
|
1144 | - $error = self::update_from_4(); |
|
1145 | - if ($error != '') return $error; |
|
1146 | - else return self::check_version(true); |
|
1147 | - } elseif ($result['value'] == '5') { |
|
1148 | - $error = self::update_from_5(); |
|
1149 | - if ($error != '') return $error; |
|
1150 | - else return self::check_version(true); |
|
1151 | - } elseif ($result['value'] == '6') { |
|
1152 | - $error = self::update_from_6(); |
|
1153 | - if ($error != '') return $error; |
|
1154 | - else return self::check_version(true); |
|
1155 | - } elseif ($result['value'] == '7') { |
|
1156 | - $error = self::update_from_7(); |
|
1157 | - if ($error != '') return $error; |
|
1158 | - else return self::check_version(true); |
|
1159 | - } elseif ($result['value'] == '8') { |
|
1160 | - $error = self::update_from_8(); |
|
1161 | - if ($error != '') return $error; |
|
1162 | - else return self::check_version(true); |
|
1163 | - } elseif ($result['value'] == '9') { |
|
1164 | - $error = self::update_from_9(); |
|
1165 | - if ($error != '') return $error; |
|
1166 | - else return self::check_version(true); |
|
1167 | - } elseif ($result['value'] == '10') { |
|
1168 | - $error = self::update_from_10(); |
|
1169 | - if ($error != '') return $error; |
|
1170 | - else return self::check_version(true); |
|
1171 | - } elseif ($result['value'] == '11') { |
|
1172 | - $error = self::update_from_11(); |
|
1173 | - if ($error != '') return $error; |
|
1174 | - else return self::check_version(true); |
|
1175 | - } elseif ($result['value'] == '12') { |
|
1176 | - $error = self::update_from_12(); |
|
1177 | - if ($error != '') return $error; |
|
1178 | - else return self::check_version(true); |
|
1179 | - } elseif ($result['value'] == '13') { |
|
1180 | - $error = self::update_from_13(); |
|
1181 | - if ($error != '') return $error; |
|
1182 | - else return self::check_version(true); |
|
1183 | - } elseif ($result['value'] == '14') { |
|
1184 | - $error = self::update_from_14(); |
|
1185 | - if ($error != '') return $error; |
|
1186 | - else return self::check_version(true); |
|
1187 | - } elseif ($result['value'] == '15') { |
|
1188 | - $error = self::update_from_15(); |
|
1189 | - if ($error != '') return $error; |
|
1190 | - else return self::check_version(true); |
|
1191 | - } elseif ($result['value'] == '16') { |
|
1192 | - $error = self::update_from_16(); |
|
1193 | - if ($error != '') return $error; |
|
1194 | - else return self::check_version(true); |
|
1195 | - } elseif ($result['value'] == '17') { |
|
1196 | - $error = self::update_from_17(); |
|
1197 | - if ($error != '') return $error; |
|
1198 | - else return self::check_version(true); |
|
1199 | - } elseif ($result['value'] == '18') { |
|
1200 | - $error = self::update_from_18(); |
|
1201 | - if ($error != '') return $error; |
|
1202 | - else return self::check_version(true); |
|
1203 | - } elseif ($result['value'] == '19') { |
|
1204 | - $error = self::update_from_19(); |
|
1205 | - if ($error != '') return $error; |
|
1206 | - else return self::check_version(true); |
|
1207 | - } elseif ($result['value'] == '20') { |
|
1208 | - $error = self::update_from_20(); |
|
1209 | - if ($error != '') return $error; |
|
1210 | - else return self::check_version(true); |
|
1211 | - } elseif ($result['value'] == '21') { |
|
1212 | - $error = self::update_from_21(); |
|
1213 | - if ($error != '') return $error; |
|
1214 | - else return self::check_version(true); |
|
1215 | - } elseif ($result['value'] == '22') { |
|
1216 | - $error = self::update_from_22(); |
|
1217 | - if ($error != '') return $error; |
|
1218 | - else return self::check_version(true); |
|
1219 | - } elseif ($result['value'] == '23') { |
|
1220 | - $error = self::update_from_23(); |
|
1221 | - if ($error != '') return $error; |
|
1222 | - else return self::check_version(true); |
|
1223 | - } elseif ($result['value'] == '24') { |
|
1224 | - $error = self::update_from_24(); |
|
1225 | - if ($error != '') return $error; |
|
1226 | - else return self::check_version(true); |
|
1227 | - } elseif ($result['value'] == '25') { |
|
1228 | - $error = self::update_from_25(); |
|
1229 | - if ($error != '') return $error; |
|
1230 | - else return self::check_version(true); |
|
1231 | - } else return ''; |
|
1232 | - } |
|
1233 | - else return $result['value']; |
|
1132 | + } |
|
1133 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1134 | + if ($update) { |
|
1135 | + if ($result['value'] == '2') { |
|
1136 | + $error = self::update_from_2(); |
|
1137 | + if ($error != '') return $error; |
|
1138 | + else return self::check_version(true); |
|
1139 | + } elseif ($result['value'] == '3') { |
|
1140 | + $error = self::update_from_3(); |
|
1141 | + if ($error != '') return $error; |
|
1142 | + else return self::check_version(true); |
|
1143 | + } elseif ($result['value'] == '4') { |
|
1144 | + $error = self::update_from_4(); |
|
1145 | + if ($error != '') return $error; |
|
1146 | + else return self::check_version(true); |
|
1147 | + } elseif ($result['value'] == '5') { |
|
1148 | + $error = self::update_from_5(); |
|
1149 | + if ($error != '') return $error; |
|
1150 | + else return self::check_version(true); |
|
1151 | + } elseif ($result['value'] == '6') { |
|
1152 | + $error = self::update_from_6(); |
|
1153 | + if ($error != '') return $error; |
|
1154 | + else return self::check_version(true); |
|
1155 | + } elseif ($result['value'] == '7') { |
|
1156 | + $error = self::update_from_7(); |
|
1157 | + if ($error != '') return $error; |
|
1158 | + else return self::check_version(true); |
|
1159 | + } elseif ($result['value'] == '8') { |
|
1160 | + $error = self::update_from_8(); |
|
1161 | + if ($error != '') return $error; |
|
1162 | + else return self::check_version(true); |
|
1163 | + } elseif ($result['value'] == '9') { |
|
1164 | + $error = self::update_from_9(); |
|
1165 | + if ($error != '') return $error; |
|
1166 | + else return self::check_version(true); |
|
1167 | + } elseif ($result['value'] == '10') { |
|
1168 | + $error = self::update_from_10(); |
|
1169 | + if ($error != '') return $error; |
|
1170 | + else return self::check_version(true); |
|
1171 | + } elseif ($result['value'] == '11') { |
|
1172 | + $error = self::update_from_11(); |
|
1173 | + if ($error != '') return $error; |
|
1174 | + else return self::check_version(true); |
|
1175 | + } elseif ($result['value'] == '12') { |
|
1176 | + $error = self::update_from_12(); |
|
1177 | + if ($error != '') return $error; |
|
1178 | + else return self::check_version(true); |
|
1179 | + } elseif ($result['value'] == '13') { |
|
1180 | + $error = self::update_from_13(); |
|
1181 | + if ($error != '') return $error; |
|
1182 | + else return self::check_version(true); |
|
1183 | + } elseif ($result['value'] == '14') { |
|
1184 | + $error = self::update_from_14(); |
|
1185 | + if ($error != '') return $error; |
|
1186 | + else return self::check_version(true); |
|
1187 | + } elseif ($result['value'] == '15') { |
|
1188 | + $error = self::update_from_15(); |
|
1189 | + if ($error != '') return $error; |
|
1190 | + else return self::check_version(true); |
|
1191 | + } elseif ($result['value'] == '16') { |
|
1192 | + $error = self::update_from_16(); |
|
1193 | + if ($error != '') return $error; |
|
1194 | + else return self::check_version(true); |
|
1195 | + } elseif ($result['value'] == '17') { |
|
1196 | + $error = self::update_from_17(); |
|
1197 | + if ($error != '') return $error; |
|
1198 | + else return self::check_version(true); |
|
1199 | + } elseif ($result['value'] == '18') { |
|
1200 | + $error = self::update_from_18(); |
|
1201 | + if ($error != '') return $error; |
|
1202 | + else return self::check_version(true); |
|
1203 | + } elseif ($result['value'] == '19') { |
|
1204 | + $error = self::update_from_19(); |
|
1205 | + if ($error != '') return $error; |
|
1206 | + else return self::check_version(true); |
|
1207 | + } elseif ($result['value'] == '20') { |
|
1208 | + $error = self::update_from_20(); |
|
1209 | + if ($error != '') return $error; |
|
1210 | + else return self::check_version(true); |
|
1211 | + } elseif ($result['value'] == '21') { |
|
1212 | + $error = self::update_from_21(); |
|
1213 | + if ($error != '') return $error; |
|
1214 | + else return self::check_version(true); |
|
1215 | + } elseif ($result['value'] == '22') { |
|
1216 | + $error = self::update_from_22(); |
|
1217 | + if ($error != '') return $error; |
|
1218 | + else return self::check_version(true); |
|
1219 | + } elseif ($result['value'] == '23') { |
|
1220 | + $error = self::update_from_23(); |
|
1221 | + if ($error != '') return $error; |
|
1222 | + else return self::check_version(true); |
|
1223 | + } elseif ($result['value'] == '24') { |
|
1224 | + $error = self::update_from_24(); |
|
1225 | + if ($error != '') return $error; |
|
1226 | + else return self::check_version(true); |
|
1227 | + } elseif ($result['value'] == '25') { |
|
1228 | + $error = self::update_from_25(); |
|
1229 | + if ($error != '') return $error; |
|
1230 | + else return self::check_version(true); |
|
1231 | + } else return ''; |
|
1232 | + } |
|
1233 | + else return $result['value']; |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | - } else return $version; |
|
1237 | - } |
|
1236 | + } else return $version; |
|
1237 | + } |
|
1238 | 1238 | |
1239 | 1239 | } |
1240 | 1240 | //echo update_schema::check_version(); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | try { |
816 | 816 | $sth = $Connection->db->prepare($query); |
817 | 817 | $sth->execute(); |
818 | - } catch(PDOException $e) { |
|
818 | + } catch (PDOException $e) { |
|
819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
820 | 820 | } |
821 | 821 | } |
822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | 830 | } |
831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | try { |
835 | 835 | $sth = $Connection->db->prepare($query); |
836 | 836 | $sth->execute(); |
837 | - } catch(PDOException $e) { |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
839 | 839 | } |
840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 851 | } |
852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
854 | 854 | // Add forsource to airlines |
855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
856 | 856 | try { |
857 | 857 | $sth = $Connection->db->prepare($query); |
858 | 858 | $sth->execute(); |
859 | - } catch(PDOException $e) { |
|
859 | + } catch (PDOException $e) { |
|
860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
861 | 861 | } |
862 | 862 | } |
863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
864 | 864 | // Add forsource to airlines |
865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
866 | 866 | try { |
867 | 867 | $sth = $Connection->db->prepare($query); |
868 | 868 | $sth->execute(); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
871 | 871 | } |
872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | try { |
879 | 879 | $sth = $Connection->db->prepare($query); |
880 | 880 | $sth->execute(); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
883 | 883 | } |
884 | 884 | } |
885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
886 | 886 | // Add forsource to airlines |
887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
888 | 888 | try { |
889 | 889 | $sth = $Connection->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
893 | 893 | } |
894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | try { |
901 | 901 | $sth = $Connection->db->prepare($query); |
902 | 902 | $sth->execute(); |
903 | - } catch(PDOException $e) { |
|
903 | + } catch (PDOException $e) { |
|
904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
905 | 905 | } |
906 | 906 | } |
907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
908 | 908 | // Add forsource to airlines |
909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
910 | 910 | try { |
911 | 911 | $sth = $Connection->db->prepare($query); |
912 | 912 | $sth->execute(); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
915 | 915 | } |
916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
922 | 922 | try { |
923 | 923 | $sth = $Connection->db->prepare($query); |
924 | 924 | $sth->execute(); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
927 | 927 | } |
928 | 928 | } |
929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
930 | 930 | // Add forsource to airlines |
931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | 934 | $sth->execute(); |
935 | - } catch(PDOException $e) { |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
937 | 937 | } |
938 | 938 | } |
939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
940 | 940 | // Add forsource to airlines |
941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
942 | 942 | try { |
943 | 943 | $sth = $Connection->db->prepare($query); |
944 | 944 | $sth->execute(); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
947 | 947 | } |
948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
949 | 949 | // Add unique key |
950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
951 | 951 | try { |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
956 | 956 | } |
957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $Connection->db->prepare($query); |
966 | 966 | $sth->execute(); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
973 | 973 | // Add forsource to airlines |
974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | 977 | $sth->execute(); |
978 | - } catch(PDOException $e) { |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
980 | 980 | } |
981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | try { |
988 | 988 | $sth = $Connection->db->prepare($query); |
989 | 989 | $sth->execute(); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
992 | 992 | } |
993 | 993 | } |
994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
995 | 995 | // Add forsource to airlines |
996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
997 | 997 | try { |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1002 | 1002 | } |
1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | try { |
1010 | 1010 | $sth = $Connection->db->prepare($query); |
1011 | 1011 | $sth->execute(); |
1012 | - } catch(PDOException $e) { |
|
1012 | + } catch (PDOException $e) { |
|
1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1017 | 1017 | // Add forsource to airlines |
1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1019 | 1019 | try { |
1020 | 1020 | $sth = $Connection->db->prepare($query); |
1021 | 1021 | $sth->execute(); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1024 | 1024 | } |
1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | try { |
1032 | 1032 | $sth = $Connection->db->prepare($query); |
1033 | 1033 | $sth->execute(); |
1034 | - } catch(PDOException $e) { |
|
1034 | + } catch (PDOException $e) { |
|
1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | try { |
1041 | 1041 | $sth = $Connection->db->prepare($query); |
1042 | 1042 | $sth->execute(); |
1043 | - } catch(PDOException $e) { |
|
1043 | + } catch (PDOException $e) { |
|
1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1045 | 1045 | } |
1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | global $globalDBdriver; |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $error = ''; |
1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1054 | 1054 | // Add forsource to airlines |
1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1056 | 1056 | try { |
1057 | 1057 | $sth = $Connection->db->prepare($query); |
1058 | 1058 | $sth->execute(); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1061 | 1061 | } |
1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
1068 | 1068 | try { |
1069 | 1069 | $sth = $Connection->db->prepare($query); |
1070 | 1070 | $sth->execute(); |
1071 | - } catch(PDOException $e) { |
|
1071 | + } catch (PDOException $e) { |
|
1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1076 | 1076 | // Add forsource to airlines |
1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1078 | 1078 | try { |
1079 | 1079 | $sth = $Connection->db->prepare($query); |
1080 | 1080 | $sth->execute(); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1083 | 1083 | } |
1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | try { |
1099 | 1099 | $sth = $Connection->db->prepare($query); |
1100 | 1100 | $sth->execute(); |
1101 | - } catch(PDOException $e) { |
|
1101 | + } catch (PDOException $e) { |
|
1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1103 | 1103 | } |
1104 | 1104 | return $error; |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | try { |
1122 | 1122 | $sth = $Connection->db->prepare($query); |
1123 | 1123 | $sth->execute(); |
1124 | - } catch(PDOException $e) { |
|
1124 | + } catch (PDOException $e) { |
|
1125 | 1125 | return "error : ".$e->getMessage()."\n"; |
1126 | 1126 | } |
1127 | 1127 | $result = $sth->fetch(PDO::FETCH_ASSOC); |