@@ -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(); |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | public static function import_file($filename) { |
7 | 7 | $filename = filter_var($filename,FILTER_SANITIZE_STRING); |
8 | 8 | $Connection = new Connection(); |
9 | - //Connection::$db->beginTransaction(); |
|
10 | - $templine = ''; |
|
11 | - $lines = file($filename); |
|
12 | - foreach ($lines as $line) |
|
13 | - { |
|
14 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
15 | - $templine .= $line; |
|
16 | - if (substr(trim($line), -1,1) == ';') |
|
17 | - { |
|
18 | - try { |
|
19 | - $sth = $Connection->db->prepare($templine); |
|
9 | + //Connection::$db->beginTransaction(); |
|
10 | + $templine = ''; |
|
11 | + $lines = file($filename); |
|
12 | + foreach ($lines as $line) |
|
13 | + { |
|
14 | + if (substr($line,0,2) == '--' || $line == '') continue; |
|
15 | + $templine .= $line; |
|
16 | + if (substr(trim($line), -1,1) == ';') |
|
17 | + { |
|
18 | + try { |
|
19 | + $sth = $Connection->db->prepare($templine); |
|
20 | 20 | $sth->execute(); |
21 | - } catch(PDOException $e) { |
|
21 | + } catch(PDOException $e) { |
|
22 | 22 | return "error (import ".$filename.") : ".$e->getMessage()."\n"; |
23 | - } |
|
24 | - $templine = ''; |
|
25 | - } |
|
23 | + } |
|
24 | + $templine = ''; |
|
25 | + } |
|
26 | 26 | } |
27 | - //Connection::$db->commit(); |
|
28 | - $Connection->db = null; |
|
29 | - return ''; |
|
27 | + //Connection::$db->commit(); |
|
28 | + $Connection->db = null; |
|
29 | + return ''; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function import_all_db($directory) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
36 | 36 | while(false !== ($filename = readdir($dh))) |
37 | 37 | { |
38 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
38 | + if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
39 | 39 | } |
40 | 40 | return $error; |
41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $host = filter_var($host,FILTER_SANITIZE_STRING); |
51 | 51 | // Dirty hack |
52 | 52 | if ($host != 'localhost' && $host != '127.0.0.1') { |
53 | - $grantright = $_SERVER['SERVER_ADDR']; |
|
53 | + $grantright = $_SERVER['SERVER_ADDR']; |
|
54 | 54 | } else $grantright = 'localhost'; |
55 | 55 | try { |
56 | 56 | $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |
@@ -4,21 +4,21 @@ discard block |
||
4 | 4 | |
5 | 5 | class create_db { |
6 | 6 | public static function import_file($filename) { |
7 | - $filename = filter_var($filename,FILTER_SANITIZE_STRING); |
|
7 | + $filename = filter_var($filename, FILTER_SANITIZE_STRING); |
|
8 | 8 | $Connection = new Connection(); |
9 | 9 | //Connection::$db->beginTransaction(); |
10 | 10 | $templine = ''; |
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 == '') continue; |
|
15 | 15 | $templine .= $line; |
16 | - if (substr(trim($line), -1,1) == ';') |
|
16 | + if (substr(trim($line), -1, 1) == ';') |
|
17 | 17 | { |
18 | 18 | try { |
19 | 19 | $sth = $Connection->db->prepare($templine); |
20 | 20 | $sth->execute(); |
21 | - } catch(PDOException $e) { |
|
21 | + } catch (PDOException $e) { |
|
22 | 22 | return "error (import ".$filename.") : ".$e->getMessage()."\n"; |
23 | 23 | } |
24 | 24 | $templine = ''; |
@@ -33,27 +33,27 @@ discard block |
||
33 | 33 | $error = ''; |
34 | 34 | $dh = opendir($directory); |
35 | 35 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
36 | - while(false !== ($filename = readdir($dh))) |
|
36 | + while (false !== ($filename = readdir($dh))) |
|
37 | 37 | { |
38 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
38 | + if (preg_match('/\.sql$/', $filename)) $error .= create_db::import_file($directory.$filename); |
|
39 | 39 | } |
40 | 40 | return $error; |
41 | 41 | } |
42 | 42 | |
43 | - public static function create_database($root,$root_pass,$user,$pass,$db,$db_type,$host) { |
|
44 | - $root = filter_var($root,FILTER_SANITIZE_STRING); |
|
45 | - $root_pass = filter_var($root_pass,FILTER_SANITIZE_STRING); |
|
46 | - $user = filter_var($user,FILTER_SANITIZE_STRING); |
|
47 | - $password = filter_var($pass,FILTER_SANITIZE_STRING); |
|
48 | - $db = filter_var($db,FILTER_SANITIZE_STRING); |
|
49 | - $db_type = filter_var($db_type,FILTER_SANITIZE_STRING); |
|
50 | - $host = filter_var($host,FILTER_SANITIZE_STRING); |
|
43 | + public static function create_database($root, $root_pass, $user, $pass, $db, $db_type, $host) { |
|
44 | + $root = filter_var($root, FILTER_SANITIZE_STRING); |
|
45 | + $root_pass = filter_var($root_pass, FILTER_SANITIZE_STRING); |
|
46 | + $user = filter_var($user, FILTER_SANITIZE_STRING); |
|
47 | + $password = filter_var($pass, FILTER_SANITIZE_STRING); |
|
48 | + $db = filter_var($db, FILTER_SANITIZE_STRING); |
|
49 | + $db_type = filter_var($db_type, FILTER_SANITIZE_STRING); |
|
50 | + $host = filter_var($host, FILTER_SANITIZE_STRING); |
|
51 | 51 | // Dirty hack |
52 | 52 | if ($host != 'localhost' && $host != '127.0.0.1') { |
53 | 53 | $grantright = $_SERVER['SERVER_ADDR']; |
54 | 54 | } else $grantright = 'localhost'; |
55 | 55 | try { |
56 | - $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |
|
56 | + $dbh = new PDO($db_type.':host='.$host, $root, $root_pass); |
|
57 | 57 | $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
58 | 58 | if ($db_type == 'mysql') { |
59 | 59 | $dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."'; |
64 | 64 | GRANT ALL PRIVILEGES ON DATABASE ".$db." TO ".$user.";"); |
65 | 65 | } |
66 | - } catch(PDOException $e) { |
|
66 | + } catch (PDOException $e) { |
|
67 | 67 | $dbh = null; |
68 | 68 | return "error : ".$e->getMessage(); |
69 | 69 | } |
@@ -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; |
@@ -70,38 +70,38 @@ discard block |
||
70 | 70 | try { |
71 | 71 | //$Connection = new Connection(); |
72 | 72 | $sth = $Connection->db->prepare($query); |
73 | - $sth->execute(array(':source' => $database_file)); |
|
74 | - } catch(PDOException $e) { |
|
75 | - return "error : ".$e->getMessage(); |
|
76 | - } |
|
73 | + $sth->execute(array(':source' => $database_file)); |
|
74 | + } catch(PDOException $e) { |
|
75 | + return "error : ".$e->getMessage(); |
|
76 | + } |
|
77 | 77 | |
78 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
79 | - update_db::connect_sqlite($database_file); |
|
78 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
79 | + update_db::connect_sqlite($database_file); |
|
80 | 80 | //$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 | 81 | $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"; |
82 | 82 | try { |
83 | - $sth = update_db::$db_sqlite->prepare($query); |
|
84 | - $sth->execute(); |
|
85 | - } catch(PDOException $e) { |
|
86 | - return "error : ".$e->getMessage(); |
|
87 | - } |
|
83 | + $sth = update_db::$db_sqlite->prepare($query); |
|
84 | + $sth->execute(); |
|
85 | + } catch(PDOException $e) { |
|
86 | + return "error : ".$e->getMessage(); |
|
87 | + } |
|
88 | 88 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
89 | 89 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
90 | 90 | $Connection = new Connection(); |
91 | 91 | $sth_dest = $Connection->db->prepare($query_dest); |
92 | 92 | try { |
93 | 93 | if ($globalTransaction) $Connection->db->beginTransaction(); |
94 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
94 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
95 | 95 | //$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 | 96 | $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 | 97 | $sth_dest->execute($query_dest_values); |
98 | - } |
|
98 | + } |
|
99 | 99 | if ($globalTransaction) $Connection->db->commit(); |
100 | 100 | } catch(PDOException $e) { |
101 | 101 | if ($globalTransaction) $Connection->db->rollBack(); |
102 | 102 | return "error : ".$e->getMessage(); |
103 | 103 | } |
104 | - return ''; |
|
104 | + return ''; |
|
105 | 105 | } |
106 | 106 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
107 | 107 | global $globalTransaction; |
@@ -110,27 +110,27 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $Connection = new Connection(); |
112 | 112 | $sth = $Connection->db->prepare($query); |
113 | - $sth->execute(array(':source' => $database_file)); |
|
114 | - } catch(PDOException $e) { |
|
115 | - return "error : ".$e->getMessage(); |
|
116 | - } |
|
113 | + $sth->execute(array(':source' => $database_file)); |
|
114 | + } catch(PDOException $e) { |
|
115 | + return "error : ".$e->getMessage(); |
|
116 | + } |
|
117 | 117 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
118 | 118 | try { |
119 | 119 | $Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | - $sth->execute(array(':source' => $database_file)); |
|
122 | - } catch(PDOException $e) { |
|
123 | - return "error : ".$e->getMessage(); |
|
124 | - } |
|
121 | + $sth->execute(array(':source' => $database_file)); |
|
122 | + } catch(PDOException $e) { |
|
123 | + return "error : ".$e->getMessage(); |
|
124 | + } |
|
125 | 125 | |
126 | - update_db::connect_sqlite($database_file); |
|
126 | + update_db::connect_sqlite($database_file); |
|
127 | 127 | $query = 'select * from Aircraft'; |
128 | 128 | try { |
129 | - $sth = update_db::$db_sqlite->prepare($query); |
|
130 | - $sth->execute(); |
|
131 | - } catch(PDOException $e) { |
|
132 | - return "error : ".$e->getMessage(); |
|
133 | - } |
|
129 | + $sth = update_db::$db_sqlite->prepare($query); |
|
130 | + $sth->execute(); |
|
131 | + } catch(PDOException $e) { |
|
132 | + return "error : ".$e->getMessage(); |
|
133 | + } |
|
134 | 134 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
135 | 135 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
136 | 136 | |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
142 | 142 | try { |
143 | 143 | if ($globalTransaction) $Connection->db->beginTransaction(); |
144 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
144 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
145 | 145 | //$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 | 146 | if ($values['UserString4'] == 'M') $type = 'military'; |
147 | 147 | else $type = null; |
148 | 148 | $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 | 149 | $sth_dest->execute($query_dest_values); |
150 | 150 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
151 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
152 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
151 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
152 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
153 | 153 | } |
154 | - } |
|
154 | + } |
|
155 | 155 | if ($globalTransaction) $Connection->db->commit(); |
156 | 156 | } catch(PDOException $e) { |
157 | 157 | return "error : ".$e->getMessage(); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | try { |
162 | 162 | $Connection = new Connection(); |
163 | 163 | $sth = $Connection->db->prepare($query); |
164 | - $sth->execute(array(':source' => $database_file)); |
|
165 | - } catch(PDOException $e) { |
|
166 | - return "error : ".$e->getMessage(); |
|
167 | - } |
|
164 | + $sth->execute(array(':source' => $database_file)); |
|
165 | + } catch(PDOException $e) { |
|
166 | + return "error : ".$e->getMessage(); |
|
167 | + } |
|
168 | 168 | return ''; |
169 | 169 | } |
170 | 170 | |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | try { |
177 | 177 | $Connection = new Connection(); |
178 | 178 | $sth = $Connection->db->prepare($query); |
179 | - $sth->execute(array(':source' => $database_file)); |
|
180 | - } catch(PDOException $e) { |
|
181 | - return "error : ".$e->getMessage(); |
|
182 | - } |
|
179 | + $sth->execute(array(':source' => $database_file)); |
|
180 | + } catch(PDOException $e) { |
|
181 | + return "error : ".$e->getMessage(); |
|
182 | + } |
|
183 | 183 | |
184 | 184 | if ($fh = fopen($database_file,"r")) { |
185 | 185 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -189,25 +189,25 @@ discard block |
||
189 | 189 | $sth_dest = $Connection->db->prepare($query_dest); |
190 | 190 | try { |
191 | 191 | if ($globalTransaction) $Connection->db->beginTransaction(); |
192 | - while (!feof($fh)) { |
|
193 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
192 | + while (!feof($fh)) { |
|
193 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
194 | 194 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
195 | - $values['ModeS'] = substr($line,0,6); |
|
196 | - $values['Registration'] = trim(substr($line,69,6)); |
|
197 | - $aircraft_name = trim(substr($line,48,6)); |
|
198 | - // Check if we can find ICAO, else set it to GLID |
|
199 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
200 | - $search_more = ''; |
|
201 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
202 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
203 | - $sth_search = $Connection->db->prepare($query_search); |
|
195 | + $values['ModeS'] = substr($line,0,6); |
|
196 | + $values['Registration'] = trim(substr($line,69,6)); |
|
197 | + $aircraft_name = trim(substr($line,48,6)); |
|
198 | + // Check if we can find ICAO, else set it to GLID |
|
199 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
200 | + $search_more = ''; |
|
201 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
202 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
203 | + $sth_search = $Connection->db->prepare($query_search); |
|
204 | 204 | try { |
205 | - $sth_search->execute(); |
|
206 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
207 | - //if (count($result) > 0) { |
|
208 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
209 | - $values['ICAOTypeCode'] = $result['icao']; |
|
210 | - } |
|
205 | + $sth_search->execute(); |
|
206 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
207 | + //if (count($result) > 0) { |
|
208 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
209 | + $values['ICAOTypeCode'] = $result['icao']; |
|
210 | + } |
|
211 | 211 | } catch(PDOException $e) { |
212 | 212 | return "error : ".$e->getMessage(); |
213 | 213 | } |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | try { |
231 | 231 | $Connection = new Connection(); |
232 | 232 | $sth = $Connection->db->prepare($query); |
233 | - $sth->execute(array(':source' => $database_file)); |
|
234 | - } catch(PDOException $e) { |
|
235 | - return "error : ".$e->getMessage(); |
|
236 | - } |
|
233 | + $sth->execute(array(':source' => $database_file)); |
|
234 | + } catch(PDOException $e) { |
|
235 | + return "error : ".$e->getMessage(); |
|
236 | + } |
|
237 | 237 | return ''; |
238 | 238 | } |
239 | 239 | |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | try { |
245 | 245 | $Connection = new Connection(); |
246 | 246 | $sth = $Connection->db->prepare($query); |
247 | - $sth->execute(array(':source' => $database_file)); |
|
248 | - } catch(PDOException $e) { |
|
249 | - return "error : ".$e->getMessage(); |
|
250 | - } |
|
247 | + $sth->execute(array(':source' => $database_file)); |
|
248 | + } catch(PDOException $e) { |
|
249 | + return "error : ".$e->getMessage(); |
|
250 | + } |
|
251 | 251 | |
252 | 252 | if ($fh = fopen($database_file,"r")) { |
253 | 253 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -258,24 +258,24 @@ discard block |
||
258 | 258 | try { |
259 | 259 | if ($globalTransaction) $Connection->db->beginTransaction(); |
260 | 260 | $tmp = fgetcsv($fh,9999,',',"'"); |
261 | - while (!feof($fh)) { |
|
262 | - $line = fgetcsv($fh,9999,',',"'"); |
|
261 | + while (!feof($fh)) { |
|
262 | + $line = fgetcsv($fh,9999,',',"'"); |
|
263 | 263 | |
264 | 264 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
265 | 265 | //print_r($line); |
266 | - $values['ModeS'] = $line[1]; |
|
267 | - $values['Registration'] = $line[3]; |
|
268 | - $aircraft_name = $line[2]; |
|
269 | - // Check if we can find ICAO, else set it to GLID |
|
270 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
271 | - $search_more = ''; |
|
272 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
273 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
274 | - $sth_search = $Connection->db->prepare($query_search); |
|
266 | + $values['ModeS'] = $line[1]; |
|
267 | + $values['Registration'] = $line[3]; |
|
268 | + $aircraft_name = $line[2]; |
|
269 | + // Check if we can find ICAO, else set it to GLID |
|
270 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
271 | + $search_more = ''; |
|
272 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
273 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
274 | + $sth_search = $Connection->db->prepare($query_search); |
|
275 | 275 | try { |
276 | - $sth_search->execute(); |
|
277 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
278 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
276 | + $sth_search->execute(); |
|
277 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
278 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
279 | 279 | } catch(PDOException $e) { |
280 | 280 | return "error : ".$e->getMessage(); |
281 | 281 | } |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | try { |
299 | 299 | $Connection = new Connection(); |
300 | 300 | $sth = $Connection->db->prepare($query); |
301 | - $sth->execute(array(':source' => $database_file)); |
|
302 | - } catch(PDOException $e) { |
|
303 | - return "error : ".$e->getMessage(); |
|
304 | - } |
|
301 | + $sth->execute(array(':source' => $database_file)); |
|
302 | + } catch(PDOException $e) { |
|
303 | + return "error : ".$e->getMessage(); |
|
304 | + } |
|
305 | 305 | return ''; |
306 | 306 | } |
307 | 307 | |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | try { |
313 | 313 | $Connection = new Connection(); |
314 | 314 | $sth = $Connection->db->prepare($query); |
315 | - $sth->execute(array(':source' => $database_file)); |
|
316 | - } catch(PDOException $e) { |
|
317 | - return "error : ".$e->getMessage(); |
|
318 | - } |
|
315 | + $sth->execute(array(':source' => $database_file)); |
|
316 | + } catch(PDOException $e) { |
|
317 | + return "error : ".$e->getMessage(); |
|
318 | + } |
|
319 | 319 | |
320 | 320 | if ($fh = fopen($database_file,"r")) { |
321 | 321 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -326,94 +326,94 @@ discard block |
||
326 | 326 | try { |
327 | 327 | if ($globalTransaction) $Connection->db->beginTransaction(); |
328 | 328 | $tmp = fgetcsv($fh,9999,',','"'); |
329 | - while (!feof($fh)) { |
|
330 | - $line = fgetcsv($fh,9999,',','"'); |
|
331 | - //print_r($line); |
|
332 | - if ($country == 'F') { |
|
333 | - $values['registration'] = $line[0]; |
|
334 | - $values['base'] = $line[4]; |
|
335 | - $values['owner'] = $line[5]; |
|
336 | - if ($line[6] == '') $values['date_first_reg'] = ''; |
|
337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
338 | - $values['cancel'] = $line[7]; |
|
329 | + while (!feof($fh)) { |
|
330 | + $line = fgetcsv($fh,9999,',','"'); |
|
331 | + //print_r($line); |
|
332 | + if ($country == 'F') { |
|
333 | + $values['registration'] = $line[0]; |
|
334 | + $values['base'] = $line[4]; |
|
335 | + $values['owner'] = $line[5]; |
|
336 | + if ($line[6] == '') $values['date_first_reg'] = ''; |
|
337 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
338 | + $values['cancel'] = $line[7]; |
|
339 | 339 | } elseif ($country == 'EI') { |
340 | - // TODO : add modeS & reg to aircraft_modes |
|
341 | - $values['registration'] = $line[0]; |
|
342 | - $values['base'] = $line[3]; |
|
343 | - $values['owner'] = $line[2]; |
|
344 | - if ($line[1] == '') $values['date_first_reg'] = ''; |
|
345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
346 | - $values['cancel'] = ''; |
|
340 | + // TODO : add modeS & reg to aircraft_modes |
|
341 | + $values['registration'] = $line[0]; |
|
342 | + $values['base'] = $line[3]; |
|
343 | + $values['owner'] = $line[2]; |
|
344 | + if ($line[1] == '') $values['date_first_reg'] = ''; |
|
345 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
346 | + $values['cancel'] = ''; |
|
347 | 347 | } elseif ($country == 'HB') { |
348 | - // TODO : add modeS & reg to aircraft_modes |
|
349 | - $values['registration'] = $line[0]; |
|
350 | - $values['base'] = null; |
|
351 | - $values['owner'] = $line[5]; |
|
352 | - $values['date_first_reg'] = ''; |
|
353 | - $values['cancel'] = ''; |
|
348 | + // TODO : add modeS & reg to aircraft_modes |
|
349 | + $values['registration'] = $line[0]; |
|
350 | + $values['base'] = null; |
|
351 | + $values['owner'] = $line[5]; |
|
352 | + $values['date_first_reg'] = ''; |
|
353 | + $values['cancel'] = ''; |
|
354 | 354 | } elseif ($country == 'OK') { |
355 | - // TODO : add modeS & reg to aircraft_modes |
|
356 | - $values['registration'] = $line[3]; |
|
357 | - $values['base'] = null; |
|
358 | - $values['owner'] = $line[5]; |
|
359 | - if ($line[18] == '') $values['date_first_reg'] = ''; |
|
360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
361 | - $values['cancel'] = ''; |
|
355 | + // TODO : add modeS & reg to aircraft_modes |
|
356 | + $values['registration'] = $line[3]; |
|
357 | + $values['base'] = null; |
|
358 | + $values['owner'] = $line[5]; |
|
359 | + if ($line[18] == '') $values['date_first_reg'] = ''; |
|
360 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
361 | + $values['cancel'] = ''; |
|
362 | 362 | } elseif ($country == 'VH') { |
363 | - // TODO : add modeS & reg to aircraft_modes |
|
364 | - $values['registration'] = $line[0]; |
|
365 | - $values['base'] = null; |
|
366 | - $values['owner'] = $line[12]; |
|
367 | - if ($line[28] == '') $values['date_first_reg'] = ''; |
|
368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
369 | - |
|
370 | - $values['cancel'] = $line[39]; |
|
363 | + // TODO : add modeS & reg to aircraft_modes |
|
364 | + $values['registration'] = $line[0]; |
|
365 | + $values['base'] = null; |
|
366 | + $values['owner'] = $line[12]; |
|
367 | + if ($line[28] == '') $values['date_first_reg'] = ''; |
|
368 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
369 | + |
|
370 | + $values['cancel'] = $line[39]; |
|
371 | 371 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
372 | - $values['registration'] = $line[0]; |
|
373 | - $values['base'] = null; |
|
374 | - $values['owner'] = $line[4]; |
|
375 | - $values['date_first_reg'] = null; |
|
376 | - $values['cancel'] = ''; |
|
372 | + $values['registration'] = $line[0]; |
|
373 | + $values['base'] = null; |
|
374 | + $values['owner'] = $line[4]; |
|
375 | + $values['date_first_reg'] = null; |
|
376 | + $values['cancel'] = ''; |
|
377 | 377 | } elseif ($country == 'CC') { |
378 | - $values['registration'] = $line[0]; |
|
379 | - $values['base'] = null; |
|
380 | - $values['owner'] = $line[6]; |
|
381 | - $values['date_first_reg'] = null; |
|
382 | - $values['cancel'] = ''; |
|
378 | + $values['registration'] = $line[0]; |
|
379 | + $values['base'] = null; |
|
380 | + $values['owner'] = $line[6]; |
|
381 | + $values['date_first_reg'] = null; |
|
382 | + $values['cancel'] = ''; |
|
383 | 383 | } elseif ($country == 'HJ') { |
384 | - $values['registration'] = $line[0]; |
|
385 | - $values['base'] = null; |
|
386 | - $values['owner'] = $line[8]; |
|
387 | - if ($line[7] == '') $values['date_first_reg'] = ''; |
|
388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
389 | - $values['cancel'] = ''; |
|
384 | + $values['registration'] = $line[0]; |
|
385 | + $values['base'] = null; |
|
386 | + $values['owner'] = $line[8]; |
|
387 | + if ($line[7] == '') $values['date_first_reg'] = ''; |
|
388 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
389 | + $values['cancel'] = ''; |
|
390 | 390 | } elseif ($country == 'PP') { |
391 | - $values['registration'] = $line[0]; |
|
392 | - $values['base'] = null; |
|
393 | - $values['owner'] = $line[4]; |
|
394 | - if ($line[6] == '') $values['date_first_reg'] = ''; |
|
395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
396 | - $values['cancel'] = $line[7]; |
|
391 | + $values['registration'] = $line[0]; |
|
392 | + $values['base'] = null; |
|
393 | + $values['owner'] = $line[4]; |
|
394 | + if ($line[6] == '') $values['date_first_reg'] = ''; |
|
395 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
396 | + $values['cancel'] = $line[7]; |
|
397 | 397 | } elseif ($country == 'E7') { |
398 | - $values['registration'] = $line[0]; |
|
399 | - $values['base'] = null; |
|
400 | - $values['owner'] = $line[4]; |
|
401 | - if ($line[5] == '') $values['date_first_reg'] = ''; |
|
402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
403 | - $values['cancel'] = ''; |
|
398 | + $values['registration'] = $line[0]; |
|
399 | + $values['base'] = null; |
|
400 | + $values['owner'] = $line[4]; |
|
401 | + if ($line[5] == '') $values['date_first_reg'] = ''; |
|
402 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
403 | + $values['cancel'] = ''; |
|
404 | 404 | } elseif ($country == '8Q') { |
405 | - $values['registration'] = $line[0]; |
|
406 | - $values['base'] = null; |
|
407 | - $values['owner'] = $line[3]; |
|
408 | - if ($line[7] == '') $values['date_first_reg'] = ''; |
|
409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
410 | - $values['cancel'] = ''; |
|
405 | + $values['registration'] = $line[0]; |
|
406 | + $values['base'] = null; |
|
407 | + $values['owner'] = $line[3]; |
|
408 | + if ($line[7] == '') $values['date_first_reg'] = ''; |
|
409 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
410 | + $values['cancel'] = ''; |
|
411 | 411 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
412 | - $values['registration'] = $line[0]; |
|
413 | - $values['base'] = null; |
|
414 | - $values['owner'] = $line[3]; |
|
415 | - $values['date_first_reg'] = ''; |
|
416 | - $values['cancel'] = ''; |
|
412 | + $values['registration'] = $line[0]; |
|
413 | + $values['base'] = null; |
|
414 | + $values['owner'] = $line[3]; |
|
415 | + $values['date_first_reg'] = ''; |
|
416 | + $values['cancel'] = ''; |
|
417 | 417 | } |
418 | 418 | if ($values['cancel'] == '' && $values['registration'] != null) { |
419 | 419 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -535,20 +535,20 @@ discard block |
||
535 | 535 | try { |
536 | 536 | $Connection = new Connection(); |
537 | 537 | $sth = $Connection->db->prepare($query); |
538 | - $sth->execute(); |
|
539 | - } catch(PDOException $e) { |
|
540 | - return "error : ".$e->getMessage(); |
|
541 | - } |
|
538 | + $sth->execute(); |
|
539 | + } catch(PDOException $e) { |
|
540 | + return "error : ".$e->getMessage(); |
|
541 | + } |
|
542 | 542 | |
543 | 543 | |
544 | 544 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
545 | 545 | try { |
546 | 546 | $Connection = new Connection(); |
547 | 547 | $sth = $Connection->db->prepare($query); |
548 | - $sth->execute(); |
|
549 | - } catch(PDOException $e) { |
|
550 | - return "error : ".$e->getMessage(); |
|
551 | - } |
|
548 | + $sth->execute(); |
|
549 | + } catch(PDOException $e) { |
|
550 | + return "error : ".$e->getMessage(); |
|
551 | + } |
|
552 | 552 | |
553 | 553 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
554 | 554 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | try { |
615 | 615 | $Connection = new Connection(); |
616 | 616 | $sth = $Connection->db->prepare($query); |
617 | - $sth->execute(); |
|
618 | - } catch(PDOException $e) { |
|
619 | - return "error : ".$e->getMessage(); |
|
620 | - } |
|
617 | + $sth->execute(); |
|
618 | + } catch(PDOException $e) { |
|
619 | + return "error : ".$e->getMessage(); |
|
620 | + } |
|
621 | 621 | |
622 | 622 | |
623 | 623 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | try { |
628 | 628 | $Connection = new Connection(); |
629 | 629 | $sth = $Connection->db->prepare($query); |
630 | - $sth->execute($query_values); |
|
631 | - } catch(PDOException $e) { |
|
632 | - return "error : ".$e->getMessage(); |
|
633 | - } |
|
630 | + $sth->execute($query_values); |
|
631 | + } catch(PDOException $e) { |
|
632 | + return "error : ".$e->getMessage(); |
|
633 | + } |
|
634 | 634 | $i++; |
635 | 635 | /* |
636 | 636 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | |
746 | 746 | |
747 | - return "success"; |
|
747 | + return "success"; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | public static function translation() { |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | try { |
761 | 761 | $Connection = new Connection(); |
762 | 762 | $sth = $Connection->db->prepare($query); |
763 | - $sth->execute(array(':source' => 'translation.csv')); |
|
764 | - } catch(PDOException $e) { |
|
765 | - return "error : ".$e->getMessage(); |
|
766 | - } |
|
763 | + $sth->execute(array(':source' => 'translation.csv')); |
|
764 | + } catch(PDOException $e) { |
|
765 | + return "error : ".$e->getMessage(); |
|
766 | + } |
|
767 | 767 | |
768 | 768 | |
769 | 769 | //update_db::unzip($out_file); |
@@ -782,21 +782,21 @@ discard block |
||
782 | 782 | $data = $row; |
783 | 783 | $operator = $data[2]; |
784 | 784 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
785 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
786 | - //echo substr($operator, 0, 2)."\n";; |
|
787 | - if (count($airline_array) > 0) { |
|
785 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
786 | + //echo substr($operator, 0, 2)."\n";; |
|
787 | + if (count($airline_array) > 0) { |
|
788 | 788 | //print_r($airline_array); |
789 | 789 | $operator = $airline_array[0]['icao'].substr($operator,2); |
790 | - } |
|
791 | - } |
|
790 | + } |
|
791 | + } |
|
792 | 792 | |
793 | 793 | $operator_correct = $data[3]; |
794 | 794 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
795 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
796 | - if (count($airline_array) > 0) { |
|
797 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
798 | - } |
|
799 | - } |
|
795 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
796 | + if (count($airline_array) > 0) { |
|
797 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
798 | + } |
|
799 | + } |
|
800 | 800 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
801 | 801 | try { |
802 | 802 | $sth = $Connection->db->prepare($query); |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | //$Connection->db->commit(); |
811 | 811 | } |
812 | 812 | return ''; |
813 | - } |
|
813 | + } |
|
814 | 814 | |
815 | 815 | public static function translation_fam() { |
816 | 816 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -820,10 +820,10 @@ discard block |
||
820 | 820 | try { |
821 | 821 | $Connection = new Connection(); |
822 | 822 | $sth = $Connection->db->prepare($query); |
823 | - $sth->execute(array(':source' => 'website_fam')); |
|
824 | - } catch(PDOException $e) { |
|
825 | - return "error : ".$e->getMessage(); |
|
826 | - } |
|
823 | + $sth->execute(array(':source' => 'website_fam')); |
|
824 | + } catch(PDOException $e) { |
|
825 | + return "error : ".$e->getMessage(); |
|
826 | + } |
|
827 | 827 | |
828 | 828 | |
829 | 829 | //update_db::unzip($out_file); |
@@ -852,54 +852,54 @@ discard block |
||
852 | 852 | //$Connection->db->commit(); |
853 | 853 | } |
854 | 854 | return ''; |
855 | - } |
|
855 | + } |
|
856 | 856 | |
857 | 857 | /** |
858 | - * Convert a HTML table to an array |
|
859 | - * @param String $data HTML page |
|
860 | - * @return Array array of the tables in HTML page |
|
861 | - */ |
|
862 | - private static function table2array($data) { |
|
863 | - $html = str_get_html($data); |
|
864 | - $tabledata=array(); |
|
865 | - foreach($html->find('tr') as $element) |
|
866 | - { |
|
867 | - $td = array(); |
|
868 | - foreach( $element->find('th') as $row) |
|
869 | - { |
|
870 | - $td [] = trim($row->plaintext); |
|
871 | - } |
|
872 | - $td=array_filter($td); |
|
873 | - $tabledata[] = $td; |
|
874 | - |
|
875 | - $td = array(); |
|
876 | - $tdi = array(); |
|
877 | - foreach( $element->find('td') as $row) |
|
878 | - { |
|
879 | - $td [] = trim($row->plaintext); |
|
880 | - $tdi [] = trim($row->innertext); |
|
881 | - } |
|
882 | - $td=array_filter($td); |
|
883 | - $tdi=array_filter($tdi); |
|
884 | - // $tabledata[]=array_merge($td,$tdi); |
|
885 | - $tabledata[]=$td; |
|
886 | - } |
|
887 | - return(array_filter($tabledata)); |
|
888 | - } |
|
889 | - |
|
890 | - /** |
|
891 | - * Get data from form result |
|
892 | - * @param String $url form URL |
|
893 | - * @return String the result |
|
894 | - */ |
|
895 | - private static function getData($url) { |
|
896 | - $ch = curl_init(); |
|
897 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
898 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
899 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
900 | - 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'); |
|
901 | - return curl_exec($ch); |
|
902 | - } |
|
858 | + * Convert a HTML table to an array |
|
859 | + * @param String $data HTML page |
|
860 | + * @return Array array of the tables in HTML page |
|
861 | + */ |
|
862 | + private static function table2array($data) { |
|
863 | + $html = str_get_html($data); |
|
864 | + $tabledata=array(); |
|
865 | + foreach($html->find('tr') as $element) |
|
866 | + { |
|
867 | + $td = array(); |
|
868 | + foreach( $element->find('th') as $row) |
|
869 | + { |
|
870 | + $td [] = trim($row->plaintext); |
|
871 | + } |
|
872 | + $td=array_filter($td); |
|
873 | + $tabledata[] = $td; |
|
874 | + |
|
875 | + $td = array(); |
|
876 | + $tdi = array(); |
|
877 | + foreach( $element->find('td') as $row) |
|
878 | + { |
|
879 | + $td [] = trim($row->plaintext); |
|
880 | + $tdi [] = trim($row->innertext); |
|
881 | + } |
|
882 | + $td=array_filter($td); |
|
883 | + $tdi=array_filter($tdi); |
|
884 | + // $tabledata[]=array_merge($td,$tdi); |
|
885 | + $tabledata[]=$td; |
|
886 | + } |
|
887 | + return(array_filter($tabledata)); |
|
888 | + } |
|
889 | + |
|
890 | + /** |
|
891 | + * Get data from form result |
|
892 | + * @param String $url form URL |
|
893 | + * @return String the result |
|
894 | + */ |
|
895 | + private static function getData($url) { |
|
896 | + $ch = curl_init(); |
|
897 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
898 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
899 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
900 | + 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'); |
|
901 | + return curl_exec($ch); |
|
902 | + } |
|
903 | 903 | /* |
904 | 904 | public static function waypoints() { |
905 | 905 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -949,10 +949,10 @@ discard block |
||
949 | 949 | try { |
950 | 950 | $Connection = new Connection(); |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | - $sth->execute(); |
|
953 | - } catch(PDOException $e) { |
|
954 | - return "error : ".$e->getMessage(); |
|
955 | - } |
|
952 | + $sth->execute(); |
|
953 | + } catch(PDOException $e) { |
|
954 | + return "error : ".$e->getMessage(); |
|
955 | + } |
|
956 | 956 | |
957 | 957 | |
958 | 958 | //update_db::unzip($out_file); |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | if ($globalTransaction) $Connection->db->commit(); |
994 | 994 | } |
995 | 995 | return ''; |
996 | - } |
|
996 | + } |
|
997 | 997 | |
998 | 998 | public static function ivao_airlines($filename) { |
999 | 999 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1002,10 +1002,10 @@ discard block |
||
1002 | 1002 | try { |
1003 | 1003 | $Connection = new Connection(); |
1004 | 1004 | $sth = $Connection->db->prepare($query); |
1005 | - $sth->execute(); |
|
1006 | - } catch(PDOException $e) { |
|
1007 | - return "error : ".$e->getMessage(); |
|
1008 | - } |
|
1005 | + $sth->execute(); |
|
1006 | + } catch(PDOException $e) { |
|
1007 | + return "error : ".$e->getMessage(); |
|
1008 | + } |
|
1009 | 1009 | |
1010 | 1010 | $header = NULL; |
1011 | 1011 | $delimiter = ':'; |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | if ($globalTransaction) $Connection->db->commit(); |
1030 | 1030 | } |
1031 | 1031 | return ''; |
1032 | - } |
|
1032 | + } |
|
1033 | 1033 | |
1034 | 1034 | public static function update_airspace() { |
1035 | 1035 | global $tmp_dir, $globalDBdriver; |
@@ -1064,10 +1064,10 @@ discard block |
||
1064 | 1064 | $query = 'DROP TABLE countries'; |
1065 | 1065 | try { |
1066 | 1066 | $sth = $Connection->db->prepare($query); |
1067 | - $sth->execute(); |
|
1068 | - } catch(PDOException $e) { |
|
1069 | - echo "error : ".$e->getMessage(); |
|
1070 | - } |
|
1067 | + $sth->execute(); |
|
1068 | + } catch(PDOException $e) { |
|
1069 | + echo "error : ".$e->getMessage(); |
|
1070 | + } |
|
1071 | 1071 | } |
1072 | 1072 | if ($globalDBdriver == 'mysql') { |
1073 | 1073 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1412,12 +1412,12 @@ discard block |
||
1412 | 1412 | echo $data; |
1413 | 1413 | */ |
1414 | 1414 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1415 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
1416 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1417 | - $result = fread($fh,100000000); |
|
1418 | - //echo $result; |
|
1419 | - //var_dump(str_get_html($result)); |
|
1420 | - //print_r(self::table2array($result)); |
|
1415 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
1416 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1417 | + $result = fread($fh,100000000); |
|
1418 | + //echo $result; |
|
1419 | + //var_dump(str_get_html($result)); |
|
1420 | + //print_r(self::table2array($result)); |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | } |
@@ -1431,10 +1431,10 @@ discard block |
||
1431 | 1431 | try { |
1432 | 1432 | $Connection = new Connection(); |
1433 | 1433 | $sth = $Connection->db->prepare($query); |
1434 | - $sth->execute(); |
|
1435 | - } catch(PDOException $e) { |
|
1436 | - return "error : ".$e->getMessage(); |
|
1437 | - } |
|
1434 | + $sth->execute(); |
|
1435 | + } catch(PDOException $e) { |
|
1436 | + return "error : ".$e->getMessage(); |
|
1437 | + } |
|
1438 | 1438 | |
1439 | 1439 | $error = ''; |
1440 | 1440 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1490,8 +1490,8 @@ discard block |
||
1490 | 1490 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
1491 | 1491 | $data['permanent'] = 0; |
1492 | 1492 | } else { |
1493 | - $data['date_end'] = NULL; |
|
1494 | - $data['permanent'] = 1; |
|
1493 | + $data['date_end'] = NULL; |
|
1494 | + $data['permanent'] = 1; |
|
1495 | 1495 | } |
1496 | 1496 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1497 | 1497 | $NOTAM = new NOTAM(); |
@@ -1515,13 +1515,13 @@ discard block |
||
1515 | 1515 | try { |
1516 | 1516 | $Connection = new Connection(); |
1517 | 1517 | $sth = $Connection->db->prepare($query); |
1518 | - $sth->execute(); |
|
1519 | - } catch(PDOException $e) { |
|
1520 | - return "error : ".$e->getMessage(); |
|
1521 | - } |
|
1522 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1523 | - if ($row['nb'] > 0) return false; |
|
1524 | - else return true; |
|
1518 | + $sth->execute(); |
|
1519 | + } catch(PDOException $e) { |
|
1520 | + return "error : ".$e->getMessage(); |
|
1521 | + } |
|
1522 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1523 | + if ($row['nb'] > 0) return false; |
|
1524 | + else return true; |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | public static function insert_last_update() { |
@@ -1530,10 +1530,10 @@ discard block |
||
1530 | 1530 | try { |
1531 | 1531 | $Connection = new Connection(); |
1532 | 1532 | $sth = $Connection->db->prepare($query); |
1533 | - $sth->execute(); |
|
1534 | - } catch(PDOException $e) { |
|
1535 | - return "error : ".$e->getMessage(); |
|
1536 | - } |
|
1533 | + $sth->execute(); |
|
1534 | + } catch(PDOException $e) { |
|
1535 | + return "error : ".$e->getMessage(); |
|
1536 | + } |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | public static function check_last_notam_update() { |
@@ -1546,13 +1546,13 @@ discard block |
||
1546 | 1546 | try { |
1547 | 1547 | $Connection = new Connection(); |
1548 | 1548 | $sth = $Connection->db->prepare($query); |
1549 | - $sth->execute(); |
|
1550 | - } catch(PDOException $e) { |
|
1551 | - return "error : ".$e->getMessage(); |
|
1552 | - } |
|
1553 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1554 | - if ($row['nb'] > 0) return false; |
|
1555 | - else return true; |
|
1549 | + $sth->execute(); |
|
1550 | + } catch(PDOException $e) { |
|
1551 | + return "error : ".$e->getMessage(); |
|
1552 | + } |
|
1553 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1554 | + if ($row['nb'] > 0) return false; |
|
1555 | + else return true; |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | public static function insert_last_notam_update() { |
@@ -1561,10 +1561,10 @@ discard block |
||
1561 | 1561 | try { |
1562 | 1562 | $Connection = new Connection(); |
1563 | 1563 | $sth = $Connection->db->prepare($query); |
1564 | - $sth->execute(); |
|
1565 | - } catch(PDOException $e) { |
|
1566 | - return "error : ".$e->getMessage(); |
|
1567 | - } |
|
1564 | + $sth->execute(); |
|
1565 | + } catch(PDOException $e) { |
|
1566 | + return "error : ".$e->getMessage(); |
|
1567 | + } |
|
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | public static function check_last_owner_update() { |
@@ -1577,13 +1577,13 @@ discard block |
||
1577 | 1577 | try { |
1578 | 1578 | $Connection = new Connection(); |
1579 | 1579 | $sth = $Connection->db->prepare($query); |
1580 | - $sth->execute(); |
|
1581 | - } catch(PDOException $e) { |
|
1582 | - return "error : ".$e->getMessage(); |
|
1583 | - } |
|
1584 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1585 | - if ($row['nb'] > 0) return false; |
|
1586 | - else return true; |
|
1580 | + $sth->execute(); |
|
1581 | + } catch(PDOException $e) { |
|
1582 | + return "error : ".$e->getMessage(); |
|
1583 | + } |
|
1584 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1585 | + if ($row['nb'] > 0) return false; |
|
1586 | + else return true; |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | public static function insert_last_owner_update() { |
@@ -1592,10 +1592,10 @@ discard block |
||
1592 | 1592 | try { |
1593 | 1593 | $Connection = new Connection(); |
1594 | 1594 | $sth = $Connection->db->prepare($query); |
1595 | - $sth->execute(); |
|
1596 | - } catch(PDOException $e) { |
|
1597 | - return "error : ".$e->getMessage(); |
|
1598 | - } |
|
1595 | + $sth->execute(); |
|
1596 | + } catch(PDOException $e) { |
|
1597 | + return "error : ".$e->getMessage(); |
|
1598 | + } |
|
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | public static function update_all() { |
@@ -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'] = ''; |
|
337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
382 | + if ($line[6] == '') { |
|
383 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
393 | + if ($line[1] == '') { |
|
394 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
411 | + if ($line[18] == '') { |
|
412 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
422 | + if ($line[28] == '') { |
|
423 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
445 | + if ($line[7] == '') { |
|
446 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
455 | + if ($line[6] == '') { |
|
456 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
465 | + if ($line[5] == '') { |
|
466 | + $values['date_first_reg'] = ''; |
|
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'] = ''; |
|
409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
475 | + if ($line[7] == '') { |
|
476 | + $values['date_first_reg'] = ''; |
|
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 | try { |
@@ -1099,35 +1210,59 @@ discard block |
||
1099 | 1210 | //if ($globalDebug) echo "IVAO : Download..."; |
1100 | 1211 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1101 | 1212 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1102 | - if ($globalDebug) echo "Unzip..."; |
|
1213 | + if ($globalDebug) { |
|
1214 | + echo "Unzip..."; |
|
1215 | + } |
|
1103 | 1216 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1104 | - if ($globalDebug) echo "Add to DB..."; |
|
1217 | + if ($globalDebug) { |
|
1218 | + echo "Add to DB..."; |
|
1219 | + } |
|
1105 | 1220 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1106 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1221 | + if ($globalDebug) { |
|
1222 | + echo "Copy airlines logos to airlines images directory..."; |
|
1223 | + } |
|
1107 | 1224 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1108 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1109 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1110 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1225 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1226 | + $error = "Failed to copy airlines logo."; |
|
1227 | + } |
|
1228 | + } else { |
|
1229 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1230 | + } |
|
1231 | + } else { |
|
1232 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1233 | + } |
|
1111 | 1234 | if ($error != '') { |
1112 | 1235 | return $error; |
1113 | - } elseif ($globalDebug) echo "Done\n"; |
|
1236 | + } elseif ($globalDebug) { |
|
1237 | + echo "Done\n"; |
|
1238 | + } |
|
1114 | 1239 | return ''; |
1115 | 1240 | } |
1116 | 1241 | |
1117 | 1242 | public static function update_routes() { |
1118 | 1243 | global $tmp_dir, $globalDebug; |
1119 | 1244 | $error = ''; |
1120 | - if ($globalDebug) echo "Routes : Download..."; |
|
1245 | + if ($globalDebug) { |
|
1246 | + echo "Routes : Download..."; |
|
1247 | + } |
|
1121 | 1248 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1122 | 1249 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1123 | - if ($globalDebug) echo "Gunzip..."; |
|
1250 | + if ($globalDebug) { |
|
1251 | + echo "Gunzip..."; |
|
1252 | + } |
|
1124 | 1253 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1125 | - if ($globalDebug) echo "Add to DB..."; |
|
1254 | + if ($globalDebug) { |
|
1255 | + echo "Add to DB..."; |
|
1256 | + } |
|
1126 | 1257 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1127 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1258 | + } else { |
|
1259 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1260 | + } |
|
1128 | 1261 | if ($error != '') { |
1129 | 1262 | return $error; |
1130 | - } elseif ($globalDebug) echo "Done\n"; |
|
1263 | + } elseif ($globalDebug) { |
|
1264 | + echo "Done\n"; |
|
1265 | + } |
|
1131 | 1266 | return ''; |
1132 | 1267 | } |
1133 | 1268 | public static function update_ModeS() { |
@@ -1144,257 +1279,455 @@ discard block |
||
1144 | 1279 | exit; |
1145 | 1280 | } elseif ($globalDebug) echo "Done\n"; |
1146 | 1281 | */ |
1147 | - if ($globalDebug) echo "Modes : Download..."; |
|
1282 | + if ($globalDebug) { |
|
1283 | + echo "Modes : Download..."; |
|
1284 | + } |
|
1148 | 1285 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1149 | 1286 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1150 | - if ($globalDebug) echo "Unzip..."; |
|
1287 | + if ($globalDebug) { |
|
1288 | + echo "Unzip..."; |
|
1289 | + } |
|
1151 | 1290 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
1152 | - if ($globalDebug) echo "Add to DB..."; |
|
1291 | + if ($globalDebug) { |
|
1292 | + echo "Add to DB..."; |
|
1293 | + } |
|
1153 | 1294 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1154 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1295 | + } else { |
|
1296 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1297 | + } |
|
1155 | 1298 | if ($error != '') { |
1156 | 1299 | return $error; |
1157 | - } elseif ($globalDebug) echo "Done\n"; |
|
1300 | + } elseif ($globalDebug) { |
|
1301 | + echo "Done\n"; |
|
1302 | + } |
|
1158 | 1303 | return ''; |
1159 | 1304 | } |
1160 | 1305 | |
1161 | 1306 | public static function update_ModeS_flarm() { |
1162 | 1307 | global $tmp_dir, $globalDebug; |
1163 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1308 | + if ($globalDebug) { |
|
1309 | + echo "Modes Flarmnet: Download..."; |
|
1310 | + } |
|
1164 | 1311 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1165 | 1312 | if (file_exists($tmp_dir.'data.fln')) { |
1166 | - if ($globalDebug) echo "Add to DB..."; |
|
1313 | + if ($globalDebug) { |
|
1314 | + echo "Add to DB..."; |
|
1315 | + } |
|
1167 | 1316 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1168 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1317 | + } else { |
|
1318 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1319 | + } |
|
1169 | 1320 | if ($error != '') { |
1170 | 1321 | return $error; |
1171 | - } elseif ($globalDebug) echo "Done\n"; |
|
1322 | + } elseif ($globalDebug) { |
|
1323 | + echo "Done\n"; |
|
1324 | + } |
|
1172 | 1325 | return ''; |
1173 | 1326 | } |
1174 | 1327 | |
1175 | 1328 | public static function update_ModeS_ogn() { |
1176 | 1329 | global $tmp_dir, $globalDebug; |
1177 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1330 | + if ($globalDebug) { |
|
1331 | + echo "Modes OGN: Download..."; |
|
1332 | + } |
|
1178 | 1333 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1179 | 1334 | if (file_exists($tmp_dir.'ogn.csv')) { |
1180 | - if ($globalDebug) echo "Add to DB..."; |
|
1335 | + if ($globalDebug) { |
|
1336 | + echo "Add to DB..."; |
|
1337 | + } |
|
1181 | 1338 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1182 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1339 | + } else { |
|
1340 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1341 | + } |
|
1183 | 1342 | if ($error != '') { |
1184 | 1343 | return $error; |
1185 | - } elseif ($globalDebug) echo "Done\n"; |
|
1344 | + } elseif ($globalDebug) { |
|
1345 | + echo "Done\n"; |
|
1346 | + } |
|
1186 | 1347 | return ''; |
1187 | 1348 | } |
1188 | 1349 | |
1189 | 1350 | public static function update_owner() { |
1190 | 1351 | global $tmp_dir, $globalDebug; |
1191 | 1352 | |
1192 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1353 | + if ($globalDebug) { |
|
1354 | + echo "Owner France: Download..."; |
|
1355 | + } |
|
1193 | 1356 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1194 | 1357 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1195 | - if ($globalDebug) echo "Add to DB..."; |
|
1358 | + if ($globalDebug) { |
|
1359 | + echo "Add to DB..."; |
|
1360 | + } |
|
1196 | 1361 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1197 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1362 | + } else { |
|
1363 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1364 | + } |
|
1198 | 1365 | if ($error != '') { |
1199 | 1366 | return $error; |
1200 | - } elseif ($globalDebug) echo "Done\n"; |
|
1367 | + } elseif ($globalDebug) { |
|
1368 | + echo "Done\n"; |
|
1369 | + } |
|
1201 | 1370 | |
1202 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1371 | + if ($globalDebug) { |
|
1372 | + echo "Owner Ireland: Download..."; |
|
1373 | + } |
|
1203 | 1374 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1204 | 1375 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1205 | - if ($globalDebug) echo "Add to DB..."; |
|
1376 | + if ($globalDebug) { |
|
1377 | + echo "Add to DB..."; |
|
1378 | + } |
|
1206 | 1379 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1207 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1380 | + } else { |
|
1381 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1382 | + } |
|
1208 | 1383 | if ($error != '') { |
1209 | 1384 | return $error; |
1210 | - } elseif ($globalDebug) echo "Done\n"; |
|
1211 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1385 | + } elseif ($globalDebug) { |
|
1386 | + echo "Done\n"; |
|
1387 | + } |
|
1388 | + if ($globalDebug) { |
|
1389 | + echo "Owner Switzerland: Download..."; |
|
1390 | + } |
|
1212 | 1391 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1213 | 1392 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1214 | - if ($globalDebug) echo "Add to DB..."; |
|
1393 | + if ($globalDebug) { |
|
1394 | + echo "Add to DB..."; |
|
1395 | + } |
|
1215 | 1396 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1216 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1397 | + } else { |
|
1398 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1399 | + } |
|
1217 | 1400 | if ($error != '') { |
1218 | 1401 | return $error; |
1219 | - } elseif ($globalDebug) echo "Done\n"; |
|
1220 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
1402 | + } elseif ($globalDebug) { |
|
1403 | + echo "Done\n"; |
|
1404 | + } |
|
1405 | + if ($globalDebug) { |
|
1406 | + echo "Owner Czech Republic: Download..."; |
|
1407 | + } |
|
1221 | 1408 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1222 | 1409 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1223 | - if ($globalDebug) echo "Add to DB..."; |
|
1410 | + if ($globalDebug) { |
|
1411 | + echo "Add to DB..."; |
|
1412 | + } |
|
1224 | 1413 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1225 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1414 | + } else { |
|
1415 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1416 | + } |
|
1226 | 1417 | if ($error != '') { |
1227 | 1418 | return $error; |
1228 | - } elseif ($globalDebug) echo "Done\n"; |
|
1229 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
1419 | + } elseif ($globalDebug) { |
|
1420 | + echo "Done\n"; |
|
1421 | + } |
|
1422 | + if ($globalDebug) { |
|
1423 | + echo "Owner Australia: Download..."; |
|
1424 | + } |
|
1230 | 1425 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1231 | 1426 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1232 | - if ($globalDebug) echo "Add to DB..."; |
|
1427 | + if ($globalDebug) { |
|
1428 | + echo "Add to DB..."; |
|
1429 | + } |
|
1233 | 1430 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1234 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1431 | + } else { |
|
1432 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1433 | + } |
|
1235 | 1434 | if ($error != '') { |
1236 | 1435 | return $error; |
1237 | - } elseif ($globalDebug) echo "Done\n"; |
|
1238 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
1436 | + } elseif ($globalDebug) { |
|
1437 | + echo "Done\n"; |
|
1438 | + } |
|
1439 | + if ($globalDebug) { |
|
1440 | + echo "Owner Austria: Download..."; |
|
1441 | + } |
|
1239 | 1442 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1240 | 1443 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1241 | - if ($globalDebug) echo "Add to DB..."; |
|
1444 | + if ($globalDebug) { |
|
1445 | + echo "Add to DB..."; |
|
1446 | + } |
|
1242 | 1447 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1243 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1448 | + } else { |
|
1449 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1450 | + } |
|
1244 | 1451 | if ($error != '') { |
1245 | 1452 | return $error; |
1246 | - } elseif ($globalDebug) echo "Done\n"; |
|
1247 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
1453 | + } elseif ($globalDebug) { |
|
1454 | + echo "Done\n"; |
|
1455 | + } |
|
1456 | + if ($globalDebug) { |
|
1457 | + echo "Owner Chile: Download..."; |
|
1458 | + } |
|
1248 | 1459 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1249 | 1460 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1250 | - if ($globalDebug) echo "Add to DB..."; |
|
1461 | + if ($globalDebug) { |
|
1462 | + echo "Add to DB..."; |
|
1463 | + } |
|
1251 | 1464 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1252 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1465 | + } else { |
|
1466 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1467 | + } |
|
1253 | 1468 | if ($error != '') { |
1254 | 1469 | return $error; |
1255 | - } elseif ($globalDebug) echo "Done\n"; |
|
1256 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
1470 | + } elseif ($globalDebug) { |
|
1471 | + echo "Done\n"; |
|
1472 | + } |
|
1473 | + if ($globalDebug) { |
|
1474 | + echo "Owner Colombia: Download..."; |
|
1475 | + } |
|
1257 | 1476 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1258 | 1477 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1259 | - if ($globalDebug) echo "Add to DB..."; |
|
1478 | + if ($globalDebug) { |
|
1479 | + echo "Add to DB..."; |
|
1480 | + } |
|
1260 | 1481 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1261 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1482 | + } else { |
|
1483 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1484 | + } |
|
1262 | 1485 | if ($error != '') { |
1263 | 1486 | return $error; |
1264 | - } elseif ($globalDebug) echo "Done\n"; |
|
1265 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
1487 | + } elseif ($globalDebug) { |
|
1488 | + echo "Done\n"; |
|
1489 | + } |
|
1490 | + if ($globalDebug) { |
|
1491 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
1492 | + } |
|
1266 | 1493 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1267 | 1494 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1268 | - if ($globalDebug) echo "Add to DB..."; |
|
1495 | + if ($globalDebug) { |
|
1496 | + echo "Add to DB..."; |
|
1497 | + } |
|
1269 | 1498 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1270 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1499 | + } else { |
|
1500 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1501 | + } |
|
1271 | 1502 | if ($error != '') { |
1272 | 1503 | return $error; |
1273 | - } elseif ($globalDebug) echo "Done\n"; |
|
1274 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
1504 | + } elseif ($globalDebug) { |
|
1505 | + echo "Done\n"; |
|
1506 | + } |
|
1507 | + if ($globalDebug) { |
|
1508 | + echo "Owner Brazil: Download..."; |
|
1509 | + } |
|
1275 | 1510 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1276 | 1511 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1277 | - if ($globalDebug) echo "Add to DB..."; |
|
1512 | + if ($globalDebug) { |
|
1513 | + echo "Add to DB..."; |
|
1514 | + } |
|
1278 | 1515 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1279 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1516 | + } else { |
|
1517 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1518 | + } |
|
1280 | 1519 | if ($error != '') { |
1281 | 1520 | return $error; |
1282 | - } elseif ($globalDebug) echo "Done\n"; |
|
1283 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
1521 | + } elseif ($globalDebug) { |
|
1522 | + echo "Done\n"; |
|
1523 | + } |
|
1524 | + if ($globalDebug) { |
|
1525 | + echo "Owner Cayman Islands: Download..."; |
|
1526 | + } |
|
1284 | 1527 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1285 | 1528 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1286 | - if ($globalDebug) echo "Add to DB..."; |
|
1529 | + if ($globalDebug) { |
|
1530 | + echo "Add to DB..."; |
|
1531 | + } |
|
1287 | 1532 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1288 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1533 | + } else { |
|
1534 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1535 | + } |
|
1289 | 1536 | if ($error != '') { |
1290 | 1537 | return $error; |
1291 | - } elseif ($globalDebug) echo "Done\n"; |
|
1292 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
1538 | + } elseif ($globalDebug) { |
|
1539 | + echo "Done\n"; |
|
1540 | + } |
|
1541 | + if ($globalDebug) { |
|
1542 | + echo "Owner Croatia: Download..."; |
|
1543 | + } |
|
1293 | 1544 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1294 | 1545 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1295 | - if ($globalDebug) echo "Add to DB..."; |
|
1546 | + if ($globalDebug) { |
|
1547 | + echo "Add to DB..."; |
|
1548 | + } |
|
1296 | 1549 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1297 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1550 | + } else { |
|
1551 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1552 | + } |
|
1298 | 1553 | if ($error != '') { |
1299 | 1554 | return $error; |
1300 | - } elseif ($globalDebug) echo "Done\n"; |
|
1301 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
1555 | + } elseif ($globalDebug) { |
|
1556 | + echo "Done\n"; |
|
1557 | + } |
|
1558 | + if ($globalDebug) { |
|
1559 | + echo "Owner Luxembourg: Download..."; |
|
1560 | + } |
|
1302 | 1561 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1303 | 1562 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1304 | - if ($globalDebug) echo "Add to DB..."; |
|
1563 | + if ($globalDebug) { |
|
1564 | + echo "Add to DB..."; |
|
1565 | + } |
|
1305 | 1566 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1306 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1567 | + } else { |
|
1568 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1569 | + } |
|
1307 | 1570 | if ($error != '') { |
1308 | 1571 | return $error; |
1309 | - } elseif ($globalDebug) echo "Done\n"; |
|
1310 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
1572 | + } elseif ($globalDebug) { |
|
1573 | + echo "Done\n"; |
|
1574 | + } |
|
1575 | + if ($globalDebug) { |
|
1576 | + echo "Owner Maldives: Download..."; |
|
1577 | + } |
|
1311 | 1578 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1312 | 1579 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1313 | - if ($globalDebug) echo "Add to DB..."; |
|
1580 | + if ($globalDebug) { |
|
1581 | + echo "Add to DB..."; |
|
1582 | + } |
|
1314 | 1583 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1315 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1584 | + } else { |
|
1585 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1586 | + } |
|
1316 | 1587 | if ($error != '') { |
1317 | 1588 | return $error; |
1318 | - } elseif ($globalDebug) echo "Done\n"; |
|
1319 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
1589 | + } elseif ($globalDebug) { |
|
1590 | + echo "Done\n"; |
|
1591 | + } |
|
1592 | + if ($globalDebug) { |
|
1593 | + echo "Owner New Zealand: Download..."; |
|
1594 | + } |
|
1320 | 1595 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1321 | 1596 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1322 | - if ($globalDebug) echo "Add to DB..."; |
|
1597 | + if ($globalDebug) { |
|
1598 | + echo "Add to DB..."; |
|
1599 | + } |
|
1323 | 1600 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1324 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1601 | + } else { |
|
1602 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1603 | + } |
|
1325 | 1604 | if ($error != '') { |
1326 | 1605 | return $error; |
1327 | - } elseif ($globalDebug) echo "Done\n"; |
|
1328 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
1606 | + } elseif ($globalDebug) { |
|
1607 | + echo "Done\n"; |
|
1608 | + } |
|
1609 | + if ($globalDebug) { |
|
1610 | + echo "Owner Papua New Guinea: Download..."; |
|
1611 | + } |
|
1329 | 1612 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1330 | 1613 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1331 | - if ($globalDebug) echo "Add to DB..."; |
|
1614 | + if ($globalDebug) { |
|
1615 | + echo "Add to DB..."; |
|
1616 | + } |
|
1332 | 1617 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1333 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1618 | + } else { |
|
1619 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1620 | + } |
|
1334 | 1621 | if ($error != '') { |
1335 | 1622 | return $error; |
1336 | - } elseif ($globalDebug) echo "Done\n"; |
|
1337 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
1623 | + } elseif ($globalDebug) { |
|
1624 | + echo "Done\n"; |
|
1625 | + } |
|
1626 | + if ($globalDebug) { |
|
1627 | + echo "Owner Slovakia: Download..."; |
|
1628 | + } |
|
1338 | 1629 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1339 | 1630 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1340 | - if ($globalDebug) echo "Add to DB..."; |
|
1631 | + if ($globalDebug) { |
|
1632 | + echo "Add to DB..."; |
|
1633 | + } |
|
1341 | 1634 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1342 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1635 | + } else { |
|
1636 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1637 | + } |
|
1343 | 1638 | if ($error != '') { |
1344 | 1639 | return $error; |
1345 | - } elseif ($globalDebug) echo "Done\n"; |
|
1346 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
1640 | + } elseif ($globalDebug) { |
|
1641 | + echo "Done\n"; |
|
1642 | + } |
|
1643 | + if ($globalDebug) { |
|
1644 | + echo "Owner Ecuador: Download..."; |
|
1645 | + } |
|
1347 | 1646 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1348 | 1647 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1349 | - if ($globalDebug) echo "Add to DB..."; |
|
1648 | + if ($globalDebug) { |
|
1649 | + echo "Add to DB..."; |
|
1650 | + } |
|
1350 | 1651 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1351 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1652 | + } else { |
|
1653 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1654 | + } |
|
1352 | 1655 | if ($error != '') { |
1353 | 1656 | return $error; |
1354 | - } elseif ($globalDebug) echo "Done\n"; |
|
1355 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
1657 | + } elseif ($globalDebug) { |
|
1658 | + echo "Done\n"; |
|
1659 | + } |
|
1660 | + if ($globalDebug) { |
|
1661 | + echo "Owner Iceland: Download..."; |
|
1662 | + } |
|
1356 | 1663 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1357 | 1664 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1358 | - if ($globalDebug) echo "Add to DB..."; |
|
1665 | + if ($globalDebug) { |
|
1666 | + echo "Add to DB..."; |
|
1667 | + } |
|
1359 | 1668 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1360 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
1669 | + } else { |
|
1670 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
1671 | + } |
|
1361 | 1672 | if ($error != '') { |
1362 | 1673 | return $error; |
1363 | - } elseif ($globalDebug) echo "Done\n"; |
|
1674 | + } elseif ($globalDebug) { |
|
1675 | + echo "Done\n"; |
|
1676 | + } |
|
1364 | 1677 | return ''; |
1365 | 1678 | } |
1366 | 1679 | |
1367 | 1680 | public static function update_translation() { |
1368 | 1681 | global $tmp_dir, $globalDebug; |
1369 | 1682 | $error = ''; |
1370 | - if ($globalDebug) echo "Translation : Download..."; |
|
1683 | + if ($globalDebug) { |
|
1684 | + echo "Translation : Download..."; |
|
1685 | + } |
|
1371 | 1686 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1372 | 1687 | if (file_exists($tmp_dir.'translation.zip')) { |
1373 | - if ($globalDebug) echo "Unzip..."; |
|
1688 | + if ($globalDebug) { |
|
1689 | + echo "Unzip..."; |
|
1690 | + } |
|
1374 | 1691 | update_db::unzip($tmp_dir.'translation.zip'); |
1375 | - if ($globalDebug) echo "Add to DB..."; |
|
1692 | + if ($globalDebug) { |
|
1693 | + echo "Add to DB..."; |
|
1694 | + } |
|
1376 | 1695 | $error = update_db::translation(); |
1377 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
1696 | + } else { |
|
1697 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
1698 | + } |
|
1378 | 1699 | if ($error != '') { |
1379 | 1700 | return $error; |
1380 | - } elseif ($globalDebug) echo "Done\n"; |
|
1701 | + } elseif ($globalDebug) { |
|
1702 | + echo "Done\n"; |
|
1703 | + } |
|
1381 | 1704 | return ''; |
1382 | 1705 | } |
1383 | 1706 | |
1384 | 1707 | public static function update_translation_fam() { |
1385 | 1708 | global $tmp_dir, $globalDebug; |
1386 | 1709 | $error = ''; |
1387 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
1710 | + if ($globalDebug) { |
|
1711 | + echo "Translation from FlightAirMap website : Download..."; |
|
1712 | + } |
|
1388 | 1713 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1389 | 1714 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1390 | - if ($globalDebug) echo "Gunzip..."; |
|
1715 | + if ($globalDebug) { |
|
1716 | + echo "Gunzip..."; |
|
1717 | + } |
|
1391 | 1718 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1392 | - if ($globalDebug) echo "Add to DB..."; |
|
1719 | + if ($globalDebug) { |
|
1720 | + echo "Add to DB..."; |
|
1721 | + } |
|
1393 | 1722 | $error = update_db::translation_fam(); |
1394 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
1723 | + } else { |
|
1724 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
1725 | + } |
|
1395 | 1726 | if ($error != '') { |
1396 | 1727 | return $error; |
1397 | - } elseif ($globalDebug) echo "Done\n"; |
|
1728 | + } elseif ($globalDebug) { |
|
1729 | + echo "Done\n"; |
|
1730 | + } |
|
1398 | 1731 | return ''; |
1399 | 1732 | } |
1400 | 1733 | |
@@ -1437,7 +1770,9 @@ discard block |
||
1437 | 1770 | } |
1438 | 1771 | |
1439 | 1772 | $error = ''; |
1440 | - if ($globalDebug) echo "Notam : Download..."; |
|
1773 | + if ($globalDebug) { |
|
1774 | + echo "Notam : Download..."; |
|
1775 | + } |
|
1441 | 1776 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
1442 | 1777 | if (file_exists($tmp_dir.'notam.rss')) { |
1443 | 1778 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1452,14 +1787,30 @@ discard block |
||
1452 | 1787 | $data['fir'] = $q[0]; |
1453 | 1788 | $data['code'] = $q[1]; |
1454 | 1789 | $ifrvfr = $q[2]; |
1455 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
1456 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
1457 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
1458 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
1459 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
1460 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
1461 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
1462 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
1790 | + if ($ifrvfr == 'IV') { |
|
1791 | + $data['rules'] = 'IFR/VFR'; |
|
1792 | + } |
|
1793 | + if ($ifrvfr == 'I') { |
|
1794 | + $data['rules'] = 'IFR'; |
|
1795 | + } |
|
1796 | + if ($ifrvfr == 'V') { |
|
1797 | + $data['rules'] = 'VFR'; |
|
1798 | + } |
|
1799 | + if ($q[4] == 'A') { |
|
1800 | + $data['scope'] = 'Airport warning'; |
|
1801 | + } |
|
1802 | + if ($q[4] == 'E') { |
|
1803 | + $data['scope'] = 'Enroute warning'; |
|
1804 | + } |
|
1805 | + if ($q[4] == 'W') { |
|
1806 | + $data['scope'] = 'Navigation warning'; |
|
1807 | + } |
|
1808 | + if ($q[4] == 'AE') { |
|
1809 | + $data['scope'] = 'Airport/Enroute warning'; |
|
1810 | + } |
|
1811 | + if ($q[4] == 'AW') { |
|
1812 | + $data['scope'] = 'Airport/Navigation warning'; |
|
1813 | + } |
|
1463 | 1814 | //$data['scope'] = $q[4]; |
1464 | 1815 | $data['lower_limit'] = $q[5]; |
1465 | 1816 | $data['upper_limit'] = $q[6]; |
@@ -1467,8 +1818,12 @@ discard block |
||
1467 | 1818 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
1468 | 1819 | $latitude = $Common->convertDec($las,'latitude'); |
1469 | 1820 | $longitude = $Common->convertDec($lns,'longitude'); |
1470 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
1471 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
1821 | + if ($lac == 'S') { |
|
1822 | + $latitude = '-'.$latitude; |
|
1823 | + } |
|
1824 | + if ($lnc == 'W') { |
|
1825 | + $longitude = '-'.$longitude; |
|
1826 | + } |
|
1472 | 1827 | $data['center_latitude'] = $latitude; |
1473 | 1828 | $data['center_longitude'] = $longitude; |
1474 | 1829 | $data['radius'] = intval($radius); |
@@ -1498,10 +1853,14 @@ discard block |
||
1498 | 1853 | $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']); |
1499 | 1854 | unset($data); |
1500 | 1855 | } |
1501 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
1856 | + } else { |
|
1857 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
1858 | + } |
|
1502 | 1859 | if ($error != '') { |
1503 | 1860 | return $error; |
1504 | - } elseif ($globalDebug) echo "Done\n"; |
|
1861 | + } elseif ($globalDebug) { |
|
1862 | + echo "Done\n"; |
|
1863 | + } |
|
1505 | 1864 | return ''; |
1506 | 1865 | } |
1507 | 1866 | |
@@ -1520,8 +1879,11 @@ discard block |
||
1520 | 1879 | return "error : ".$e->getMessage(); |
1521 | 1880 | } |
1522 | 1881 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1523 | - if ($row['nb'] > 0) return false; |
|
1524 | - else return true; |
|
1882 | + if ($row['nb'] > 0) { |
|
1883 | + return false; |
|
1884 | + } else { |
|
1885 | + return true; |
|
1886 | + } |
|
1525 | 1887 | } |
1526 | 1888 | |
1527 | 1889 | public static function insert_last_update() { |
@@ -1551,8 +1913,11 @@ discard block |
||
1551 | 1913 | return "error : ".$e->getMessage(); |
1552 | 1914 | } |
1553 | 1915 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1554 | - if ($row['nb'] > 0) return false; |
|
1555 | - else return true; |
|
1916 | + if ($row['nb'] > 0) { |
|
1917 | + return false; |
|
1918 | + } else { |
|
1919 | + return true; |
|
1920 | + } |
|
1556 | 1921 | } |
1557 | 1922 | |
1558 | 1923 | public static function insert_last_notam_update() { |
@@ -1582,8 +1947,11 @@ discard block |
||
1582 | 1947 | return "error : ".$e->getMessage(); |
1583 | 1948 | } |
1584 | 1949 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1585 | - if ($row['nb'] > 0) return false; |
|
1586 | - else return true; |
|
1950 | + if ($row['nb'] > 0) { |
|
1951 | + return false; |
|
1952 | + } else { |
|
1953 | + return true; |
|
1954 | + } |
|
1587 | 1955 | } |
1588 | 1956 | |
1589 | 1957 | public static function insert_last_owner_update() { |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | curl_close($ch); |
24 | 24 | } |
25 | 25 | |
26 | - public static function gunzip($in_file,$out_file_name = '') { |
|
26 | + public static function gunzip($in_file, $out_file_name = '') { |
|
27 | 27 | //echo $in_file.' -> '.$out_file_name."\n"; |
28 | 28 | $buffer_size = 4096; // read 4kb at a time |
29 | 29 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
30 | 30 | if ($in_file != '' && file_exists($in_file)) { |
31 | 31 | // 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'); |
|
32 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
33 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
34 | 34 | $out_file = fopen($out_file_name, 'wb'); |
35 | - while(!gzeof($file)) { |
|
35 | + while (!gzeof($file)) { |
|
36 | 36 | fwrite($out_file, gzread($file, $buffer_size)); |
37 | 37 | } |
38 | 38 | fclose($out_file); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | try { |
57 | 57 | self::$db_sqlite = new PDO('sqlite:'.$database); |
58 | 58 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | return "error : ".$e->getMessage(); |
61 | 61 | } |
62 | 62 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | //$Connection = new Connection(); |
72 | 72 | $sth = $Connection->db->prepare($query); |
73 | 73 | $sth->execute(array(':source' => $database_file)); |
74 | - } catch(PDOException $e) { |
|
74 | + } catch (PDOException $e) { |
|
75 | 75 | return "error : ".$e->getMessage(); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | try { |
83 | 83 | $sth = update_db::$db_sqlite->prepare($query); |
84 | 84 | $sth->execute(); |
85 | - } catch(PDOException $e) { |
|
85 | + } catch (PDOException $e) { |
|
86 | 86 | return "error : ".$e->getMessage(); |
87 | 87 | } |
88 | 88 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | if ($globalTransaction) $Connection->db->beginTransaction(); |
94 | 94 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
95 | 95 | //$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 | - $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); |
|
96 | + $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 | 97 | $sth_dest->execute($query_dest_values); |
98 | 98 | } |
99 | 99 | if ($globalTransaction) $Connection->db->commit(); |
100 | - } catch(PDOException $e) { |
|
100 | + } catch (PDOException $e) { |
|
101 | 101 | if ($globalTransaction) $Connection->db->rollBack(); |
102 | 102 | return "error : ".$e->getMessage(); |
103 | 103 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $Connection = new Connection(); |
112 | 112 | $sth = $Connection->db->prepare($query); |
113 | 113 | $sth->execute(array(':source' => $database_file)); |
114 | - } catch(PDOException $e) { |
|
114 | + } catch (PDOException $e) { |
|
115 | 115 | return "error : ".$e->getMessage(); |
116 | 116 | } |
117 | 117 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | 121 | $sth->execute(array(':source' => $database_file)); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | try { |
129 | 129 | $sth = update_db::$db_sqlite->prepare($query); |
130 | 130 | $sth->execute(); |
131 | - } catch(PDOException $e) { |
|
131 | + } catch (PDOException $e) { |
|
132 | 132 | return "error : ".$e->getMessage(); |
133 | 133 | } |
134 | 134 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | //$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 | 146 | if ($values['UserString4'] == 'M') $type = 'military'; |
147 | 147 | else $type = null; |
148 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
148 | + $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 | 149 | $sth_dest->execute($query_dest_values); |
150 | 150 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
151 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
151 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
152 | 152 | $sth_dest_owner->execute($query_dest_owner_values); |
153 | 153 | } |
154 | 154 | } |
155 | 155 | if ($globalTransaction) $Connection->db->commit(); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return "error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $Connection = new Connection(); |
163 | 163 | $sth = $Connection->db->prepare($query); |
164 | 164 | $sth->execute(array(':source' => $database_file)); |
165 | - } catch(PDOException $e) { |
|
165 | + } catch (PDOException $e) { |
|
166 | 166 | return "error : ".$e->getMessage(); |
167 | 167 | } |
168 | 168 | return ''; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | $Connection = new Connection(); |
178 | 178 | $sth = $Connection->db->prepare($query); |
179 | 179 | $sth->execute(array(':source' => $database_file)); |
180 | - } catch(PDOException $e) { |
|
180 | + } catch (PDOException $e) { |
|
181 | 181 | return "error : ".$e->getMessage(); |
182 | 182 | } |
183 | 183 | |
184 | - if ($fh = fopen($database_file,"r")) { |
|
184 | + if ($fh = fopen($database_file, "r")) { |
|
185 | 185 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
186 | 186 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
187 | 187 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | try { |
191 | 191 | if ($globalTransaction) $Connection->db->beginTransaction(); |
192 | 192 | while (!feof($fh)) { |
193 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
193 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
194 | 194 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
195 | - $values['ModeS'] = substr($line,0,6); |
|
196 | - $values['Registration'] = trim(substr($line,69,6)); |
|
197 | - $aircraft_name = trim(substr($line,48,6)); |
|
195 | + $values['ModeS'] = substr($line, 0, 6); |
|
196 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
197 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
198 | 198 | // Check if we can find ICAO, else set it to GLID |
199 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
199 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
200 | 200 | $search_more = ''; |
201 | 201 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
202 | 202 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | if (isset($result['icao']) && $result['icao'] != '') { |
209 | 209 | $values['ICAOTypeCode'] = $result['icao']; |
210 | 210 | } |
211 | - } catch(PDOException $e) { |
|
211 | + } catch (PDOException $e) { |
|
212 | 212 | return "error : ".$e->getMessage(); |
213 | 213 | } |
214 | 214 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
215 | 215 | // Add data to db |
216 | 216 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
217 | 217 | //$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']); |
218 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
218 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
219 | 219 | //print_r($query_dest_values); |
220 | 220 | $sth_dest->execute($query_dest_values); |
221 | 221 | } |
222 | 222 | } |
223 | 223 | if ($globalTransaction) $Connection->db->commit(); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | return "error : ".$e->getMessage(); |
226 | 226 | } |
227 | 227 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $Connection = new Connection(); |
232 | 232 | $sth = $Connection->db->prepare($query); |
233 | 233 | $sth->execute(array(':source' => $database_file)); |
234 | - } catch(PDOException $e) { |
|
234 | + } catch (PDOException $e) { |
|
235 | 235 | return "error : ".$e->getMessage(); |
236 | 236 | } |
237 | 237 | return ''; |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | $Connection = new Connection(); |
246 | 246 | $sth = $Connection->db->prepare($query); |
247 | 247 | $sth->execute(array(':source' => $database_file)); |
248 | - } catch(PDOException $e) { |
|
248 | + } catch (PDOException $e) { |
|
249 | 249 | return "error : ".$e->getMessage(); |
250 | 250 | } |
251 | 251 | |
252 | - if ($fh = fopen($database_file,"r")) { |
|
252 | + if ($fh = fopen($database_file, "r")) { |
|
253 | 253 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
254 | 254 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
255 | 255 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | $sth_dest = $Connection->db->prepare($query_dest); |
258 | 258 | try { |
259 | 259 | if ($globalTransaction) $Connection->db->beginTransaction(); |
260 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
260 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
261 | 261 | while (!feof($fh)) { |
262 | - $line = fgetcsv($fh,9999,',',"'"); |
|
262 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
263 | 263 | |
264 | 264 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
265 | 265 | //print_r($line); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $values['Registration'] = $line[3]; |
268 | 268 | $aircraft_name = $line[2]; |
269 | 269 | // Check if we can find ICAO, else set it to GLID |
270 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
270 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
271 | 271 | $search_more = ''; |
272 | 272 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
273 | 273 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -276,20 +276,20 @@ discard block |
||
276 | 276 | $sth_search->execute(); |
277 | 277 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
278 | 278 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
279 | - } catch(PDOException $e) { |
|
279 | + } catch (PDOException $e) { |
|
280 | 280 | return "error : ".$e->getMessage(); |
281 | 281 | } |
282 | 282 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
283 | 283 | // Add data to db |
284 | 284 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
285 | 285 | //$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']); |
286 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
286 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
287 | 287 | //print_r($query_dest_values); |
288 | 288 | $sth_dest->execute($query_dest_values); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | if ($globalTransaction) $Connection->db->commit(); |
292 | - } catch(PDOException $e) { |
|
292 | + } catch (PDOException $e) { |
|
293 | 293 | return "error : ".$e->getMessage(); |
294 | 294 | } |
295 | 295 | } |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | $Connection = new Connection(); |
300 | 300 | $sth = $Connection->db->prepare($query); |
301 | 301 | $sth->execute(array(':source' => $database_file)); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | return ''; |
306 | 306 | } |
307 | 307 | |
308 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
308 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
309 | 309 | global $globalTransaction; |
310 | 310 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
311 | 311 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | $Connection = new Connection(); |
314 | 314 | $sth = $Connection->db->prepare($query); |
315 | 315 | $sth->execute(array(':source' => $database_file)); |
316 | - } catch(PDOException $e) { |
|
316 | + } catch (PDOException $e) { |
|
317 | 317 | return "error : ".$e->getMessage(); |
318 | 318 | } |
319 | 319 | |
320 | - if ($fh = fopen($database_file,"r")) { |
|
320 | + if ($fh = fopen($database_file, "r")) { |
|
321 | 321 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
322 | 322 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
323 | 323 | |
@@ -325,16 +325,16 @@ discard block |
||
325 | 325 | $sth_dest = $Connection->db->prepare($query_dest); |
326 | 326 | try { |
327 | 327 | if ($globalTransaction) $Connection->db->beginTransaction(); |
328 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
328 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
329 | 329 | while (!feof($fh)) { |
330 | - $line = fgetcsv($fh,9999,',','"'); |
|
330 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
331 | 331 | //print_r($line); |
332 | 332 | if ($country == 'F') { |
333 | 333 | $values['registration'] = $line[0]; |
334 | 334 | $values['base'] = $line[4]; |
335 | 335 | $values['owner'] = $line[5]; |
336 | 336 | if ($line[6] == '') $values['date_first_reg'] = ''; |
337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
337 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
338 | 338 | $values['cancel'] = $line[7]; |
339 | 339 | } elseif ($country == 'EI') { |
340 | 340 | // TODO : add modeS & reg to aircraft_modes |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $values['base'] = $line[3]; |
343 | 343 | $values['owner'] = $line[2]; |
344 | 344 | if ($line[1] == '') $values['date_first_reg'] = ''; |
345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
345 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
346 | 346 | $values['cancel'] = ''; |
347 | 347 | } elseif ($country == 'HB') { |
348 | 348 | // TODO : add modeS & reg to aircraft_modes |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $values['base'] = null; |
358 | 358 | $values['owner'] = $line[5]; |
359 | 359 | if ($line[18] == '') $values['date_first_reg'] = ''; |
360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
360 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
361 | 361 | $values['cancel'] = ''; |
362 | 362 | } elseif ($country == 'VH') { |
363 | 363 | // TODO : add modeS & reg to aircraft_modes |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $values['base'] = null; |
366 | 366 | $values['owner'] = $line[12]; |
367 | 367 | if ($line[28] == '') $values['date_first_reg'] = ''; |
368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
368 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
369 | 369 | |
370 | 370 | $values['cancel'] = $line[39]; |
371 | 371 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -385,28 +385,28 @@ discard block |
||
385 | 385 | $values['base'] = null; |
386 | 386 | $values['owner'] = $line[8]; |
387 | 387 | if ($line[7] == '') $values['date_first_reg'] = ''; |
388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
388 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
389 | 389 | $values['cancel'] = ''; |
390 | 390 | } elseif ($country == 'PP') { |
391 | 391 | $values['registration'] = $line[0]; |
392 | 392 | $values['base'] = null; |
393 | 393 | $values['owner'] = $line[4]; |
394 | 394 | if ($line[6] == '') $values['date_first_reg'] = ''; |
395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
395 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
396 | 396 | $values['cancel'] = $line[7]; |
397 | 397 | } elseif ($country == 'E7') { |
398 | 398 | $values['registration'] = $line[0]; |
399 | 399 | $values['base'] = null; |
400 | 400 | $values['owner'] = $line[4]; |
401 | 401 | if ($line[5] == '') $values['date_first_reg'] = ''; |
402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
402 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
403 | 403 | $values['cancel'] = ''; |
404 | 404 | } elseif ($country == '8Q') { |
405 | 405 | $values['registration'] = $line[0]; |
406 | 406 | $values['base'] = null; |
407 | 407 | $values['owner'] = $line[3]; |
408 | 408 | if ($line[7] == '') $values['date_first_reg'] = ''; |
409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
409 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
410 | 410 | $values['cancel'] = ''; |
411 | 411 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
412 | 412 | $values['registration'] = $line[0]; |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $values['cancel'] = ''; |
417 | 417 | } |
418 | 418 | if ($values['cancel'] == '' && $values['registration'] != null) { |
419 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
419 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
420 | 420 | $sth_dest->execute($query_dest_values); |
421 | 421 | } |
422 | 422 | } |
423 | 423 | if ($globalTransaction) $Connection->db->commit(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error : ".$e->getMessage(); |
426 | 426 | } |
427 | 427 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | $Connection = new Connection(); |
537 | 537 | $sth = $Connection->db->prepare($query); |
538 | 538 | $sth->execute(); |
539 | - } catch(PDOException $e) { |
|
539 | + } catch (PDOException $e) { |
|
540 | 540 | return "error : ".$e->getMessage(); |
541 | 541 | } |
542 | 542 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | $Connection = new Connection(); |
547 | 547 | $sth = $Connection->db->prepare($query); |
548 | 548 | $sth->execute(); |
549 | - } catch(PDOException $e) { |
|
549 | + } catch (PDOException $e) { |
|
550 | 550 | return "error : ".$e->getMessage(); |
551 | 551 | } |
552 | 552 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | if ($globalTransaction) $Connection->db->beginTransaction(); |
558 | 558 | |
559 | 559 | $i = 0; |
560 | - while($row = sparql_fetch_array($result)) |
|
560 | + while ($row = sparql_fetch_array($result)) |
|
561 | 561 | { |
562 | 562 | if ($i >= 1) { |
563 | 563 | //print_r($row); |
@@ -577,31 +577,31 @@ discard block |
||
577 | 577 | $row['image'] = ''; |
578 | 578 | $row['image_thumb'] = ''; |
579 | 579 | } else { |
580 | - $image = str_replace(' ','_',$row['image']); |
|
580 | + $image = str_replace(' ', '_', $row['image']); |
|
581 | 581 | $digest = md5($image); |
582 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
583 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
584 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
585 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
582 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
583 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
584 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
585 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
586 | 586 | } |
587 | 587 | |
588 | - $country = explode('-',$row['country']); |
|
588 | + $country = explode('-', $row['country']); |
|
589 | 589 | $row['country'] = $country[0]; |
590 | 590 | |
591 | 591 | $row['type'] = trim($row['type']); |
592 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
592 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
593 | 593 | $row['type'] = 'Military'; |
594 | 594 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
595 | 595 | $row['type'] = 'small_airport'; |
596 | 596 | } |
597 | 597 | |
598 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
599 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
598 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
599 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
600 | 600 | //print_r($query_dest_values); |
601 | 601 | |
602 | 602 | try { |
603 | 603 | $sth_dest->execute($query_dest_values); |
604 | - } catch(PDOException $e) { |
|
604 | + } catch (PDOException $e) { |
|
605 | 605 | return "error : ".$e->getMessage(); |
606 | 606 | } |
607 | 607 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | $Connection = new Connection(); |
616 | 616 | $sth = $Connection->db->prepare($query); |
617 | 617 | $sth->execute(); |
618 | - } catch(PDOException $e) { |
|
618 | + } catch (PDOException $e) { |
|
619 | 619 | return "error : ".$e->getMessage(); |
620 | 620 | } |
621 | 621 | |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
624 | 624 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
625 | 625 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
626 | - $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' => ''); |
|
626 | + $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' => ''); |
|
627 | 627 | try { |
628 | 628 | $Connection = new Connection(); |
629 | 629 | $sth = $Connection->db->prepare($query); |
630 | 630 | $sth->execute($query_values); |
631 | - } catch(PDOException $e) { |
|
631 | + } catch (PDOException $e) { |
|
632 | 632 | return "error : ".$e->getMessage(); |
633 | 633 | } |
634 | 634 | $i++; |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | echo "Download data from ourairports.com...\n"; |
647 | 647 | $delimiter = ','; |
648 | 648 | $out_file = $tmp_dir.'airports.csv'; |
649 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
649 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
650 | 650 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
651 | 651 | echo "Add data from ourairports.com...\n"; |
652 | 652 | |
@@ -657,32 +657,32 @@ discard block |
||
657 | 657 | //$Connection->db->beginTransaction(); |
658 | 658 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
659 | 659 | { |
660 | - if(!$header) $header = $row; |
|
660 | + if (!$header) $header = $row; |
|
661 | 661 | else { |
662 | 662 | $data = array(); |
663 | 663 | $data = array_combine($header, $row); |
664 | 664 | try { |
665 | 665 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
666 | 666 | $sth->execute(array(':icao' => $data['gps_code'])); |
667 | - } catch(PDOException $e) { |
|
667 | + } catch (PDOException $e) { |
|
668 | 668 | return "error : ".$e->getMessage(); |
669 | 669 | } |
670 | 670 | if ($sth->fetchColumn() > 0) { |
671 | 671 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
672 | 672 | try { |
673 | 673 | $sth = $Connection->db->prepare($query); |
674 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
675 | - } catch(PDOException $e) { |
|
674 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
675 | + } catch (PDOException $e) { |
|
676 | 676 | return "error : ".$e->getMessage(); |
677 | 677 | } |
678 | 678 | } else { |
679 | 679 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
680 | 680 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
681 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
681 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
682 | 682 | try { |
683 | 683 | $sth = $Connection->db->prepare($query); |
684 | 684 | $sth->execute($query_values); |
685 | - } catch(PDOException $e) { |
|
685 | + } catch (PDOException $e) { |
|
686 | 686 | return "error : ".$e->getMessage(); |
687 | 687 | } |
688 | 688 | $i++; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | |
696 | 696 | echo "Download data from another free database...\n"; |
697 | 697 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
698 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
698 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
699 | 699 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
700 | 700 | update_db::unzip($out_file); |
701 | 701 | $header = NULL; |
@@ -707,15 +707,15 @@ discard block |
||
707 | 707 | //$Connection->db->beginTransaction(); |
708 | 708 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
709 | 709 | { |
710 | - if(!$header) $header = $row; |
|
710 | + if (!$header) $header = $row; |
|
711 | 711 | else { |
712 | 712 | $data = $row; |
713 | 713 | |
714 | 714 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
715 | 715 | try { |
716 | 716 | $sth = $Connection->db->prepare($query); |
717 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
718 | - } catch(PDOException $e) { |
|
717 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
718 | + } catch (PDOException $e) { |
|
719 | 719 | return "error : ".$e->getMessage(); |
720 | 720 | } |
721 | 721 | } |
@@ -729,15 +729,15 @@ discard block |
||
729 | 729 | try { |
730 | 730 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
731 | 731 | $sth->execute(); |
732 | - } catch(PDOException $e) { |
|
732 | + } catch (PDOException $e) { |
|
733 | 733 | return "error : ".$e->getMessage(); |
734 | 734 | } |
735 | 735 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
736 | 736 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
737 | 737 | try { |
738 | 738 | $sth2 = $Connection->db->prepare($query2); |
739 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
740 | - } catch(PDOException $e) { |
|
739 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
740 | + } catch (PDOException $e) { |
|
741 | 741 | return "error : ".$e->getMessage(); |
742 | 742 | } |
743 | 743 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $Connection = new Connection(); |
762 | 762 | $sth = $Connection->db->prepare($query); |
763 | 763 | $sth->execute(array(':source' => 'translation.csv')); |
764 | - } catch(PDOException $e) { |
|
764 | + } catch (PDOException $e) { |
|
765 | 765 | return "error : ".$e->getMessage(); |
766 | 766 | } |
767 | 767 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
779 | 779 | { |
780 | 780 | $i++; |
781 | - if($i > 12) { |
|
781 | + if ($i > 12) { |
|
782 | 782 | $data = $row; |
783 | 783 | $operator = $data[2]; |
784 | 784 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | //echo substr($operator, 0, 2)."\n";; |
787 | 787 | if (count($airline_array) > 0) { |
788 | 788 | //print_r($airline_array); |
789 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
789 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
790 | 790 | } |
791 | 791 | } |
792 | 792 | |
@@ -794,14 +794,14 @@ discard block |
||
794 | 794 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
795 | 795 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
796 | 796 | if (count($airline_array) > 0) { |
797 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
797 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
801 | 801 | try { |
802 | 802 | $sth = $Connection->db->prepare($query); |
803 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
804 | - } catch(PDOException $e) { |
|
803 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
804 | + } catch (PDOException $e) { |
|
805 | 805 | return "error : ".$e->getMessage(); |
806 | 806 | } |
807 | 807 | } |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | $Connection = new Connection(); |
822 | 822 | $sth = $Connection->db->prepare($query); |
823 | 823 | $sth->execute(array(':source' => 'website_fam')); |
824 | - } catch(PDOException $e) { |
|
824 | + } catch (PDOException $e) { |
|
825 | 825 | return "error : ".$e->getMessage(); |
826 | 826 | } |
827 | 827 | |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
842 | 842 | try { |
843 | 843 | $sth = $Connection->db->prepare($query); |
844 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
845 | - } catch(PDOException $e) { |
|
844 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
845 | + } catch (PDOException $e) { |
|
846 | 846 | return "error : ".$e->getMessage(); |
847 | 847 | } |
848 | 848 | } |
@@ -861,28 +861,28 @@ discard block |
||
861 | 861 | */ |
862 | 862 | private static function table2array($data) { |
863 | 863 | $html = str_get_html($data); |
864 | - $tabledata=array(); |
|
865 | - foreach($html->find('tr') as $element) |
|
864 | + $tabledata = array(); |
|
865 | + foreach ($html->find('tr') as $element) |
|
866 | 866 | { |
867 | 867 | $td = array(); |
868 | - foreach( $element->find('th') as $row) |
|
868 | + foreach ($element->find('th') as $row) |
|
869 | 869 | { |
870 | 870 | $td [] = trim($row->plaintext); |
871 | 871 | } |
872 | - $td=array_filter($td); |
|
872 | + $td = array_filter($td); |
|
873 | 873 | $tabledata[] = $td; |
874 | 874 | |
875 | 875 | $td = array(); |
876 | 876 | $tdi = array(); |
877 | - foreach( $element->find('td') as $row) |
|
877 | + foreach ($element->find('td') as $row) |
|
878 | 878 | { |
879 | 879 | $td [] = trim($row->plaintext); |
880 | 880 | $tdi [] = trim($row->innertext); |
881 | 881 | } |
882 | - $td=array_filter($td); |
|
883 | - $tdi=array_filter($tdi); |
|
882 | + $td = array_filter($td); |
|
883 | + $tdi = array_filter($tdi); |
|
884 | 884 | // $tabledata[]=array_merge($td,$tdi); |
885 | - $tabledata[]=$td; |
|
885 | + $tabledata[] = $td; |
|
886 | 886 | } |
887 | 887 | return(array_filter($tabledata)); |
888 | 888 | } |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | $Connection = new Connection(); |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | 952 | $sth->execute(); |
953 | - } catch(PDOException $e) { |
|
953 | + } catch (PDOException $e) { |
|
954 | 954 | return "error : ".$e->getMessage(); |
955 | 955 | } |
956 | 956 | |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
967 | 967 | { |
968 | 968 | $i++; |
969 | - if($i > 3 && count($row) > 2) { |
|
969 | + if ($i > 3 && count($row) > 2) { |
|
970 | 970 | $data = array_values(array_filter($row)); |
971 | 971 | $cntdata = count($data); |
972 | 972 | if ($cntdata > 10) { |
973 | 973 | $value = $data[9]; |
974 | 974 | |
975 | - for ($i =10;$i < $cntdata;$i++) { |
|
975 | + for ($i = 10; $i < $cntdata; $i++) { |
|
976 | 976 | $value .= ' '.$data[$i]; |
977 | 977 | } |
978 | 978 | $data[9] = $value; |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
983 | 983 | try { |
984 | 984 | $sth = $Connection->db->prepare($query); |
985 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
986 | - } catch(PDOException $e) { |
|
985 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
986 | + } catch (PDOException $e) { |
|
987 | 987 | return "error : ".$e->getMessage(); |
988 | 988 | } |
989 | 989 | } |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | $Connection = new Connection(); |
1004 | 1004 | $sth = $Connection->db->prepare($query); |
1005 | 1005 | $sth->execute(); |
1006 | - } catch(PDOException $e) { |
|
1006 | + } catch (PDOException $e) { |
|
1007 | 1007 | return "error : ".$e->getMessage(); |
1008 | 1008 | } |
1009 | 1009 | |
@@ -1015,12 +1015,12 @@ discard block |
||
1015 | 1015 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1016 | 1016 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1017 | 1017 | { |
1018 | - if(count($row) > 1) { |
|
1018 | + if (count($row) > 1) { |
|
1019 | 1019 | $query = "INSERT INTO airlines (name,icao,active) VALUES (:name, :icao, 'Y')"; |
1020 | 1020 | try { |
1021 | 1021 | $sth = $Connection->db->prepare($query); |
1022 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1023 | - } catch(PDOException $e) { |
|
1022 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1023 | + } catch (PDOException $e) { |
|
1024 | 1024 | return "error : ".$e->getMessage(); |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1034,15 +1034,15 @@ discard block |
||
1034 | 1034 | public static function update_airspace() { |
1035 | 1035 | global $tmp_dir, $globalDBdriver; |
1036 | 1036 | include_once('class.create_db.php'); |
1037 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1037 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1038 | 1038 | else { |
1039 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1039 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1040 | 1040 | $query = "CREATE EXTENSION postgis"; |
1041 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1041 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1042 | 1042 | try { |
1043 | 1043 | $sth = $Connection->db->prepare($query); |
1044 | 1044 | $sth->execute(); |
1045 | - } catch(PDOException $e) { |
|
1045 | + } catch (PDOException $e) { |
|
1046 | 1046 | return "error : ".$e->getMessage(); |
1047 | 1047 | } |
1048 | 1048 | } |
@@ -1066,14 +1066,14 @@ discard block |
||
1066 | 1066 | try { |
1067 | 1067 | $sth = $Connection->db->prepare($query); |
1068 | 1068 | $sth->execute(); |
1069 | - } catch(PDOException $e) { |
|
1069 | + } catch (PDOException $e) { |
|
1070 | 1070 | echo "error : ".$e->getMessage(); |
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | if ($globalDBdriver == 'mysql') { |
1074 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1074 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1075 | 1075 | } else { |
1076 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1076 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1077 | 1077 | } |
1078 | 1078 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1079 | 1079 | return $error; |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1087 | 1087 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1088 | 1088 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1089 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1089 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1090 | 1090 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1091 | 1091 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1092 | 1092 | return $error; |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1107 | 1107 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1108 | 1108 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1109 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1109 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1110 | 1110 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1111 | 1111 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1112 | 1112 | if ($error != '') { |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | global $tmp_dir, $globalDebug; |
1120 | 1120 | $error = ''; |
1121 | 1121 | if ($globalDebug) echo "Routes : Download..."; |
1122 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1122 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1123 | 1123 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1124 | 1124 | if ($globalDebug) echo "Gunzip..."; |
1125 | 1125 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | } elseif ($globalDebug) echo "Done\n"; |
1147 | 1147 | */ |
1148 | 1148 | if ($globalDebug) echo "Modes : Download..."; |
1149 | - update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1149 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
1150 | 1150 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1151 | 1151 | if ($globalDebug) echo "Unzip..."; |
1152 | 1152 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | public static function update_ModeS_flarm() { |
1163 | 1163 | global $tmp_dir, $globalDebug; |
1164 | 1164 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1165 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1165 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1166 | 1166 | if (file_exists($tmp_dir.'data.fln')) { |
1167 | 1167 | if ($globalDebug) echo "Add to DB..."; |
1168 | 1168 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | public static function update_ModeS_ogn() { |
1177 | 1177 | global $tmp_dir, $globalDebug; |
1178 | 1178 | if ($globalDebug) echo "Modes OGN: Download..."; |
1179 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1179 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1180 | 1180 | if (file_exists($tmp_dir.'ogn.csv')) { |
1181 | 1181 | if ($globalDebug) echo "Add to DB..."; |
1182 | 1182 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1191,173 +1191,173 @@ discard block |
||
1191 | 1191 | global $tmp_dir, $globalDebug; |
1192 | 1192 | |
1193 | 1193 | if ($globalDebug) echo "Owner France: Download..."; |
1194 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1194 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1195 | 1195 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1196 | 1196 | if ($globalDebug) echo "Add to DB..."; |
1197 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1197 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1198 | 1198 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1199 | 1199 | if ($error != '') { |
1200 | 1200 | return $error; |
1201 | 1201 | } elseif ($globalDebug) echo "Done\n"; |
1202 | 1202 | |
1203 | 1203 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1204 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1204 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1205 | 1205 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1206 | 1206 | if ($globalDebug) echo "Add to DB..."; |
1207 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1207 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1208 | 1208 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1209 | 1209 | if ($error != '') { |
1210 | 1210 | return $error; |
1211 | 1211 | } elseif ($globalDebug) echo "Done\n"; |
1212 | 1212 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1213 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1213 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1214 | 1214 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1215 | 1215 | if ($globalDebug) echo "Add to DB..."; |
1216 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1216 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1217 | 1217 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1218 | 1218 | if ($error != '') { |
1219 | 1219 | return $error; |
1220 | 1220 | } elseif ($globalDebug) echo "Done\n"; |
1221 | 1221 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1222 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1222 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1223 | 1223 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1224 | 1224 | if ($globalDebug) echo "Add to DB..."; |
1225 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1225 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1226 | 1226 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1227 | 1227 | if ($error != '') { |
1228 | 1228 | return $error; |
1229 | 1229 | } elseif ($globalDebug) echo "Done\n"; |
1230 | 1230 | if ($globalDebug) echo "Owner Australia: Download..."; |
1231 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1231 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1232 | 1232 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1233 | 1233 | if ($globalDebug) echo "Add to DB..."; |
1234 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1234 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1235 | 1235 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1236 | 1236 | if ($error != '') { |
1237 | 1237 | return $error; |
1238 | 1238 | } elseif ($globalDebug) echo "Done\n"; |
1239 | 1239 | if ($globalDebug) echo "Owner Austria: Download..."; |
1240 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1240 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1241 | 1241 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1242 | 1242 | if ($globalDebug) echo "Add to DB..."; |
1243 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1243 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1244 | 1244 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1245 | 1245 | if ($error != '') { |
1246 | 1246 | return $error; |
1247 | 1247 | } elseif ($globalDebug) echo "Done\n"; |
1248 | 1248 | if ($globalDebug) echo "Owner Chile: Download..."; |
1249 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1249 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1250 | 1250 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1251 | 1251 | if ($globalDebug) echo "Add to DB..."; |
1252 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1252 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1253 | 1253 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1254 | 1254 | if ($error != '') { |
1255 | 1255 | return $error; |
1256 | 1256 | } elseif ($globalDebug) echo "Done\n"; |
1257 | 1257 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1258 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1258 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1259 | 1259 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1260 | 1260 | if ($globalDebug) echo "Add to DB..."; |
1261 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1261 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1262 | 1262 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1263 | 1263 | if ($error != '') { |
1264 | 1264 | return $error; |
1265 | 1265 | } elseif ($globalDebug) echo "Done\n"; |
1266 | 1266 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1267 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1267 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1268 | 1268 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1269 | 1269 | if ($globalDebug) echo "Add to DB..."; |
1270 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1270 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1271 | 1271 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1272 | 1272 | if ($error != '') { |
1273 | 1273 | return $error; |
1274 | 1274 | } elseif ($globalDebug) echo "Done\n"; |
1275 | 1275 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1276 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1276 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1277 | 1277 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1278 | 1278 | if ($globalDebug) echo "Add to DB..."; |
1279 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1279 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1280 | 1280 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1281 | 1281 | if ($error != '') { |
1282 | 1282 | return $error; |
1283 | 1283 | } elseif ($globalDebug) echo "Done\n"; |
1284 | 1284 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1285 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1285 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1286 | 1286 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1287 | 1287 | if ($globalDebug) echo "Add to DB..."; |
1288 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1288 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1289 | 1289 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1290 | 1290 | if ($error != '') { |
1291 | 1291 | return $error; |
1292 | 1292 | } elseif ($globalDebug) echo "Done\n"; |
1293 | 1293 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1294 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1294 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1295 | 1295 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1296 | 1296 | if ($globalDebug) echo "Add to DB..."; |
1297 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1297 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1298 | 1298 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1299 | 1299 | if ($error != '') { |
1300 | 1300 | return $error; |
1301 | 1301 | } elseif ($globalDebug) echo "Done\n"; |
1302 | 1302 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1303 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1303 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1304 | 1304 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1305 | 1305 | if ($globalDebug) echo "Add to DB..."; |
1306 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1306 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1307 | 1307 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1308 | 1308 | if ($error != '') { |
1309 | 1309 | return $error; |
1310 | 1310 | } elseif ($globalDebug) echo "Done\n"; |
1311 | 1311 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1312 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1312 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1313 | 1313 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1314 | 1314 | if ($globalDebug) echo "Add to DB..."; |
1315 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1315 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1316 | 1316 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1317 | 1317 | if ($error != '') { |
1318 | 1318 | return $error; |
1319 | 1319 | } elseif ($globalDebug) echo "Done\n"; |
1320 | 1320 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1321 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1321 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1322 | 1322 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1323 | 1323 | if ($globalDebug) echo "Add to DB..."; |
1324 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1324 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1325 | 1325 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1326 | 1326 | if ($error != '') { |
1327 | 1327 | return $error; |
1328 | 1328 | } elseif ($globalDebug) echo "Done\n"; |
1329 | 1329 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1330 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1330 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1331 | 1331 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1332 | 1332 | if ($globalDebug) echo "Add to DB..."; |
1333 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1333 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1334 | 1334 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1335 | 1335 | if ($error != '') { |
1336 | 1336 | return $error; |
1337 | 1337 | } elseif ($globalDebug) echo "Done\n"; |
1338 | 1338 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1339 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1339 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1340 | 1340 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1341 | 1341 | if ($globalDebug) echo "Add to DB..."; |
1342 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1342 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1343 | 1343 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1344 | 1344 | if ($error != '') { |
1345 | 1345 | return $error; |
1346 | 1346 | } elseif ($globalDebug) echo "Done\n"; |
1347 | 1347 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1348 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1348 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1349 | 1349 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1350 | 1350 | if ($globalDebug) echo "Add to DB..."; |
1351 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1351 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1352 | 1352 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1353 | 1353 | if ($error != '') { |
1354 | 1354 | return $error; |
1355 | 1355 | } elseif ($globalDebug) echo "Done\n"; |
1356 | 1356 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1357 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1357 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1358 | 1358 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1359 | 1359 | if ($globalDebug) echo "Add to DB..."; |
1360 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1360 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1361 | 1361 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1362 | 1362 | if ($error != '') { |
1363 | 1363 | return $error; |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | global $tmp_dir, $globalDebug; |
1370 | 1370 | $error = ''; |
1371 | 1371 | if ($globalDebug) echo "Translation : Download..."; |
1372 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1372 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1373 | 1373 | if (file_exists($tmp_dir.'translation.zip')) { |
1374 | 1374 | if ($globalDebug) echo "Unzip..."; |
1375 | 1375 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1386,7 +1386,7 @@ discard block |
||
1386 | 1386 | global $tmp_dir, $globalDebug; |
1387 | 1387 | $error = ''; |
1388 | 1388 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1389 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1389 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1390 | 1390 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1391 | 1391 | if ($globalDebug) echo "Gunzip..."; |
1392 | 1392 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | */ |
1415 | 1415 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1416 | 1416 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
1417 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1418 | - $result = fread($fh,100000000); |
|
1417 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
1418 | + $result = fread($fh, 100000000); |
|
1419 | 1419 | //echo $result; |
1420 | 1420 | //var_dump(str_get_html($result)); |
1421 | 1421 | //print_r(self::table2array($result)); |
@@ -1433,23 +1433,23 @@ discard block |
||
1433 | 1433 | $Connection = new Connection(); |
1434 | 1434 | $sth = $Connection->db->prepare($query); |
1435 | 1435 | $sth->execute(); |
1436 | - } catch(PDOException $e) { |
|
1436 | + } catch (PDOException $e) { |
|
1437 | 1437 | return "error : ".$e->getMessage(); |
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | $error = ''; |
1441 | 1441 | if ($globalDebug) echo "Notam : Download..."; |
1442 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
1442 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
1443 | 1443 | if (file_exists($tmp_dir.'notam.rss')) { |
1444 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
1444 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
1445 | 1445 | foreach ($notams['channel']['item'] as $notam) { |
1446 | - $title = explode(':',$notam['title']); |
|
1446 | + $title = explode(':', $notam['title']); |
|
1447 | 1447 | $data['ref'] = trim($title[0]); |
1448 | 1448 | unset($title[0]); |
1449 | - $data['title'] = trim(implode(':',$title)); |
|
1450 | - $description = strip_tags($notam['description'],'<pre>'); |
|
1451 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
1452 | - $q = explode('/',$match[1]); |
|
1449 | + $data['title'] = trim(implode(':', $title)); |
|
1450 | + $description = strip_tags($notam['description'], '<pre>'); |
|
1451 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
1452 | + $q = explode('/', $match[1]); |
|
1453 | 1453 | $data['fir'] = $q[0]; |
1454 | 1454 | $data['code'] = $q[1]; |
1455 | 1455 | $ifrvfr = $q[2]; |
@@ -1465,30 +1465,30 @@ discard block |
||
1465 | 1465 | $data['lower_limit'] = $q[5]; |
1466 | 1466 | $data['upper_limit'] = $q[6]; |
1467 | 1467 | $latlonrad = $q[7]; |
1468 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
1469 | - $latitude = $Common->convertDec($las,'latitude'); |
|
1470 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
1468 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
1469 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
1470 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
1471 | 1471 | if ($lac == 'S') $latitude = '-'.$latitude; |
1472 | 1472 | if ($lnc == 'W') $longitude = '-'.$longitude; |
1473 | 1473 | $data['center_latitude'] = $latitude; |
1474 | 1474 | $data['center_longitude'] = $longitude; |
1475 | 1475 | $data['radius'] = intval($radius); |
1476 | 1476 | |
1477 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
1477 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
1478 | 1478 | $data['text'] = $match[1]; |
1479 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
1479 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
1480 | 1480 | $fromto = $match[1]; |
1481 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
1481 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
1482 | 1482 | $fromall = trim($match[1]); |
1483 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
1483 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
1484 | 1484 | $from = trim($match[1]); |
1485 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
1486 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
1485 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
1486 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
1487 | 1487 | $toall = trim($match[1]); |
1488 | - if (!preg_match(':Permanent:',$toall)) { |
|
1489 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
1488 | + if (!preg_match(':Permanent:', $toall)) { |
|
1489 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
1490 | 1490 | $to = trim($match[1]); |
1491 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
1491 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
1492 | 1492 | $data['permanent'] = 0; |
1493 | 1493 | } else { |
1494 | 1494 | $data['date_end'] = NULL; |
@@ -1496,7 +1496,7 @@ discard block |
||
1496 | 1496 | } |
1497 | 1497 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1498 | 1498 | $NOTAM = new NOTAM(); |
1499 | - $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']); |
|
1499 | + $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 | 1500 | unset($data); |
1501 | 1501 | } |
1502 | 1502 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | $Connection = new Connection(); |
1518 | 1518 | $sth = $Connection->db->prepare($query); |
1519 | 1519 | $sth->execute(); |
1520 | - } catch(PDOException $e) { |
|
1520 | + } catch (PDOException $e) { |
|
1521 | 1521 | return "error : ".$e->getMessage(); |
1522 | 1522 | } |
1523 | 1523 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | $Connection = new Connection(); |
1533 | 1533 | $sth = $Connection->db->prepare($query); |
1534 | 1534 | $sth->execute(); |
1535 | - } catch(PDOException $e) { |
|
1535 | + } catch (PDOException $e) { |
|
1536 | 1536 | return "error : ".$e->getMessage(); |
1537 | 1537 | } |
1538 | 1538 | } |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | $Connection = new Connection(); |
1549 | 1549 | $sth = $Connection->db->prepare($query); |
1550 | 1550 | $sth->execute(); |
1551 | - } catch(PDOException $e) { |
|
1551 | + } catch (PDOException $e) { |
|
1552 | 1552 | return "error : ".$e->getMessage(); |
1553 | 1553 | } |
1554 | 1554 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | $Connection = new Connection(); |
1564 | 1564 | $sth = $Connection->db->prepare($query); |
1565 | 1565 | $sth->execute(); |
1566 | - } catch(PDOException $e) { |
|
1566 | + } catch (PDOException $e) { |
|
1567 | 1567 | return "error : ".$e->getMessage(); |
1568 | 1568 | } |
1569 | 1569 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | $Connection = new Connection(); |
1580 | 1580 | $sth = $Connection->db->prepare($query); |
1581 | 1581 | $sth->execute(); |
1582 | - } catch(PDOException $e) { |
|
1582 | + } catch (PDOException $e) { |
|
1583 | 1583 | return "error : ".$e->getMessage(); |
1584 | 1584 | } |
1585 | 1585 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | $Connection = new Connection(); |
1595 | 1595 | $sth = $Connection->db->prepare($query); |
1596 | 1596 | $sth->execute(); |
1597 | - } catch(PDOException $e) { |
|
1597 | + } catch (PDOException $e) { |
|
1598 | 1598 | return "error : ".$e->getMessage(); |
1599 | 1599 | } |
1600 | 1600 | } |
@@ -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; |
@@ -10,37 +10,37 @@ discard block |
||
10 | 10 | |
11 | 11 | # to document: CGIParams |
12 | 12 | |
13 | -function sparql_connect( $endpoint ) { return new sparql_connection( $endpoint ); } |
|
13 | +function sparql_connect($endpoint) { return new sparql_connection($endpoint); } |
|
14 | 14 | |
15 | -function sparql_ns( $short, $long, $db = null ) { return _sparql_a_connection( $db )->ns( $short, $long ); } |
|
16 | -function sparql_query( $sparql, $db = null ) { return _sparql_a_connection( $db )->query( $sparql ); } |
|
17 | -function sparql_errno( $db = null ) { return _sparql_a_connection( $db )->errno(); } |
|
18 | -function sparql_error( $db = null ) { return _sparql_a_connection( $db )->error(); } |
|
15 | +function sparql_ns($short, $long, $db = null) { return _sparql_a_connection($db)->ns($short, $long); } |
|
16 | +function sparql_query($sparql, $db = null) { return _sparql_a_connection($db)->query($sparql); } |
|
17 | +function sparql_errno($db = null) { return _sparql_a_connection($db)->errno(); } |
|
18 | +function sparql_error($db = null) { return _sparql_a_connection($db)->error(); } |
|
19 | 19 | |
20 | -function sparql_fetch_array( $result ) { return $result->fetch_array(); } |
|
21 | -function sparql_num_rows( $result ) { return $result->num_rows(); } |
|
22 | -function sparql_field_array( $result ) { return $result->field_array(); } |
|
23 | -function sparql_field_name( $result, $i ) { return $result->field_name( $i ); } |
|
20 | +function sparql_fetch_array($result) { return $result->fetch_array(); } |
|
21 | +function sparql_num_rows($result) { return $result->num_rows(); } |
|
22 | +function sparql_field_array($result) { return $result->field_array(); } |
|
23 | +function sparql_field_name($result, $i) { return $result->field_name($i); } |
|
24 | 24 | |
25 | -function sparql_fetch_all( $result ) { return $result->fetch_all(); } |
|
25 | +function sparql_fetch_all($result) { return $result->fetch_all(); } |
|
26 | 26 | |
27 | -function sparql_get( $endpoint, $sparql ) |
|
27 | +function sparql_get($endpoint, $sparql) |
|
28 | 28 | { |
29 | - $db = sparql_connect( $endpoint ); |
|
30 | - if( !$db ) { return; } |
|
31 | - $result = $db->query( $sparql ); |
|
32 | - if( !$result ) { return; } |
|
29 | + $db = sparql_connect($endpoint); |
|
30 | + if (!$db) { return; } |
|
31 | + $result = $db->query($sparql); |
|
32 | + if (!$result) { return; } |
|
33 | 33 | return $result->fetch_all(); |
34 | 34 | } |
35 | 35 | |
36 | -function _sparql_a_connection( $db ) |
|
36 | +function _sparql_a_connection($db) |
|
37 | 37 | { |
38 | 38 | global $sparql_last_connection; |
39 | - if( !isset( $db ) ) |
|
39 | + if (!isset($db)) |
|
40 | 40 | { |
41 | - if( !isset( $sparql_last_connection ) ) |
|
41 | + if (!isset($sparql_last_connection)) |
|
42 | 42 | { |
43 | - print( "No currect SPARQL connection (connection) in play!" ); |
|
43 | + print("No currect SPARQL connection (connection) in play!"); |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | $db = $sparql_last_connection; |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | var $params = null; |
63 | 63 | # capabilities are either true, false or null if not yet tested. |
64 | 64 | |
65 | - function __construct( $endpoint ) |
|
65 | + function __construct($endpoint) |
|
66 | 66 | { |
67 | 67 | $this->endpoint = $endpoint; |
68 | 68 | global $sparql_last_connection; |
69 | 69 | $sparql_last_connection = $this; |
70 | 70 | } |
71 | 71 | |
72 | - function ns( $short, $long ) |
|
72 | + function ns($short, $long) |
|
73 | 73 | { |
74 | 74 | $this->ns[$short] = $long; |
75 | 75 | } |
@@ -77,77 +77,77 @@ discard block |
||
77 | 77 | function errno() { return $this->errno; } |
78 | 78 | function error() { return $this->error; } |
79 | 79 | |
80 | - function cgiParams( $params = null ) |
|
80 | + function cgiParams($params = null) |
|
81 | 81 | { |
82 | - if( $params === null ) { return $this->params; } |
|
83 | - if( $params === "" ) { $this->params = null; return; } |
|
82 | + if ($params === null) { return $this->params; } |
|
83 | + if ($params === "") { $this->params = null; return; } |
|
84 | 84 | $this->params = $params; |
85 | 85 | } |
86 | 86 | |
87 | - function query( $query, $timeout=null ) |
|
87 | + function query($query, $timeout = null) |
|
88 | 88 | { |
89 | 89 | $prefixes = ""; |
90 | - foreach( $this->ns as $k=>$v ) |
|
90 | + foreach ($this->ns as $k=>$v) |
|
91 | 91 | { |
92 | 92 | $prefixes .= "PREFIX $k: <$v>\n"; |
93 | 93 | } |
94 | - $output = $this->dispatchQuery( $prefixes.$query, $timeout ); |
|
95 | - if( $this->errno ) { return; } |
|
94 | + $output = $this->dispatchQuery($prefixes.$query, $timeout); |
|
95 | + if ($this->errno) { return; } |
|
96 | 96 | $parser = new xx_xml($output, 'contents'); |
97 | - if( $parser->error() ) |
|
97 | + if ($parser->error()) |
|
98 | 98 | { |
99 | 99 | $this->errno = -1; # to not clash with CURLOPT return; } |
100 | 100 | $this->error = $parser->error(); |
101 | 101 | return; |
102 | 102 | } |
103 | - return new sparql_result( $this, $parser->rows, $parser->fields ); |
|
103 | + return new sparql_result($this, $parser->rows, $parser->fields); |
|
104 | 104 | } |
105 | 105 | |
106 | - function alive( $timeout=3 ) |
|
106 | + function alive($timeout = 3) |
|
107 | 107 | { |
108 | - $result = $this->query( "SELECT * WHERE { ?s ?p ?o } LIMIT 1", $timeout ); |
|
108 | + $result = $this->query("SELECT * WHERE { ?s ?p ?o } LIMIT 1", $timeout); |
|
109 | 109 | |
110 | - if( $this->errno ) { return false; } |
|
110 | + if ($this->errno) { return false; } |
|
111 | 111 | |
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | |
115 | - function dispatchQuery( $sparql, $timeout=null ) |
|
115 | + function dispatchQuery($sparql, $timeout = null) |
|
116 | 116 | { |
117 | - $url = $this->endpoint."?query=".urlencode( $sparql ); |
|
118 | - if( $this->params !== null ) |
|
117 | + $url = $this->endpoint."?query=".urlencode($sparql); |
|
118 | + if ($this->params !== null) |
|
119 | 119 | { |
120 | 120 | $url .= "&".$this->params; |
121 | 121 | } |
122 | - if( $this->debug ) { print "<div class='debug'><a href='".htmlspecialchars($url)."'>".htmlspecialchars($prefixes.$query)."</a></div>\n"; } |
|
122 | + if ($this->debug) { print "<div class='debug'><a href='".htmlspecialchars($url)."'>".htmlspecialchars($prefixes.$query)."</a></div>\n"; } |
|
123 | 123 | $this->errno = null; |
124 | 124 | $this->error = null; |
125 | 125 | $ch = curl_init($url); |
126 | 126 | #curl_setopt($ch, CURLOPT_HEADER, 1); |
127 | - if( $timeout !== null ) |
|
127 | + if ($timeout !== null) |
|
128 | 128 | { |
129 | - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ); |
|
129 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
130 | 130 | } |
131 | 131 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
132 | - curl_setopt($ch, CURLOPT_HTTPHEADER,array ( |
|
132 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
133 | 133 | "Accept: application/sparql-results+xml" |
134 | 134 | )); |
135 | 135 | |
136 | 136 | $output = curl_exec($ch); |
137 | 137 | $info = curl_getinfo($ch); |
138 | - if(curl_errno($ch)) |
|
138 | + if (curl_errno($ch)) |
|
139 | 139 | { |
140 | - $this->errno = curl_errno( $ch ); |
|
141 | - $this->error = 'Curl error: ' . curl_error($ch); |
|
140 | + $this->errno = curl_errno($ch); |
|
141 | + $this->error = 'Curl error: '.curl_error($ch); |
|
142 | 142 | return; |
143 | 143 | } |
144 | - if( $output === '' ) |
|
144 | + if ($output === '') |
|
145 | 145 | { |
146 | 146 | $this->errno = "-1"; |
147 | 147 | $this->error = 'URL returned no data'; |
148 | 148 | return; |
149 | 149 | } |
150 | - if( $info['http_code'] != 200) |
|
150 | + if ($info['http_code'] != 200) |
|
151 | 151 | { |
152 | 152 | $this->errno = $info['http_code']; |
153 | 153 | $this->error = 'Bad response, '.$info['http_code'].': '.$output; |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | |
180 | 180 | var $caps_cache; |
181 | 181 | var $caps_anysubject; |
182 | - function capabilityCache( $filename, $dba_type='db4' ) |
|
182 | + function capabilityCache($filename, $dba_type = 'db4') |
|
183 | 183 | { |
184 | - $this->caps_cache = dba_open($filename, "c", $dba_type ); |
|
184 | + $this->caps_cache = dba_open($filename, "c", $dba_type); |
|
185 | 185 | } |
186 | 186 | function capabilityCodes() |
187 | 187 | { |
188 | - return array_keys( $this->caps_desc ); |
|
188 | + return array_keys($this->caps_desc); |
|
189 | 189 | } |
190 | 190 | function capabilityDescription($code) |
191 | 191 | { |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | |
195 | 195 | # return true if the endpoint supports a capability |
196 | 196 | # nb. returns false if connecion isn't authoriased to use the feature, eg LOAD |
197 | - function supports( $code ) |
|
197 | + function supports($code) |
|
198 | 198 | { |
199 | - if( isset( $this->caps[$code] ) ) { return $this->caps[$code]; } |
|
199 | + if (isset($this->caps[$code])) { return $this->caps[$code]; } |
|
200 | 200 | $was_cached = false; |
201 | - if( isset( $this->caps_cache ) ) |
|
201 | + if (isset($this->caps_cache)) |
|
202 | 202 | { |
203 | 203 | $CACHE_TIMEOUT_SECONDS = 7*24*60*60; |
204 | 204 | $db_key = $this->endpoint.";".$code; |
205 | - $db_val = dba_fetch( $db_key, $this->caps_cache ); |
|
206 | - if( $db_val !== false ) |
|
205 | + $db_val = dba_fetch($db_key, $this->caps_cache); |
|
206 | + if ($db_val !== false) |
|
207 | 207 | { |
208 | - list( $result, $when ) = preg_split( '/;/', $db_val ); |
|
209 | - if( $when + $CACHE_TIMEOUT_SECONDS > time() ) |
|
208 | + list($result, $when) = preg_split('/;/', $db_val); |
|
209 | + if ($when + $CACHE_TIMEOUT_SECONDS > time()) |
|
210 | 210 | { |
211 | 211 | return $result; |
212 | 212 | } |
@@ -215,26 +215,26 @@ 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(); } |
|
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 | 225 | else { print "<p>Unknown capability code: '$code'</p>"; return false; } |
226 | 226 | $this->caps[$code] = $r; |
227 | - if( isset( $this->caps_cache ) ) |
|
227 | + if (isset($this->caps_cache)) |
|
228 | 228 | { |
229 | 229 | $db_key = $this->endpoint.";".$code; |
230 | 230 | $db_val = $r.";".time(); |
231 | - if( $was_cached ) |
|
231 | + if ($was_cached) |
|
232 | 232 | { |
233 | - dba_replace( $db_key, $db_val, $this->caps_cache ); |
|
233 | + dba_replace($db_key, $db_val, $this->caps_cache); |
|
234 | 234 | } |
235 | 235 | else |
236 | 236 | { |
237 | - dba_insert( $db_key, $db_val, $this->caps_cache ); |
|
237 | + dba_insert($db_key, $db_val, $this->caps_cache); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | return $r; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | |
243 | 243 | function anySubject() |
244 | 244 | { |
245 | - if( !isset( $this->caps_anysubject ) ) |
|
245 | + if (!isset($this->caps_anysubject)) |
|
246 | 246 | { |
247 | 247 | $results = $this->query( |
248 | 248 | "SELECT * WHERE { ?s ?p ?o } LIMIT 1" ); |
249 | - if( sizeof($results)) |
|
249 | + if (sizeof($results)) |
|
250 | 250 | { |
251 | 251 | $row = $results->fetch_array(); |
252 | 252 | $this->caps_anysubject = $row["s"]; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | { |
261 | 261 | $output = $this->dispatchQuery( |
262 | 262 | "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 1" ); |
263 | - return !isset( $this->errno ); |
|
263 | + return !isset($this->errno); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | # return true if the endpoint supports AS |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $output = $this->dispatchQuery( |
270 | 270 | "SELECT (1+2 AS ?bar) WHERE { ?s ?p ?o } LIMIT 1" ); |
271 | - return !isset( $this->errno ); |
|
271 | + return !isset($this->errno); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | # return true if the endpoint supports AS |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | { |
277 | 277 | $output = $this->dispatchQuery( |
278 | 278 | "SELECT (\"foo\" AS ?bar) WHERE { ?s ?p ?o } LIMIT 1" ); |
279 | - return !isset( $this->errno ); |
|
279 | + return !isset($this->errno); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | # return true if the endpoint supports SELECT (COUNT(?x) as ?n) ... GROUP BY |
@@ -284,35 +284,35 @@ discard block |
||
284 | 284 | { |
285 | 285 | # assumes at least one rdf:type predicate |
286 | 286 | $s = $this->anySubject(); |
287 | - if( !isset($s) ) { return false; } |
|
287 | + if (!isset($s)) { return false; } |
|
288 | 288 | $output = $this->dispatchQuery( |
289 | 289 | "SELECT (COUNT(?p) AS ?n) ?o WHERE { <$s> ?p ?o } GROUP BY ?o" ); |
290 | - return !isset( $this->errno ); |
|
290 | + return !isset($this->errno); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | function test_max() |
294 | 294 | { |
295 | 295 | $s = $this->anySubject(); |
296 | - if( !isset($s) ) { return false; } |
|
296 | + if (!isset($s)) { return false; } |
|
297 | 297 | $output = $this->dispatchQuery( |
298 | 298 | "SELECT (MAX(?p) AS ?max) ?o WHERE { <$s> ?p ?o } GROUP BY ?o" ); |
299 | - return !isset( $this->errno ); |
|
299 | + return !isset($this->errno); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | function test_sample() |
303 | 303 | { |
304 | 304 | $s = $this->anySubject(); |
305 | - if( !isset($s) ) { return false; } |
|
305 | + if (!isset($s)) { return false; } |
|
306 | 306 | $output = $this->dispatchQuery( |
307 | 307 | "SELECT (SAMPLE(?p) AS ?sam) ?o WHERE { <$s> ?p ?o } GROUP BY ?o" ); |
308 | - return !isset( $this->errno ); |
|
308 | + return !isset($this->errno); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | function test_load() |
312 | 312 | { |
313 | 313 | $output = $this->dispatchQuery( |
314 | 314 | "LOAD <http://graphite.ecs.soton.ac.uk/sparqllib/examples/loadtest.rdf>" ); |
315 | - return !isset( $this->errno ); |
|
315 | + return !isset($this->errno); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | var $fields; |
325 | 325 | var $db; |
326 | 326 | var $i = 0; |
327 | - function __construct( $db, $rows, $fields ) |
|
327 | + function __construct($db, $rows, $fields) |
|
328 | 328 | { |
329 | 329 | $this->rows = $rows; |
330 | 330 | $this->fields = $fields; |
@@ -333,17 +333,17 @@ discard block |
||
333 | 333 | |
334 | 334 | function fetch_array() |
335 | 335 | { |
336 | - if( !@$this->rows[$this->i] ) { return; } |
|
336 | + if (!@$this->rows[$this->i]) { return; } |
|
337 | 337 | $r = array(); |
338 | - foreach( $this->rows[$this->i++] as $k=>$v ) |
|
338 | + foreach ($this->rows[$this->i++] as $k=>$v) |
|
339 | 339 | { |
340 | 340 | $r[$k] = $v["value"]; |
341 | 341 | $r["$k.type"] = $v["type"]; |
342 | - if( isset( $v["language"] ) ) |
|
342 | + if (isset($v["language"])) |
|
343 | 343 | { |
344 | 344 | $r["$k.language"] = $v["language"]; |
345 | 345 | } |
346 | - if( isset( $v["datatype"] ) ) |
|
346 | + if (isset($v["datatype"])) |
|
347 | 347 | { |
348 | 348 | $r["$k.datatype"] = $v["datatype"]; |
349 | 349 | } |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | { |
356 | 356 | $r = new sparql_results(); |
357 | 357 | $r->fields = $this->fields; |
358 | - foreach( $this->rows as $i=>$row ) |
|
358 | + foreach ($this->rows as $i=>$row) |
|
359 | 359 | { |
360 | - $r []= $this->fetch_array(); |
|
360 | + $r [] = $this->fetch_array(); |
|
361 | 361 | } |
362 | 362 | return $r; |
363 | 363 | } |
364 | 364 | |
365 | 365 | function num_rows() |
366 | 366 | { |
367 | - return sizeof( $this->rows ); |
|
367 | + return sizeof($this->rows); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | function field_array() |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | var $type; |
401 | 401 | |
402 | 402 | // function with the default parameter value |
403 | - function xx_xml($url='http://www.opocot.com', $type='url') { |
|
403 | + function xx_xml($url = 'http://www.opocot.com', $type = 'url') { |
|
404 | 404 | $this->type = $type; |
405 | 405 | $this->url = $url; |
406 | 406 | $this->parse(); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $this->rows = array(); |
415 | 415 | $this->fields = array(); |
416 | 416 | $data = ''; |
417 | - $this->parser = xml_parser_create ("UTF-8"); |
|
417 | + $this->parser = xml_parser_create("UTF-8"); |
|
418 | 418 | xml_set_object($this->parser, $this); |
419 | 419 | xml_set_element_handler($this->parser, 'startXML', 'endXML'); |
420 | 420 | xml_set_character_data_handler($this->parser, 'charXML'); |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | } else if ($this->type == 'contents') { |
440 | 440 | // Now we can pass the contents, maybe if you want |
441 | 441 | // to use CURL, SOCK or other method. |
442 | - $lines = explode("\n",$this->url); |
|
442 | + $lines = explode("\n", $this->url); |
|
443 | 443 | foreach ($lines as $val) { |
444 | - $data = $val . "\n"; |
|
444 | + $data = $val."\n"; |
|
445 | 445 | if (!xml_parse($this->parser, $data)) { |
446 | 446 | $this->error = $data."\n".sprintf('XML error at line %d column %d', |
447 | 447 | xml_get_current_line_number($this->parser), |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | - if( !$this->looks_legit ) |
|
453 | + if (!$this->looks_legit) |
|
454 | 454 | { |
455 | 455 | $this->error = "Didn't even see a sparql element, is this really an endpoint?"; |
456 | 456 | } |
@@ -458,53 +458,53 @@ discard block |
||
458 | 458 | |
459 | 459 | function startXML($parser, $name, $attr) |
460 | 460 | { |
461 | - if( $name == "sparql" ) { $this->looks_legit = true; } |
|
462 | - if( $name == "result" ) |
|
461 | + if ($name == "sparql") { $this->looks_legit = true; } |
|
462 | + if ($name == "result") |
|
463 | 463 | { |
464 | 464 | $this->result = array(); |
465 | 465 | } |
466 | - if( $name == "binding" ) |
|
466 | + if ($name == "binding") |
|
467 | 467 | { |
468 | 468 | $this->part = $attr["name"]; |
469 | 469 | } |
470 | - if( $name == "uri" || $name == "bnode" ) |
|
470 | + if ($name == "uri" || $name == "bnode") |
|
471 | 471 | { |
472 | 472 | $this->part_type = $name; |
473 | 473 | $this->chars = ""; |
474 | 474 | } |
475 | - if( $name == "literal" ) |
|
475 | + if ($name == "literal") |
|
476 | 476 | { |
477 | 477 | $this->part_type = "literal"; |
478 | - if( isset( $attr["datatype"] ) ) |
|
478 | + if (isset($attr["datatype"])) |
|
479 | 479 | { |
480 | 480 | $this->part_datatype = $attr["datatype"]; |
481 | 481 | } |
482 | - if( isset( $attr["xml:lang"] ) ) |
|
482 | + if (isset($attr["xml:lang"])) |
|
483 | 483 | { |
484 | 484 | $this->part_lang = $attr["xml:lang"]; |
485 | 485 | } |
486 | 486 | $this->chars = ""; |
487 | 487 | } |
488 | - if( $name == "variable" ) |
|
488 | + if ($name == "variable") |
|
489 | 489 | { |
490 | 490 | $this->fields[] = $attr["name"]; |
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | - function endXML($parser, $name) { |
|
495 | - if( $name == "result" ) |
|
494 | + function endXML($parser, $name) { |
|
495 | + if ($name == "result") |
|
496 | 496 | { |
497 | 497 | $this->rows[] = $this->result; |
498 | 498 | $this->result = array(); |
499 | 499 | } |
500 | - if( $name == "uri" || $name == "bnode" || $name == "literal" ) |
|
500 | + if ($name == "uri" || $name == "bnode" || $name == "literal") |
|
501 | 501 | { |
502 | - $this->result[$this->part] = array( "type"=>$name, "value"=>$this->chars ); |
|
503 | - if( isset( $this->part_lang ) ) |
|
502 | + $this->result[$this->part] = array("type"=>$name, "value"=>$this->chars); |
|
503 | + if (isset($this->part_lang)) |
|
504 | 504 | { |
505 | 505 | $this->result[$this->part]["lang"] = $this->part_lang; |
506 | 506 | } |
507 | - if( isset( $this->part_datatype ) ) |
|
507 | + if (isset($this->part_datatype)) |
|
508 | 508 | { |
509 | 509 | $this->result[$this->part]["datatype"] = $this->part_datatype; |
510 | 510 | } |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | - function charXML($parser, $data) { |
|
516 | + function charXML($parser, $data) { |
|
517 | 517 | @$this->chars .= $data; |
518 | 518 | } |
519 | 519 | |
@@ -527,28 +527,28 @@ discard block |
||
527 | 527 | function render_table() |
528 | 528 | { |
529 | 529 | $html = "<table class='sparql-results'><tr>"; |
530 | - foreach( $this->fields as $i=>$field ) |
|
530 | + foreach ($this->fields as $i=>$field) |
|
531 | 531 | { |
532 | 532 | $html .= "<th>?$field</th>"; |
533 | 533 | } |
534 | 534 | $html .= "</tr>"; |
535 | - foreach( $this as $row ) |
|
535 | + foreach ($this as $row) |
|
536 | 536 | { |
537 | - $html.="<tr>"; |
|
538 | - foreach( $row as $cell ) |
|
537 | + $html .= "<tr>"; |
|
538 | + foreach ($row as $cell) |
|
539 | 539 | { |
540 | - $html .= "<td>".htmlspecialchars( $cell )."</td>"; |
|
540 | + $html .= "<td>".htmlspecialchars($cell)."</td>"; |
|
541 | 541 | } |
542 | - $html.="</tr>"; |
|
542 | + $html .= "</tr>"; |
|
543 | 543 | } |
544 | - $html.="</table> |
|
544 | + $html .= "</table> |
|
545 | 545 | <style> |
546 | 546 | table.sparql-results { border-collapse: collapse; } |
547 | 547 | table.sparql-results tr td { border: solid 1px #000 ; padding:4px;vertical-align:top} |
548 | 548 | table.sparql-results tr th { border: solid 1px #000 ; padding:4px;vertical-align:top ; background-color:#eee;} |
549 | 549 | </style> |
550 | 550 | "; |
551 | - return $html;exit; |
|
551 | + return $html; exit; |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | } |
@@ -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); |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | $this->SI = new SpotterImport($this->db); |
17 | 17 | } |
18 | 18 | /** |
19 | - * Change IATA to ICAO value for ident |
|
20 | - * |
|
21 | - * @param String $ident ident |
|
22 | - * @return String the icao |
|
23 | - */ |
|
19 | + * Change IATA to ICAO value for ident |
|
20 | + * |
|
21 | + * @param String $ident ident |
|
22 | + * @return String the icao |
|
23 | + */ |
|
24 | 24 | public function ident2icao($ident) { |
25 | 25 | if (substr($ident,0,2) == 'AF') { |
26 | 26 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * Deletes all info in the live table |
|
40 | - * |
|
41 | - * @return String success or false |
|
42 | - * |
|
43 | - */ |
|
39 | + * Deletes all info in the live table |
|
40 | + * |
|
41 | + * @return String success or false |
|
42 | + * |
|
43 | + */ |
|
44 | 44 | public function deleteLiveAcarsData() |
45 | 45 | { |
46 | 46 | global $globalDBdriver; |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * Deletes all info in the archive table |
|
64 | - * |
|
65 | - * @return String success or false |
|
66 | - * |
|
67 | - */ |
|
63 | + * Deletes all info in the archive table |
|
64 | + * |
|
65 | + * @return String success or false |
|
66 | + * |
|
67 | + */ |
|
68 | 68 | public function deleteArchiveAcarsData() |
69 | 69 | { |
70 | 70 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | /** |
88 | - * Parse ACARS data |
|
89 | - * |
|
90 | - * @param String ACARS data in acarsdec data |
|
91 | - * |
|
92 | - */ |
|
88 | + * Parse ACARS data |
|
89 | + * |
|
90 | + * @param String ACARS data in acarsdec data |
|
91 | + * |
|
92 | + */ |
|
93 | 93 | function parse($data) { |
94 | 94 | global $globalDebug, $globalACARSArchive; |
95 | 95 | $Image = new Image($this->db); |
@@ -660,11 +660,11 @@ discard block |
||
660 | 660 | |
661 | 661 | |
662 | 662 | /** |
663 | - * Add ACARS data |
|
664 | - * |
|
665 | - * @param String ACARS data in acarsdec data |
|
666 | - * |
|
667 | - */ |
|
663 | + * Add ACARS data |
|
664 | + * |
|
665 | + * @param String ACARS data in acarsdec data |
|
666 | + * |
|
667 | + */ |
|
668 | 668 | function add($data) { |
669 | 669 | global $globalDebug, $globalACARSArchive; |
670 | 670 | $Image = new Image($this->db); |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | - * Add Live ACARS data in DB |
|
723 | - * |
|
724 | - * @param String $ident ident |
|
725 | - * @param String $registration Registration of the aircraft |
|
726 | - * @param String $label Label of the ACARS message |
|
727 | - * @param String $block_id Block id of the ACARS message |
|
728 | - * @param String $msg_no Number of the ACARS message |
|
729 | - * @param String $message ACARS message |
|
730 | - */ |
|
722 | + * Add Live ACARS data in DB |
|
723 | + * |
|
724 | + * @param String $ident ident |
|
725 | + * @param String $registration Registration of the aircraft |
|
726 | + * @param String $label Label of the ACARS message |
|
727 | + * @param String $block_id Block id of the ACARS message |
|
728 | + * @param String $msg_no Number of the ACARS message |
|
729 | + * @param String $message ACARS message |
|
730 | + */ |
|
731 | 731 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
732 | 732 | global $globalDebug; |
733 | 733 | date_default_timezone_set('UTC'); |
@@ -765,15 +765,15 @@ discard block |
||
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
768 | - * Add Archive ACARS data in DB |
|
769 | - * |
|
770 | - * @param String $ident ident |
|
771 | - * @param String $registration Registration of the aircraft |
|
772 | - * @param String $label Label of the ACARS message |
|
773 | - * @param String $block_id Block id of the ACARS message |
|
774 | - * @param String $msg_no Number of the ACARS message |
|
775 | - * @param String $message ACARS message |
|
776 | - */ |
|
768 | + * Add Archive ACARS data in DB |
|
769 | + * |
|
770 | + * @param String $ident ident |
|
771 | + * @param String $registration Registration of the aircraft |
|
772 | + * @param String $label Label of the ACARS message |
|
773 | + * @param String $block_id Block id of the ACARS message |
|
774 | + * @param String $msg_no Number of the ACARS message |
|
775 | + * @param String $message ACARS message |
|
776 | + */ |
|
777 | 777 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
778 | 778 | global $globalDebug; |
779 | 779 | date_default_timezone_set('UTC'); |
@@ -807,11 +807,11 @@ discard block |
||
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
810 | - * Get Message title from label from DB |
|
811 | - * |
|
812 | - * @param String $ident |
|
813 | - * @return Array Return ACARS data in array |
|
814 | - */ |
|
810 | + * Get Message title from label from DB |
|
811 | + * |
|
812 | + * @param String $ident |
|
813 | + * @return Array Return ACARS data in array |
|
814 | + */ |
|
815 | 815 | public function getTitlefromLabel($label) { |
816 | 816 | $Connection = new Connection($this->db); |
817 | 817 | $this->db = $Connection->db; |
@@ -830,10 +830,10 @@ discard block |
||
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
833 | - * List all Message title & label from DB |
|
834 | - * |
|
835 | - * @return Array Return ACARS data in array |
|
836 | - */ |
|
833 | + * List all Message title & label from DB |
|
834 | + * |
|
835 | + * @return Array Return ACARS data in array |
|
836 | + */ |
|
837 | 837 | public function getAllTitleLabel() { |
838 | 838 | $query = "SELECT * FROM acars_label ORDER BY title"; |
839 | 839 | $query_values = array(); |
@@ -850,11 +850,11 @@ discard block |
||
850 | 850 | } |
851 | 851 | |
852 | 852 | /** |
853 | - * Get Live ACARS data from DB |
|
854 | - * |
|
855 | - * @param String $ident |
|
856 | - * @return Array Return ACARS data in array |
|
857 | - */ |
|
853 | + * Get Live ACARS data from DB |
|
854 | + * |
|
855 | + * @param String $ident |
|
856 | + * @return Array Return ACARS data in array |
|
857 | + */ |
|
858 | 858 | public function getLiveAcarsData($ident) { |
859 | 859 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
860 | 860 | $query_values = array(':ident' => $ident); |
@@ -871,10 +871,10 @@ discard block |
||
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
874 | - * Get Latest ACARS data from DB |
|
875 | - * |
|
876 | - * @return Array Return ACARS data in array |
|
877 | - */ |
|
874 | + * Get Latest ACARS data from DB |
|
875 | + * |
|
876 | + * @return Array Return ACARS data in array |
|
877 | + */ |
|
878 | 878 | public function getLatestAcarsData($limit = '',$label = '') { |
879 | 879 | global $globalURL, $globalDBdriver; |
880 | 880 | $Image = new Image($this->db); |
@@ -972,10 +972,10 @@ discard block |
||
972 | 972 | } |
973 | 973 | |
974 | 974 | /** |
975 | - * Get Archive ACARS data from DB |
|
976 | - * |
|
977 | - * @return Array Return ACARS data in array |
|
978 | - */ |
|
975 | + * Get Archive ACARS data from DB |
|
976 | + * |
|
977 | + * @return Array Return ACARS data in array |
|
978 | + */ |
|
979 | 979 | public function getArchiveAcarsData($limit = '',$label = '') { |
980 | 980 | global $globalURL, $globalDBdriver; |
981 | 981 | $Image = new Image($this->db); |
@@ -1077,13 +1077,13 @@ discard block |
||
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /** |
1080 | - * Add ModeS data to DB |
|
1081 | - * |
|
1082 | - * @param String $ident ident |
|
1083 | - * @param String $registration Registration of the aircraft |
|
1084 | - * @param String $icao |
|
1085 | - * @param String $ICAOTypeCode |
|
1086 | - */ |
|
1080 | + * Add ModeS data to DB |
|
1081 | + * |
|
1082 | + * @param String $ident ident |
|
1083 | + * @param String $registration Registration of the aircraft |
|
1084 | + * @param String $icao |
|
1085 | + * @param String $ICAOTypeCode |
|
1086 | + */ |
|
1087 | 1087 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
1088 | 1088 | global $globalDebug, $globalDBdriver; |
1089 | 1089 | $ident = trim($ident); |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * @return String the icao |
23 | 23 | */ |
24 | 24 | public function ident2icao($ident) { |
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'); |
|
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'); |
|
28 | 28 | } else { |
29 | 29 | $Spotter = new Spotter($this->db); |
30 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
30 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
31 | 31 | if (isset($identicao[0])) { |
32 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
32 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
33 | 33 | } else $icao = $ident; |
34 | 34 | } |
35 | 35 | return $icao; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | $sth = $this->db->prepare($query); |
55 | 55 | $sth->execute(); |
56 | - } catch(PDOException $e) { |
|
56 | + } catch (PDOException $e) { |
|
57 | 57 | return "error"; |
58 | 58 | } |
59 | 59 | return "success"; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $sth = $this->db->prepare($query); |
79 | 79 | $sth->execute(); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error"; |
82 | 82 | } |
83 | 83 | return "success"; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | $Schedule = new Schedule($this->db); |
97 | 97 | $Translation = new Translation($this->db); |
98 | 98 | |
99 | - $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); |
|
99 | + $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); |
|
101 | 101 | if ($n != 0) { |
102 | - $registration = str_replace('.','',$registration); |
|
103 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
102 | + $registration = str_replace('.', '', $registration); |
|
103 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
104 | 104 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
105 | 105 | } else $message = $data; |
106 | 106 | $icao = ''; |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | //$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%*11[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $temp); |
115 | 115 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
116 | 116 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
117 | - $latitude = $la / 10000.0; |
|
118 | - $longitude = $ln / 10000.0; |
|
117 | + $latitude = $la/10000.0; |
|
118 | + $longitude = $ln/10000.0; |
|
119 | 119 | if ($lac == 'S') $latitude = '-'.$latitude; |
120 | 120 | if ($lnc == 'W') $longitude = '-'.$longitude; |
121 | 121 | // Temp not always available |
122 | 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'); |
|
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'); |
|
125 | 125 | |
126 | 126 | //$icao = $Translation->checkTranslation($ident); |
127 | 127 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -129,19 +129,19 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | if (!$found && ($label == '10')) { |
132 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
132 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
133 | 133 | 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"; |
|
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"; |
|
137 | 137 | //$icao = ACARS->ident2icao($ident); |
138 | 138 | //$icao = $Translation->checkTranslation($ident); |
139 | 139 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
140 | 140 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
141 | 141 | $found = true; |
142 | 142 | } |
143 | - elseif ($n == 2 || $n == 4) { |
|
144 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
143 | + elseif ($n == 2 || $n == 4) { |
|
144 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
145 | 145 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
146 | 146 | //$icao = ACARS->ident2icao($ident); |
147 | 147 | //$icao = $Translation->checkTranslation($ident); |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | */ |
190 | 190 | |
191 | 191 | //$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 | - $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); |
|
192 | + $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 | 193 | 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); |
|
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); |
|
197 | 197 | $icao = trim($aident); |
198 | 198 | |
199 | 199 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
214 | 214 | $las = $las.'.'.$lass; |
215 | 215 | $lns = $lns.'.'.$lns; |
216 | - $latitude = $las / 1000.0; |
|
217 | - $longitude = $lns / 1000.0; |
|
216 | + $latitude = $las/1000.0; |
|
217 | + $longitude = $lns/1000.0; |
|
218 | 218 | if ($lac == 'S') $latitude = '-'.$latitude; |
219 | 219 | if ($lnc == 'W') $longitude = '-'.$longitude; |
220 | 220 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | RMK/FUEL 2.6 M0.79) |
292 | 292 | */ |
293 | 293 | //$n = sscanf($message, "#DFB(POS-%s -%4d%c%5d%c/%*d F%d\nRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
294 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
294 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
295 | 295 | if ($n == 9) { |
296 | 296 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
297 | 297 | $icao = trim($aident); |
298 | 298 | $decode['icao'] = $icao; |
299 | - $latitude = $las / 100.0; |
|
300 | - $longitude = $lns / 100.0; |
|
299 | + $latitude = $las/100.0; |
|
300 | + $longitude = $lns/100.0; |
|
301 | 301 | if ($lac == 'S') $latitude = '-'.$latitude; |
302 | 302 | if ($lnc == 'W') $longitude = '-'.$longitude; |
303 | 303 | |
304 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
304 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
305 | 305 | $found = true; |
306 | 306 | } |
307 | 307 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | if ($lac == 'S') $latitude = '-'.$latitude; |
317 | 317 | if ($lnc == 'W') $longitude = '-'.$longitude; |
318 | 318 | |
319 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
319 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
320 | 320 | $found = true; |
321 | 321 | } |
322 | 322 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | DABNK,10100, 7100,02:46, 200, 44068,52.4, 77000, 62500, 66000,3, 4, |
345 | 345 | */ |
346 | 346 | // $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 | - $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); |
|
347 | + $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 | 348 | if ($n == 8) { |
349 | 349 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
350 | 350 | $icao = trim($aident); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | /* example message : |
374 | 374 | LFLLLFRS1315U2687X |
375 | 375 | */ |
376 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
376 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
377 | 377 | if ($n == 3) { |
378 | 378 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
379 | 379 | //$icao = $Translation->checkTranslation($ident); |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | /* example message : |
388 | 388 | 3J01 DSPTCH 7503/01 LFTH/LFPO .F-HMLF |
389 | 389 | */ |
390 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
390 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
391 | 391 | if ($n == 3) { |
392 | 392 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
393 | 393 | //$icao = $Translation->checkTranslation($ident); |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | } |
399 | 399 | } |
400 | 400 | if (!$found) { |
401 | - $n = sscanf($message,'MET01%4c',$airport); |
|
401 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
402 | 402 | if ($n == 1) { |
403 | 403 | if ($globalDebug) echo 'airport name : '.$airport; |
404 | 404 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -407,241 +407,241 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | if ($label == 'H1') { |
410 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
411 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
410 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
411 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
412 | 412 | } |
413 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
414 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
413 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
414 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
415 | 415 | } |
416 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
417 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
416 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
417 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
418 | 418 | } |
419 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
420 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
419 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
420 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
421 | 421 | } |
422 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
423 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
422 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
423 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
424 | 424 | } |
425 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
426 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
425 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
426 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
427 | 427 | } |
428 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
429 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
428 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
429 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
430 | 430 | } |
431 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
432 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
431 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
432 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
433 | 433 | } |
434 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
435 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
434 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
435 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
436 | 436 | } |
437 | - elseif (preg_match(':^#CF:',$message)) { |
|
438 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
437 | + elseif (preg_match(':^#CF:', $message)) { |
|
438 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
439 | 439 | } |
440 | - elseif (preg_match(':^#DF:',$message)) { |
|
441 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
440 | + elseif (preg_match(':^#DF:', $message)) { |
|
441 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
442 | 442 | } |
443 | - elseif (preg_match(':^#EC:',$message)) { |
|
444 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
443 | + elseif (preg_match(':^#EC:', $message)) { |
|
444 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
445 | 445 | } |
446 | - elseif (preg_match(':^#EI:',$message)) { |
|
447 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
446 | + elseif (preg_match(':^#EI:', $message)) { |
|
447 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
448 | 448 | } |
449 | - elseif (preg_match(':^#H1:',$message)) { |
|
450 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
449 | + elseif (preg_match(':^#H1:', $message)) { |
|
450 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
451 | 451 | } |
452 | - elseif (preg_match(':^#H2:',$message)) { |
|
453 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
452 | + elseif (preg_match(':^#H2:', $message)) { |
|
453 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
454 | 454 | } |
455 | - elseif (preg_match(':^#HD:',$message)) { |
|
456 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
455 | + elseif (preg_match(':^#HD:', $message)) { |
|
456 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
457 | 457 | } |
458 | - elseif (preg_match(':^#M1:',$message)) { |
|
459 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
458 | + elseif (preg_match(':^#M1:', $message)) { |
|
459 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
460 | 460 | } |
461 | - elseif (preg_match(':^#M2:',$message)) { |
|
462 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
461 | + elseif (preg_match(':^#M2:', $message)) { |
|
462 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
463 | 463 | } |
464 | - elseif (preg_match(':^#M3:',$message)) { |
|
465 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
464 | + elseif (preg_match(':^#M3:', $message)) { |
|
465 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
466 | 466 | } |
467 | - elseif (preg_match(':^#MD:',$message)) { |
|
468 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
467 | + elseif (preg_match(':^#MD:', $message)) { |
|
468 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
469 | 469 | } |
470 | - elseif (preg_match(':^#PS:',$message)) { |
|
471 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
470 | + elseif (preg_match(':^#PS:', $message)) { |
|
471 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
472 | 472 | } |
473 | - elseif (preg_match(':^#S1:',$message)) { |
|
474 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
473 | + elseif (preg_match(':^#S1:', $message)) { |
|
474 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
475 | 475 | } |
476 | - elseif (preg_match(':^#S2:',$message)) { |
|
477 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
476 | + elseif (preg_match(':^#S2:', $message)) { |
|
477 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
478 | 478 | } |
479 | - elseif (preg_match(':^#SD:',$message)) { |
|
480 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
479 | + elseif (preg_match(':^#SD:', $message)) { |
|
480 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
481 | 481 | } |
482 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
483 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
482 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
483 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
484 | 484 | } |
485 | - elseif (preg_match(':^#WO:',$message)) { |
|
486 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
485 | + elseif (preg_match(':^#WO:', $message)) { |
|
486 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
487 | 487 | } |
488 | - elseif (preg_match(':^#A1:',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
488 | + elseif (preg_match(':^#A1:', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match(':^#A3:',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
491 | + elseif (preg_match(':^#A3:', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match(':^#A4:',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
494 | + elseif (preg_match(':^#A4:', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match(':^#A6:',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
497 | + elseif (preg_match(':^#A6:', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#A8:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
500 | + elseif (preg_match(':^#A8:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match(':^#A9:',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
503 | + elseif (preg_match(':^#A9:', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#A0:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
506 | + elseif (preg_match(':^#A0:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#AA:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
509 | + elseif (preg_match(':^#AA:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#AB:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
512 | + elseif (preg_match(':^#AB:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#AC:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
515 | + elseif (preg_match(':^#AC:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#AD:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
518 | + elseif (preg_match(':^#AD:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#AF:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
521 | + elseif (preg_match(':^#AF:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#B1:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
524 | + elseif (preg_match(':^#B1:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#B2:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
527 | + elseif (preg_match(':^#B2:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#B3:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
530 | + elseif (preg_match(':^#B3:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#B4:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
533 | + elseif (preg_match(':^#B4:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#B6:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
536 | + elseif (preg_match(':^#B6:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#B8:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
539 | + elseif (preg_match(':^#B8:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#B9:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
542 | + elseif (preg_match(':^#B9:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#B0:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
545 | + elseif (preg_match(':^#B0:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#BA:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
548 | + elseif (preg_match(':^#BA:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#BB:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
551 | + elseif (preg_match(':^#BB:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#BC:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
554 | + elseif (preg_match(':^#BC:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#BD:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
557 | + elseif (preg_match(':^#BD:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#BE:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
560 | + elseif (preg_match(':^#BE:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#BF:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
563 | + elseif (preg_match(':^#BF:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#H3:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
566 | + elseif (preg_match(':^#H3:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | if ($label == '10') { |
571 | - if (preg_match(':^DTO01:',$message)) { |
|
572 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
571 | + if (preg_match(':^DTO01:', $message)) { |
|
572 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
573 | 573 | } |
574 | - elseif (preg_match(':^AIS01:',$message)) { |
|
575 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
574 | + elseif (preg_match(':^AIS01:', $message)) { |
|
575 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
576 | 576 | } |
577 | - elseif (preg_match(':^FTX01:',$message)) { |
|
578 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
577 | + elseif (preg_match(':^FTX01:', $message)) { |
|
578 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
579 | 579 | } |
580 | - elseif (preg_match(':^FPL01:',$message)) { |
|
581 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
580 | + elseif (preg_match(':^FPL01:', $message)) { |
|
581 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
582 | 582 | } |
583 | - elseif (preg_match(':^WAB01:',$message)) { |
|
584 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
583 | + elseif (preg_match(':^WAB01:', $message)) { |
|
584 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
585 | 585 | } |
586 | - elseif (preg_match(':^MET01:',$message)) { |
|
587 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
586 | + elseif (preg_match(':^MET01:', $message)) { |
|
587 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
588 | 588 | } |
589 | - elseif (preg_match(':^WAB02:',$message)) { |
|
590 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
589 | + elseif (preg_match(':^WAB02:', $message)) { |
|
590 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | if ($label == '15') { |
594 | - if (preg_match(':^FST01:',$message)) { |
|
595 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
594 | + if (preg_match(':^FST01:', $message)) { |
|
595 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | if (!$found && $label == 'SA') { |
599 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
599 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
600 | 600 | if ($n == 4) { |
601 | 601 | $vsta = array('Version' => $version); |
602 | 602 | if ($state == 'E') { |
603 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
603 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
604 | 604 | } |
605 | 605 | elseif ($state == 'L') { |
606 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
606 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
607 | 607 | } |
608 | 608 | else { |
609 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
609 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
610 | 610 | } |
611 | 611 | if ($type == 'V') { |
612 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
612 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
613 | 613 | } |
614 | 614 | elseif ($type == 'S') { |
615 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
615 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
616 | 616 | } |
617 | 617 | elseif ($type == 'H') { |
618 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
618 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
619 | 619 | } |
620 | 620 | elseif ($type == 'G') { |
621 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
621 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
622 | 622 | } |
623 | 623 | elseif ($type == 'C') { |
624 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
624 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
625 | 625 | } |
626 | 626 | elseif ($type == '2') { |
627 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
627 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
628 | 628 | } |
629 | 629 | elseif ($type == 'X') { |
630 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
630 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
631 | 631 | } |
632 | 632 | elseif ($type == 'I') { |
633 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
633 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
634 | 634 | } |
635 | 635 | else { |
636 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
636 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
637 | 637 | } |
638 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
639 | - $decode = array_merge($vsta,$decode); |
|
638 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
639 | + $decode = array_merge($vsta, $decode); |
|
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
643 | 643 | $title = $this->getTitlefromLabel($label); |
644 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
644 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
645 | 645 | |
646 | 646 | /* |
647 | 647 | // Business jets always use GS0001 |
@@ -697,23 +697,23 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | // Business jets always use GS0001 |
700 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
700 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
701 | 701 | if ($globalDebug && isset($info) && $info != '') echo $info; |
702 | 702 | |
703 | 703 | if (count($decode) > 0) $decode_json = json_encode($decode); |
704 | 704 | else $decode_json = ''; |
705 | 705 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
706 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
706 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
707 | 707 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
708 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
708 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
709 | 709 | } |
710 | 710 | |
711 | - $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); |
|
711 | + $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); |
|
714 | 714 | |
715 | 715 | if ($globalDebug && count($decode) > 0) { |
716 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
716 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | } |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @param String $msg_no Number of the ACARS message |
729 | 729 | * @param String $message ACARS message |
730 | 730 | */ |
731 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
731 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
732 | 732 | global $globalDebug; |
733 | 733 | date_default_timezone_set('UTC'); |
734 | 734 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -737,22 +737,22 @@ discard block |
||
737 | 737 | |
738 | 738 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
739 | 739 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
740 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
740 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
741 | 741 | try { |
742 | 742 | $stht = $this->db->prepare($query_test); |
743 | 743 | $stht->execute($query_test_values); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error : ".$e->getMessage(); |
746 | 746 | } |
747 | 747 | if ($stht->fetchColumn() == 0) { |
748 | 748 | if ($globalDebug) echo "Add Live ACARS data..."; |
749 | 749 | $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 | - $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")); |
|
750 | + $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 | 751 | try { |
752 | 752 | |
753 | 753 | $sth = $this->db->prepare($query); |
754 | 754 | $sth->execute($query_values); |
755 | - } catch(PDOException $e) { |
|
755 | + } catch (PDOException $e) { |
|
756 | 756 | return "error : ".$e->getMessage(); |
757 | 757 | } |
758 | 758 | } else { |
@@ -774,10 +774,10 @@ discard block |
||
774 | 774 | * @param String $msg_no Number of the ACARS message |
775 | 775 | * @param String $message ACARS message |
776 | 776 | */ |
777 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
777 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
778 | 778 | global $globalDebug; |
779 | 779 | date_default_timezone_set('UTC'); |
780 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) == FALSE && preg_match('/^ARR0/',$message) == FALSE && preg_match('/^ETA/',$message) == FALSE && preg_match('/^WXR/',$message) == FALSE && preg_match('/^FTX01.FIC/',$message) == FALSE) { |
|
780 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) == FALSE && preg_match('/^ARR0/', $message) == FALSE && preg_match('/^ETA/', $message) == FALSE && preg_match('/^WXR/', $message) == FALSE && preg_match('/^FTX01.FIC/', $message) == FALSE) { |
|
781 | 781 | /* |
782 | 782 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
783 | 783 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | */ |
794 | 794 | if ($globalDebug) echo "Add Live ACARS data..."; |
795 | 795 | $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 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
796 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
797 | 797 | try { |
798 | 798 | |
799 | 799 | $sth = $this->db->prepare($query); |
800 | 800 | $sth->execute($query_values); |
801 | - } catch(PDOException $e) { |
|
801 | + } catch (PDOException $e) { |
|
802 | 802 | return "error : ".$e->getMessage(); |
803 | 803 | } |
804 | 804 | // } |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | |
822 | 822 | $sth = $this->db->prepare($query); |
823 | 823 | $sth->execute($query_values); |
824 | - } catch(PDOException $e) { |
|
824 | + } catch (PDOException $e) { |
|
825 | 825 | return "error : ".$e->getMessage(); |
826 | 826 | } |
827 | 827 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | |
842 | 842 | $sth = $this->db->prepare($query); |
843 | 843 | $sth->execute($query_values); |
844 | - } catch(PDOException $e) { |
|
844 | + } catch (PDOException $e) { |
|
845 | 845 | return "error : ".$e->getMessage(); |
846 | 846 | } |
847 | 847 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | |
863 | 863 | $sth = $this->db->prepare($query); |
864 | 864 | $sth->execute($query_values); |
865 | - } catch(PDOException $e) { |
|
865 | + } catch (PDOException $e) { |
|
866 | 866 | return "error : ".$e->getMessage(); |
867 | 867 | } |
868 | 868 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return Array Return ACARS data in array |
877 | 877 | */ |
878 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
878 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
879 | 879 | global $globalURL, $globalDBdriver; |
880 | 880 | $Image = new Image($this->db); |
881 | 881 | $Spotter = new Spotter($this->db); |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | { |
888 | 888 | $limit_array = explode(",", $limit); |
889 | 889 | |
890 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
891 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
890 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
891 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
892 | 892 | |
893 | 893 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
894 | 894 | { |
@@ -910,49 +910,49 @@ discard block |
||
910 | 910 | |
911 | 911 | $sth = $this->db->prepare($query); |
912 | 912 | $sth->execute($query_values); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error : ".$e->getMessage(); |
915 | 915 | } |
916 | 916 | $i = 0; |
917 | 917 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
918 | 918 | $data = array(); |
919 | 919 | if ($row['registration'] != '') { |
920 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
920 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
921 | 921 | $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' => '')); |
|
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' => '')); |
|
925 | 925 | $icao = ''; |
926 | 926 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
927 | 927 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
928 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
928 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
929 | 929 | if (isset($identicao[0])) { |
930 | - 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'); |
|
930 | + 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'); |
|
934 | 934 | |
935 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
935 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
936 | 936 | } else $icao = $row['ident']; |
937 | - $icao = $Translation->checkTranslation($icao,false); |
|
937 | + $icao = $Translation->checkTranslation($icao, false); |
|
938 | 938 | |
939 | - $decode = json_decode($row['decode'],true); |
|
939 | + $decode = json_decode($row['decode'], true); |
|
940 | 940 | $found = false; |
941 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
941 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
942 | 942 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
943 | 943 | if (isset($airport_info[0]['icao'])) { |
944 | 944 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
945 | 945 | $found = true; |
946 | 946 | } |
947 | 947 | } |
948 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
948 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
949 | 949 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
950 | 950 | if (isset($airport_info[0]['icao'])) { |
951 | 951 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
952 | 952 | $found = true; |
953 | 953 | } |
954 | 954 | } |
955 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
955 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
956 | 956 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
957 | 957 | if (isset($airport_info[0]['icao'])) { |
958 | 958 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | } |
961 | 961 | } |
962 | 962 | if ($found) $row['decode'] = json_encode($decode); |
963 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
963 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
964 | 964 | $result[] = $data; |
965 | 965 | $i++; |
966 | 966 | } |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | * |
977 | 977 | * @return Array Return ACARS data in array |
978 | 978 | */ |
979 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
979 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
980 | 980 | global $globalURL, $globalDBdriver; |
981 | 981 | $Image = new Image($this->db); |
982 | 982 | $Spotter = new Spotter($this->db); |
@@ -988,8 +988,8 @@ discard block |
||
988 | 988 | { |
989 | 989 | $limit_array = explode(",", $limit); |
990 | 990 | |
991 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
992 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
991 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
992 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
993 | 993 | |
994 | 994 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
995 | 995 | { |
@@ -1019,45 +1019,45 @@ discard block |
||
1019 | 1019 | |
1020 | 1020 | $sth = $this->db->prepare($query); |
1021 | 1021 | $sth->execute($query_values); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error : ".$e->getMessage(); |
1024 | 1024 | } |
1025 | - $i=0; |
|
1025 | + $i = 0; |
|
1026 | 1026 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1027 | 1027 | $data = array(); |
1028 | 1028 | if ($row['registration'] != '') { |
1029 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1029 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1030 | 1030 | $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' => '')); |
|
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' => '')); |
|
1034 | 1034 | $icao = ''; |
1035 | 1035 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1036 | 1036 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1037 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1037 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1038 | 1038 | if (isset($identicao[0])) { |
1039 | - 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'); |
|
1043 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1039 | + 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'); |
|
1043 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1044 | 1044 | } else $icao = $row['ident']; |
1045 | 1045 | $icao = $Translation->checkTranslation($icao); |
1046 | 1046 | |
1047 | 1047 | |
1048 | - $decode = json_decode($row['decode'],true); |
|
1048 | + $decode = json_decode($row['decode'], true); |
|
1049 | 1049 | $found = false; |
1050 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1050 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1051 | 1051 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1052 | 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>'; |
1053 | 1053 | $found = true; |
1054 | 1054 | } |
1055 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1055 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1056 | 1056 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1057 | 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>'; |
1058 | 1058 | $found = true; |
1059 | 1059 | } |
1060 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1060 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1061 | 1061 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1062 | 1062 | if (isset($airport_info[0]['icao'])) { |
1063 | 1063 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | if ($found) $row['decode'] = json_encode($decode); |
1068 | 1068 | |
1069 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1069 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1070 | 1070 | $result[] = $data; |
1071 | 1071 | $i++; |
1072 | 1072 | } |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | * @param String $icao |
1085 | 1085 | * @param String $ICAOTypeCode |
1086 | 1086 | */ |
1087 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1087 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1088 | 1088 | global $globalDebug, $globalDBdriver; |
1089 | 1089 | $ident = trim($ident); |
1090 | 1090 | $Translation = new Translation($this->db); |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | return ''; |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - $registration = str_replace('.','',$registration); |
|
1101 | + $registration = str_replace('.', '', $registration); |
|
1102 | 1102 | $ident = $Translation->ident2icao($ident); |
1103 | 1103 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1104 | 1104 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | $sthsi = $this->db->prepare($querysi); |
1110 | 1110 | $sthsi->execute($querysi_values); |
1111 | - } catch(PDOException $e) { |
|
1111 | + } catch (PDOException $e) { |
|
1112 | 1112 | if ($globalDebug) echo $e->getMessage(); |
1113 | 1113 | return "error : ".$e->getMessage(); |
1114 | 1114 | } |
@@ -1118,8 +1118,8 @@ discard block |
||
1118 | 1118 | $Translation = new Translation($this->db); |
1119 | 1119 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1120 | 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'); |
|
1121 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1122 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1123 | 1123 | } else { |
1124 | 1124 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1125 | 1125 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1127,14 +1127,14 @@ discard block |
||
1127 | 1127 | try { |
1128 | 1128 | $sth = $this->db->prepare($query); |
1129 | 1129 | $sth->execute($query_values); |
1130 | - } catch(PDOException $e) { |
|
1130 | + } catch (PDOException $e) { |
|
1131 | 1131 | if ($globalDebug) echo $e->getMessage(); |
1132 | 1132 | return "error : ".$e->getMessage(); |
1133 | 1133 | } |
1134 | 1134 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1135 | 1135 | if (isset($result['modes'])) $hex = $result['modes']; |
1136 | 1136 | else $hex = ''; |
1137 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1137 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1138 | 1138 | $this->SI->add($SI_data); |
1139 | 1139 | } |
1140 | 1140 | } |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | |
1147 | 1147 | $sth = $this->db->prepare($query); |
1148 | 1148 | $sth->execute($query_values); |
1149 | - } catch(PDOException $e) { |
|
1149 | + } catch (PDOException $e) { |
|
1150 | 1150 | if ($globalDebug) echo $e->getMessage(); |
1151 | 1151 | return "error : ".$e->getMessage(); |
1152 | 1152 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1157 | 1157 | else $ModeS = ''; |
1158 | 1158 | if ($ModeS == '') { |
1159 | - $id = explode('-',$result['flightaware_id']); |
|
1159 | + $id = explode('-', $result['flightaware_id']); |
|
1160 | 1160 | $ModeS = $id[0]; |
1161 | 1161 | } |
1162 | 1162 | if ($ModeS != '') { |
@@ -1167,21 +1167,21 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | $sthc = $this->db->prepare($queryc); |
1169 | 1169 | $sthc->execute($queryc_values); |
1170 | - } catch(PDOException $e) { |
|
1170 | + } catch (PDOException $e) { |
|
1171 | 1171 | if ($globalDebug) echo $e->getMessage(); |
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1175 | 1175 | |
1176 | - if (count($row) == 0) { |
|
1176 | + if (count($row) == 0) { |
|
1177 | 1177 | if ($globalDebug) echo " Add to ModeS table - "; |
1178 | 1178 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1179 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1179 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1180 | 1180 | try { |
1181 | 1181 | |
1182 | 1182 | $sthi = $this->db->prepare($queryi); |
1183 | 1183 | $sthi->execute($queryi_values); |
1184 | - } catch(PDOException $e) { |
|
1184 | + } catch (PDOException $e) { |
|
1185 | 1185 | if ($globalDebug) echo $e->getMessage(); |
1186 | 1186 | return "error : ".$e->getMessage(); |
1187 | 1187 | } |
@@ -1189,16 +1189,16 @@ discard block |
||
1189 | 1189 | if ($globalDebug) echo " Update ModeS table - "; |
1190 | 1190 | if ($ICAOTypeCode != '') { |
1191 | 1191 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1192 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1192 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1193 | 1193 | } else { |
1194 | 1194 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1195 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1195 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1196 | 1196 | } |
1197 | 1197 | try { |
1198 | 1198 | |
1199 | 1199 | $sthi = $this->db->prepare($queryi); |
1200 | 1200 | $sthi->execute($queryi_values); |
1201 | - } catch(PDOException $e) { |
|
1201 | + } catch (PDOException $e) { |
|
1202 | 1202 | if ($globalDebug) echo $e->getMessage(); |
1203 | 1203 | return "error : ".$e->getMessage(); |
1204 | 1204 | } |
@@ -1236,13 +1236,13 @@ discard block |
||
1236 | 1236 | elseif ($globalDBdriver == 'pgsql') { |
1237 | 1237 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1238 | 1238 | } |
1239 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1239 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1240 | 1240 | } |
1241 | 1241 | try { |
1242 | 1242 | |
1243 | 1243 | $sthi = $this->db->prepare($queryi); |
1244 | 1244 | $sthi->execute($queryi_values); |
1245 | - } catch(PDOException $e) { |
|
1245 | + } catch (PDOException $e) { |
|
1246 | 1246 | if ($globalDebug) echo $e->getMessage(); |
1247 | 1247 | return "error : ".$e->getMessage(); |
1248 | 1248 | } |
@@ -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) | |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class aprs { |
3 | - private function urshift($n, $s) { |
|
3 | + private function urshift($n, $s) { |
|
4 | 4 | return ($n >= 0) ? ($n >> $s) : |
5 | - (($n & 0x7fffffff) >> $s) | |
|
6 | - (0x40000000 >> ($s - 1)); |
|
7 | - } |
|
5 | + (($n & 0x7fffffff) >> $s) | |
|
6 | + (0x40000000 >> ($s - 1)); |
|
7 | + } |
|
8 | 8 | |
9 | - public function parse($input) { |
|
9 | + public function parse($input) { |
|
10 | 10 | $debug = false; |
11 | 11 | $result = array(); |
12 | 12 | $input_len = strlen($input); |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | |
18 | 18 | /* Check that end was found and body has at least one byte. */ |
19 | 19 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
20 | - echo 'invalid'; |
|
21 | - return false; |
|
20 | + echo 'invalid'; |
|
21 | + return false; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /* Save header and body. */ |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | /* Parse source, target and path. */ |
32 | 32 | //FLRDF0A52>APRS,qAS,LSTB |
33 | 33 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
34 | - $ident = $matches[1]; |
|
35 | - $all_elements = $matches[2]; |
|
36 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
37 | - $result['ident'] = $ident; |
|
34 | + $ident = $matches[1]; |
|
35 | + $all_elements = $matches[2]; |
|
36 | + if ($debug) echo 'ident : '.$ident."\n"; |
|
37 | + $result['ident'] = $ident; |
|
38 | 38 | } else return false; |
39 | 39 | $elements = explode(',',$all_elements); |
40 | 40 | $source = end($elements); |
41 | 41 | $result['source'] = $source; |
42 | 42 | foreach ($elements as $element) { |
43 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
44 | - //echo "ok"; |
|
45 | - if ($element == 'TCPIP*') return false; |
|
46 | - } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
43 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
44 | + //echo "ok"; |
|
45 | + if ($element == 'TCPIP*') return false; |
|
46 | + } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
47 | 47 | //echo "ok"; |
48 | - } else { |
|
49 | - return false; |
|
50 | - } |
|
48 | + } else { |
|
49 | + return false; |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | // Check for Timestamp |
53 | 53 | $body_parse = substr($body,1); |
54 | 54 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
55 | - $timestamp = $matches[0]; |
|
56 | - if ($matches[4] == 'h') { |
|
55 | + $timestamp = $matches[0]; |
|
56 | + if ($matches[4] == 'h') { |
|
57 | 57 | $timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]); |
58 | 58 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
59 | 59 | /* |
60 | 60 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
61 | 61 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
62 | 62 | */ |
63 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
63 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
64 | 64 | // FIXME : fix this... |
65 | 65 | $timestamp = strtotime($matches[1].' '.$matches[2].':'.$matches[3]); |
66 | - } |
|
67 | - $body_parse = substr($body_parse,7); |
|
68 | - $result['timestamp'] = $timestamp; |
|
66 | + } |
|
67 | + $body_parse = substr($body_parse,7); |
|
68 | + $result['timestamp'] = $timestamp; |
|
69 | 69 | } |
70 | 70 | if (strlen($body_parse) > 19) { |
71 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
71 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
72 | 72 | // 4658.70N/00707.78Ez |
73 | 73 | //print_r(str_split($body_parse)); |
74 | 74 | $latlon = $matches[0]; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $lon = intval($lon_deg); |
85 | 85 | if ($lat > 89 || $lon > 179) return false; |
86 | 86 | |
87 | - /* |
|
87 | + /* |
|
88 | 88 | $tmp_5b = str_replace('.','',$lat_min); |
89 | 89 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
90 | 90 | print_r($matches); |
@@ -96,58 +96,58 @@ discard block |
||
96 | 96 | if ($wind == 'W') $longitude = 0-$longitude; |
97 | 97 | $result['latitude'] = $latitude; |
98 | 98 | $result['longitude'] = $longitude; |
99 | - } |
|
100 | - if ($body_len > 19) { |
|
99 | + } |
|
100 | + if ($body_len > 19) { |
|
101 | 101 | $body_split = str_split($body_parse); |
102 | 102 | $symbol_code = $body_split[18]; |
103 | 103 | if ($symbol_code != '_') { |
104 | - $body_parse = substr($body_parse,19); |
|
105 | - $body_parse_len = strlen($body_parse); |
|
106 | - if ($body_parse_len >= 7) { |
|
104 | + $body_parse = substr($body_parse,19); |
|
105 | + $body_parse_len = strlen($body_parse); |
|
106 | + if ($body_parse_len >= 7) { |
|
107 | 107 | |
108 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
109 | - $course = substr($body_parse,0,3); |
|
110 | - $tmp_s = intval($course); |
|
111 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course); |
|
112 | - $speed = substr($body_parse,4,3); |
|
113 | - $result['speed'] = round($speed*1.852); |
|
114 | - $body_parse = substr($body_parse,7); |
|
115 | - } |
|
116 | - // Check PHGR, PHG, RNG |
|
117 | - } else if ($body_parse_len > 0) { |
|
108 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
109 | + $course = substr($body_parse,0,3); |
|
110 | + $tmp_s = intval($course); |
|
111 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course); |
|
112 | + $speed = substr($body_parse,4,3); |
|
113 | + $result['speed'] = round($speed*1.852); |
|
114 | + $body_parse = substr($body_parse,7); |
|
115 | + } |
|
116 | + // Check PHGR, PHG, RNG |
|
117 | + } else if ($body_parse_len > 0) { |
|
118 | 118 | $rest = $body_parse; |
119 | - } |
|
120 | - if (strlen($body_parse) > 0) { |
|
121 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
122 | - $altitude = intval($matches[1]); |
|
123 | - $result['altitude'] = round($altitude*0.3048); |
|
124 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
125 | - } |
|
126 | - } |
|
119 | + } |
|
120 | + if (strlen($body_parse) > 0) { |
|
121 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
122 | + $altitude = intval($matches[1]); |
|
123 | + $result['altitude'] = round($altitude*0.3048); |
|
124 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | - // Telemetry |
|
129 | - if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
|
130 | - // Nothing yet... |
|
131 | - } |
|
132 | - // DAO |
|
133 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
134 | - $dao = $matches[1]; |
|
135 | - $dao_split = str_split($dao); |
|
136 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
137 | - $lat_off = (($dao[1])-48.0)*0.001/60.0; |
|
138 | - $lon_off = (($dao[2])-48.0)*0.001/60.0; |
|
128 | + // Telemetry |
|
129 | + if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
|
130 | + // Nothing yet... |
|
131 | + } |
|
132 | + // DAO |
|
133 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
134 | + $dao = $matches[1]; |
|
135 | + $dao_split = str_split($dao); |
|
136 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
137 | + $lat_off = (($dao[1])-48.0)*0.001/60.0; |
|
138 | + $lon_off = (($dao[2])-48.0)*0.001/60.0; |
|
139 | 139 | |
140 | - } |
|
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; |
|
145 | - $body_parse = substr($body_parse,6); |
|
146 | - } |
|
140 | + } |
|
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; |
|
145 | + $body_parse = substr($body_parse,6); |
|
146 | + } |
|
147 | 147 | |
148 | - // OGN comment |
|
148 | + // OGN comment |
|
149 | 149 | // echo "Before OGN : ".$body_parse."\n"; |
150 | - if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
150 | + if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
151 | 151 | $id = $matches[1]; |
152 | 152 | $mode = substr($id,0,2); |
153 | 153 | $address = substr($id,2); |
@@ -177,49 +177,49 @@ discard block |
||
177 | 177 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
178 | 178 | $result['stealth'] = $stealth; |
179 | 179 | $result['address'] = $address; |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | - //Comment |
|
183 | - $result['comment'] = $body_parse; |
|
182 | + //Comment |
|
183 | + $result['comment'] = $body_parse; |
|
184 | 184 | } else { |
185 | - // parse weather |
|
186 | - $body_parse = substr($body_parse,19); |
|
187 | - $body_parse_len = strlen($body_parse); |
|
185 | + // parse weather |
|
186 | + $body_parse = substr($body_parse,19); |
|
187 | + $body_parse_len = strlen($body_parse); |
|
188 | 188 | |
189 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
189 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
190 | 190 | $result['wind_dir'] = $matches[1]; |
191 | 191 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
192 | 192 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
193 | 193 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
194 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
195 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
194 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
195 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
196 | 196 | $result['wind_dir'] = $matches[1]; |
197 | 197 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
198 | 198 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
199 | 199 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
200 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
201 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
200 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
201 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
202 | 202 | $result['wind_dir'] = $matches[1]; |
203 | 203 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
204 | 204 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
205 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
206 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
205 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
206 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
207 | 207 | $result['wind_dir'] = $matches[1]; |
208 | 208 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
209 | 209 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
210 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
211 | - } |
|
212 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
210 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
211 | + } |
|
212 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
213 | 213 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
214 | - } |
|
214 | + } |
|
215 | + } |
|
215 | 216 | } |
216 | - } |
|
217 | 217 | } |
218 | 218 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
219 | 219 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
220 | 220 | //print_r($result); |
221 | 221 | return $result; |
222 | - } |
|
222 | + } |
|
223 | 223 | } |
224 | 224 | /* |
225 | 225 | $aprs = new aprs(); |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class aprs { |
3 | 3 | private function urshift($n, $s) { |
4 | - return ($n >= 0) ? ($n >> $s) : |
|
5 | - (($n & 0x7fffffff) >> $s) | |
|
4 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
6 | 5 | (0x40000000 >> ($s - 1)); |
7 | 6 | } |
8 | 7 | |
@@ -13,7 +12,7 @@ discard block |
||
13 | 12 | $split_input = str_split($input); |
14 | 13 | |
15 | 14 | /* Find the end of header checking for NULL bytes while doing it. */ |
16 | - $splitpos = strpos($input,':'); |
|
15 | + $splitpos = strpos($input, ':'); |
|
17 | 16 | |
18 | 17 | /* Check that end was found and body has at least one byte. */ |
19 | 18 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -22,36 +21,36 @@ discard block |
||
22 | 21 | } |
23 | 22 | |
24 | 23 | /* Save header and body. */ |
25 | - $body = substr($input,$splitpos+1,$input_len); |
|
24 | + $body = substr($input, $splitpos + 1, $input_len); |
|
26 | 25 | $body_len = strlen($body); |
27 | - $header = substr($input,0,$splitpos); |
|
26 | + $header = substr($input, 0, $splitpos); |
|
28 | 27 | $header_len = strlen($header); |
29 | 28 | if ($debug) echo 'header : '.$header."\n"; |
30 | 29 | |
31 | 30 | /* Parse source, target and path. */ |
32 | 31 | //FLRDF0A52>APRS,qAS,LSTB |
33 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
32 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
34 | 33 | $ident = $matches[1]; |
35 | 34 | $all_elements = $matches[2]; |
36 | 35 | if ($debug) echo 'ident : '.$ident."\n"; |
37 | 36 | $result['ident'] = $ident; |
38 | 37 | } else return false; |
39 | - $elements = explode(',',$all_elements); |
|
38 | + $elements = explode(',', $all_elements); |
|
40 | 39 | $source = end($elements); |
41 | 40 | $result['source'] = $source; |
42 | 41 | foreach ($elements as $element) { |
43 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
42 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
44 | 43 | //echo "ok"; |
45 | 44 | if ($element == 'TCPIP*') return false; |
46 | - } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
45 | + } elseif (preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
47 | 46 | //echo "ok"; |
48 | 47 | } else { |
49 | 48 | return false; |
50 | 49 | } |
51 | 50 | } |
52 | 51 | // Check for Timestamp |
53 | - $body_parse = substr($body,1); |
|
54 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
52 | + $body_parse = substr($body, 1); |
|
53 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
55 | 54 | $timestamp = $matches[0]; |
56 | 55 | if ($matches[4] == 'h') { |
57 | 56 | $timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]); |
@@ -64,11 +63,11 @@ discard block |
||
64 | 63 | // FIXME : fix this... |
65 | 64 | $timestamp = strtotime($matches[1].' '.$matches[2].':'.$matches[3]); |
66 | 65 | } |
67 | - $body_parse = substr($body_parse,7); |
|
66 | + $body_parse = substr($body_parse, 7); |
|
68 | 67 | $result['timestamp'] = $timestamp; |
69 | 68 | } |
70 | 69 | if (strlen($body_parse) > 19) { |
71 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
70 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
72 | 71 | // 4658.70N/00707.78Ez |
73 | 72 | //print_r(str_split($body_parse)); |
74 | 73 | $latlon = $matches[0]; |
@@ -92,8 +91,8 @@ discard block |
||
92 | 91 | */ |
93 | 92 | $latitude = $lat + floatval($lat_min)/60; |
94 | 93 | $longitude = $lon + floatval($lon_min)/60; |
95 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
96 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
94 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
95 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
97 | 96 | $result['latitude'] = $latitude; |
98 | 97 | $result['longitude'] = $longitude; |
99 | 98 | } |
@@ -101,63 +100,63 @@ discard block |
||
101 | 100 | $body_split = str_split($body_parse); |
102 | 101 | $symbol_code = $body_split[18]; |
103 | 102 | if ($symbol_code != '_') { |
104 | - $body_parse = substr($body_parse,19); |
|
103 | + $body_parse = substr($body_parse, 19); |
|
105 | 104 | $body_parse_len = strlen($body_parse); |
106 | 105 | if ($body_parse_len >= 7) { |
107 | 106 | |
108 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
109 | - $course = substr($body_parse,0,3); |
|
107 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
108 | + $course = substr($body_parse, 0, 3); |
|
110 | 109 | $tmp_s = intval($course); |
111 | 110 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course); |
112 | - $speed = substr($body_parse,4,3); |
|
111 | + $speed = substr($body_parse, 4, 3); |
|
113 | 112 | $result['speed'] = round($speed*1.852); |
114 | - $body_parse = substr($body_parse,7); |
|
113 | + $body_parse = substr($body_parse, 7); |
|
115 | 114 | } |
116 | 115 | // Check PHGR, PHG, RNG |
117 | 116 | } else if ($body_parse_len > 0) { |
118 | 117 | $rest = $body_parse; |
119 | 118 | } |
120 | 119 | if (strlen($body_parse) > 0) { |
121 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
120 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
122 | 121 | $altitude = intval($matches[1]); |
123 | 122 | $result['altitude'] = round($altitude*0.3048); |
124 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
123 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
125 | 124 | } |
126 | 125 | } |
127 | 126 | |
128 | 127 | // Telemetry |
129 | - if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
|
128 | + if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/', $body_parse, $matches)) { |
|
130 | 129 | // Nothing yet... |
131 | 130 | } |
132 | 131 | // DAO |
133 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
132 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
134 | 133 | $dao = $matches[1]; |
135 | 134 | $dao_split = str_split($dao); |
136 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
137 | - $lat_off = (($dao[1])-48.0)*0.001/60.0; |
|
138 | - $lon_off = (($dao[2])-48.0)*0.001/60.0; |
|
135 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
136 | + $lat_off = (($dao[1]) - 48.0)*0.001/60.0; |
|
137 | + $lon_off = (($dao[2]) - 48.0)*0.001/60.0; |
|
139 | 138 | |
140 | 139 | } |
141 | 140 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
142 | 141 | else $result['latitude'] += $lat_off; |
143 | 142 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
144 | 143 | else $result['longitude'] += $lon_off; |
145 | - $body_parse = substr($body_parse,6); |
|
144 | + $body_parse = substr($body_parse, 6); |
|
146 | 145 | } |
147 | 146 | |
148 | 147 | // OGN comment |
149 | 148 | // echo "Before OGN : ".$body_parse."\n"; |
150 | - if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
149 | + if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/', $body_parse, $matches)) { |
|
151 | 150 | $id = $matches[1]; |
152 | - $mode = substr($id,0,2); |
|
153 | - $address = substr($id,2); |
|
151 | + $mode = substr($id, 0, 2); |
|
152 | + $address = substr($id, 2); |
|
154 | 153 | //print_r($matches); |
155 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
154 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
156 | 155 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
157 | 156 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
158 | 157 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
159 | 158 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
160 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
159 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
161 | 160 | $result['aircrafttype_code'] = $aircraftType; |
162 | 161 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
163 | 162 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -174,7 +173,7 @@ discard block |
||
174 | 173 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
175 | 174 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
176 | 175 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
177 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
176 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
178 | 177 | $result['stealth'] = $stealth; |
179 | 178 | $result['address'] = $address; |
180 | 179 | } |
@@ -183,40 +182,40 @@ discard block |
||
183 | 182 | $result['comment'] = $body_parse; |
184 | 183 | } else { |
185 | 184 | // parse weather |
186 | - $body_parse = substr($body_parse,19); |
|
185 | + $body_parse = substr($body_parse, 19); |
|
187 | 186 | $body_parse_len = strlen($body_parse); |
188 | 187 | |
189 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
188 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
190 | 189 | $result['wind_dir'] = $matches[1]; |
191 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
192 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
193 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
194 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
195 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
190 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
191 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
192 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
193 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
194 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
196 | 195 | $result['wind_dir'] = $matches[1]; |
197 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
198 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
199 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
200 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
201 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
196 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
197 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
198 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
199 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
200 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
202 | 201 | $result['wind_dir'] = $matches[1]; |
203 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
204 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
205 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
206 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
202 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
203 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
204 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
205 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
207 | 206 | $result['wind_dir'] = $matches[1]; |
208 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
209 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
210 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
207 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
208 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
209 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
211 | 210 | } |
212 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
213 | - $result['temp'] = round(5/9*(($matches[1])-32),1); |
|
211 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { |
|
212 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); |
|
214 | 213 | } |
215 | 214 | } |
216 | 215 | } |
217 | 216 | } |
218 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
219 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
217 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
218 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
220 | 219 | //print_r($result); |
221 | 220 | return $result; |
222 | 221 | } |
@@ -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 | { |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | protected $cookies = array(); |
7 | 7 | |
8 | 8 | /** |
9 | - * Get data from form result |
|
10 | - * @param String $url form URL |
|
11 | - * @param String $type type of submit form method (get or post) |
|
12 | - * @param String or Array $data values form post method |
|
13 | - * @param Array $headers header to submit with the form |
|
14 | - * @return String the result |
|
15 | - */ |
|
9 | + * Get data from form result |
|
10 | + * @param String $url form URL |
|
11 | + * @param String $type type of submit form method (get or post) |
|
12 | + * @param String or Array $data values form post method |
|
13 | + * @param Array $headers header to submit with the form |
|
14 | + * @return String the result |
|
15 | + */ |
|
16 | 16 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
17 | 17 | $ch = curl_init(); |
18 | 18 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
68 | 68 | } |
69 | 69 | } else { |
70 | - return $result; |
|
70 | + return $result; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * Convert a HTML table to an array |
|
83 | - * @param String $data HTML page |
|
84 | - * @return Array array of the tables in HTML page |
|
85 | - */ |
|
82 | + * Convert a HTML table to an array |
|
83 | + * @param String $data HTML page |
|
84 | + * @return Array array of the tables in HTML page |
|
85 | + */ |
|
86 | 86 | public function table2array($data) { |
87 | 87 | if (!is_string($data)) return array(); |
88 | 88 | if ($data == '') return array(); |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | - * Convert <p> part of a HTML page to an array |
|
119 | - * @param String $data HTML page |
|
120 | - * @return Array array of the <p> in HTML page |
|
121 | - */ |
|
118 | + * Convert <p> part of a HTML page to an array |
|
119 | + * @param String $data HTML page |
|
120 | + * @return Array array of the <p> in HTML page |
|
121 | + */ |
|
122 | 122 | public function text2array($data) { |
123 | 123 | $html = str_get_html($data); |
124 | 124 | $tabledata=array(); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Give distance between 2 coordonnates |
|
136 | - * @param Float $lat latitude of first point |
|
137 | - * @param Float $lon longitude of first point |
|
138 | - * @param Float $latc latitude of second point |
|
139 | - * @param Float $lonc longitude of second point |
|
140 | - * @param String $unit km else no unit used |
|
141 | - * @return Float Distance in $unit |
|
142 | - */ |
|
135 | + * Give distance between 2 coordonnates |
|
136 | + * @param Float $lat latitude of first point |
|
137 | + * @param Float $lon longitude of first point |
|
138 | + * @param Float $latc latitude of second point |
|
139 | + * @param Float $lonc longitude of second point |
|
140 | + * @param String $unit km else no unit used |
|
141 | + * @return Float Distance in $unit |
|
142 | + */ |
|
143 | 143 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
144 | 144 | if ($lat == $latc && $lon == $lonc) return 0; |
145 | 145 | $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; |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | - * Check is distance realistic |
|
161 | - * @param int $timeDifference the time between the reception of both messages |
|
162 | - * @param float $distance distance covered |
|
163 | - * @return whether distance is realistic |
|
164 | - */ |
|
160 | + * Check is distance realistic |
|
161 | + * @param int $timeDifference the time between the reception of both messages |
|
162 | + * @param float $distance distance covered |
|
163 | + * @return whether distance is realistic |
|
164 | + */ |
|
165 | 165 | public function withinThreshold ($timeDifference, $distance) { |
166 | 166 | $x = abs($timeDifference); |
167 | 167 | $d = abs($distance); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | public function isInteger($input){ |
182 | - return(ctype_digit(strval($input))); |
|
182 | + return(ctype_digit(strval($input))); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | - * Copy folder contents |
|
199 | - * @param string $source Source path |
|
200 | - * @param string $dest Destination path |
|
201 | - * @return bool Returns true on success, false on failure |
|
202 | - */ |
|
198 | + * Copy folder contents |
|
199 | + * @param string $source Source path |
|
200 | + * @param string $dest Destination path |
|
201 | + * @return bool Returns true on success, false on failure |
|
202 | + */ |
|
203 | 203 | public function xcopy($source, $dest, $permissions = 0755) |
204 | 204 | { |
205 | 205 | $files = glob($source.'*.*'); |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * Check if an url exist |
|
215 | - * @param String $url url to check |
|
216 | - * @return bool Return true on succes false on failure |
|
217 | - */ |
|
214 | + * Check if an url exist |
|
215 | + * @param String $url url to check |
|
216 | + * @return bool Return true on succes false on failure |
|
217 | + */ |
|
218 | 218 | public function urlexist($url){ |
219 | 219 | $headers=get_headers($url); |
220 | 220 | return stripos($headers[0],"200 OK")?true:false; |
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * Convert hexa to string |
|
225 | - * @param String $hex data in hexa |
|
226 | - * @return String Return result |
|
227 | - */ |
|
224 | + * Convert hexa to string |
|
225 | + * @param String $hex data in hexa |
|
226 | + * @return String Return result |
|
227 | + */ |
|
228 | 228 | public function hex2str($hex) { |
229 | 229 | $str = ''; |
230 | 230 | $hexln = strlen($hex); |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Returns list of available locales |
|
276 | - * |
|
277 | - * @return array |
|
275 | + * Returns list of available locales |
|
276 | + * |
|
277 | + * @return array |
|
278 | 278 | */ |
279 | 279 | public function listLocaleDir() |
280 | 280 | { |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | * @param Array $headers header to submit with the form |
14 | 14 | * @return String the result |
15 | 15 | */ |
16 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
16 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
17 | 17 | $ch = curl_init(); |
18 | 18 | curl_setopt($ch, CURLOPT_URL, $url); |
19 | 19 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
20 | 20 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
21 | 21 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
22 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
22 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
23 | 23 | //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'); |
24 | 24 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
25 | 25 | if ($useragent == '') { |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | } |
30 | 30 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
31 | 31 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
32 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
32 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
33 | 33 | if ($type == 'post') { |
34 | 34 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
35 | 35 | if (is_array($data)) { |
36 | 36 | curl_setopt($ch, CURLOPT_POST, count($data)); |
37 | 37 | $data_string = ''; |
38 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
38 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
39 | 39 | rtrim($data_string, '&'); |
40 | 40 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
41 | 41 | } else { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | if ($cookie != '') { |
49 | 49 | if (is_array($cookie)) { |
50 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
50 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
51 | 51 | } else { |
52 | 52 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
53 | 53 | } |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | $result = curl_exec($ch); |
59 | 59 | $info = curl_getinfo($ch); |
60 | 60 | curl_close($ch); |
61 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
61 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
62 | 62 | echo "Cloudflare Detected\n"; |
63 | 63 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
64 | 64 | $useragent = UAgent::random(); |
65 | 65 | cloudflare::useUserAgent($useragent); |
66 | 66 | if ($clearanceCookie = cloudflare::bypass($url)) { |
67 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
67 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
68 | 68 | } |
69 | 69 | } else { |
70 | 70 | return $result; |
@@ -87,27 +87,27 @@ discard block |
||
87 | 87 | if (!is_string($data)) return array(); |
88 | 88 | if ($data == '') return array(); |
89 | 89 | $html = str_get_html($data); |
90 | - $tabledata=array(); |
|
91 | - foreach($html->find('tr') as $element) |
|
90 | + $tabledata = array(); |
|
91 | + foreach ($html->find('tr') as $element) |
|
92 | 92 | { |
93 | 93 | $td = array(); |
94 | - foreach( $element->find('th') as $row) |
|
94 | + foreach ($element->find('th') as $row) |
|
95 | 95 | { |
96 | 96 | $td [] = trim($row->plaintext); |
97 | 97 | } |
98 | - $td=array_filter($td); |
|
98 | + $td = array_filter($td); |
|
99 | 99 | $tabledata[] = $td; |
100 | 100 | |
101 | 101 | $td = array(); |
102 | 102 | $tdi = array(); |
103 | - foreach( $element->find('td') as $row) |
|
103 | + foreach ($element->find('td') as $row) |
|
104 | 104 | { |
105 | 105 | $td [] = trim($row->plaintext); |
106 | 106 | $tdi [] = trim($row->innertext); |
107 | 107 | } |
108 | - $td=array_filter($td); |
|
109 | - $tdi=array_filter($tdi); |
|
110 | - $tabledata[]=array_merge($td,$tdi); |
|
108 | + $td = array_filter($td); |
|
109 | + $tdi = array_filter($tdi); |
|
110 | + $tabledata[] = array_merge($td, $tdi); |
|
111 | 111 | } |
112 | 112 | $html->clear(); |
113 | 113 | unset($html); |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function text2array($data) { |
123 | 123 | $html = str_get_html($data); |
124 | - $tabledata=array(); |
|
125 | - foreach($html->find('p') as $element) |
|
124 | + $tabledata = array(); |
|
125 | + foreach ($html->find('p') as $element) |
|
126 | 126 | { |
127 | 127 | $tabledata [] = trim($element->plaintext); |
128 | 128 | } |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
144 | 144 | if ($lat == $latc && $lon == $lonc) return 0; |
145 | - $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; |
|
145 | + $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 | 146 | if ($unit == "km") { |
147 | - return round($dist * 1.609344); |
|
147 | + return round($dist*1.609344); |
|
148 | 148 | } elseif ($unit == "m") { |
149 | - return round($dist * 1.609344 * 1000); |
|
149 | + return round($dist*1.609344*1000); |
|
150 | 150 | } elseif ($unit == "mile" || $unit == "mi") { |
151 | 151 | return round($dist); |
152 | 152 | } elseif ($unit == "nm") { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param float $distance distance covered |
163 | 163 | * @return whether distance is realistic |
164 | 164 | */ |
165 | - public function withinThreshold ($timeDifference, $distance) { |
|
165 | + public function withinThreshold($timeDifference, $distance) { |
|
166 | 166 | $x = abs($timeDifference); |
167 | 167 | $d = abs($distance); |
168 | 168 | if ($x == 0 || $d == 0) return true; |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | return ($array !== array_values($array)); |
179 | 179 | } |
180 | 180 | |
181 | - public function isInteger($input){ |
|
181 | + public function isInteger($input) { |
|
182 | 182 | return(ctype_digit(strval($input))); |
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | - public function convertDec($dms,$latlong) { |
|
186 | + public function convertDec($dms, $latlong) { |
|
187 | 187 | if ($latlong == 'latitude') { |
188 | 188 | $deg = substr($dms, 0, 2); |
189 | 189 | $min = substr($dms, 2, 4); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $deg = substr($dms, 0, 3); |
192 | 192 | $min = substr($dms, 3, 5); |
193 | 193 | } |
194 | - return $deg+(($min*60)/3600); |
|
194 | + return $deg + (($min*60)/3600); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | public function xcopy($source, $dest, $permissions = 0755) |
204 | 204 | { |
205 | 205 | $files = glob($source.'*.*'); |
206 | - foreach($files as $file){ |
|
207 | - $file_to_go = str_replace($source,$dest,$file); |
|
206 | + foreach ($files as $file) { |
|
207 | + $file_to_go = str_replace($source, $dest, $file); |
|
208 | 208 | copy($file, $file_to_go); |
209 | 209 | } |
210 | 210 | return true; |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @param String $url url to check |
216 | 216 | * @return bool Return true on succes false on failure |
217 | 217 | */ |
218 | - public function urlexist($url){ |
|
219 | - $headers=get_headers($url); |
|
220 | - return stripos($headers[0],"200 OK")?true:false; |
|
218 | + public function urlexist($url) { |
|
219 | + $headers = get_headers($url); |
|
220 | + return stripos($headers[0], "200 OK") ? true : false; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | public function hex2str($hex) { |
229 | 229 | $str = ''; |
230 | 230 | $hexln = strlen($hex); |
231 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
231 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
232 | 232 | return $str; |
233 | 233 | } |
234 | 234 | |
@@ -237,33 +237,33 @@ discard block |
||
237 | 237 | //difference in longitudinal coordinates |
238 | 238 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
239 | 239 | //difference in the phi of latitudinal coordinates |
240 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
240 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
241 | 241 | //we need to recalculate $dLon if it is greater than pi |
242 | - if(abs($dLon) > pi()) { |
|
243 | - if($dLon > 0) { |
|
244 | - $dLon = (2 * pi() - $dLon) * -1; |
|
242 | + if (abs($dLon) > pi()) { |
|
243 | + if ($dLon > 0) { |
|
244 | + $dLon = (2*pi() - $dLon)*-1; |
|
245 | 245 | } else { |
246 | - $dLon = 2 * pi() + $dLon; |
|
246 | + $dLon = 2*pi() + $dLon; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | //return the angle, normalized |
250 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
250 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
251 | 251 | } |
252 | 252 | |
253 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.1) { |
|
254 | - $a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
|
255 | - $a = -($lon2-$lon1); |
|
253 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.1) { |
|
254 | + $a = ($lon2 - $lon1)*$lat3 + ($lat2 - $lat1)*$lon3 + ($lat1*$lon2 + $lat2*$lon1); |
|
255 | + $a = -($lon2 - $lon1); |
|
256 | 256 | $b = $lat2 - $lat1; |
257 | - $c = -($a*$lat1+$b*$lon1); |
|
258 | - $d = $a*$lat3+$b*$lon3+$c; |
|
257 | + $c = -($a*$lat1 + $b*$lon1); |
|
258 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
259 | 259 | if ($d > -$approx && $d < $approx) return true; |
260 | 260 | else return false; |
261 | 261 | } |
262 | 262 | |
263 | 263 | public function array_merge_noappend() { |
264 | 264 | $output = array(); |
265 | - foreach(func_get_args() as $array) { |
|
266 | - foreach($array as $key => $value) { |
|
265 | + foreach (func_get_args() as $array) { |
|
266 | + foreach ($array as $key => $value) { |
|
267 | 267 | $output[$key] = isset($output[$key]) ? |
268 | 268 | array_merge($output[$key], $value) : $value; |
269 | 269 | } |
@@ -294,34 +294,34 @@ discard block |
||
294 | 294 | return $result; |
295 | 295 | } |
296 | 296 | |
297 | - function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
297 | + function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
298 | 298 | global $globalMapRefresh; |
299 | 299 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
300 | 300 | $r = 6378; |
301 | 301 | $latitude = deg2rad($latitude); |
302 | 302 | $longitude = deg2rad($longitude); |
303 | 303 | $bearing = deg2rad($heading); |
304 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
305 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
306 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
304 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
305 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
306 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
307 | 307 | } |
308 | 308 | |
309 | - function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
309 | + function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
310 | 310 | // distance in meter |
311 | 311 | $R = 6378.14; |
312 | - $latitude1 = $latitude * (M_PI/180); |
|
313 | - $longitude1 = $longitude * (M_PI/180); |
|
314 | - $brng = $bearing * (M_PI/180); |
|
312 | + $latitude1 = $latitude*(M_PI/180); |
|
313 | + $longitude1 = $longitude*(M_PI/180); |
|
314 | + $brng = $bearing*(M_PI/180); |
|
315 | 315 | $d = $distance; |
316 | 316 | |
317 | 317 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
318 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
318 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
319 | 319 | |
320 | - $latitude2 = $latitude2 * (180/M_PI); |
|
321 | - $longitude2 = $longitude2 * (180/M_PI); |
|
320 | + $latitude2 = $latitude2*(180/M_PI); |
|
321 | + $longitude2 = $longitude2*(180/M_PI); |
|
322 | 322 | |
323 | - $flat = round ($latitude2,6); |
|
324 | - $flong = round ($longitude2,6); |
|
323 | + $flat = round($latitude2, 6); |
|
324 | + $flong = round($longitude2, 6); |
|
325 | 325 | /* |
326 | 326 | $dx = $distance*cos($bearing); |
327 | 327 | $dy = $distance*sin($bearing); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $flong = $longitude + $dlong; |
331 | 331 | $flat = $latitude + $dlat; |
332 | 332 | */ |
333 | - return array('latitude' => $flat,'longitude' => $flong); |
|
333 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | \ No newline at end of file |
@@ -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; |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | public $latest_schema = 23; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver; |
|
11 | - if ($dbc === null) { |
|
10 | + global $globalDBdriver; |
|
11 | + if ($dbc === null) { |
|
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | - if ($user === null && $pass === null) { |
|
13 | + if ($user === null && $pass === null) { |
|
14 | 14 | $this->createDBConnection(); |
15 | - } else { |
|
15 | + } else { |
|
16 | 16 | $this->createDBConnection(null,$user,$pass); |
17 | - } |
|
17 | + } |
|
18 | 18 | } else { |
19 | - $this->createDBConnection($dbname); |
|
19 | + $this->createDBConnection($dbname); |
|
20 | 20 | } |
21 | - } elseif ($dbname === null || $dbname === 'default') { |
|
21 | + } elseif ($dbname === null || $dbname === 'default') { |
|
22 | 22 | $this->db = $dbc; |
23 | 23 | if ($this->connectionExists() === false) { |
24 | 24 | /* |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | */ |
29 | 29 | $this->createDBConnection(); |
30 | 30 | } |
31 | - } else { |
|
31 | + } else { |
|
32 | 32 | //$this->connectionExists(); |
33 | 33 | $this->dbs[$dbname] = $dbc; |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | - * Creates the database connection |
|
40 | - * |
|
41 | - * @return Boolean of the database connection |
|
42 | - * |
|
43 | - */ |
|
39 | + * Creates the database connection |
|
40 | + * |
|
41 | + * @return Boolean of the database connection |
|
42 | + * |
|
43 | + */ |
|
44 | 44 | |
45 | 45 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
46 | 46 | { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | if($results->rowCount()>0) { |
136 | - return true; |
|
136 | + return true; |
|
137 | 137 | } |
138 | 138 | else return false; |
139 | 139 | } |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | $sum = $sum->fetchColumn(0); |
151 | 151 | } else $sum = 0; |
152 | 152 | if (intval($sum) !== 2) { |
153 | - return false; |
|
153 | + return false; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | } catch(PDOException $e) { |
157 | 157 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
158 | - throw $e; |
|
159 | - } |
|
160 | - //echo 'error ! '.$e->getMessage(); |
|
158 | + throw $e; |
|
159 | + } |
|
160 | + //echo 'error ! '.$e->getMessage(); |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | return true; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | if($results->rowCount()>0) { |
184 | - return true; |
|
184 | + return true; |
|
185 | 185 | } |
186 | 186 | else return false; |
187 | 187 | } |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | $version = 0; |
236 | 236 | if ($this->tableExists('aircraft')) { |
237 | 237 | if (!$this->tableExists('config')) { |
238 | - $version = '1'; |
|
239 | - return $version; |
|
238 | + $version = '1'; |
|
239 | + return $version; |
|
240 | 240 | } else { |
241 | 241 | $Connection = new Connection(); |
242 | 242 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @return Boolean if latest version or not |
258 | 258 | */ |
259 | 259 | public function latest() { |
260 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
261 | - else return false; |
|
260 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
261 | + else return false; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | } |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 23; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalDBdriver; |
11 | 11 | if ($dbc === null) { |
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | 13 | if ($user === null && $pass === null) { |
14 | 14 | $this->createDBConnection(); |
15 | 15 | } else { |
16 | - $this->createDBConnection(null,$user,$pass); |
|
16 | + $this->createDBConnection(null, $user, $pass); |
|
17 | 17 | } |
18 | 18 | } else { |
19 | 19 | $this->createDBConnection($dbname); |
@@ -80,32 +80,32 @@ discard block |
||
80 | 80 | while (true) { |
81 | 81 | try { |
82 | 82 | if ($globalDBSdriver == 'mysql') { |
83 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
83 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
84 | 84 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
85 | 85 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
86 | - $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); |
|
86 | + $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); |
|
91 | 91 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
92 | 92 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
93 | 93 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
94 | 94 | // to enable it : $this->dbs[$DBname]->exec('SET sql_mode = "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY"'); |
95 | 95 | $this->dbs[$DBname]->exec('SET sql_mode = "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'); |
96 | 96 | } else { |
97 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
97 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
98 | 98 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
99 | 99 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
100 | - $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); |
|
100 | + $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); |
|
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
106 | 106 | } |
107 | 107 | break; |
108 | - } catch(PDOException $e) { |
|
108 | + } catch (PDOException $e) { |
|
109 | 109 | $i++; |
110 | 110 | if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
111 | 111 | //exit; |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | try { |
130 | 130 | //$Connection = new Connection(); |
131 | 131 | $results = $this->db->query($query); |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | - if($results->rowCount()>0) { |
|
135 | + if ($results->rowCount() > 0) { |
|
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | else return false; |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - } catch(PDOException $e) { |
|
157 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
156 | + } catch (PDOException $e) { |
|
157 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
158 | 158 | throw $e; |
159 | 159 | } |
160 | 160 | //echo 'error ! '.$e->getMessage(); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | /* |
167 | 167 | * Check if index exist |
168 | 168 | */ |
169 | - public function indexExists($table,$index) |
|
169 | + public function indexExists($table, $index) |
|
170 | 170 | { |
171 | 171 | global $globalDBdriver, $globalDBname; |
172 | 172 | if ($globalDBdriver == 'mysql') { |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | try { |
178 | 178 | //$Connection = new Connection(); |
179 | 179 | $results = $this->db->query($query); |
180 | - } catch(PDOException $e) { |
|
180 | + } catch (PDOException $e) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | - if($results->rowCount()>0) { |
|
183 | + if ($results->rowCount() > 0) { |
|
184 | 184 | return true; |
185 | 185 | } |
186 | 186 | else return false; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
196 | 196 | try { |
197 | 197 | $results = $this->db->query($query); |
198 | - } catch(PDOException $e) { |
|
198 | + } catch (PDOException $e) { |
|
199 | 199 | return "error : ".$e->getMessage()."\n"; |
200 | 200 | } |
201 | 201 | $columns = array(); |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | * Check if a column name exist in a table |
212 | 212 | * @return Boolean column exist or not |
213 | 213 | */ |
214 | - public function checkColumnName($table,$name) |
|
214 | + public function checkColumnName($table, $name) |
|
215 | 215 | { |
216 | 216 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
217 | 217 | try { |
218 | 218 | $results = $this->db->query($query); |
219 | - } catch(PDOException $e) { |
|
219 | + } catch (PDOException $e) { |
|
220 | 220 | return "error : ".$e->getMessage()."\n"; |
221 | 221 | } |
222 | 222 | $colcnt = $results->columnCount(); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | try { |
244 | 244 | $sth = $this->db->prepare($query); |
245 | 245 | $sth->execute(); |
246 | - } catch(PDOException $e) { |
|
246 | + } catch (PDOException $e) { |
|
247 | 247 | return "error : ".$e->getMessage()."\n"; |
248 | 248 | } |
249 | 249 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -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'; |
@@ -4,27 +4,27 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/settings.php'); |
5 | 5 | |
6 | 6 | class Image { |
7 | - public $db; |
|
7 | + public $db; |
|
8 | 8 | |
9 | - function __construct($dbc = null) { |
|
10 | - $Connection = new Connection($dbc); |
|
11 | - $this->db = $Connection->db; |
|
12 | - } |
|
9 | + function __construct($dbc = null) { |
|
10 | + $Connection = new Connection($dbc); |
|
11 | + $this->db = $Connection->db; |
|
12 | + } |
|
13 | 13 | |
14 | - /** |
|
15 | - * Gets the images based on the aircraft registration |
|
16 | - * |
|
17 | - * @return Array the images list |
|
18 | - * |
|
19 | - */ |
|
20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
21 | - { |
|
22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
14 | + /** |
|
15 | + * Gets the images based on the aircraft registration |
|
16 | + * |
|
17 | + * @return Array the images list |
|
18 | + * |
|
19 | + */ |
|
20 | + public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
21 | + { |
|
22 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
25 | + if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
26 | 26 | |
27 | - $registration = trim($registration); |
|
27 | + $registration = trim($registration); |
|
28 | 28 | |
29 | 29 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
30 | 30 | FROM spotter_image |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | $sth = $this->db->prepare($query); |
35 | 35 | $sth->execute(array(':registration' => $registration)); |
36 | - /* |
|
36 | + /* |
|
37 | 37 | $images_array = array(); |
38 | 38 | $temp_array = array(); |
39 | 39 | |
@@ -52,36 +52,36 @@ discard block |
||
52 | 52 | |
53 | 53 | return $images_array; |
54 | 54 | */ |
55 | - return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
56 | - } |
|
55 | + return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Gets the image copyright based on the Exif data |
|
60 | - * |
|
61 | - * @return String image copyright |
|
62 | - * |
|
63 | - */ |
|
64 | - public function getExifCopyright($url) { |
|
65 | - $exif = exif_read_data($url); |
|
66 | - $copyright = ''; |
|
67 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
68 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
69 | - if ($copyright != '') { |
|
70 | - $copyright = str_replace('Copyright ','',$copyright); |
|
71 | - $copyright = str_replace('© ','',$copyright); |
|
72 | - $copyright = str_replace('(c) ','',$copyright); |
|
73 | - } |
|
74 | - return $copyright; |
|
75 | - } |
|
58 | + /** |
|
59 | + * Gets the image copyright based on the Exif data |
|
60 | + * |
|
61 | + * @return String image copyright |
|
62 | + * |
|
63 | + */ |
|
64 | + public function getExifCopyright($url) { |
|
65 | + $exif = exif_read_data($url); |
|
66 | + $copyright = ''; |
|
67 | + if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
68 | + elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
69 | + if ($copyright != '') { |
|
70 | + $copyright = str_replace('Copyright ','',$copyright); |
|
71 | + $copyright = str_replace('© ','',$copyright); |
|
72 | + $copyright = str_replace('(c) ','',$copyright); |
|
73 | + } |
|
74 | + return $copyright; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Adds the images based on the aircraft registration |
|
79 | - * |
|
80 | - * @return String either success or error |
|
81 | - * |
|
82 | - */ |
|
83 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
84 | - { |
|
77 | + /** |
|
78 | + * Adds the images based on the aircraft registration |
|
79 | + * |
|
80 | + * @return String either success or error |
|
81 | + * |
|
82 | + */ |
|
83 | + public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
84 | + { |
|
85 | 85 | global $globalAircraftImageFetch; |
86 | 86 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
87 | 87 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -90,29 +90,29 @@ discard block |
||
90 | 90 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
91 | 91 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
92 | 92 | if ($image_url['original'] != '') { |
93 | - $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 | - try { |
|
93 | + $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 | + try { |
|
95 | 95 | |
96 | 96 | $sth = $this->db->prepare($query); |
97 | 97 | $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
98 | - } catch(PDOException $e) { |
|
98 | + } catch(PDOException $e) { |
|
99 | 99 | echo $e->getMessage."\n"; |
100 | 100 | return "error"; |
101 | - } |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | return "success"; |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * Gets the aircraft image |
|
109 | - * |
|
110 | - * @param String $aircraft_registration the registration of the aircraft |
|
111 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
112 | - * |
|
113 | - */ |
|
114 | - public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
|
115 | - { |
|
107 | + /** |
|
108 | + * Gets the aircraft image |
|
109 | + * |
|
110 | + * @param String $aircraft_registration the registration of the aircraft |
|
111 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
112 | + * |
|
113 | + */ |
|
114 | + public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
|
115 | + { |
|
116 | 116 | global $globalAircraftImageSources, $globalIVAO; |
117 | 117 | $Spotter = new Spotter($this->db); |
118 | 118 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
@@ -120,17 +120,17 @@ discard block |
||
120 | 120 | |
121 | 121 | if ($aircraft_registration != '') { |
122 | 122 | if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
123 | - $aircraft_registration = urlencode(trim($aircraft_registration)); |
|
124 | - $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 = ''; |
|
131 | - } elseif ($aircraft_icao != '') { |
|
132 | - $aircraft_registration = $aircraft_icao; |
|
133 | - $aircraft_name = ''; |
|
123 | + $aircraft_registration = urlencode(trim($aircraft_registration)); |
|
124 | + $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 = ''; |
|
131 | + } elseif ($aircraft_icao != '') { |
|
132 | + $aircraft_registration = $aircraft_icao; |
|
133 | + $aircraft_name = ''; |
|
134 | 134 | } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
135 | 135 | |
136 | 136 | if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
151 | 151 | } |
152 | 152 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
153 | - } |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * Gets the aircraft image from Planespotters |
|
157 | - * |
|
158 | - * @param String $aircraft_registration the registration of the aircraft |
|
159 | - * @param String $aircraft_name type of the aircraft |
|
160 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
161 | - * |
|
162 | - */ |
|
163 | - public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
|
155 | + /** |
|
156 | + * Gets the aircraft image from Planespotters |
|
157 | + * |
|
158 | + * @param String $aircraft_registration the registration of the aircraft |
|
159 | + * @param String $aircraft_name type of the aircraft |
|
160 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
161 | + * |
|
162 | + */ |
|
163 | + public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
|
164 | 164 | $Common = new Common(); |
165 | 165 | // If aircraft registration is only number, also check with aircraft model |
166 | 166 | if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
167 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
167 | + $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
168 | 168 | } else { |
169 | - //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
|
170 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
169 | + //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
|
170 | + $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | $data = $Common->getData($url); |
174 | 174 | if ($xml = simplexml_load_string($data)) { |
175 | - if (isset($xml->channel->item)) { |
|
175 | + if (isset($xml->channel->item)) { |
|
176 | 176 | $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
177 | 177 | $image_url['thumbnail'] = $thumbnail_url; |
178 | 178 | $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
@@ -180,31 +180,31 @@ discard block |
||
180 | 180 | $image_url['source_website'] = trim((string)$xml->channel->item->link); |
181 | 181 | $image_url['source'] = 'planespotters'; |
182 | 182 | return $image_url; |
183 | - } |
|
183 | + } |
|
184 | 184 | } |
185 | 185 | return false; |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * Gets the aircraft image from Deviantart |
|
190 | - * |
|
191 | - * @param String $aircraft_registration the registration of the aircraft |
|
192 | - * @param String $aircraft_name type of the aircraft |
|
193 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
194 | - * |
|
195 | - */ |
|
196 | - public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
|
188 | + /** |
|
189 | + * Gets the aircraft image from Deviantart |
|
190 | + * |
|
191 | + * @param String $aircraft_registration the registration of the aircraft |
|
192 | + * @param String $aircraft_name type of the aircraft |
|
193 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
194 | + * |
|
195 | + */ |
|
196 | + public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
|
197 | 197 | $Common = new Common(); |
198 | 198 | // If aircraft registration is only number, also check with aircraft model |
199 | 199 | if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
200 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
200 | + $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
201 | 201 | } else { |
202 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
202 | + $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $data = $Common->getData($url); |
206 | 206 | if ($xml = simplexml_load_string($data)) { |
207 | - if (isset($xml->channel->item->link)) { |
|
207 | + if (isset($xml->channel->item->link)) { |
|
208 | 208 | $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
209 | 209 | $image_url['thumbnail'] = $thumbnail_url; |
210 | 210 | $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | $image_url['source_website'] = trim((string)$xml->channel->item->link); |
214 | 214 | $image_url['source'] = 'deviantart'; |
215 | 215 | return $image_url; |
216 | - } |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | return false; |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Gets the aircraft image from JetPhotos |
|
223 | - * |
|
224 | - * @param String $aircraft_registration the registration of the aircraft |
|
225 | - * @param String $aircraft_name type of the aircraft |
|
226 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
227 | - * |
|
228 | - */ |
|
229 | - public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
|
221 | + /** |
|
222 | + * Gets the aircraft image from JetPhotos |
|
223 | + * |
|
224 | + * @param String $aircraft_registration the registration of the aircraft |
|
225 | + * @param String $aircraft_name type of the aircraft |
|
226 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
227 | + * |
|
228 | + */ |
|
229 | + public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
|
230 | 230 | $Common = new Common(); |
231 | 231 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
232 | 232 | |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | @$dom->loadHTML($data); |
236 | 236 | $all_pics = array(); |
237 | 237 | foreach($dom->getElementsByTagName('img') as $image) { |
238 | - if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
|
238 | + if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
|
239 | 239 | $all_pics[] = $image->getAttribute('src'); |
240 | - } |
|
240 | + } |
|
241 | 241 | } |
242 | 242 | $all_authors = array(); |
243 | 243 | foreach($dom->getElementsByTagName('meta') as $author) { |
244 | - if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
|
244 | + if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
|
245 | 245 | $all_authors[] = $author->getAttribute('content'); |
246 | - } |
|
246 | + } |
|
247 | 247 | } |
248 | 248 | $all_ref = array(); |
249 | 249 | foreach($dom->getElementsByTagName('a') as $link) { |
250 | - $all_ref[] = $link->getAttribute('href'); |
|
250 | + $all_ref[] = $link->getAttribute('href'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | if (isset($all_pics[0])) { |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | return $image_url; |
260 | 260 | } |
261 | 261 | return false; |
262 | - } |
|
262 | + } |
|
263 | 263 | |
264 | - /** |
|
265 | - * Gets the aircraft image from PlanePictures |
|
266 | - * |
|
267 | - * @param String $aircraft_registration the registration of the aircraft |
|
268 | - * @param String $aircraft_name type of the aircraft |
|
269 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
270 | - * |
|
271 | - */ |
|
272 | - public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
|
264 | + /** |
|
265 | + * Gets the aircraft image from PlanePictures |
|
266 | + * |
|
267 | + * @param String $aircraft_registration the registration of the aircraft |
|
268 | + * @param String $aircraft_name type of the aircraft |
|
269 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
270 | + * |
|
271 | + */ |
|
272 | + public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
|
273 | 273 | $Common = new Common(); |
274 | 274 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
275 | 275 | |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | @$dom->loadHTML($data); |
279 | 279 | $all_pics = array(); |
280 | 280 | foreach($dom->getElementsByTagName('img') as $image) { |
281 | - $all_pics[] = $image->getAttribute('src'); |
|
281 | + $all_pics[] = $image->getAttribute('src'); |
|
282 | 282 | } |
283 | 283 | $all_links = array(); |
284 | 284 | foreach($dom->getElementsByTagName('a') as $link) { |
285 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
285 | + $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
286 | 286 | } |
287 | 287 | if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) { |
288 | 288 | $image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1]; |
@@ -293,26 +293,26 @@ discard block |
||
293 | 293 | return $image_url; |
294 | 294 | } |
295 | 295 | return false; |
296 | - } |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
299 | - * Gets the aircraft image from Flickr |
|
300 | - * |
|
301 | - * @param String $aircraft_registration the registration of the aircraft |
|
302 | - * @param String $aircraft_name type of the aircraft |
|
303 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
304 | - * |
|
305 | - */ |
|
306 | - public function fromFlickr($aircraft_registration,$aircraft_name='') { |
|
298 | + /** |
|
299 | + * Gets the aircraft image from Flickr |
|
300 | + * |
|
301 | + * @param String $aircraft_registration the registration of the aircraft |
|
302 | + * @param String $aircraft_name type of the aircraft |
|
303 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
304 | + * |
|
305 | + */ |
|
306 | + public function fromFlickr($aircraft_registration,$aircraft_name='') { |
|
307 | 307 | $Common = new Common(); |
308 | 308 | |
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'; |
|
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'; |
|
311 | 311 | |
312 | 312 | $data = $Common->getData($url); |
313 | 313 | |
314 | 314 | if ($xml = simplexml_load_string($data)) { |
315 | - if (isset($xml->channel->item)) { |
|
315 | + if (isset($xml->channel->item)) { |
|
316 | 316 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
317 | 317 | $image_url['thumbnail'] = $original_url; |
318 | 318 | $image_url['original'] = $original_url; |
@@ -320,39 +320,39 @@ discard block |
||
320 | 320 | $image_url['source_website'] = trim((string)$xml->channel->item->link); |
321 | 321 | $image_url['source'] = 'flickr'; |
322 | 322 | return $image_url; |
323 | - } |
|
323 | + } |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return false; |
327 | - } |
|
327 | + } |
|
328 | 328 | |
329 | 329 | |
330 | - public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
|
330 | + public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
|
331 | 331 | $Common = new Common(); |
332 | 332 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
333 | 333 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
334 | - $image_url['thumbnail'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
|
335 | - $image_url['original'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
|
336 | - $image_url['copyright'] = 'IVAO'; |
|
337 | - $image_url['source_website'] = 'http://mtlcatalog.ivao.aero/'; |
|
338 | - $image_url['source'] = 'ivao.aero'; |
|
339 | - return $image_url; |
|
334 | + $image_url['thumbnail'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
|
335 | + $image_url['original'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
|
336 | + $image_url['copyright'] = 'IVAO'; |
|
337 | + $image_url['source_website'] = 'http://mtlcatalog.ivao.aero/'; |
|
338 | + $image_url['source'] = 'ivao.aero'; |
|
339 | + return $image_url; |
|
340 | 340 | } else { |
341 | - return false; |
|
341 | + return false; |
|
342 | 342 | } |
343 | 343 | |
344 | - } |
|
344 | + } |
|
345 | 345 | |
346 | 346 | |
347 | - /** |
|
348 | - * Gets the aircraft image from Bing |
|
349 | - * |
|
350 | - * @param String $aircraft_registration the registration of the aircraft |
|
351 | - * @param String $aircraft_name type of the aircraft |
|
352 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
353 | - * |
|
354 | - */ |
|
355 | - public function fromBing($aircraft_registration,$aircraft_name='') { |
|
347 | + /** |
|
348 | + * Gets the aircraft image from Bing |
|
349 | + * |
|
350 | + * @param String $aircraft_registration the registration of the aircraft |
|
351 | + * @param String $aircraft_name type of the aircraft |
|
352 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
353 | + * |
|
354 | + */ |
|
355 | + public function fromBing($aircraft_registration,$aircraft_name='') { |
|
356 | 356 | global $globalImageBingKey; |
357 | 357 | $Common = new Common(); |
358 | 358 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -365,54 +365,54 @@ discard block |
||
365 | 365 | |
366 | 366 | $result = json_decode($data); |
367 | 367 | if (isset($result->d->results[0]->MediaUrl)) { |
368 | - $image_url['original'] = $result->d->results[0]->MediaUrl; |
|
369 | - $image_url['source_website'] = $result->d->results[0]->SourceUrl; |
|
370 | - // Thumbnail can't be used this way... |
|
371 | - // $image_url['thumbnail'] = $result->d->results[0]->Thumbnail->MediaUrl; |
|
372 | - $image_url['thumbnail'] = $result->d->results[0]->MediaUrl; |
|
373 | - $url = parse_url($image_url['source_website']); |
|
374 | - $image_url['copyright'] = $url['host']; |
|
375 | - $image_url['source'] = 'bing'; |
|
376 | - return $image_url; |
|
368 | + $image_url['original'] = $result->d->results[0]->MediaUrl; |
|
369 | + $image_url['source_website'] = $result->d->results[0]->SourceUrl; |
|
370 | + // Thumbnail can't be used this way... |
|
371 | + // $image_url['thumbnail'] = $result->d->results[0]->Thumbnail->MediaUrl; |
|
372 | + $image_url['thumbnail'] = $result->d->results[0]->MediaUrl; |
|
373 | + $url = parse_url($image_url['source_website']); |
|
374 | + $image_url['copyright'] = $url['host']; |
|
375 | + $image_url['source'] = 'bing'; |
|
376 | + return $image_url; |
|
377 | 377 | } |
378 | 378 | return false; |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | - /** |
|
382 | - * Gets the aircraft image from airport-data |
|
383 | - * |
|
384 | - * @param String $aircraft_registration the registration of the aircraft |
|
385 | - * @param String $aircraft_name type of the aircraft |
|
386 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
387 | - * |
|
388 | - */ |
|
389 | - public function fromAirportData($aircraft_registration,$aircraft_name='') { |
|
381 | + /** |
|
382 | + * Gets the aircraft image from airport-data |
|
383 | + * |
|
384 | + * @param String $aircraft_registration the registration of the aircraft |
|
385 | + * @param String $aircraft_name type of the aircraft |
|
386 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
387 | + * |
|
388 | + */ |
|
389 | + public function fromAirportData($aircraft_registration,$aircraft_name='') { |
|
390 | 390 | $Common = new Common(); |
391 | 391 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
392 | 392 | $data = $Common->getData($url); |
393 | 393 | $result = json_decode($data); |
394 | 394 | |
395 | 395 | if (isset($result->count) && $result->count > 0) { |
396 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
397 | - $image_url['source_website'] = $result->data[0]->link; |
|
398 | - $image_url['thumbnail'] = $result->data[0]->image; |
|
399 | - $image_url['copyright'] = $result->data[0]->photographer; |
|
400 | - $image_url['source'] = 'AirportData'; |
|
396 | + $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
397 | + $image_url['source_website'] = $result->data[0]->link; |
|
398 | + $image_url['thumbnail'] = $result->data[0]->image; |
|
399 | + $image_url['copyright'] = $result->data[0]->photographer; |
|
400 | + $image_url['source'] = 'AirportData'; |
|
401 | 401 | |
402 | - return $image_url; |
|
402 | + return $image_url; |
|
403 | 403 | } |
404 | 404 | return false; |
405 | - } |
|
405 | + } |
|
406 | 406 | |
407 | - /** |
|
408 | - * Gets the aircraft image from WikiMedia |
|
409 | - * |
|
410 | - * @param String $aircraft_registration the registration of the aircraft |
|
411 | - * @param String $aircraft_name type of the aircraft |
|
412 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
413 | - * |
|
414 | - */ |
|
415 | - public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
|
407 | + /** |
|
408 | + * Gets the aircraft image from WikiMedia |
|
409 | + * |
|
410 | + * @param String $aircraft_registration the registration of the aircraft |
|
411 | + * @param String $aircraft_name type of the aircraft |
|
412 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
413 | + * |
|
414 | + */ |
|
415 | + public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
|
416 | 416 | $Common = new Common(); |
417 | 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 | 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'; |
@@ -420,59 +420,59 @@ discard block |
||
420 | 420 | $data = $Common->getData($url); |
421 | 421 | $result = json_decode($data); |
422 | 422 | if (isset($result->query->search[0]->title)) { |
423 | - $fileo = $result->query->search[0]->title; |
|
424 | - if (substr($fileo,-3) == 'pdf') return false; |
|
425 | - $file = urlencode($fileo); |
|
426 | - $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; |
|
423 | + $fileo = $result->query->search[0]->title; |
|
424 | + if (substr($fileo,-3) == 'pdf') return false; |
|
425 | + $file = urlencode($fileo); |
|
426 | + $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 | 427 | |
428 | - $data2 = $Common->getData($url2); |
|
429 | - $result2 = json_decode($data2); |
|
430 | - if (isset($result2->query->pages)) { |
|
428 | + $data2 = $Common->getData($url2); |
|
429 | + $result2 = json_decode($data2); |
|
430 | + if (isset($result2->query->pages)) { |
|
431 | 431 | foreach ($result2->query->pages as $page) { |
432 | - if (isset($page->imageinfo[0]->user)) { |
|
432 | + if (isset($page->imageinfo[0]->user)) { |
|
433 | 433 | $image_url['copyright'] = 'Wikimedia, '.$page->imageinfo[0]->user; |
434 | 434 | $image_url['original'] = $page->imageinfo[0]->url; |
435 | 435 | $image_url['thumbnail'] = $page->imageinfo[0]->thumburl; |
436 | 436 | $image_url['source'] = 'wikimedia'; |
437 | 437 | $image_url['source_website'] = 'http://commons.wikimedia.org/wiki/'.$fileo; |
438 | 438 | //return $image_url; |
439 | - } |
|
439 | + } |
|
440 | + } |
|
440 | 441 | } |
441 | - } |
|
442 | 442 | |
443 | - if (isset($image_url['original'])) { |
|
443 | + if (isset($image_url['original'])) { |
|
444 | 444 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&iiprop=extmetadata&format=json&continue&titles='.$file; |
445 | 445 | |
446 | 446 | $data2 = $Common->getData($url2); |
447 | 447 | $result2 = json_decode($data2); |
448 | 448 | if (isset($result2->query->pages)) { |
449 | - foreach ($result2->query->pages as $page) { |
|
449 | + foreach ($result2->query->pages as $page) { |
|
450 | 450 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
451 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
452 | - if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
|
453 | - $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
|
454 | - } |
|
455 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
456 | - return $image_url; |
|
451 | + $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
452 | + if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
|
453 | + $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
|
454 | + } |
|
455 | + $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
456 | + return $image_url; |
|
457 | + } |
|
457 | 458 | } |
458 | - } |
|
459 | 459 | } |
460 | 460 | return $image_url; |
461 | - } |
|
461 | + } |
|
462 | 462 | |
463 | 463 | } |
464 | 464 | return false; |
465 | - } |
|
465 | + } |
|
466 | 466 | |
467 | - /** |
|
468 | - * Gets the aircraft image from custom url |
|
469 | - * |
|
470 | - * @param String $aircraft_registration the registration of the aircraft |
|
471 | - * @param String $aircraft_name type of the aircraft |
|
472 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
473 | - * |
|
474 | - */ |
|
475 | - public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
|
467 | + /** |
|
468 | + * Gets the aircraft image from custom url |
|
469 | + * |
|
470 | + * @param String $aircraft_registration the registration of the aircraft |
|
471 | + * @param String $aircraft_name type of the aircraft |
|
472 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
473 | + * |
|
474 | + */ |
|
475 | + public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
|
476 | 476 | global $globalAircraftCustomSources; |
477 | 477 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
478 | 478 | if (!empty($globalAircraftImageCustomSources)) { |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | } |
496 | 496 | return false; |
497 | 497 | } else return false; |
498 | - } |
|
498 | + } |
|
499 | 499 | |
500 | 500 | |
501 | 501 |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | * @return Array the images list |
18 | 18 | * |
19 | 19 | */ |
20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
21 | 21 | { |
22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
25 | 25 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
26 | 26 | |
27 | 27 | $registration = trim($registration); |
28 | 28 | |
29 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
|
29 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
|
30 | 30 | FROM spotter_image |
31 | 31 | WHERE spotter_image.registration = :registration"; |
32 | 32 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
68 | 68 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
69 | 69 | if ($copyright != '') { |
70 | - $copyright = str_replace('Copyright ','',$copyright); |
|
71 | - $copyright = str_replace('© ','',$copyright); |
|
72 | - $copyright = str_replace('(c) ','',$copyright); |
|
70 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
71 | + $copyright = str_replace('© ', '', $copyright); |
|
72 | + $copyright = str_replace('(c) ', '', $copyright); |
|
73 | 73 | } |
74 | 74 | return $copyright; |
75 | 75 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * @return String either success or error |
81 | 81 | * |
82 | 82 | */ |
83 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
83 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
84 | 84 | { |
85 | 85 | global $globalAircraftImageFetch; |
86 | 86 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
87 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
87 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
88 | 88 | $registration = trim($registration); |
89 | 89 | //getting the aircraft image |
90 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
90 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
91 | 91 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
92 | 92 | if ($image_url['original'] != '') { |
93 | - $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)"; |
|
93 | + $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 | 94 | try { |
95 | 95 | |
96 | 96 | $sth = $this->db->prepare($query); |
97 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
98 | - } catch(PDOException $e) { |
|
97 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
98 | + } catch (PDOException $e) { |
|
99 | 99 | echo $e->getMessage."\n"; |
100 | 100 | return "error"; |
101 | 101 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | global $globalAircraftImageSources, $globalIVAO; |
117 | 117 | $Spotter = new Spotter($this->db); |
118 | 118 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
119 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
119 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
120 | 120 | |
121 | 121 | if ($aircraft_registration != '') { |
122 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
122 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
123 | 123 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
124 | 124 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
125 | 125 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | } elseif ($aircraft_icao != '') { |
132 | 132 | $aircraft_registration = $aircraft_icao; |
133 | 133 | $aircraft_name = ''; |
134 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
134 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
135 | 135 | |
136 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
136 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
137 | 137 | |
138 | 138 | foreach ($globalAircraftImageSources as $source) { |
139 | 139 | $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); |
|
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 | 150 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
151 | 151 | } |
152 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
152 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,24 +160,24 @@ discard block |
||
160 | 160 | * @return Array the aircraft thumbnail, orignal url and copyright |
161 | 161 | * |
162 | 162 | */ |
163 | - public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
|
163 | + public function fromPlanespotters($aircraft_registration, $aircraft_name = '') { |
|
164 | 164 | $Common = new Common(); |
165 | 165 | // If aircraft registration is only number, also check with aircraft model |
166 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
167 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
166 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
167 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
168 | 168 | } else { |
169 | 169 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
170 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
170 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | $data = $Common->getData($url); |
174 | 174 | if ($xml = simplexml_load_string($data)) { |
175 | 175 | if (isset($xml->channel->item)) { |
176 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
176 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
177 | 177 | $image_url['thumbnail'] = $thumbnail_url; |
178 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
179 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
180 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
178 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
179 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
180 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
181 | 181 | $image_url['source'] = 'planespotters'; |
182 | 182 | return $image_url; |
183 | 183 | } |
@@ -193,24 +193,24 @@ discard block |
||
193 | 193 | * @return Array the aircraft thumbnail, orignal url and copyright |
194 | 194 | * |
195 | 195 | */ |
196 | - public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
|
196 | + public function fromDeviantart($aircraft_registration, $aircraft_name = '') { |
|
197 | 197 | $Common = new Common(); |
198 | 198 | // If aircraft registration is only number, also check with aircraft model |
199 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
200 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
199 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
200 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
201 | 201 | } else { |
202 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
202 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $data = $Common->getData($url); |
206 | 206 | if ($xml = simplexml_load_string($data)) { |
207 | 207 | if (isset($xml->channel->item->link)) { |
208 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
208 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
209 | 209 | $image_url['thumbnail'] = $thumbnail_url; |
210 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
210 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
211 | 211 | $image_url['original'] = $original_url; |
212 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
213 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
212 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
213 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
214 | 214 | $image_url['source'] = 'deviantart'; |
215 | 215 | return $image_url; |
216 | 216 | } |
@@ -226,33 +226,33 @@ discard block |
||
226 | 226 | * @return Array the aircraft thumbnail, orignal url and copyright |
227 | 227 | * |
228 | 228 | */ |
229 | - public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
|
229 | + public function fromJetPhotos($aircraft_registration, $aircraft_name = '') { |
|
230 | 230 | $Common = new Common(); |
231 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
231 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
232 | 232 | |
233 | 233 | $data = $Common->getData($url); |
234 | 234 | $dom = new DOMDocument(); |
235 | 235 | @$dom->loadHTML($data); |
236 | 236 | $all_pics = array(); |
237 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
237 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
238 | 238 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
239 | 239 | $all_pics[] = $image->getAttribute('src'); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | $all_authors = array(); |
243 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
243 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
244 | 244 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
245 | 245 | $all_authors[] = $author->getAttribute('content'); |
246 | 246 | } |
247 | 247 | } |
248 | 248 | $all_ref = array(); |
249 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
249 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
250 | 250 | $all_ref[] = $link->getAttribute('href'); |
251 | 251 | } |
252 | 252 | |
253 | 253 | if (isset($all_pics[0])) { |
254 | 254 | $image_url['thumbnail'] = $all_pics[0]; |
255 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
255 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
256 | 256 | $image_url['copyright'] = $all_authors[0]; |
257 | 257 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
258 | 258 | $image_url['source'] = 'JetPhotos'; |
@@ -269,24 +269,24 @@ discard block |
||
269 | 269 | * @return Array the aircraft thumbnail, orignal url and copyright |
270 | 270 | * |
271 | 271 | */ |
272 | - public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
|
272 | + public function fromPlanePictures($aircraft_registration, $aircraft_name = '') { |
|
273 | 273 | $Common = new Common(); |
274 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
274 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
275 | 275 | |
276 | 276 | $data = $Common->getData($url); |
277 | 277 | $dom = new DOMDocument(); |
278 | 278 | @$dom->loadHTML($data); |
279 | 279 | $all_pics = array(); |
280 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
280 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
281 | 281 | $all_pics[] = $image->getAttribute('src'); |
282 | 282 | } |
283 | 283 | $all_links = array(); |
284 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
285 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
284 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
285 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
286 | 286 | } |
287 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) { |
|
287 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) { |
|
288 | 288 | $image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1]; |
289 | - $image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]); |
|
289 | + $image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]); |
|
290 | 290 | $image_url['copyright'] = $all_links[6]['text']; |
291 | 291 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
292 | 292 | $image_url['source'] = 'PlanePictures'; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @return Array the aircraft thumbnail, orignal url and copyright |
304 | 304 | * |
305 | 305 | */ |
306 | - public function fromFlickr($aircraft_registration,$aircraft_name='') { |
|
306 | + public function fromFlickr($aircraft_registration, $aircraft_name = '') { |
|
307 | 307 | $Common = new Common(); |
308 | 308 | |
309 | 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); |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | |
314 | 314 | if ($xml = simplexml_load_string($data)) { |
315 | 315 | if (isset($xml->channel->item)) { |
316 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
316 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
317 | 317 | $image_url['thumbnail'] = $original_url; |
318 | 318 | $image_url['original'] = $original_url; |
319 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
320 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
319 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
320 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
321 | 321 | $image_url['source'] = 'flickr'; |
322 | 322 | return $image_url; |
323 | 323 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | |
330 | - public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
|
330 | + public function fromIvaoMtl($aircraft_icao, $airline_icao) { |
|
331 | 331 | $Common = new Common(); |
332 | 332 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
333 | 333 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -352,16 +352,16 @@ discard block |
||
352 | 352 | * @return Array the aircraft thumbnail, orignal url and copyright |
353 | 353 | * |
354 | 354 | */ |
355 | - public function fromBing($aircraft_registration,$aircraft_name='') { |
|
355 | + public function fromBing($aircraft_registration, $aircraft_name = '') { |
|
356 | 356 | global $globalImageBingKey; |
357 | 357 | $Common = new Common(); |
358 | 358 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
359 | 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 | 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'; |
361 | 361 | |
362 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
362 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
363 | 363 | |
364 | - $data = $Common->getData($url,'get','',$headers); |
|
364 | + $data = $Common->getData($url, 'get', '', $headers); |
|
365 | 365 | |
366 | 366 | $result = json_decode($data); |
367 | 367 | if (isset($result->d->results[0]->MediaUrl)) { |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | * @return Array the aircraft thumbnail, orignal url and copyright |
387 | 387 | * |
388 | 388 | */ |
389 | - public function fromAirportData($aircraft_registration,$aircraft_name='') { |
|
389 | + public function fromAirportData($aircraft_registration, $aircraft_name = '') { |
|
390 | 390 | $Common = new Common(); |
391 | 391 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
392 | 392 | $data = $Common->getData($url); |
393 | 393 | $result = json_decode($data); |
394 | 394 | |
395 | 395 | if (isset($result->count) && $result->count > 0) { |
396 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
396 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
397 | 397 | $image_url['source_website'] = $result->data[0]->link; |
398 | 398 | $image_url['thumbnail'] = $result->data[0]->image; |
399 | 399 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return Array the aircraft thumbnail, orignal url and copyright |
413 | 413 | * |
414 | 414 | */ |
415 | - public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
|
415 | + public function fromWikimedia($aircraft_registration, $aircraft_name = '') { |
|
416 | 416 | $Common = new Common(); |
417 | 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 | 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'; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $result = json_decode($data); |
422 | 422 | if (isset($result->query->search[0]->title)) { |
423 | 423 | $fileo = $result->query->search[0]->title; |
424 | - if (substr($fileo,-3) == 'pdf') return false; |
|
424 | + if (substr($fileo, -3) == 'pdf') return false; |
|
425 | 425 | $file = urlencode($fileo); |
426 | 426 | $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 | 427 | |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | if (isset($result2->query->pages)) { |
449 | 449 | foreach ($result2->query->pages as $page) { |
450 | 450 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
451 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
451 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
452 | 452 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
453 | 453 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
454 | 454 | } |
455 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
455 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
456 | 456 | return $image_url; |
457 | 457 | } |
458 | 458 | } |
@@ -472,21 +472,21 @@ discard block |
||
472 | 472 | * @return Array the aircraft thumbnail, orignal url and copyright |
473 | 473 | * |
474 | 474 | */ |
475 | - public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
|
475 | + public function fromCustomSource($aircraft_registration, $aircraft_name = '') { |
|
476 | 476 | global $globalAircraftCustomSources; |
477 | 477 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
478 | 478 | if (!empty($globalAircraftImageCustomSources)) { |
479 | 479 | if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
480 | 480 | foreach ($globalAircraftImageCustomSources as $source) { |
481 | 481 | $Common = new Common(); |
482 | - $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
483 | - $url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
482 | + $url = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
483 | + $url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
484 | 484 | if ($Common->urlexist($url)) { |
485 | 485 | $image_url['thumbnail'] = $url_thumbnail; |
486 | 486 | $image_url['original'] = $url; |
487 | 487 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
488 | 488 | else $exifCopyright = ''; |
489 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
489 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
490 | 490 | else $image_url['copyright'] = $source['copyright']; |
491 | 491 | $image_url['source_website'] = $source['source_website']; |
492 | 492 | $image_url['source'] = $source['source']; |
@@ -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 | { |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!function_exists("gettext")) { |
4 | - function _($text) { |
|
5 | - return $text; |
|
6 | - } |
|
4 | + function _($text) { |
|
5 | + return $text; |
|
6 | + } |
|
7 | 7 | } else { |
8 | 8 | if (isset($_COOKIE['language']) && $_COOKIE['language'] != 'en_GB' && (isset($globalTranslate) && $globalTranslate)) { |
9 | 9 | $Language = new Language(); |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | /** |
78 | - * Returns list of available locales |
|
79 | - * |
|
80 | - * @return array |
|
78 | + * Returns list of available locales |
|
79 | + * |
|
80 | + * @return array |
|
81 | 81 | */ |
82 | 82 | public function listLocaleDir() |
83 | 83 | { |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | - * Returns list of available languages |
|
107 | - * |
|
108 | - * @return array |
|
106 | + * Returns list of available languages |
|
107 | + * |
|
108 | + * @return array |
|
109 | 109 | */ |
110 | 110 | public function getLanguages() |
111 | 111 | { |
@@ -24,54 +24,54 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | class Language { |
27 | - public $all_languages = array('ar_SA' => array('العَرَبِيَّةُ', 'ar', 'arabic'), |
|
28 | - 'bg_BG' => array('Български', 'bg', 'bulgarian'), |
|
29 | - 'id_ID' => array('Bahasa Indonesia', 'id', 'indonesian'), |
|
30 | - 'ms_MY' => array('Bahasa Melayu', 'ms', 'malay'), |
|
31 | - 'ca_ES' => array('Català', 'ca', 'catalan'), // ca_CA |
|
32 | - 'cs_CZ' => array('Čeština', 'cs', 'czech'), |
|
33 | - 'de_DE' => array('Deutsch', 'de', 'german'), |
|
34 | - 'da_DK' => array('Dansk', 'da', 'danish') , // dk_DK |
|
35 | - 'et_EE' => array('Eesti', 'et', 'estonian'), // ee_ET |
|
36 | - 'en_GB' => array('English', 'en', 'english'), |
|
37 | - 'en_US' => array('English (US)', 'en', 'english'), |
|
38 | - 'es_AR' => array('Español (Argentina)', 'es', 'spanish'), |
|
39 | - 'es_CO' => array('Español (Colombia)', 'es', 'spanish'), |
|
40 | - 'es_ES' => array('Español (España)', 'es', 'spanish'), |
|
41 | - 'es_419' => array('Español (América Latina)', 'es', 'spanish'), |
|
42 | - 'es_MX' => array('Español (Mexico)', 'es', 'spanish'), |
|
43 | - 'es_VE' => array('Español (Venezuela)', 'es', 'spanish'), |
|
44 | - 'eu_ES' => array('Euskara', 'en', 'basque'), |
|
45 | - 'fr_FR' => array('Français', 'fr', 'french'), |
|
46 | - 'gl_ES' => array('Galego', 'gl', 'galician'), |
|
47 | - 'el_GR' => array('Ελληνικά', 'el', 'greek'), // el_EL |
|
48 | - 'he_IL' => array('עברית', 'he', 'hebrew'), // he_HE |
|
49 | - 'hr_HR' => array('Hrvatski', 'hr', 'croatian'), |
|
50 | - 'hu_HU' => array('Magyar', 'hu', 'hungarian'), |
|
51 | - 'it_IT' => array('Italiano', 'it', 'italian'), |
|
52 | - 'lv_LV' => array('Latviešu', 'lv', 'latvian'), |
|
53 | - 'lt_LT' => array('Lietuvių', 'lt', 'lithuanian'), |
|
54 | - 'nl_NL' => array('Nederlands', 'nl', 'dutch'), |
|
55 | - 'nb_NO' => array('Norsk (Bokmål)', 'nb', 'norwegian'), // no_NB |
|
56 | - 'nn_NO' => array('Norsk (Nynorsk)', 'nn', 'norwegian'), // no_NN |
|
57 | - 'fa_IR' => array('فارسی', 'fa', 'persian'), |
|
58 | - 'pl_PL' => array('Polski', 'pl', 'polish'), |
|
59 | - 'pt_PT' => array('Português', 'pt', 'portuguese'), |
|
60 | - 'pt_BR' => array('Português do Brasil', 'pt', 'brazilian portuguese'), |
|
61 | - 'ro_RO' => array('Română', 'en', 'romanian'), |
|
62 | - 'ru_RU' => array('Pусский', 'ru', 'russian'), |
|
63 | - 'sk_SK' => array('Slovenčina', 'sk', 'slovak'), |
|
64 | - 'sl_SI' => array('Slovenščina', 'sl', 'slovenian slovene'), |
|
65 | - 'sr_RS' => array('Srpski', 'sr', 'serbian'), |
|
66 | - 'fi_FI' => array('Suomi', 'fi', 'finish'), |
|
67 | - 'sv_SE' => array('Svenska', 'sv', 'swedish'), |
|
68 | - 'vi_VN' => array('Tiếng Việt', 'vi', 'vietnamese'), |
|
69 | - 'th_TH' => array('ภาษาไทย', 'th', 'thai'), |
|
70 | - 'tr_TR' => array('Türkçe', 'tr', 'turkish'), |
|
71 | - 'uk_UA' => array('Українська', 'en', 'ukrainian'), // ua_UA |
|
72 | - 'ja_JP' => array('日本語', 'ja', 'japanese'), |
|
73 | - 'zh_CN' => array('简体中文', 'zh', 'chinese'), |
|
74 | - 'zh_TW' => array('繁體中文', 'zh', 'chinese') |
|
27 | + public $all_languages = array('ar_SA' => array('العَرَبِيَّةُ', 'ar', 'arabic'), |
|
28 | + 'bg_BG' => array('Български', 'bg', 'bulgarian'), |
|
29 | + 'id_ID' => array('Bahasa Indonesia', 'id', 'indonesian'), |
|
30 | + 'ms_MY' => array('Bahasa Melayu', 'ms', 'malay'), |
|
31 | + 'ca_ES' => array('Català', 'ca', 'catalan'), // ca_CA |
|
32 | + 'cs_CZ' => array('Čeština', 'cs', 'czech'), |
|
33 | + 'de_DE' => array('Deutsch', 'de', 'german'), |
|
34 | + 'da_DK' => array('Dansk', 'da', 'danish'), // dk_DK |
|
35 | + 'et_EE' => array('Eesti', 'et', 'estonian'), // ee_ET |
|
36 | + 'en_GB' => array('English', 'en', 'english'), |
|
37 | + 'en_US' => array('English (US)', 'en', 'english'), |
|
38 | + 'es_AR' => array('Español (Argentina)', 'es', 'spanish'), |
|
39 | + 'es_CO' => array('Español (Colombia)', 'es', 'spanish'), |
|
40 | + 'es_ES' => array('Español (España)', 'es', 'spanish'), |
|
41 | + 'es_419' => array('Español (América Latina)', 'es', 'spanish'), |
|
42 | + 'es_MX' => array('Español (Mexico)', 'es', 'spanish'), |
|
43 | + 'es_VE' => array('Español (Venezuela)', 'es', 'spanish'), |
|
44 | + 'eu_ES' => array('Euskara', 'en', 'basque'), |
|
45 | + 'fr_FR' => array('Français', 'fr', 'french'), |
|
46 | + 'gl_ES' => array('Galego', 'gl', 'galician'), |
|
47 | + 'el_GR' => array('Ελληνικά', 'el', 'greek'), // el_EL |
|
48 | + 'he_IL' => array('עברית', 'he', 'hebrew'), // he_HE |
|
49 | + 'hr_HR' => array('Hrvatski', 'hr', 'croatian'), |
|
50 | + 'hu_HU' => array('Magyar', 'hu', 'hungarian'), |
|
51 | + 'it_IT' => array('Italiano', 'it', 'italian'), |
|
52 | + 'lv_LV' => array('Latviešu', 'lv', 'latvian'), |
|
53 | + 'lt_LT' => array('Lietuvių', 'lt', 'lithuanian'), |
|
54 | + 'nl_NL' => array('Nederlands', 'nl', 'dutch'), |
|
55 | + 'nb_NO' => array('Norsk (Bokmål)', 'nb', 'norwegian'), // no_NB |
|
56 | + 'nn_NO' => array('Norsk (Nynorsk)', 'nn', 'norwegian'), // no_NN |
|
57 | + 'fa_IR' => array('فارسی', 'fa', 'persian'), |
|
58 | + 'pl_PL' => array('Polski', 'pl', 'polish'), |
|
59 | + 'pt_PT' => array('Português', 'pt', 'portuguese'), |
|
60 | + 'pt_BR' => array('Português do Brasil', 'pt', 'brazilian portuguese'), |
|
61 | + 'ro_RO' => array('Română', 'en', 'romanian'), |
|
62 | + 'ru_RU' => array('Pусский', 'ru', 'russian'), |
|
63 | + 'sk_SK' => array('Slovenčina', 'sk', 'slovak'), |
|
64 | + 'sl_SI' => array('Slovenščina', 'sl', 'slovenian slovene'), |
|
65 | + 'sr_RS' => array('Srpski', 'sr', 'serbian'), |
|
66 | + 'fi_FI' => array('Suomi', 'fi', 'finish'), |
|
67 | + 'sv_SE' => array('Svenska', 'sv', 'swedish'), |
|
68 | + 'vi_VN' => array('Tiếng Việt', 'vi', 'vietnamese'), |
|
69 | + 'th_TH' => array('ภาษาไทย', 'th', 'thai'), |
|
70 | + 'tr_TR' => array('Türkçe', 'tr', 'turkish'), |
|
71 | + 'uk_UA' => array('Українська', 'en', 'ukrainian'), // ua_UA |
|
72 | + 'ja_JP' => array('日本語', 'ja', 'japanese'), |
|
73 | + 'zh_CN' => array('简体中文', 'zh', 'chinese'), |
|
74 | + 'zh_TW' => array('繁體中文', 'zh', 'chinese') |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | public function getLocale($locale) |
101 | 101 | { |
102 | - return array($locale,$this->all_languages[$locale][1],$this->all_languages[$locale][2],$locale.'.utf8',$locale.'.UTF8'); |
|
102 | + return array($locale, $this->all_languages[$locale][1], $this->all_languages[$locale][2], $locale.'.utf8', $locale.'.UTF8'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -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 | } |