@@ -3,6 +3,10 @@ |
||
3 | 3 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
4 | 4 | |
5 | 5 | class create_db { |
6 | + |
|
7 | + /** |
|
8 | + * @param string $filename |
|
9 | + */ |
|
6 | 10 | public static function import_file($filename) { |
7 | 11 | $filename = filter_var($filename,FILTER_SANITIZE_STRING); |
8 | 12 | $Connection = new Connection(); |
@@ -11,7 +11,9 @@ discard block |
||
11 | 11 | $lines = file($filename); |
12 | 12 | foreach ($lines as $line) |
13 | 13 | { |
14 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
14 | + if (substr($line,0,2) == '--' || $line == '') { |
|
15 | + continue; |
|
16 | + } |
|
15 | 17 | $templine .= $line; |
16 | 18 | if (substr(trim($line), -1,1) == ';') |
17 | 19 | { |
@@ -35,7 +37,9 @@ discard block |
||
35 | 37 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
36 | 38 | while(false !== ($filename = readdir($dh))) |
37 | 39 | { |
38 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
40 | + if (preg_match('/\.sql$/',$filename)) { |
|
41 | + $error .= create_db::import_file($directory.$filename); |
|
42 | + } |
|
39 | 43 | } |
40 | 44 | return $error; |
41 | 45 | } |
@@ -51,13 +55,17 @@ discard block |
||
51 | 55 | // Dirty hack |
52 | 56 | if ($host != 'localhost' && $host != '127.0.0.1') { |
53 | 57 | $grantright = $_SERVER['SERVER_ADDR']; |
54 | - } else $grantright = 'localhost'; |
|
58 | + } else { |
|
59 | + $grantright = 'localhost'; |
|
60 | + } |
|
55 | 61 | try { |
56 | 62 | $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |
57 | 63 | $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
58 | 64 | if ($db_type == 'mysql') { |
59 | 65 | $dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
60 | - if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
66 | + if ($grantright == 'localhost') { |
|
67 | + $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
68 | + } |
|
61 | 69 | } else if ($db_type == 'pgsql') { |
62 | 70 | $dbh->exec("CREATE DATABASE ".$db.";"); |
63 | 71 | $dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."'; |
@@ -10,6 +10,9 @@ discard block |
||
10 | 10 | class update_db { |
11 | 11 | public static $db_sqlite; |
12 | 12 | |
13 | + /** |
|
14 | + * @param string $file |
|
15 | + */ |
|
13 | 16 | public static function download($url, $file, $referer = '') { |
14 | 17 | $fp = fopen($file, 'w+'); |
15 | 18 | $ch = curl_init(); |
@@ -23,6 +26,9 @@ discard block |
||
23 | 26 | curl_close($ch); |
24 | 27 | } |
25 | 28 | |
29 | + /** |
|
30 | + * @param string $in_file |
|
31 | + */ |
|
26 | 32 | public static function gunzip($in_file,$out_file_name = '') { |
27 | 33 | //echo $in_file.' -> '.$out_file_name."\n"; |
28 | 34 | $buffer_size = 4096; // read 4kb at a time |
@@ -40,6 +46,9 @@ discard block |
||
40 | 46 | } |
41 | 47 | } |
42 | 48 | |
49 | + /** |
|
50 | + * @param string $in_file |
|
51 | + */ |
|
43 | 52 | public static function unzip($in_file) { |
44 | 53 | if ($in_file != '' && file_exists($in_file)) { |
45 | 54 | $path = pathinfo(realpath($in_file), PATHINFO_DIRNAME); |
@@ -61,6 +70,9 @@ discard block |
||
61 | 70 | } |
62 | 71 | } |
63 | 72 | |
73 | + /** |
|
74 | + * @param string $database_file |
|
75 | + */ |
|
64 | 76 | public static function retrieve_route_sqlite_to_dest($database_file) { |
65 | 77 | global $globalDebug, $globalTransaction; |
66 | 78 | //$query = 'TRUNCATE TABLE routes'; |
@@ -103,6 +115,10 @@ discard block |
||
103 | 115 | } |
104 | 116 | return ''; |
105 | 117 | } |
118 | + |
|
119 | + /** |
|
120 | + * @param string $database_file |
|
121 | + */ |
|
106 | 122 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
107 | 123 | global $globalTransaction; |
108 | 124 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -168,6 +184,9 @@ discard block |
||
168 | 184 | return ''; |
169 | 185 | } |
170 | 186 | |
187 | + /** |
|
188 | + * @param string $database_file |
|
189 | + */ |
|
171 | 190 | public static function retrieve_modes_flarmnet($database_file) { |
172 | 191 | global $globalTransaction; |
173 | 192 | $Common = new Common(); |
@@ -237,6 +256,9 @@ discard block |
||
237 | 256 | return ''; |
238 | 257 | } |
239 | 258 | |
259 | + /** |
|
260 | + * @param string $database_file |
|
261 | + */ |
|
240 | 262 | public static function retrieve_modes_ogn($database_file) { |
241 | 263 | global $globalTransaction; |
242 | 264 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -305,6 +327,9 @@ discard block |
||
305 | 327 | return ''; |
306 | 328 | } |
307 | 329 | |
330 | + /** |
|
331 | + * @param string $database_file |
|
332 | + */ |
|
308 | 333 | public static function retrieve_owner($database_file,$country = 'F') { |
309 | 334 | global $globalTransaction; |
310 | 335 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -937,6 +962,9 @@ discard block |
||
937 | 962 | |
938 | 963 | } |
939 | 964 | */ |
965 | + /** |
|
966 | + * @param string $filename |
|
967 | + */ |
|
940 | 968 | public static function waypoints($filename) { |
941 | 969 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
942 | 970 | global $tmp_dir, $globalTransaction; |
@@ -993,6 +1021,9 @@ discard block |
||
993 | 1021 | return ''; |
994 | 1022 | } |
995 | 1023 | |
1024 | + /** |
|
1025 | + * @param string $filename |
|
1026 | + */ |
|
996 | 1027 | public static function ivao_airlines($filename) { |
997 | 1028 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
998 | 1029 | global $tmp_dir, $globalTransaction; |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
19 | + if ($referer != '') { |
|
20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
21 | + } |
|
20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
22 | 24 | $data = curl_exec($ch); |
@@ -26,11 +28,16 @@ discard block |
||
26 | 28 | public static function gunzip($in_file,$out_file_name = '') { |
27 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; |
28 | 30 | $buffer_size = 4096; // read 4kb at a time |
29 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
31 | + if ($out_file_name == '') { |
|
32 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
33 | + } |
|
30 | 34 | if ($in_file != '' && file_exists($in_file)) { |
31 | 35 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
32 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
33 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
36 | + if (function_exists('gzopen')) { |
|
37 | + $file = gzopen($in_file,'rb'); |
|
38 | + } elseif (function_exists('gzopen64')) { |
|
39 | + $file = gzopen64($in_file,'rb'); |
|
40 | + } |
|
34 | 41 | $out_file = fopen($out_file_name, 'wb'); |
35 | 42 | while(!gzeof($file)) { |
36 | 43 | fwrite($out_file, gzread($file, $buffer_size)); |
@@ -48,8 +55,12 @@ discard block |
||
48 | 55 | if ($res === TRUE) { |
49 | 56 | $zip->extractTo($path); |
50 | 57 | $zip->close(); |
51 | - } else return false; |
|
52 | - } else return false; |
|
58 | + } else { |
|
59 | + return false; |
|
60 | + } |
|
61 | + } else { |
|
62 | + return false; |
|
63 | + } |
|
53 | 64 | } |
54 | 65 | |
55 | 66 | public static function connect_sqlite($database) { |
@@ -64,7 +75,9 @@ discard block |
||
64 | 75 | public static function retrieve_route_sqlite_to_dest($database_file) { |
65 | 76 | global $globalDebug, $globalTransaction; |
66 | 77 | //$query = 'TRUNCATE TABLE routes'; |
67 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
78 | + if ($globalDebug) { |
|
79 | + echo " - Delete previous routes from DB -"; |
|
80 | + } |
|
68 | 81 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
69 | 82 | $Connection = new Connection(); |
70 | 83 | try { |
@@ -75,7 +88,9 @@ discard block |
||
75 | 88 | return "error : ".$e->getMessage(); |
76 | 89 | } |
77 | 90 | |
78 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
91 | + if ($globalDebug) { |
|
92 | + echo " - Add routes to DB -"; |
|
93 | + } |
|
79 | 94 | update_db::connect_sqlite($database_file); |
80 | 95 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
81 | 96 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -90,15 +105,21 @@ discard block |
||
90 | 105 | $Connection = new Connection(); |
91 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
92 | 107 | try { |
93 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
108 | + if ($globalTransaction) { |
|
109 | + $Connection->db->beginTransaction(); |
|
110 | + } |
|
94 | 111 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
95 | 112 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
96 | 113 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
97 | 114 | $sth_dest->execute($query_dest_values); |
98 | 115 | } |
99 | - if ($globalTransaction) $Connection->db->commit(); |
|
116 | + if ($globalTransaction) { |
|
117 | + $Connection->db->commit(); |
|
118 | + } |
|
100 | 119 | } catch(PDOException $e) { |
101 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
120 | + if ($globalTransaction) { |
|
121 | + $Connection->db->rollBack(); |
|
122 | + } |
|
102 | 123 | return "error : ".$e->getMessage(); |
103 | 124 | } |
104 | 125 | return ''; |
@@ -140,11 +161,16 @@ discard block |
||
140 | 161 | $sth_dest = $Connection->db->prepare($query_dest); |
141 | 162 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
142 | 163 | try { |
143 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
164 | + if ($globalTransaction) { |
|
165 | + $Connection->db->beginTransaction(); |
|
166 | + } |
|
144 | 167 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
145 | 168 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
146 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
147 | - else $type = null; |
|
169 | + if ($values['UserString4'] == 'M') { |
|
170 | + $type = 'military'; |
|
171 | + } else { |
|
172 | + $type = null; |
|
173 | + } |
|
148 | 174 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
149 | 175 | $sth_dest->execute($query_dest_values); |
150 | 176 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -152,7 +178,9 @@ discard block |
||
152 | 178 | $sth_dest_owner->execute($query_dest_owner_values); |
153 | 179 | } |
154 | 180 | } |
155 | - if ($globalTransaction) $Connection->db->commit(); |
|
181 | + if ($globalTransaction) { |
|
182 | + $Connection->db->commit(); |
|
183 | + } |
|
156 | 184 | } catch(PDOException $e) { |
157 | 185 | return "error : ".$e->getMessage(); |
158 | 186 | } |
@@ -188,7 +216,9 @@ discard block |
||
188 | 216 | $Connection = new Connection(); |
189 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
190 | 218 | try { |
191 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
219 | + if ($globalTransaction) { |
|
220 | + $Connection->db->beginTransaction(); |
|
221 | + } |
|
192 | 222 | while (!feof($fh)) { |
193 | 223 | $line = $Common->hex2str(fgets($fh,9999)); |
194 | 224 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
@@ -198,7 +228,9 @@ discard block |
||
198 | 228 | // Check if we can find ICAO, else set it to GLID |
199 | 229 | $aircraft_name_split = explode(' ',$aircraft_name); |
200 | 230 | $search_more = ''; |
201 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
231 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
232 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
233 | + } |
|
202 | 234 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
203 | 235 | $sth_search = $Connection->db->prepare($query_search); |
204 | 236 | try { |
@@ -211,7 +243,9 @@ discard block |
||
211 | 243 | } catch(PDOException $e) { |
212 | 244 | return "error : ".$e->getMessage(); |
213 | 245 | } |
214 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
246 | + if (!isset($values['ICAOTypeCode'])) { |
|
247 | + $values['ICAOTypeCode'] = 'GLID'; |
|
248 | + } |
|
215 | 249 | // Add data to db |
216 | 250 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
217 | 251 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -220,7 +254,9 @@ discard block |
||
220 | 254 | $sth_dest->execute($query_dest_values); |
221 | 255 | } |
222 | 256 | } |
223 | - if ($globalTransaction) $Connection->db->commit(); |
|
257 | + if ($globalTransaction) { |
|
258 | + $Connection->db->commit(); |
|
259 | + } |
|
224 | 260 | } catch(PDOException $e) { |
225 | 261 | return "error : ".$e->getMessage(); |
226 | 262 | } |
@@ -256,7 +292,9 @@ discard block |
||
256 | 292 | $Connection = new Connection(); |
257 | 293 | $sth_dest = $Connection->db->prepare($query_dest); |
258 | 294 | try { |
259 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
295 | + if ($globalTransaction) { |
|
296 | + $Connection->db->beginTransaction(); |
|
297 | + } |
|
260 | 298 | $tmp = fgetcsv($fh,9999,',',"'"); |
261 | 299 | while (!feof($fh)) { |
262 | 300 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -269,13 +307,17 @@ discard block |
||
269 | 307 | // Check if we can find ICAO, else set it to GLID |
270 | 308 | $aircraft_name_split = explode(' ',$aircraft_name); |
271 | 309 | $search_more = ''; |
272 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
310 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
311 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
312 | + } |
|
273 | 313 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
274 | 314 | $sth_search = $Connection->db->prepare($query_search); |
275 | 315 | try { |
276 | 316 | $sth_search->execute(); |
277 | 317 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
278 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
318 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
319 | + $values['ICAOTypeCode'] = $result['icao']; |
|
320 | + } |
|
279 | 321 | } catch(PDOException $e) { |
280 | 322 | return "error : ".$e->getMessage(); |
281 | 323 | } |
@@ -288,7 +330,9 @@ discard block |
||
288 | 330 | $sth_dest->execute($query_dest_values); |
289 | 331 | } |
290 | 332 | } |
291 | - if ($globalTransaction) $Connection->db->commit(); |
|
333 | + if ($globalTransaction) { |
|
334 | + $Connection->db->commit(); |
|
335 | + } |
|
292 | 336 | } catch(PDOException $e) { |
293 | 337 | return "error : ".$e->getMessage(); |
294 | 338 | } |
@@ -324,7 +368,9 @@ discard block |
||
324 | 368 | $Connection = new Connection(); |
325 | 369 | $sth_dest = $Connection->db->prepare($query_dest); |
326 | 370 | try { |
327 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
371 | + if ($globalTransaction) { |
|
372 | + $Connection->db->beginTransaction(); |
|
373 | + } |
|
328 | 374 | $tmp = fgetcsv($fh,9999,',','"'); |
329 | 375 | while (!feof($fh)) { |
330 | 376 | $line = fgetcsv($fh,9999,',','"'); |
@@ -333,16 +379,22 @@ discard block |
||
333 | 379 | $values['registration'] = $line[0]; |
334 | 380 | $values['base'] = $line[4]; |
335 | 381 | $values['owner'] = $line[5]; |
336 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
382 | + if ($line[6] == '') { |
|
383 | + $values['date_first_reg'] = null; |
|
384 | + } else { |
|
385 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
386 | + } |
|
338 | 387 | $values['cancel'] = $line[7]; |
339 | 388 | } elseif ($country == 'EI') { |
340 | 389 | // TODO : add modeS & reg to aircraft_modes |
341 | 390 | $values['registration'] = $line[0]; |
342 | 391 | $values['base'] = $line[3]; |
343 | 392 | $values['owner'] = $line[2]; |
344 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
393 | + if ($line[1] == '') { |
|
394 | + $values['date_first_reg'] = null; |
|
395 | + } else { |
|
396 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
397 | + } |
|
346 | 398 | $values['cancel'] = ''; |
347 | 399 | } elseif ($country == 'HB') { |
348 | 400 | // TODO : add modeS & reg to aircraft_modes |
@@ -356,16 +408,22 @@ discard block |
||
356 | 408 | $values['registration'] = $line[3]; |
357 | 409 | $values['base'] = null; |
358 | 410 | $values['owner'] = $line[5]; |
359 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
411 | + if ($line[18] == '') { |
|
412 | + $values['date_first_reg'] = null; |
|
413 | + } else { |
|
414 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
415 | + } |
|
361 | 416 | $values['cancel'] = ''; |
362 | 417 | } elseif ($country == 'VH') { |
363 | 418 | // TODO : add modeS & reg to aircraft_modes |
364 | 419 | $values['registration'] = $line[0]; |
365 | 420 | $values['base'] = null; |
366 | 421 | $values['owner'] = $line[12]; |
367 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
422 | + if ($line[28] == '') { |
|
423 | + $values['date_first_reg'] = null; |
|
424 | + } else { |
|
425 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
426 | + } |
|
369 | 427 | |
370 | 428 | $values['cancel'] = $line[39]; |
371 | 429 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -384,29 +442,41 @@ discard block |
||
384 | 442 | $values['registration'] = $line[0]; |
385 | 443 | $values['base'] = null; |
386 | 444 | $values['owner'] = $line[8]; |
387 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
445 | + if ($line[7] == '') { |
|
446 | + $values['date_first_reg'] = null; |
|
447 | + } else { |
|
448 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
449 | + } |
|
389 | 450 | $values['cancel'] = ''; |
390 | 451 | } elseif ($country == 'PP') { |
391 | 452 | $values['registration'] = $line[0]; |
392 | 453 | $values['base'] = null; |
393 | 454 | $values['owner'] = $line[4]; |
394 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
455 | + if ($line[6] == '') { |
|
456 | + $values['date_first_reg'] = null; |
|
457 | + } else { |
|
458 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
459 | + } |
|
396 | 460 | $values['cancel'] = $line[7]; |
397 | 461 | } elseif ($country == 'E7') { |
398 | 462 | $values['registration'] = $line[0]; |
399 | 463 | $values['base'] = null; |
400 | 464 | $values['owner'] = $line[4]; |
401 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
465 | + if ($line[5] == '') { |
|
466 | + $values['date_first_reg'] = null; |
|
467 | + } else { |
|
468 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
469 | + } |
|
403 | 470 | $values['cancel'] = ''; |
404 | 471 | } elseif ($country == '8Q') { |
405 | 472 | $values['registration'] = $line[0]; |
406 | 473 | $values['base'] = null; |
407 | 474 | $values['owner'] = $line[3]; |
408 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
475 | + if ($line[7] == '') { |
|
476 | + $values['date_first_reg'] = null; |
|
477 | + } else { |
|
478 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
479 | + } |
|
410 | 480 | $values['cancel'] = ''; |
411 | 481 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
412 | 482 | $values['registration'] = $line[0]; |
@@ -420,7 +490,9 @@ discard block |
||
420 | 490 | $sth_dest->execute($query_dest_values); |
421 | 491 | } |
422 | 492 | } |
423 | - if ($globalTransaction) $Connection->db->commit(); |
|
493 | + if ($globalTransaction) { |
|
494 | + $Connection->db->commit(); |
|
495 | + } |
|
424 | 496 | } catch(PDOException $e) { |
425 | 497 | return "error : ".$e->getMessage(); |
426 | 498 | } |
@@ -554,25 +626,45 @@ discard block |
||
554 | 626 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
555 | 627 | $Connection = new Connection(); |
556 | 628 | $sth_dest = $Connection->db->prepare($query_dest); |
557 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
629 | + if ($globalTransaction) { |
|
630 | + $Connection->db->beginTransaction(); |
|
631 | + } |
|
558 | 632 | |
559 | 633 | $i = 0; |
560 | 634 | while($row = sparql_fetch_array($result)) |
561 | 635 | { |
562 | 636 | if ($i >= 1) { |
563 | 637 | //print_r($row); |
564 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
565 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
566 | - if (!isset($row['type'])) $row['type'] = ''; |
|
567 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
638 | + if (!isset($row['iata'])) { |
|
639 | + $row['iata'] = ''; |
|
640 | + } |
|
641 | + if (!isset($row['icao'])) { |
|
642 | + $row['icao'] = ''; |
|
643 | + } |
|
644 | + if (!isset($row['type'])) { |
|
645 | + $row['type'] = ''; |
|
646 | + } |
|
647 | + if (!isset($row['altitude'])) { |
|
648 | + $row['altitude'] = ''; |
|
649 | + } |
|
568 | 650 | if (isset($row['city_bis'])) { |
569 | 651 | $row['city'] = $row['city_bis']; |
570 | 652 | } |
571 | - if (!isset($row['city'])) $row['city'] = ''; |
|
572 | - if (!isset($row['country'])) $row['country'] = ''; |
|
573 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
574 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
575 | - if (!isset($row['name'])) continue; |
|
653 | + if (!isset($row['city'])) { |
|
654 | + $row['city'] = ''; |
|
655 | + } |
|
656 | + if (!isset($row['country'])) { |
|
657 | + $row['country'] = ''; |
|
658 | + } |
|
659 | + if (!isset($row['homepage'])) { |
|
660 | + $row['homepage'] = ''; |
|
661 | + } |
|
662 | + if (!isset($row['wikipedia_page'])) { |
|
663 | + $row['wikipedia_page'] = ''; |
|
664 | + } |
|
665 | + if (!isset($row['name'])) { |
|
666 | + continue; |
|
667 | + } |
|
576 | 668 | if (!isset($row['image'])) { |
577 | 669 | $row['image'] = ''; |
578 | 670 | $row['image_thumb'] = ''; |
@@ -608,7 +700,9 @@ discard block |
||
608 | 700 | |
609 | 701 | $i++; |
610 | 702 | } |
611 | - if ($globalTransaction) $Connection->db->commit(); |
|
703 | + if ($globalTransaction) { |
|
704 | + $Connection->db->commit(); |
|
705 | + } |
|
612 | 706 | echo "Delete duplicate rows...\n"; |
613 | 707 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
614 | 708 | try { |
@@ -620,7 +714,9 @@ discard block |
||
620 | 714 | } |
621 | 715 | |
622 | 716 | |
623 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
717 | + if ($globalDebug) { |
|
718 | + echo "Insert Not available Airport...\n"; |
|
719 | + } |
|
624 | 720 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
625 | 721 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
626 | 722 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -647,7 +743,9 @@ discard block |
||
647 | 743 | $delimiter = ','; |
648 | 744 | $out_file = $tmp_dir.'airports.csv'; |
649 | 745 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
650 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
746 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
747 | + return FALSE; |
|
748 | + } |
|
651 | 749 | echo "Add data from ourairports.com...\n"; |
652 | 750 | |
653 | 751 | $header = NULL; |
@@ -657,8 +755,9 @@ discard block |
||
657 | 755 | //$Connection->db->beginTransaction(); |
658 | 756 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
659 | 757 | { |
660 | - if(!$header) $header = $row; |
|
661 | - else { |
|
758 | + if(!$header) { |
|
759 | + $header = $row; |
|
760 | + } else { |
|
662 | 761 | $data = array(); |
663 | 762 | $data = array_combine($header, $row); |
664 | 763 | try { |
@@ -696,7 +795,9 @@ discard block |
||
696 | 795 | echo "Download data from another free database...\n"; |
697 | 796 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
698 | 797 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
699 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
798 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
799 | + return FALSE; |
|
800 | + } |
|
700 | 801 | update_db::unzip($out_file); |
701 | 802 | $header = NULL; |
702 | 803 | echo "Add data from another free database...\n"; |
@@ -707,8 +808,9 @@ discard block |
||
707 | 808 | //$Connection->db->beginTransaction(); |
708 | 809 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
709 | 810 | { |
710 | - if(!$header) $header = $row; |
|
711 | - else { |
|
811 | + if(!$header) { |
|
812 | + $header = $row; |
|
813 | + } else { |
|
712 | 814 | $data = $row; |
713 | 815 | |
714 | 816 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -962,7 +1064,9 @@ discard block |
||
962 | 1064 | if (($handle = fopen($filename, 'r')) !== FALSE) |
963 | 1065 | { |
964 | 1066 | $i = 0; |
965 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1067 | + if ($globalTransaction) { |
|
1068 | + $Connection->db->beginTransaction(); |
|
1069 | + } |
|
966 | 1070 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
967 | 1071 | { |
968 | 1072 | $i++; |
@@ -990,7 +1094,9 @@ discard block |
||
990 | 1094 | } |
991 | 1095 | } |
992 | 1096 | fclose($handle); |
993 | - if ($globalTransaction) $Connection->db->commit(); |
|
1097 | + if ($globalTransaction) { |
|
1098 | + $Connection->db->commit(); |
|
1099 | + } |
|
994 | 1100 | } |
995 | 1101 | return ''; |
996 | 1102 | } |
@@ -1012,7 +1118,9 @@ discard block |
||
1012 | 1118 | $Connection = new Connection(); |
1013 | 1119 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1014 | 1120 | { |
1015 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1121 | + if ($globalTransaction) { |
|
1122 | + $Connection->db->beginTransaction(); |
|
1123 | + } |
|
1016 | 1124 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1017 | 1125 | { |
1018 | 1126 | if(count($row) > 1) { |
@@ -1026,7 +1134,9 @@ discard block |
||
1026 | 1134 | } |
1027 | 1135 | } |
1028 | 1136 | fclose($handle); |
1029 | - if ($globalTransaction) $Connection->db->commit(); |
|
1137 | + if ($globalTransaction) { |
|
1138 | + $Connection->db->commit(); |
|
1139 | + } |
|
1030 | 1140 | } |
1031 | 1141 | return ''; |
1032 | 1142 | } |
@@ -1034,8 +1144,9 @@ discard block |
||
1034 | 1144 | public static function update_airspace() { |
1035 | 1145 | global $tmp_dir, $globalDBdriver; |
1036 | 1146 | include_once('class.create_db.php'); |
1037 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1038 | - else { |
|
1147 | + if ($globalDBdriver == 'mysql') { |
|
1148 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1149 | + } else { |
|
1039 | 1150 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1040 | 1151 | $query = "CREATE EXTENSION postgis"; |
1041 | 1152 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1100,35 +1211,59 @@ discard block |
||
1100 | 1211 | //if ($globalDebug) echo "IVAO : Download..."; |
1101 | 1212 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1102 | 1213 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1103 | - if ($globalDebug) echo "Unzip..."; |
|
1214 | + if ($globalDebug) { |
|
1215 | + echo "Unzip..."; |
|
1216 | + } |
|
1104 | 1217 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1105 | - if ($globalDebug) echo "Add to DB..."; |
|
1218 | + if ($globalDebug) { |
|
1219 | + echo "Add to DB..."; |
|
1220 | + } |
|
1106 | 1221 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1107 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1222 | + if ($globalDebug) { |
|
1223 | + echo "Copy airlines logos to airlines images directory..."; |
|
1224 | + } |
|
1108 | 1225 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1109 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1110 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1111 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1226 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1227 | + $error = "Failed to copy airlines logo."; |
|
1228 | + } |
|
1229 | + } else { |
|
1230 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1231 | + } |
|
1232 | + } else { |
|
1233 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1234 | + } |
|
1112 | 1235 | if ($error != '') { |
1113 | 1236 | return $error; |
1114 | - } elseif ($globalDebug) echo "Done\n"; |
|
1237 | + } elseif ($globalDebug) { |
|
1238 | + echo "Done\n"; |
|
1239 | + } |
|
1115 | 1240 | return ''; |
1116 | 1241 | } |
1117 | 1242 | |
1118 | 1243 | public static function update_routes() { |
1119 | 1244 | global $tmp_dir, $globalDebug; |
1120 | 1245 | $error = ''; |
1121 | - if ($globalDebug) echo "Routes : Download..."; |
|
1246 | + if ($globalDebug) { |
|
1247 | + echo "Routes : Download..."; |
|
1248 | + } |
|
1122 | 1249 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1123 | 1250 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1124 | - if ($globalDebug) echo "Gunzip..."; |
|
1251 | + if ($globalDebug) { |
|
1252 | + echo "Gunzip..."; |
|
1253 | + } |
|
1125 | 1254 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1126 | - if ($globalDebug) echo "Add to DB..."; |
|
1255 | + if ($globalDebug) { |
|
1256 | + echo "Add to DB..."; |
|
1257 | + } |
|
1127 | 1258 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1128 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1259 | + } else { |
|
1260 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1261 | + } |
|
1129 | 1262 | if ($error != '') { |
1130 | 1263 | return $error; |
1131 | - } elseif ($globalDebug) echo "Done\n"; |
|
1264 | + } elseif ($globalDebug) { |
|
1265 | + echo "Done\n"; |
|
1266 | + } |
|
1132 | 1267 | return ''; |
1133 | 1268 | } |
1134 | 1269 | public static function update_ModeS() { |
@@ -1145,257 +1280,455 @@ discard block |
||
1145 | 1280 | exit; |
1146 | 1281 | } elseif ($globalDebug) echo "Done\n"; |
1147 | 1282 | */ |
1148 | - if ($globalDebug) echo "Modes : Download..."; |
|
1283 | + if ($globalDebug) { |
|
1284 | + echo "Modes : Download..."; |
|
1285 | + } |
|
1149 | 1286 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1150 | 1287 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1151 | - if ($globalDebug) echo "Unzip..."; |
|
1288 | + if ($globalDebug) { |
|
1289 | + echo "Unzip..."; |
|
1290 | + } |
|
1152 | 1291 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
1153 | - if ($globalDebug) echo "Add to DB..."; |
|
1292 | + if ($globalDebug) { |
|
1293 | + echo "Add to DB..."; |
|
1294 | + } |
|
1154 | 1295 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1155 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1296 | + } else { |
|
1297 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1298 | + } |
|
1156 | 1299 | if ($error != '') { |
1157 | 1300 | return $error; |
1158 | - } elseif ($globalDebug) echo "Done\n"; |
|
1301 | + } elseif ($globalDebug) { |
|
1302 | + echo "Done\n"; |
|
1303 | + } |
|
1159 | 1304 | return ''; |
1160 | 1305 | } |
1161 | 1306 | |
1162 | 1307 | public static function update_ModeS_flarm() { |
1163 | 1308 | global $tmp_dir, $globalDebug; |
1164 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1309 | + if ($globalDebug) { |
|
1310 | + echo "Modes Flarmnet: Download..."; |
|
1311 | + } |
|
1165 | 1312 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1166 | 1313 | if (file_exists($tmp_dir.'data.fln')) { |
1167 | - if ($globalDebug) echo "Add to DB..."; |
|
1314 | + if ($globalDebug) { |
|
1315 | + echo "Add to DB..."; |
|
1316 | + } |
|
1168 | 1317 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1169 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1318 | + } else { |
|
1319 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1320 | + } |
|
1170 | 1321 | if ($error != '') { |
1171 | 1322 | return $error; |
1172 | - } elseif ($globalDebug) echo "Done\n"; |
|
1323 | + } elseif ($globalDebug) { |
|
1324 | + echo "Done\n"; |
|
1325 | + } |
|
1173 | 1326 | return ''; |
1174 | 1327 | } |
1175 | 1328 | |
1176 | 1329 | public static function update_ModeS_ogn() { |
1177 | 1330 | global $tmp_dir, $globalDebug; |
1178 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1331 | + if ($globalDebug) { |
|
1332 | + echo "Modes OGN: Download..."; |
|
1333 | + } |
|
1179 | 1334 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1180 | 1335 | if (file_exists($tmp_dir.'ogn.csv')) { |
1181 | - if ($globalDebug) echo "Add to DB..."; |
|
1336 | + if ($globalDebug) { |
|
1337 | + echo "Add to DB..."; |
|
1338 | + } |
|
1182 | 1339 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1183 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1340 | + } else { |
|
1341 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1342 | + } |
|
1184 | 1343 | if ($error != '') { |
1185 | 1344 | return $error; |
1186 | - } elseif ($globalDebug) echo "Done\n"; |
|
1345 | + } elseif ($globalDebug) { |
|
1346 | + echo "Done\n"; |
|
1347 | + } |
|
1187 | 1348 | return ''; |
1188 | 1349 | } |
1189 | 1350 | |
1190 | 1351 | public static function update_owner() { |
1191 | 1352 | global $tmp_dir, $globalDebug; |
1192 | 1353 | |
1193 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1354 | + if ($globalDebug) { |
|
1355 | + echo "Owner France: Download..."; |
|
1356 | + } |
|
1194 | 1357 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1195 | 1358 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1196 | - if ($globalDebug) echo "Add to DB..."; |
|
1359 | + if ($globalDebug) { |
|
1360 | + echo "Add to DB..."; |
|
1361 | + } |
|
1197 | 1362 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1198 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1363 | + } else { |
|
1364 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1365 | + } |
|
1199 | 1366 | if ($error != '') { |
1200 | 1367 | return $error; |
1201 | - } elseif ($globalDebug) echo "Done\n"; |
|
1368 | + } elseif ($globalDebug) { |
|
1369 | + echo "Done\n"; |
|
1370 | + } |
|
1202 | 1371 | |
1203 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1372 | + if ($globalDebug) { |
|
1373 | + echo "Owner Ireland: Download..."; |
|
1374 | + } |
|
1204 | 1375 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1205 | 1376 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1206 | - if ($globalDebug) echo "Add to DB..."; |
|
1377 | + if ($globalDebug) { |
|
1378 | + echo "Add to DB..."; |
|
1379 | + } |
|
1207 | 1380 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1208 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1381 | + } else { |
|
1382 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1383 | + } |
|
1209 | 1384 | if ($error != '') { |
1210 | 1385 | return $error; |
1211 | - } elseif ($globalDebug) echo "Done\n"; |
|
1212 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1386 | + } elseif ($globalDebug) { |
|
1387 | + echo "Done\n"; |
|
1388 | + } |
|
1389 | + if ($globalDebug) { |
|
1390 | + echo "Owner Switzerland: Download..."; |
|
1391 | + } |
|
1213 | 1392 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1214 | 1393 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1215 | - if ($globalDebug) echo "Add to DB..."; |
|
1394 | + if ($globalDebug) { |
|
1395 | + echo "Add to DB..."; |
|
1396 | + } |
|
1216 | 1397 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1217 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1398 | + } else { |
|
1399 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1400 | + } |
|
1218 | 1401 | if ($error != '') { |
1219 | 1402 | return $error; |
1220 | - } elseif ($globalDebug) echo "Done\n"; |
|
1221 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
1403 | + } elseif ($globalDebug) { |
|
1404 | + echo "Done\n"; |
|
1405 | + } |
|
1406 | + if ($globalDebug) { |
|
1407 | + echo "Owner Czech Republic: Download..."; |
|
1408 | + } |
|
1222 | 1409 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1223 | 1410 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1224 | - if ($globalDebug) echo "Add to DB..."; |
|
1411 | + if ($globalDebug) { |
|
1412 | + echo "Add to DB..."; |
|
1413 | + } |
|
1225 | 1414 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1226 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1415 | + } else { |
|
1416 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1417 | + } |
|
1227 | 1418 | if ($error != '') { |
1228 | 1419 | return $error; |
1229 | - } elseif ($globalDebug) echo "Done\n"; |
|
1230 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
1420 | + } elseif ($globalDebug) { |
|
1421 | + echo "Done\n"; |
|
1422 | + } |
|
1423 | + if ($globalDebug) { |
|
1424 | + echo "Owner Australia: Download..."; |
|
1425 | + } |
|
1231 | 1426 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1232 | 1427 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1233 | - if ($globalDebug) echo "Add to DB..."; |
|
1428 | + if ($globalDebug) { |
|
1429 | + echo "Add to DB..."; |
|
1430 | + } |
|
1234 | 1431 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1235 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1432 | + } else { |
|
1433 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1434 | + } |
|
1236 | 1435 | if ($error != '') { |
1237 | 1436 | return $error; |
1238 | - } elseif ($globalDebug) echo "Done\n"; |
|
1239 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
1437 | + } elseif ($globalDebug) { |
|
1438 | + echo "Done\n"; |
|
1439 | + } |
|
1440 | + if ($globalDebug) { |
|
1441 | + echo "Owner Austria: Download..."; |
|
1442 | + } |
|
1240 | 1443 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1241 | 1444 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1242 | - if ($globalDebug) echo "Add to DB..."; |
|
1445 | + if ($globalDebug) { |
|
1446 | + echo "Add to DB..."; |
|
1447 | + } |
|
1243 | 1448 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1244 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1449 | + } else { |
|
1450 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1451 | + } |
|
1245 | 1452 | if ($error != '') { |
1246 | 1453 | return $error; |
1247 | - } elseif ($globalDebug) echo "Done\n"; |
|
1248 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
1454 | + } elseif ($globalDebug) { |
|
1455 | + echo "Done\n"; |
|
1456 | + } |
|
1457 | + if ($globalDebug) { |
|
1458 | + echo "Owner Chile: Download..."; |
|
1459 | + } |
|
1249 | 1460 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1250 | 1461 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1251 | - if ($globalDebug) echo "Add to DB..."; |
|
1462 | + if ($globalDebug) { |
|
1463 | + echo "Add to DB..."; |
|
1464 | + } |
|
1252 | 1465 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1253 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1466 | + } else { |
|
1467 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1468 | + } |
|
1254 | 1469 | if ($error != '') { |
1255 | 1470 | return $error; |
1256 | - } elseif ($globalDebug) echo "Done\n"; |
|
1257 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
1471 | + } elseif ($globalDebug) { |
|
1472 | + echo "Done\n"; |
|
1473 | + } |
|
1474 | + if ($globalDebug) { |
|
1475 | + echo "Owner Colombia: Download..."; |
|
1476 | + } |
|
1258 | 1477 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1259 | 1478 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1260 | - if ($globalDebug) echo "Add to DB..."; |
|
1479 | + if ($globalDebug) { |
|
1480 | + echo "Add to DB..."; |
|
1481 | + } |
|
1261 | 1482 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1262 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1483 | + } else { |
|
1484 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1485 | + } |
|
1263 | 1486 | if ($error != '') { |
1264 | 1487 | return $error; |
1265 | - } elseif ($globalDebug) echo "Done\n"; |
|
1266 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
1488 | + } elseif ($globalDebug) { |
|
1489 | + echo "Done\n"; |
|
1490 | + } |
|
1491 | + if ($globalDebug) { |
|
1492 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
1493 | + } |
|
1267 | 1494 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1268 | 1495 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1269 | - if ($globalDebug) echo "Add to DB..."; |
|
1496 | + if ($globalDebug) { |
|
1497 | + echo "Add to DB..."; |
|
1498 | + } |
|
1270 | 1499 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1271 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1500 | + } else { |
|
1501 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1502 | + } |
|
1272 | 1503 | if ($error != '') { |
1273 | 1504 | return $error; |
1274 | - } elseif ($globalDebug) echo "Done\n"; |
|
1275 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
1505 | + } elseif ($globalDebug) { |
|
1506 | + echo "Done\n"; |
|
1507 | + } |
|
1508 | + if ($globalDebug) { |
|
1509 | + echo "Owner Brazil: Download..."; |
|
1510 | + } |
|
1276 | 1511 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1277 | 1512 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1278 | - if ($globalDebug) echo "Add to DB..."; |
|
1513 | + if ($globalDebug) { |
|
1514 | + echo "Add to DB..."; |
|
1515 | + } |
|
1279 | 1516 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1280 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1517 | + } else { |
|
1518 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1519 | + } |
|
1281 | 1520 | if ($error != '') { |
1282 | 1521 | return $error; |
1283 | - } elseif ($globalDebug) echo "Done\n"; |
|
1284 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
1522 | + } elseif ($globalDebug) { |
|
1523 | + echo "Done\n"; |
|
1524 | + } |
|
1525 | + if ($globalDebug) { |
|
1526 | + echo "Owner Cayman Islands: Download..."; |
|
1527 | + } |
|
1285 | 1528 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1286 | 1529 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1287 | - if ($globalDebug) echo "Add to DB..."; |
|
1530 | + if ($globalDebug) { |
|
1531 | + echo "Add to DB..."; |
|
1532 | + } |
|
1288 | 1533 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1289 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1534 | + } else { |
|
1535 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1536 | + } |
|
1290 | 1537 | if ($error != '') { |
1291 | 1538 | return $error; |
1292 | - } elseif ($globalDebug) echo "Done\n"; |
|
1293 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
1539 | + } elseif ($globalDebug) { |
|
1540 | + echo "Done\n"; |
|
1541 | + } |
|
1542 | + if ($globalDebug) { |
|
1543 | + echo "Owner Croatia: Download..."; |
|
1544 | + } |
|
1294 | 1545 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1295 | 1546 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1296 | - if ($globalDebug) echo "Add to DB..."; |
|
1547 | + if ($globalDebug) { |
|
1548 | + echo "Add to DB..."; |
|
1549 | + } |
|
1297 | 1550 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1298 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1551 | + } else { |
|
1552 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1553 | + } |
|
1299 | 1554 | if ($error != '') { |
1300 | 1555 | return $error; |
1301 | - } elseif ($globalDebug) echo "Done\n"; |
|
1302 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
1556 | + } elseif ($globalDebug) { |
|
1557 | + echo "Done\n"; |
|
1558 | + } |
|
1559 | + if ($globalDebug) { |
|
1560 | + echo "Owner Luxembourg: Download..."; |
|
1561 | + } |
|
1303 | 1562 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1304 | 1563 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1305 | - if ($globalDebug) echo "Add to DB..."; |
|
1564 | + if ($globalDebug) { |
|
1565 | + echo "Add to DB..."; |
|
1566 | + } |
|
1306 | 1567 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1307 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1568 | + } else { |
|
1569 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1570 | + } |
|
1308 | 1571 | if ($error != '') { |
1309 | 1572 | return $error; |
1310 | - } elseif ($globalDebug) echo "Done\n"; |
|
1311 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
1573 | + } elseif ($globalDebug) { |
|
1574 | + echo "Done\n"; |
|
1575 | + } |
|
1576 | + if ($globalDebug) { |
|
1577 | + echo "Owner Maldives: Download..."; |
|
1578 | + } |
|
1312 | 1579 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1313 | 1580 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1314 | - if ($globalDebug) echo "Add to DB..."; |
|
1581 | + if ($globalDebug) { |
|
1582 | + echo "Add to DB..."; |
|
1583 | + } |
|
1315 | 1584 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1316 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1585 | + } else { |
|
1586 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1587 | + } |
|
1317 | 1588 | if ($error != '') { |
1318 | 1589 | return $error; |
1319 | - } elseif ($globalDebug) echo "Done\n"; |
|
1320 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
1590 | + } elseif ($globalDebug) { |
|
1591 | + echo "Done\n"; |
|
1592 | + } |
|
1593 | + if ($globalDebug) { |
|
1594 | + echo "Owner New Zealand: Download..."; |
|
1595 | + } |
|
1321 | 1596 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1322 | 1597 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1323 | - if ($globalDebug) echo "Add to DB..."; |
|
1598 | + if ($globalDebug) { |
|
1599 | + echo "Add to DB..."; |
|
1600 | + } |
|
1324 | 1601 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1325 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1602 | + } else { |
|
1603 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1604 | + } |
|
1326 | 1605 | if ($error != '') { |
1327 | 1606 | return $error; |
1328 | - } elseif ($globalDebug) echo "Done\n"; |
|
1329 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
1607 | + } elseif ($globalDebug) { |
|
1608 | + echo "Done\n"; |
|
1609 | + } |
|
1610 | + if ($globalDebug) { |
|
1611 | + echo "Owner Papua New Guinea: Download..."; |
|
1612 | + } |
|
1330 | 1613 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1331 | 1614 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1332 | - if ($globalDebug) echo "Add to DB..."; |
|
1615 | + if ($globalDebug) { |
|
1616 | + echo "Add to DB..."; |
|
1617 | + } |
|
1333 | 1618 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1334 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1619 | + } else { |
|
1620 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1621 | + } |
|
1335 | 1622 | if ($error != '') { |
1336 | 1623 | return $error; |
1337 | - } elseif ($globalDebug) echo "Done\n"; |
|
1338 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
1624 | + } elseif ($globalDebug) { |
|
1625 | + echo "Done\n"; |
|
1626 | + } |
|
1627 | + if ($globalDebug) { |
|
1628 | + echo "Owner Slovakia: Download..."; |
|
1629 | + } |
|
1339 | 1630 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1340 | 1631 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1341 | - if ($globalDebug) echo "Add to DB..."; |
|
1632 | + if ($globalDebug) { |
|
1633 | + echo "Add to DB..."; |
|
1634 | + } |
|
1342 | 1635 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1343 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1636 | + } else { |
|
1637 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1638 | + } |
|
1344 | 1639 | if ($error != '') { |
1345 | 1640 | return $error; |
1346 | - } elseif ($globalDebug) echo "Done\n"; |
|
1347 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
1641 | + } elseif ($globalDebug) { |
|
1642 | + echo "Done\n"; |
|
1643 | + } |
|
1644 | + if ($globalDebug) { |
|
1645 | + echo "Owner Ecuador: Download..."; |
|
1646 | + } |
|
1348 | 1647 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1349 | 1648 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1350 | - if ($globalDebug) echo "Add to DB..."; |
|
1649 | + if ($globalDebug) { |
|
1650 | + echo "Add to DB..."; |
|
1651 | + } |
|
1351 | 1652 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1352 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1653 | + } else { |
|
1654 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1655 | + } |
|
1353 | 1656 | if ($error != '') { |
1354 | 1657 | return $error; |
1355 | - } elseif ($globalDebug) echo "Done\n"; |
|
1356 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
1658 | + } elseif ($globalDebug) { |
|
1659 | + echo "Done\n"; |
|
1660 | + } |
|
1661 | + if ($globalDebug) { |
|
1662 | + echo "Owner Iceland: Download..."; |
|
1663 | + } |
|
1357 | 1664 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1358 | 1665 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1359 | - if ($globalDebug) echo "Add to DB..."; |
|
1666 | + if ($globalDebug) { |
|
1667 | + echo "Add to DB..."; |
|
1668 | + } |
|
1360 | 1669 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1361 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
1670 | + } else { |
|
1671 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
1672 | + } |
|
1362 | 1673 | if ($error != '') { |
1363 | 1674 | return $error; |
1364 | - } elseif ($globalDebug) echo "Done\n"; |
|
1675 | + } elseif ($globalDebug) { |
|
1676 | + echo "Done\n"; |
|
1677 | + } |
|
1365 | 1678 | return ''; |
1366 | 1679 | } |
1367 | 1680 | |
1368 | 1681 | public static function update_translation() { |
1369 | 1682 | global $tmp_dir, $globalDebug; |
1370 | 1683 | $error = ''; |
1371 | - if ($globalDebug) echo "Translation : Download..."; |
|
1684 | + if ($globalDebug) { |
|
1685 | + echo "Translation : Download..."; |
|
1686 | + } |
|
1372 | 1687 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1373 | 1688 | if (file_exists($tmp_dir.'translation.zip')) { |
1374 | - if ($globalDebug) echo "Unzip..."; |
|
1689 | + if ($globalDebug) { |
|
1690 | + echo "Unzip..."; |
|
1691 | + } |
|
1375 | 1692 | update_db::unzip($tmp_dir.'translation.zip'); |
1376 | - if ($globalDebug) echo "Add to DB..."; |
|
1693 | + if ($globalDebug) { |
|
1694 | + echo "Add to DB..."; |
|
1695 | + } |
|
1377 | 1696 | $error = update_db::translation(); |
1378 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
1697 | + } else { |
|
1698 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
1699 | + } |
|
1379 | 1700 | if ($error != '') { |
1380 | 1701 | return $error; |
1381 | - } elseif ($globalDebug) echo "Done\n"; |
|
1702 | + } elseif ($globalDebug) { |
|
1703 | + echo "Done\n"; |
|
1704 | + } |
|
1382 | 1705 | return ''; |
1383 | 1706 | } |
1384 | 1707 | |
1385 | 1708 | public static function update_translation_fam() { |
1386 | 1709 | global $tmp_dir, $globalDebug; |
1387 | 1710 | $error = ''; |
1388 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
1711 | + if ($globalDebug) { |
|
1712 | + echo "Translation from FlightAirMap website : Download..."; |
|
1713 | + } |
|
1389 | 1714 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1390 | 1715 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1391 | - if ($globalDebug) echo "Gunzip..."; |
|
1716 | + if ($globalDebug) { |
|
1717 | + echo "Gunzip..."; |
|
1718 | + } |
|
1392 | 1719 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1393 | - if ($globalDebug) echo "Add to DB..."; |
|
1720 | + if ($globalDebug) { |
|
1721 | + echo "Add to DB..."; |
|
1722 | + } |
|
1394 | 1723 | $error = update_db::translation_fam(); |
1395 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
1724 | + } else { |
|
1725 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
1726 | + } |
|
1396 | 1727 | if ($error != '') { |
1397 | 1728 | return $error; |
1398 | - } elseif ($globalDebug) echo "Done\n"; |
|
1729 | + } elseif ($globalDebug) { |
|
1730 | + echo "Done\n"; |
|
1731 | + } |
|
1399 | 1732 | return ''; |
1400 | 1733 | } |
1401 | 1734 | |
@@ -1438,7 +1771,9 @@ discard block |
||
1438 | 1771 | } |
1439 | 1772 | |
1440 | 1773 | $error = ''; |
1441 | - if ($globalDebug) echo "Notam : Download..."; |
|
1774 | + if ($globalDebug) { |
|
1775 | + echo "Notam : Download..."; |
|
1776 | + } |
|
1442 | 1777 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
1443 | 1778 | if (file_exists($tmp_dir.'notam.rss')) { |
1444 | 1779 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1453,14 +1788,30 @@ discard block |
||
1453 | 1788 | $data['fir'] = $q[0]; |
1454 | 1789 | $data['code'] = $q[1]; |
1455 | 1790 | $ifrvfr = $q[2]; |
1456 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
1457 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
1458 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
1459 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
1460 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
1461 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
1462 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
1463 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
1791 | + if ($ifrvfr == 'IV') { |
|
1792 | + $data['rules'] = 'IFR/VFR'; |
|
1793 | + } |
|
1794 | + if ($ifrvfr == 'I') { |
|
1795 | + $data['rules'] = 'IFR'; |
|
1796 | + } |
|
1797 | + if ($ifrvfr == 'V') { |
|
1798 | + $data['rules'] = 'VFR'; |
|
1799 | + } |
|
1800 | + if ($q[4] == 'A') { |
|
1801 | + $data['scope'] = 'Airport warning'; |
|
1802 | + } |
|
1803 | + if ($q[4] == 'E') { |
|
1804 | + $data['scope'] = 'Enroute warning'; |
|
1805 | + } |
|
1806 | + if ($q[4] == 'W') { |
|
1807 | + $data['scope'] = 'Navigation warning'; |
|
1808 | + } |
|
1809 | + if ($q[4] == 'AE') { |
|
1810 | + $data['scope'] = 'Airport/Enroute warning'; |
|
1811 | + } |
|
1812 | + if ($q[4] == 'AW') { |
|
1813 | + $data['scope'] = 'Airport/Navigation warning'; |
|
1814 | + } |
|
1464 | 1815 | //$data['scope'] = $q[4]; |
1465 | 1816 | $data['lower_limit'] = $q[5]; |
1466 | 1817 | $data['upper_limit'] = $q[6]; |
@@ -1468,8 +1819,12 @@ discard block |
||
1468 | 1819 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
1469 | 1820 | $latitude = $Common->convertDec($las,'latitude'); |
1470 | 1821 | $longitude = $Common->convertDec($lns,'longitude'); |
1471 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
1472 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
1822 | + if ($lac == 'S') { |
|
1823 | + $latitude = '-'.$latitude; |
|
1824 | + } |
|
1825 | + if ($lnc == 'W') { |
|
1826 | + $longitude = '-'.$longitude; |
|
1827 | + } |
|
1473 | 1828 | $data['center_latitude'] = $latitude; |
1474 | 1829 | $data['center_longitude'] = $longitude; |
1475 | 1830 | $data['radius'] = intval($radius); |
@@ -1499,10 +1854,14 @@ discard block |
||
1499 | 1854 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
1500 | 1855 | unset($data); |
1501 | 1856 | } |
1502 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
1857 | + } else { |
|
1858 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
1859 | + } |
|
1503 | 1860 | if ($error != '') { |
1504 | 1861 | return $error; |
1505 | - } elseif ($globalDebug) echo "Done\n"; |
|
1862 | + } elseif ($globalDebug) { |
|
1863 | + echo "Done\n"; |
|
1864 | + } |
|
1506 | 1865 | return ''; |
1507 | 1866 | } |
1508 | 1867 | |
@@ -1521,8 +1880,11 @@ discard block |
||
1521 | 1880 | return "error : ".$e->getMessage(); |
1522 | 1881 | } |
1523 | 1882 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1524 | - if ($row['nb'] > 0) return false; |
|
1525 | - else return true; |
|
1883 | + if ($row['nb'] > 0) { |
|
1884 | + return false; |
|
1885 | + } else { |
|
1886 | + return true; |
|
1887 | + } |
|
1526 | 1888 | } |
1527 | 1889 | |
1528 | 1890 | public static function insert_last_update() { |
@@ -1552,8 +1914,11 @@ discard block |
||
1552 | 1914 | return "error : ".$e->getMessage(); |
1553 | 1915 | } |
1554 | 1916 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1555 | - if ($row['nb'] > 0) return false; |
|
1556 | - else return true; |
|
1917 | + if ($row['nb'] > 0) { |
|
1918 | + return false; |
|
1919 | + } else { |
|
1920 | + return true; |
|
1921 | + } |
|
1557 | 1922 | } |
1558 | 1923 | |
1559 | 1924 | public static function insert_last_notam_update() { |
@@ -1583,8 +1948,11 @@ discard block |
||
1583 | 1948 | return "error : ".$e->getMessage(); |
1584 | 1949 | } |
1585 | 1950 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1586 | - if ($row['nb'] > 0) return false; |
|
1587 | - else return true; |
|
1951 | + if ($row['nb'] > 0) { |
|
1952 | + return false; |
|
1953 | + } else { |
|
1954 | + return true; |
|
1955 | + } |
|
1588 | 1956 | } |
1589 | 1957 | |
1590 | 1958 | public static function insert_last_owner_update() { |
@@ -13,6 +13,9 @@ discard block |
||
13 | 13 | function sparql_connect( $endpoint ) { return new sparql_connection( $endpoint ); } |
14 | 14 | |
15 | 15 | function sparql_ns( $short, $long, $db = null ) { return _sparql_a_connection( $db )->ns( $short, $long ); } |
16 | +/** |
|
17 | + * @param string $sparql |
|
18 | + */ |
|
16 | 19 | function sparql_query( $sparql, $db = null ) { return _sparql_a_connection( $db )->query( $sparql ); } |
17 | 20 | function sparql_errno( $db = null ) { return _sparql_a_connection( $db )->errno(); } |
18 | 21 | function sparql_error( $db = null ) { return _sparql_a_connection( $db )->error(); } |
@@ -84,6 +87,9 @@ discard block |
||
84 | 87 | $this->params = $params; |
85 | 88 | } |
86 | 89 | |
90 | + /** |
|
91 | + * @param integer $timeout |
|
92 | + */ |
|
87 | 93 | function query( $query, $timeout=null ) |
88 | 94 | { |
89 | 95 | $prefixes = ""; |
@@ -324,6 +330,10 @@ discard block |
||
324 | 330 | var $fields; |
325 | 331 | var $db; |
326 | 332 | var $i = 0; |
333 | + |
|
334 | + /** |
|
335 | + * @param sparql_connection $db |
|
336 | + */ |
|
327 | 337 | function __construct( $db, $rows, $fields ) |
328 | 338 | { |
329 | 339 | $this->rows = $rows; |
@@ -215,14 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | $r = null; |
217 | 217 | |
218 | - if( $code == "select" ) { $r = $this->test_select(); } |
|
219 | - elseif( $code == "constant_as" ) { $r = $this->test_constant_as(); } |
|
220 | - elseif( $code == "math_as" ) { $r = $this->test_math_as(); } |
|
221 | - elseif( $code == "count" ) { $r = $this->test_count(); } |
|
222 | - elseif( $code == "max" ) { $r = $this->test_max(); } |
|
223 | - elseif( $code == "load" ) { $r = $this->test_load(); } |
|
224 | - elseif( $code == "sample" ) { $r = $this->test_sample(); } |
|
225 | - else { print "<p>Unknown capability code: '$code'</p>"; return false; } |
|
218 | + if( $code == "select" ) { $r = $this->test_select(); } elseif( $code == "constant_as" ) { $r = $this->test_constant_as(); } elseif( $code == "math_as" ) { $r = $this->test_math_as(); } elseif( $code == "count" ) { $r = $this->test_count(); } elseif( $code == "max" ) { $r = $this->test_max(); } elseif( $code == "load" ) { $r = $this->test_load(); } elseif( $code == "sample" ) { $r = $this->test_sample(); } else { print "<p>Unknown capability code: '$code'</p>"; return false; } |
|
226 | 219 | $this->caps[$code] = $r; |
227 | 220 | if( isset( $this->caps_cache ) ) |
228 | 221 | { |
@@ -231,8 +224,7 @@ discard block |
||
231 | 224 | if( $was_cached ) |
232 | 225 | { |
233 | 226 | dba_replace( $db_key, $db_val, $this->caps_cache ); |
234 | - } |
|
235 | - else |
|
227 | + } else |
|
236 | 228 | { |
237 | 229 | dba_insert( $db_key, $db_val, $this->caps_cache ); |
238 | 230 | } |
@@ -809,8 +809,6 @@ |
||
809 | 809 | /** |
810 | 810 | * Get Message title from label from DB |
811 | 811 | * |
812 | - * @param String $ident |
|
813 | - * @return Array Return ACARS data in array |
|
814 | 812 | */ |
815 | 813 | public function getTitlefromLabel($label) { |
816 | 814 | $Connection = new Connection($this->db); |
@@ -23,14 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function ident2icao($ident) { |
25 | 25 | if (substr($ident,0,2) == 'AF') { |
26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
26 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
27 | + $icao = $ident; |
|
28 | + } else { |
|
29 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
30 | + } |
|
28 | 31 | } else { |
29 | 32 | $Spotter = new Spotter($this->db); |
30 | 33 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
31 | 34 | if (isset($identicao[0])) { |
32 | 35 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
33 | - } else $icao = $ident; |
|
36 | + } else { |
|
37 | + $icao = $ident; |
|
38 | + } |
|
34 | 39 | } |
35 | 40 | return $icao; |
36 | 41 | } |
@@ -97,12 +102,18 @@ discard block |
||
97 | 102 | $Translation = new Translation($this->db); |
98 | 103 | |
99 | 104 | $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); |
100 | - 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); |
|
105 | + if ($n == 0) { |
|
106 | + $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); |
|
107 | + } |
|
101 | 108 | if ($n != 0) { |
102 | 109 | $registration = str_replace('.','',$registration); |
103 | 110 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
104 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
105 | - } else $message = $data; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
113 | + } |
|
114 | + } else { |
|
115 | + $message = $data; |
|
116 | + } |
|
106 | 117 | $icao = ''; |
107 | 118 | $airicao = ''; |
108 | 119 | $decode = array(); |
@@ -116,12 +127,21 @@ discard block |
||
116 | 127 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
117 | 128 | $latitude = $la / 10000.0; |
118 | 129 | $longitude = $ln / 10000.0; |
119 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
120 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
130 | + if ($lac == 'S') { |
|
131 | + $latitude = '-'.$latitude; |
|
132 | + } |
|
133 | + if ($lnc == 'W') { |
|
134 | + $longitude = '-'.$longitude; |
|
135 | + } |
|
121 | 136 | // Temp not always available |
122 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
123 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
124 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
137 | + if ($globalDebug) { |
|
138 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
139 | + } |
|
140 | + if ($temp == '') { |
|
141 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | + } else { |
|
143 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
144 | + } |
|
125 | 145 | |
126 | 146 | //$icao = $Translation->checkTranslation($ident); |
127 | 147 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -131,25 +151,35 @@ discard block |
||
131 | 151 | if (!$found && ($label == '10')) { |
132 | 152 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
133 | 153 | if ($n == 4 && strlen($darr) == 4) { |
134 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
135 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
136 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
154 | + if ($dhour != '') { |
|
155 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
156 | + } |
|
157 | + if ($ahour != '') { |
|
158 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
159 | + } |
|
160 | + if ($globalDebug) { |
|
161 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
162 | + } |
|
137 | 163 | //$icao = ACARS->ident2icao($ident); |
138 | 164 | //$icao = $Translation->checkTranslation($ident); |
139 | 165 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
140 | 166 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
141 | 167 | $found = true; |
142 | - } |
|
143 | - elseif ($n == 2 || $n == 4) { |
|
144 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
145 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
168 | + } elseif ($n == 2 || $n == 4) { |
|
169 | + if ($dhour != '') { |
|
170 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
171 | + } |
|
172 | + if ($globalDebug) { |
|
173 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
174 | + } |
|
146 | 175 | //$icao = ACARS->ident2icao($ident); |
147 | 176 | //$icao = $Translation->checkTranslation($ident); |
148 | 177 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
149 | 178 | $found = true; |
150 | - } |
|
151 | - elseif ($n == 1) { |
|
152 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
179 | + } elseif ($n == 1) { |
|
180 | + if ($globalDebug) { |
|
181 | + echo 'airport arrival : '.$darr."\n"; |
|
182 | + } |
|
153 | 183 | //$icao = ACARS->ident2icao($ident); |
154 | 184 | //$icao = $Translation->checkTranslation($ident); |
155 | 185 | $decode = array('Arrival airport' => $darr); |
@@ -166,7 +196,9 @@ discard block |
||
166 | 196 | |
167 | 197 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
168 | 198 | if ($n == 4) { |
169 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
201 | + } |
|
170 | 202 | //$icao = ACARS->ident2icao($ident); |
171 | 203 | //$icao = $Translation->checkTranslation($ident); |
172 | 204 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -191,14 +223,23 @@ discard block |
||
191 | 223 | //$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
192 | 224 | $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); |
193 | 225 | if ($n > 8) { |
194 | - 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"; |
|
195 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
196 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
226 | + if ($globalDebug) { |
|
227 | + 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"; |
|
228 | + } |
|
229 | + if ($dhour != '') { |
|
230 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
231 | + } |
|
232 | + if ($ahour != '') { |
|
233 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
234 | + } |
|
197 | 235 | $icao = trim($aident); |
198 | 236 | |
199 | 237 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
200 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
201 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
238 | + if ($ahour == '') { |
|
239 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
240 | + } else { |
|
241 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
242 | + } |
|
202 | 243 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
203 | 244 | $decode['icao'] = $icao; |
204 | 245 | $found = true; |
@@ -215,9 +256,15 @@ discard block |
||
215 | 256 | $lns = $lns.'.'.$lns; |
216 | 257 | $latitude = $las / 1000.0; |
217 | 258 | $longitude = $lns / 1000.0; |
218 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
219 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
220 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
259 | + if ($lac == 'S') { |
|
260 | + $latitude = '-'.$latitude; |
|
261 | + } |
|
262 | + if ($lnc == 'W') { |
|
263 | + $longitude = '-'.$longitude; |
|
264 | + } |
|
265 | + if ($globalDebug) { |
|
266 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
267 | + } |
|
221 | 268 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
222 | 269 | $found = true; |
223 | 270 | } |
@@ -233,7 +280,9 @@ discard block |
||
233 | 280 | */ |
234 | 281 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
235 | 282 | if ($n == 4) { |
236 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
283 | + if ($globalDebug) { |
|
284 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
285 | + } |
|
237 | 286 | //$icao = $Translation->checkTranslation($ident); |
238 | 287 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
239 | 288 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -244,7 +293,9 @@ discard block |
||
244 | 293 | // example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609" |
245 | 294 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
246 | 295 | if ($n == 4) { |
247 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
296 | + if ($globalDebug) { |
|
297 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
298 | + } |
|
248 | 299 | //$icao = $Translation->checkTranslation($ident); |
249 | 300 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
250 | 301 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -255,7 +306,9 @@ discard block |
||
255 | 306 | // example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF EBLG EBBR N4621.5E 524.2195" |
256 | 307 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
257 | 308 | if ($n == 2) { |
258 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
311 | + } |
|
259 | 312 | //$icao = $Translation->checkTranslation($ident); |
260 | 313 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
261 | 314 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -267,7 +320,9 @@ discard block |
||
267 | 320 | // example message : 'Reg. : F-GHQJ - Ident : AF6241 - Label : H1 - Message : #DFBA01/CCF-GHQJ,FEB27,205556,LFMN,LFPO,0241/C106,17404,5000,42,0010,0,0100,42,X/CEN270,36012,257,778,6106,299,B5B7G8/EC731134,42387,01439,41194,12/EE731212,44932,11870,43555,12/N10875,0875,0910,6330,1205,-----' |
268 | 321 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
269 | 322 | if ($n == 6) { |
270 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
323 | + if ($globalDebug) { |
|
324 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
325 | + } |
|
271 | 326 | //$icao = $Translation->checkTranslation($ident); |
272 | 327 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
273 | 328 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -278,7 +333,9 @@ discard block |
||
278 | 333 | // example message : 'Reg. : F-GUGP - Ident : AF1842 - Label : H1 - Message : #DFBA01/A31801,1,1/CCF-GUGP,MAR11,093856,LFPG,LSGG,1842/C106,55832,5000,37,0010,0,0100,37,X/CEN282,31018,277,750,5515,255,C11036/EC577870,02282,07070,01987,73,14/EE577871,02282,06947,01987,73/N10790,0790,0903,5' |
279 | 334 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
280 | 335 | if ($n == 7) { |
281 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
336 | + if ($globalDebug) { |
|
337 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
338 | + } |
|
282 | 339 | //$icao = $Translation->checkTranslation($ident); |
283 | 340 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
284 | 341 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -298,8 +355,12 @@ discard block |
||
298 | 355 | $decode['icao'] = $icao; |
299 | 356 | $latitude = $las / 100.0; |
300 | 357 | $longitude = $lns / 100.0; |
301 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
302 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
358 | + if ($lac == 'S') { |
|
359 | + $latitude = '-'.$latitude; |
|
360 | + } |
|
361 | + if ($lnc == 'W') { |
|
362 | + $longitude = '-'.$longitude; |
|
363 | + } |
|
303 | 364 | |
304 | 365 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
305 | 366 | $found = true; |
@@ -313,8 +374,12 @@ discard block |
||
313 | 374 | if ($n == 4) { |
314 | 375 | $latitude = $las; |
315 | 376 | $longitude = $lns; |
316 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
317 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
377 | + if ($lac == 'S') { |
|
378 | + $latitude = '-'.$latitude; |
|
379 | + } |
|
380 | + if ($lnc == 'W') { |
|
381 | + $longitude = '-'.$longitude; |
|
382 | + } |
|
318 | 383 | |
319 | 384 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
320 | 385 | $found = true; |
@@ -328,7 +393,9 @@ discard block |
||
328 | 393 | */ |
329 | 394 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
330 | 395 | if ($n == 5) { |
331 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
396 | + if ($globalDebug) { |
|
397 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
398 | + } |
|
332 | 399 | //$icao = $Translation->checkTranslation($ident); |
333 | 400 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
334 | 401 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -346,7 +413,9 @@ discard block |
||
346 | 413 | // $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident); |
347 | 414 | $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); |
348 | 415 | if ($n == 8) { |
349 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
416 | + if ($globalDebug) { |
|
417 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
418 | + } |
|
350 | 419 | $icao = trim($aident); |
351 | 420 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
352 | 421 | $decode['icao'] = $icao; |
@@ -361,7 +430,9 @@ discard block |
||
361 | 430 | */ |
362 | 431 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
363 | 432 | if ($n == 5) { |
364 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
433 | + if ($globalDebug) { |
|
434 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
435 | + } |
|
365 | 436 | //$icao = $Translation->checkTranslation($ident); |
366 | 437 | |
367 | 438 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -375,7 +446,9 @@ discard block |
||
375 | 446 | */ |
376 | 447 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
377 | 448 | if ($n == 3) { |
378 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
449 | + if ($globalDebug) { |
|
450 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
451 | + } |
|
379 | 452 | //$icao = $Translation->checkTranslation($ident); |
380 | 453 | |
381 | 454 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -389,7 +462,9 @@ discard block |
||
389 | 462 | */ |
390 | 463 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
391 | 464 | if ($n == 3) { |
392 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
465 | + if ($globalDebug) { |
|
466 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
467 | + } |
|
393 | 468 | //$icao = $Translation->checkTranslation($ident); |
394 | 469 | |
395 | 470 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -400,7 +475,9 @@ discard block |
||
400 | 475 | if (!$found) { |
401 | 476 | $n = sscanf($message,'MET01%4c',$airport); |
402 | 477 | if ($n == 1) { |
403 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
478 | + if ($globalDebug) { |
|
479 | + echo 'airport name : '.$airport; |
|
480 | + } |
|
404 | 481 | $decode = array('Airport/Waypoint name' => $airport); |
405 | 482 | $found = true; |
406 | 483 | } |
@@ -409,184 +486,126 @@ discard block |
||
409 | 486 | if ($label == 'H1') { |
410 | 487 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
411 | 488 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
412 | - } |
|
413 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
489 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
414 | 490 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
415 | - } |
|
416 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
491 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
417 | 492 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
418 | - } |
|
419 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
493 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
420 | 494 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
421 | - } |
|
422 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
495 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
423 | 496 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
424 | - } |
|
425 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
497 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
426 | 498 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
427 | - } |
|
428 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
499 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
429 | 500 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
430 | - } |
|
431 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
501 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
432 | 502 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
433 | - } |
|
434 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
503 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
435 | 504 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
436 | - } |
|
437 | - elseif (preg_match(':^#CF:',$message)) { |
|
505 | + } elseif (preg_match(':^#CF:',$message)) { |
|
438 | 506 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
439 | - } |
|
440 | - elseif (preg_match(':^#DF:',$message)) { |
|
507 | + } elseif (preg_match(':^#DF:',$message)) { |
|
441 | 508 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
442 | - } |
|
443 | - elseif (preg_match(':^#EC:',$message)) { |
|
509 | + } elseif (preg_match(':^#EC:',$message)) { |
|
444 | 510 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
445 | - } |
|
446 | - elseif (preg_match(':^#EI:',$message)) { |
|
511 | + } elseif (preg_match(':^#EI:',$message)) { |
|
447 | 512 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
448 | - } |
|
449 | - elseif (preg_match(':^#H1:',$message)) { |
|
513 | + } elseif (preg_match(':^#H1:',$message)) { |
|
450 | 514 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
451 | - } |
|
452 | - elseif (preg_match(':^#H2:',$message)) { |
|
515 | + } elseif (preg_match(':^#H2:',$message)) { |
|
453 | 516 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
454 | - } |
|
455 | - elseif (preg_match(':^#HD:',$message)) { |
|
517 | + } elseif (preg_match(':^#HD:',$message)) { |
|
456 | 518 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
457 | - } |
|
458 | - elseif (preg_match(':^#M1:',$message)) { |
|
519 | + } elseif (preg_match(':^#M1:',$message)) { |
|
459 | 520 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
460 | - } |
|
461 | - elseif (preg_match(':^#M2:',$message)) { |
|
521 | + } elseif (preg_match(':^#M2:',$message)) { |
|
462 | 522 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
463 | - } |
|
464 | - elseif (preg_match(':^#M3:',$message)) { |
|
523 | + } elseif (preg_match(':^#M3:',$message)) { |
|
465 | 524 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
466 | - } |
|
467 | - elseif (preg_match(':^#MD:',$message)) { |
|
525 | + } elseif (preg_match(':^#MD:',$message)) { |
|
468 | 526 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
469 | - } |
|
470 | - elseif (preg_match(':^#PS:',$message)) { |
|
527 | + } elseif (preg_match(':^#PS:',$message)) { |
|
471 | 528 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
472 | - } |
|
473 | - elseif (preg_match(':^#S1:',$message)) { |
|
529 | + } elseif (preg_match(':^#S1:',$message)) { |
|
474 | 530 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
475 | - } |
|
476 | - elseif (preg_match(':^#S2:',$message)) { |
|
531 | + } elseif (preg_match(':^#S2:',$message)) { |
|
477 | 532 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
478 | - } |
|
479 | - elseif (preg_match(':^#SD:',$message)) { |
|
533 | + } elseif (preg_match(':^#SD:',$message)) { |
|
480 | 534 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
481 | - } |
|
482 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
535 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
483 | 536 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
484 | - } |
|
485 | - elseif (preg_match(':^#WO:',$message)) { |
|
537 | + } elseif (preg_match(':^#WO:',$message)) { |
|
486 | 538 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
487 | - } |
|
488 | - elseif (preg_match(':^#A1:',$message)) { |
|
539 | + } elseif (preg_match(':^#A1:',$message)) { |
|
489 | 540 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
490 | - } |
|
491 | - elseif (preg_match(':^#A3:',$message)) { |
|
541 | + } elseif (preg_match(':^#A3:',$message)) { |
|
492 | 542 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
493 | - } |
|
494 | - elseif (preg_match(':^#A4:',$message)) { |
|
543 | + } elseif (preg_match(':^#A4:',$message)) { |
|
495 | 544 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
496 | - } |
|
497 | - elseif (preg_match(':^#A6:',$message)) { |
|
545 | + } elseif (preg_match(':^#A6:',$message)) { |
|
498 | 546 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
499 | - } |
|
500 | - elseif (preg_match(':^#A8:',$message)) { |
|
547 | + } elseif (preg_match(':^#A8:',$message)) { |
|
501 | 548 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
502 | - } |
|
503 | - elseif (preg_match(':^#A9:',$message)) { |
|
549 | + } elseif (preg_match(':^#A9:',$message)) { |
|
504 | 550 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
505 | - } |
|
506 | - elseif (preg_match(':^#A0:',$message)) { |
|
551 | + } elseif (preg_match(':^#A0:',$message)) { |
|
507 | 552 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
508 | - } |
|
509 | - elseif (preg_match(':^#AA:',$message)) { |
|
553 | + } elseif (preg_match(':^#AA:',$message)) { |
|
510 | 554 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
511 | - } |
|
512 | - elseif (preg_match(':^#AB:',$message)) { |
|
555 | + } elseif (preg_match(':^#AB:',$message)) { |
|
513 | 556 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
514 | - } |
|
515 | - elseif (preg_match(':^#AC:',$message)) { |
|
557 | + } elseif (preg_match(':^#AC:',$message)) { |
|
516 | 558 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
517 | - } |
|
518 | - elseif (preg_match(':^#AD:',$message)) { |
|
559 | + } elseif (preg_match(':^#AD:',$message)) { |
|
519 | 560 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
520 | - } |
|
521 | - elseif (preg_match(':^#AF:',$message)) { |
|
561 | + } elseif (preg_match(':^#AF:',$message)) { |
|
522 | 562 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
523 | - } |
|
524 | - elseif (preg_match(':^#B1:',$message)) { |
|
563 | + } elseif (preg_match(':^#B1:',$message)) { |
|
525 | 564 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
526 | - } |
|
527 | - elseif (preg_match(':^#B2:',$message)) { |
|
565 | + } elseif (preg_match(':^#B2:',$message)) { |
|
528 | 566 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
529 | - } |
|
530 | - elseif (preg_match(':^#B3:',$message)) { |
|
567 | + } elseif (preg_match(':^#B3:',$message)) { |
|
531 | 568 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
532 | - } |
|
533 | - elseif (preg_match(':^#B4:',$message)) { |
|
569 | + } elseif (preg_match(':^#B4:',$message)) { |
|
534 | 570 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
535 | - } |
|
536 | - elseif (preg_match(':^#B6:',$message)) { |
|
571 | + } elseif (preg_match(':^#B6:',$message)) { |
|
537 | 572 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
538 | - } |
|
539 | - elseif (preg_match(':^#B8:',$message)) { |
|
573 | + } elseif (preg_match(':^#B8:',$message)) { |
|
540 | 574 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
541 | - } |
|
542 | - elseif (preg_match(':^#B9:',$message)) { |
|
575 | + } elseif (preg_match(':^#B9:',$message)) { |
|
543 | 576 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
544 | - } |
|
545 | - elseif (preg_match(':^#B0:',$message)) { |
|
577 | + } elseif (preg_match(':^#B0:',$message)) { |
|
546 | 578 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
547 | - } |
|
548 | - elseif (preg_match(':^#BA:',$message)) { |
|
579 | + } elseif (preg_match(':^#BA:',$message)) { |
|
549 | 580 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
550 | - } |
|
551 | - elseif (preg_match(':^#BB:',$message)) { |
|
581 | + } elseif (preg_match(':^#BB:',$message)) { |
|
552 | 582 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
553 | - } |
|
554 | - elseif (preg_match(':^#BC:',$message)) { |
|
583 | + } elseif (preg_match(':^#BC:',$message)) { |
|
555 | 584 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
556 | - } |
|
557 | - elseif (preg_match(':^#BD:',$message)) { |
|
585 | + } elseif (preg_match(':^#BD:',$message)) { |
|
558 | 586 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
559 | - } |
|
560 | - elseif (preg_match(':^#BE:',$message)) { |
|
587 | + } elseif (preg_match(':^#BE:',$message)) { |
|
561 | 588 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
562 | - } |
|
563 | - elseif (preg_match(':^#BF:',$message)) { |
|
589 | + } elseif (preg_match(':^#BF:',$message)) { |
|
564 | 590 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
565 | - } |
|
566 | - elseif (preg_match(':^#H3:',$message)) { |
|
591 | + } elseif (preg_match(':^#H3:',$message)) { |
|
567 | 592 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
568 | 593 | } |
569 | 594 | } |
570 | 595 | if ($label == '10') { |
571 | 596 | if (preg_match(':^DTO01:',$message)) { |
572 | 597 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
573 | - } |
|
574 | - elseif (preg_match(':^AIS01:',$message)) { |
|
598 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
575 | 599 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
576 | - } |
|
577 | - elseif (preg_match(':^FTX01:',$message)) { |
|
600 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
578 | 601 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
579 | - } |
|
580 | - elseif (preg_match(':^FPL01:',$message)) { |
|
602 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
581 | 603 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
582 | - } |
|
583 | - elseif (preg_match(':^WAB01:',$message)) { |
|
604 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
584 | 605 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
585 | - } |
|
586 | - elseif (preg_match(':^MET01:',$message)) { |
|
606 | + } elseif (preg_match(':^MET01:',$message)) { |
|
587 | 607 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
588 | - } |
|
589 | - elseif (preg_match(':^WAB02:',$message)) { |
|
608 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
590 | 609 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
591 | 610 | } |
592 | 611 | } |
@@ -601,38 +620,28 @@ discard block |
||
601 | 620 | $vsta = array('Version' => $version); |
602 | 621 | if ($state == 'E') { |
603 | 622 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
604 | - } |
|
605 | - elseif ($state == 'L') { |
|
623 | + } elseif ($state == 'L') { |
|
606 | 624 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
607 | - } |
|
608 | - else { |
|
625 | + } else { |
|
609 | 626 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
610 | 627 | } |
611 | 628 | if ($type == 'V') { |
612 | 629 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
613 | - } |
|
614 | - elseif ($type == 'S') { |
|
630 | + } elseif ($type == 'S') { |
|
615 | 631 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
616 | - } |
|
617 | - elseif ($type == 'H') { |
|
632 | + } elseif ($type == 'H') { |
|
618 | 633 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
619 | - } |
|
620 | - elseif ($type == 'G') { |
|
634 | + } elseif ($type == 'G') { |
|
621 | 635 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
622 | - } |
|
623 | - elseif ($type == 'C') { |
|
636 | + } elseif ($type == 'C') { |
|
624 | 637 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
625 | - } |
|
626 | - elseif ($type == '2') { |
|
638 | + } elseif ($type == '2') { |
|
627 | 639 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
628 | - } |
|
629 | - elseif ($type == 'X') { |
|
640 | + } elseif ($type == 'X') { |
|
630 | 641 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
631 | - } |
|
632 | - elseif ($type == 'I') { |
|
642 | + } elseif ($type == 'I') { |
|
633 | 643 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
634 | - } |
|
635 | - else { |
|
644 | + } else { |
|
636 | 645 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
637 | 646 | } |
638 | 647 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -641,7 +650,9 @@ discard block |
||
641 | 650 | } |
642 | 651 | |
643 | 652 | $title = $this->getTitlefromLabel($label); |
644 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
653 | + if ($title != '') { |
|
654 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
655 | + } |
|
645 | 656 | |
646 | 657 | /* |
647 | 658 | // Business jets always use GS0001 |
@@ -682,14 +693,26 @@ discard block |
||
682 | 693 | $decode = $message['decode']; |
683 | 694 | $registration = $message['registration']; |
684 | 695 | |
685 | - if (isset($decode['latitude'])) $latitude = $latitude; |
|
686 | - else $latitude = ''; |
|
687 | - if (isset($decode['longitude'])) $longitude = $longitude; |
|
688 | - else $longitude = ''; |
|
689 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
690 | - else $airicao = ''; |
|
691 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
692 | - else $icao = $Translation->checkTranslation($ident); |
|
696 | + if (isset($decode['latitude'])) { |
|
697 | + $latitude = $latitude; |
|
698 | + } else { |
|
699 | + $latitude = ''; |
|
700 | + } |
|
701 | + if (isset($decode['longitude'])) { |
|
702 | + $longitude = $longitude; |
|
703 | + } else { |
|
704 | + $longitude = ''; |
|
705 | + } |
|
706 | + if (isset($decode['airicao'])) { |
|
707 | + $airicao = $decode['airicao']; |
|
708 | + } else { |
|
709 | + $airicao = ''; |
|
710 | + } |
|
711 | + if (isset($decode['icao'])) { |
|
712 | + $icao = $decode['icao']; |
|
713 | + } else { |
|
714 | + $icao = $Translation->checkTranslation($ident); |
|
715 | + } |
|
693 | 716 | |
694 | 717 | $image_array = $Image->getSpotterImage($registration); |
695 | 718 | if (!isset($image_array[0]['registration'])) { |
@@ -697,11 +720,18 @@ discard block |
||
697 | 720 | } |
698 | 721 | |
699 | 722 | // Business jets always use GS0001 |
700 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
701 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
723 | + if ($ident != 'GS0001') { |
|
724 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
725 | + } |
|
726 | + if ($globalDebug && isset($info) && $info != '') { |
|
727 | + echo $info; |
|
728 | + } |
|
702 | 729 | |
703 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
704 | - else $decode_json = ''; |
|
730 | + if (count($decode) > 0) { |
|
731 | + $decode_json = json_encode($decode); |
|
732 | + } else { |
|
733 | + $decode_json = ''; |
|
734 | + } |
|
705 | 735 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
706 | 736 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
707 | 737 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
@@ -709,8 +739,12 @@ discard block |
||
709 | 739 | } |
710 | 740 | |
711 | 741 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
712 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
713 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
742 | + if (!isset($globalACARSArchive)) { |
|
743 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
744 | + } |
|
745 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
746 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
747 | + } |
|
714 | 748 | |
715 | 749 | if ($globalDebug && count($decode) > 0) { |
716 | 750 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
@@ -735,7 +769,9 @@ discard block |
||
735 | 769 | $Connection = new Connection($this->db); |
736 | 770 | $this->db = $Connection->db; |
737 | 771 | |
738 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
772 | + if ($globalDebug) { |
|
773 | + echo "Test if not already in Live ACARS table..."; |
|
774 | + } |
|
739 | 775 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
740 | 776 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
741 | 777 | try { |
@@ -745,7 +781,9 @@ discard block |
||
745 | 781 | return "error : ".$e->getMessage(); |
746 | 782 | } |
747 | 783 | if ($stht->fetchColumn() == 0) { |
748 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
784 | + if ($globalDebug) { |
|
785 | + echo "Add Live ACARS data..."; |
|
786 | + } |
|
749 | 787 | $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)"; |
750 | 788 | $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")); |
751 | 789 | try { |
@@ -756,10 +794,14 @@ discard block |
||
756 | 794 | return "error : ".$e->getMessage(); |
757 | 795 | } |
758 | 796 | } else { |
759 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
797 | + if ($globalDebug) { |
|
798 | + echo "Data already in DB...\n"; |
|
799 | + } |
|
760 | 800 | return false; |
761 | 801 | } |
762 | - if ($globalDebug) echo "Done\n"; |
|
802 | + if ($globalDebug) { |
|
803 | + echo "Done\n"; |
|
804 | + } |
|
763 | 805 | return true; |
764 | 806 | } |
765 | 807 | } |
@@ -791,7 +833,9 @@ discard block |
||
791 | 833 | } |
792 | 834 | if ($stht->fetchColumn() == 0) { |
793 | 835 | */ |
794 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
836 | + if ($globalDebug) { |
|
837 | + echo "Add Live ACARS data..."; |
|
838 | + } |
|
795 | 839 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
796 | 840 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
797 | 841 | try { |
@@ -802,7 +846,9 @@ discard block |
||
802 | 846 | return "error : ".$e->getMessage(); |
803 | 847 | } |
804 | 848 | // } |
805 | - if ($globalDebug) echo "Done\n"; |
|
849 | + if ($globalDebug) { |
|
850 | + echo "Done\n"; |
|
851 | + } |
|
806 | 852 | } |
807 | 853 | } |
808 | 854 | |
@@ -825,8 +871,11 @@ discard block |
||
825 | 871 | return "error : ".$e->getMessage(); |
826 | 872 | } |
827 | 873 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
828 | - if (count($row) > 0) return $row[0]['title']; |
|
829 | - else return ''; |
|
874 | + if (count($row) > 0) { |
|
875 | + return $row[0]['title']; |
|
876 | + } else { |
|
877 | + return ''; |
|
878 | + } |
|
830 | 879 | } |
831 | 880 | |
832 | 881 | /** |
@@ -845,8 +894,11 @@ discard block |
||
845 | 894 | return "error : ".$e->getMessage(); |
846 | 895 | } |
847 | 896 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
848 | - if (count($row) > 0) return $row; |
|
849 | - else return ''; |
|
897 | + if (count($row) > 0) { |
|
898 | + return $row; |
|
899 | + } else { |
|
900 | + return ''; |
|
901 | + } |
|
850 | 902 | } |
851 | 903 | |
852 | 904 | /** |
@@ -866,8 +918,11 @@ discard block |
||
866 | 918 | return "error : ".$e->getMessage(); |
867 | 919 | } |
868 | 920 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
869 | - if (count($row) > 0) return $row[0]; |
|
870 | - else return array(); |
|
921 | + if (count($row) > 0) { |
|
922 | + return $row[0]; |
|
923 | + } else { |
|
924 | + return array(); |
|
925 | + } |
|
871 | 926 | } |
872 | 927 | |
873 | 928 | /** |
@@ -919,21 +974,37 @@ discard block |
||
919 | 974 | if ($row['registration'] != '') { |
920 | 975 | $row['registration'] = str_replace('.','',$row['registration']); |
921 | 976 | $image_array = $Image->getSpotterImage($row['registration']); |
922 | - 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'])); |
|
923 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
924 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
977 | + if (count($image_array) > 0) { |
|
978 | + $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'])); |
|
979 | + } else { |
|
980 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
981 | + } |
|
982 | + } else { |
|
983 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
984 | + } |
|
925 | 985 | $icao = ''; |
926 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
927 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
986 | + if ($row['registration'] == '') { |
|
987 | + $row['registration'] = 'NA'; |
|
988 | + } |
|
989 | + if ($row['ident'] == '') { |
|
990 | + $row['ident'] = 'NA'; |
|
991 | + } |
|
928 | 992 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
929 | 993 | if (isset($identicao[0])) { |
930 | 994 | if (substr($row['ident'],0,2) == 'AF') { |
931 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
932 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
933 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
995 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
996 | + $icao = $row['ident']; |
|
997 | + } else { |
|
998 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
999 | + } |
|
1000 | + } else { |
|
1001 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1002 | + } |
|
934 | 1003 | |
935 | 1004 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
936 | - } else $icao = $row['ident']; |
|
1005 | + } else { |
|
1006 | + $icao = $row['ident']; |
|
1007 | + } |
|
937 | 1008 | $icao = $Translation->checkTranslation($icao,false); |
938 | 1009 | |
939 | 1010 | $decode = json_decode($row['decode'],true); |
@@ -959,7 +1030,9 @@ discard block |
||
959 | 1030 | $found = true; |
960 | 1031 | } |
961 | 1032 | } |
962 | - if ($found) $row['decode'] = json_encode($decode); |
|
1033 | + if ($found) { |
|
1034 | + $row['decode'] = json_encode($decode); |
|
1035 | + } |
|
963 | 1036 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
964 | 1037 | $result[] = $data; |
965 | 1038 | $i++; |
@@ -967,8 +1040,9 @@ discard block |
||
967 | 1040 | if (isset($result)) { |
968 | 1041 | $result[0]['query_number_rows'] = $i; |
969 | 1042 | return $result; |
1043 | + } else { |
|
1044 | + return array(); |
|
970 | 1045 | } |
971 | - else return array(); |
|
972 | 1046 | } |
973 | 1047 | |
974 | 1048 | /** |
@@ -1028,20 +1102,36 @@ discard block |
||
1028 | 1102 | if ($row['registration'] != '') { |
1029 | 1103 | $row['registration'] = str_replace('.','',$row['registration']); |
1030 | 1104 | $image_array = $Image->getSpotterImage($row['registration']); |
1031 | - 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'])); |
|
1032 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1033 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1105 | + if (count($image_array) > 0) { |
|
1106 | + $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'])); |
|
1107 | + } else { |
|
1108 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1109 | + } |
|
1110 | + } else { |
|
1111 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1112 | + } |
|
1034 | 1113 | $icao = ''; |
1035 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1036 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1114 | + if ($row['registration'] == '') { |
|
1115 | + $row['registration'] = 'NA'; |
|
1116 | + } |
|
1117 | + if ($row['ident'] == '') { |
|
1118 | + $row['ident'] = 'NA'; |
|
1119 | + } |
|
1037 | 1120 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1038 | 1121 | if (isset($identicao[0])) { |
1039 | 1122 | if (substr($row['ident'],0,2) == 'AF') { |
1040 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1041 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1042 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1123 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1124 | + $icao = $row['ident']; |
|
1125 | + } else { |
|
1126 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1127 | + } |
|
1128 | + } else { |
|
1129 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1130 | + } |
|
1043 | 1131 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1044 | - } else $icao = $row['ident']; |
|
1132 | + } else { |
|
1133 | + $icao = $row['ident']; |
|
1134 | + } |
|
1045 | 1135 | $icao = $Translation->checkTranslation($icao); |
1046 | 1136 | |
1047 | 1137 | |
@@ -1049,12 +1139,16 @@ discard block |
||
1049 | 1139 | $found = false; |
1050 | 1140 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1051 | 1141 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1052 | - 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>'; |
|
1142 | + if (isset($airport_info[0]['icao'])) { |
|
1143 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1144 | + } |
|
1053 | 1145 | $found = true; |
1054 | 1146 | } |
1055 | 1147 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1056 | 1148 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1057 | - 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>'; |
|
1149 | + if (isset($airport_info[0]['icao'])) { |
|
1150 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1151 | + } |
|
1058 | 1152 | $found = true; |
1059 | 1153 | } |
1060 | 1154 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1064,7 +1158,9 @@ discard block |
||
1064 | 1158 | $found = true; |
1065 | 1159 | } |
1066 | 1160 | } |
1067 | - if ($found) $row['decode'] = json_encode($decode); |
|
1161 | + if ($found) { |
|
1162 | + $row['decode'] = json_encode($decode); |
|
1163 | + } |
|
1068 | 1164 | |
1069 | 1165 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1070 | 1166 | $result[] = $data; |
@@ -1073,7 +1169,9 @@ discard block |
||
1073 | 1169 | if (isset($result)) { |
1074 | 1170 | $result[0]['query_number_rows'] = $i; |
1075 | 1171 | return $result; |
1076 | - } else return array(); |
|
1172 | + } else { |
|
1173 | + return array(); |
|
1174 | + } |
|
1077 | 1175 | } |
1078 | 1176 | |
1079 | 1177 | /** |
@@ -1089,19 +1187,29 @@ discard block |
||
1089 | 1187 | $ident = trim($ident); |
1090 | 1188 | $Translation = new Translation($this->db); |
1091 | 1189 | $Spotter = new Spotter($this->db); |
1092 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1190 | + if ($globalDebug) { |
|
1191 | + echo "Test if we add ModeS data..."; |
|
1192 | + } |
|
1093 | 1193 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1094 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1095 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1194 | + if ($icao == '') { |
|
1195 | + $icao = $Translation->checkTranslation($ident); |
|
1196 | + } |
|
1197 | + if ($globalDebug) { |
|
1198 | + echo '- Ident : '.$icao.' - '; |
|
1199 | + } |
|
1096 | 1200 | if ($ident == '' || $registration == '') { |
1097 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1201 | + if ($globalDebug) { |
|
1202 | + echo "Ident or registration null, exit\n"; |
|
1203 | + } |
|
1098 | 1204 | return ''; |
1099 | 1205 | } |
1100 | 1206 | |
1101 | 1207 | $registration = str_replace('.','',$registration); |
1102 | 1208 | $ident = $Translation->ident2icao($ident); |
1103 | 1209 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1104 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1210 | + if ($globalDebug) { |
|
1211 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1212 | + } |
|
1105 | 1213 | $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"; |
1106 | 1214 | $querysi_values = array(':registration' => $registration); |
1107 | 1215 | try { |
@@ -1109,7 +1217,9 @@ discard block |
||
1109 | 1217 | $sthsi = $this->db->prepare($querysi); |
1110 | 1218 | $sthsi->execute($querysi_values); |
1111 | 1219 | } catch(PDOException $e) { |
1112 | - if ($globalDebug) echo $e->getMessage(); |
|
1220 | + if ($globalDebug) { |
|
1221 | + echo $e->getMessage(); |
|
1222 | + } |
|
1113 | 1223 | return "error : ".$e->getMessage(); |
1114 | 1224 | } |
1115 | 1225 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1117,9 +1227,14 @@ discard block |
||
1117 | 1227 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1118 | 1228 | $Translation = new Translation($this->db); |
1119 | 1229 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1120 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1121 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1122 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1230 | + if ($globalDebug) { |
|
1231 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1232 | + } |
|
1233 | + if ($ident != $trans_ident) { |
|
1234 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1235 | + } elseif ($trans_ident == $ident) { |
|
1236 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1237 | + } |
|
1123 | 1238 | } else { |
1124 | 1239 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1125 | 1240 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1128,17 +1243,24 @@ discard block |
||
1128 | 1243 | $sth = $this->db->prepare($query); |
1129 | 1244 | $sth->execute($query_values); |
1130 | 1245 | } catch(PDOException $e) { |
1131 | - if ($globalDebug) echo $e->getMessage(); |
|
1246 | + if ($globalDebug) { |
|
1247 | + echo $e->getMessage(); |
|
1248 | + } |
|
1132 | 1249 | return "error : ".$e->getMessage(); |
1133 | 1250 | } |
1134 | 1251 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1135 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1136 | - else $hex = ''; |
|
1252 | + if (isset($result['modes'])) { |
|
1253 | + $hex = $result['modes']; |
|
1254 | + } else { |
|
1255 | + $hex = ''; |
|
1256 | + } |
|
1137 | 1257 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1138 | 1258 | $this->SI->add($SI_data); |
1139 | 1259 | } |
1140 | 1260 | } |
1141 | - if ($globalDebug) echo 'Done'."\n"; |
|
1261 | + if ($globalDebug) { |
|
1262 | + echo 'Done'."\n"; |
|
1263 | + } |
|
1142 | 1264 | |
1143 | 1265 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1144 | 1266 | $query_values = array(':ident' => $icao); |
@@ -1147,14 +1269,19 @@ discard block |
||
1147 | 1269 | $sth = $this->db->prepare($query); |
1148 | 1270 | $sth->execute($query_values); |
1149 | 1271 | } catch(PDOException $e) { |
1150 | - if ($globalDebug) echo $e->getMessage(); |
|
1272 | + if ($globalDebug) { |
|
1273 | + echo $e->getMessage(); |
|
1274 | + } |
|
1151 | 1275 | return "error : ".$e->getMessage(); |
1152 | 1276 | } |
1153 | 1277 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1154 | 1278 | //print_r($result); |
1155 | 1279 | if (isset($result['flightaware_id'])) { |
1156 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1157 | - else $ModeS = ''; |
|
1280 | + if (isset($result['ModeS'])) { |
|
1281 | + $ModeS = $result['ModeS']; |
|
1282 | + } else { |
|
1283 | + $ModeS = ''; |
|
1284 | + } |
|
1158 | 1285 | if ($ModeS == '') { |
1159 | 1286 | $id = explode('-',$result['flightaware_id']); |
1160 | 1287 | $ModeS = $id[0]; |
@@ -1168,13 +1295,17 @@ discard block |
||
1168 | 1295 | $sthc = $this->db->prepare($queryc); |
1169 | 1296 | $sthc->execute($queryc_values); |
1170 | 1297 | } catch(PDOException $e) { |
1171 | - if ($globalDebug) echo $e->getMessage(); |
|
1298 | + if ($globalDebug) { |
|
1299 | + echo $e->getMessage(); |
|
1300 | + } |
|
1172 | 1301 | return "error : ".$e->getMessage(); |
1173 | 1302 | } |
1174 | 1303 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1175 | 1304 | |
1176 | 1305 | if (count($row) == 0) { |
1177 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1306 | + if ($globalDebug) { |
|
1307 | + echo " Add to ModeS table - "; |
|
1308 | + } |
|
1178 | 1309 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1179 | 1310 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1180 | 1311 | try { |
@@ -1182,11 +1313,15 @@ discard block |
||
1182 | 1313 | $sthi = $this->db->prepare($queryi); |
1183 | 1314 | $sthi->execute($queryi_values); |
1184 | 1315 | } catch(PDOException $e) { |
1185 | - if ($globalDebug) echo $e->getMessage(); |
|
1316 | + if ($globalDebug) { |
|
1317 | + echo $e->getMessage(); |
|
1318 | + } |
|
1186 | 1319 | return "error : ".$e->getMessage(); |
1187 | 1320 | } |
1188 | 1321 | } else { |
1189 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1322 | + if ($globalDebug) { |
|
1323 | + echo " Update ModeS table - "; |
|
1324 | + } |
|
1190 | 1325 | if ($ICAOTypeCode != '') { |
1191 | 1326 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1192 | 1327 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1199,7 +1334,9 @@ discard block |
||
1199 | 1334 | $sthi = $this->db->prepare($queryi); |
1200 | 1335 | $sthi->execute($queryi_values); |
1201 | 1336 | } catch(PDOException $e) { |
1202 | - if ($globalDebug) echo $e->getMessage(); |
|
1337 | + if ($globalDebug) { |
|
1338 | + echo $e->getMessage(); |
|
1339 | + } |
|
1203 | 1340 | return "error : ".$e->getMessage(); |
1204 | 1341 | } |
1205 | 1342 | } |
@@ -1221,7 +1358,9 @@ discard block |
||
1221 | 1358 | return "error : ".$e->getMessage(); |
1222 | 1359 | } |
1223 | 1360 | */ |
1224 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1361 | + if ($globalDebug) { |
|
1362 | + echo " Update Spotter_output table - "; |
|
1363 | + } |
|
1225 | 1364 | if ($ICAOTypeCode != '') { |
1226 | 1365 | if ($globalDBdriver == 'mysql') { |
1227 | 1366 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1232,8 +1371,7 @@ discard block |
||
1232 | 1371 | } else { |
1233 | 1372 | if ($globalDBdriver == 'mysql') { |
1234 | 1373 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1235 | - } |
|
1236 | - elseif ($globalDBdriver == 'pgsql') { |
|
1374 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1237 | 1375 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1238 | 1376 | } |
1239 | 1377 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1243,15 +1381,21 @@ discard block |
||
1243 | 1381 | $sthi = $this->db->prepare($queryi); |
1244 | 1382 | $sthi->execute($queryi_values); |
1245 | 1383 | } catch(PDOException $e) { |
1246 | - if ($globalDebug) echo $e->getMessage(); |
|
1384 | + if ($globalDebug) { |
|
1385 | + echo $e->getMessage(); |
|
1386 | + } |
|
1247 | 1387 | return "error : ".$e->getMessage(); |
1248 | 1388 | } |
1249 | 1389 | |
1250 | 1390 | } |
1251 | 1391 | } else { |
1252 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1392 | + if ($globalDebug) { |
|
1393 | + echo " Can't find ModeS in spotter_output - "; |
|
1394 | + } |
|
1395 | + } |
|
1396 | + if ($globalDebug) { |
|
1397 | + echo "Done\n"; |
|
1253 | 1398 | } |
1254 | - if ($globalDebug) echo "Done\n"; |
|
1255 | 1399 | } |
1256 | 1400 | } |
1257 | 1401 | ?> |
@@ -1,5 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | class aprs { |
3 | + |
|
4 | + /** |
|
5 | + * @param integer $n |
|
6 | + * @param integer $s |
|
7 | + */ |
|
3 | 8 | private function urshift($n, $s) { |
4 | 9 | return ($n >= 0) ? ($n >> $s) : |
5 | 10 | (($n & 0x7fffffff) >> $s) | |
@@ -26,23 +26,31 @@ discard block |
||
26 | 26 | $body_len = strlen($body); |
27 | 27 | $header = substr($input,0,$splitpos); |
28 | 28 | $header_len = strlen($header); |
29 | - if ($debug) echo 'header : '.$header."\n"; |
|
29 | + if ($debug) { |
|
30 | + echo 'header : '.$header."\n"; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | /* Parse source, target and path. */ |
32 | 34 | //FLRDF0A52>APRS,qAS,LSTB |
33 | 35 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
34 | 36 | $ident = $matches[1]; |
35 | 37 | $all_elements = $matches[2]; |
36 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
38 | + if ($debug) { |
|
39 | + echo 'ident : '.$ident."\n"; |
|
40 | + } |
|
37 | 41 | $result['ident'] = $ident; |
38 | - } else return false; |
|
42 | + } else { |
|
43 | + return false; |
|
44 | + } |
|
39 | 45 | $elements = explode(',',$all_elements); |
40 | 46 | $source = end($elements); |
41 | 47 | $result['source'] = $source; |
42 | 48 | foreach ($elements as $element) { |
43 | 49 | if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
44 | 50 | //echo "ok"; |
45 | - if ($element == 'TCPIP*') return false; |
|
51 | + if ($element == 'TCPIP*') { |
|
52 | + return false; |
|
53 | + } |
|
46 | 54 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
47 | 55 | //echo "ok"; |
48 | 56 | } else { |
@@ -82,7 +90,9 @@ discard block |
||
82 | 90 | $symbol_table = $matches[4]; |
83 | 91 | $lat = intval($lat_deg); |
84 | 92 | $lon = intval($lon_deg); |
85 | - if ($lat > 89 || $lon > 179) return false; |
|
93 | + if ($lat > 89 || $lon > 179) { |
|
94 | + return false; |
|
95 | + } |
|
86 | 96 | |
87 | 97 | /* |
88 | 98 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -92,8 +102,12 @@ discard block |
||
92 | 102 | */ |
93 | 103 | $latitude = $lat + floatval($lat_min)/60; |
94 | 104 | $longitude = $lon + floatval($lon_min)/60; |
95 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
96 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
105 | + if ($sind == 'S') { |
|
106 | + $latitude = 0-$latitude; |
|
107 | + } |
|
108 | + if ($wind == 'W') { |
|
109 | + $longitude = 0-$longitude; |
|
110 | + } |
|
97 | 111 | $result['latitude'] = $latitude; |
98 | 112 | $result['longitude'] = $longitude; |
99 | 113 | } |
@@ -108,7 +122,9 @@ discard block |
||
108 | 122 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
109 | 123 | $course = substr($body_parse,0,3); |
110 | 124 | $tmp_s = intval($course); |
111 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course); |
|
125 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
126 | + $result['course'] = intval($course); |
|
127 | + } |
|
112 | 128 | $speed = substr($body_parse,4,3); |
113 | 129 | $result['speed'] = round($speed*1.852); |
114 | 130 | $body_parse = substr($body_parse,7); |
@@ -138,10 +154,16 @@ discard block |
||
138 | 154 | $lon_off = (($dao[2])-48.0)*0.001/60.0; |
139 | 155 | |
140 | 156 | } |
141 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
142 | - else $result['latitude'] += $lat_off; |
|
143 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
144 | - else $result['longitude'] += $lon_off; |
|
157 | + if ($result['latitude'] < 0) { |
|
158 | + $result['latitude'] -= $lat_off; |
|
159 | + } else { |
|
160 | + $result['latitude'] += $lat_off; |
|
161 | + } |
|
162 | + if ($result['longitude'] < 0) { |
|
163 | + $result['longitude'] -= $lon_off; |
|
164 | + } else { |
|
165 | + $result['longitude'] += $lon_off; |
|
166 | + } |
|
145 | 167 | $body_parse = substr($body_parse,6); |
146 | 168 | } |
147 | 169 | |
@@ -153,27 +175,48 @@ discard block |
||
153 | 175 | $address = substr($id,2); |
154 | 176 | //print_r($matches); |
155 | 177 | $addressType = (intval(substr($id,0,2),16))&3; |
156 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
157 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
158 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
159 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
178 | + if ($addressType == 0) { |
|
179 | + $result['addresstype'] = "RANDOM"; |
|
180 | + } elseif ($addressType == 1) { |
|
181 | + $result['addresstype'] = "ICAO"; |
|
182 | + } elseif ($addressType == 2) { |
|
183 | + $result['addresstype'] = "FLARM"; |
|
184 | + } elseif ($addressType == 3) { |
|
185 | + $result['addresstype'] = "OGN"; |
|
186 | + } |
|
160 | 187 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
161 | 188 | $result['aircrafttype_code'] = $aircraftType; |
162 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
163 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
164 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
165 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
166 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
167 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
168 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
169 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
170 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
171 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
172 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
173 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
174 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
175 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
176 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
189 | + if ($aircraftType == 0) { |
|
190 | + $result['aircrafttype'] = "UNKNOWN"; |
|
191 | + } elseif ($aircraftType == 1) { |
|
192 | + $result['aircrafttype'] = "GLIDER"; |
|
193 | + } elseif ($aircraftType == 2) { |
|
194 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
195 | + } elseif ($aircraftType == 3) { |
|
196 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
197 | + } elseif ($aircraftType == 4) { |
|
198 | + $result['aircrafttype'] = "PARACHUTE"; |
|
199 | + } elseif ($aircraftType == 5) { |
|
200 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
201 | + } elseif ($aircraftType == 6) { |
|
202 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
203 | + } elseif ($aircraftType == 7) { |
|
204 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
205 | + } elseif ($aircraftType == 8) { |
|
206 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
207 | + } elseif ($aircraftType == 9) { |
|
208 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
209 | + } elseif ($aircraftType == 10) { |
|
210 | + $result['aircrafttype'] = "UFO"; |
|
211 | + } elseif ($aircraftType == 11) { |
|
212 | + $result['aircrafttype'] = "BALLOON"; |
|
213 | + } elseif ($aircraftType == 12) { |
|
214 | + $result['aircrafttype'] = "AIRSHIP"; |
|
215 | + } elseif ($aircraftType == 13) { |
|
216 | + $result['aircrafttype'] = "UAV"; |
|
217 | + } elseif ($aircraftType == 15) { |
|
218 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
219 | + } |
|
177 | 220 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
178 | 221 | $result['stealth'] = $stealth; |
179 | 222 | $result['address'] = $address; |
@@ -215,8 +258,12 @@ discard block |
||
215 | 258 | } |
216 | 259 | } |
217 | 260 | } |
218 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
219 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
261 | + if (isset($result['latitude'])) { |
|
262 | + $result['latitude'] = round($result['latitude'],4); |
|
263 | + } |
|
264 | + if (isset($result['longitude'])) { |
|
265 | + $result['longitude'] = round($result['longitude'],4); |
|
266 | + } |
|
220 | 267 | //print_r($result); |
221 | 268 | return $result; |
222 | 269 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * Check is distance realistic |
161 | 161 | * @param int $timeDifference the time between the reception of both messages |
162 | 162 | * @param float $distance distance covered |
163 | - * @return whether distance is realistic |
|
163 | + * @return boolean distance is realistic |
|
164 | 164 | */ |
165 | 165 | public function withinThreshold ($timeDifference, $distance) { |
166 | 166 | $x = abs($timeDifference); |
@@ -183,6 +183,9 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | + /** |
|
187 | + * @param string $latlong |
|
188 | + */ |
|
186 | 189 | public function convertDec($dms,$latlong) { |
187 | 190 | if ($latlong == 'latitude') { |
188 | 191 | $deg = substr($dms, 0, 2); |
@@ -274,7 +277,7 @@ discard block |
||
274 | 277 | /** |
275 | 278 | * Returns list of available locales |
276 | 279 | * |
277 | - * @return array |
|
280 | + * @return string[] |
|
278 | 281 | */ |
279 | 282 | public function listLocaleDir() |
280 | 283 | { |
@@ -27,8 +27,11 @@ discard block |
||
27 | 27 | } else { |
28 | 28 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
29 | 29 | } |
30 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
31 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
30 | + if ($timeout == '') { |
|
31 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
32 | + } else { |
|
33 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
34 | + } |
|
32 | 35 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
33 | 36 | if ($type == 'post') { |
34 | 37 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -73,8 +76,9 @@ discard block |
||
73 | 76 | |
74 | 77 | private function curlResponseHeaderCallback($ch, $headerLine) { |
75 | 78 | global $cookies; |
76 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
77 | - $cookies[] = $cookie; |
|
79 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
80 | + $cookies[] = $cookie; |
|
81 | + } |
|
78 | 82 | return strlen($headerLine); // Needed by curl |
79 | 83 | } |
80 | 84 | |
@@ -84,8 +88,12 @@ discard block |
||
84 | 88 | * @return Array array of the tables in HTML page |
85 | 89 | */ |
86 | 90 | public function table2array($data) { |
87 | - if (!is_string($data)) return array(); |
|
88 | - if ($data == '') return array(); |
|
91 | + if (!is_string($data)) { |
|
92 | + return array(); |
|
93 | + } |
|
94 | + if ($data == '') { |
|
95 | + return array(); |
|
96 | + } |
|
89 | 97 | $html = str_get_html($data); |
90 | 98 | $tabledata=array(); |
91 | 99 | foreach($html->find('tr') as $element) |
@@ -141,7 +149,9 @@ discard block |
||
141 | 149 | * @return Float Distance in $unit |
142 | 150 | */ |
143 | 151 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
144 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
152 | + if ($lat == $latc && $lon == $lonc) { |
|
153 | + return 0; |
|
154 | + } |
|
145 | 155 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
146 | 156 | if ($unit == "km") { |
147 | 157 | return round($dist * 1.609344); |
@@ -165,10 +175,16 @@ discard block |
||
165 | 175 | public function withinThreshold ($timeDifference, $distance) { |
166 | 176 | $x = abs($timeDifference); |
167 | 177 | $d = abs($distance); |
168 | - if ($x == 0 || $d == 0) return true; |
|
178 | + if ($x == 0 || $d == 0) { |
|
179 | + return true; |
|
180 | + } |
|
169 | 181 | // may be due to Internet jitter; distance is realistic |
170 | - if ($x < 0.7 && $d < 2000) return true; |
|
171 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
182 | + if ($x < 0.7 && $d < 2000) { |
|
183 | + return true; |
|
184 | + } else { |
|
185 | + return $d/$x < 1500*0.27778; |
|
186 | + } |
|
187 | + // 1500 km/h max |
|
172 | 188 | } |
173 | 189 | |
174 | 190 | |
@@ -228,7 +244,9 @@ discard block |
||
228 | 244 | public function hex2str($hex) { |
229 | 245 | $str = ''; |
230 | 246 | $hexln = strlen($hex); |
231 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
247 | + for($i=0;$i<$hexln;$i+=2) { |
|
248 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
249 | + } |
|
232 | 250 | return $str; |
233 | 251 | } |
234 | 252 | |
@@ -256,8 +274,11 @@ discard block |
||
256 | 274 | $b = $lat2 - $lat1; |
257 | 275 | $c = -($a*$lat1+$b*$lon1); |
258 | 276 | $d = $a*$lat3+$b*$lon3+$c; |
259 | - if ($d > -$approx && $d < $approx) return true; |
|
260 | - else return false; |
|
277 | + if ($d > -$approx && $d < $approx) { |
|
278 | + return true; |
|
279 | + } else { |
|
280 | + return false; |
|
281 | + } |
|
261 | 282 | } |
262 | 283 | |
263 | 284 | public function array_merge_noappend() { |
@@ -283,7 +304,9 @@ discard block |
||
283 | 304 | return $result; |
284 | 305 | } |
285 | 306 | $handle = @opendir('./locale'); |
286 | - if ($handle === false) return $result; |
|
307 | + if ($handle === false) { |
|
308 | + return $result; |
|
309 | + } |
|
287 | 310 | while (false !== ($file = readdir($handle))) { |
288 | 311 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
289 | 312 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -6,6 +6,9 @@ discard block |
||
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 23; |
8 | 8 | |
9 | + /** |
|
10 | + * @param string $dbname |
|
11 | + */ |
|
9 | 12 | public function __construct($dbc = null,$dbname = null) { |
10 | 13 | global $globalDBdriver; |
11 | 14 | if ($dbc === null) { |
@@ -102,6 +105,9 @@ discard block |
||
102 | 105 | return true; |
103 | 106 | } |
104 | 107 | |
108 | + /** |
|
109 | + * @param string $table |
|
110 | + */ |
|
105 | 111 | public function tableExists($table) |
106 | 112 | { |
107 | 113 | global $globalDBdriver, $globalDBname; |
@@ -53,8 +53,11 @@ discard block |
||
53 | 53 | $globalDBSname = $globalDBname; |
54 | 54 | $globalDBSuser = $globalDBuser; |
55 | 55 | $globalDBSpass = $globalDBpass; |
56 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
57 | - else $globalDBSport = $globalDBport; |
|
56 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
57 | + $globalDBSport = 3306; |
|
58 | + } else { |
|
59 | + $globalDBSport = $globalDBport; |
|
60 | + } |
|
58 | 61 | } else { |
59 | 62 | $DBname = 'default'; |
60 | 63 | $globalDBSdriver = $globalDBdriver; |
@@ -62,8 +65,11 @@ discard block |
||
62 | 65 | $globalDBSname = $globalDBname; |
63 | 66 | $globalDBSuser = $user; |
64 | 67 | $globalDBSpass = $pass; |
65 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
66 | - else $globalDBSport = $globalDBport; |
|
68 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
69 | + $globalDBSport = 3306; |
|
70 | + } else { |
|
71 | + $globalDBSport = $globalDBport; |
|
72 | + } |
|
67 | 73 | } |
68 | 74 | } else { |
69 | 75 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -71,11 +77,16 @@ discard block |
||
71 | 77 | $globalDBSname = $globalDB[$DBname]['name']; |
72 | 78 | $globalDBSuser = $globalDB[$DBname]['user']; |
73 | 79 | $globalDBSpass = $globalDB[$DBname]['pass']; |
74 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
75 | - else $globalDBSport = 3306; |
|
80 | + if (isset($globalDB[$DBname]['port'])) { |
|
81 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
82 | + } else { |
|
83 | + $globalDBSport = 3306; |
|
84 | + } |
|
76 | 85 | } |
77 | 86 | // Set number of try to connect to DB |
78 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
87 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
88 | + $globalDBretry = 5; |
|
89 | + } |
|
79 | 90 | $i = 0; |
80 | 91 | while (true) { |
81 | 92 | try { |
@@ -84,10 +95,16 @@ discard block |
||
84 | 95 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
85 | 96 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
86 | 97 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
87 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
88 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
89 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
90 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
98 | + if (!isset($globalDBTimeOut)) { |
|
99 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
100 | + } else { |
|
101 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
102 | + } |
|
103 | + if (!isset($globalDBPersistent)) { |
|
104 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
105 | + } else { |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
107 | + } |
|
91 | 108 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
92 | 109 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
93 | 110 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -98,22 +115,34 @@ discard block |
||
98 | 115 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
99 | 116 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
100 | 117 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
101 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
102 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
103 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
104 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
118 | + if (!isset($globalDBTimeOut)) { |
|
119 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
120 | + } else { |
|
121 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
122 | + } |
|
123 | + if (!isset($globalDBPersistent)) { |
|
124 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
125 | + } else { |
|
126 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
127 | + } |
|
105 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
106 | 129 | } |
107 | 130 | break; |
108 | 131 | } catch(PDOException $e) { |
109 | 132 | $i++; |
110 | - if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
|
133 | + if (isset($globalDebug) && $globalDebug) { |
|
134 | + echo $e->getMessage()."\n"; |
|
135 | + } |
|
111 | 136 | //exit; |
112 | - if ($i > $globalDBretry) return false; |
|
137 | + if ($i > $globalDBretry) { |
|
138 | + return false; |
|
139 | + } |
|
113 | 140 | //return false; |
114 | 141 | } |
115 | 142 | } |
116 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
143 | + if ($DBname === 'default') { |
|
144 | + $this->db = $this->dbs['default']; |
|
145 | + } |
|
117 | 146 | return true; |
118 | 147 | } |
119 | 148 | |
@@ -125,7 +154,9 @@ discard block |
||
125 | 154 | } elseif ($globalDBdriver == 'pgsql') { |
126 | 155 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
127 | 156 | } |
128 | - if ($this->db == NULL) return false; |
|
157 | + if ($this->db == NULL) { |
|
158 | + return false; |
|
159 | + } |
|
129 | 160 | try { |
130 | 161 | //$Connection = new Connection(); |
131 | 162 | $results = $this->db->query($query); |
@@ -134,21 +165,28 @@ discard block |
||
134 | 165 | } |
135 | 166 | if($results->rowCount()>0) { |
136 | 167 | return true; |
168 | + } else { |
|
169 | + return false; |
|
137 | 170 | } |
138 | - else return false; |
|
139 | 171 | } |
140 | 172 | |
141 | 173 | public function connectionExists() |
142 | 174 | { |
143 | 175 | global $globalDBdriver, $globalDBCheckConnection; |
144 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
176 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
177 | + return true; |
|
178 | + } |
|
145 | 179 | $query = "SELECT 1 + 1"; |
146 | - if ($this->db == NULL) return false; |
|
180 | + if ($this->db == NULL) { |
|
181 | + return false; |
|
182 | + } |
|
147 | 183 | try { |
148 | 184 | $sum = @$this->db->query($query); |
149 | 185 | if ($sum instanceof \PDOStatement) { |
150 | 186 | $sum = $sum->fetchColumn(0); |
151 | - } else $sum = 0; |
|
187 | + } else { |
|
188 | + $sum = 0; |
|
189 | + } |
|
152 | 190 | if (intval($sum) !== 2) { |
153 | 191 | return false; |
154 | 192 | } |
@@ -182,8 +220,9 @@ discard block |
||
182 | 220 | } |
183 | 221 | if($results->rowCount()>0) { |
184 | 222 | return true; |
223 | + } else { |
|
224 | + return false; |
|
185 | 225 | } |
186 | - else return false; |
|
187 | 226 | } |
188 | 227 | |
189 | 228 | /* |
@@ -222,7 +261,9 @@ discard block |
||
222 | 261 | $colcnt = $results->columnCount(); |
223 | 262 | for ($i = 0; $i < $colcnt; $i++) { |
224 | 263 | $col = $results->getColumnMeta($i); |
225 | - if ($name == $col['name']) return true; |
|
264 | + if ($name == $col['name']) { |
|
265 | + return true; |
|
266 | + } |
|
226 | 267 | } |
227 | 268 | return false; |
228 | 269 | } |
@@ -249,7 +290,9 @@ discard block |
||
249 | 290 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
250 | 291 | return $result['value']; |
251 | 292 | } |
252 | - } else return $version; |
|
293 | + } else { |
|
294 | + return $version; |
|
295 | + } |
|
253 | 296 | } |
254 | 297 | |
255 | 298 | /* |
@@ -257,8 +300,11 @@ discard block |
||
257 | 300 | * @return Boolean if latest version or not |
258 | 301 | */ |
259 | 302 | public function latest() { |
260 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
261 | - else return false; |
|
303 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
304 | + return true; |
|
305 | + } else { |
|
306 | + return false; |
|
307 | + } |
|
262 | 308 | } |
263 | 309 | |
264 | 310 | } |
@@ -327,6 +327,9 @@ |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | |
330 | + /** |
|
331 | + * @param string $aircraft_icao |
|
332 | + */ |
|
330 | 333 | public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
331 | 334 | $Common = new Common(); |
332 | 335 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
25 | + if ($registration == '' && $aircraft_icao != '') { |
|
26 | + $registration = $aircraft_icao.$airline_icao; |
|
27 | + } |
|
26 | 28 | |
27 | 29 | $registration = trim($registration); |
28 | 30 | |
@@ -64,8 +66,11 @@ discard block |
||
64 | 66 | public function getExifCopyright($url) { |
65 | 67 | $exif = exif_read_data($url); |
66 | 68 | $copyright = ''; |
67 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
68 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
69 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
70 | + $copyright = $exif['COMPUTED']['copyright']; |
|
71 | + } elseif (isset($exif['copyright'])) { |
|
72 | + $copyright = $exif['copyright']; |
|
73 | + } |
|
69 | 74 | if ($copyright != '') { |
70 | 75 | $copyright = str_replace('Copyright ','',$copyright); |
71 | 76 | $copyright = str_replace('© ','',$copyright); |
@@ -83,12 +88,16 @@ discard block |
||
83 | 88 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
84 | 89 | { |
85 | 90 | global $globalAircraftImageFetch; |
86 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
91 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
92 | + return ''; |
|
93 | + } |
|
87 | 94 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
88 | 95 | $registration = trim($registration); |
89 | 96 | //getting the aircraft image |
90 | 97 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
91 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
98 | + if ($registration == '' && $aircraft_icao != '') { |
|
99 | + $registration = $aircraft_icao.$airline_icao; |
|
100 | + } |
|
92 | 101 | if ($image_url['original'] != '') { |
93 | 102 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
94 | 103 | try { |
@@ -115,39 +124,78 @@ discard block |
||
115 | 124 | { |
116 | 125 | global $globalAircraftImageSources, $globalIVAO; |
117 | 126 | $Spotter = new Spotter($this->db); |
118 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
127 | + if (!isset($globalIVAO)) { |
|
128 | + $globalIVAO = FALSE; |
|
129 | + } |
|
119 | 130 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
120 | 131 | |
121 | 132 | if ($aircraft_registration != '') { |
122 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
133 | + if (strpos($aircraft_registration,'/') !== false) { |
|
134 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
135 | + } |
|
123 | 136 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
124 | 137 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
125 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
126 | - else $aircraft_name = ''; |
|
127 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
128 | - else $aircraft_icao = ''; |
|
129 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
130 | - else $airline_icao = ''; |
|
138 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
139 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
140 | + } else { |
|
141 | + $aircraft_name = ''; |
|
142 | + } |
|
143 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
144 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
145 | + } else { |
|
146 | + $aircraft_icao = ''; |
|
147 | + } |
|
148 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
149 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
150 | + } else { |
|
151 | + $airline_icao = ''; |
|
152 | + } |
|
131 | 153 | } elseif ($aircraft_icao != '') { |
132 | 154 | $aircraft_registration = $aircraft_icao; |
133 | 155 | $aircraft_name = ''; |
134 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
156 | + } else { |
|
157 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
158 | + } |
|
135 | 159 | |
136 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
160 | + if (!isset($globalAircraftImageSources)) { |
|
161 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
162 | + } |
|
137 | 163 | |
138 | 164 | foreach ($globalAircraftImageSources as $source) { |
139 | 165 | $source = strtolower($source); |
140 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
141 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
142 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
143 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
144 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
145 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
146 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
147 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
148 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
149 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
150 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
166 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
167 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
168 | + } |
|
169 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
170 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
171 | + } |
|
172 | + if ($source == 'flickr') { |
|
173 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
174 | + } |
|
175 | + if ($source == 'bing') { |
|
176 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
177 | + } |
|
178 | + if ($source == 'deviantart') { |
|
179 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
180 | + } |
|
181 | + if ($source == 'wikimedia') { |
|
182 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
183 | + } |
|
184 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
185 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
186 | + } |
|
187 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
188 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
189 | + } |
|
190 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
191 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
192 | + } |
|
193 | + if ($source == 'customsources') { |
|
194 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
195 | + } |
|
196 | + if (isset($images_array) && $images_array['original'] != '') { |
|
197 | + return $images_array; |
|
198 | + } |
|
151 | 199 | } |
152 | 200 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
153 | 201 | } |
@@ -306,8 +354,11 @@ discard block |
||
306 | 354 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
307 | 355 | $Common = new Common(); |
308 | 356 | |
309 | - if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
310 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
357 | + if ($aircraft_name != '') { |
|
358 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
359 | + } else { |
|
360 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
361 | + } |
|
311 | 362 | |
312 | 363 | $data = $Common->getData($url); |
313 | 364 | |
@@ -355,9 +406,14 @@ discard block |
||
355 | 406 | public function fromBing($aircraft_registration,$aircraft_name='') { |
356 | 407 | global $globalImageBingKey; |
357 | 408 | $Common = new Common(); |
358 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
359 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
360 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
409 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
410 | + return false; |
|
411 | + } |
|
412 | + if ($aircraft_name != '') { |
|
413 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
414 | + } else { |
|
415 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
416 | + } |
|
361 | 417 | |
362 | 418 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
363 | 419 | |
@@ -414,14 +470,19 @@ discard block |
||
414 | 470 | */ |
415 | 471 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
416 | 472 | $Common = new Common(); |
417 | - if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
418 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
473 | + if ($aircraft_name != '') { |
|
474 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
475 | + } else { |
|
476 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
477 | + } |
|
419 | 478 | |
420 | 479 | $data = $Common->getData($url); |
421 | 480 | $result = json_decode($data); |
422 | 481 | if (isset($result->query->search[0]->title)) { |
423 | 482 | $fileo = $result->query->search[0]->title; |
424 | - if (substr($fileo,-3) == 'pdf') return false; |
|
483 | + if (substr($fileo,-3) == 'pdf') { |
|
484 | + return false; |
|
485 | + } |
|
425 | 486 | $file = urlencode($fileo); |
426 | 487 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
427 | 488 | |
@@ -476,7 +537,9 @@ discard block |
||
476 | 537 | global $globalAircraftCustomSources; |
477 | 538 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
478 | 539 | if (!empty($globalAircraftImageCustomSources)) { |
479 | - if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
540 | + if (!isset($globalAircraftImageCustomSources[0])) { |
|
541 | + $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
542 | + } |
|
480 | 543 | foreach ($globalAircraftImageCustomSources as $source) { |
481 | 544 | $Common = new Common(); |
482 | 545 | $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
@@ -484,17 +547,25 @@ discard block |
||
484 | 547 | if ($Common->urlexist($url)) { |
485 | 548 | $image_url['thumbnail'] = $url_thumbnail; |
486 | 549 | $image_url['original'] = $url; |
487 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
488 | - else $exifCopyright = ''; |
|
489 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
490 | - else $image_url['copyright'] = $source['copyright']; |
|
550 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
551 | + $exifCopyright = $this->getExifCopyright($url); |
|
552 | + } else { |
|
553 | + $exifCopyright = ''; |
|
554 | + } |
|
555 | + if ($exifCopyright != '') { |
|
556 | + $image_url['copyright'] = $exifCopyright; |
|
557 | + } else { |
|
558 | + $image_url['copyright'] = $source['copyright']; |
|
559 | + } |
|
491 | 560 | $image_url['source_website'] = $source['source_website']; |
492 | 561 | $image_url['source'] = $source['source']; |
493 | 562 | return $image_url; |
494 | 563 | } |
495 | 564 | } |
496 | 565 | return false; |
497 | - } else return false; |
|
566 | + } else { |
|
567 | + return false; |
|
568 | + } |
|
498 | 569 | } |
499 | 570 | |
500 | 571 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | /** |
78 | 78 | * Returns list of available locales |
79 | 79 | * |
80 | - * @return array |
|
80 | + * @return string[] |
|
81 | 81 | */ |
82 | 82 | public function listLocaleDir() |
83 | 83 | { |
@@ -86,7 +86,9 @@ discard block |
||
86 | 86 | return $result; |
87 | 87 | } |
88 | 88 | $handle = @opendir('./locale'); |
89 | - if ($handle === false) return $result; |
|
89 | + if ($handle === false) { |
|
90 | + return $result; |
|
91 | + } |
|
90 | 92 | while (false !== ($file = readdir($handle))) { |
91 | 93 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
92 | 94 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -112,7 +114,9 @@ discard block |
||
112 | 114 | $available = $this->listLocaleDir(); |
113 | 115 | $allAvailableLanguages = array(); |
114 | 116 | foreach ($available as $lang) { |
115 | - if (isset($this->all_languages[$lang])) $allAvailableLanguages[$lang] = $this->all_languages[$lang]; |
|
117 | + if (isset($this->all_languages[$lang])) { |
|
118 | + $allAvailableLanguages[$lang] = $this->all_languages[$lang]; |
|
119 | + } |
|
116 | 120 | } |
117 | 121 | return $allAvailableLanguages; |
118 | 122 | } |