@@ -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 | $Marine = new Marine($this->db); |
90 | 97 | $data_country = $Marine->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 | |
95 | 107 | //$country = $over_country; |
96 | 108 | // Route is not added in marine_archive |
@@ -593,7 +605,9 @@ discard block |
||
593 | 605 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
594 | 606 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
595 | 607 | $translate = $Translation->ident2icao($q_item); |
596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
608 | + if ($translate != $q_item) { |
|
609 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
610 | + } |
|
597 | 611 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
598 | 612 | $additional_query .= ")"; |
599 | 613 | } |
@@ -811,7 +825,9 @@ discard block |
||
811 | 825 | date_default_timezone_set($globalTimezone); |
812 | 826 | $datetime = new DateTime(); |
813 | 827 | $offset = $datetime->format('P'); |
814 | - } else $offset = '+00:00'; |
|
828 | + } else { |
|
829 | + $offset = '+00:00'; |
|
830 | + } |
|
815 | 831 | |
816 | 832 | |
817 | 833 | if ($date_array[1] != "") |
@@ -1087,9 +1103,13 @@ discard block |
||
1087 | 1103 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1088 | 1104 | } |
1089 | 1105 | } |
1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1106 | + if ($sincedate != '') { |
|
1107 | + $query .= "AND date > '".$sincedate."' "; |
|
1108 | + } |
|
1091 | 1109 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1092 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1110 | + if ($limit) { |
|
1111 | + $query .= " LIMIT 0,10"; |
|
1112 | + } |
|
1093 | 1113 | |
1094 | 1114 | |
1095 | 1115 | $sth = $this->db->prepare($query); |
@@ -1133,9 +1153,13 @@ discard block |
||
1133 | 1153 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1134 | 1154 | } |
1135 | 1155 | } |
1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1156 | + if ($sincedate != '') { |
|
1157 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1158 | + } |
|
1137 | 1159 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1138 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1160 | + if ($limit) { |
|
1161 | + $query .= " LIMIT 0,10"; |
|
1162 | + } |
|
1139 | 1163 | |
1140 | 1164 | |
1141 | 1165 | $sth = $this->db->prepare($query); |
@@ -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); |
@@ -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 | ?> |
@@ -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 | } |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -803,12 +855,16 @@ discard block |
||
803 | 855 | if ($globalDBdriver == 'mysql') { |
804 | 856 | if (!$Connection->tableExists('tle')) { |
805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
806 | - if ($error != '') return $error; |
|
858 | + if ($error != '') { |
|
859 | + return $error; |
|
860 | + } |
|
807 | 861 | } |
808 | 862 | } else { |
809 | 863 | if (!$Connection->tableExists('tle')) { |
810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
811 | - if ($error != '') return $error; |
|
865 | + if ($error != '') { |
|
866 | + return $error; |
|
867 | + } |
|
812 | 868 | } |
813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
848 | 904 | } else { |
849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 906 | } |
851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
907 | + if ($error != '') { |
|
908 | + return 'Import airlines.sql : '.$error; |
|
909 | + } |
|
852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
853 | 911 | // Add forsource to airlines |
854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
1331 | 1389 | } |
1332 | 1390 | if ($globalDBdriver == 'mysql') { |
1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
1334 | - if ($error != '') return $error; |
|
1392 | + if ($error != '') { |
|
1393 | + return $error; |
|
1394 | + } |
|
1335 | 1395 | } else { |
1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1337 | - if ($error != '') return $error; |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } |
|
1338 | 1400 | } |
1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
1342 | 1404 | $error .= update_db::update_vatsim(); |
1343 | - if ($error != '') return $error; |
|
1405 | + if ($error != '') { |
|
1406 | + return $error; |
|
1407 | + } |
|
1344 | 1408 | } |
1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1346 | 1410 | $error .= update_db::update_IVAO(); |
1347 | - if ($error != '') return $error; |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } |
|
1348 | 1414 | } |
1349 | 1415 | } |
1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
1607 | 1673 | if ($globalDBdriver == 'mysql') { |
1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1610 | - if ($error != '') return $error; |
|
1676 | + if ($error != '') { |
|
1677 | + return $error; |
|
1678 | + } |
|
1611 | 1679 | } |
1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1614 | - if ($error != '') return $error; |
|
1682 | + if ($error != '') { |
|
1683 | + return $error; |
|
1684 | + } |
|
1615 | 1685 | } |
1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
1618 | - if ($error != '') return $error; |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } |
|
1619 | 1691 | } |
1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
1622 | - if ($error != '') return $error; |
|
1694 | + if ($error != '') { |
|
1695 | + return $error; |
|
1696 | + } |
|
1623 | 1697 | } |
1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1626 | - if ($error != '') return $error; |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } |
|
1627 | 1703 | } |
1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1630 | - if ($error != '') return $error; |
|
1706 | + if ($error != '') { |
|
1707 | + return $error; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } else { |
1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1634 | - if ($error != '') return $error; |
|
1712 | + if ($error != '') { |
|
1713 | + return $error; |
|
1714 | + } |
|
1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1636 | - if ($error != '') return $error; |
|
1716 | + if ($error != '') { |
|
1717 | + return $error; |
|
1718 | + } |
|
1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1638 | - if ($error != '') return $error; |
|
1720 | + if ($error != '') { |
|
1721 | + return $error; |
|
1722 | + } |
|
1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1640 | - if ($error != '') return $error; |
|
1724 | + if ($error != '') { |
|
1725 | + return $error; |
|
1726 | + } |
|
1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1642 | - if ($error != '') return $error; |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } |
|
1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1644 | - if ($error != '') return $error; |
|
1732 | + if ($error != '') { |
|
1733 | + return $error; |
|
1734 | + } |
|
1645 | 1735 | } |
1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
1660 | 1750 | if ($globalDBdriver == 'mysql') { |
1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
1663 | - if ($error != '') return $error; |
|
1753 | + if ($error != '') { |
|
1754 | + return $error; |
|
1755 | + } |
|
1664 | 1756 | } |
1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1667 | - if ($error != '') return $error; |
|
1759 | + if ($error != '') { |
|
1760 | + return $error; |
|
1761 | + } |
|
1668 | 1762 | } |
1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1671 | - if ($error != '') return $error; |
|
1765 | + if ($error != '') { |
|
1766 | + return $error; |
|
1767 | + } |
|
1672 | 1768 | } |
1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1675 | - if ($error != '') return $error; |
|
1771 | + if ($error != '') { |
|
1772 | + return $error; |
|
1773 | + } |
|
1676 | 1774 | } |
1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1679 | - if ($error != '') return $error; |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } |
|
1680 | 1780 | } |
1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1683 | - if ($error != '') return $error; |
|
1783 | + if ($error != '') { |
|
1784 | + return $error; |
|
1785 | + } |
|
1684 | 1786 | } |
1685 | 1787 | } else { |
1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1687 | - if ($error != '') return $error; |
|
1789 | + if ($error != '') { |
|
1790 | + return $error; |
|
1791 | + } |
|
1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1689 | - if ($error != '') return $error; |
|
1793 | + if ($error != '') { |
|
1794 | + return $error; |
|
1795 | + } |
|
1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1691 | - if ($error != '') return $error; |
|
1797 | + if ($error != '') { |
|
1798 | + return $error; |
|
1799 | + } |
|
1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1693 | - if ($error != '') return $error; |
|
1801 | + if ($error != '') { |
|
1802 | + return $error; |
|
1803 | + } |
|
1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1695 | - if ($error != '') return $error; |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } |
|
1696 | 1808 | } |
1697 | 1809 | if ($globalDBdriver == 'mysql') { |
1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
2063 | 2175 | if ($globalDBdriver == 'mysql') { |
2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
2066 | - if ($error != '') return $error; |
|
2178 | + if ($error != '') { |
|
2179 | + return $error; |
|
2180 | + } |
|
2067 | 2181 | } |
2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
2091 | 2205 | $error = ''; |
2092 | 2206 | if ($globalDBdriver == 'mysql') { |
2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
2094 | - if ($error != '') return $error; |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } |
|
2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
2096 | - if ($error != '') return $error; |
|
2212 | + if ($error != '') { |
|
2213 | + return $error; |
|
2214 | + } |
|
2097 | 2215 | } else { |
2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2099 | - if ($error != '') return $error; |
|
2217 | + if ($error != '') { |
|
2218 | + return $error; |
|
2219 | + } |
|
2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
2101 | - if ($error != '') return $error; |
|
2221 | + if ($error != '') { |
|
2222 | + return $error; |
|
2223 | + } |
|
2102 | 2224 | } |
2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
2115 | 2237 | $error .= update_db::update_vatsim(); |
2116 | 2238 | } |
2117 | 2239 | } |
2118 | - if ($error != '') return $error; |
|
2240 | + if ($error != '') { |
|
2241 | + return $error; |
|
2242 | + } |
|
2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
2120 | 2244 | try { |
2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
2134 | 2258 | if ($globalDBdriver == 'mysql') { |
2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
2136 | - if ($error != '') return $error; |
|
2260 | + if ($error != '') { |
|
2261 | + return $error; |
|
2262 | + } |
|
2137 | 2263 | } else { |
2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
2139 | - if ($error != '') return $error; |
|
2265 | + if ($error != '') { |
|
2266 | + return $error; |
|
2267 | + } |
|
2140 | 2268 | } |
2141 | 2269 | } |
2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2159,8 +2287,11 @@ discard block |
||
2159 | 2287 | if ($Connection->tableExists('aircraft')) { |
2160 | 2288 | if (!$Connection->tableExists('config')) { |
2161 | 2289 | $version = '1'; |
2162 | - if ($update) return self::update_from_1(); |
|
2163 | - else return $version; |
|
2290 | + if ($update) { |
|
2291 | + return self::update_from_1(); |
|
2292 | + } else { |
|
2293 | + return $version; |
|
2294 | + } |
|
2164 | 2295 | } else { |
2165 | 2296 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2166 | 2297 | try { |
@@ -2173,187 +2304,326 @@ discard block |
||
2173 | 2304 | if ($update) { |
2174 | 2305 | if ($result['value'] == '2') { |
2175 | 2306 | $error = self::update_from_2(); |
2176 | - if ($error != '') return $error; |
|
2177 | - else return self::check_version(true); |
|
2307 | + if ($error != '') { |
|
2308 | + return $error; |
|
2309 | + } else { |
|
2310 | + return self::check_version(true); |
|
2311 | + } |
|
2178 | 2312 | } elseif ($result['value'] == '3') { |
2179 | 2313 | $error = self::update_from_3(); |
2180 | - if ($error != '') return $error; |
|
2181 | - else return self::check_version(true); |
|
2314 | + if ($error != '') { |
|
2315 | + return $error; |
|
2316 | + } else { |
|
2317 | + return self::check_version(true); |
|
2318 | + } |
|
2182 | 2319 | } elseif ($result['value'] == '4') { |
2183 | 2320 | $error = self::update_from_4(); |
2184 | - if ($error != '') return $error; |
|
2185 | - else return self::check_version(true); |
|
2321 | + if ($error != '') { |
|
2322 | + return $error; |
|
2323 | + } else { |
|
2324 | + return self::check_version(true); |
|
2325 | + } |
|
2186 | 2326 | } elseif ($result['value'] == '5') { |
2187 | 2327 | $error = self::update_from_5(); |
2188 | - if ($error != '') return $error; |
|
2189 | - else return self::check_version(true); |
|
2328 | + if ($error != '') { |
|
2329 | + return $error; |
|
2330 | + } else { |
|
2331 | + return self::check_version(true); |
|
2332 | + } |
|
2190 | 2333 | } elseif ($result['value'] == '6') { |
2191 | 2334 | $error = self::update_from_6(); |
2192 | - if ($error != '') return $error; |
|
2193 | - else return self::check_version(true); |
|
2335 | + if ($error != '') { |
|
2336 | + return $error; |
|
2337 | + } else { |
|
2338 | + return self::check_version(true); |
|
2339 | + } |
|
2194 | 2340 | } elseif ($result['value'] == '7') { |
2195 | 2341 | $error = self::update_from_7(); |
2196 | - if ($error != '') return $error; |
|
2197 | - else return self::check_version(true); |
|
2342 | + if ($error != '') { |
|
2343 | + return $error; |
|
2344 | + } else { |
|
2345 | + return self::check_version(true); |
|
2346 | + } |
|
2198 | 2347 | } elseif ($result['value'] == '8') { |
2199 | 2348 | $error = self::update_from_8(); |
2200 | - if ($error != '') return $error; |
|
2201 | - else return self::check_version(true); |
|
2349 | + if ($error != '') { |
|
2350 | + return $error; |
|
2351 | + } else { |
|
2352 | + return self::check_version(true); |
|
2353 | + } |
|
2202 | 2354 | } elseif ($result['value'] == '9') { |
2203 | 2355 | $error = self::update_from_9(); |
2204 | - if ($error != '') return $error; |
|
2205 | - else return self::check_version(true); |
|
2356 | + if ($error != '') { |
|
2357 | + return $error; |
|
2358 | + } else { |
|
2359 | + return self::check_version(true); |
|
2360 | + } |
|
2206 | 2361 | } elseif ($result['value'] == '10') { |
2207 | 2362 | $error = self::update_from_10(); |
2208 | - if ($error != '') return $error; |
|
2209 | - else return self::check_version(true); |
|
2363 | + if ($error != '') { |
|
2364 | + return $error; |
|
2365 | + } else { |
|
2366 | + return self::check_version(true); |
|
2367 | + } |
|
2210 | 2368 | } elseif ($result['value'] == '11') { |
2211 | 2369 | $error = self::update_from_11(); |
2212 | - if ($error != '') return $error; |
|
2213 | - else return self::check_version(true); |
|
2370 | + if ($error != '') { |
|
2371 | + return $error; |
|
2372 | + } else { |
|
2373 | + return self::check_version(true); |
|
2374 | + } |
|
2214 | 2375 | } elseif ($result['value'] == '12') { |
2215 | 2376 | $error = self::update_from_12(); |
2216 | - if ($error != '') return $error; |
|
2217 | - else return self::check_version(true); |
|
2377 | + if ($error != '') { |
|
2378 | + return $error; |
|
2379 | + } else { |
|
2380 | + return self::check_version(true); |
|
2381 | + } |
|
2218 | 2382 | } elseif ($result['value'] == '13') { |
2219 | 2383 | $error = self::update_from_13(); |
2220 | - if ($error != '') return $error; |
|
2221 | - else return self::check_version(true); |
|
2384 | + if ($error != '') { |
|
2385 | + return $error; |
|
2386 | + } else { |
|
2387 | + return self::check_version(true); |
|
2388 | + } |
|
2222 | 2389 | } elseif ($result['value'] == '14') { |
2223 | 2390 | $error = self::update_from_14(); |
2224 | - if ($error != '') return $error; |
|
2225 | - else return self::check_version(true); |
|
2391 | + if ($error != '') { |
|
2392 | + return $error; |
|
2393 | + } else { |
|
2394 | + return self::check_version(true); |
|
2395 | + } |
|
2226 | 2396 | } elseif ($result['value'] == '15') { |
2227 | 2397 | $error = self::update_from_15(); |
2228 | - if ($error != '') return $error; |
|
2229 | - else return self::check_version(true); |
|
2398 | + if ($error != '') { |
|
2399 | + return $error; |
|
2400 | + } else { |
|
2401 | + return self::check_version(true); |
|
2402 | + } |
|
2230 | 2403 | } elseif ($result['value'] == '16') { |
2231 | 2404 | $error = self::update_from_16(); |
2232 | - if ($error != '') return $error; |
|
2233 | - else return self::check_version(true); |
|
2405 | + if ($error != '') { |
|
2406 | + return $error; |
|
2407 | + } else { |
|
2408 | + return self::check_version(true); |
|
2409 | + } |
|
2234 | 2410 | } elseif ($result['value'] == '17') { |
2235 | 2411 | $error = self::update_from_17(); |
2236 | - if ($error != '') return $error; |
|
2237 | - else return self::check_version(true); |
|
2412 | + if ($error != '') { |
|
2413 | + return $error; |
|
2414 | + } else { |
|
2415 | + return self::check_version(true); |
|
2416 | + } |
|
2238 | 2417 | } elseif ($result['value'] == '18') { |
2239 | 2418 | $error = self::update_from_18(); |
2240 | - if ($error != '') return $error; |
|
2241 | - else return self::check_version(true); |
|
2419 | + if ($error != '') { |
|
2420 | + return $error; |
|
2421 | + } else { |
|
2422 | + return self::check_version(true); |
|
2423 | + } |
|
2242 | 2424 | } elseif ($result['value'] == '19') { |
2243 | 2425 | $error = self::update_from_19(); |
2244 | - if ($error != '') return $error; |
|
2245 | - else return self::check_version(true); |
|
2426 | + if ($error != '') { |
|
2427 | + return $error; |
|
2428 | + } else { |
|
2429 | + return self::check_version(true); |
|
2430 | + } |
|
2246 | 2431 | } elseif ($result['value'] == '20') { |
2247 | 2432 | $error = self::update_from_20(); |
2248 | - if ($error != '') return $error; |
|
2249 | - else return self::check_version(true); |
|
2433 | + if ($error != '') { |
|
2434 | + return $error; |
|
2435 | + } else { |
|
2436 | + return self::check_version(true); |
|
2437 | + } |
|
2250 | 2438 | } elseif ($result['value'] == '21') { |
2251 | 2439 | $error = self::update_from_21(); |
2252 | - if ($error != '') return $error; |
|
2253 | - else return self::check_version(true); |
|
2440 | + if ($error != '') { |
|
2441 | + return $error; |
|
2442 | + } else { |
|
2443 | + return self::check_version(true); |
|
2444 | + } |
|
2254 | 2445 | } elseif ($result['value'] == '22') { |
2255 | 2446 | $error = self::update_from_22(); |
2256 | - if ($error != '') return $error; |
|
2257 | - else return self::check_version(true); |
|
2447 | + if ($error != '') { |
|
2448 | + return $error; |
|
2449 | + } else { |
|
2450 | + return self::check_version(true); |
|
2451 | + } |
|
2258 | 2452 | } elseif ($result['value'] == '23') { |
2259 | 2453 | $error = self::update_from_23(); |
2260 | - if ($error != '') return $error; |
|
2261 | - else return self::check_version(true); |
|
2454 | + if ($error != '') { |
|
2455 | + return $error; |
|
2456 | + } else { |
|
2457 | + return self::check_version(true); |
|
2458 | + } |
|
2262 | 2459 | } elseif ($result['value'] == '24') { |
2263 | 2460 | $error = self::update_from_24(); |
2264 | - if ($error != '') return $error; |
|
2265 | - else return self::check_version(true); |
|
2461 | + if ($error != '') { |
|
2462 | + return $error; |
|
2463 | + } else { |
|
2464 | + return self::check_version(true); |
|
2465 | + } |
|
2266 | 2466 | } elseif ($result['value'] == '25') { |
2267 | 2467 | $error = self::update_from_25(); |
2268 | - if ($error != '') return $error; |
|
2269 | - else return self::check_version(true); |
|
2468 | + if ($error != '') { |
|
2469 | + return $error; |
|
2470 | + } else { |
|
2471 | + return self::check_version(true); |
|
2472 | + } |
|
2270 | 2473 | } elseif ($result['value'] == '26') { |
2271 | 2474 | $error = self::update_from_26(); |
2272 | - if ($error != '') return $error; |
|
2273 | - else return self::check_version(true); |
|
2475 | + if ($error != '') { |
|
2476 | + return $error; |
|
2477 | + } else { |
|
2478 | + return self::check_version(true); |
|
2479 | + } |
|
2274 | 2480 | } elseif ($result['value'] == '27') { |
2275 | 2481 | $error = self::update_from_27(); |
2276 | - if ($error != '') return $error; |
|
2277 | - else return self::check_version(true); |
|
2482 | + if ($error != '') { |
|
2483 | + return $error; |
|
2484 | + } else { |
|
2485 | + return self::check_version(true); |
|
2486 | + } |
|
2278 | 2487 | } elseif ($result['value'] == '28') { |
2279 | 2488 | $error = self::update_from_28(); |
2280 | - if ($error != '') return $error; |
|
2281 | - else return self::check_version(true); |
|
2489 | + if ($error != '') { |
|
2490 | + return $error; |
|
2491 | + } else { |
|
2492 | + return self::check_version(true); |
|
2493 | + } |
|
2282 | 2494 | } elseif ($result['value'] == '29') { |
2283 | 2495 | $error = self::update_from_29(); |
2284 | - if ($error != '') return $error; |
|
2285 | - else return self::check_version(true); |
|
2496 | + if ($error != '') { |
|
2497 | + return $error; |
|
2498 | + } else { |
|
2499 | + return self::check_version(true); |
|
2500 | + } |
|
2286 | 2501 | } elseif ($result['value'] == '30') { |
2287 | 2502 | $error = self::update_from_30(); |
2288 | - if ($error != '') return $error; |
|
2289 | - else return self::check_version(true); |
|
2503 | + if ($error != '') { |
|
2504 | + return $error; |
|
2505 | + } else { |
|
2506 | + return self::check_version(true); |
|
2507 | + } |
|
2290 | 2508 | } elseif ($result['value'] == '31') { |
2291 | 2509 | $error = self::update_from_31(); |
2292 | - if ($error != '') return $error; |
|
2293 | - else return self::check_version(true); |
|
2510 | + if ($error != '') { |
|
2511 | + return $error; |
|
2512 | + } else { |
|
2513 | + return self::check_version(true); |
|
2514 | + } |
|
2294 | 2515 | } elseif ($result['value'] == '32') { |
2295 | 2516 | $error = self::update_from_32(); |
2296 | - if ($error != '') return $error; |
|
2297 | - else return self::check_version(true); |
|
2517 | + if ($error != '') { |
|
2518 | + return $error; |
|
2519 | + } else { |
|
2520 | + return self::check_version(true); |
|
2521 | + } |
|
2298 | 2522 | } elseif ($result['value'] == '33') { |
2299 | 2523 | $error = self::update_from_33(); |
2300 | - if ($error != '') return $error; |
|
2301 | - else return self::check_version(true); |
|
2524 | + if ($error != '') { |
|
2525 | + return $error; |
|
2526 | + } else { |
|
2527 | + return self::check_version(true); |
|
2528 | + } |
|
2302 | 2529 | } elseif ($result['value'] == '34') { |
2303 | 2530 | $error = self::update_from_34(); |
2304 | - if ($error != '') return $error; |
|
2305 | - else return self::check_version(true); |
|
2531 | + if ($error != '') { |
|
2532 | + return $error; |
|
2533 | + } else { |
|
2534 | + return self::check_version(true); |
|
2535 | + } |
|
2306 | 2536 | } elseif ($result['value'] == '35') { |
2307 | 2537 | $error = self::update_from_35(); |
2308 | - if ($error != '') return $error; |
|
2309 | - else return self::check_version(true); |
|
2538 | + if ($error != '') { |
|
2539 | + return $error; |
|
2540 | + } else { |
|
2541 | + return self::check_version(true); |
|
2542 | + } |
|
2310 | 2543 | } elseif ($result['value'] == '36') { |
2311 | 2544 | $error = self::update_from_36(); |
2312 | - if ($error != '') return $error; |
|
2313 | - else return self::check_version(true); |
|
2545 | + if ($error != '') { |
|
2546 | + return $error; |
|
2547 | + } else { |
|
2548 | + return self::check_version(true); |
|
2549 | + } |
|
2314 | 2550 | } elseif ($result['value'] == '37') { |
2315 | 2551 | $error = self::update_from_37(); |
2316 | - if ($error != '') return $error; |
|
2317 | - else return self::check_version(true); |
|
2552 | + if ($error != '') { |
|
2553 | + return $error; |
|
2554 | + } else { |
|
2555 | + return self::check_version(true); |
|
2556 | + } |
|
2318 | 2557 | } elseif ($result['value'] == '38') { |
2319 | 2558 | $error = self::update_from_38(); |
2320 | - if ($error != '') return $error; |
|
2321 | - else return self::check_version(true); |
|
2559 | + if ($error != '') { |
|
2560 | + return $error; |
|
2561 | + } else { |
|
2562 | + return self::check_version(true); |
|
2563 | + } |
|
2322 | 2564 | } elseif ($result['value'] == '39') { |
2323 | 2565 | $error = self::update_from_39(); |
2324 | - if ($error != '') return $error; |
|
2325 | - else return self::check_version(true); |
|
2566 | + if ($error != '') { |
|
2567 | + return $error; |
|
2568 | + } else { |
|
2569 | + return self::check_version(true); |
|
2570 | + } |
|
2326 | 2571 | } elseif ($result['value'] == '40') { |
2327 | 2572 | $error = self::update_from_40(); |
2328 | - if ($error != '') return $error; |
|
2329 | - else return self::check_version(true); |
|
2573 | + if ($error != '') { |
|
2574 | + return $error; |
|
2575 | + } else { |
|
2576 | + return self::check_version(true); |
|
2577 | + } |
|
2330 | 2578 | } elseif ($result['value'] == '41') { |
2331 | 2579 | $error = self::update_from_41(); |
2332 | - if ($error != '') return $error; |
|
2333 | - else return self::check_version(true); |
|
2580 | + if ($error != '') { |
|
2581 | + return $error; |
|
2582 | + } else { |
|
2583 | + return self::check_version(true); |
|
2584 | + } |
|
2334 | 2585 | } elseif ($result['value'] == '42') { |
2335 | 2586 | $error = self::update_from_42(); |
2336 | - if ($error != '') return $error; |
|
2337 | - else return self::check_version(true); |
|
2587 | + if ($error != '') { |
|
2588 | + return $error; |
|
2589 | + } else { |
|
2590 | + return self::check_version(true); |
|
2591 | + } |
|
2338 | 2592 | } elseif ($result['value'] == '43') { |
2339 | 2593 | $error = self::update_from_43(); |
2340 | - if ($error != '') return $error; |
|
2341 | - else return self::check_version(true); |
|
2594 | + if ($error != '') { |
|
2595 | + return $error; |
|
2596 | + } else { |
|
2597 | + return self::check_version(true); |
|
2598 | + } |
|
2342 | 2599 | } elseif ($result['value'] == '44') { |
2343 | 2600 | $error = self::update_from_44(); |
2344 | - if ($error != '') return $error; |
|
2345 | - else return self::check_version(true); |
|
2601 | + if ($error != '') { |
|
2602 | + return $error; |
|
2603 | + } else { |
|
2604 | + return self::check_version(true); |
|
2605 | + } |
|
2346 | 2606 | } elseif ($result['value'] == '45') { |
2347 | 2607 | $error = self::update_from_45(); |
2348 | - if ($error != '') return $error; |
|
2349 | - else return self::check_version(true); |
|
2350 | - } else return ''; |
|
2608 | + if ($error != '') { |
|
2609 | + return $error; |
|
2610 | + } else { |
|
2611 | + return self::check_version(true); |
|
2612 | + } |
|
2613 | + } else { |
|
2614 | + return ''; |
|
2615 | + } |
|
2351 | 2616 | } else { |
2352 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2353 | - else return 0; |
|
2617 | + if (isset($result['value']) && $result['value'] != '') { |
|
2618 | + return $result['value']; |
|
2619 | + } else { |
|
2620 | + return 0; |
|
2621 | + } |
|
2354 | 2622 | } |
2355 | 2623 | } |
2356 | - } else return $version; |
|
2624 | + } else { |
|
2625 | + return $version; |
|
2626 | + } |
|
2357 | 2627 | } |
2358 | 2628 | } |
2359 | 2629 | } |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | if (file_exists('images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png')) |
34 | 34 | { |
35 | 35 | print '<img src="'.$globalURL.'/images/airlines/'.str_replace(' ','_',$alliance['alliance']).'.png" alt="'._("Click to see alliance activity").'" title="'._("Click to see alliance activity").'" /> '; |
36 | - } else print $alliance['alliance']; |
|
36 | + } else { |
|
37 | + print $alliance['alliance']; |
|
38 | + } |
|
37 | 39 | print '</a>'; |
38 | 40 | print '</div>'; |
39 | 41 | } |
@@ -42,13 +44,21 @@ discard block |
||
42 | 44 | } |
43 | 45 | print '<div class="select-item"><form action="'.$globalURL.'/airline" method="post"><select name="airline_type" class="selectpicker" data-live-search="true">'; |
44 | 46 | print '<option value="all"'; |
45 | - if ($airline_type == 'all') print 'selected="selected" '; |
|
47 | + if ($airline_type == 'all') { |
|
48 | + print 'selected="selected" '; |
|
49 | + } |
|
46 | 50 | print '>'._("All").'</option><option value="passenger"'; |
47 | - if ($airline_type == 'passenger') print 'selected="selected" '; |
|
51 | + if ($airline_type == 'passenger') { |
|
52 | + print 'selected="selected" '; |
|
53 | + } |
|
48 | 54 | print '>'._("Passenger").'</option><option value="cargo"'; |
49 | - if ($airline_type == 'cargo') print 'selected="selected" '; |
|
55 | + if ($airline_type == 'cargo') { |
|
56 | + print 'selected="selected" '; |
|
57 | + } |
|
50 | 58 | print '>'._("Cargo").'</option><option value="military"'; |
51 | - if ($airline_type == 'military') print 'selected="selected" '; |
|
59 | + if ($airline_type == 'military') { |
|
60 | + print 'selected="selected" '; |
|
61 | + } |
|
52 | 62 | print '>'._("Military").'</option></select>'; |
53 | 63 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button></form></div>'; |
54 | 64 | |
@@ -75,7 +85,9 @@ discard block |
||
75 | 85 | $firstLetter = strtoupper($Common->replace_mb_substr($value['airline_name'], 0, 1)); |
76 | 86 | if($previous !== $firstLetter) |
77 | 87 | { |
78 | - if ($previous !== null) print ' | '; |
|
88 | + if ($previous !== null) { |
|
89 | + print ' | '; |
|
90 | + } |
|
79 | 91 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
80 | 92 | } |
81 | 93 | $previous = $firstLetter; |
@@ -88,7 +100,9 @@ discard block |
||
88 | 100 | { |
89 | 101 | if($previous !== $firstLetter) |
90 | 102 | { |
91 | - if ($previous !== null) print '</div>'; |
|
103 | + if ($previous !== null) { |
|
104 | + print '</div>'; |
|
105 | + } |
|
92 | 106 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
93 | 107 | } |
94 | 108 | $previous = $firstLetter; |
@@ -102,10 +116,14 @@ discard block |
||
102 | 116 | } elseif (file_exists('images/airlines/'.$value['airline_icao'].'.png')) |
103 | 117 | { |
104 | 118 | print '<img src="'.$globalURL.'/images/airlines/'.$value['airline_icao'].'.png" alt="'._("Click to see airline activity").'" title="'._("Click to see airline activity").'" /> '; |
105 | - if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
119 | + if (isset($value['ban_eu']) && $value['ban_eu'] == 1) { |
|
120 | + print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
121 | + } |
|
106 | 122 | } else { |
107 | 123 | print $value['airline_name']; |
108 | - if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
124 | + if (isset($value['ban_eu']) && $value['ban_eu'] == 1) { |
|
125 | + print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
126 | + } |
|
109 | 127 | } |
110 | 128 | print '</a>'; |
111 | 129 | print '</div>'; |
@@ -105,8 +105,11 @@ |
||
105 | 105 | } elseif (isset($_GET['satellite'])) { |
106 | 106 | readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/satellites/'.$filename); |
107 | 107 | } else { |
108 | - if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
109 | - else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename); |
|
108 | + if ($color == 'FF0000') { |
|
109 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
110 | + } else { |
|
111 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename); |
|
112 | + } |
|
110 | 113 | } |
111 | 114 | } |
112 | 115 | ?> |
113 | 116 | \ No newline at end of file |
@@ -3,11 +3,18 @@ discard block |
||
3 | 3 | require_once('../require/class.Language.php'); |
4 | 4 | |
5 | 5 | // Compressed GeoJson is used if true |
6 | -if (!isset($globalJsonCompress)) $compress = true; |
|
7 | -else $compress = $globalJsonCompress; |
|
6 | +if (!isset($globalJsonCompress)) { |
|
7 | + $compress = true; |
|
8 | +} else { |
|
9 | + $compress = $globalJsonCompress; |
|
10 | +} |
|
8 | 11 | |
9 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
10 | -if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
12 | +if (isset($_GET['ident'])) { |
|
13 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
14 | +} |
|
15 | +if (isset($_GET['flightaware_id'])) { |
|
16 | + $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
17 | +} |
|
11 | 18 | ?> |
12 | 19 | |
13 | 20 | |
@@ -72,9 +79,12 @@ discard block |
||
72 | 79 | |
73 | 80 | function update_airportsLayer() { |
74 | 81 | <?php |
75 | - if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom']; |
|
76 | - else $getZoom = '7'; |
|
77 | -?> |
|
82 | + if (isset($_COOKIE['AirportZoom'])) { |
|
83 | + $getZoom = $_COOKIE['AirportZoom']; |
|
84 | + } else { |
|
85 | + $getZoom = '7'; |
|
86 | + } |
|
87 | + ?> |
|
78 | 88 | if (typeof airportsLayer != 'undefined') { |
79 | 89 | if (map.hasLayer(airportsLayer) == true) { |
80 | 90 | map.removeLayer(airportsLayer); |
@@ -320,9 +330,13 @@ discard block |
||
320 | 330 | if (callsign != ""){ markerLabel += callsign; } |
321 | 331 | if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; } |
322 | 332 | <?php |
323 | - if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor']; |
|
324 | - elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor; |
|
325 | - else $IconColor = '1a3151'; |
|
333 | + if (isset($_COOKIE['IconColor'])) { |
|
334 | + $IconColor = $_COOKIE['IconColor']; |
|
335 | + } elseif (isset($globalAircraftIconColor)) { |
|
336 | + $IconColor = $globalAircraftIconColor; |
|
337 | + } else { |
|
338 | + $IconColor = '1a3151'; |
|
339 | + } |
|
326 | 340 | if (!isset($ident) && !isset($flightaware_id)) { |
327 | 341 | ?> |
328 | 342 | //info_update(feature.properties.fc); |
@@ -370,7 +384,12 @@ discard block |
||
370 | 384 | <?php |
371 | 385 | } else { |
372 | 386 | ?> |
373 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
387 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
388 | + print $archiveupdatetime*1000; |
|
389 | +} else { |
|
390 | + print $globalMapRefresh*1000+20000; |
|
391 | +} |
|
392 | +?>+feature.properties.sqt*1000); |
|
374 | 393 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
375 | 394 | <?php |
376 | 395 | } |
@@ -419,7 +438,12 @@ discard block |
||
419 | 438 | <?php |
420 | 439 | } else { |
421 | 440 | ?> |
422 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
441 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
442 | + print $archiveupdatetime*1000; |
|
443 | +} else { |
|
444 | + print $globalMapRefresh*1000+20000; |
|
445 | +} |
|
446 | +?>+feature.properties.sqt*1000); |
|
423 | 447 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
424 | 448 | <?php |
425 | 449 | } |
@@ -466,7 +490,12 @@ discard block |
||
466 | 490 | <?php |
467 | 491 | } else { |
468 | 492 | ?> |
469 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
493 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
494 | + print $archiveupdatetime*1000; |
|
495 | +} else { |
|
496 | + print $globalMapRefresh*1000+20000; |
|
497 | +} |
|
498 | +?>+feature.properties.sqt*1000); |
|
470 | 499 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
471 | 500 | <?php |
472 | 501 | } |
@@ -820,13 +849,23 @@ discard block |
||
820 | 849 | if (isset($archive) && $archive) { |
821 | 850 | ?> |
822 | 851 | //then load it again every 30 seconds |
823 | - // var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
852 | + // var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
853 | + print ($globalMapRefresh*1000)/2; |
|
854 | +} else { |
|
855 | + print '15000'; |
|
856 | +} |
|
857 | +?>); |
|
824 | 858 | reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>); |
825 | 859 | <?php |
826 | 860 | } else { |
827 | 861 | ?> |
828 | 862 | //then load it again every 30 seconds |
829 | - reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
863 | + reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
864 | + print $globalMapRefresh*1000; |
|
865 | +} else { |
|
866 | + print '30000'; |
|
867 | +} |
|
868 | +?>); |
|
830 | 869 | var currentdate = new Date(); |
831 | 870 | var currentyear = new Date().getFullYear(); |
832 | 871 | var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0)); |
@@ -838,7 +877,12 @@ discard block |
||
838 | 877 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
839 | 878 | ?> |
840 | 879 | update_polarLayer(); |
841 | - setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
880 | + setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
881 | + print $globalMapRefresh*1000*2; |
|
882 | +} else { |
|
883 | + print '60000'; |
|
884 | +} |
|
885 | +?>); |
|
842 | 886 | <?php |
843 | 887 | } |
844 | 888 | ?> |
@@ -853,7 +897,12 @@ discard block |
||
853 | 897 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
854 | 898 | ?> |
855 | 899 | update_atcLayer(); |
856 | - setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
900 | + setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
901 | + print $globalMapRefresh*1000*2; |
|
902 | +} else { |
|
903 | + print '60000'; |
|
904 | +} |
|
905 | +?>); |
|
857 | 906 | <?php |
858 | 907 | } |
859 | 908 | ?> |
@@ -5,8 +5,11 @@ discard block |
||
5 | 5 | setcookie("MapFormat",'2d'); |
6 | 6 | |
7 | 7 | // Compressed GeoJson is used if true |
8 | -if (!isset($globalJsonCompress)) $compress = true; |
|
9 | -else $compress = $globalJsonCompress; |
|
8 | +if (!isset($globalJsonCompress)) { |
|
9 | + $compress = true; |
|
10 | +} else { |
|
11 | + $compress = $globalJsonCompress; |
|
12 | +} |
|
10 | 13 | ?> |
11 | 14 | |
12 | 15 | |
@@ -156,9 +159,13 @@ discard block |
||
156 | 159 | if (callsign != ""){ markerMarineLabel += callsign; } |
157 | 160 | if (type != ""){ markerMarineLabel += ' - '+type; } |
158 | 161 | <?php |
159 | - if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor']; |
|
160 | - elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor; |
|
161 | - else $MarineIconColor = '1a3151'; |
|
162 | + if (isset($_COOKIE['MarineIconColor'])) { |
|
163 | + $MarineIconColor = $_COOKIE['MarineIconColor']; |
|
164 | + } elseif (isset($globalMarineIconColor)) { |
|
165 | + $MarineIconColor = $globalMarineIconColor; |
|
166 | + } else { |
|
167 | + $MarineIconColor = '1a3151'; |
|
168 | + } |
|
162 | 169 | if (!isset($ident) && !isset($fammarine_id)) { |
163 | 170 | ?> |
164 | 171 | //info_marine_update(feature.properties.fc); |
@@ -193,7 +200,12 @@ discard block |
||
193 | 200 | <?php |
194 | 201 | } else { |
195 | 202 | ?> |
196 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
203 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
204 | + print $archiveupdatetime*1000; |
|
205 | +} else { |
|
206 | + print $globalMapRefresh*1000+20000; |
|
207 | +} |
|
208 | +?>+feature.properties.sqt*1000); |
|
197 | 209 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
198 | 210 | <?php |
199 | 211 | } |
@@ -249,7 +261,12 @@ discard block |
||
249 | 261 | <?php |
250 | 262 | } else { |
251 | 263 | ?> |
252 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
264 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
265 | + print $archiveupdatetime*1000; |
|
266 | +} else { |
|
267 | + print $globalMapRefresh*1000+20000; |
|
268 | +} |
|
269 | +?>+feature.properties.sqt*1000); |
|
253 | 270 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
254 | 271 | <?php |
255 | 272 | } |
@@ -304,7 +321,12 @@ discard block |
||
304 | 321 | <?php |
305 | 322 | } else { |
306 | 323 | ?> |
307 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
324 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
325 | + print $archiveupdatetime*1000; |
|
326 | +} else { |
|
327 | + print $globalMapRefresh*1000+20000; |
|
328 | +} |
|
329 | +?>+feature.properties.sqt*1000); |
|
308 | 330 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
309 | 331 | <?php |
310 | 332 | } |
@@ -594,14 +616,24 @@ discard block |
||
594 | 616 | if (isset($archive) && $archive) { |
595 | 617 | ?> |
596 | 618 | //then load it again every 30 seconds |
597 | -// var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
619 | +// var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) { |
|
620 | + print ($globalMapRefresh*1000)/2; |
|
621 | +} else { |
|
622 | + print '15000'; |
|
623 | +} |
|
624 | +?>); |
|
598 | 625 | reloadMarinePage = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php print $archiveupdatetime*1000; ?>); |
599 | 626 | <?php |
600 | 627 | } else { |
601 | 628 | ?> |
602 | 629 | //then load it again every 30 seconds |
603 | 630 | reloadMarinePage = setInterval( |
604 | - function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
631 | + function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) { |
|
632 | + print $globalMapRefresh*1000; |
|
633 | +} else { |
|
634 | + print '30000'; |
|
635 | +} |
|
636 | +?>); |
|
605 | 637 | <?php |
606 | 638 | } |
607 | 639 | ?> |