@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection.'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Tracker = new Tracker($this->db); |
90 | 97 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | // Route is not added in tracker_archive |
95 | 107 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
96 | 108 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -589,7 +601,9 @@ discard block |
||
589 | 601 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
590 | 602 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
591 | 603 | $translate = $Translation->ident2icao($q_item); |
592 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
604 | + if ($translate != $q_item) { |
|
605 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
606 | + } |
|
593 | 607 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
594 | 608 | $additional_query .= ")"; |
595 | 609 | } |
@@ -807,7 +821,9 @@ discard block |
||
807 | 821 | date_default_timezone_set($globalTimezone); |
808 | 822 | $datetime = new DateTime(); |
809 | 823 | $offset = $datetime->format('P'); |
810 | - } else $offset = '+00:00'; |
|
824 | + } else { |
|
825 | + $offset = '+00:00'; |
|
826 | + } |
|
811 | 827 | |
812 | 828 | |
813 | 829 | if ($date_array[1] != "") |
@@ -1083,9 +1099,13 @@ discard block |
||
1083 | 1099 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1084 | 1100 | } |
1085 | 1101 | } |
1086 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1102 | + if ($sincedate != '') { |
|
1103 | + $query .= "AND date > '".$sincedate."' "; |
|
1104 | + } |
|
1087 | 1105 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1088 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1106 | + if ($limit) { |
|
1107 | + $query .= " LIMIT 0,10"; |
|
1108 | + } |
|
1089 | 1109 | |
1090 | 1110 | |
1091 | 1111 | $sth = $this->db->prepare($query); |
@@ -1129,9 +1149,13 @@ discard block |
||
1129 | 1149 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1130 | 1150 | } |
1131 | 1151 | } |
1132 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1152 | + if ($sincedate != '') { |
|
1153 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1154 | + } |
|
1133 | 1155 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1134 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1156 | + if ($limit) { |
|
1157 | + $query .= " LIMIT 0,10"; |
|
1158 | + } |
|
1135 | 1159 | |
1136 | 1160 | |
1137 | 1161 | $sth = $this->db->prepare($query); |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection.'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -77,8 +81,11 @@ discard block |
||
77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
79 | 83 | } |
80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
82 | 89 | if ($filter_query_where != '') { |
83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
84 | 91 | } |
@@ -119,9 +126,13 @@ discard block |
||
119 | 126 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 127 | } |
121 | 128 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
129 | + if ($orderby_query == '') { |
|
130 | + $orderby_query= ' ORDER BY date DESC'; |
|
131 | + } |
|
123 | 132 | |
124 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
133 | + if (!isset($globalLiveInterval)) { |
|
134 | + $globalLiveInterval = '200'; |
|
135 | + } |
|
125 | 136 | if ($globalDBdriver == 'mysql') { |
126 | 137 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
127 | 138 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -146,7 +157,9 @@ discard block |
||
146 | 157 | |
147 | 158 | $filter_query = $this->getFilter($filter,true,true); |
148 | 159 | |
149 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
160 | + if (!isset($globalLiveInterval)) { |
|
161 | + $globalLiveInterval = '200'; |
|
162 | + } |
|
150 | 163 | if ($globalDBdriver == 'mysql') { |
151 | 164 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
152 | 165 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -180,7 +193,9 @@ discard block |
||
180 | 193 | |
181 | 194 | $filter_query = $this->getFilter($filter,true,true); |
182 | 195 | |
183 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
196 | + if (!isset($globalLiveInterval)) { |
|
197 | + $globalLiveInterval = '200'; |
|
198 | + } |
|
184 | 199 | if ($globalDBdriver == 'mysql') { |
185 | 200 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
186 | 201 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
@@ -213,7 +228,9 @@ discard block |
||
213 | 228 | global $globalDBdriver, $globalLiveInterval; |
214 | 229 | $filter_query = $this->getFilter($filter,true,true); |
215 | 230 | |
216 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
231 | + if (!isset($globalLiveInterval)) { |
|
232 | + $globalLiveInterval = '200'; |
|
233 | + } |
|
217 | 234 | if ($globalDBdriver == 'mysql') { |
218 | 235 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
219 | 236 | } else { |
@@ -241,7 +258,9 @@ discard block |
||
241 | 258 | { |
242 | 259 | global $globalDBdriver, $globalLiveInterval; |
243 | 260 | $Spotter = new Spotter($this->db); |
244 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
261 | + if (!isset($globalLiveInterval)) { |
|
262 | + $globalLiveInterval = '200'; |
|
263 | + } |
|
245 | 264 | $filter_query = $this->getFilter($filter); |
246 | 265 | |
247 | 266 | if (is_array($coord)) { |
@@ -249,7 +268,9 @@ discard block |
||
249 | 268 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
250 | 269 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
251 | 270 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
252 | - } else return array(); |
|
271 | + } else { |
|
272 | + return array(); |
|
273 | + } |
|
253 | 274 | if ($globalDBdriver == 'mysql') { |
254 | 275 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
255 | 276 | } else { |
@@ -269,7 +290,9 @@ discard block |
||
269 | 290 | { |
270 | 291 | global $globalDBdriver, $globalLiveInterval; |
271 | 292 | $Spotter = new Spotter($this->db); |
272 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
293 | + if (!isset($globalLiveInterval)) { |
|
294 | + $globalLiveInterval = '200'; |
|
295 | + } |
|
273 | 296 | $filter_query = $this->getFilter($filter); |
274 | 297 | |
275 | 298 | if (is_array($coord)) { |
@@ -277,7 +300,9 @@ discard block |
||
277 | 300 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
278 | 301 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
279 | 302 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
280 | - } else return array(); |
|
303 | + } else { |
|
304 | + return array(); |
|
305 | + } |
|
281 | 306 | if ($globalDBdriver == 'mysql') { |
282 | 307 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
283 | 308 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -445,11 +470,15 @@ discard block |
||
445 | 470 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
446 | 471 | if ($globalDBdriver == 'mysql') { |
447 | 472 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
448 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
473 | + if ($liveinterval) { |
|
474 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
475 | + } |
|
449 | 476 | $query .= ' ORDER BY date'; |
450 | 477 | } else { |
451 | 478 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
452 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
479 | + if ($liveinterval) { |
|
480 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
481 | + } |
|
453 | 482 | $query .= ' ORDER BY date'; |
454 | 483 | } |
455 | 484 | |
@@ -544,7 +573,9 @@ discard block |
||
544 | 573 | $i++; |
545 | 574 | $j++; |
546 | 575 | if ($j == 30) { |
547 | - if ($globalDebug) echo "."; |
|
576 | + if ($globalDebug) { |
|
577 | + echo "."; |
|
578 | + } |
|
548 | 579 | try { |
549 | 580 | |
550 | 581 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -824,7 +855,9 @@ discard block |
||
824 | 855 | { |
825 | 856 | return false; |
826 | 857 | } |
827 | - } else return ''; |
|
858 | + } else { |
|
859 | + return ''; |
|
860 | + } |
|
828 | 861 | |
829 | 862 | if ($longitude != '') |
830 | 863 | { |
@@ -832,7 +865,9 @@ discard block |
||
832 | 865 | { |
833 | 866 | return false; |
834 | 867 | } |
835 | - } else return ''; |
|
868 | + } else { |
|
869 | + return ''; |
|
870 | + } |
|
836 | 871 | |
837 | 872 | |
838 | 873 | if ($heading != '') |
@@ -841,7 +876,9 @@ discard block |
||
841 | 876 | { |
842 | 877 | return false; |
843 | 878 | } |
844 | - } else $heading = 0; |
|
879 | + } else { |
|
880 | + $heading = 0; |
|
881 | + } |
|
845 | 882 | |
846 | 883 | if ($groundspeed != '') |
847 | 884 | { |
@@ -849,9 +886,13 @@ discard block |
||
849 | 886 | { |
850 | 887 | return false; |
851 | 888 | } |
852 | - } else $groundspeed = 0; |
|
889 | + } else { |
|
890 | + $groundspeed = 0; |
|
891 | + } |
|
853 | 892 | date_default_timezone_set('UTC'); |
854 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
893 | + if ($date == '') { |
|
894 | + $date = date("Y-m-d H:i:s", time()); |
|
895 | + } |
|
855 | 896 | |
856 | 897 | |
857 | 898 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -872,12 +913,20 @@ discard block |
||
872 | 913 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
873 | 914 | |
874 | 915 | |
875 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
876 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
877 | - if ($arrival_date == '') $arrival_date = NULL; |
|
916 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
917 | + $groundspeed = 0; |
|
918 | + } |
|
919 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
920 | + $heading = 0; |
|
921 | + } |
|
922 | + if ($arrival_date == '') { |
|
923 | + $arrival_date = NULL; |
|
924 | + } |
|
878 | 925 | $query = ''; |
879 | 926 | if ($globalArchive) { |
880 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
927 | + if ($globalDebug) { |
|
928 | + echo '-- Delete previous data -- '; |
|
929 | + } |
|
881 | 930 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
882 | 931 | } |
883 | 932 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -892,10 +941,14 @@ discard block |
||
892 | 941 | } |
893 | 942 | |
894 | 943 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
895 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
944 | + if ($globalDebug) { |
|
945 | + echo '(Add to Marine archive : '; |
|
946 | + } |
|
896 | 947 | $MarineArchive = new MarineArchive($this->db); |
897 | 948 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
898 | - if ($globalDebug) echo $result.')'; |
|
949 | + if ($globalDebug) { |
|
950 | + echo $result.')'; |
|
951 | + } |
|
899 | 952 | } |
900 | 953 | return "success"; |
901 | 954 | } |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | public function __construct($dbc = null) { |
10 | 10 | $Connection = new Connection($dbc); |
11 | 11 | $this->db = $Connection->db(); |
12 | - if ($this->db === null) die('Error: No DB connection.'); |
|
12 | + if ($this->db === null) { |
|
13 | + die('Error: No DB connection.'); |
|
14 | + } |
|
13 | 15 | } |
14 | 16 | |
15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
26 | 28 | $reg = $registration; |
27 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
29 | + if ($reg == '' && $aircraft_icao != '') { |
|
30 | + $reg = $aircraft_icao.$airline_icao; |
|
31 | + } |
|
28 | 32 | $reg = trim($reg); |
29 | 33 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
32 | 36 | $sth = $this->db->prepare($query); |
33 | 37 | $sth->execute(array(':registration' => $reg)); |
34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | - if (!empty($result)) return $result; |
|
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
37 | - else return array(); |
|
39 | + if (!empty($result)) { |
|
40 | + return $result; |
|
41 | + } elseif ($registration != '') { |
|
42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
43 | + } else { |
|
44 | + return array(); |
|
45 | + } |
|
38 | 46 | } |
39 | 47 | |
40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
77 | 85 | public function getExifCopyright($url) { |
78 | 86 | $exif = exif_read_data($url); |
79 | 87 | $copyright = ''; |
80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
90 | + } elseif (isset($exif['copyright'])) { |
|
91 | + $copyright = $exif['copyright']; |
|
92 | + } |
|
82 | 93 | if ($copyright != '') { |
83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
97 | 108 | { |
98 | 109 | global $globalDebug,$globalAircraftImageFetch; |
99 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
110 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
111 | + return ''; |
|
112 | + } |
|
100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
101 | 114 | $registration = trim($registration); |
102 | 115 | //getting the aircraft image |
103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
116 | + if ($globalDebug && $registration != '') { |
|
117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
122 | + } |
|
106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
124 | + if ($registration == '' && $aircraft_icao != '') { |
|
125 | + $registration = $aircraft_icao.$airline_icao; |
|
126 | + } |
|
108 | 127 | if ($image_url['original'] != '') { |
109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
128 | + if ($globalDebug) { |
|
129 | + echo 'Found !'."\n"; |
|
130 | + } |
|
110 | 131 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
111 | 132 | try { |
112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
115 | 136 | echo $e->getMessage()."\n"; |
116 | 137 | return "error"; |
117 | 138 | } |
118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
139 | + } elseif ($globalDebug) { |
|
140 | + echo "Not found :'(\n"; |
|
141 | + } |
|
119 | 142 | return "success"; |
120 | 143 | } |
121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
129 | 152 | { |
130 | 153 | global $globalDebug,$globalMarineImageFetch; |
131 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
154 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
155 | + return ''; |
|
156 | + } |
|
132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
138 | 163 | $identity = $Marine->getIdentity($mmsi); |
139 | 164 | if (isset($identity[0]['mmsi'])) { |
140 | 165 | $imo = $identity[0]['imo']; |
141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
166 | + if ($identity[0]['ship_name'] != '') { |
|
167 | + $name = $identity[0]['ship_name']; |
|
168 | + } |
|
142 | 169 | } |
143 | 170 | } |
144 | 171 | unset($Marine); |
145 | 172 | |
146 | 173 | //getting the aircraft image |
147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
174 | + if ($globalDebug && $name != '') { |
|
175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
176 | + } |
|
148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
149 | 178 | if ($image_url['original'] != '') { |
150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo 'Found !'."\n"; |
|
181 | + } |
|
151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
152 | 183 | try { |
153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
156 | 187 | echo $e->getMessage()."\n"; |
157 | 188 | return "error"; |
158 | 189 | } |
159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
190 | + } elseif ($globalDebug) { |
|
191 | + echo "Not found :'(\n"; |
|
192 | + } |
|
160 | 193 | return "success"; |
161 | 194 | } |
162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
171 | 204 | { |
172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 206 | $Spotter = new Spotter($this->db); |
174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
207 | + if (!isset($globalIVAO)) { |
|
208 | + $globalIVAO = FALSE; |
|
209 | + } |
|
175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
176 | 211 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
214 | + } |
|
178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
181 | - else $aircraft_name = ''; |
|
182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
183 | - else $aircraft_icao = ''; |
|
184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
185 | - else $airline_icao = ''; |
|
217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
219 | + } else { |
|
220 | + $aircraft_name = ''; |
|
221 | + } |
|
222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
224 | + } else { |
|
225 | + $aircraft_icao = ''; |
|
226 | + } |
|
227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
229 | + } else { |
|
230 | + $airline_icao = ''; |
|
231 | + } |
|
186 | 232 | } elseif ($aircraft_icao != '') { |
187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
189 | - else $aircraft_name = ''; |
|
234 | + if (isset($aircraft_info[0]['type'])) { |
|
235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
236 | + } else { |
|
237 | + $aircraft_name = ''; |
|
238 | + } |
|
190 | 239 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
240 | + } else { |
|
241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
242 | + } |
|
192 | 243 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
244 | + if (!isset($globalAircraftImageSources)) { |
|
245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
246 | + } |
|
194 | 247 | foreach ($globalAircraftImageSources as $source) { |
195 | 248 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
207 | - } |
|
208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
251 | + } |
|
252 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
254 | + } |
|
255 | + if ($source == 'flickr') { |
|
256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
257 | + } |
|
258 | + if ($source == 'bing') { |
|
259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
260 | + } |
|
261 | + if ($source == 'deviantart') { |
|
262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
263 | + } |
|
264 | + if ($source == 'wikimedia') { |
|
265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
266 | + } |
|
267 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
269 | + } |
|
270 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
272 | + } |
|
273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
275 | + } |
|
276 | + if ($source == 'customsources') { |
|
277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
278 | + } |
|
279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
280 | + return $images_array; |
|
281 | + } |
|
282 | + } |
|
283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
284 | + return $this->findAircraftImage($aircraft_icao); |
|
285 | + } |
|
209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
210 | 287 | } |
211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
227 | 304 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
305 | + if (strlen($name) < 4) { |
|
306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
307 | + } |
|
229 | 308 | /* |
230 | 309 | $Marine = new Marine($this->db); |
231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
237 | 316 | } |
238 | 317 | unset($Marine); |
239 | 318 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
319 | + if (!isset($globalMarineImageSources)) { |
|
320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
321 | + } |
|
241 | 322 | foreach ($globalMarineImageSources as $source) { |
242 | 323 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
324 | + if ($source == 'flickr') { |
|
325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
326 | + } |
|
327 | + if ($source == 'bing') { |
|
328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
329 | + } |
|
330 | + if ($source == 'deviantart') { |
|
331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
332 | + } |
|
333 | + if ($source == 'wikimedia') { |
|
334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
335 | + } |
|
336 | + if ($source == 'customsources') { |
|
337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
338 | + } |
|
339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
340 | + return $images_array; |
|
341 | + } |
|
249 | 342 | } |
250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
251 | 344 | } |
@@ -409,11 +502,17 @@ discard block |
||
409 | 502 | public function fromFlickr($type,$registration,$name='') { |
410 | 503 | $Common = new Common(); |
411 | 504 | if ($type == 'aircraft') { |
412 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
413 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
505 | + if ($name != '') { |
|
506 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
507 | + } else { |
|
508 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
509 | + } |
|
414 | 510 | } elseif ($type == 'marine') { |
415 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
416 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
511 | + if ($name != '') { |
|
512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
513 | + } else { |
|
514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
515 | + } |
|
417 | 516 | } |
418 | 517 | $data = $Common->getData($url); |
419 | 518 | if ($xml = simplexml_load_string($data)) { |
@@ -458,13 +557,21 @@ discard block |
||
458 | 557 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
459 | 558 | global $globalImageBingKey; |
460 | 559 | $Common = new Common(); |
461 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
560 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
561 | + return false; |
|
562 | + } |
|
462 | 563 | if ($type == 'aircraft') { |
463 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
464 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
564 | + if ($aircraft_name != '') { |
|
565 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
566 | + } else { |
|
567 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
568 | + } |
|
465 | 569 | } elseif ($type == 'marine') { |
466 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
467 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
570 | + if ($aircraft_name != '') { |
|
571 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
572 | + } else { |
|
573 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
574 | + } |
|
468 | 575 | } |
469 | 576 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
470 | 577 | $data = $Common->getData($url,'get','',$headers); |
@@ -520,17 +627,25 @@ discard block |
||
520 | 627 | public function fromWikimedia($type,$registration,$name='') { |
521 | 628 | $Common = new Common(); |
522 | 629 | if ($type == 'aircraft') { |
523 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
524 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
630 | + if ($name != '') { |
|
631 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
632 | + } else { |
|
633 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
634 | + } |
|
525 | 635 | } elseif ($type == 'marine') { |
526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
527 | - else return false; |
|
636 | + if ($name != '') { |
|
637 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
638 | + } else { |
|
639 | + return false; |
|
640 | + } |
|
528 | 641 | } |
529 | 642 | $data = $Common->getData($url); |
530 | 643 | $result = json_decode($data); |
531 | 644 | if (isset($result->query->search[0]->title)) { |
532 | 645 | $fileo = $result->query->search[0]->title; |
533 | - if (substr($fileo,-3) == 'pdf') return false; |
|
646 | + if (substr($fileo,-3) == 'pdf') { |
|
647 | + return false; |
|
648 | + } |
|
534 | 649 | $file = urlencode($fileo); |
535 | 650 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
536 | 651 | $data2 = $Common->getData($url2); |
@@ -601,18 +716,27 @@ discard block |
||
601 | 716 | $image_url = array(); |
602 | 717 | $image_url['thumbnail'] = $url_thumbnail; |
603 | 718 | $image_url['original'] = $url; |
604 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
605 | - else $exifCopyright = ''; |
|
606 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
607 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
608 | - else $image_url['copyright'] = $source['source_website']; |
|
719 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
720 | + $exifCopyright = $this->getExifCopyright($url); |
|
721 | + } else { |
|
722 | + $exifCopyright = ''; |
|
723 | + } |
|
724 | + if ($exifCopyright != '') { |
|
725 | + $image_url['copyright'] = $exifCopyright; |
|
726 | + } elseif (isset($source['copyright'])) { |
|
727 | + $image_url['copyright'] = $source['copyright']; |
|
728 | + } else { |
|
729 | + $image_url['copyright'] = $source['source_website']; |
|
730 | + } |
|
609 | 731 | $image_url['source_website'] = $source['source_website']; |
610 | 732 | $image_url['source'] = $source['source']; |
611 | 733 | return $image_url; |
612 | 734 | } |
613 | 735 | } |
614 | 736 | return false; |
615 | - } else return false; |
|
737 | + } else { |
|
738 | + return false; |
|
739 | + } |
|
616 | 740 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
617 | 741 | $customsources = array(); |
618 | 742 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -637,18 +761,27 @@ discard block |
||
637 | 761 | $image_url = array(); |
638 | 762 | $image_url['thumbnail'] = $url_thumbnail; |
639 | 763 | $image_url['original'] = $url; |
640 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
641 | - else $exifCopyright = ''; |
|
642 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
643 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
644 | - else $image_url['copyright'] = $source['source_website']; |
|
764 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
765 | + $exifCopyright = $this->getExifCopyright($url); |
|
766 | + } else { |
|
767 | + $exifCopyright = ''; |
|
768 | + } |
|
769 | + if ($exifCopyright != '') { |
|
770 | + $image_url['copyright'] = $exifCopyright; |
|
771 | + } elseif (isset($source['copyright'])) { |
|
772 | + $image_url['copyright'] = $source['copyright']; |
|
773 | + } else { |
|
774 | + $image_url['copyright'] = $source['source_website']; |
|
775 | + } |
|
645 | 776 | $image_url['source_website'] = $source['source_website']; |
646 | 777 | $image_url['source'] = $source['source']; |
647 | 778 | return $image_url; |
648 | 779 | } |
649 | 780 | } |
650 | 781 | return false; |
651 | - } else return false; |
|
782 | + } else { |
|
783 | + return false; |
|
784 | + } |
|
652 | 785 | } |
653 | 786 | } |
654 | 787 |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | public function __construct($dbc = null) { |
8 | 8 | $Connection = new Connection($dbc); |
9 | 9 | $this->db = $Connection->db; |
10 | - if ($this->db === null) die('Error: No DB connection.'); |
|
10 | + if ($this->db === null) { |
|
11 | + die('Error: No DB connection.'); |
|
12 | + } |
|
11 | 13 | } |
12 | 14 | |
13 | 15 | public function getAllLocationInfo() { |
@@ -102,7 +104,9 @@ discard block |
||
102 | 104 | } |
103 | 105 | |
104 | 106 | public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
105 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
107 | + if ($last_seen == '') { |
|
108 | + $last_seen = date('Y-m-d H:i:s'); |
|
109 | + } |
|
106 | 110 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
107 | 111 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
108 | 112 | try { |
@@ -114,7 +118,9 @@ discard block |
||
114 | 118 | } |
115 | 119 | |
116 | 120 | public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
117 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
121 | + if ($last_seen == '') { |
|
122 | + $last_seen = date('Y-m-d H:i:s'); |
|
123 | + } |
|
118 | 124 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
119 | 125 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
120 | 126 | try { |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | } |
138 | 144 | |
139 | 145 | public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
140 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
146 | + if ($last_seen == '') { |
|
147 | + $last_seen = date('Y-m-d H:i:s'); |
|
148 | + } |
|
141 | 149 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
142 | 150 | $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
143 | 151 | try { |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | public function __construct($dbc = null,$fromACARSscript = false) { |
14 | 14 | $Connection = new Connection($dbc); |
15 | 15 | $this->db = $Connection->db(); |
16 | - if ($this->db === null) die('Error: No DB connection.'); |
|
16 | + if ($this->db === null) { |
|
17 | + die('Error: No DB connection.'); |
|
18 | + } |
|
17 | 19 | if ($fromACARSscript) { |
18 | 20 | $this->fromACARSscript = true; |
19 | 21 | $this->SI = new SpotterImport($this->db); |
@@ -27,14 +29,19 @@ discard block |
||
27 | 29 | */ |
28 | 30 | public function ident2icao($ident) { |
29 | 31 | if (substr($ident,0,2) == 'AF') { |
30 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
32 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
33 | + $icao = $ident; |
|
34 | + } else { |
|
35 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
36 | + } |
|
32 | 37 | } else { |
33 | 38 | $Spotter = new Spotter($this->db); |
34 | 39 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
35 | 40 | if (isset($identicao[0])) { |
36 | 41 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
37 | - } else $icao = $ident; |
|
42 | + } else { |
|
43 | + $icao = $ident; |
|
44 | + } |
|
38 | 45 | } |
39 | 46 | return $icao; |
40 | 47 | } |
@@ -107,14 +114,24 @@ discard block |
||
107 | 114 | $message = ''; |
108 | 115 | $result = array(); |
109 | 116 | $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
110 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
111 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
112 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
117 | + if ($n == 0) { |
|
118 | + $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
119 | + } |
|
120 | + if ($n == 0) { |
|
121 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
122 | + } |
|
123 | + if ($n == 0) { |
|
124 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
125 | + } |
|
113 | 126 | if ($n != 0) { |
114 | 127 | $registration = str_replace('.','',$registration); |
115 | 128 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
116 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
117 | - } else $message = $data; |
|
129 | + if ($globalDebug) { |
|
130 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
131 | + } |
|
132 | + } else { |
|
133 | + $message = $data; |
|
134 | + } |
|
118 | 135 | $decode = array(); |
119 | 136 | $found = false; |
120 | 137 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -134,12 +151,21 @@ discard block |
||
134 | 151 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
135 | 152 | $latitude = $la / 10000.0; |
136 | 153 | $longitude = $ln / 10000.0; |
137 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
138 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
154 | + if ($lac == 'S') { |
|
155 | + $latitude = '-'.$latitude; |
|
156 | + } |
|
157 | + if ($lnc == 'W') { |
|
158 | + $longitude = '-'.$longitude; |
|
159 | + } |
|
139 | 160 | // Temp not always available |
140 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
141 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
161 | + if ($globalDebug) { |
|
162 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
163 | + } |
|
164 | + if ($temp == '') { |
|
165 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
166 | + } else { |
|
167 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
168 | + } |
|
143 | 169 | |
144 | 170 | //$icao = $Translation->checkTranslation($ident); |
145 | 171 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -153,25 +179,35 @@ discard block |
||
153 | 179 | $ahour = ''; |
154 | 180 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
155 | 181 | if ($n == 4 && strlen($darr) == 4) { |
156 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
157 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
158 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
182 | + if ($dhour != '') { |
|
183 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
184 | + } |
|
185 | + if ($ahour != '') { |
|
186 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
187 | + } |
|
188 | + if ($globalDebug) { |
|
189 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
190 | + } |
|
159 | 191 | //$icao = ACARS->ident2icao($ident); |
160 | 192 | //$icao = $Translation->checkTranslation($ident); |
161 | 193 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
162 | 194 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
163 | 195 | $found = true; |
164 | - } |
|
165 | - elseif ($n == 2 || $n == 4) { |
|
166 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
167 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
196 | + } elseif ($n == 2 || $n == 4) { |
|
197 | + if ($dhour != '') { |
|
198 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
199 | + } |
|
200 | + if ($globalDebug) { |
|
201 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
202 | + } |
|
168 | 203 | //$icao = ACARS->ident2icao($ident); |
169 | 204 | //$icao = $Translation->checkTranslation($ident); |
170 | 205 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
171 | 206 | $found = true; |
172 | - } |
|
173 | - elseif ($n == 1) { |
|
174 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
207 | + } elseif ($n == 1) { |
|
208 | + if ($globalDebug) { |
|
209 | + echo 'airport arrival : '.$darr."\n"; |
|
210 | + } |
|
175 | 211 | //$icao = ACARS->ident2icao($ident); |
176 | 212 | //$icao = $Translation->checkTranslation($ident); |
177 | 213 | $decode = array('Arrival airport' => $darr); |
@@ -189,7 +225,9 @@ discard block |
||
189 | 225 | $darr = ''; |
190 | 226 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
191 | 227 | if ($n == 4) { |
192 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
230 | + } |
|
193 | 231 | //$icao = ACARS->ident2icao($ident); |
194 | 232 | //$icao = $Translation->checkTranslation($ident); |
195 | 233 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -223,14 +261,23 @@ discard block |
||
223 | 261 | $apiste = ''; |
224 | 262 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
225 | 263 | if ($n > 8) { |
226 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
228 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
264 | + if ($globalDebug) { |
|
265 | + echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
266 | + } |
|
267 | + if ($dhour != '') { |
|
268 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
269 | + } |
|
270 | + if ($ahour != '') { |
|
271 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
272 | + } |
|
229 | 273 | $icao = trim($aident); |
230 | 274 | |
231 | 275 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
232 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
233 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
276 | + if ($ahour == '') { |
|
277 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
278 | + } else { |
|
279 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
280 | + } |
|
234 | 281 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
235 | 282 | $decode['icao'] = $icao; |
236 | 283 | $found = true; |
@@ -252,9 +299,15 @@ discard block |
||
252 | 299 | $lns = $lns.'.'.$lns; |
253 | 300 | $latitude = $las / 1000.0; |
254 | 301 | $longitude = $lns / 1000.0; |
255 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
256 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
257 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
302 | + if ($lac == 'S') { |
|
303 | + $latitude = '-'.$latitude; |
|
304 | + } |
|
305 | + if ($lnc == 'W') { |
|
306 | + $longitude = '-'.$longitude; |
|
307 | + } |
|
308 | + if ($globalDebug) { |
|
309 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
310 | + } |
|
258 | 311 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
259 | 312 | $found = true; |
260 | 313 | } |
@@ -272,7 +325,9 @@ discard block |
||
272 | 325 | $darr = ''; |
273 | 326 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
274 | 327 | if ($n == 4) { |
275 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
328 | + if ($globalDebug) { |
|
329 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
330 | + } |
|
276 | 331 | //$icao = $Translation->checkTranslation($ident); |
277 | 332 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
278 | 333 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -285,7 +340,9 @@ discard block |
||
285 | 340 | $darr = ''; |
286 | 341 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
287 | 342 | if ($n == 4) { |
288 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
343 | + if ($globalDebug) { |
|
344 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
345 | + } |
|
289 | 346 | //$icao = $Translation->checkTranslation($ident); |
290 | 347 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
291 | 348 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -298,7 +355,9 @@ discard block |
||
298 | 355 | $darr = ''; |
299 | 356 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
300 | 357 | if ($n == 2) { |
301 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
358 | + if ($globalDebug) { |
|
359 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
360 | + } |
|
302 | 361 | //$icao = $Translation->checkTranslation($ident); |
303 | 362 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
304 | 363 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -312,7 +371,9 @@ discard block |
||
312 | 371 | $darr = ''; |
313 | 372 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
314 | 373 | if ($n == 6) { |
315 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
374 | + if ($globalDebug) { |
|
375 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
376 | + } |
|
316 | 377 | //$icao = $Translation->checkTranslation($ident); |
317 | 378 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
318 | 379 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -325,7 +386,9 @@ discard block |
||
325 | 386 | $darr = ''; |
326 | 387 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
327 | 388 | if ($n == 7) { |
328 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
389 | + if ($globalDebug) { |
|
390 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
391 | + } |
|
329 | 392 | //$icao = $Translation->checkTranslation($ident); |
330 | 393 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
331 | 394 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -353,8 +416,12 @@ discard block |
||
353 | 416 | $decode['icao'] = $icao; |
354 | 417 | $latitude = $las / 100.0; |
355 | 418 | $longitude = $lns / 100.0; |
356 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
357 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
419 | + if ($lac == 'S') { |
|
420 | + $latitude = '-'.$latitude; |
|
421 | + } |
|
422 | + if ($lnc == 'W') { |
|
423 | + $longitude = '-'.$longitude; |
|
424 | + } |
|
358 | 425 | |
359 | 426 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
360 | 427 | $found = true; |
@@ -372,8 +439,12 @@ discard block |
||
372 | 439 | if ($n == 4) { |
373 | 440 | $latitude = $las; |
374 | 441 | $longitude = $lns; |
375 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
376 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
442 | + if ($lac == 'S') { |
|
443 | + $latitude = '-'.$latitude; |
|
444 | + } |
|
445 | + if ($lnc == 'W') { |
|
446 | + $longitude = '-'.$longitude; |
|
447 | + } |
|
377 | 448 | |
378 | 449 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
379 | 450 | $found = true; |
@@ -389,7 +460,9 @@ discard block |
||
389 | 460 | $darr = ''; |
390 | 461 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
391 | 462 | if ($n == 5) { |
392 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
463 | + if ($globalDebug) { |
|
464 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
465 | + } |
|
393 | 466 | //$icao = $Translation->checkTranslation($ident); |
394 | 467 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
395 | 468 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -410,7 +483,9 @@ discard block |
||
410 | 483 | $aident = ''; |
411 | 484 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
412 | 485 | if ($n == 8) { |
413 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
486 | + if ($globalDebug) { |
|
487 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
488 | + } |
|
414 | 489 | $icao = trim($aident); |
415 | 490 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
416 | 491 | $decode['icao'] = $icao; |
@@ -427,7 +502,9 @@ discard block |
||
427 | 502 | $darr = ''; |
428 | 503 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
429 | 504 | if ($n == 5) { |
430 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
505 | + if ($globalDebug) { |
|
506 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
507 | + } |
|
431 | 508 | //$icao = $Translation->checkTranslation($ident); |
432 | 509 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
433 | 510 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -442,7 +519,9 @@ discard block |
||
442 | 519 | $darr = ''; |
443 | 520 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
444 | 521 | if ($n == 3) { |
445 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
522 | + if ($globalDebug) { |
|
523 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
524 | + } |
|
446 | 525 | //$icao = $Translation->checkTranslation($ident); |
447 | 526 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
448 | 527 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -457,7 +536,9 @@ discard block |
||
457 | 536 | $darr = ''; |
458 | 537 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
459 | 538 | if ($n == 3) { |
460 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
539 | + if ($globalDebug) { |
|
540 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
541 | + } |
|
461 | 542 | //$icao = $Translation->checkTranslation($ident); |
462 | 543 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
463 | 544 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -467,7 +548,9 @@ discard block |
||
467 | 548 | if (!$found) { |
468 | 549 | $n = sscanf($message,'MET01%4c',$airport); |
469 | 550 | if ($n == 1) { |
470 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
551 | + if ($globalDebug) { |
|
552 | + echo 'airport name : '.$airport; |
|
553 | + } |
|
471 | 554 | $decode = array('Airport/Waypoint name' => $airport); |
472 | 555 | $found = true; |
473 | 556 | } |
@@ -475,184 +558,126 @@ discard block |
||
475 | 558 | if ($label == 'H1') { |
476 | 559 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
477 | 560 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
478 | - } |
|
479 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
561 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
480 | 562 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
481 | - } |
|
482 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
563 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
483 | 564 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
484 | - } |
|
485 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
565 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
486 | 566 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
487 | - } |
|
488 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
567 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
489 | 568 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
490 | - } |
|
491 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
569 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
492 | 570 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
493 | - } |
|
494 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
571 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
495 | 572 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
496 | - } |
|
497 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
573 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
498 | 574 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
499 | - } |
|
500 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
575 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
501 | 576 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
502 | - } |
|
503 | - elseif (preg_match(':^#CF:',$message)) { |
|
577 | + } elseif (preg_match(':^#CF:',$message)) { |
|
504 | 578 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
505 | - } |
|
506 | - elseif (preg_match(':^#DF:',$message)) { |
|
579 | + } elseif (preg_match(':^#DF:',$message)) { |
|
507 | 580 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
508 | - } |
|
509 | - elseif (preg_match(':^#EC:',$message)) { |
|
581 | + } elseif (preg_match(':^#EC:',$message)) { |
|
510 | 582 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
511 | - } |
|
512 | - elseif (preg_match(':^#EI:',$message)) { |
|
583 | + } elseif (preg_match(':^#EI:',$message)) { |
|
513 | 584 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
514 | - } |
|
515 | - elseif (preg_match(':^#H1:',$message)) { |
|
585 | + } elseif (preg_match(':^#H1:',$message)) { |
|
516 | 586 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
517 | - } |
|
518 | - elseif (preg_match(':^#H2:',$message)) { |
|
587 | + } elseif (preg_match(':^#H2:',$message)) { |
|
519 | 588 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
520 | - } |
|
521 | - elseif (preg_match(':^#HD:',$message)) { |
|
589 | + } elseif (preg_match(':^#HD:',$message)) { |
|
522 | 590 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
523 | - } |
|
524 | - elseif (preg_match(':^#M1:',$message)) { |
|
591 | + } elseif (preg_match(':^#M1:',$message)) { |
|
525 | 592 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
526 | - } |
|
527 | - elseif (preg_match(':^#M2:',$message)) { |
|
593 | + } elseif (preg_match(':^#M2:',$message)) { |
|
528 | 594 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
529 | - } |
|
530 | - elseif (preg_match(':^#M3:',$message)) { |
|
595 | + } elseif (preg_match(':^#M3:',$message)) { |
|
531 | 596 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
532 | - } |
|
533 | - elseif (preg_match(':^#MD:',$message)) { |
|
597 | + } elseif (preg_match(':^#MD:',$message)) { |
|
534 | 598 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
535 | - } |
|
536 | - elseif (preg_match(':^#PS:',$message)) { |
|
599 | + } elseif (preg_match(':^#PS:',$message)) { |
|
537 | 600 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
538 | - } |
|
539 | - elseif (preg_match(':^#S1:',$message)) { |
|
601 | + } elseif (preg_match(':^#S1:',$message)) { |
|
540 | 602 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
541 | - } |
|
542 | - elseif (preg_match(':^#S2:',$message)) { |
|
603 | + } elseif (preg_match(':^#S2:',$message)) { |
|
543 | 604 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
544 | - } |
|
545 | - elseif (preg_match(':^#SD:',$message)) { |
|
605 | + } elseif (preg_match(':^#SD:',$message)) { |
|
546 | 606 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
547 | - } |
|
548 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
607 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
549 | 608 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
550 | - } |
|
551 | - elseif (preg_match(':^#WO:',$message)) { |
|
609 | + } elseif (preg_match(':^#WO:',$message)) { |
|
552 | 610 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
553 | - } |
|
554 | - elseif (preg_match(':^#A1:',$message)) { |
|
611 | + } elseif (preg_match(':^#A1:',$message)) { |
|
555 | 612 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
556 | - } |
|
557 | - elseif (preg_match(':^#A3:',$message)) { |
|
613 | + } elseif (preg_match(':^#A3:',$message)) { |
|
558 | 614 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
559 | - } |
|
560 | - elseif (preg_match(':^#A4:',$message)) { |
|
615 | + } elseif (preg_match(':^#A4:',$message)) { |
|
561 | 616 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
562 | - } |
|
563 | - elseif (preg_match(':^#A6:',$message)) { |
|
617 | + } elseif (preg_match(':^#A6:',$message)) { |
|
564 | 618 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
565 | - } |
|
566 | - elseif (preg_match(':^#A8:',$message)) { |
|
619 | + } elseif (preg_match(':^#A8:',$message)) { |
|
567 | 620 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
568 | - } |
|
569 | - elseif (preg_match(':^#A9:',$message)) { |
|
621 | + } elseif (preg_match(':^#A9:',$message)) { |
|
570 | 622 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
571 | - } |
|
572 | - elseif (preg_match(':^#A0:',$message)) { |
|
623 | + } elseif (preg_match(':^#A0:',$message)) { |
|
573 | 624 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
574 | - } |
|
575 | - elseif (preg_match(':^#AA:',$message)) { |
|
625 | + } elseif (preg_match(':^#AA:',$message)) { |
|
576 | 626 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
577 | - } |
|
578 | - elseif (preg_match(':^#AB:',$message)) { |
|
627 | + } elseif (preg_match(':^#AB:',$message)) { |
|
579 | 628 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
580 | - } |
|
581 | - elseif (preg_match(':^#AC:',$message)) { |
|
629 | + } elseif (preg_match(':^#AC:',$message)) { |
|
582 | 630 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
583 | - } |
|
584 | - elseif (preg_match(':^#AD:',$message)) { |
|
631 | + } elseif (preg_match(':^#AD:',$message)) { |
|
585 | 632 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
586 | - } |
|
587 | - elseif (preg_match(':^#AF:',$message)) { |
|
633 | + } elseif (preg_match(':^#AF:',$message)) { |
|
588 | 634 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
589 | - } |
|
590 | - elseif (preg_match(':^#B1:',$message)) { |
|
635 | + } elseif (preg_match(':^#B1:',$message)) { |
|
591 | 636 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
592 | - } |
|
593 | - elseif (preg_match(':^#B2:',$message)) { |
|
637 | + } elseif (preg_match(':^#B2:',$message)) { |
|
594 | 638 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
595 | - } |
|
596 | - elseif (preg_match(':^#B3:',$message)) { |
|
639 | + } elseif (preg_match(':^#B3:',$message)) { |
|
597 | 640 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
598 | - } |
|
599 | - elseif (preg_match(':^#B4:',$message)) { |
|
641 | + } elseif (preg_match(':^#B4:',$message)) { |
|
600 | 642 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
601 | - } |
|
602 | - elseif (preg_match(':^#B6:',$message)) { |
|
643 | + } elseif (preg_match(':^#B6:',$message)) { |
|
603 | 644 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
604 | - } |
|
605 | - elseif (preg_match(':^#B8:',$message)) { |
|
645 | + } elseif (preg_match(':^#B8:',$message)) { |
|
606 | 646 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
607 | - } |
|
608 | - elseif (preg_match(':^#B9:',$message)) { |
|
647 | + } elseif (preg_match(':^#B9:',$message)) { |
|
609 | 648 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
610 | - } |
|
611 | - elseif (preg_match(':^#B0:',$message)) { |
|
649 | + } elseif (preg_match(':^#B0:',$message)) { |
|
612 | 650 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
613 | - } |
|
614 | - elseif (preg_match(':^#BA:',$message)) { |
|
651 | + } elseif (preg_match(':^#BA:',$message)) { |
|
615 | 652 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
616 | - } |
|
617 | - elseif (preg_match(':^#BB:',$message)) { |
|
653 | + } elseif (preg_match(':^#BB:',$message)) { |
|
618 | 654 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
619 | - } |
|
620 | - elseif (preg_match(':^#BC:',$message)) { |
|
655 | + } elseif (preg_match(':^#BC:',$message)) { |
|
621 | 656 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
622 | - } |
|
623 | - elseif (preg_match(':^#BD:',$message)) { |
|
657 | + } elseif (preg_match(':^#BD:',$message)) { |
|
624 | 658 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
625 | - } |
|
626 | - elseif (preg_match(':^#BE:',$message)) { |
|
659 | + } elseif (preg_match(':^#BE:',$message)) { |
|
627 | 660 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
628 | - } |
|
629 | - elseif (preg_match(':^#BF:',$message)) { |
|
661 | + } elseif (preg_match(':^#BF:',$message)) { |
|
630 | 662 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
631 | - } |
|
632 | - elseif (preg_match(':^#H3:',$message)) { |
|
663 | + } elseif (preg_match(':^#H3:',$message)) { |
|
633 | 664 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
634 | 665 | } |
635 | 666 | } |
636 | 667 | if ($label == '10') { |
637 | 668 | if (preg_match(':^DTO01:',$message)) { |
638 | 669 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
639 | - } |
|
640 | - elseif (preg_match(':^AIS01:',$message)) { |
|
670 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
641 | 671 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
642 | - } |
|
643 | - elseif (preg_match(':^FTX01:',$message)) { |
|
672 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
644 | 673 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
645 | - } |
|
646 | - elseif (preg_match(':^FPL01:',$message)) { |
|
674 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
647 | 675 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
648 | - } |
|
649 | - elseif (preg_match(':^WAB01:',$message)) { |
|
676 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
650 | 677 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
651 | - } |
|
652 | - elseif (preg_match(':^MET01:',$message)) { |
|
678 | + } elseif (preg_match(':^MET01:',$message)) { |
|
653 | 679 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
654 | - } |
|
655 | - elseif (preg_match(':^WAB02:',$message)) { |
|
680 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
656 | 681 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
657 | 682 | } |
658 | 683 | } |
@@ -667,38 +692,28 @@ discard block |
||
667 | 692 | $vsta = array('Version' => $version); |
668 | 693 | if ($state == 'E') { |
669 | 694 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
670 | - } |
|
671 | - elseif ($state == 'L') { |
|
695 | + } elseif ($state == 'L') { |
|
672 | 696 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
673 | - } |
|
674 | - else { |
|
697 | + } else { |
|
675 | 698 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
676 | 699 | } |
677 | 700 | if ($type == 'V') { |
678 | 701 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
679 | - } |
|
680 | - elseif ($type == 'S') { |
|
702 | + } elseif ($type == 'S') { |
|
681 | 703 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
682 | - } |
|
683 | - elseif ($type == 'H') { |
|
704 | + } elseif ($type == 'H') { |
|
684 | 705 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
685 | - } |
|
686 | - elseif ($type == 'G') { |
|
706 | + } elseif ($type == 'G') { |
|
687 | 707 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
688 | - } |
|
689 | - elseif ($type == 'C') { |
|
708 | + } elseif ($type == 'C') { |
|
690 | 709 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
691 | - } |
|
692 | - elseif ($type == '2') { |
|
710 | + } elseif ($type == '2') { |
|
693 | 711 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
694 | - } |
|
695 | - elseif ($type == 'X') { |
|
712 | + } elseif ($type == 'X') { |
|
696 | 713 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
697 | - } |
|
698 | - elseif ($type == 'I') { |
|
714 | + } elseif ($type == 'I') { |
|
699 | 715 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
700 | - } |
|
701 | - else { |
|
716 | + } else { |
|
702 | 717 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
703 | 718 | } |
704 | 719 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -707,7 +722,9 @@ discard block |
||
707 | 722 | } |
708 | 723 | |
709 | 724 | $title = $this->getTitlefromLabel($label); |
710 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
725 | + if ($title != '') { |
|
726 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
727 | + } |
|
711 | 728 | /* |
712 | 729 | // Business jets always use GS0001 |
713 | 730 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -742,31 +759,54 @@ discard block |
||
742 | 759 | $msg = $message['message']; |
743 | 760 | $decode = $message['decode']; |
744 | 761 | $registration = (string)$message['registration']; |
745 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
746 | - else $latitude = ''; |
|
747 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
748 | - else $longitude = ''; |
|
749 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
750 | - else $airicao = ''; |
|
751 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
752 | - else $icao = $Translation->checkTranslation($ident); |
|
762 | + if (isset($decode['latitude'])) { |
|
763 | + $latitude = $decode['latitude']; |
|
764 | + } else { |
|
765 | + $latitude = ''; |
|
766 | + } |
|
767 | + if (isset($decode['longitude'])) { |
|
768 | + $longitude = $decode['longitude']; |
|
769 | + } else { |
|
770 | + $longitude = ''; |
|
771 | + } |
|
772 | + if (isset($decode['airicao'])) { |
|
773 | + $airicao = $decode['airicao']; |
|
774 | + } else { |
|
775 | + $airicao = ''; |
|
776 | + } |
|
777 | + if (isset($decode['icao'])) { |
|
778 | + $icao = $decode['icao']; |
|
779 | + } else { |
|
780 | + $icao = $Translation->checkTranslation($ident); |
|
781 | + } |
|
753 | 782 | $image_array = $Image->getSpotterImage($registration); |
754 | 783 | if (!isset($image_array[0]['registration'])) { |
755 | 784 | $Image->addSpotterImage($registration); |
756 | 785 | } |
757 | 786 | // Business jets always use GS0001 |
758 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
759 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
760 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
761 | - else $decode_json = ''; |
|
787 | + if ($ident != 'GS0001') { |
|
788 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
789 | + } |
|
790 | + if ($globalDebug && isset($info) && $info != '') { |
|
791 | + echo $info; |
|
792 | + } |
|
793 | + if (count($decode) > 0) { |
|
794 | + $decode_json = json_encode($decode); |
|
795 | + } else { |
|
796 | + $decode_json = ''; |
|
797 | + } |
|
762 | 798 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
763 | 799 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
764 | 800 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
765 | 801 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
766 | 802 | } |
767 | 803 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
768 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
769 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
804 | + if (!isset($globalACARSArchive)) { |
|
805 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
806 | + } |
|
807 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
808 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
809 | + } |
|
770 | 810 | if ($globalDebug && count($decode) > 0) { |
771 | 811 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
772 | 812 | } |
@@ -789,7 +829,9 @@ discard block |
||
789 | 829 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
790 | 830 | $Connection = new Connection($this->db); |
791 | 831 | $this->db = $Connection->db; |
792 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
832 | + if ($globalDebug) { |
|
833 | + echo "Test if not already in Live ACARS table..."; |
|
834 | + } |
|
793 | 835 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
794 | 836 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
795 | 837 | try { |
@@ -799,7 +841,9 @@ discard block |
||
799 | 841 | return "error : ".$e->getMessage(); |
800 | 842 | } |
801 | 843 | if ($stht->fetchColumn() == 0) { |
802 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
844 | + if ($globalDebug) { |
|
845 | + echo "Add Live ACARS data..."; |
|
846 | + } |
|
803 | 847 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
804 | 848 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
805 | 849 | try { |
@@ -809,10 +853,14 @@ discard block |
||
809 | 853 | return "error : ".$e->getMessage(); |
810 | 854 | } |
811 | 855 | } else { |
812 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
856 | + if ($globalDebug) { |
|
857 | + echo "Data already in DB...\n"; |
|
858 | + } |
|
813 | 859 | return false; |
814 | 860 | } |
815 | - if ($globalDebug) echo "Done\n"; |
|
861 | + if ($globalDebug) { |
|
862 | + echo "Done\n"; |
|
863 | + } |
|
816 | 864 | return true; |
817 | 865 | } |
818 | 866 | } |
@@ -843,7 +891,9 @@ discard block |
||
843 | 891 | } |
844 | 892 | if ($stht->fetchColumn() == 0) { |
845 | 893 | */ |
846 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
894 | + if ($globalDebug) { |
|
895 | + echo "Add Live ACARS data..."; |
|
896 | + } |
|
847 | 897 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
848 | 898 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
849 | 899 | try { |
@@ -852,7 +902,9 @@ discard block |
||
852 | 902 | } catch(PDOException $e) { |
853 | 903 | return "error : ".$e->getMessage(); |
854 | 904 | } |
855 | - if ($globalDebug) echo "Done\n"; |
|
905 | + if ($globalDebug) { |
|
906 | + echo "Done\n"; |
|
907 | + } |
|
856 | 908 | } |
857 | 909 | } |
858 | 910 | |
@@ -875,8 +927,11 @@ discard block |
||
875 | 927 | return ''; |
876 | 928 | } |
877 | 929 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
878 | - if (count($row) > 0) return $row[0]['title']; |
|
879 | - else return ''; |
|
930 | + if (count($row) > 0) { |
|
931 | + return $row[0]['title']; |
|
932 | + } else { |
|
933 | + return ''; |
|
934 | + } |
|
880 | 935 | } |
881 | 936 | |
882 | 937 | /** |
@@ -895,8 +950,11 @@ discard block |
||
895 | 950 | return array(); |
896 | 951 | } |
897 | 952 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
898 | - if (count($row) > 0) return $row; |
|
899 | - else return array(); |
|
953 | + if (count($row) > 0) { |
|
954 | + return $row; |
|
955 | + } else { |
|
956 | + return array(); |
|
957 | + } |
|
900 | 958 | } |
901 | 959 | |
902 | 960 | /** |
@@ -916,8 +974,11 @@ discard block |
||
916 | 974 | return array(); |
917 | 975 | } |
918 | 976 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
919 | - if (count($row) > 0) return $row[0]; |
|
920 | - else return array(); |
|
977 | + if (count($row) > 0) { |
|
978 | + return $row[0]; |
|
979 | + } else { |
|
980 | + return array(); |
|
981 | + } |
|
921 | 982 | } |
922 | 983 | |
923 | 984 | /** |
@@ -962,19 +1023,35 @@ discard block |
||
962 | 1023 | if ($row['registration'] != '') { |
963 | 1024 | $row['registration'] = str_replace('.','',$row['registration']); |
964 | 1025 | $image_array = $Image->getSpotterImage($row['registration']); |
965 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
966 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
967 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
968 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
969 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1026 | + if (count($image_array) > 0) { |
|
1027 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1028 | + } else { |
|
1029 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1030 | + } |
|
1031 | + } else { |
|
1032 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1033 | + } |
|
1034 | + if ($row['registration'] == '') { |
|
1035 | + $row['registration'] = 'NA'; |
|
1036 | + } |
|
1037 | + if ($row['ident'] == '') { |
|
1038 | + $row['ident'] = 'NA'; |
|
1039 | + } |
|
970 | 1040 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
971 | 1041 | if (isset($identicao[0])) { |
972 | 1042 | if (substr($row['ident'],0,2) == 'AF') { |
973 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
975 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1043 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1044 | + $icao = $row['ident']; |
|
1045 | + } else { |
|
1046 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1047 | + } |
|
1048 | + } else { |
|
1049 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1050 | + } |
|
976 | 1051 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
977 | - } else $icao = $row['ident']; |
|
1052 | + } else { |
|
1053 | + $icao = $row['ident']; |
|
1054 | + } |
|
978 | 1055 | $icao = $Translation->checkTranslation($icao,false); |
979 | 1056 | $decode = json_decode($row['decode'],true); |
980 | 1057 | $found = false; |
@@ -999,7 +1076,9 @@ discard block |
||
999 | 1076 | $found = true; |
1000 | 1077 | } |
1001 | 1078 | } |
1002 | - if ($found) $row['decode'] = json_encode($decode); |
|
1079 | + if ($found) { |
|
1080 | + $row['decode'] = json_encode($decode); |
|
1081 | + } |
|
1003 | 1082 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1004 | 1083 | $result[] = $data; |
1005 | 1084 | $i++; |
@@ -1007,8 +1086,9 @@ discard block |
||
1007 | 1086 | if (isset($result)) { |
1008 | 1087 | $result[0]['query_number_rows'] = $i; |
1009 | 1088 | return $result; |
1089 | + } else { |
|
1090 | + return array(); |
|
1010 | 1091 | } |
1011 | - else return array(); |
|
1012 | 1092 | } |
1013 | 1093 | |
1014 | 1094 | /** |
@@ -1057,31 +1137,51 @@ discard block |
||
1057 | 1137 | if ($row['registration'] != '') { |
1058 | 1138 | $row['registration'] = str_replace('.','',$row['registration']); |
1059 | 1139 | $image_array = $Image->getSpotterImage($row['registration']); |
1060 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1061 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1062 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1140 | + if (count($image_array) > 0) { |
|
1141 | + $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1142 | + } else { |
|
1143 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1144 | + } |
|
1145 | + } else { |
|
1146 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1147 | + } |
|
1063 | 1148 | $icao = ''; |
1064 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1065 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1149 | + if ($row['registration'] == '') { |
|
1150 | + $row['registration'] = 'NA'; |
|
1151 | + } |
|
1152 | + if ($row['ident'] == '') { |
|
1153 | + $row['ident'] = 'NA'; |
|
1154 | + } |
|
1066 | 1155 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1067 | 1156 | if (isset($identicao[0])) { |
1068 | 1157 | if (substr($row['ident'],0,2) == 'AF') { |
1069 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1071 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1158 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1159 | + $icao = $row['ident']; |
|
1160 | + } else { |
|
1161 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1162 | + } |
|
1163 | + } else { |
|
1164 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1165 | + } |
|
1072 | 1166 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1073 | - } else $icao = $row['ident']; |
|
1167 | + } else { |
|
1168 | + $icao = $row['ident']; |
|
1169 | + } |
|
1074 | 1170 | $icao = $Translation->checkTranslation($icao); |
1075 | 1171 | $decode = json_decode($row['decode'],true); |
1076 | 1172 | $found = false; |
1077 | 1173 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1078 | 1174 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1079 | - if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1175 | + if (isset($airport_info[0]['icao'])) { |
|
1176 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1177 | + } |
|
1080 | 1178 | $found = true; |
1081 | 1179 | } |
1082 | 1180 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1083 | 1181 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1084 | - if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1182 | + if (isset($airport_info[0]['icao'])) { |
|
1183 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1184 | + } |
|
1085 | 1185 | $found = true; |
1086 | 1186 | } |
1087 | 1187 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1091,7 +1191,9 @@ discard block |
||
1091 | 1191 | $found = true; |
1092 | 1192 | } |
1093 | 1193 | } |
1094 | - if ($found) $row['decode'] = json_encode($decode); |
|
1194 | + if ($found) { |
|
1195 | + $row['decode'] = json_encode($decode); |
|
1196 | + } |
|
1095 | 1197 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1096 | 1198 | $result[] = $data; |
1097 | 1199 | $i++; |
@@ -1099,7 +1201,9 @@ discard block |
||
1099 | 1201 | if (isset($result)) { |
1100 | 1202 | $result[0]['query_number_rows'] = $i; |
1101 | 1203 | return $result; |
1102 | - } else return array(); |
|
1204 | + } else { |
|
1205 | + return array(); |
|
1206 | + } |
|
1103 | 1207 | } |
1104 | 1208 | |
1105 | 1209 | /** |
@@ -1115,25 +1219,37 @@ discard block |
||
1115 | 1219 | $ident = trim($ident); |
1116 | 1220 | $Translation = new Translation($this->db); |
1117 | 1221 | $Spotter = new Spotter($this->db); |
1118 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1222 | + if ($globalDebug) { |
|
1223 | + echo "Test if we add ModeS data..."; |
|
1224 | + } |
|
1119 | 1225 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1120 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1121 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1226 | + if ($icao == '') { |
|
1227 | + $icao = $Translation->checkTranslation($ident); |
|
1228 | + } |
|
1229 | + if ($globalDebug) { |
|
1230 | + echo '- Ident : '.$icao.' - '; |
|
1231 | + } |
|
1122 | 1232 | if ($ident == '' || $registration == '') { |
1123 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1233 | + if ($globalDebug) { |
|
1234 | + echo "Ident or registration null, exit\n"; |
|
1235 | + } |
|
1124 | 1236 | return ''; |
1125 | 1237 | } |
1126 | 1238 | $registration = str_replace('.','',$registration); |
1127 | 1239 | $ident = $Translation->ident2icao($ident); |
1128 | 1240 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1129 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1241 | + if ($globalDebug) { |
|
1242 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1243 | + } |
|
1130 | 1244 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
1131 | 1245 | $querysi_values = array(':registration' => $registration); |
1132 | 1246 | try { |
1133 | 1247 | $sthsi = $this->db->prepare($querysi); |
1134 | 1248 | $sthsi->execute($querysi_values); |
1135 | 1249 | } catch(PDOException $e) { |
1136 | - if ($globalDebug) echo $e->getMessage(); |
|
1250 | + if ($globalDebug) { |
|
1251 | + echo $e->getMessage(); |
|
1252 | + } |
|
1137 | 1253 | return "error : ".$e->getMessage(); |
1138 | 1254 | } |
1139 | 1255 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1141,9 +1257,14 @@ discard block |
||
1141 | 1257 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1142 | 1258 | $Translation = new Translation($this->db); |
1143 | 1259 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1144 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1145 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1146 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1260 | + if ($globalDebug) { |
|
1261 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1262 | + } |
|
1263 | + if ($ident != $trans_ident) { |
|
1264 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1265 | + } elseif ($trans_ident == $ident) { |
|
1266 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1267 | + } |
|
1147 | 1268 | } else { |
1148 | 1269 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1149 | 1270 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1152,32 +1273,46 @@ discard block |
||
1152 | 1273 | $sth = $this->db->prepare($query); |
1153 | 1274 | $sth->execute($query_values); |
1154 | 1275 | } catch(PDOException $e) { |
1155 | - if ($globalDebug) echo $e->getMessage(); |
|
1276 | + if ($globalDebug) { |
|
1277 | + echo $e->getMessage(); |
|
1278 | + } |
|
1156 | 1279 | return "error : ".$e->getMessage(); |
1157 | 1280 | } |
1158 | 1281 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1159 | 1282 | $sth->closeCursor(); |
1160 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1161 | - else $hex = ''; |
|
1283 | + if (isset($result['modes'])) { |
|
1284 | + $hex = $result['modes']; |
|
1285 | + } else { |
|
1286 | + $hex = ''; |
|
1287 | + } |
|
1162 | 1288 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1163 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
1289 | + if ($this->fromACARSscript) { |
|
1290 | + $this->SI->add($SI_data); |
|
1291 | + } |
|
1164 | 1292 | } |
1165 | 1293 | } |
1166 | - if ($globalDebug) echo 'Done'."\n"; |
|
1294 | + if ($globalDebug) { |
|
1295 | + echo 'Done'."\n"; |
|
1296 | + } |
|
1167 | 1297 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1168 | 1298 | $query_values = array(':ident' => $icao); |
1169 | 1299 | try { |
1170 | 1300 | $sth = $this->db->prepare($query); |
1171 | 1301 | $sth->execute($query_values); |
1172 | 1302 | } catch(PDOException $e) { |
1173 | - if ($globalDebug) echo $e->getMessage(); |
|
1303 | + if ($globalDebug) { |
|
1304 | + echo $e->getMessage(); |
|
1305 | + } |
|
1174 | 1306 | return "error : ".$e->getMessage(); |
1175 | 1307 | } |
1176 | 1308 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1177 | 1309 | $sth->closeCursor(); |
1178 | 1310 | if (isset($result['flightaware_id'])) { |
1179 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1180 | - else $ModeS = ''; |
|
1311 | + if (isset($result['ModeS'])) { |
|
1312 | + $ModeS = $result['ModeS']; |
|
1313 | + } else { |
|
1314 | + $ModeS = ''; |
|
1315 | + } |
|
1181 | 1316 | if ($ModeS == '') { |
1182 | 1317 | $id = explode('-',$result['flightaware_id']); |
1183 | 1318 | $ModeS = $id[0]; |
@@ -1190,24 +1325,32 @@ discard block |
||
1190 | 1325 | $sthc = $this->db->prepare($queryc); |
1191 | 1326 | $sthc->execute($queryc_values); |
1192 | 1327 | } catch(PDOException $e) { |
1193 | - if ($globalDebug) echo $e->getMessage(); |
|
1328 | + if ($globalDebug) { |
|
1329 | + echo $e->getMessage(); |
|
1330 | + } |
|
1194 | 1331 | return "error : ".$e->getMessage(); |
1195 | 1332 | } |
1196 | 1333 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1197 | 1334 | $sthc->closeCursor(); |
1198 | 1335 | if (count($row) == 0) { |
1199 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1336 | + if ($globalDebug) { |
|
1337 | + echo " Add to ModeS table - "; |
|
1338 | + } |
|
1200 | 1339 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1201 | 1340 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1202 | 1341 | try { |
1203 | 1342 | $sthi = $this->db->prepare($queryi); |
1204 | 1343 | $sthi->execute($queryi_values); |
1205 | 1344 | } catch(PDOException $e) { |
1206 | - if ($globalDebug) echo $e->getMessage(); |
|
1345 | + if ($globalDebug) { |
|
1346 | + echo $e->getMessage(); |
|
1347 | + } |
|
1207 | 1348 | return "error : ".$e->getMessage(); |
1208 | 1349 | } |
1209 | 1350 | } else { |
1210 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1351 | + if ($globalDebug) { |
|
1352 | + echo " Update ModeS table - "; |
|
1353 | + } |
|
1211 | 1354 | if ($ICAOTypeCode != '') { |
1212 | 1355 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1213 | 1356 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1219,7 +1362,9 @@ discard block |
||
1219 | 1362 | $sthi = $this->db->prepare($queryi); |
1220 | 1363 | $sthi->execute($queryi_values); |
1221 | 1364 | } catch(PDOException $e) { |
1222 | - if ($globalDebug) echo $e->getMessage(); |
|
1365 | + if ($globalDebug) { |
|
1366 | + echo $e->getMessage(); |
|
1367 | + } |
|
1223 | 1368 | return "error : ".$e->getMessage(); |
1224 | 1369 | } |
1225 | 1370 | } |
@@ -1240,7 +1385,9 @@ discard block |
||
1240 | 1385 | return "error : ".$e->getMessage(); |
1241 | 1386 | } |
1242 | 1387 | */ |
1243 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1388 | + if ($globalDebug) { |
|
1389 | + echo " Update Spotter_output table - "; |
|
1390 | + } |
|
1244 | 1391 | if ($ICAOTypeCode != '') { |
1245 | 1392 | if ($globalDBdriver == 'mysql') { |
1246 | 1393 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1251,8 +1398,7 @@ discard block |
||
1251 | 1398 | } else { |
1252 | 1399 | if ($globalDBdriver == 'mysql') { |
1253 | 1400 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1254 | - } |
|
1255 | - elseif ($globalDBdriver == 'pgsql') { |
|
1401 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1256 | 1402 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1257 | 1403 | } |
1258 | 1404 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1261,14 +1407,20 @@ discard block |
||
1261 | 1407 | $sthi = $this->db->prepare($queryi); |
1262 | 1408 | $sthi->execute($queryi_values); |
1263 | 1409 | } catch(PDOException $e) { |
1264 | - if ($globalDebug) echo $e->getMessage(); |
|
1410 | + if ($globalDebug) { |
|
1411 | + echo $e->getMessage(); |
|
1412 | + } |
|
1265 | 1413 | return "error : ".$e->getMessage(); |
1266 | 1414 | } |
1267 | 1415 | } |
1268 | 1416 | } else { |
1269 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1417 | + if ($globalDebug) { |
|
1418 | + echo " Can't find ModeS in spotter_output - "; |
|
1419 | + } |
|
1420 | + } |
|
1421 | + if ($globalDebug) { |
|
1422 | + echo "Done\n"; |
|
1270 | 1423 | } |
1271 | - if ($globalDebug) echo "Done\n"; |
|
1272 | 1424 | } |
1273 | 1425 | } |
1274 | 1426 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection.'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection.'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | /** |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | if (isset($filter[0]['source'])) { |
33 | 35 | $filters = array_merge($filters,$filter); |
34 | 36 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
37 | + if (is_array($globalFilter)) { |
|
38 | + $filter = array_merge($filter,$globalFilter); |
|
39 | + } |
|
36 | 40 | $filter_query_join = ''; |
37 | 41 | $filter_query_where = ''; |
38 | 42 | foreach($filters as $flt) { |
@@ -71,8 +75,11 @@ discard block |
||
71 | 75 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 76 | } |
73 | 77 | } |
74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
78 | + if ($filter_query_where == '' && $where) { |
|
79 | + $filter_query_where = ' WHERE'; |
|
80 | + } elseif ($filter_query_where != '' && $and) { |
|
81 | + $filter_query_where .= ' AND'; |
|
82 | + } |
|
76 | 83 | if ($filter_query_where != '') { |
77 | 84 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
78 | 85 | } |
@@ -126,26 +133,43 @@ discard block |
||
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
127 | 134 | } elseif (isset($row['spotter_archive_output_id'])) { |
128 | 135 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
129 | - */} |
|
130 | - elseif (isset($row['trackerid'])) { |
|
136 | + */} elseif (isset($row['trackerid'])) { |
|
131 | 137 | $temp_array['trackerid'] = $row['trackerid']; |
132 | 138 | } else { |
133 | 139 | $temp_array['trackerid'] = ''; |
134 | 140 | } |
135 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
137 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
141 | + if (isset($row['famtrackid'])) { |
|
142 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
143 | + } |
|
144 | + if (isset($row['type'])) { |
|
145 | + $temp_array['type'] = $row['type']; |
|
146 | + } |
|
147 | + if (isset($row['comment'])) { |
|
148 | + $temp_array['comment'] = $row['comment']; |
|
149 | + } |
|
138 | 150 | $temp_array['ident'] = $row['ident']; |
139 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
140 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
141 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
151 | + if (isset($row['latitude'])) { |
|
152 | + $temp_array['latitude'] = $row['latitude']; |
|
153 | + } |
|
154 | + if (isset($row['longitude'])) { |
|
155 | + $temp_array['longitude'] = $row['longitude']; |
|
156 | + } |
|
157 | + if (isset($row['format_source'])) { |
|
158 | + $temp_array['format_source'] = $row['format_source']; |
|
159 | + } |
|
160 | + if (isset($row['altitude'])) { |
|
161 | + $temp_array['altitude'] = $row['altitude']; |
|
162 | + } |
|
143 | 163 | if (isset($row['heading'])) { |
144 | 164 | $temp_array['heading'] = $row['heading']; |
145 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
146 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 172 | } |
148 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
149 | 173 | |
150 | 174 | if (isset($row['date'])) { |
151 | 175 | $dateArray = $this->parseDateString($row['date']); |
@@ -188,13 +212,21 @@ discard block |
||
188 | 212 | } |
189 | 213 | |
190 | 214 | $fromsource = NULL; |
191 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
192 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
193 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
215 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
216 | + $temp_array['source_name'] = $row['source_name']; |
|
217 | + } |
|
218 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
219 | + $temp_array['over_country'] = $row['over_country']; |
|
220 | + } |
|
221 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
222 | + $temp_array['distance'] = $row['distance']; |
|
223 | + } |
|
194 | 224 | $temp_array['query_number_rows'] = $num_rows; |
195 | 225 | $spotter_array[] = $temp_array; |
196 | 226 | } |
197 | - if ($num_rows == 0) return array(); |
|
227 | + if ($num_rows == 0) { |
|
228 | + return array(); |
|
229 | + } |
|
198 | 230 | $spotter_array[0]['query_number_rows'] = $num_rows; |
199 | 231 | return $spotter_array; |
200 | 232 | } |
@@ -225,8 +257,12 @@ discard block |
||
225 | 257 | { |
226 | 258 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
227 | 259 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
228 | - } else $limit_query = ""; |
|
229 | - } else $limit_query = ""; |
|
260 | + } else { |
|
261 | + $limit_query = ""; |
|
262 | + } |
|
263 | + } else { |
|
264 | + $limit_query = ""; |
|
265 | + } |
|
230 | 266 | |
231 | 267 | if ($sort != "") |
232 | 268 | { |
@@ -254,7 +290,9 @@ discard block |
||
254 | 290 | global $global_query; |
255 | 291 | |
256 | 292 | date_default_timezone_set('UTC'); |
257 | - if ($id == '') return array(); |
|
293 | + if ($id == '') { |
|
294 | + return array(); |
|
295 | + } |
|
258 | 296 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 297 | $query_values = array(':id' => $id); |
260 | 298 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -397,8 +435,11 @@ discard block |
||
397 | 435 | $query .= " ORDER BY tracker_output.source_name ASC"; |
398 | 436 | |
399 | 437 | $sth = $this->db->prepare($query); |
400 | - if (!empty($query_values)) $sth->execute($query_values); |
|
401 | - else $sth->execute(); |
|
438 | + if (!empty($query_values)) { |
|
439 | + $sth->execute($query_values); |
|
440 | + } else { |
|
441 | + $sth->execute(); |
|
442 | + } |
|
402 | 443 | |
403 | 444 | $source_array = array(); |
404 | 445 | $temp_array = array(); |
@@ -453,7 +494,9 @@ discard block |
||
453 | 494 | date_default_timezone_set($globalTimezone); |
454 | 495 | $datetime = new DateTime(); |
455 | 496 | $offset = $datetime->format('P'); |
456 | - } else $offset = '+00:00'; |
|
497 | + } else { |
|
498 | + $offset = '+00:00'; |
|
499 | + } |
|
457 | 500 | |
458 | 501 | if ($globalDBdriver == 'mysql') { |
459 | 502 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -609,7 +652,9 @@ discard block |
||
609 | 652 | { |
610 | 653 | return false; |
611 | 654 | } |
612 | - } else $altitude = 0; |
|
655 | + } else { |
|
656 | + $altitude = 0; |
|
657 | + } |
|
613 | 658 | |
614 | 659 | if ($heading != "") |
615 | 660 | { |
@@ -648,8 +693,12 @@ discard block |
||
648 | 693 | $latitude = 0; |
649 | 694 | $longitude = 0; |
650 | 695 | } |
651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
696 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
697 | + $heading = 0; |
|
698 | + } |
|
699 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
700 | + $groundspeed = 0; |
|
701 | + } |
|
653 | 702 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
654 | 703 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 704 | |
@@ -758,7 +807,9 @@ discard block |
||
758 | 807 | global $globalDBdriver, $globalArchive; |
759 | 808 | //$filter_query = $this->getFilter($filters,true,true); |
760 | 809 | $Connection= new Connection($this->db); |
761 | - if (!$Connection->tableExists('countries')) return array(); |
|
810 | + if (!$Connection->tableExists('countries')) { |
|
811 | + return array(); |
|
812 | + } |
|
762 | 813 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
763 | 814 | require_once('class.TrackerLive.php'); |
764 | 815 | $TrackerLive = new TrackerLive(); |
@@ -801,7 +852,9 @@ discard block |
||
801 | 852 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
802 | 853 | } |
803 | 854 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
804 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
855 | + if ($limit) { |
|
856 | + $query .= " LIMIT 10 OFFSET 0"; |
|
857 | + } |
|
805 | 858 | |
806 | 859 | |
807 | 860 | $sth = $this->db->prepare($query); |
@@ -834,12 +887,18 @@ discard block |
||
834 | 887 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
835 | 888 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
836 | 889 | if ($olderthanmonths > 0) { |
837 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
838 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
890 | + if ($globalDBdriver == 'mysql') { |
|
891 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
892 | + } else { |
|
893 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
894 | + } |
|
839 | 895 | } |
840 | 896 | if ($sincedate != '') { |
841 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
842 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
897 | + if ($globalDBdriver == 'mysql') { |
|
898 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
899 | + } else { |
|
900 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
901 | + } |
|
843 | 902 | } |
844 | 903 | $query_values = array(); |
845 | 904 | if ($year != '') { |
@@ -870,7 +929,9 @@ discard block |
||
870 | 929 | } |
871 | 930 | } |
872 | 931 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
873 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
932 | + if ($limit) { |
|
933 | + $query .= " LIMIT 10 OFFSET 0"; |
|
934 | + } |
|
874 | 935 | |
875 | 936 | $sth = $this->db->prepare($query); |
876 | 937 | $sth->execute($query_values); |
@@ -905,7 +966,9 @@ discard block |
||
905 | 966 | date_default_timezone_set($globalTimezone); |
906 | 967 | $datetime = new DateTime(); |
907 | 968 | $offset = $datetime->format('P'); |
908 | - } else $offset = '+00:00'; |
|
969 | + } else { |
|
970 | + $offset = '+00:00'; |
|
971 | + } |
|
909 | 972 | |
910 | 973 | if ($globalDBdriver == 'mysql') { |
911 | 974 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -955,7 +1018,9 @@ discard block |
||
955 | 1018 | date_default_timezone_set($globalTimezone); |
956 | 1019 | $datetime = new DateTime(); |
957 | 1020 | $offset = $datetime->format('P'); |
958 | - } else $offset = '+00:00'; |
|
1021 | + } else { |
|
1022 | + $offset = '+00:00'; |
|
1023 | + } |
|
959 | 1024 | $filter_query = $this->getFilter($filters,true,true); |
960 | 1025 | if ($globalDBdriver == 'mysql') { |
961 | 1026 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1001,7 +1066,9 @@ discard block |
||
1001 | 1066 | date_default_timezone_set($globalTimezone); |
1002 | 1067 | $datetime = new DateTime(); |
1003 | 1068 | $offset = $datetime->format('P'); |
1004 | - } else $offset = '+00:00'; |
|
1069 | + } else { |
|
1070 | + $offset = '+00:00'; |
|
1071 | + } |
|
1005 | 1072 | $filter_query = $this->getFilter($filters,true,true); |
1006 | 1073 | if ($globalDBdriver == 'mysql') { |
1007 | 1074 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1049,7 +1116,9 @@ discard block |
||
1049 | 1116 | date_default_timezone_set($globalTimezone); |
1050 | 1117 | $datetime = new DateTime(); |
1051 | 1118 | $offset = $datetime->format('P'); |
1052 | - } else $offset = '+00:00'; |
|
1119 | + } else { |
|
1120 | + $offset = '+00:00'; |
|
1121 | + } |
|
1053 | 1122 | |
1054 | 1123 | if ($globalDBdriver == 'mysql') { |
1055 | 1124 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1098,7 +1167,9 @@ discard block |
||
1098 | 1167 | date_default_timezone_set($globalTimezone); |
1099 | 1168 | $datetime = new DateTime(); |
1100 | 1169 | $offset = $datetime->format('P'); |
1101 | - } else $offset = '+00:00'; |
|
1170 | + } else { |
|
1171 | + $offset = '+00:00'; |
|
1172 | + } |
|
1102 | 1173 | $filter_query = $this->getFilter($filters,true,true); |
1103 | 1174 | if ($globalDBdriver == 'mysql') { |
1104 | 1175 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1147,7 +1218,9 @@ discard block |
||
1147 | 1218 | date_default_timezone_set($globalTimezone); |
1148 | 1219 | $datetime = new DateTime(); |
1149 | 1220 | $offset = $datetime->format('P'); |
1150 | - } else $offset = '+00:00'; |
|
1221 | + } else { |
|
1222 | + $offset = '+00:00'; |
|
1223 | + } |
|
1151 | 1224 | |
1152 | 1225 | $orderby_sql = ''; |
1153 | 1226 | if ($orderby == "hour") |
@@ -1216,7 +1289,9 @@ discard block |
||
1216 | 1289 | date_default_timezone_set($globalTimezone); |
1217 | 1290 | $datetime = new DateTime($date); |
1218 | 1291 | $offset = $datetime->format('P'); |
1219 | - } else $offset = '+00:00'; |
|
1292 | + } else { |
|
1293 | + $offset = '+00:00'; |
|
1294 | + } |
|
1220 | 1295 | |
1221 | 1296 | if ($globalDBdriver == 'mysql') { |
1222 | 1297 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1264,7 +1339,9 @@ discard block |
||
1264 | 1339 | date_default_timezone_set($globalTimezone); |
1265 | 1340 | $datetime = new DateTime(); |
1266 | 1341 | $offset = $datetime->format('P'); |
1267 | - } else $offset = '+00:00'; |
|
1342 | + } else { |
|
1343 | + $offset = '+00:00'; |
|
1344 | + } |
|
1268 | 1345 | |
1269 | 1346 | if ($globalDBdriver == 'mysql') { |
1270 | 1347 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1329,8 +1406,11 @@ discard block |
||
1329 | 1406 | $query_values = array_merge($query_values,array(':month' => $month)); |
1330 | 1407 | } |
1331 | 1408 | } |
1332 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1409 | + if (empty($query_values)) { |
|
1410 | + $queryi .= $this->getFilter($filters); |
|
1411 | + } else { |
|
1412 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1413 | + } |
|
1334 | 1414 | |
1335 | 1415 | $sth = $this->db->prepare($queryi); |
1336 | 1416 | $sth->execute($query_values); |
@@ -1367,8 +1447,11 @@ discard block |
||
1367 | 1447 | $query_values = array_merge($query_values,array(':month' => $month)); |
1368 | 1448 | } |
1369 | 1449 | } |
1370 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1450 | + if (empty($query_values)) { |
|
1451 | + $queryi .= $this->getFilter($filters); |
|
1452 | + } else { |
|
1453 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1454 | + } |
|
1372 | 1455 | |
1373 | 1456 | $sth = $this->db->prepare($queryi); |
1374 | 1457 | $sth->execute($query_values); |
@@ -1390,7 +1473,9 @@ discard block |
||
1390 | 1473 | date_default_timezone_set($globalTimezone); |
1391 | 1474 | $datetime = new DateTime(); |
1392 | 1475 | $offset = $datetime->format('P'); |
1393 | - } else $offset = '+00:00'; |
|
1476 | + } else { |
|
1477 | + $offset = '+00:00'; |
|
1478 | + } |
|
1394 | 1479 | |
1395 | 1480 | if ($globalDBdriver == 'mysql') { |
1396 | 1481 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1494,7 +1579,9 @@ discard block |
||
1494 | 1579 | */ |
1495 | 1580 | public function parseDirection($direction = 0) |
1496 | 1581 | { |
1497 | - if ($direction == '') $direction = 0; |
|
1582 | + if ($direction == '') { |
|
1583 | + $direction = 0; |
|
1584 | + } |
|
1498 | 1585 | $direction_array = array(); |
1499 | 1586 | $temp_array = array(); |
1500 | 1587 | |
@@ -1583,7 +1670,9 @@ discard block |
||
1583 | 1670 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1584 | 1671 | |
1585 | 1672 | $Connection = new Connection($this->db); |
1586 | - if (!$Connection->tableExists('countries')) return ''; |
|
1673 | + if (!$Connection->tableExists('countries')) { |
|
1674 | + return ''; |
|
1675 | + } |
|
1587 | 1676 | |
1588 | 1677 | try { |
1589 | 1678 | /* |
@@ -1603,9 +1692,13 @@ discard block |
||
1603 | 1692 | $sth->closeCursor(); |
1604 | 1693 | if (count($row) > 0) { |
1605 | 1694 | return $row; |
1606 | - } else return ''; |
|
1695 | + } else { |
|
1696 | + return ''; |
|
1697 | + } |
|
1607 | 1698 | } catch (PDOException $e) { |
1608 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1699 | + if (isset($globalDebug) && $globalDebug) { |
|
1700 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1701 | + } |
|
1609 | 1702 | return ''; |
1610 | 1703 | } |
1611 | 1704 | |
@@ -1623,7 +1716,9 @@ discard block |
||
1623 | 1716 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1624 | 1717 | |
1625 | 1718 | $Connection = new Connection($this->db); |
1626 | - if (!$Connection->tableExists('countries')) return ''; |
|
1719 | + if (!$Connection->tableExists('countries')) { |
|
1720 | + return ''; |
|
1721 | + } |
|
1627 | 1722 | |
1628 | 1723 | try { |
1629 | 1724 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1635,9 +1730,13 @@ discard block |
||
1635 | 1730 | $sth->closeCursor(); |
1636 | 1731 | if (count($row) > 0) { |
1637 | 1732 | return $row; |
1638 | - } else return ''; |
|
1733 | + } else { |
|
1734 | + return ''; |
|
1735 | + } |
|
1639 | 1736 | } catch (PDOException $e) { |
1640 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1737 | + if (isset($globalDebug) && $globalDebug) { |
|
1738 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1739 | + } |
|
1641 | 1740 | return ''; |
1642 | 1741 | } |
1643 | 1742 | |
@@ -1698,7 +1797,9 @@ discard block |
||
1698 | 1797 | } |
1699 | 1798 | } |
1700 | 1799 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
1701 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1800 | + if ($limit) { |
|
1801 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1802 | + } |
|
1702 | 1803 | $sth = $this->db->prepare($query); |
1703 | 1804 | $sth->execute($query_values); |
1704 | 1805 | $tracker_array = array(); |
@@ -1725,7 +1826,9 @@ discard block |
||
1725 | 1826 | { |
1726 | 1827 | global $globalBitlyAccessToken; |
1727 | 1828 | |
1728 | - if ($globalBitlyAccessToken == '') return $url; |
|
1829 | + if ($globalBitlyAccessToken == '') { |
|
1830 | + return $url; |
|
1831 | + } |
|
1729 | 1832 | |
1730 | 1833 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1731 | 1834 |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | public function __construct($dbc = null) { |
13 | 13 | $Connection = new Connection($dbc); |
14 | 14 | $this->db = $Connection->db(); |
15 | - if ($this->db === null) die('Error: No DB connection.'); |
|
15 | + if ($this->db === null) { |
|
16 | + die('Error: No DB connection.'); |
|
17 | + } |
|
16 | 18 | } |
17 | 19 | |
18 | 20 | /** |
@@ -124,7 +126,9 @@ discard block |
||
124 | 126 | $sth->closeCursor(); |
125 | 127 | if (count($row) > 0) { |
126 | 128 | return $row; |
127 | - } else return array(); |
|
129 | + } else { |
|
130 | + return array(); |
|
131 | + } |
|
128 | 132 | } |
129 | 133 | |
130 | 134 | public function checkSchedule($ident) { |
@@ -160,7 +164,9 @@ discard block |
||
160 | 164 | $Common = new Common(); |
161 | 165 | $check_date = new Datetime($date); |
162 | 166 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
163 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
167 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
168 | + return array(); |
|
169 | + } |
|
164 | 170 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
165 | 171 | $json = $Common->getData($url); |
166 | 172 | |
@@ -187,7 +193,9 @@ discard block |
||
187 | 193 | */ |
188 | 194 | |
189 | 195 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
190 | - } else return array(); |
|
196 | + } else { |
|
197 | + return array(); |
|
198 | + } |
|
191 | 199 | } |
192 | 200 | |
193 | 201 | /** |
@@ -202,7 +210,9 @@ discard block |
||
202 | 210 | date_default_timezone_set($globalTimezone); |
203 | 211 | $check_date = new Datetime($date); |
204 | 212 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
205 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
213 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
214 | + return array(); |
|
215 | + } |
|
206 | 216 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
207 | 217 | $json = $Common->getData($url); |
208 | 218 | $parsed_json = json_decode($json); |
@@ -215,7 +225,9 @@ discard block |
||
215 | 225 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
216 | 226 | |
217 | 227 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
218 | - } else return array(); |
|
228 | + } else { |
|
229 | + return array(); |
|
230 | + } |
|
219 | 231 | } |
220 | 232 | |
221 | 233 | /** |
@@ -226,7 +238,9 @@ discard block |
||
226 | 238 | private function getRyanair($callsign) { |
227 | 239 | $Common = new Common(); |
228 | 240 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
229 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
241 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
242 | + return array(); |
|
243 | + } |
|
230 | 244 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
231 | 245 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
232 | 246 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -240,8 +254,12 @@ discard block |
||
240 | 254 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
241 | 255 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
242 | 256 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
243 | - } else return array(); |
|
244 | - } else return array(); |
|
257 | + } else { |
|
258 | + return array(); |
|
259 | + } |
|
260 | + } else { |
|
261 | + return array(); |
|
262 | + } |
|
245 | 263 | } |
246 | 264 | |
247 | 265 | /** |
@@ -252,7 +270,9 @@ discard block |
||
252 | 270 | private function getSwiss($callsign) { |
253 | 271 | $Common = new Common(); |
254 | 272 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
255 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
273 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
274 | + return array(); |
|
275 | + } |
|
256 | 276 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
257 | 277 | $json = $Common->getData($url); |
258 | 278 | $parsed_json = json_decode($json); |
@@ -272,8 +292,12 @@ discard block |
||
272 | 292 | } |
273 | 293 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
274 | 294 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
275 | - } else return array(); |
|
276 | - } else return array(); |
|
295 | + } else { |
|
296 | + return array(); |
|
297 | + } |
|
298 | + } else { |
|
299 | + return array(); |
|
300 | + } |
|
277 | 301 | } |
278 | 302 | |
279 | 303 | /** |
@@ -287,12 +311,18 @@ discard block |
||
287 | 311 | $Common = new Common(); |
288 | 312 | $check_date = new Datetime($date); |
289 | 313 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
290 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
291 | - if ($globalBritishAirwaysKey == '') return array(); |
|
314 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
315 | + return array(); |
|
316 | + } |
|
317 | + if ($globalBritishAirwaysKey == '') { |
|
318 | + return array(); |
|
319 | + } |
|
292 | 320 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
293 | 321 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
294 | 322 | $json = $Common->getData($url,'get','',$headers); |
295 | - if ($json == '') return array(); |
|
323 | + if ($json == '') { |
|
324 | + return array(); |
|
325 | + } |
|
296 | 326 | $parsed_json = json_decode($json); |
297 | 327 | $flights = $parsed_json->{'FlightsResponse'}; |
298 | 328 | if (count($flights) > 0) { |
@@ -301,7 +331,9 @@ discard block |
||
301 | 331 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
302 | 332 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
303 | 333 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
304 | - } else return array(); |
|
334 | + } else { |
|
335 | + return array(); |
|
336 | + } |
|
305 | 337 | } |
306 | 338 | |
307 | 339 | /** |
@@ -315,19 +347,27 @@ discard block |
||
315 | 347 | $Common = new Common(); |
316 | 348 | $check_date = new Datetime($date); |
317 | 349 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
318 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
319 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
350 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
351 | + return array(); |
|
352 | + } |
|
353 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
354 | + return array(); |
|
355 | + } |
|
320 | 356 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
321 | 357 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
322 | 358 | $data = $Common->getData($url,'post',$post); |
323 | 359 | $parsed_data = json_decode($data); |
324 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
360 | + if (!isset($parsed_data->{'access_token'})) { |
|
361 | + return array(); |
|
362 | + } |
|
325 | 363 | $token = $parsed_data->{'access_token'}; |
326 | 364 | |
327 | 365 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
328 | 366 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
329 | 367 | $json = $Common->getData($url,'get','',$headers); |
330 | - if ($json == '') return array(); |
|
368 | + if ($json == '') { |
|
369 | + return array(); |
|
370 | + } |
|
331 | 371 | $parsed_json = json_decode($json); |
332 | 372 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
333 | 373 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -335,7 +375,9 @@ discard block |
||
335 | 375 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
336 | 376 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
337 | 377 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
338 | - } else return array(); |
|
378 | + } else { |
|
379 | + return array(); |
|
380 | + } |
|
339 | 381 | } |
340 | 382 | |
341 | 383 | /** |
@@ -349,14 +391,20 @@ discard block |
||
349 | 391 | $Common = new Common(); |
350 | 392 | $check_date = new Datetime($date); |
351 | 393 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
352 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
353 | - if ($globalTransaviaKey == '') return array(); |
|
394 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
395 | + return array(); |
|
396 | + } |
|
397 | + if ($globalTransaviaKey == '') { |
|
398 | + return array(); |
|
399 | + } |
|
354 | 400 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
355 | 401 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
356 | 402 | $headers = array('apikey: '.$globalTransaviaKey); |
357 | 403 | $json = $Common->getData($url,'get','',$headers); |
358 | 404 | //echo 'result : '.$json; |
359 | - if ($json == '') return array(); |
|
405 | + if ($json == '') { |
|
406 | + return array(); |
|
407 | + } |
|
360 | 408 | $parsed_json = json_decode($json); |
361 | 409 | |
362 | 410 | if (isset($parsed_json->{'data'}[0])) { |
@@ -365,7 +413,9 @@ discard block |
||
365 | 413 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
366 | 414 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
367 | 415 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
368 | - } else return array(); |
|
416 | + } else { |
|
417 | + return array(); |
|
418 | + } |
|
369 | 419 | } |
370 | 420 | |
371 | 421 | /** |
@@ -376,7 +426,9 @@ discard block |
||
376 | 426 | public function getTunisair($callsign) { |
377 | 427 | $Common = new Common(); |
378 | 428 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
379 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
429 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
430 | + return array(); |
|
431 | + } |
|
380 | 432 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
381 | 433 | $data = $Common->getData($url); |
382 | 434 | $table = $Common->table2array($data); |
@@ -397,7 +449,9 @@ discard block |
||
397 | 449 | $Common = new Common(); |
398 | 450 | $check_date = new Datetime($date); |
399 | 451 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
400 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
452 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
453 | + return array(); |
|
454 | + } |
|
401 | 455 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
402 | 456 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
403 | 457 | $data = $Common->getData($url); |
@@ -407,8 +461,11 @@ discard block |
||
407 | 461 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
408 | 462 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
409 | 463 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
410 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
411 | - else return array(); |
|
464 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
465 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
466 | + } else { |
|
467 | + return array(); |
|
468 | + } |
|
412 | 469 | } |
413 | 470 | return array(); |
414 | 471 | } |
@@ -423,7 +480,9 @@ discard block |
||
423 | 480 | $Common = new Common(); |
424 | 481 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
425 | 482 | $check_date = new Datetime($date); |
426 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
483 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
484 | + return array(); |
|
485 | + } |
|
427 | 486 | $url = "https://www.iberia.com/web/flightDetail.do"; |
428 | 487 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
429 | 488 | $data = $Common->getData($url,'post',$post); |
@@ -440,7 +499,9 @@ discard block |
||
440 | 499 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
441 | 500 | if ($arrivalTime == 'Hora estimada de llegada') { |
442 | 501 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
443 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
502 | + } else { |
|
503 | + $arrivalTime = substr($arrivalTime,0,5); |
|
504 | + } |
|
444 | 505 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
445 | 506 | } |
446 | 507 | } |
@@ -458,7 +519,9 @@ discard block |
||
458 | 519 | $Common = new Common(); |
459 | 520 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
460 | 521 | $check_date = new Datetime($date); |
461 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
522 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
523 | + return array(); |
|
524 | + } |
|
462 | 525 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
463 | 526 | $data = $Common->getData($url); |
464 | 527 | if ($data != '') { |
@@ -474,7 +537,9 @@ discard block |
||
474 | 537 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
475 | 538 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
476 | 539 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
477 | - } else return array(); |
|
540 | + } else { |
|
541 | + return array(); |
|
542 | + } |
|
478 | 543 | } |
479 | 544 | |
480 | 545 | |
@@ -494,7 +559,9 @@ discard block |
||
494 | 559 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
495 | 560 | $check_date = new Datetime($date); |
496 | 561 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
497 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
562 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
563 | + return array(); |
|
564 | + } |
|
498 | 565 | $data = $Common->getData($url); |
499 | 566 | if ($data != '') { |
500 | 567 | $table = $Common->text2array($data); |
@@ -518,7 +585,9 @@ discard block |
||
518 | 585 | $check_date = new Datetime($date); |
519 | 586 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
520 | 587 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
588 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
589 | + return array(); |
|
590 | + } |
|
522 | 591 | $data = $Common->getData($url); |
523 | 592 | if ($data != '') { |
524 | 593 | //echo $data; |
@@ -608,7 +677,9 @@ discard block |
||
608 | 677 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
609 | 678 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
610 | 679 | //$check_date = new Datetime($date); |
611 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
680 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
681 | + return array(); |
|
682 | + } |
|
612 | 683 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
613 | 684 | $data = $Common->getData($url,'post',$post); |
614 | 685 | if ($data != '') { |
@@ -640,11 +711,15 @@ discard block |
||
640 | 711 | $airline_icao = substr($callsign, 0, 3); |
641 | 712 | } |
642 | 713 | } |
643 | - if ($airline_icao == '') return array(); |
|
714 | + if ($airline_icao == '') { |
|
715 | + return array(); |
|
716 | + } |
|
644 | 717 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
645 | 718 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
646 | 719 | //$check_date = new Datetime($date); |
647 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
720 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
721 | + return array(); |
|
722 | + } |
|
648 | 723 | $data = $Common->getData($url); |
649 | 724 | if ($data != '') { |
650 | 725 | $table = $Common->table2array($data); |
@@ -687,7 +762,9 @@ discard block |
||
687 | 762 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
688 | 763 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
689 | 764 | //$check_date = new Datetime($date); |
690 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
765 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
766 | + return array(); |
|
767 | + } |
|
691 | 768 | $data = $Common->getData($url); |
692 | 769 | if ($data != '') { |
693 | 770 | $table = $Common->table2array($data); |
@@ -740,11 +817,15 @@ discard block |
||
740 | 817 | $check_date = new Datetime($date); |
741 | 818 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
742 | 819 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
743 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
820 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
821 | + return array(); |
|
822 | + } |
|
744 | 823 | $data = $Common->getData($url); |
745 | 824 | $dom = new DomDocument(); |
746 | 825 | $dom->loadXML($data); |
747 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
826 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
827 | + return array(); |
|
828 | + } |
|
748 | 829 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
749 | 830 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
750 | 831 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -753,7 +834,9 @@ discard block |
||
753 | 834 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
754 | 835 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
755 | 836 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
756 | - } else return array(); |
|
837 | + } else { |
|
838 | + return array(); |
|
839 | + } |
|
757 | 840 | } |
758 | 841 | |
759 | 842 | /** |
@@ -767,7 +850,9 @@ discard block |
||
767 | 850 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
768 | 851 | $check_date = new Datetime($date); |
769 | 852 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
770 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
853 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
854 | + return array(); |
|
855 | + } |
|
771 | 856 | $data = $Common->getData($url); |
772 | 857 | if ($data != '') { |
773 | 858 | $table = $Common->table2array($data); |
@@ -796,7 +881,9 @@ discard block |
||
796 | 881 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
797 | 882 | $check_date = new Datetime($date); |
798 | 883 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
799 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
884 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
885 | + return array(); |
|
886 | + } |
|
800 | 887 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
801 | 888 | $data = $Common->getData($url,'post',$post); |
802 | 889 | //echo $data; |
@@ -806,11 +893,19 @@ discard block |
||
806 | 893 | if ($data != '') { |
807 | 894 | $table = $Common->table2array($data); |
808 | 895 | $flight = $table; |
809 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
810 | - else $departureTime = ''; |
|
811 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
812 | - else $departureAirport = ''; |
|
813 | - } else return array(); |
|
896 | + if (isset($flight[5][4])) { |
|
897 | + $departureTime = $flight[5][4]; |
|
898 | + } else { |
|
899 | + $departureTime = ''; |
|
900 | + } |
|
901 | + if (isset($flight[5][2])) { |
|
902 | + $departureAirport = $flight[5][2]; |
|
903 | + } else { |
|
904 | + $departureAirport = ''; |
|
905 | + } |
|
906 | + } else { |
|
907 | + return array(); |
|
908 | + } |
|
814 | 909 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
815 | 910 | $data = $Common->getData($url,'post',$post); |
816 | 911 | if ($data != '') { |
@@ -823,10 +918,14 @@ discard block |
||
823 | 918 | $arrivalTime = ''; |
824 | 919 | $arrivalAirport = ''; |
825 | 920 | } |
826 | - } else return array(); |
|
921 | + } else { |
|
922 | + return array(); |
|
923 | + } |
|
827 | 924 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
828 | 925 | $json = $Common->getData($url); |
829 | - if ($json == '') return array(); |
|
926 | + if ($json == '') { |
|
927 | + return array(); |
|
928 | + } |
|
830 | 929 | $parsed_json = json_decode($json); |
831 | 930 | $airports = $parsed_json->{'suggestList'}; |
832 | 931 | if (count($airports) > 0) { |
@@ -841,7 +940,9 @@ discard block |
||
841 | 940 | } |
842 | 941 | if (isset($DepartureAirportIata)) { |
843 | 942 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
844 | - } else return array(); |
|
943 | + } else { |
|
944 | + return array(); |
|
945 | + } |
|
845 | 946 | } |
846 | 947 | |
847 | 948 | |
@@ -849,7 +950,9 @@ discard block |
||
849 | 950 | public function fetchSchedule($ident,$date = 'NOW') { |
850 | 951 | global $globalSchedulesSources, $globalSchedulesFetch; |
851 | 952 | //$Common = new Common(); |
852 | - if (!$globalSchedulesFetch) return array(); |
|
953 | + if (!$globalSchedulesFetch) { |
|
954 | + return array(); |
|
955 | + } |
|
853 | 956 | $airline_icao = ''; |
854 | 957 | if (!is_numeric(substr($ident, 0, 3))) |
855 | 958 | { |
@@ -1077,14 +1180,21 @@ discard block |
||
1077 | 1180 | default: |
1078 | 1181 | // Randomly use a generic function to get hours |
1079 | 1182 | if (strlen($airline_icao) == 2) { |
1080 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1183 | + if (!isset($globalSchedulesSources)) { |
|
1184 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1185 | + } |
|
1081 | 1186 | if (count($globalSchedulesSources) > 0) { |
1082 | 1187 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
1083 | 1188 | $source = $globalSchedulesSources[$rand]; |
1084 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
1085 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
1189 | + if ($source == 'flightmapper') { |
|
1190 | + return $this->getFlightMapper($ident); |
|
1191 | + } elseif ($source == 'costtotravel') { |
|
1192 | + return $this->getCostToTravel($ident); |
|
1193 | + } |
|
1086 | 1194 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
1087 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
1195 | + elseif ($source == 'flightaware') { |
|
1196 | + return $this->getFlightAware($ident); |
|
1197 | + } |
|
1088 | 1198 | } |
1089 | 1199 | } |
1090 | 1200 | } |
@@ -13,10 +13,14 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct($dbc = null) { |
15 | 15 | global $globalFilterName; |
16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
16 | + if (isset($globalFilterName)) { |
|
17 | + $this->filter_name = $globalFilterName; |
|
18 | + } |
|
17 | 19 | $Connection = new Connection($dbc); |
18 | 20 | $this->db = $Connection->db(); |
19 | - if ($this->db === null) die('Error: No DB connection.'); |
|
21 | + if ($this->db === null) { |
|
22 | + die('Error: No DB connection.'); |
|
23 | + } |
|
20 | 24 | } |
21 | 25 | |
22 | 26 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -84,7 +88,9 @@ discard block |
||
84 | 88 | |
85 | 89 | public function getAllAirlineNames($filter_name = '') { |
86 | 90 | global $globalStatsFilters; |
87 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
91 | + if ($filter_name == '') { |
|
92 | + $filter_name = $this->filter_name; |
|
93 | + } |
|
88 | 94 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
89 | 95 | try { |
90 | 96 | $sth = $this->db->prepare($query); |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | return $all; |
105 | 111 | } |
106 | 112 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
107 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
113 | + if ($filter_name == '') { |
|
114 | + $filter_name = $this->filter_name; |
|
115 | + } |
|
108 | 116 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
109 | 117 | try { |
110 | 118 | $sth = $this->db->prepare($query); |
@@ -116,7 +124,9 @@ discard block |
||
116 | 124 | return $all; |
117 | 125 | } |
118 | 126 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
119 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
127 | + if ($filter_name == '') { |
|
128 | + $filter_name = $this->filter_name; |
|
129 | + } |
|
120 | 130 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
121 | 131 | try { |
122 | 132 | $sth = $this->db->prepare($query); |
@@ -128,7 +138,9 @@ discard block |
||
128 | 138 | return $all; |
129 | 139 | } |
130 | 140 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
131 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
141 | + if ($filter_name == '') { |
|
142 | + $filter_name = $this->filter_name; |
|
143 | + } |
|
132 | 144 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
133 | 145 | try { |
134 | 146 | $sth = $this->db->prepare($query); |
@@ -141,7 +153,9 @@ discard block |
||
141 | 153 | } |
142 | 154 | |
143 | 155 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
144 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
156 | + if ($filter_name == '') { |
|
157 | + $filter_name = $this->filter_name; |
|
158 | + } |
|
145 | 159 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
146 | 160 | try { |
147 | 161 | $sth = $this->db->prepare($query); |
@@ -154,7 +168,9 @@ discard block |
||
154 | 168 | } |
155 | 169 | |
156 | 170 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
171 | + if ($filter_name == '') { |
|
172 | + $filter_name = $this->filter_name; |
|
173 | + } |
|
158 | 174 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
159 | 175 | try { |
160 | 176 | $sth = $this->db->prepare($query); |
@@ -169,7 +185,9 @@ discard block |
||
169 | 185 | |
170 | 186 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
171 | 187 | global $globalStatsFilters; |
172 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
188 | + if ($filter_name == '') { |
|
189 | + $filter_name = $this->filter_name; |
|
190 | + } |
|
173 | 191 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
174 | 192 | $Spotter = new Spotter($this->db); |
175 | 193 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -178,8 +196,11 @@ discard block |
||
178 | 196 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
179 | 197 | } |
180 | 198 | if ($year == '' && $month == '') { |
181 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
199 | + if ($limit) { |
|
200 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
201 | + } else { |
|
202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
203 | + } |
|
183 | 204 | try { |
184 | 205 | $sth = $this->db->prepare($query); |
185 | 206 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -187,11 +208,16 @@ discard block |
||
187 | 208 | echo "error : ".$e->getMessage(); |
188 | 209 | } |
189 | 210 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
190 | - } else $all = array(); |
|
211 | + } else { |
|
212 | + $all = array(); |
|
213 | + } |
|
191 | 214 | } else { |
192 | 215 | if ($year == '' && $month == '') { |
193 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
194 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
216 | + if ($limit) { |
|
217 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
218 | + } else { |
|
219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
220 | + } |
|
195 | 221 | try { |
196 | 222 | $sth = $this->db->prepare($query); |
197 | 223 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -199,7 +225,9 @@ discard block |
||
199 | 225 | echo "error : ".$e->getMessage(); |
200 | 226 | } |
201 | 227 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
202 | - } else $all = array(); |
|
228 | + } else { |
|
229 | + $all = array(); |
|
230 | + } |
|
203 | 231 | } |
204 | 232 | if (empty($all)) { |
205 | 233 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -218,10 +246,15 @@ discard block |
||
218 | 246 | } |
219 | 247 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
220 | 248 | global $globalStatsFilters; |
221 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
249 | + if ($filter_name == '') { |
|
250 | + $filter_name = $this->filter_name; |
|
251 | + } |
|
222 | 252 | if ($year == '' && $month == '') { |
223 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
224 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
253 | + if ($limit) { |
|
254 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
255 | + } else { |
|
256 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
257 | + } |
|
225 | 258 | try { |
226 | 259 | $sth = $this->db->prepare($query); |
227 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -229,7 +262,9 @@ discard block |
||
229 | 262 | echo "error : ".$e->getMessage(); |
230 | 263 | } |
231 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
232 | - } else $all = array(); |
|
265 | + } else { |
|
266 | + $all = array(); |
|
267 | + } |
|
233 | 268 | if (empty($all)) { |
234 | 269 | $Spotter = new Spotter($this->db); |
235 | 270 | $filters = array(); |
@@ -244,7 +279,9 @@ discard block |
||
244 | 279 | } |
245 | 280 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
246 | 281 | global $globalStatsFilters; |
247 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
282 | + if ($filter_name == '') { |
|
283 | + $filter_name = $this->filter_name; |
|
284 | + } |
|
248 | 285 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
249 | 286 | $Spotter = new Spotter($this->db); |
250 | 287 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -253,8 +290,11 @@ discard block |
||
253 | 290 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
254 | 291 | } |
255 | 292 | if ($year == '' && $month == '') { |
256 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
257 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
293 | + if ($limit) { |
|
294 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
295 | + } else { |
|
296 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
297 | + } |
|
258 | 298 | try { |
259 | 299 | $sth = $this->db->prepare($query); |
260 | 300 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -262,11 +302,16 @@ discard block |
||
262 | 302 | echo "error : ".$e->getMessage(); |
263 | 303 | } |
264 | 304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
265 | - } else $all = array(); |
|
305 | + } else { |
|
306 | + $all = array(); |
|
307 | + } |
|
266 | 308 | } else { |
267 | 309 | if ($year == '' && $month == '') { |
268 | - 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"; |
|
269 | - 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"; |
|
310 | + if ($limit) { |
|
311 | + $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"; |
|
312 | + } else { |
|
313 | + $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"; |
|
314 | + } |
|
270 | 315 | try { |
271 | 316 | $sth = $this->db->prepare($query); |
272 | 317 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,7 +319,9 @@ discard block |
||
274 | 319 | echo "error : ".$e->getMessage(); |
275 | 320 | } |
276 | 321 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
277 | - } else $all = array(); |
|
322 | + } else { |
|
323 | + $all = array(); |
|
324 | + } |
|
278 | 325 | } |
279 | 326 | if (empty($all)) { |
280 | 327 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -294,7 +341,9 @@ discard block |
||
294 | 341 | |
295 | 342 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
296 | 343 | global $globalStatsFilters; |
297 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
344 | + if ($filter_name == '') { |
|
345 | + $filter_name = $this->filter_name; |
|
346 | + } |
|
298 | 347 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
299 | 348 | $Spotter = new Spotter($this->db); |
300 | 349 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -303,8 +352,11 @@ discard block |
||
303 | 352 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
304 | 353 | } |
305 | 354 | if ($year == '' && $month == '') { |
306 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
307 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
355 | + if ($limit) { |
|
356 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
357 | + } else { |
|
358 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
359 | + } |
|
308 | 360 | try { |
309 | 361 | $sth = $this->db->prepare($query); |
310 | 362 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -312,11 +364,16 @@ discard block |
||
312 | 364 | echo "error : ".$e->getMessage(); |
313 | 365 | } |
314 | 366 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
315 | - } else $all = array(); |
|
367 | + } else { |
|
368 | + $all = array(); |
|
369 | + } |
|
316 | 370 | } else { |
317 | 371 | if ($year == '' && $month == '') { |
318 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
319 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
372 | + if ($limit) { |
|
373 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
374 | + } else { |
|
375 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
376 | + } |
|
320 | 377 | try { |
321 | 378 | $sth = $this->db->prepare($query); |
322 | 379 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -324,7 +381,9 @@ discard block |
||
324 | 381 | echo "error : ".$e->getMessage(); |
325 | 382 | } |
326 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
327 | - } else $all = array(); |
|
384 | + } else { |
|
385 | + $all = array(); |
|
386 | + } |
|
328 | 387 | } |
329 | 388 | if (empty($all)) { |
330 | 389 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -343,7 +402,9 @@ discard block |
||
343 | 402 | } |
344 | 403 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
345 | 404 | global $globalStatsFilters; |
346 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
405 | + if ($filter_name == '') { |
|
406 | + $filter_name = $this->filter_name; |
|
407 | + } |
|
347 | 408 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
348 | 409 | $Spotter = new Spotter($this->db); |
349 | 410 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -351,12 +412,18 @@ discard block |
||
351 | 412 | foreach ($airlines as $airline) { |
352 | 413 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
353 | 414 | } |
354 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
355 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
415 | + if ($limit) { |
|
416 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
417 | + } else { |
|
418 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
419 | + } |
|
356 | 420 | $query_values = array(':filter_name' => $filter_name); |
357 | 421 | } else { |
358 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
359 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
422 | + if ($limit) { |
|
423 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
424 | + } else { |
|
425 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
426 | + } |
|
360 | 427 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
361 | 428 | } |
362 | 429 | try { |
@@ -384,17 +451,29 @@ discard block |
||
384 | 451 | |
385 | 452 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
386 | 453 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
387 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
454 | + if ($filter_name == '') { |
|
455 | + $filter_name = $this->filter_name; |
|
456 | + } |
|
388 | 457 | if ($year == '' && $month == '') { |
389 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
390 | - if ($globalIVAO) $forsource = 'ivao'; |
|
458 | + if ($globalVATSIM) { |
|
459 | + $forsource = 'vatsim'; |
|
460 | + } |
|
461 | + if ($globalIVAO) { |
|
462 | + $forsource = 'ivao'; |
|
463 | + } |
|
391 | 464 | if (isset($forsource)) { |
392 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
393 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
465 | + if ($limit) { |
|
466 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
467 | + } else { |
|
468 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
469 | + } |
|
394 | 470 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
395 | 471 | } else { |
396 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
397 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
472 | + if ($limit) { |
|
473 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
474 | + } else { |
|
475 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
476 | + } |
|
398 | 477 | $query_values = array(':filter_name' => $filter_name); |
399 | 478 | } |
400 | 479 | try { |
@@ -404,7 +483,9 @@ discard block |
||
404 | 483 | echo "error : ".$e->getMessage(); |
405 | 484 | } |
406 | 485 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
407 | - } else $all = array(); |
|
486 | + } else { |
|
487 | + $all = array(); |
|
488 | + } |
|
408 | 489 | if (empty($all)) { |
409 | 490 | $Spotter = new Spotter($this->db); |
410 | 491 | $filters = array(); |
@@ -419,7 +500,9 @@ discard block |
||
419 | 500 | } |
420 | 501 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
421 | 502 | global $globalStatsFilters; |
422 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
503 | + if ($filter_name == '') { |
|
504 | + $filter_name = $this->filter_name; |
|
505 | + } |
|
423 | 506 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
424 | 507 | $Spotter = new Spotter($this->db); |
425 | 508 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -428,8 +511,11 @@ discard block |
||
428 | 511 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
429 | 512 | } |
430 | 513 | if ($year == '' && $month == '') { |
431 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
432 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
514 | + if ($limit) { |
|
515 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
516 | + } else { |
|
517 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
518 | + } |
|
433 | 519 | try { |
434 | 520 | $sth = $this->db->prepare($query); |
435 | 521 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -437,11 +523,16 @@ discard block |
||
437 | 523 | echo "error : ".$e->getMessage(); |
438 | 524 | } |
439 | 525 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
440 | - } else $all = array(); |
|
526 | + } else { |
|
527 | + $all = array(); |
|
528 | + } |
|
441 | 529 | } else { |
442 | 530 | if ($year == '' && $month == '') { |
443 | - 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"; |
|
444 | - 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"; |
|
531 | + if ($limit) { |
|
532 | + $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"; |
|
533 | + } else { |
|
534 | + $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"; |
|
535 | + } |
|
445 | 536 | try { |
446 | 537 | $sth = $this->db->prepare($query); |
447 | 538 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -449,7 +540,9 @@ discard block |
||
449 | 540 | echo "error : ".$e->getMessage(); |
450 | 541 | } |
451 | 542 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
452 | - } else $all = array(); |
|
543 | + } else { |
|
544 | + $all = array(); |
|
545 | + } |
|
453 | 546 | } |
454 | 547 | if (empty($all)) { |
455 | 548 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -468,7 +561,9 @@ discard block |
||
468 | 561 | } |
469 | 562 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
470 | 563 | global $globalStatsFilters; |
471 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
564 | + if ($filter_name == '') { |
|
565 | + $filter_name = $this->filter_name; |
|
566 | + } |
|
472 | 567 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
473 | 568 | $Spotter = new Spotter($this->db); |
474 | 569 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -477,8 +572,11 @@ discard block |
||
477 | 572 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
478 | 573 | } |
479 | 574 | if ($year == '' && $month == '') { |
480 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
481 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
575 | + if ($limit) { |
|
576 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
577 | + } else { |
|
578 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
579 | + } |
|
482 | 580 | try { |
483 | 581 | $sth = $this->db->prepare($query); |
484 | 582 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -486,11 +584,16 @@ discard block |
||
486 | 584 | echo "error : ".$e->getMessage(); |
487 | 585 | } |
488 | 586 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
489 | - } else $all = array(); |
|
587 | + } else { |
|
588 | + $all = array(); |
|
589 | + } |
|
490 | 590 | } else { |
491 | 591 | if ($year == '' && $month == '') { |
492 | - 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"; |
|
493 | - 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"; |
|
592 | + if ($limit) { |
|
593 | + $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"; |
|
594 | + } else { |
|
595 | + $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"; |
|
596 | + } |
|
494 | 597 | try { |
495 | 598 | $sth = $this->db->prepare($query); |
496 | 599 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -498,7 +601,9 @@ discard block |
||
498 | 601 | echo "error : ".$e->getMessage(); |
499 | 602 | } |
500 | 603 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
501 | - } else $all = array(); |
|
604 | + } else { |
|
605 | + $all = array(); |
|
606 | + } |
|
502 | 607 | } |
503 | 608 | if (empty($all)) { |
504 | 609 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -517,7 +622,9 @@ discard block |
||
517 | 622 | } |
518 | 623 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
519 | 624 | $Connection = new Connection(); |
520 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
625 | + if ($filter_name == '') { |
|
626 | + $filter_name = $this->filter_name; |
|
627 | + } |
|
521 | 628 | if ($Connection->tableExists('countries')) { |
522 | 629 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
523 | 630 | $Spotter = new Spotter($this->db); |
@@ -527,8 +634,11 @@ discard block |
||
527 | 634 | foreach ($airlines as $airline) { |
528 | 635 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
529 | 636 | } |
530 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
531 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
637 | + if ($limit) { |
|
638 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
639 | + } else { |
|
640 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
641 | + } |
|
532 | 642 | try { |
533 | 643 | $sth = $this->db->prepare($query); |
534 | 644 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -537,11 +647,16 @@ discard block |
||
537 | 647 | } |
538 | 648 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
539 | 649 | return $all; |
540 | - } else return array(); |
|
650 | + } else { |
|
651 | + return array(); |
|
652 | + } |
|
541 | 653 | } else { |
542 | 654 | if ($year == '' && $month == '') { |
543 | - 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"; |
|
544 | - 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"; |
|
655 | + if ($limit) { |
|
656 | + $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"; |
|
657 | + } else { |
|
658 | + $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"; |
|
659 | + } |
|
545 | 660 | try { |
546 | 661 | $sth = $this->db->prepare($query); |
547 | 662 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -550,7 +665,9 @@ discard block |
||
550 | 665 | } |
551 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
552 | 667 | return $all; |
553 | - } else return array(); |
|
668 | + } else { |
|
669 | + return array(); |
|
670 | + } |
|
554 | 671 | } |
555 | 672 | } else { |
556 | 673 | /* |
@@ -564,10 +681,15 @@ discard block |
||
564 | 681 | } |
565 | 682 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
566 | 683 | global $globalStatsFilters; |
567 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
684 | + if ($filter_name == '') { |
|
685 | + $filter_name = $this->filter_name; |
|
686 | + } |
|
568 | 687 | if ($year == '' && $month == '') { |
569 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
570 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
688 | + if ($limit) { |
|
689 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
690 | + } else { |
|
691 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
692 | + } |
|
571 | 693 | try { |
572 | 694 | $sth = $this->db->prepare($query); |
573 | 695 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -575,7 +697,9 @@ discard block |
||
575 | 697 | echo "error : ".$e->getMessage(); |
576 | 698 | } |
577 | 699 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
578 | - } else $all = array(); |
|
700 | + } else { |
|
701 | + $all = array(); |
|
702 | + } |
|
579 | 703 | if (empty($all)) { |
580 | 704 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
581 | 705 | if ($filter_name != '') { |
@@ -590,7 +714,9 @@ discard block |
||
590 | 714 | |
591 | 715 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
592 | 716 | global $globalStatsFilters; |
593 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
717 | + if ($filter_name == '') { |
|
718 | + $filter_name = $this->filter_name; |
|
719 | + } |
|
594 | 720 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
595 | 721 | $Spotter = new Spotter($this->db); |
596 | 722 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -599,8 +725,11 @@ discard block |
||
599 | 725 | foreach ($airlines as $airline) { |
600 | 726 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
601 | 727 | } |
602 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
603 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
728 | + if ($limit) { |
|
729 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
730 | + } else { |
|
731 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
732 | + } |
|
604 | 733 | try { |
605 | 734 | $sth = $this->db->prepare($query); |
606 | 735 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,11 +737,16 @@ discard block |
||
608 | 737 | echo "error : ".$e->getMessage(); |
609 | 738 | } |
610 | 739 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
611 | - } else $all = array(); |
|
740 | + } else { |
|
741 | + $all = array(); |
|
742 | + } |
|
612 | 743 | } else { |
613 | 744 | if ($year == '' && $month == '') { |
614 | - 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"; |
|
615 | - 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"; |
|
745 | + if ($limit) { |
|
746 | + $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"; |
|
747 | + } else { |
|
748 | + $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"; |
|
749 | + } |
|
616 | 750 | try { |
617 | 751 | $sth = $this->db->prepare($query); |
618 | 752 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -620,7 +754,9 @@ discard block |
||
620 | 754 | echo "error : ".$e->getMessage(); |
621 | 755 | } |
622 | 756 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | - } else $all = array(); |
|
757 | + } else { |
|
758 | + $all = array(); |
|
759 | + } |
|
624 | 760 | } |
625 | 761 | if (empty($all)) { |
626 | 762 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -639,7 +775,9 @@ discard block |
||
639 | 775 | } |
640 | 776 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
641 | 777 | global $globalStatsFilters; |
642 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
778 | + if ($filter_name == '') { |
|
779 | + $filter_name = $this->filter_name; |
|
780 | + } |
|
643 | 781 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
644 | 782 | $Spotter = new Spotter($this->db); |
645 | 783 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -648,8 +786,11 @@ discard block |
||
648 | 786 | foreach ($airlines as $airline) { |
649 | 787 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
650 | 788 | } |
651 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
652 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
789 | + if ($limit) { |
|
790 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
791 | + } else { |
|
792 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
793 | + } |
|
653 | 794 | try { |
654 | 795 | $sth = $this->db->prepare($query); |
655 | 796 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -657,11 +798,16 @@ discard block |
||
657 | 798 | echo "error : ".$e->getMessage(); |
658 | 799 | } |
659 | 800 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
660 | - } else $all = array(); |
|
801 | + } else { |
|
802 | + $all = array(); |
|
803 | + } |
|
661 | 804 | } else { |
662 | 805 | if ($year == '' && $month == '') { |
663 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
664 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
806 | + if ($limit) { |
|
807 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
808 | + } else { |
|
809 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
810 | + } |
|
665 | 811 | try { |
666 | 812 | $sth = $this->db->prepare($query); |
667 | 813 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -669,7 +815,9 @@ discard block |
||
669 | 815 | echo "error : ".$e->getMessage(); |
670 | 816 | } |
671 | 817 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
672 | - } else $all = array(); |
|
818 | + } else { |
|
819 | + $all = array(); |
|
820 | + } |
|
673 | 821 | } |
674 | 822 | if (empty($all)) { |
675 | 823 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -694,7 +842,9 @@ discard block |
||
694 | 842 | $icao = $value['airport_departure_icao']; |
695 | 843 | if (isset($all[$icao])) { |
696 | 844 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
697 | - } else $all[$icao] = $value; |
|
845 | + } else { |
|
846 | + $all[$icao] = $value; |
|
847 | + } |
|
698 | 848 | } |
699 | 849 | $count = array(); |
700 | 850 | foreach ($all as $key => $row) { |
@@ -706,7 +856,9 @@ discard block |
||
706 | 856 | } |
707 | 857 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
708 | 858 | global $globalStatsFilters; |
709 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
859 | + if ($filter_name == '') { |
|
860 | + $filter_name = $this->filter_name; |
|
861 | + } |
|
710 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
711 | 863 | $Spotter = new Spotter($this->db); |
712 | 864 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -715,8 +867,11 @@ discard block |
||
715 | 867 | foreach ($airlines as $airline) { |
716 | 868 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
717 | 869 | } |
718 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
719 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
870 | + if ($limit) { |
|
871 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
872 | + } else { |
|
873 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
874 | + } |
|
720 | 875 | try { |
721 | 876 | $sth = $this->db->prepare($query); |
722 | 877 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -724,11 +879,16 @@ discard block |
||
724 | 879 | echo "error : ".$e->getMessage(); |
725 | 880 | } |
726 | 881 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
727 | - } else $all = array(); |
|
882 | + } else { |
|
883 | + $all = array(); |
|
884 | + } |
|
728 | 885 | } else { |
729 | 886 | if ($year == '' && $month == '') { |
730 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
731 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
887 | + if ($limit) { |
|
888 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
889 | + } else { |
|
890 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
891 | + } |
|
732 | 892 | try { |
733 | 893 | $sth = $this->db->prepare($query); |
734 | 894 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -736,7 +896,9 @@ discard block |
||
736 | 896 | echo "error : ".$e->getMessage(); |
737 | 897 | } |
738 | 898 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
739 | - } else $all = array(); |
|
899 | + } else { |
|
900 | + $all = array(); |
|
901 | + } |
|
740 | 902 | } |
741 | 903 | if (empty($all)) { |
742 | 904 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -761,7 +923,9 @@ discard block |
||
761 | 923 | $icao = $value['airport_arrival_icao']; |
762 | 924 | if (isset($all[$icao])) { |
763 | 925 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
764 | - } else $all[$icao] = $value; |
|
926 | + } else { |
|
927 | + $all[$icao] = $value; |
|
928 | + } |
|
765 | 929 | } |
766 | 930 | $count = array(); |
767 | 931 | foreach ($all as $key => $row) { |
@@ -773,7 +937,9 @@ discard block |
||
773 | 937 | } |
774 | 938 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
775 | 939 | global $globalDBdriver, $globalStatsFilters; |
776 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
940 | + if ($filter_name == '') { |
|
941 | + $filter_name = $this->filter_name; |
|
942 | + } |
|
777 | 943 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
778 | 944 | $Spotter = new Spotter($this->db); |
779 | 945 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -782,20 +948,32 @@ discard block |
||
782 | 948 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
783 | 949 | } |
784 | 950 | if ($globalDBdriver == 'mysql') { |
785 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
786 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
951 | + if ($limit) { |
|
952 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
953 | + } else { |
|
954 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
955 | + } |
|
787 | 956 | } else { |
788 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
789 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
957 | + if ($limit) { |
|
958 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
959 | + } else { |
|
960 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
961 | + } |
|
790 | 962 | } |
791 | 963 | $query_data = array(':filter_name' => $filter_name); |
792 | 964 | } else { |
793 | 965 | if ($globalDBdriver == 'mysql') { |
794 | - 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"; |
|
795 | - 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"; |
|
966 | + if ($limit) { |
|
967 | + $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"; |
|
968 | + } else { |
|
969 | + $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"; |
|
970 | + } |
|
796 | 971 | } else { |
797 | - 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"; |
|
798 | - 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"; |
|
972 | + if ($limit) { |
|
973 | + $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"; |
|
974 | + } else { |
|
975 | + $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"; |
|
976 | + } |
|
799 | 977 | } |
800 | 978 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
801 | 979 | } |
@@ -823,7 +1001,9 @@ discard block |
||
823 | 1001 | |
824 | 1002 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
825 | 1003 | global $globalStatsFilters; |
826 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1004 | + if ($filter_name == '') { |
|
1005 | + $filter_name = $this->filter_name; |
|
1006 | + } |
|
827 | 1007 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
828 | 1008 | $Spotter = new Spotter($this->db); |
829 | 1009 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -860,7 +1040,9 @@ discard block |
||
860 | 1040 | } |
861 | 1041 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
862 | 1042 | global $globalDBdriver, $globalStatsFilters; |
863 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1043 | + if ($filter_name == '') { |
|
1044 | + $filter_name = $this->filter_name; |
|
1045 | + } |
|
864 | 1046 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
865 | 1047 | $Spotter = new Spotter($this->db); |
866 | 1048 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -905,7 +1087,9 @@ discard block |
||
905 | 1087 | } |
906 | 1088 | public function countAllDates($stats_airline = '',$filter_name = '') { |
907 | 1089 | global $globalStatsFilters; |
908 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1090 | + if ($filter_name == '') { |
|
1091 | + $filter_name = $this->filter_name; |
|
1092 | + } |
|
909 | 1093 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
910 | 1094 | $Spotter = new Spotter($this->db); |
911 | 1095 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -942,7 +1126,9 @@ discard block |
||
942 | 1126 | } |
943 | 1127 | public function countAllDatesByAirlines($filter_name = '') { |
944 | 1128 | global $globalStatsFilters; |
945 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1129 | + if ($filter_name == '') { |
|
1130 | + $filter_name = $this->filter_name; |
|
1131 | + } |
|
946 | 1132 | $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"; |
947 | 1133 | $query_data = array('filter_name' => $filter_name); |
948 | 1134 | try { |
@@ -964,7 +1150,9 @@ discard block |
||
964 | 1150 | } |
965 | 1151 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
966 | 1152 | global $globalStatsFilters, $globalDBdriver; |
967 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1153 | + if ($filter_name == '') { |
|
1154 | + $filter_name = $this->filter_name; |
|
1155 | + } |
|
968 | 1156 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
969 | 1157 | $Spotter = new Spotter($this->db); |
970 | 1158 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1049,7 +1237,9 @@ discard block |
||
1049 | 1237 | } |
1050 | 1238 | public function countAllMilitaryMonths($filter_name = '') { |
1051 | 1239 | global $globalStatsFilters; |
1052 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1240 | + if ($filter_name == '') { |
|
1241 | + $filter_name = $this->filter_name; |
|
1242 | + } |
|
1053 | 1243 | $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"; |
1054 | 1244 | try { |
1055 | 1245 | $sth = $this->db->prepare($query); |
@@ -1070,7 +1260,9 @@ discard block |
||
1070 | 1260 | } |
1071 | 1261 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
1072 | 1262 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1073 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1263 | + if ($filter_name == '') { |
|
1264 | + $filter_name = $this->filter_name; |
|
1265 | + } |
|
1074 | 1266 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1075 | 1267 | $Spotter = new Spotter($this->db); |
1076 | 1268 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1078,12 +1270,18 @@ discard block |
||
1078 | 1270 | foreach ($airlines as $airline) { |
1079 | 1271 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
1080 | 1272 | } |
1081 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1082 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1273 | + if ($limit) { |
|
1274 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1275 | + } else { |
|
1276 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1277 | + } |
|
1083 | 1278 | $query_data = array(':filter_name' => $filter_name); |
1084 | 1279 | } else { |
1085 | - 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"; |
|
1086 | - 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"; |
|
1280 | + if ($limit) { |
|
1281 | + $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"; |
|
1282 | + } else { |
|
1283 | + $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"; |
|
1284 | + } |
|
1087 | 1285 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
1088 | 1286 | } |
1089 | 1287 | if ($orderby == 'hour') { |
@@ -1093,7 +1291,9 @@ discard block |
||
1093 | 1291 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
1094 | 1292 | } |
1095 | 1293 | } |
1096 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1294 | + if ($orderby == 'count') { |
|
1295 | + $query .= " ORDER BY hour_count DESC"; |
|
1296 | + } |
|
1097 | 1297 | try { |
1098 | 1298 | $sth = $this->db->prepare($query); |
1099 | 1299 | $sth->execute($query_data); |
@@ -1117,8 +1317,12 @@ discard block |
||
1117 | 1317 | } |
1118 | 1318 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
1119 | 1319 | global $globalStatsFilters; |
1120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1121 | - if ($year == '') $year = date('Y'); |
|
1320 | + if ($filter_name == '') { |
|
1321 | + $filter_name = $this->filter_name; |
|
1322 | + } |
|
1323 | + if ($year == '') { |
|
1324 | + $year = date('Y'); |
|
1325 | + } |
|
1122 | 1326 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
1123 | 1327 | if (empty($all)) { |
1124 | 1328 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1137,8 +1341,12 @@ discard block |
||
1137 | 1341 | } |
1138 | 1342 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
1139 | 1343 | global $globalStatsFilters; |
1140 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1141 | - if ($year == '') $year = date('Y'); |
|
1344 | + if ($filter_name == '') { |
|
1345 | + $filter_name = $this->filter_name; |
|
1346 | + } |
|
1347 | + if ($year == '') { |
|
1348 | + $year = date('Y'); |
|
1349 | + } |
|
1142 | 1350 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
1143 | 1351 | if (empty($all)) { |
1144 | 1352 | $filters = array(); |
@@ -1154,8 +1362,12 @@ discard block |
||
1154 | 1362 | } |
1155 | 1363 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
1156 | 1364 | global $globalStatsFilters; |
1157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1158 | - if ($year == '') $year = date('Y'); |
|
1365 | + if ($filter_name == '') { |
|
1366 | + $filter_name = $this->filter_name; |
|
1367 | + } |
|
1368 | + if ($year == '') { |
|
1369 | + $year = date('Y'); |
|
1370 | + } |
|
1159 | 1371 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
1160 | 1372 | if (empty($all)) { |
1161 | 1373 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1174,7 +1386,9 @@ discard block |
||
1174 | 1386 | } |
1175 | 1387 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1176 | 1388 | global $globalStatsFilters; |
1177 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1389 | + if ($filter_name == '') { |
|
1390 | + $filter_name = $this->filter_name; |
|
1391 | + } |
|
1178 | 1392 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1179 | 1393 | $Spotter = new Spotter($this->db); |
1180 | 1394 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1192,7 +1406,9 @@ discard block |
||
1192 | 1406 | } |
1193 | 1407 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1194 | 1408 | $all = $result[0]['nb']; |
1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1409 | + } else { |
|
1410 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1411 | + } |
|
1196 | 1412 | } else { |
1197 | 1413 | if ($year == '' && $month == '') { |
1198 | 1414 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1204,7 +1420,9 @@ discard block |
||
1204 | 1420 | } |
1205 | 1421 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1206 | 1422 | $all = $result[0]['nb']; |
1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1423 | + } else { |
|
1424 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1425 | + } |
|
1208 | 1426 | } |
1209 | 1427 | if (empty($all)) { |
1210 | 1428 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1223,7 +1441,9 @@ discard block |
||
1223 | 1441 | } |
1224 | 1442 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
1225 | 1443 | global $globalStatsFilters; |
1226 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1444 | + if ($filter_name == '') { |
|
1445 | + $filter_name = $this->filter_name; |
|
1446 | + } |
|
1227 | 1447 | if ($year == '' && $month == '') { |
1228 | 1448 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
1229 | 1449 | try { |
@@ -1234,7 +1454,9 @@ discard block |
||
1234 | 1454 | } |
1235 | 1455 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1236 | 1456 | $all = $result[0]['nb_airline']; |
1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1457 | + } else { |
|
1458 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1459 | + } |
|
1238 | 1460 | if (empty($all)) { |
1239 | 1461 | $filters = array(); |
1240 | 1462 | $filters = array('year' => $year,'month' => $month); |
@@ -1249,7 +1471,9 @@ discard block |
||
1249 | 1471 | } |
1250 | 1472 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1251 | 1473 | global $globalStatsFilters; |
1252 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1474 | + if ($filter_name == '') { |
|
1475 | + $filter_name = $this->filter_name; |
|
1476 | + } |
|
1253 | 1477 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1254 | 1478 | $Spotter = new Spotter($this->db); |
1255 | 1479 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1304,7 +1528,9 @@ discard block |
||
1304 | 1528 | } |
1305 | 1529 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
1306 | 1530 | global $globalStatsFilters; |
1307 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1531 | + if ($filter_name == '') { |
|
1532 | + $filter_name = $this->filter_name; |
|
1533 | + } |
|
1308 | 1534 | //if ($year == '') $year = date('Y'); |
1309 | 1535 | if ($year == '' && $month == '') { |
1310 | 1536 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1333,7 +1559,9 @@ discard block |
||
1333 | 1559 | } |
1334 | 1560 | |
1335 | 1561 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
1336 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1562 | + if ($filter_name == '') { |
|
1563 | + $filter_name = $this->filter_name; |
|
1564 | + } |
|
1337 | 1565 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1338 | 1566 | $Spotter = new Spotter($this->db); |
1339 | 1567 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1357,7 +1585,9 @@ discard block |
||
1357 | 1585 | return $all; |
1358 | 1586 | } |
1359 | 1587 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
1360 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1588 | + if ($filter_name == '') { |
|
1589 | + $filter_name = $this->filter_name; |
|
1590 | + } |
|
1361 | 1591 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
1362 | 1592 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1363 | 1593 | try { |
@@ -1370,7 +1600,9 @@ discard block |
||
1370 | 1600 | return $all; |
1371 | 1601 | } |
1372 | 1602 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
1373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1603 | + if ($filter_name == '') { |
|
1604 | + $filter_name = $this->filter_name; |
|
1605 | + } |
|
1374 | 1606 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1375 | 1607 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1376 | 1608 | try { |
@@ -1381,7 +1613,9 @@ discard block |
||
1381 | 1613 | } |
1382 | 1614 | } |
1383 | 1615 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
1384 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1616 | + if ($filter_name == '') { |
|
1617 | + $filter_name = $this->filter_name; |
|
1618 | + } |
|
1385 | 1619 | global $globalArchiveMonths, $globalDBdriver; |
1386 | 1620 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1387 | 1621 | $Spotter = new Spotter($this->db); |
@@ -1437,7 +1671,9 @@ discard block |
||
1437 | 1671 | } |
1438 | 1672 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1439 | 1673 | global $globalArchiveMonths, $globalDBdriver; |
1440 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1674 | + if ($filter_name == '') { |
|
1675 | + $filter_name = $this->filter_name; |
|
1676 | + } |
|
1441 | 1677 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1442 | 1678 | $Spotter = new Spotter($this->db); |
1443 | 1679 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1470,7 +1706,9 @@ discard block |
||
1470 | 1706 | } |
1471 | 1707 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1472 | 1708 | global $globalArchiveMonths, $globalDBdriver; |
1473 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1709 | + if ($filter_name == '') { |
|
1710 | + $filter_name = $this->filter_name; |
|
1711 | + } |
|
1474 | 1712 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1475 | 1713 | $Spotter = new Spotter($this->db); |
1476 | 1714 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1501,7 +1739,9 @@ discard block |
||
1501 | 1739 | } |
1502 | 1740 | public function getStatsAirlineTotal($filter_name = '') { |
1503 | 1741 | global $globalArchiveMonths, $globalDBdriver; |
1504 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1742 | + if ($filter_name == '') { |
|
1743 | + $filter_name = $this->filter_name; |
|
1744 | + } |
|
1505 | 1745 | if ($globalDBdriver == 'mysql') { |
1506 | 1746 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1507 | 1747 | } else { |
@@ -1518,7 +1758,9 @@ discard block |
||
1518 | 1758 | } |
1519 | 1759 | public function getStatsOwnerTotal($filter_name = '') { |
1520 | 1760 | global $globalArchiveMonths, $globalDBdriver; |
1521 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1761 | + if ($filter_name == '') { |
|
1762 | + $filter_name = $this->filter_name; |
|
1763 | + } |
|
1522 | 1764 | if ($globalDBdriver == 'mysql') { |
1523 | 1765 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1524 | 1766 | } else { |
@@ -1535,7 +1777,9 @@ discard block |
||
1535 | 1777 | } |
1536 | 1778 | public function getStatsOwner($owner_name,$filter_name = '') { |
1537 | 1779 | global $globalArchiveMonths, $globalDBdriver; |
1538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1780 | + if ($filter_name == '') { |
|
1781 | + $filter_name = $this->filter_name; |
|
1782 | + } |
|
1539 | 1783 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1540 | 1784 | try { |
1541 | 1785 | $sth = $this->db->prepare($query); |
@@ -1544,12 +1788,17 @@ discard block |
||
1544 | 1788 | echo "error : ".$e->getMessage(); |
1545 | 1789 | } |
1546 | 1790 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1547 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1548 | - else return 0; |
|
1791 | + if (isset($all[0]['cnt'])) { |
|
1792 | + return $all[0]['cnt']; |
|
1793 | + } else { |
|
1794 | + return 0; |
|
1795 | + } |
|
1549 | 1796 | } |
1550 | 1797 | public function getStatsPilotTotal($filter_name = '') { |
1551 | 1798 | global $globalArchiveMonths, $globalDBdriver; |
1552 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1799 | + if ($filter_name == '') { |
|
1800 | + $filter_name = $this->filter_name; |
|
1801 | + } |
|
1553 | 1802 | if ($globalDBdriver == 'mysql') { |
1554 | 1803 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1555 | 1804 | } else { |
@@ -1566,7 +1815,9 @@ discard block |
||
1566 | 1815 | } |
1567 | 1816 | public function getStatsPilot($pilot,$filter_name = '') { |
1568 | 1817 | global $globalArchiveMonths, $globalDBdriver; |
1569 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1818 | + if ($filter_name == '') { |
|
1819 | + $filter_name = $this->filter_name; |
|
1820 | + } |
|
1570 | 1821 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1571 | 1822 | try { |
1572 | 1823 | $sth = $this->db->prepare($query); |
@@ -1575,13 +1826,18 @@ discard block |
||
1575 | 1826 | echo "error : ".$e->getMessage(); |
1576 | 1827 | } |
1577 | 1828 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1578 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1579 | - else return 0; |
|
1829 | + if (isset($all[0]['cnt'])) { |
|
1830 | + return $all[0]['cnt']; |
|
1831 | + } else { |
|
1832 | + return 0; |
|
1833 | + } |
|
1580 | 1834 | } |
1581 | 1835 | |
1582 | 1836 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1583 | 1837 | global $globalDBdriver; |
1584 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1838 | + if ($filter_name == '') { |
|
1839 | + $filter_name = $this->filter_name; |
|
1840 | + } |
|
1585 | 1841 | if ($globalDBdriver == 'mysql') { |
1586 | 1842 | $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"; |
1587 | 1843 | } else { |
@@ -1597,7 +1853,9 @@ discard block |
||
1597 | 1853 | } |
1598 | 1854 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1599 | 1855 | global $globalDBdriver; |
1600 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1856 | + if ($filter_name == '') { |
|
1857 | + $filter_name = $this->filter_name; |
|
1858 | + } |
|
1601 | 1859 | if ($globalDBdriver == 'mysql') { |
1602 | 1860 | $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"; |
1603 | 1861 | } else { |
@@ -1983,10 +2241,14 @@ discard block |
||
1983 | 2241 | $Connection = new Connection(); |
1984 | 2242 | date_default_timezone_set('UTC'); |
1985 | 2243 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1986 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
2244 | + if ($globalDebug) { |
|
2245 | + echo 'Update stats !'."\n"; |
|
2246 | + } |
|
1987 | 2247 | if (isset($last_update[0]['value'])) { |
1988 | 2248 | $last_update_day = $last_update[0]['value']; |
1989 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2249 | + } else { |
|
2250 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2251 | + } |
|
1990 | 2252 | $reset = false; |
1991 | 2253 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
1992 | 2254 | if ($globalStatsResetYear) { |
@@ -1995,43 +2257,63 @@ discard block |
||
1995 | 2257 | } |
1996 | 2258 | $Spotter = new Spotter($this->db); |
1997 | 2259 | |
1998 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
2260 | + if ($globalDebug) { |
|
2261 | + echo 'Count all aircraft types...'."\n"; |
|
2262 | + } |
|
1999 | 2263 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
2000 | 2264 | foreach ($alldata as $number) { |
2001 | 2265 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
2002 | 2266 | } |
2003 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
2267 | + if ($globalDebug) { |
|
2268 | + echo 'Count all airlines...'."\n"; |
|
2269 | + } |
|
2004 | 2270 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
2005 | 2271 | foreach ($alldata as $number) { |
2006 | 2272 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
2007 | 2273 | } |
2008 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
2274 | + if ($globalDebug) { |
|
2275 | + echo 'Count all registrations...'."\n"; |
|
2276 | + } |
|
2009 | 2277 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
2010 | 2278 | foreach ($alldata as $number) { |
2011 | 2279 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
2012 | 2280 | } |
2013 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
2281 | + if ($globalDebug) { |
|
2282 | + echo 'Count all callsigns...'."\n"; |
|
2283 | + } |
|
2014 | 2284 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
2015 | 2285 | foreach ($alldata as $number) { |
2016 | 2286 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2017 | 2287 | } |
2018 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
2288 | + if ($globalDebug) { |
|
2289 | + echo 'Count all owners...'."\n"; |
|
2290 | + } |
|
2019 | 2291 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
2020 | 2292 | foreach ($alldata as $number) { |
2021 | 2293 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
2022 | 2294 | } |
2023 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
2295 | + if ($globalDebug) { |
|
2296 | + echo 'Count all pilots...'."\n"; |
|
2297 | + } |
|
2024 | 2298 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
2025 | 2299 | foreach ($alldata as $number) { |
2026 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
2300 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
2301 | + $number['pilot_id'] = $number['pilot_name']; |
|
2302 | + } |
|
2027 | 2303 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
2028 | 2304 | } |
2029 | 2305 | |
2030 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
2306 | + if ($globalDebug) { |
|
2307 | + echo 'Count all departure airports...'."\n"; |
|
2308 | + } |
|
2031 | 2309 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
2032 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
2310 | + if ($globalDebug) { |
|
2311 | + echo 'Count all detected departure airports...'."\n"; |
|
2312 | + } |
|
2033 | 2313 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
2034 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
2314 | + if ($globalDebug) { |
|
2315 | + echo 'Order departure airports...'."\n"; |
|
2316 | + } |
|
2035 | 2317 | $alldata = array(); |
2036 | 2318 | foreach ($pall as $value) { |
2037 | 2319 | $icao = $value['airport_departure_icao']; |
@@ -2041,7 +2323,9 @@ discard block |
||
2041 | 2323 | $icao = $value['airport_departure_icao']; |
2042 | 2324 | if (isset($alldata[$icao])) { |
2043 | 2325 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2044 | - } else $alldata[$icao] = $value; |
|
2326 | + } else { |
|
2327 | + $alldata[$icao] = $value; |
|
2328 | + } |
|
2045 | 2329 | } |
2046 | 2330 | $count = array(); |
2047 | 2331 | foreach ($alldata as $key => $row) { |
@@ -2051,11 +2335,17 @@ discard block |
||
2051 | 2335 | foreach ($alldata as $number) { |
2052 | 2336 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
2053 | 2337 | } |
2054 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
2338 | + if ($globalDebug) { |
|
2339 | + echo 'Count all arrival airports...'."\n"; |
|
2340 | + } |
|
2055 | 2341 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
2056 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
2342 | + if ($globalDebug) { |
|
2343 | + echo 'Count all detected arrival airports...'."\n"; |
|
2344 | + } |
|
2057 | 2345 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
2058 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
2346 | + if ($globalDebug) { |
|
2347 | + echo 'Order arrival airports...'."\n"; |
|
2348 | + } |
|
2059 | 2349 | $alldata = array(); |
2060 | 2350 | foreach ($pall as $value) { |
2061 | 2351 | $icao = $value['airport_arrival_icao']; |
@@ -2065,7 +2355,9 @@ discard block |
||
2065 | 2355 | $icao = $value['airport_arrival_icao']; |
2066 | 2356 | if (isset($alldata[$icao])) { |
2067 | 2357 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2068 | - } else $alldata[$icao] = $value; |
|
2358 | + } else { |
|
2359 | + $alldata[$icao] = $value; |
|
2360 | + } |
|
2069 | 2361 | } |
2070 | 2362 | $count = array(); |
2071 | 2363 | foreach ($alldata as $key => $row) { |
@@ -2076,7 +2368,9 @@ discard block |
||
2076 | 2368 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
2077 | 2369 | } |
2078 | 2370 | if ($Connection->tableExists('countries')) { |
2079 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
2371 | + if ($globalDebug) { |
|
2372 | + echo 'Count all flights by countries...'."\n"; |
|
2373 | + } |
|
2080 | 2374 | //$SpotterArchive = new SpotterArchive(); |
2081 | 2375 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
2082 | 2376 | $Spotter = new Spotter($this->db); |
@@ -2087,7 +2381,9 @@ discard block |
||
2087 | 2381 | } |
2088 | 2382 | |
2089 | 2383 | if (isset($globalAccidents) && $globalAccidents) { |
2090 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
2384 | + if ($globalDebug) { |
|
2385 | + echo 'Count fatalities stats...'."\n"; |
|
2386 | + } |
|
2091 | 2387 | $Accident = new Accident(); |
2092 | 2388 | $this->deleteStatsByType('fatalities_byyear'); |
2093 | 2389 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2103,48 +2399,68 @@ discard block |
||
2103 | 2399 | |
2104 | 2400 | // Add by month using getstat if month finish... |
2105 | 2401 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
2106 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
2402 | + if ($globalDebug) { |
|
2403 | + echo 'Count all flights by months...'."\n"; |
|
2404 | + } |
|
2107 | 2405 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2108 | 2406 | $filter_last_month = array('since_date' => $last_month); |
2109 | 2407 | $Spotter = new Spotter($this->db); |
2110 | 2408 | $alldata = $Spotter->countAllMonths($filter_last_month); |
2111 | 2409 | $lastyear = false; |
2112 | 2410 | foreach ($alldata as $number) { |
2113 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2411 | + if ($number['year_name'] != date('Y')) { |
|
2412 | + $lastyear = true; |
|
2413 | + } |
|
2114 | 2414 | $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']))); |
2115 | 2415 | } |
2116 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
2416 | + if ($globalDebug) { |
|
2417 | + echo 'Count all military flights by months...'."\n"; |
|
2418 | + } |
|
2117 | 2419 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
2118 | 2420 | foreach ($alldata as $number) { |
2119 | 2421 | $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']))); |
2120 | 2422 | } |
2121 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
2423 | + if ($globalDebug) { |
|
2424 | + echo 'Count all owners by months...'."\n"; |
|
2425 | + } |
|
2122 | 2426 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
2123 | 2427 | foreach ($alldata as $number) { |
2124 | 2428 | $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']))); |
2125 | 2429 | } |
2126 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
2430 | + if ($globalDebug) { |
|
2431 | + echo 'Count all pilots by months...'."\n"; |
|
2432 | + } |
|
2127 | 2433 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
2128 | 2434 | foreach ($alldata as $number) { |
2129 | 2435 | $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']))); |
2130 | 2436 | } |
2131 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
2437 | + if ($globalDebug) { |
|
2438 | + echo 'Count all airlines by months...'."\n"; |
|
2439 | + } |
|
2132 | 2440 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
2133 | 2441 | foreach ($alldata as $number) { |
2134 | 2442 | $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']))); |
2135 | 2443 | } |
2136 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
2444 | + if ($globalDebug) { |
|
2445 | + echo 'Count all aircrafts by months...'."\n"; |
|
2446 | + } |
|
2137 | 2447 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
2138 | 2448 | foreach ($alldata as $number) { |
2139 | 2449 | $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']))); |
2140 | 2450 | } |
2141 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
2451 | + if ($globalDebug) { |
|
2452 | + echo 'Count all real arrivals by months...'."\n"; |
|
2453 | + } |
|
2142 | 2454 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
2143 | 2455 | foreach ($alldata as $number) { |
2144 | 2456 | $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']))); |
2145 | 2457 | } |
2146 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
2147 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2458 | + if ($globalDebug) { |
|
2459 | + echo 'Airports data...'."\n"; |
|
2460 | + } |
|
2461 | + if ($globalDebug) { |
|
2462 | + echo '...Departure'."\n"; |
|
2463 | + } |
|
2148 | 2464 | $this->deleteStatAirport('daily'); |
2149 | 2465 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
2150 | 2466 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2262,7 +2578,9 @@ discard block |
||
2262 | 2578 | // Count by airlines |
2263 | 2579 | echo '--- Stats by airlines ---'."\n"; |
2264 | 2580 | if ($Connection->tableExists('countries')) { |
2265 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
2581 | + if ($globalDebug) { |
|
2582 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
2583 | + } |
|
2266 | 2584 | $SpotterArchive = new SpotterArchive(); |
2267 | 2585 | //$Spotter = new Spotter($this->db); |
2268 | 2586 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2271,37 +2589,53 @@ discard block |
||
2271 | 2589 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
2272 | 2590 | } |
2273 | 2591 | } |
2274 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
2592 | + if ($globalDebug) { |
|
2593 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
2594 | + } |
|
2275 | 2595 | $Spotter = new Spotter($this->db); |
2276 | 2596 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
2277 | 2597 | foreach ($alldata as $number) { |
2278 | 2598 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
2279 | 2599 | } |
2280 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2600 | + if ($globalDebug) { |
|
2601 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2602 | + } |
|
2281 | 2603 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
2282 | 2604 | foreach ($alldata as $number) { |
2283 | 2605 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
2284 | 2606 | } |
2285 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
2607 | + if ($globalDebug) { |
|
2608 | + echo 'Count all callsigns by airlines...'."\n"; |
|
2609 | + } |
|
2286 | 2610 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
2287 | 2611 | foreach ($alldata as $number) { |
2288 | 2612 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2289 | 2613 | } |
2290 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
2614 | + if ($globalDebug) { |
|
2615 | + echo 'Count all owners by airlines...'."\n"; |
|
2616 | + } |
|
2291 | 2617 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
2292 | 2618 | foreach ($alldata as $number) { |
2293 | 2619 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
2294 | 2620 | } |
2295 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
2621 | + if ($globalDebug) { |
|
2622 | + echo 'Count all pilots by airlines...'."\n"; |
|
2623 | + } |
|
2296 | 2624 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
2297 | 2625 | foreach ($alldata as $number) { |
2298 | 2626 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
2299 | 2627 | } |
2300 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
2628 | + if ($globalDebug) { |
|
2629 | + echo 'Count all departure airports by airlines...'."\n"; |
|
2630 | + } |
|
2301 | 2631 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
2302 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
2632 | + if ($globalDebug) { |
|
2633 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2634 | + } |
|
2303 | 2635 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
2304 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2636 | + if ($globalDebug) { |
|
2637 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2638 | + } |
|
2305 | 2639 | //$alldata = array(); |
2306 | 2640 | foreach ($dall as $value) { |
2307 | 2641 | $icao = $value['airport_departure_icao']; |
@@ -2322,11 +2656,17 @@ discard block |
||
2322 | 2656 | foreach ($alldata as $number) { |
2323 | 2657 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
2324 | 2658 | } |
2325 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2659 | + if ($globalDebug) { |
|
2660 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2661 | + } |
|
2326 | 2662 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
2327 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2663 | + if ($globalDebug) { |
|
2664 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2665 | + } |
|
2328 | 2666 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
2329 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2667 | + if ($globalDebug) { |
|
2668 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2669 | + } |
|
2330 | 2670 | //$alldata = array(); |
2331 | 2671 | foreach ($dall as $value) { |
2332 | 2672 | $icao = $value['airport_arrival_icao']; |
@@ -2345,37 +2685,53 @@ discard block |
||
2345 | 2685 | } |
2346 | 2686 | $alldata = $pall; |
2347 | 2687 | foreach ($alldata as $number) { |
2348 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2688 | + if ($number['airline_icao'] != '') { |
|
2689 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2690 | + } |
|
2691 | + } |
|
2692 | + if ($globalDebug) { |
|
2693 | + echo 'Count all flights by months by airlines...'."\n"; |
|
2349 | 2694 | } |
2350 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
2351 | 2695 | $Spotter = new Spotter($this->db); |
2352 | 2696 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
2353 | 2697 | $lastyear = false; |
2354 | 2698 | foreach ($alldata as $number) { |
2355 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2699 | + if ($number['year_name'] != date('Y')) { |
|
2700 | + $lastyear = true; |
|
2701 | + } |
|
2356 | 2702 | $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']); |
2357 | 2703 | } |
2358 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2704 | + if ($globalDebug) { |
|
2705 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2706 | + } |
|
2359 | 2707 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
2360 | 2708 | foreach ($alldata as $number) { |
2361 | 2709 | $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']); |
2362 | 2710 | } |
2363 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2711 | + if ($globalDebug) { |
|
2712 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2713 | + } |
|
2364 | 2714 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
2365 | 2715 | foreach ($alldata as $number) { |
2366 | 2716 | $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']); |
2367 | 2717 | } |
2368 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2718 | + if ($globalDebug) { |
|
2719 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2720 | + } |
|
2369 | 2721 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
2370 | 2722 | foreach ($alldata as $number) { |
2371 | 2723 | $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']); |
2372 | 2724 | } |
2373 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2725 | + if ($globalDebug) { |
|
2726 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2727 | + } |
|
2374 | 2728 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
2375 | 2729 | foreach ($alldata as $number) { |
2376 | 2730 | $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']); |
2377 | 2731 | } |
2378 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2732 | + if ($globalDebug) { |
|
2733 | + echo '...Departure'."\n"; |
|
2734 | + } |
|
2379 | 2735 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
2380 | 2736 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
2381 | 2737 | foreach ($dall as $value) { |
@@ -2398,7 +2754,9 @@ discard block |
||
2398 | 2754 | foreach ($alldata as $number) { |
2399 | 2755 | $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']); |
2400 | 2756 | } |
2401 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2757 | + if ($globalDebug) { |
|
2758 | + echo '...Arrival'."\n"; |
|
2759 | + } |
|
2402 | 2760 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
2403 | 2761 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
2404 | 2762 | foreach ($dall as $value) { |
@@ -2422,13 +2780,19 @@ discard block |
||
2422 | 2780 | $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']); |
2423 | 2781 | } |
2424 | 2782 | |
2425 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
2426 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2783 | + if ($globalDebug) { |
|
2784 | + echo 'Flights data...'."\n"; |
|
2785 | + } |
|
2786 | + if ($globalDebug) { |
|
2787 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2788 | + } |
|
2427 | 2789 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
2428 | 2790 | foreach ($alldata as $number) { |
2429 | 2791 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
2430 | 2792 | } |
2431 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2793 | + if ($globalDebug) { |
|
2794 | + echo '-> countAllDates...'."\n"; |
|
2795 | + } |
|
2432 | 2796 | //$previousdata = $this->countAllDatesByAirlines(); |
2433 | 2797 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
2434 | 2798 | $values = array(); |
@@ -2441,21 +2805,27 @@ discard block |
||
2441 | 2805 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
2442 | 2806 | } |
2443 | 2807 | |
2444 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2808 | + if ($globalDebug) { |
|
2809 | + echo '-> countAllHours...'."\n"; |
|
2810 | + } |
|
2445 | 2811 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
2446 | 2812 | foreach ($alldata as $number) { |
2447 | 2813 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
2448 | 2814 | } |
2449 | 2815 | |
2450 | 2816 | // Stats by filters |
2451 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2817 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2818 | + $globalStatsFilters = array(); |
|
2819 | + } |
|
2452 | 2820 | foreach ($globalStatsFilters as $name => $filter) { |
2453 | 2821 | //$filter_name = $filter['name']; |
2454 | 2822 | $filter_name = $name; |
2455 | 2823 | $reset = false; |
2456 | 2824 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
2457 | 2825 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
2458 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2826 | + if ($globalDebug) { |
|
2827 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2828 | + } |
|
2459 | 2829 | $this->deleteOldStats($filter_name); |
2460 | 2830 | unset($last_update); |
2461 | 2831 | } |
@@ -2474,7 +2844,9 @@ discard block |
||
2474 | 2844 | |
2475 | 2845 | |
2476 | 2846 | // Count by filter |
2477 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2847 | + if ($globalDebug) { |
|
2848 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2849 | + } |
|
2478 | 2850 | $Spotter = new Spotter($this->db); |
2479 | 2851 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
2480 | 2852 | foreach ($alldata as $number) { |
@@ -2511,7 +2883,9 @@ discard block |
||
2511 | 2883 | $icao = $value['airport_departure_icao']; |
2512 | 2884 | if (isset($alldata[$icao])) { |
2513 | 2885 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2514 | - } else $alldata[$icao] = $value; |
|
2886 | + } else { |
|
2887 | + $alldata[$icao] = $value; |
|
2888 | + } |
|
2515 | 2889 | } |
2516 | 2890 | $count = array(); |
2517 | 2891 | foreach ($alldata as $key => $row) { |
@@ -2532,7 +2906,9 @@ discard block |
||
2532 | 2906 | $icao = $value['airport_arrival_icao']; |
2533 | 2907 | if (isset($alldata[$icao])) { |
2534 | 2908 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2535 | - } else $alldata[$icao] = $value; |
|
2909 | + } else { |
|
2910 | + $alldata[$icao] = $value; |
|
2911 | + } |
|
2536 | 2912 | } |
2537 | 2913 | $count = array(); |
2538 | 2914 | foreach ($alldata as $key => $row) { |
@@ -2546,7 +2922,9 @@ discard block |
||
2546 | 2922 | $alldata = $Spotter->countAllMonths($filter); |
2547 | 2923 | $lastyear = false; |
2548 | 2924 | foreach ($alldata as $number) { |
2549 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2925 | + if ($number['year_name'] != date('Y')) { |
|
2926 | + $lastyear = true; |
|
2927 | + } |
|
2550 | 2928 | $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); |
2551 | 2929 | } |
2552 | 2930 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -73,8 +73,11 @@ discard block |
||
73 | 73 | $globalDBSname = $globalDBname; |
74 | 74 | $globalDBSuser = $globalDBuser; |
75 | 75 | $globalDBSpass = $globalDBpass; |
76 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
77 | - else $globalDBSport = $globalDBport; |
|
76 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
77 | + $globalDBSport = 3306; |
|
78 | + } else { |
|
79 | + $globalDBSport = $globalDBport; |
|
80 | + } |
|
78 | 81 | } else { |
79 | 82 | $DBname = 'default'; |
80 | 83 | $globalDBSdriver = $globalDBdriver; |
@@ -82,8 +85,11 @@ discard block |
||
82 | 85 | $globalDBSname = $globalDBname; |
83 | 86 | $globalDBSuser = $user; |
84 | 87 | $globalDBSpass = $pass; |
85 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
86 | - else $globalDBSport = $globalDBport; |
|
88 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
89 | + $globalDBSport = 3306; |
|
90 | + } else { |
|
91 | + $globalDBSport = $globalDBport; |
|
92 | + } |
|
87 | 93 | } |
88 | 94 | } else { |
89 | 95 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -91,12 +97,19 @@ discard block |
||
91 | 97 | $globalDBSname = $globalDB[$DBname]['name']; |
92 | 98 | $globalDBSuser = $globalDB[$DBname]['user']; |
93 | 99 | $globalDBSpass = $globalDB[$DBname]['pass']; |
94 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
95 | - else $globalDBSport = 3306; |
|
100 | + if (isset($globalDB[$DBname]['port'])) { |
|
101 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
102 | + } else { |
|
103 | + $globalDBSport = 3306; |
|
104 | + } |
|
105 | + } |
|
106 | + if ($globalDBSname == '' || $globalDBSuser == '') { |
|
107 | + return false; |
|
96 | 108 | } |
97 | - if ($globalDBSname == '' || $globalDBSuser == '') return false; |
|
98 | 109 | // Set number of try to connect to DB |
99 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
110 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
111 | + $globalDBretry = 5; |
|
112 | + } |
|
100 | 113 | $i = 0; |
101 | 114 | while (true) { |
102 | 115 | try { |
@@ -105,10 +118,16 @@ discard block |
||
105 | 118 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
106 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
107 | 120 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
108 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
109 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
110 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
111 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
121 | + if (!isset($globalDBTimeOut)) { |
|
122 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
123 | + } else { |
|
124 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
125 | + } |
|
126 | + if (!isset($globalDBPersistent)) { |
|
127 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
128 | + } else { |
|
129 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
130 | + } |
|
112 | 131 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
113 | 132 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
114 | 133 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -122,24 +141,36 @@ discard block |
||
122 | 141 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
123 | 142 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
124 | 143 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
125 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
126 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
127 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
128 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
144 | + if (!isset($globalDBTimeOut)) { |
|
145 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
146 | + } else { |
|
147 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
148 | + } |
|
149 | + if (!isset($globalDBPersistent)) { |
|
150 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
151 | + } else { |
|
152 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
153 | + } |
|
129 | 154 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
130 | 155 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
131 | 156 | } |
132 | 157 | break; |
133 | 158 | } catch(PDOException $e) { |
134 | 159 | $i++; |
135 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
160 | + if (isset($globalDebug) && $globalDebug) { |
|
161 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
162 | + } |
|
136 | 163 | //exit; |
137 | - if ($i > $globalDBretry) return false; |
|
164 | + if ($i > $globalDBretry) { |
|
165 | + return false; |
|
166 | + } |
|
138 | 167 | //return false; |
139 | 168 | } |
140 | 169 | sleep(2); |
141 | 170 | } |
142 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
171 | + if ($DBname === 'default') { |
|
172 | + $this->db = $this->dbs['default']; |
|
173 | + } |
|
143 | 174 | return true; |
144 | 175 | } |
145 | 176 | |
@@ -151,7 +182,9 @@ discard block |
||
151 | 182 | } else { |
152 | 183 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
153 | 184 | } |
154 | - if ($this->db == NULL) return false; |
|
185 | + if ($this->db == NULL) { |
|
186 | + return false; |
|
187 | + } |
|
155 | 188 | try { |
156 | 189 | //$Connection = new Connection(); |
157 | 190 | $results = $this->db->query($query); |
@@ -160,22 +193,31 @@ discard block |
||
160 | 193 | } |
161 | 194 | if($results->rowCount()>0) { |
162 | 195 | return true; |
196 | + } else { |
|
197 | + return false; |
|
163 | 198 | } |
164 | - else return false; |
|
165 | 199 | } |
166 | 200 | |
167 | 201 | public function connectionExists() |
168 | 202 | { |
169 | 203 | global $globalDBdriver, $globalDBCheckConnection, $globalNoDB; |
170 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
171 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
204 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
205 | + return true; |
|
206 | + } |
|
207 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
208 | + return true; |
|
209 | + } |
|
172 | 210 | $query = "SELECT 1 + 1"; |
173 | - if ($this->db === null) return false; |
|
211 | + if ($this->db === null) { |
|
212 | + return false; |
|
213 | + } |
|
174 | 214 | try { |
175 | 215 | $sum = @$this->db->query($query); |
176 | 216 | if ($sum instanceof \PDOStatement) { |
177 | 217 | $sum = $sum->fetchColumn(0); |
178 | - } else $sum = 0; |
|
218 | + } else { |
|
219 | + $sum = 0; |
|
220 | + } |
|
179 | 221 | if (intval($sum) !== 2) { |
180 | 222 | return false; |
181 | 223 | } |
@@ -210,8 +252,9 @@ discard block |
||
210 | 252 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
211 | 253 | if($nb[0]['nb'] > 0) { |
212 | 254 | return true; |
255 | + } else { |
|
256 | + return false; |
|
213 | 257 | } |
214 | - else return false; |
|
215 | 258 | } |
216 | 259 | |
217 | 260 | /* |
@@ -261,9 +304,12 @@ discard block |
||
261 | 304 | } |
262 | 305 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
263 | 306 | $sth->closeCursor(); |
264 | - if ($result['nb'] > 0) return true; |
|
265 | - else return false; |
|
266 | -/* } else { |
|
307 | + if ($result['nb'] > 0) { |
|
308 | + return true; |
|
309 | + } else { |
|
310 | + return false; |
|
311 | + } |
|
312 | + /* } else { |
|
267 | 313 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
268 | 314 | try { |
269 | 315 | $results = $this->db->query($query); |
@@ -302,7 +348,9 @@ discard block |
||
302 | 348 | $sth->closeCursor(); |
303 | 349 | return $result['value']; |
304 | 350 | } |
305 | - } else return $version; |
|
351 | + } else { |
|
352 | + return $version; |
|
353 | + } |
|
306 | 354 | } |
307 | 355 | |
308 | 356 | /* |
@@ -311,9 +359,14 @@ discard block |
||
311 | 359 | */ |
312 | 360 | public function latest() { |
313 | 361 | global $globalNoDB; |
314 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
315 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
316 | - else return false; |
|
362 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
363 | + return true; |
|
364 | + } |
|
365 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
366 | + return true; |
|
367 | + } else { |
|
368 | + return false; |
|
369 | + } |
|
317 | 370 | } |
318 | 371 | |
319 | 372 | } |