@@ -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); |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | if ($globalTransaction) $Connection->db->commit(); |
| 992 | 992 | } |
| 993 | 993 | return ''; |
| 994 | - } |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | 996 | public static function ivao_airlines($filename) { |
| 997 | 997 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1000,10 +1000,10 @@ discard block |
||
| 1000 | 1000 | try { |
| 1001 | 1001 | $Connection = new Connection(); |
| 1002 | 1002 | $sth = $Connection->db->prepare($query); |
| 1003 | - $sth->execute(); |
|
| 1004 | - } catch(PDOException $e) { |
|
| 1005 | - return "error : ".$e->getMessage(); |
|
| 1006 | - } |
|
| 1003 | + $sth->execute(); |
|
| 1004 | + } catch(PDOException $e) { |
|
| 1005 | + return "error : ".$e->getMessage(); |
|
| 1006 | + } |
|
| 1007 | 1007 | |
| 1008 | 1008 | $header = NULL; |
| 1009 | 1009 | $delimiter = ':'; |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | if ($globalTransaction) $Connection->db->commit(); |
| 1028 | 1028 | } |
| 1029 | 1029 | return ''; |
| 1030 | - } |
|
| 1030 | + } |
|
| 1031 | 1031 | |
| 1032 | 1032 | public static function update_airspace() { |
| 1033 | 1033 | global $tmp_dir, $globalDBdriver; |
@@ -1053,10 +1053,10 @@ discard block |
||
| 1053 | 1053 | $query = 'DROP TABLE countries'; |
| 1054 | 1054 | try { |
| 1055 | 1055 | $sth = $Connection->db->prepare($query); |
| 1056 | - $sth->execute(); |
|
| 1057 | - } catch(PDOException $e) { |
|
| 1058 | - echo "error : ".$e->getMessage(); |
|
| 1059 | - } |
|
| 1056 | + $sth->execute(); |
|
| 1057 | + } catch(PDOException $e) { |
|
| 1058 | + echo "error : ".$e->getMessage(); |
|
| 1059 | + } |
|
| 1060 | 1060 | } |
| 1061 | 1061 | if ($globalDBdriver == 'mysql') { |
| 1062 | 1062 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1401,12 +1401,12 @@ discard block |
||
| 1401 | 1401 | echo $data; |
| 1402 | 1402 | */ |
| 1403 | 1403 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1404 | - var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1405 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1406 | - $result = fread($fh,100000000); |
|
| 1407 | - //echo $result; |
|
| 1408 | - var_dump(str_get_html($result)); |
|
| 1409 | - //print_r(self::table2array($result)); |
|
| 1404 | + var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1405 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1406 | + $result = fread($fh,100000000); |
|
| 1407 | + //echo $result; |
|
| 1408 | + var_dump(str_get_html($result)); |
|
| 1409 | + //print_r(self::table2array($result)); |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | } |
@@ -1420,10 +1420,10 @@ discard block |
||
| 1420 | 1420 | try { |
| 1421 | 1421 | $Connection = new Connection(); |
| 1422 | 1422 | $sth = $Connection->db->prepare($query); |
| 1423 | - $sth->execute(); |
|
| 1424 | - } catch(PDOException $e) { |
|
| 1425 | - return "error : ".$e->getMessage(); |
|
| 1426 | - } |
|
| 1423 | + $sth->execute(); |
|
| 1424 | + } catch(PDOException $e) { |
|
| 1425 | + return "error : ".$e->getMessage(); |
|
| 1426 | + } |
|
| 1427 | 1427 | |
| 1428 | 1428 | $error = ''; |
| 1429 | 1429 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1479,8 +1479,8 @@ discard block |
||
| 1479 | 1479 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 1480 | 1480 | $data['permanent'] = 0; |
| 1481 | 1481 | } else { |
| 1482 | - $data['date_end'] = NULL; |
|
| 1483 | - $data['permanent'] = 1; |
|
| 1482 | + $data['date_end'] = NULL; |
|
| 1483 | + $data['permanent'] = 1; |
|
| 1484 | 1484 | } |
| 1485 | 1485 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1486 | 1486 | $NOTAM = new NOTAM(); |
@@ -1504,13 +1504,13 @@ discard block |
||
| 1504 | 1504 | try { |
| 1505 | 1505 | $Connection = new Connection(); |
| 1506 | 1506 | $sth = $Connection->db->prepare($query); |
| 1507 | - $sth->execute(); |
|
| 1508 | - } catch(PDOException $e) { |
|
| 1509 | - return "error : ".$e->getMessage(); |
|
| 1510 | - } |
|
| 1511 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1512 | - if ($row['nb'] > 0) return false; |
|
| 1513 | - else return true; |
|
| 1507 | + $sth->execute(); |
|
| 1508 | + } catch(PDOException $e) { |
|
| 1509 | + return "error : ".$e->getMessage(); |
|
| 1510 | + } |
|
| 1511 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1512 | + if ($row['nb'] > 0) return false; |
|
| 1513 | + else return true; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | public static function insert_last_update() { |
@@ -1519,10 +1519,10 @@ discard block |
||
| 1519 | 1519 | try { |
| 1520 | 1520 | $Connection = new Connection(); |
| 1521 | 1521 | $sth = $Connection->db->prepare($query); |
| 1522 | - $sth->execute(); |
|
| 1523 | - } catch(PDOException $e) { |
|
| 1524 | - return "error : ".$e->getMessage(); |
|
| 1525 | - } |
|
| 1522 | + $sth->execute(); |
|
| 1523 | + } catch(PDOException $e) { |
|
| 1524 | + return "error : ".$e->getMessage(); |
|
| 1525 | + } |
|
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | 1528 | public static function check_last_notam_update() { |
@@ -1535,13 +1535,13 @@ discard block |
||
| 1535 | 1535 | try { |
| 1536 | 1536 | $Connection = new Connection(); |
| 1537 | 1537 | $sth = $Connection->db->prepare($query); |
| 1538 | - $sth->execute(); |
|
| 1539 | - } catch(PDOException $e) { |
|
| 1540 | - return "error : ".$e->getMessage(); |
|
| 1541 | - } |
|
| 1542 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1543 | - if ($row['nb'] > 0) return false; |
|
| 1544 | - else return true; |
|
| 1538 | + $sth->execute(); |
|
| 1539 | + } catch(PDOException $e) { |
|
| 1540 | + return "error : ".$e->getMessage(); |
|
| 1541 | + } |
|
| 1542 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1543 | + if ($row['nb'] > 0) return false; |
|
| 1544 | + else return true; |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | public static function insert_last_notam_update() { |
@@ -1550,10 +1550,10 @@ discard block |
||
| 1550 | 1550 | try { |
| 1551 | 1551 | $Connection = new Connection(); |
| 1552 | 1552 | $sth = $Connection->db->prepare($query); |
| 1553 | - $sth->execute(); |
|
| 1554 | - } catch(PDOException $e) { |
|
| 1555 | - return "error : ".$e->getMessage(); |
|
| 1556 | - } |
|
| 1553 | + $sth->execute(); |
|
| 1554 | + } catch(PDOException $e) { |
|
| 1555 | + return "error : ".$e->getMessage(); |
|
| 1556 | + } |
|
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | public static function check_last_owner_update() { |
@@ -1566,13 +1566,13 @@ discard block |
||
| 1566 | 1566 | try { |
| 1567 | 1567 | $Connection = new Connection(); |
| 1568 | 1568 | $sth = $Connection->db->prepare($query); |
| 1569 | - $sth->execute(); |
|
| 1570 | - } catch(PDOException $e) { |
|
| 1571 | - return "error : ".$e->getMessage(); |
|
| 1572 | - } |
|
| 1573 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1574 | - if ($row['nb'] > 0) return false; |
|
| 1575 | - else return true; |
|
| 1569 | + $sth->execute(); |
|
| 1570 | + } catch(PDOException $e) { |
|
| 1571 | + return "error : ".$e->getMessage(); |
|
| 1572 | + } |
|
| 1573 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1574 | + if ($row['nb'] > 0) return false; |
|
| 1575 | + else return true; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | public static function insert_last_owner_update() { |
@@ -1581,10 +1581,10 @@ discard block |
||
| 1581 | 1581 | try { |
| 1582 | 1582 | $Connection = new Connection(); |
| 1583 | 1583 | $sth = $Connection->db->prepare($query); |
| 1584 | - $sth->execute(); |
|
| 1585 | - } catch(PDOException $e) { |
|
| 1586 | - return "error : ".$e->getMessage(); |
|
| 1587 | - } |
|
| 1584 | + $sth->execute(); |
|
| 1585 | + } catch(PDOException $e) { |
|
| 1586 | + return "error : ".$e->getMessage(); |
|
| 1587 | + } |
|
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | public static function update_all() { |
@@ -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,11 +966,11 @@ 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 | if (count($data) > 10) { |
| 972 | 972 | $value = $data[9]; |
| 973 | - for ($i =10;$i < count($data);$i++) { |
|
| 973 | + for ($i = 10; $i < count($data); $i++) { |
|
| 974 | 974 | $value .= ' '.$data[$i]; |
| 975 | 975 | } |
| 976 | 976 | $data[9] = $value; |
@@ -980,8 +980,8 @@ discard block |
||
| 980 | 980 | $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)'; |
| 981 | 981 | try { |
| 982 | 982 | $sth = $Connection->db->prepare($query); |
| 983 | - $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])); |
|
| 984 | - } catch(PDOException $e) { |
|
| 983 | + $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])); |
|
| 984 | + } catch (PDOException $e) { |
|
| 985 | 985 | return "error : ".$e->getMessage(); |
| 986 | 986 | } |
| 987 | 987 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | $Connection = new Connection(); |
| 1002 | 1002 | $sth = $Connection->db->prepare($query); |
| 1003 | 1003 | $sth->execute(); |
| 1004 | - } catch(PDOException $e) { |
|
| 1004 | + } catch (PDOException $e) { |
|
| 1005 | 1005 | return "error : ".$e->getMessage(); |
| 1006 | 1006 | } |
| 1007 | 1007 | |
@@ -1013,12 +1013,12 @@ discard block |
||
| 1013 | 1013 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1014 | 1014 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1015 | 1015 | { |
| 1016 | - if(count($row) > 1) { |
|
| 1016 | + if (count($row) > 1) { |
|
| 1017 | 1017 | $query = "INSERT INTO airlines (name,icao,active) VALUES (:name, :icao, 'Y')"; |
| 1018 | 1018 | try { |
| 1019 | 1019 | $sth = $Connection->db->prepare($query); |
| 1020 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1021 | - } catch(PDOException $e) { |
|
| 1020 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1021 | + } catch (PDOException $e) { |
|
| 1022 | 1022 | return "error : ".$e->getMessage(); |
| 1023 | 1023 | } |
| 1024 | 1024 | } |
@@ -1032,8 +1032,8 @@ discard block |
||
| 1032 | 1032 | public static function update_airspace() { |
| 1033 | 1033 | global $tmp_dir, $globalDBdriver; |
| 1034 | 1034 | include_once('class.create_db.php'); |
| 1035 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1036 | - else update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1035 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1036 | + else update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1037 | 1037 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1038 | 1038 | return $error; |
| 1039 | 1039 | } |
@@ -1054,14 +1054,14 @@ discard block |
||
| 1054 | 1054 | try { |
| 1055 | 1055 | $sth = $Connection->db->prepare($query); |
| 1056 | 1056 | $sth->execute(); |
| 1057 | - } catch(PDOException $e) { |
|
| 1057 | + } catch (PDOException $e) { |
|
| 1058 | 1058 | echo "error : ".$e->getMessage(); |
| 1059 | 1059 | } |
| 1060 | 1060 | } |
| 1061 | 1061 | if ($globalDBdriver == 'mysql') { |
| 1062 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1062 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1063 | 1063 | } else { |
| 1064 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1064 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1067 | 1067 | return $error; |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1075 | 1075 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1076 | 1076 | // 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'); |
| 1077 | - 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'); |
|
| 1077 | + 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'); |
|
| 1078 | 1078 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1079 | 1079 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1080 | 1080 | return $error; |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1095 | 1095 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1096 | 1096 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1097 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1097 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1098 | 1098 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1099 | 1099 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1100 | 1100 | if ($error != '') { |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | global $tmp_dir, $globalDebug; |
| 1108 | 1108 | $error = ''; |
| 1109 | 1109 | if ($globalDebug) echo "Routes : Download..."; |
| 1110 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1110 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1111 | 1111 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1112 | 1112 | if ($globalDebug) echo "Gunzip..."; |
| 1113 | 1113 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | } elseif ($globalDebug) echo "Done\n"; |
| 1135 | 1135 | */ |
| 1136 | 1136 | if ($globalDebug) echo "Modes : Download..."; |
| 1137 | - update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1137 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
| 1138 | 1138 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1139 | 1139 | if ($globalDebug) echo "Unzip..."; |
| 1140 | 1140 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | public static function update_ModeS_flarm() { |
| 1151 | 1151 | global $tmp_dir, $globalDebug; |
| 1152 | 1152 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1153 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1153 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1154 | 1154 | if (file_exists($tmp_dir.'data.fln')) { |
| 1155 | 1155 | if ($globalDebug) echo "Add to DB..."; |
| 1156 | 1156 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | public static function update_ModeS_ogn() { |
| 1165 | 1165 | global $tmp_dir, $globalDebug; |
| 1166 | 1166 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1167 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1167 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1168 | 1168 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1169 | 1169 | if ($globalDebug) echo "Add to DB..."; |
| 1170 | 1170 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1179,173 +1179,173 @@ discard block |
||
| 1179 | 1179 | global $tmp_dir, $globalDebug; |
| 1180 | 1180 | |
| 1181 | 1181 | if ($globalDebug) echo "Owner France: Download..."; |
| 1182 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1182 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1183 | 1183 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1184 | 1184 | if ($globalDebug) echo "Add to DB..."; |
| 1185 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1185 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1186 | 1186 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1187 | 1187 | if ($error != '') { |
| 1188 | 1188 | return $error; |
| 1189 | 1189 | } elseif ($globalDebug) echo "Done\n"; |
| 1190 | 1190 | |
| 1191 | 1191 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1192 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1192 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1193 | 1193 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1194 | 1194 | if ($globalDebug) echo "Add to DB..."; |
| 1195 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1195 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1196 | 1196 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1197 | 1197 | if ($error != '') { |
| 1198 | 1198 | return $error; |
| 1199 | 1199 | } elseif ($globalDebug) echo "Done\n"; |
| 1200 | 1200 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1201 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1201 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1202 | 1202 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1203 | 1203 | if ($globalDebug) echo "Add to DB..."; |
| 1204 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1204 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1205 | 1205 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1206 | 1206 | if ($error != '') { |
| 1207 | 1207 | return $error; |
| 1208 | 1208 | } elseif ($globalDebug) echo "Done\n"; |
| 1209 | 1209 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1210 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1210 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1211 | 1211 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1212 | 1212 | if ($globalDebug) echo "Add to DB..."; |
| 1213 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1213 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1214 | 1214 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1215 | 1215 | if ($error != '') { |
| 1216 | 1216 | return $error; |
| 1217 | 1217 | } elseif ($globalDebug) echo "Done\n"; |
| 1218 | 1218 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1219 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1219 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1220 | 1220 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1221 | 1221 | if ($globalDebug) echo "Add to DB..."; |
| 1222 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1222 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1223 | 1223 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1224 | 1224 | if ($error != '') { |
| 1225 | 1225 | return $error; |
| 1226 | 1226 | } elseif ($globalDebug) echo "Done\n"; |
| 1227 | 1227 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1228 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1228 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1229 | 1229 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1230 | 1230 | if ($globalDebug) echo "Add to DB..."; |
| 1231 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1231 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1232 | 1232 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1233 | 1233 | if ($error != '') { |
| 1234 | 1234 | return $error; |
| 1235 | 1235 | } elseif ($globalDebug) echo "Done\n"; |
| 1236 | 1236 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1237 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1237 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1238 | 1238 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1239 | 1239 | if ($globalDebug) echo "Add to DB..."; |
| 1240 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1240 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1241 | 1241 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1242 | 1242 | if ($error != '') { |
| 1243 | 1243 | return $error; |
| 1244 | 1244 | } elseif ($globalDebug) echo "Done\n"; |
| 1245 | 1245 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1246 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1246 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1247 | 1247 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1248 | 1248 | if ($globalDebug) echo "Add to DB..."; |
| 1249 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1249 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1250 | 1250 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1251 | 1251 | if ($error != '') { |
| 1252 | 1252 | return $error; |
| 1253 | 1253 | } elseif ($globalDebug) echo "Done\n"; |
| 1254 | 1254 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1255 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1255 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1256 | 1256 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1257 | 1257 | if ($globalDebug) echo "Add to DB..."; |
| 1258 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1258 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1259 | 1259 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1260 | 1260 | if ($error != '') { |
| 1261 | 1261 | return $error; |
| 1262 | 1262 | } elseif ($globalDebug) echo "Done\n"; |
| 1263 | 1263 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1264 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1264 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1265 | 1265 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1266 | 1266 | if ($globalDebug) echo "Add to DB..."; |
| 1267 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1267 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1268 | 1268 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1269 | 1269 | if ($error != '') { |
| 1270 | 1270 | return $error; |
| 1271 | 1271 | } elseif ($globalDebug) echo "Done\n"; |
| 1272 | 1272 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1273 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1273 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1274 | 1274 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1275 | 1275 | if ($globalDebug) echo "Add to DB..."; |
| 1276 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1276 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1277 | 1277 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1278 | 1278 | if ($error != '') { |
| 1279 | 1279 | return $error; |
| 1280 | 1280 | } elseif ($globalDebug) echo "Done\n"; |
| 1281 | 1281 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1282 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1282 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1283 | 1283 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1284 | 1284 | if ($globalDebug) echo "Add to DB..."; |
| 1285 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1285 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1286 | 1286 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1287 | 1287 | if ($error != '') { |
| 1288 | 1288 | return $error; |
| 1289 | 1289 | } elseif ($globalDebug) echo "Done\n"; |
| 1290 | 1290 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1291 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1291 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1292 | 1292 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1293 | 1293 | if ($globalDebug) echo "Add to DB..."; |
| 1294 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1294 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1295 | 1295 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1296 | 1296 | if ($error != '') { |
| 1297 | 1297 | return $error; |
| 1298 | 1298 | } elseif ($globalDebug) echo "Done\n"; |
| 1299 | 1299 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1300 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1300 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1301 | 1301 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1302 | 1302 | if ($globalDebug) echo "Add to DB..."; |
| 1303 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1303 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1304 | 1304 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1305 | 1305 | if ($error != '') { |
| 1306 | 1306 | return $error; |
| 1307 | 1307 | } elseif ($globalDebug) echo "Done\n"; |
| 1308 | 1308 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1309 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1309 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1310 | 1310 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1311 | 1311 | if ($globalDebug) echo "Add to DB..."; |
| 1312 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1312 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1313 | 1313 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1314 | 1314 | if ($error != '') { |
| 1315 | 1315 | return $error; |
| 1316 | 1316 | } elseif ($globalDebug) echo "Done\n"; |
| 1317 | 1317 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1318 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1318 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1319 | 1319 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1320 | 1320 | if ($globalDebug) echo "Add to DB..."; |
| 1321 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1321 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1322 | 1322 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1323 | 1323 | if ($error != '') { |
| 1324 | 1324 | return $error; |
| 1325 | 1325 | } elseif ($globalDebug) echo "Done\n"; |
| 1326 | 1326 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1327 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1327 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1328 | 1328 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1329 | 1329 | if ($globalDebug) echo "Add to DB..."; |
| 1330 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1330 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1331 | 1331 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1332 | 1332 | if ($error != '') { |
| 1333 | 1333 | return $error; |
| 1334 | 1334 | } elseif ($globalDebug) echo "Done\n"; |
| 1335 | 1335 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1336 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1336 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1337 | 1337 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1338 | 1338 | if ($globalDebug) echo "Add to DB..."; |
| 1339 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1339 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1340 | 1340 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1341 | 1341 | if ($error != '') { |
| 1342 | 1342 | return $error; |
| 1343 | 1343 | } elseif ($globalDebug) echo "Done\n"; |
| 1344 | 1344 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1345 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1345 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1346 | 1346 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1347 | 1347 | if ($globalDebug) echo "Add to DB..."; |
| 1348 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1348 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1349 | 1349 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1350 | 1350 | if ($error != '') { |
| 1351 | 1351 | return $error; |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | global $tmp_dir, $globalDebug; |
| 1358 | 1358 | $error = ''; |
| 1359 | 1359 | if ($globalDebug) echo "Translation : Download..."; |
| 1360 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1360 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1361 | 1361 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1362 | 1362 | if ($globalDebug) echo "Unzip..."; |
| 1363 | 1363 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | global $tmp_dir, $globalDebug; |
| 1375 | 1375 | $error = ''; |
| 1376 | 1376 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1377 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1377 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1378 | 1378 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1379 | 1379 | if ($globalDebug) echo "Gunzip..."; |
| 1380 | 1380 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1402,8 +1402,8 @@ discard block |
||
| 1402 | 1402 | */ |
| 1403 | 1403 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1404 | 1404 | var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 1405 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1406 | - $result = fread($fh,100000000); |
|
| 1405 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 1406 | + $result = fread($fh, 100000000); |
|
| 1407 | 1407 | //echo $result; |
| 1408 | 1408 | var_dump(str_get_html($result)); |
| 1409 | 1409 | //print_r(self::table2array($result)); |
@@ -1421,23 +1421,23 @@ discard block |
||
| 1421 | 1421 | $Connection = new Connection(); |
| 1422 | 1422 | $sth = $Connection->db->prepare($query); |
| 1423 | 1423 | $sth->execute(); |
| 1424 | - } catch(PDOException $e) { |
|
| 1424 | + } catch (PDOException $e) { |
|
| 1425 | 1425 | return "error : ".$e->getMessage(); |
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | 1428 | $error = ''; |
| 1429 | 1429 | if ($globalDebug) echo "Notam : Download..."; |
| 1430 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 1430 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 1431 | 1431 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1432 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 1432 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 1433 | 1433 | foreach ($notams['channel']['item'] as $notam) { |
| 1434 | - $title = explode(':',$notam['title']); |
|
| 1434 | + $title = explode(':', $notam['title']); |
|
| 1435 | 1435 | $data['ref'] = trim($title[0]); |
| 1436 | 1436 | unset($title[0]); |
| 1437 | - $data['title'] = trim(implode(':',$title)); |
|
| 1438 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 1439 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 1440 | - $q = explode('/',$match[1]); |
|
| 1437 | + $data['title'] = trim(implode(':', $title)); |
|
| 1438 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 1439 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 1440 | + $q = explode('/', $match[1]); |
|
| 1441 | 1441 | $data['fir'] = $q[0]; |
| 1442 | 1442 | $data['code'] = $q[1]; |
| 1443 | 1443 | $ifrvfr = $q[2]; |
@@ -1453,30 +1453,30 @@ discard block |
||
| 1453 | 1453 | $data['lower_limit'] = $q[5]; |
| 1454 | 1454 | $data['upper_limit'] = $q[6]; |
| 1455 | 1455 | $latlonrad = $q[7]; |
| 1456 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 1457 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 1458 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 1456 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 1457 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 1458 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 1459 | 1459 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 1460 | 1460 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 1461 | 1461 | $data['center_latitude'] = $latitude; |
| 1462 | 1462 | $data['center_longitude'] = $longitude; |
| 1463 | 1463 | $data['radius'] = intval($radius); |
| 1464 | 1464 | |
| 1465 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 1465 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 1466 | 1466 | $data['text'] = $match[1]; |
| 1467 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 1467 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 1468 | 1468 | $fromto = $match[1]; |
| 1469 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 1469 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 1470 | 1470 | $fromall = trim($match[1]); |
| 1471 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 1471 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 1472 | 1472 | $from = trim($match[1]); |
| 1473 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 1474 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 1473 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 1474 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 1475 | 1475 | $toall = trim($match[1]); |
| 1476 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 1477 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 1476 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 1477 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 1478 | 1478 | $to = trim($match[1]); |
| 1479 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 1479 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 1480 | 1480 | $data['permanent'] = 0; |
| 1481 | 1481 | } else { |
| 1482 | 1482 | $data['date_end'] = NULL; |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | } |
| 1485 | 1485 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1486 | 1486 | $NOTAM = new NOTAM(); |
| 1487 | - $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']); |
|
| 1487 | + $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']); |
|
| 1488 | 1488 | unset($data); |
| 1489 | 1489 | } |
| 1490 | 1490 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1505,7 +1505,7 @@ discard block |
||
| 1505 | 1505 | $Connection = new Connection(); |
| 1506 | 1506 | $sth = $Connection->db->prepare($query); |
| 1507 | 1507 | $sth->execute(); |
| 1508 | - } catch(PDOException $e) { |
|
| 1508 | + } catch (PDOException $e) { |
|
| 1509 | 1509 | return "error : ".$e->getMessage(); |
| 1510 | 1510 | } |
| 1511 | 1511 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | $Connection = new Connection(); |
| 1521 | 1521 | $sth = $Connection->db->prepare($query); |
| 1522 | 1522 | $sth->execute(); |
| 1523 | - } catch(PDOException $e) { |
|
| 1523 | + } catch (PDOException $e) { |
|
| 1524 | 1524 | return "error : ".$e->getMessage(); |
| 1525 | 1525 | } |
| 1526 | 1526 | } |
@@ -1536,7 +1536,7 @@ discard block |
||
| 1536 | 1536 | $Connection = new Connection(); |
| 1537 | 1537 | $sth = $Connection->db->prepare($query); |
| 1538 | 1538 | $sth->execute(); |
| 1539 | - } catch(PDOException $e) { |
|
| 1539 | + } catch (PDOException $e) { |
|
| 1540 | 1540 | return "error : ".$e->getMessage(); |
| 1541 | 1541 | } |
| 1542 | 1542 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | $Connection = new Connection(); |
| 1552 | 1552 | $sth = $Connection->db->prepare($query); |
| 1553 | 1553 | $sth->execute(); |
| 1554 | - } catch(PDOException $e) { |
|
| 1554 | + } catch (PDOException $e) { |
|
| 1555 | 1555 | return "error : ".$e->getMessage(); |
| 1556 | 1556 | } |
| 1557 | 1557 | } |
@@ -1567,7 +1567,7 @@ discard block |
||
| 1567 | 1567 | $Connection = new Connection(); |
| 1568 | 1568 | $sth = $Connection->db->prepare($query); |
| 1569 | 1569 | $sth->execute(); |
| 1570 | - } catch(PDOException $e) { |
|
| 1570 | + } catch (PDOException $e) { |
|
| 1571 | 1571 | return "error : ".$e->getMessage(); |
| 1572 | 1572 | } |
| 1573 | 1573 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | $Connection = new Connection(); |
| 1583 | 1583 | $sth = $Connection->db->prepare($query); |
| 1584 | 1584 | $sth->execute(); |
| 1585 | - } catch(PDOException $e) { |
|
| 1585 | + } catch (PDOException $e) { |
|
| 1586 | 1586 | return "error : ".$e->getMessage(); |
| 1587 | 1587 | } |
| 1588 | 1588 | } |
@@ -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++; |
@@ -988,7 +1092,9 @@ discard block |
||
| 988 | 1092 | } |
| 989 | 1093 | } |
| 990 | 1094 | fclose($handle); |
| 991 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1095 | + if ($globalTransaction) { |
|
| 1096 | + $Connection->db->commit(); |
|
| 1097 | + } |
|
| 992 | 1098 | } |
| 993 | 1099 | return ''; |
| 994 | 1100 | } |
@@ -1010,7 +1116,9 @@ discard block |
||
| 1010 | 1116 | $Connection = new Connection(); |
| 1011 | 1117 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1012 | 1118 | { |
| 1013 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1119 | + if ($globalTransaction) { |
|
| 1120 | + $Connection->db->beginTransaction(); |
|
| 1121 | + } |
|
| 1014 | 1122 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1015 | 1123 | { |
| 1016 | 1124 | if(count($row) > 1) { |
@@ -1024,7 +1132,9 @@ discard block |
||
| 1024 | 1132 | } |
| 1025 | 1133 | } |
| 1026 | 1134 | fclose($handle); |
| 1027 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1135 | + if ($globalTransaction) { |
|
| 1136 | + $Connection->db->commit(); |
|
| 1137 | + } |
|
| 1028 | 1138 | } |
| 1029 | 1139 | return ''; |
| 1030 | 1140 | } |
@@ -1032,8 +1142,11 @@ discard block |
||
| 1032 | 1142 | public static function update_airspace() { |
| 1033 | 1143 | global $tmp_dir, $globalDBdriver; |
| 1034 | 1144 | include_once('class.create_db.php'); |
| 1035 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1036 | - else update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1145 | + if ($globalDBdriver == 'mysql') { |
|
| 1146 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1147 | + } else { |
|
| 1148 | + update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1149 | + } |
|
| 1037 | 1150 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1038 | 1151 | return $error; |
| 1039 | 1152 | } |
@@ -1088,35 +1201,59 @@ discard block |
||
| 1088 | 1201 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1089 | 1202 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1090 | 1203 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1091 | - if ($globalDebug) echo "Unzip..."; |
|
| 1204 | + if ($globalDebug) { |
|
| 1205 | + echo "Unzip..."; |
|
| 1206 | + } |
|
| 1092 | 1207 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1093 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1208 | + if ($globalDebug) { |
|
| 1209 | + echo "Add to DB..."; |
|
| 1210 | + } |
|
| 1094 | 1211 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1095 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1212 | + if ($globalDebug) { |
|
| 1213 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1214 | + } |
|
| 1096 | 1215 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1097 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1098 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1099 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1216 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1217 | + $error = "Failed to copy airlines logo."; |
|
| 1218 | + } |
|
| 1219 | + } else { |
|
| 1220 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1221 | + } |
|
| 1222 | + } else { |
|
| 1223 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1224 | + } |
|
| 1100 | 1225 | if ($error != '') { |
| 1101 | 1226 | return $error; |
| 1102 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1227 | + } elseif ($globalDebug) { |
|
| 1228 | + echo "Done\n"; |
|
| 1229 | + } |
|
| 1103 | 1230 | return ''; |
| 1104 | 1231 | } |
| 1105 | 1232 | |
| 1106 | 1233 | public static function update_routes() { |
| 1107 | 1234 | global $tmp_dir, $globalDebug; |
| 1108 | 1235 | $error = ''; |
| 1109 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1236 | + if ($globalDebug) { |
|
| 1237 | + echo "Routes : Download..."; |
|
| 1238 | + } |
|
| 1110 | 1239 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1111 | 1240 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1112 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1241 | + if ($globalDebug) { |
|
| 1242 | + echo "Gunzip..."; |
|
| 1243 | + } |
|
| 1113 | 1244 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1114 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1245 | + if ($globalDebug) { |
|
| 1246 | + echo "Add to DB..."; |
|
| 1247 | + } |
|
| 1115 | 1248 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1116 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1249 | + } else { |
|
| 1250 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1251 | + } |
|
| 1117 | 1252 | if ($error != '') { |
| 1118 | 1253 | return $error; |
| 1119 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1254 | + } elseif ($globalDebug) { |
|
| 1255 | + echo "Done\n"; |
|
| 1256 | + } |
|
| 1120 | 1257 | return ''; |
| 1121 | 1258 | } |
| 1122 | 1259 | public static function update_ModeS() { |
@@ -1133,257 +1270,455 @@ discard block |
||
| 1133 | 1270 | exit; |
| 1134 | 1271 | } elseif ($globalDebug) echo "Done\n"; |
| 1135 | 1272 | */ |
| 1136 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1273 | + if ($globalDebug) { |
|
| 1274 | + echo "Modes : Download..."; |
|
| 1275 | + } |
|
| 1137 | 1276 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1138 | 1277 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1139 | - if ($globalDebug) echo "Unzip..."; |
|
| 1278 | + if ($globalDebug) { |
|
| 1279 | + echo "Unzip..."; |
|
| 1280 | + } |
|
| 1140 | 1281 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
| 1141 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1282 | + if ($globalDebug) { |
|
| 1283 | + echo "Add to DB..."; |
|
| 1284 | + } |
|
| 1142 | 1285 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1143 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1286 | + } else { |
|
| 1287 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1288 | + } |
|
| 1144 | 1289 | if ($error != '') { |
| 1145 | 1290 | return $error; |
| 1146 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1291 | + } elseif ($globalDebug) { |
|
| 1292 | + echo "Done\n"; |
|
| 1293 | + } |
|
| 1147 | 1294 | return ''; |
| 1148 | 1295 | } |
| 1149 | 1296 | |
| 1150 | 1297 | public static function update_ModeS_flarm() { |
| 1151 | 1298 | global $tmp_dir, $globalDebug; |
| 1152 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1299 | + if ($globalDebug) { |
|
| 1300 | + echo "Modes Flarmnet: Download..."; |
|
| 1301 | + } |
|
| 1153 | 1302 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1154 | 1303 | if (file_exists($tmp_dir.'data.fln')) { |
| 1155 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1304 | + if ($globalDebug) { |
|
| 1305 | + echo "Add to DB..."; |
|
| 1306 | + } |
|
| 1156 | 1307 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1157 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1308 | + } else { |
|
| 1309 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1310 | + } |
|
| 1158 | 1311 | if ($error != '') { |
| 1159 | 1312 | return $error; |
| 1160 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1313 | + } elseif ($globalDebug) { |
|
| 1314 | + echo "Done\n"; |
|
| 1315 | + } |
|
| 1161 | 1316 | return ''; |
| 1162 | 1317 | } |
| 1163 | 1318 | |
| 1164 | 1319 | public static function update_ModeS_ogn() { |
| 1165 | 1320 | global $tmp_dir, $globalDebug; |
| 1166 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1321 | + if ($globalDebug) { |
|
| 1322 | + echo "Modes OGN: Download..."; |
|
| 1323 | + } |
|
| 1167 | 1324 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1168 | 1325 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1169 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1326 | + if ($globalDebug) { |
|
| 1327 | + echo "Add to DB..."; |
|
| 1328 | + } |
|
| 1170 | 1329 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1171 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1330 | + } else { |
|
| 1331 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1332 | + } |
|
| 1172 | 1333 | if ($error != '') { |
| 1173 | 1334 | return $error; |
| 1174 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1335 | + } elseif ($globalDebug) { |
|
| 1336 | + echo "Done\n"; |
|
| 1337 | + } |
|
| 1175 | 1338 | return ''; |
| 1176 | 1339 | } |
| 1177 | 1340 | |
| 1178 | 1341 | public static function update_owner() { |
| 1179 | 1342 | global $tmp_dir, $globalDebug; |
| 1180 | 1343 | |
| 1181 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1344 | + if ($globalDebug) { |
|
| 1345 | + echo "Owner France: Download..."; |
|
| 1346 | + } |
|
| 1182 | 1347 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1183 | 1348 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1184 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1349 | + if ($globalDebug) { |
|
| 1350 | + echo "Add to DB..."; |
|
| 1351 | + } |
|
| 1185 | 1352 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1186 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1353 | + } else { |
|
| 1354 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1355 | + } |
|
| 1187 | 1356 | if ($error != '') { |
| 1188 | 1357 | return $error; |
| 1189 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1358 | + } elseif ($globalDebug) { |
|
| 1359 | + echo "Done\n"; |
|
| 1360 | + } |
|
| 1190 | 1361 | |
| 1191 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1362 | + if ($globalDebug) { |
|
| 1363 | + echo "Owner Ireland: Download..."; |
|
| 1364 | + } |
|
| 1192 | 1365 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1193 | 1366 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1194 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1367 | + if ($globalDebug) { |
|
| 1368 | + echo "Add to DB..."; |
|
| 1369 | + } |
|
| 1195 | 1370 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1196 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1371 | + } else { |
|
| 1372 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1373 | + } |
|
| 1197 | 1374 | if ($error != '') { |
| 1198 | 1375 | return $error; |
| 1199 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1200 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1376 | + } elseif ($globalDebug) { |
|
| 1377 | + echo "Done\n"; |
|
| 1378 | + } |
|
| 1379 | + if ($globalDebug) { |
|
| 1380 | + echo "Owner Switzerland: Download..."; |
|
| 1381 | + } |
|
| 1201 | 1382 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1202 | 1383 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1203 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1384 | + if ($globalDebug) { |
|
| 1385 | + echo "Add to DB..."; |
|
| 1386 | + } |
|
| 1204 | 1387 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1205 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1388 | + } else { |
|
| 1389 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1390 | + } |
|
| 1206 | 1391 | if ($error != '') { |
| 1207 | 1392 | return $error; |
| 1208 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1209 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1393 | + } elseif ($globalDebug) { |
|
| 1394 | + echo "Done\n"; |
|
| 1395 | + } |
|
| 1396 | + if ($globalDebug) { |
|
| 1397 | + echo "Owner Czech Republic: Download..."; |
|
| 1398 | + } |
|
| 1210 | 1399 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1211 | 1400 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1212 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1401 | + if ($globalDebug) { |
|
| 1402 | + echo "Add to DB..."; |
|
| 1403 | + } |
|
| 1213 | 1404 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1214 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1405 | + } else { |
|
| 1406 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1407 | + } |
|
| 1215 | 1408 | if ($error != '') { |
| 1216 | 1409 | return $error; |
| 1217 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1218 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1410 | + } elseif ($globalDebug) { |
|
| 1411 | + echo "Done\n"; |
|
| 1412 | + } |
|
| 1413 | + if ($globalDebug) { |
|
| 1414 | + echo "Owner Australia: Download..."; |
|
| 1415 | + } |
|
| 1219 | 1416 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1220 | 1417 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1221 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1418 | + if ($globalDebug) { |
|
| 1419 | + echo "Add to DB..."; |
|
| 1420 | + } |
|
| 1222 | 1421 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1223 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1422 | + } else { |
|
| 1423 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1424 | + } |
|
| 1224 | 1425 | if ($error != '') { |
| 1225 | 1426 | return $error; |
| 1226 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1227 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1427 | + } elseif ($globalDebug) { |
|
| 1428 | + echo "Done\n"; |
|
| 1429 | + } |
|
| 1430 | + if ($globalDebug) { |
|
| 1431 | + echo "Owner Austria: Download..."; |
|
| 1432 | + } |
|
| 1228 | 1433 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1229 | 1434 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1230 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1435 | + if ($globalDebug) { |
|
| 1436 | + echo "Add to DB..."; |
|
| 1437 | + } |
|
| 1231 | 1438 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1232 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1439 | + } else { |
|
| 1440 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1441 | + } |
|
| 1233 | 1442 | if ($error != '') { |
| 1234 | 1443 | return $error; |
| 1235 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1236 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1444 | + } elseif ($globalDebug) { |
|
| 1445 | + echo "Done\n"; |
|
| 1446 | + } |
|
| 1447 | + if ($globalDebug) { |
|
| 1448 | + echo "Owner Chile: Download..."; |
|
| 1449 | + } |
|
| 1237 | 1450 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1238 | 1451 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1239 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1452 | + if ($globalDebug) { |
|
| 1453 | + echo "Add to DB..."; |
|
| 1454 | + } |
|
| 1240 | 1455 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1241 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1456 | + } else { |
|
| 1457 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1458 | + } |
|
| 1242 | 1459 | if ($error != '') { |
| 1243 | 1460 | return $error; |
| 1244 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1245 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1461 | + } elseif ($globalDebug) { |
|
| 1462 | + echo "Done\n"; |
|
| 1463 | + } |
|
| 1464 | + if ($globalDebug) { |
|
| 1465 | + echo "Owner Colombia: Download..."; |
|
| 1466 | + } |
|
| 1246 | 1467 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1247 | 1468 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1248 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1469 | + if ($globalDebug) { |
|
| 1470 | + echo "Add to DB..."; |
|
| 1471 | + } |
|
| 1249 | 1472 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1250 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1473 | + } else { |
|
| 1474 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1475 | + } |
|
| 1251 | 1476 | if ($error != '') { |
| 1252 | 1477 | return $error; |
| 1253 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1254 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1478 | + } elseif ($globalDebug) { |
|
| 1479 | + echo "Done\n"; |
|
| 1480 | + } |
|
| 1481 | + if ($globalDebug) { |
|
| 1482 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1483 | + } |
|
| 1255 | 1484 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1256 | 1485 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1257 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1486 | + if ($globalDebug) { |
|
| 1487 | + echo "Add to DB..."; |
|
| 1488 | + } |
|
| 1258 | 1489 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1259 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1490 | + } else { |
|
| 1491 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1492 | + } |
|
| 1260 | 1493 | if ($error != '') { |
| 1261 | 1494 | return $error; |
| 1262 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1263 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1495 | + } elseif ($globalDebug) { |
|
| 1496 | + echo "Done\n"; |
|
| 1497 | + } |
|
| 1498 | + if ($globalDebug) { |
|
| 1499 | + echo "Owner Brazil: Download..."; |
|
| 1500 | + } |
|
| 1264 | 1501 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1265 | 1502 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1266 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1503 | + if ($globalDebug) { |
|
| 1504 | + echo "Add to DB..."; |
|
| 1505 | + } |
|
| 1267 | 1506 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1268 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1507 | + } else { |
|
| 1508 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1509 | + } |
|
| 1269 | 1510 | if ($error != '') { |
| 1270 | 1511 | return $error; |
| 1271 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1272 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1512 | + } elseif ($globalDebug) { |
|
| 1513 | + echo "Done\n"; |
|
| 1514 | + } |
|
| 1515 | + if ($globalDebug) { |
|
| 1516 | + echo "Owner Cayman Islands: Download..."; |
|
| 1517 | + } |
|
| 1273 | 1518 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1274 | 1519 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1275 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1520 | + if ($globalDebug) { |
|
| 1521 | + echo "Add to DB..."; |
|
| 1522 | + } |
|
| 1276 | 1523 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1277 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1524 | + } else { |
|
| 1525 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1526 | + } |
|
| 1278 | 1527 | if ($error != '') { |
| 1279 | 1528 | return $error; |
| 1280 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1281 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1529 | + } elseif ($globalDebug) { |
|
| 1530 | + echo "Done\n"; |
|
| 1531 | + } |
|
| 1532 | + if ($globalDebug) { |
|
| 1533 | + echo "Owner Croatia: Download..."; |
|
| 1534 | + } |
|
| 1282 | 1535 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1283 | 1536 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1284 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1537 | + if ($globalDebug) { |
|
| 1538 | + echo "Add to DB..."; |
|
| 1539 | + } |
|
| 1285 | 1540 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1286 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1541 | + } else { |
|
| 1542 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1543 | + } |
|
| 1287 | 1544 | if ($error != '') { |
| 1288 | 1545 | return $error; |
| 1289 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1290 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1546 | + } elseif ($globalDebug) { |
|
| 1547 | + echo "Done\n"; |
|
| 1548 | + } |
|
| 1549 | + if ($globalDebug) { |
|
| 1550 | + echo "Owner Luxembourg: Download..."; |
|
| 1551 | + } |
|
| 1291 | 1552 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1292 | 1553 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1293 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1554 | + if ($globalDebug) { |
|
| 1555 | + echo "Add to DB..."; |
|
| 1556 | + } |
|
| 1294 | 1557 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1295 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1558 | + } else { |
|
| 1559 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1560 | + } |
|
| 1296 | 1561 | if ($error != '') { |
| 1297 | 1562 | return $error; |
| 1298 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1299 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1563 | + } elseif ($globalDebug) { |
|
| 1564 | + echo "Done\n"; |
|
| 1565 | + } |
|
| 1566 | + if ($globalDebug) { |
|
| 1567 | + echo "Owner Maldives: Download..."; |
|
| 1568 | + } |
|
| 1300 | 1569 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1301 | 1570 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1302 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1571 | + if ($globalDebug) { |
|
| 1572 | + echo "Add to DB..."; |
|
| 1573 | + } |
|
| 1303 | 1574 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1304 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1575 | + } else { |
|
| 1576 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1577 | + } |
|
| 1305 | 1578 | if ($error != '') { |
| 1306 | 1579 | return $error; |
| 1307 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1308 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1580 | + } elseif ($globalDebug) { |
|
| 1581 | + echo "Done\n"; |
|
| 1582 | + } |
|
| 1583 | + if ($globalDebug) { |
|
| 1584 | + echo "Owner New Zealand: Download..."; |
|
| 1585 | + } |
|
| 1309 | 1586 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1310 | 1587 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1311 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1588 | + if ($globalDebug) { |
|
| 1589 | + echo "Add to DB..."; |
|
| 1590 | + } |
|
| 1312 | 1591 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1313 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1592 | + } else { |
|
| 1593 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1594 | + } |
|
| 1314 | 1595 | if ($error != '') { |
| 1315 | 1596 | return $error; |
| 1316 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1317 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1597 | + } elseif ($globalDebug) { |
|
| 1598 | + echo "Done\n"; |
|
| 1599 | + } |
|
| 1600 | + if ($globalDebug) { |
|
| 1601 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1602 | + } |
|
| 1318 | 1603 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1319 | 1604 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1320 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1605 | + if ($globalDebug) { |
|
| 1606 | + echo "Add to DB..."; |
|
| 1607 | + } |
|
| 1321 | 1608 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1322 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1609 | + } else { |
|
| 1610 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1611 | + } |
|
| 1323 | 1612 | if ($error != '') { |
| 1324 | 1613 | return $error; |
| 1325 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1326 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1614 | + } elseif ($globalDebug) { |
|
| 1615 | + echo "Done\n"; |
|
| 1616 | + } |
|
| 1617 | + if ($globalDebug) { |
|
| 1618 | + echo "Owner Slovakia: Download..."; |
|
| 1619 | + } |
|
| 1327 | 1620 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1328 | 1621 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1329 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1622 | + if ($globalDebug) { |
|
| 1623 | + echo "Add to DB..."; |
|
| 1624 | + } |
|
| 1330 | 1625 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1331 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1626 | + } else { |
|
| 1627 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1628 | + } |
|
| 1332 | 1629 | if ($error != '') { |
| 1333 | 1630 | return $error; |
| 1334 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1335 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1631 | + } elseif ($globalDebug) { |
|
| 1632 | + echo "Done\n"; |
|
| 1633 | + } |
|
| 1634 | + if ($globalDebug) { |
|
| 1635 | + echo "Owner Ecuador: Download..."; |
|
| 1636 | + } |
|
| 1336 | 1637 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1337 | 1638 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1338 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1639 | + if ($globalDebug) { |
|
| 1640 | + echo "Add to DB..."; |
|
| 1641 | + } |
|
| 1339 | 1642 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1340 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1643 | + } else { |
|
| 1644 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1645 | + } |
|
| 1341 | 1646 | if ($error != '') { |
| 1342 | 1647 | return $error; |
| 1343 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1344 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1648 | + } elseif ($globalDebug) { |
|
| 1649 | + echo "Done\n"; |
|
| 1650 | + } |
|
| 1651 | + if ($globalDebug) { |
|
| 1652 | + echo "Owner Iceland: Download..."; |
|
| 1653 | + } |
|
| 1345 | 1654 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1346 | 1655 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1347 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1656 | + if ($globalDebug) { |
|
| 1657 | + echo "Add to DB..."; |
|
| 1658 | + } |
|
| 1348 | 1659 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1349 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1660 | + } else { |
|
| 1661 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1662 | + } |
|
| 1350 | 1663 | if ($error != '') { |
| 1351 | 1664 | return $error; |
| 1352 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1665 | + } elseif ($globalDebug) { |
|
| 1666 | + echo "Done\n"; |
|
| 1667 | + } |
|
| 1353 | 1668 | return ''; |
| 1354 | 1669 | } |
| 1355 | 1670 | |
| 1356 | 1671 | public static function update_translation() { |
| 1357 | 1672 | global $tmp_dir, $globalDebug; |
| 1358 | 1673 | $error = ''; |
| 1359 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1674 | + if ($globalDebug) { |
|
| 1675 | + echo "Translation : Download..."; |
|
| 1676 | + } |
|
| 1360 | 1677 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1361 | 1678 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1362 | - if ($globalDebug) echo "Unzip..."; |
|
| 1679 | + if ($globalDebug) { |
|
| 1680 | + echo "Unzip..."; |
|
| 1681 | + } |
|
| 1363 | 1682 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1364 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1683 | + if ($globalDebug) { |
|
| 1684 | + echo "Add to DB..."; |
|
| 1685 | + } |
|
| 1365 | 1686 | $error = update_db::translation(); |
| 1366 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1687 | + } else { |
|
| 1688 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1689 | + } |
|
| 1367 | 1690 | if ($error != '') { |
| 1368 | 1691 | return $error; |
| 1369 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1692 | + } elseif ($globalDebug) { |
|
| 1693 | + echo "Done\n"; |
|
| 1694 | + } |
|
| 1370 | 1695 | return ''; |
| 1371 | 1696 | } |
| 1372 | 1697 | |
| 1373 | 1698 | public static function update_translation_fam() { |
| 1374 | 1699 | global $tmp_dir, $globalDebug; |
| 1375 | 1700 | $error = ''; |
| 1376 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1701 | + if ($globalDebug) { |
|
| 1702 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1703 | + } |
|
| 1377 | 1704 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1378 | 1705 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1379 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1706 | + if ($globalDebug) { |
|
| 1707 | + echo "Gunzip..."; |
|
| 1708 | + } |
|
| 1380 | 1709 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1381 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1710 | + if ($globalDebug) { |
|
| 1711 | + echo "Add to DB..."; |
|
| 1712 | + } |
|
| 1382 | 1713 | $error = update_db::translation_fam(); |
| 1383 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1714 | + } else { |
|
| 1715 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1716 | + } |
|
| 1384 | 1717 | if ($error != '') { |
| 1385 | 1718 | return $error; |
| 1386 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1719 | + } elseif ($globalDebug) { |
|
| 1720 | + echo "Done\n"; |
|
| 1721 | + } |
|
| 1387 | 1722 | return ''; |
| 1388 | 1723 | } |
| 1389 | 1724 | |
@@ -1426,7 +1761,9 @@ discard block |
||
| 1426 | 1761 | } |
| 1427 | 1762 | |
| 1428 | 1763 | $error = ''; |
| 1429 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 1764 | + if ($globalDebug) { |
|
| 1765 | + echo "Notam : Download..."; |
|
| 1766 | + } |
|
| 1430 | 1767 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1431 | 1768 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1432 | 1769 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1441,14 +1778,30 @@ discard block |
||
| 1441 | 1778 | $data['fir'] = $q[0]; |
| 1442 | 1779 | $data['code'] = $q[1]; |
| 1443 | 1780 | $ifrvfr = $q[2]; |
| 1444 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1445 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1446 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1447 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1448 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1449 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1450 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1451 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 1781 | + if ($ifrvfr == 'IV') { |
|
| 1782 | + $data['rules'] = 'IFR/VFR'; |
|
| 1783 | + } |
|
| 1784 | + if ($ifrvfr == 'I') { |
|
| 1785 | + $data['rules'] = 'IFR'; |
|
| 1786 | + } |
|
| 1787 | + if ($ifrvfr == 'V') { |
|
| 1788 | + $data['rules'] = 'VFR'; |
|
| 1789 | + } |
|
| 1790 | + if ($q[4] == 'A') { |
|
| 1791 | + $data['scope'] = 'Airport warning'; |
|
| 1792 | + } |
|
| 1793 | + if ($q[4] == 'E') { |
|
| 1794 | + $data['scope'] = 'Enroute warning'; |
|
| 1795 | + } |
|
| 1796 | + if ($q[4] == 'W') { |
|
| 1797 | + $data['scope'] = 'Navigation warning'; |
|
| 1798 | + } |
|
| 1799 | + if ($q[4] == 'AE') { |
|
| 1800 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 1801 | + } |
|
| 1802 | + if ($q[4] == 'AW') { |
|
| 1803 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 1804 | + } |
|
| 1452 | 1805 | //$data['scope'] = $q[4]; |
| 1453 | 1806 | $data['lower_limit'] = $q[5]; |
| 1454 | 1807 | $data['upper_limit'] = $q[6]; |
@@ -1456,8 +1809,12 @@ discard block |
||
| 1456 | 1809 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1457 | 1810 | $latitude = $Common->convertDec($las,'latitude'); |
| 1458 | 1811 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1459 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1460 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 1812 | + if ($lac == 'S') { |
|
| 1813 | + $latitude = '-'.$latitude; |
|
| 1814 | + } |
|
| 1815 | + if ($lnc == 'W') { |
|
| 1816 | + $longitude = '-'.$longitude; |
|
| 1817 | + } |
|
| 1461 | 1818 | $data['center_latitude'] = $latitude; |
| 1462 | 1819 | $data['center_longitude'] = $longitude; |
| 1463 | 1820 | $data['radius'] = intval($radius); |
@@ -1487,10 +1844,14 @@ discard block |
||
| 1487 | 1844 | $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']); |
| 1488 | 1845 | unset($data); |
| 1489 | 1846 | } |
| 1490 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 1847 | + } else { |
|
| 1848 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 1849 | + } |
|
| 1491 | 1850 | if ($error != '') { |
| 1492 | 1851 | return $error; |
| 1493 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1852 | + } elseif ($globalDebug) { |
|
| 1853 | + echo "Done\n"; |
|
| 1854 | + } |
|
| 1494 | 1855 | return ''; |
| 1495 | 1856 | } |
| 1496 | 1857 | |
@@ -1509,8 +1870,11 @@ discard block |
||
| 1509 | 1870 | return "error : ".$e->getMessage(); |
| 1510 | 1871 | } |
| 1511 | 1872 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1512 | - if ($row['nb'] > 0) return false; |
|
| 1513 | - else return true; |
|
| 1873 | + if ($row['nb'] > 0) { |
|
| 1874 | + return false; |
|
| 1875 | + } else { |
|
| 1876 | + return true; |
|
| 1877 | + } |
|
| 1514 | 1878 | } |
| 1515 | 1879 | |
| 1516 | 1880 | public static function insert_last_update() { |
@@ -1540,8 +1904,11 @@ discard block |
||
| 1540 | 1904 | return "error : ".$e->getMessage(); |
| 1541 | 1905 | } |
| 1542 | 1906 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1543 | - if ($row['nb'] > 0) return false; |
|
| 1544 | - else return true; |
|
| 1907 | + if ($row['nb'] > 0) { |
|
| 1908 | + return false; |
|
| 1909 | + } else { |
|
| 1910 | + return true; |
|
| 1911 | + } |
|
| 1545 | 1912 | } |
| 1546 | 1913 | |
| 1547 | 1914 | public static function insert_last_notam_update() { |
@@ -1571,8 +1938,11 @@ discard block |
||
| 1571 | 1938 | return "error : ".$e->getMessage(); |
| 1572 | 1939 | } |
| 1573 | 1940 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1574 | - if ($row['nb'] > 0) return false; |
|
| 1575 | - else return true; |
|
| 1941 | + if ($row['nb'] > 0) { |
|
| 1942 | + return false; |
|
| 1943 | + } else { |
|
| 1944 | + return true; |
|
| 1945 | + } |
|
| 1576 | 1946 | } |
| 1577 | 1947 | |
| 1578 | 1948 | public static function insert_last_owner_update() { |
@@ -68,6 +68,9 @@ discard block |
||
| 68 | 68 | // ----------------------------------------------------------------------------- |
| 69 | 69 | // get html dom from file |
| 70 | 70 | // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. |
| 71 | +/** |
|
| 72 | + * @param string $url |
|
| 73 | + */ |
|
| 71 | 74 | function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
| 72 | 75 | { |
| 73 | 76 | // We DO force the tags to be terminated. |
@@ -125,6 +128,9 @@ discard block |
||
| 125 | 128 | public $tag_start = 0; |
| 126 | 129 | private $dom = null; |
| 127 | 130 | |
| 131 | + /** |
|
| 132 | + * @param simple_html_dom $dom |
|
| 133 | + */ |
|
| 128 | 134 | function __construct($dom) |
| 129 | 135 | { |
| 130 | 136 | $this->dom = $dom; |
@@ -1501,6 +1507,11 @@ discard block |
||
| 1501 | 1507 | } |
| 1502 | 1508 | |
| 1503 | 1509 | // parse attributes |
| 1510 | + |
|
| 1511 | + /** |
|
| 1512 | + * @param simple_html_dom_node $node |
|
| 1513 | + * @param string[] $space |
|
| 1514 | + */ |
|
| 1504 | 1515 | protected function parse_attr($node, $name, &$space) |
| 1505 | 1516 | { |
| 1506 | 1517 | // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037 |
@@ -1538,6 +1549,11 @@ discard block |
||
| 1538 | 1549 | } |
| 1539 | 1550 | |
| 1540 | 1551 | // link node's parent |
| 1552 | + |
|
| 1553 | + /** |
|
| 1554 | + * @param simple_html_dom_node $node |
|
| 1555 | + * @param boolean $is_child |
|
| 1556 | + */ |
|
| 1541 | 1557 | protected function link_nodes(&$node, $is_child) |
| 1542 | 1558 | { |
| 1543 | 1559 | $node->parent = $this->parent; |
@@ -1549,6 +1565,10 @@ discard block |
||
| 1549 | 1565 | } |
| 1550 | 1566 | |
| 1551 | 1567 | // as a text node |
| 1568 | + |
|
| 1569 | + /** |
|
| 1570 | + * @param string $tag |
|
| 1571 | + */ |
|
| 1552 | 1572 | protected function as_text_node($tag) |
| 1553 | 1573 | { |
| 1554 | 1574 | $node = new simple_html_dom_node($this); |
@@ -1559,12 +1579,18 @@ discard block |
||
| 1559 | 1579 | return true; |
| 1560 | 1580 | } |
| 1561 | 1581 | |
| 1582 | + /** |
|
| 1583 | + * @param string $chars |
|
| 1584 | + */ |
|
| 1562 | 1585 | protected function skip($chars) |
| 1563 | 1586 | { |
| 1564 | 1587 | $this->pos += strspn($this->doc, $chars, $this->pos); |
| 1565 | 1588 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1566 | 1589 | } |
| 1567 | 1590 | |
| 1591 | + /** |
|
| 1592 | + * @param string $chars |
|
| 1593 | + */ |
|
| 1568 | 1594 | protected function copy_skip($chars) |
| 1569 | 1595 | { |
| 1570 | 1596 | $pos = $this->pos; |
@@ -1575,6 +1601,9 @@ discard block |
||
| 1575 | 1601 | return substr($this->doc, $pos, $len); |
| 1576 | 1602 | } |
| 1577 | 1603 | |
| 1604 | + /** |
|
| 1605 | + * @param string $chars |
|
| 1606 | + */ |
|
| 1578 | 1607 | protected function copy_until($chars) |
| 1579 | 1608 | { |
| 1580 | 1609 | $pos = $this->pos; |
@@ -1584,6 +1613,9 @@ discard block |
||
| 1584 | 1613 | return substr($this->doc, $pos, $len); |
| 1585 | 1614 | } |
| 1586 | 1615 | |
| 1616 | + /** |
|
| 1617 | + * @param string $char |
|
| 1618 | + */ |
|
| 1587 | 1619 | protected function copy_until_char($char) |
| 1588 | 1620 | { |
| 1589 | 1621 | if ($this->char===null) return ''; |
@@ -1602,6 +1634,9 @@ discard block |
||
| 1602 | 1634 | return substr($this->doc, $pos_old, $pos-$pos_old); |
| 1603 | 1635 | } |
| 1604 | 1636 | |
| 1637 | + /** |
|
| 1638 | + * @param string $char |
|
| 1639 | + */ |
|
| 1605 | 1640 | protected function copy_until_char_escape($char) |
| 1606 | 1641 | { |
| 1607 | 1642 | if ($this->char===null) return ''; |
@@ -1633,6 +1668,10 @@ discard block |
||
| 1633 | 1668 | |
| 1634 | 1669 | // remove noise from html content |
| 1635 | 1670 | // save the noise in the $this->noise array. |
| 1671 | + |
|
| 1672 | + /** |
|
| 1673 | + * @param string $pattern |
|
| 1674 | + */ |
|
| 1636 | 1675 | protected function remove_noise($pattern, $remove_tag=false) |
| 1637 | 1676 | { |
| 1638 | 1677 | global $debug_object; |
@@ -1658,6 +1697,10 @@ discard block |
||
| 1658 | 1697 | } |
| 1659 | 1698 | |
| 1660 | 1699 | // restore noise to html content |
| 1700 | + |
|
| 1701 | + /** |
|
| 1702 | + * @param string|null $text |
|
| 1703 | + */ |
|
| 1661 | 1704 | function restore_noise($text) |
| 1662 | 1705 | { |
| 1663 | 1706 | global $debug_object; |
@@ -824,11 +824,11 @@ |
||
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
| 827 | - * Returns true if $string is valid UTF-8 and false otherwise. |
|
| 828 | - * |
|
| 829 | - * @param mixed $str String to be tested |
|
| 830 | - * @return boolean |
|
| 831 | - */ |
|
| 827 | + * Returns true if $string is valid UTF-8 and false otherwise. |
|
| 828 | + * |
|
| 829 | + * @param mixed $str String to be tested |
|
| 830 | + * @return boolean |
|
| 831 | + */ |
|
| 832 | 832 | static function is_utf8($str) |
| 833 | 833 | { |
| 834 | 834 | $c=0; $b=0; |
@@ -45,21 +45,21 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | define('HDOM_TYPE_ELEMENT', 1); |
| 47 | 47 | define('HDOM_TYPE_COMMENT', 2); |
| 48 | -define('HDOM_TYPE_TEXT', 3); |
|
| 49 | -define('HDOM_TYPE_ENDTAG', 4); |
|
| 50 | -define('HDOM_TYPE_ROOT', 5); |
|
| 48 | +define('HDOM_TYPE_TEXT', 3); |
|
| 49 | +define('HDOM_TYPE_ENDTAG', 4); |
|
| 50 | +define('HDOM_TYPE_ROOT', 5); |
|
| 51 | 51 | define('HDOM_TYPE_UNKNOWN', 6); |
| 52 | 52 | define('HDOM_QUOTE_DOUBLE', 0); |
| 53 | 53 | define('HDOM_QUOTE_SINGLE', 1); |
| 54 | -define('HDOM_QUOTE_NO', 3); |
|
| 55 | -define('HDOM_INFO_BEGIN', 0); |
|
| 56 | -define('HDOM_INFO_END', 1); |
|
| 57 | -define('HDOM_INFO_QUOTE', 2); |
|
| 58 | -define('HDOM_INFO_SPACE', 3); |
|
| 59 | -define('HDOM_INFO_TEXT', 4); |
|
| 60 | -define('HDOM_INFO_INNER', 5); |
|
| 61 | -define('HDOM_INFO_OUTER', 6); |
|
| 62 | -define('HDOM_INFO_ENDSPACE',7); |
|
| 54 | +define('HDOM_QUOTE_NO', 3); |
|
| 55 | +define('HDOM_INFO_BEGIN', 0); |
|
| 56 | +define('HDOM_INFO_END', 1); |
|
| 57 | +define('HDOM_INFO_QUOTE', 2); |
|
| 58 | +define('HDOM_INFO_SPACE', 3); |
|
| 59 | +define('HDOM_INFO_TEXT', 4); |
|
| 60 | +define('HDOM_INFO_INNER', 5); |
|
| 61 | +define('HDOM_INFO_OUTER', 6); |
|
| 62 | +define('HDOM_INFO_ENDSPACE', 7); |
|
| 63 | 63 | define('DEFAULT_TARGET_CHARSET', 'UTF-8'); |
| 64 | 64 | define('DEFAULT_BR_TEXT', "\r\n"); |
| 65 | 65 | define('DEFAULT_SPAN_TEXT', " "); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // ----------------------------------------------------------------------------- |
| 69 | 69 | // get html dom from file |
| 70 | 70 | // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. |
| 71 | -function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
| 71 | +function file_get_html($url, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
| 72 | 72 | { |
| 73 | 73 | // We DO force the tags to be terminated. |
| 74 | 74 | $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // get html dom from string |
| 89 | -function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
| 89 | +function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
| 90 | 90 | { |
| 91 | 91 | $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); |
| 92 | 92 | if (empty($str) || strlen($str) > MAX_FILE_SIZE) |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // dump html dom tree |
| 102 | -function dump_html_tree($node, $show_attr=true, $deep=0) |
|
| 102 | +function dump_html_tree($node, $show_attr = true, $deep = 0) |
|
| 103 | 103 | { |
| 104 | 104 | $node->dump($node); |
| 105 | 105 | } |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // dump node's tree |
| 154 | - function dump($show_attr=true, $deep=0) |
|
| 154 | + function dump($show_attr = true, $deep = 0) |
|
| 155 | 155 | { |
| 156 | 156 | $lead = str_repeat(' ', $deep); |
| 157 | 157 | |
| 158 | 158 | echo $lead.$this->tag; |
| 159 | - if ($show_attr && count($this->attr)>0) |
|
| 159 | + if ($show_attr && count($this->attr) > 0) |
|
| 160 | 160 | { |
| 161 | 161 | echo '('; |
| 162 | 162 | foreach ($this->attr as $k=>$v) |
@@ -169,18 +169,18 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | foreach ($this->nodes as $c) |
| 171 | 171 | { |
| 172 | - $c->dump($show_attr, $deep+1); |
|
| 172 | + $c->dump($show_attr, $deep + 1); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | // Debugging function to dump a single dom node with a bunch of information about it. |
| 179 | - function dump_node($echo=true) |
|
| 179 | + function dump_node($echo = true) |
|
| 180 | 180 | { |
| 181 | 181 | |
| 182 | 182 | $string = $this->tag; |
| 183 | - if (count($this->attr)>0) |
|
| 183 | + if (count($this->attr) > 0) |
|
| 184 | 184 | { |
| 185 | 185 | $string .= '('; |
| 186 | 186 | foreach ($this->attr as $k=>$v) |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | $string .= ')'; |
| 191 | 191 | } |
| 192 | - if (count($this->_)>0) |
|
| 192 | + if (count($this->_) > 0) |
|
| 193 | 193 | { |
| 194 | 194 | $string .= ' $_ ('; |
| 195 | 195 | foreach ($this->_ as $k=>$v) |
@@ -211,22 +211,22 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | if (isset($this->text)) |
| 213 | 213 | { |
| 214 | - $string .= " text: (" . $this->text . ")"; |
|
| 214 | + $string .= " text: (".$this->text.")"; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $string .= " HDOM_INNER_INFO: '"; |
| 218 | 218 | if (isset($node->_[HDOM_INFO_INNER])) |
| 219 | 219 | { |
| 220 | - $string .= $node->_[HDOM_INFO_INNER] . "'"; |
|
| 220 | + $string .= $node->_[HDOM_INFO_INNER]."'"; |
|
| 221 | 221 | } |
| 222 | 222 | else |
| 223 | 223 | { |
| 224 | 224 | $string .= ' NULL '; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $string .= " children: " . count($this->children); |
|
| 228 | - $string .= " nodes: " . count($this->nodes); |
|
| 229 | - $string .= " tag_start: " . $this->tag_start; |
|
| 227 | + $string .= " children: ".count($this->children); |
|
| 228 | + $string .= " nodes: ".count($this->nodes); |
|
| 229 | + $string .= " tag_start: ".$this->tag_start; |
|
| 230 | 230 | $string .= "\n"; |
| 231 | 231 | |
| 232 | 232 | if ($echo) |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | // returns the parent of node |
| 244 | 244 | // If a node is passed in, it will reset the parent of the current node to that one. |
| 245 | - function parent($parent=null) |
|
| 245 | + function parent($parent = null) |
|
| 246 | 246 | { |
| 247 | 247 | // I am SURE that this doesn't work properly. |
| 248 | 248 | // It fails to unset the current node from it's current parents nodes or children list first. |
@@ -263,9 +263,9 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // returns children of node |
| 266 | - function children($idx=-1) |
|
| 266 | + function children($idx = -1) |
|
| 267 | 267 | { |
| 268 | - if ($idx===-1) |
|
| 268 | + if ($idx === -1) |
|
| 269 | 269 | { |
| 270 | 270 | return $this->children; |
| 271 | 271 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | // returns the first child of node |
| 280 | 280 | function first_child() |
| 281 | 281 | { |
| 282 | - if (count($this->children)>0) |
|
| 282 | + if (count($this->children) > 0) |
|
| 283 | 283 | { |
| 284 | 284 | return $this->children[0]; |
| 285 | 285 | } |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | // returns the last child of node |
| 290 | 290 | function last_child() |
| 291 | 291 | { |
| 292 | - if (($count=count($this->children))>0) |
|
| 292 | + if (($count = count($this->children)) > 0) |
|
| 293 | 293 | { |
| 294 | - return $this->children[$count-1]; |
|
| 294 | + return $this->children[$count - 1]; |
|
| 295 | 295 | } |
| 296 | 296 | return null; |
| 297 | 297 | } |
@@ -299,18 +299,18 @@ discard block |
||
| 299 | 299 | // returns the next sibling of node |
| 300 | 300 | function next_sibling() |
| 301 | 301 | { |
| 302 | - if ($this->parent===null) |
|
| 302 | + if ($this->parent === null) |
|
| 303 | 303 | { |
| 304 | 304 | return null; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $idx = 0; |
| 308 | 308 | $count = count($this->parent->children); |
| 309 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
| 309 | + while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
| 310 | 310 | { |
| 311 | 311 | ++$idx; |
| 312 | 312 | } |
| 313 | - if (++$idx>=$count) |
|
| 313 | + if (++$idx >= $count) |
|
| 314 | 314 | { |
| 315 | 315 | return null; |
| 316 | 316 | } |
@@ -320,12 +320,12 @@ discard block |
||
| 320 | 320 | // returns the previous sibling of node |
| 321 | 321 | function prev_sibling() |
| 322 | 322 | { |
| 323 | - if ($this->parent===null) return null; |
|
| 323 | + if ($this->parent === null) return null; |
|
| 324 | 324 | $idx = 0; |
| 325 | 325 | $count = count($this->parent->children); |
| 326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
| 326 | + while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
| 327 | 327 | ++$idx; |
| 328 | - if (--$idx<0) return null; |
|
| 328 | + if (--$idx < 0) return null; |
|
| 329 | 329 | return $this->parent->children[$idx]; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | while (!is_null($returnDom)) |
| 342 | 342 | { |
| 343 | - if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); } |
|
| 343 | + if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: ".$returnDom->tag); } |
|
| 344 | 344 | |
| 345 | 345 | if ($returnDom->tag == $tag) |
| 346 | 346 | { |
@@ -374,16 +374,16 @@ discard block |
||
| 374 | 374 | { |
| 375 | 375 | if (!empty($this->text)) |
| 376 | 376 | { |
| 377 | - $text = " with text: " . $this->text; |
|
| 377 | + $text = " with text: ".$this->text; |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | - $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
|
| 380 | + $debug_object->debug_log(1, 'Innertext of tag: '.$this->tag.$text); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ($this->tag==='root') return $this->innertext(); |
|
| 383 | + if ($this->tag === 'root') return $this->innertext(); |
|
| 384 | 384 | |
| 385 | 385 | // trigger callback |
| 386 | - if ($this->dom && $this->dom->callback!==null) |
|
| 386 | + if ($this->dom && $this->dom->callback !== null) |
|
| 387 | 387 | { |
| 388 | 388 | call_user_func_array($this->dom->callback, array($this)); |
| 389 | 389 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | // render end tag |
| 421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
| 421 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) |
|
| 422 | 422 | $ret .= '</'.$this->tag.'>'; |
| 423 | 423 | return $ret; |
| 424 | 424 | } |
@@ -433,8 +433,8 @@ discard block |
||
| 433 | 433 | case HDOM_TYPE_COMMENT: return ''; |
| 434 | 434 | case HDOM_TYPE_UNKNOWN: return ''; |
| 435 | 435 | } |
| 436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
| 437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
| 436 | + if (strcasecmp($this->tag, 'script') === 0) return ''; |
|
| 437 | + if (strcasecmp($this->tag, 'style') === 0) return ''; |
|
| 438 | 438 | |
| 439 | 439 | $ret = ''; |
| 440 | 440 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -480,12 +480,12 @@ discard block |
||
| 480 | 480 | ++$i; |
| 481 | 481 | |
| 482 | 482 | // skip removed attribute |
| 483 | - if ($val===null || $val===false) |
|
| 483 | + if ($val === null || $val === false) |
|
| 484 | 484 | continue; |
| 485 | 485 | |
| 486 | 486 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
| 487 | 487 | //no value attr: nowrap, checked selected... |
| 488 | - if ($val===true) |
|
| 488 | + if ($val === true) |
|
| 489 | 489 | $ret .= $key; |
| 490 | 490 | else { |
| 491 | 491 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
@@ -498,34 +498,34 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | $ret = $this->dom->restore_noise($ret); |
| 501 | - return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>'; |
|
| 501 | + return $ret.$this->_[HDOM_INFO_ENDSPACE].'>'; |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // find elements by css selector |
| 505 | 505 | //PaperG - added ability for find to lowercase the value of the selector. |
| 506 | - function find($selector, $idx=null, $lowercase=false) |
|
| 506 | + function find($selector, $idx = null, $lowercase = false) |
|
| 507 | 507 | { |
| 508 | 508 | $selectors = $this->parse_selector($selector); |
| 509 | - if (($count=count($selectors))===0) return array(); |
|
| 509 | + if (($count = count($selectors)) === 0) return array(); |
|
| 510 | 510 | $found_keys = array(); |
| 511 | 511 | |
| 512 | 512 | // find each selector |
| 513 | - for ($c=0; $c<$count; ++$c) |
|
| 513 | + for ($c = 0; $c < $count; ++$c) |
|
| 514 | 514 | { |
| 515 | 515 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
| 516 | 516 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
| 517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
| 517 | + if (($levle = count($selectors[$c])) === 0) return array(); |
|
| 518 | 518 | if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
| 519 | 519 | |
| 520 | 520 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
| 521 | 521 | |
| 522 | 522 | // handle descendant selectors, no recursive! |
| 523 | - for ($l=0; $l<$levle; ++$l) |
|
| 523 | + for ($l = 0; $l < $levle; ++$l) |
|
| 524 | 524 | { |
| 525 | 525 | $ret = array(); |
| 526 | 526 | foreach ($head as $k=>$v) |
| 527 | 527 | { |
| 528 | - $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; |
|
| 528 | + $n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k]; |
|
| 529 | 529 | //PaperG - Pass this optional parameter on to the seek function. |
| 530 | 530 | $n->seek($selectors[$c][$l], $ret, $lowercase); |
| 531 | 531 | } |
@@ -550,13 +550,13 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | // return nth-element or array |
| 552 | 552 | if (is_null($idx)) return $found; |
| 553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
| 553 | + else if ($idx < 0) $idx = count($found) + $idx; |
|
| 554 | 554 | return (isset($found[$idx])) ? $found[$idx] : null; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | // seek for given conditions |
| 558 | 558 | // PaperG - added parameter to allow for case insensitive testing of the value of a selector. |
| 559 | - protected function seek($selector, &$ret, $lowercase=false) |
|
| 559 | + protected function seek($selector, &$ret, $lowercase = false) |
|
| 560 | 560 | { |
| 561 | 561 | global $debug_object; |
| 562 | 562 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | $count = 0; |
| 570 | 570 | foreach ($this->children as $c) |
| 571 | 571 | { |
| 572 | - if ($tag==='*' || $tag===$c->tag) { |
|
| 573 | - if (++$count==$key) { |
|
| 572 | + if ($tag === '*' || $tag === $c->tag) { |
|
| 573 | + if (++$count == $key) { |
|
| 574 | 574 | $ret[$c->_[HDOM_INFO_BEGIN]] = 1; |
| 575 | 575 | return; |
| 576 | 576 | } |
@@ -580,38 +580,38 @@ discard block |
||
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0; |
| 583 | - if ($end==0) { |
|
| 583 | + if ($end == 0) { |
|
| 584 | 584 | $parent = $this->parent; |
| 585 | - while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) { |
|
| 585 | + while (!isset($parent->_[HDOM_INFO_END]) && $parent !== null) { |
|
| 586 | 586 | $end -= 1; |
| 587 | 587 | $parent = $parent->parent; |
| 588 | 588 | } |
| 589 | 589 | $end += $parent->_[HDOM_INFO_END]; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) { |
|
| 592 | + for ($i = $this->_[HDOM_INFO_BEGIN] + 1; $i < $end; ++$i) { |
|
| 593 | 593 | $node = $this->dom->nodes[$i]; |
| 594 | 594 | |
| 595 | 595 | $pass = true; |
| 596 | 596 | |
| 597 | - if ($tag==='*' && !$key) { |
|
| 597 | + if ($tag === '*' && !$key) { |
|
| 598 | 598 | if (in_array($node, $this->children, true)) |
| 599 | 599 | $ret[$i] = 1; |
| 600 | 600 | continue; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | // compare tag |
| 604 | - if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;} |
|
| 604 | + if ($tag && $tag != $node->tag && $tag !== '*') {$pass = false; } |
|
| 605 | 605 | // compare key |
| 606 | 606 | if ($pass && $key) { |
| 607 | 607 | if ($no_key) { |
| 608 | - if (isset($node->attr[$key])) $pass=false; |
|
| 608 | + if (isset($node->attr[$key])) $pass = false; |
|
| 609 | 609 | } else { |
| 610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
| 610 | + if (($key != "plaintext") && !isset($node->attr[$key])) $pass = false; |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | // compare value |
| 614 | - if ($pass && $key && $val && $val!=='*') { |
|
| 614 | + if ($pass && $key && $val && $val !== '*') { |
|
| 615 | 615 | // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right? |
| 616 | 616 | if ($key == "plaintext") { |
| 617 | 617 | // $node->plaintext actually returns $node->text(); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | // this is a normal search, we want the value of that attribute of the tag. |
| 621 | 621 | $nodeKeyValue = $node->attr[$key]; |
| 622 | 622 | } |
| 623 | - if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);} |
|
| 623 | + if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: ".$node->tag." for attribute: ".$key.$exp.$val." where nodes value is: ".$nodeKeyValue); } |
|
| 624 | 624 | |
| 625 | 625 | //PaperG - If lowercase is set, do a case insensitive test of the value of the selector. |
| 626 | 626 | if ($lowercase) { |
@@ -628,11 +628,11 @@ discard block |
||
| 628 | 628 | } else { |
| 629 | 629 | $check = $this->match($exp, $val, $nodeKeyValue); |
| 630 | 630 | } |
| 631 | - if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));} |
|
| 631 | + if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: ".($check ? "true" : "false")); } |
|
| 632 | 632 | |
| 633 | 633 | // handle multiple class |
| 634 | - if (!$check && strcasecmp($key, 'class')===0) { |
|
| 635 | - foreach (explode(' ',$node->attr[$key]) as $k) { |
|
| 634 | + if (!$check && strcasecmp($key, 'class') === 0) { |
|
| 635 | + foreach (explode(' ', $node->attr[$key]) as $k) { |
|
| 636 | 636 | // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form. |
| 637 | 637 | if (!empty($k)) { |
| 638 | 638 | if ($lowercase) { |
@@ -650,24 +650,24 @@ discard block |
||
| 650 | 650 | unset($node); |
| 651 | 651 | } |
| 652 | 652 | // It's passed by reference so this is actually what this function returns. |
| 653 | - if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);} |
|
| 653 | + if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret); } |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | protected function match($exp, $pattern, $value) { |
| 657 | 657 | global $debug_object; |
| 658 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
| 658 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
| 659 | 659 | |
| 660 | 660 | switch ($exp) { |
| 661 | 661 | case '=': |
| 662 | - return ($value===$pattern); |
|
| 662 | + return ($value === $pattern); |
|
| 663 | 663 | case '!=': |
| 664 | - return ($value!==$pattern); |
|
| 664 | + return ($value !== $pattern); |
|
| 665 | 665 | case '^=': |
| 666 | - return preg_match("/^".preg_quote($pattern,'/')."/", $value); |
|
| 666 | + return preg_match("/^".preg_quote($pattern, '/')."/", $value); |
|
| 667 | 667 | case '$=': |
| 668 | - return preg_match("/".preg_quote($pattern,'/')."$/", $value); |
|
| 668 | + return preg_match("/".preg_quote($pattern, '/')."$/", $value); |
|
| 669 | 669 | case '*=': |
| 670 | - if ($pattern[0]=='/') { |
|
| 670 | + if ($pattern[0] == '/') { |
|
| 671 | 671 | return preg_match($pattern, $value); |
| 672 | 672 | } |
| 673 | 673 | return preg_match("/".$pattern."/i", $value); |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | protected function parse_selector($selector_string) { |
| 679 | 679 | global $debug_object; |
| 680 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
| 680 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
| 681 | 681 | |
| 682 | 682 | // pattern of CSS selectors, modified from mootools |
| 683 | 683 | // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does. |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; |
| 689 | 689 | $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; |
| 690 | 690 | preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); |
| 691 | - if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);} |
|
| 691 | + if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches); } |
|
| 692 | 692 | |
| 693 | 693 | $selectors = array(); |
| 694 | 694 | $result = array(); |
@@ -696,29 +696,29 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | foreach ($matches as $m) { |
| 698 | 698 | $m[0] = trim($m[0]); |
| 699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
| 699 | + if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') continue; |
|
| 700 | 700 | // for browser generated xpath |
| 701 | - if ($m[1]==='tbody') continue; |
|
| 701 | + if ($m[1] === 'tbody') continue; |
|
| 702 | 702 | |
| 703 | 703 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
| 704 | - if (!empty($m[2])) {$key='id'; $val=$m[2];} |
|
| 705 | - if (!empty($m[3])) {$key='class'; $val=$m[3];} |
|
| 706 | - if (!empty($m[4])) {$key=$m[4];} |
|
| 707 | - if (!empty($m[5])) {$exp=$m[5];} |
|
| 708 | - if (!empty($m[6])) {$val=$m[6];} |
|
| 704 | + if (!empty($m[2])) {$key = 'id'; $val = $m[2]; } |
|
| 705 | + if (!empty($m[3])) {$key = 'class'; $val = $m[3]; } |
|
| 706 | + if (!empty($m[4])) {$key = $m[4]; } |
|
| 707 | + if (!empty($m[5])) {$exp = $m[5]; } |
|
| 708 | + if (!empty($m[6])) {$val = $m[6]; } |
|
| 709 | 709 | |
| 710 | 710 | // convert to lowercase |
| 711 | - if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} |
|
| 711 | + if ($this->dom->lowercase) {$tag = strtolower($tag); $key = strtolower($key); } |
|
| 712 | 712 | //elements that do NOT have the specified attribute |
| 713 | - if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;} |
|
| 713 | + if (isset($key[0]) && $key[0] === '!') {$key = substr($key, 1); $no_key = true; } |
|
| 714 | 714 | |
| 715 | 715 | $result[] = array($tag, $key, $val, $exp, $no_key); |
| 716 | - if (trim($m[7])===',') { |
|
| 716 | + if (trim($m[7]) === ',') { |
|
| 717 | 717 | $selectors[] = $result; |
| 718 | 718 | $result = array(); |
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | - if (count($result)>0) |
|
| 721 | + if (count($result) > 0) |
|
| 722 | 722 | $selectors[] = $result; |
| 723 | 723 | return $selectors; |
| 724 | 724 | } |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | function __set($name, $value) |
| 743 | 743 | { |
| 744 | 744 | global $debug_object; |
| 745 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
| 745 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
| 746 | 746 | |
| 747 | 747 | switch ($name) |
| 748 | 748 | { |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | function convert_text($text) |
| 781 | 781 | { |
| 782 | 782 | global $debug_object; |
| 783 | - if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} |
|
| 783 | + if (is_object($debug_object)) {$debug_object->debug_log_entry(1); } |
|
| 784 | 784 | |
| 785 | 785 | $converted_text = $text; |
| 786 | 786 | |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | $sourceCharset = strtoupper($this->dom->_charset); |
| 793 | 793 | $targetCharset = strtoupper($this->dom->_target_charset); |
| 794 | 794 | } |
| 795 | - if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);} |
|
| 795 | + if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: ".$sourceCharset." target charaset: ".$targetCharset); } |
|
| 796 | 796 | |
| 797 | 797 | if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0)) |
| 798 | 798 | { |
@@ -831,27 +831,27 @@ discard block |
||
| 831 | 831 | */ |
| 832 | 832 | static function is_utf8($str) |
| 833 | 833 | { |
| 834 | - $c=0; $b=0; |
|
| 835 | - $bits=0; |
|
| 836 | - $len=strlen($str); |
|
| 837 | - for($i=0; $i<$len; $i++) |
|
| 834 | + $c = 0; $b = 0; |
|
| 835 | + $bits = 0; |
|
| 836 | + $len = strlen($str); |
|
| 837 | + for ($i = 0; $i < $len; $i++) |
|
| 838 | 838 | { |
| 839 | - $c=ord($str[$i]); |
|
| 840 | - if($c > 128) |
|
| 839 | + $c = ord($str[$i]); |
|
| 840 | + if ($c > 128) |
|
| 841 | 841 | { |
| 842 | - if(($c >= 254)) return false; |
|
| 843 | - elseif($c >= 252) $bits=6; |
|
| 844 | - elseif($c >= 248) $bits=5; |
|
| 845 | - elseif($c >= 240) $bits=4; |
|
| 846 | - elseif($c >= 224) $bits=3; |
|
| 847 | - elseif($c >= 192) $bits=2; |
|
| 842 | + if (($c >= 254)) return false; |
|
| 843 | + elseif ($c >= 252) $bits = 6; |
|
| 844 | + elseif ($c >= 248) $bits = 5; |
|
| 845 | + elseif ($c >= 240) $bits = 4; |
|
| 846 | + elseif ($c >= 224) $bits = 3; |
|
| 847 | + elseif ($c >= 192) $bits = 2; |
|
| 848 | 848 | else return false; |
| 849 | - if(($i+$bits) > $len) return false; |
|
| 850 | - while($bits > 1) |
|
| 849 | + if (($i + $bits) > $len) return false; |
|
| 850 | + while ($bits > 1) |
|
| 851 | 851 | { |
| 852 | 852 | $i++; |
| 853 | - $b=ord($str[$i]); |
|
| 854 | - if($b < 128 || $b > 191) return false; |
|
| 853 | + $b = ord($str[$i]); |
|
| 854 | + if ($b < 128 || $b > 191) return false; |
|
| 855 | 855 | $bits--; |
| 856 | 856 | } |
| 857 | 857 | } |
@@ -955,24 +955,24 @@ discard block |
||
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | // camel naming conventions |
| 958 | - function getAllAttributes() {return $this->attr;} |
|
| 959 | - function getAttribute($name) {return $this->__get($name);} |
|
| 960 | - function setAttribute($name, $value) {$this->__set($name, $value);} |
|
| 961 | - function hasAttribute($name) {return $this->__isset($name);} |
|
| 962 | - function removeAttribute($name) {$this->__set($name, null);} |
|
| 963 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
| 964 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
| 965 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
| 966 | - function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);} |
|
| 967 | - function parentNode() {return $this->parent();} |
|
| 968 | - function childNodes($idx=-1) {return $this->children($idx);} |
|
| 969 | - function firstChild() {return $this->first_child();} |
|
| 970 | - function lastChild() {return $this->last_child();} |
|
| 971 | - function nextSibling() {return $this->next_sibling();} |
|
| 972 | - function previousSibling() {return $this->prev_sibling();} |
|
| 973 | - function hasChildNodes() {return $this->has_child();} |
|
| 974 | - function nodeName() {return $this->tag;} |
|
| 975 | - function appendChild($node) {$node->parent($this); return $node;} |
|
| 958 | + function getAllAttributes() {return $this->attr; } |
|
| 959 | + function getAttribute($name) {return $this->__get($name); } |
|
| 960 | + function setAttribute($name, $value) {$this->__set($name, $value); } |
|
| 961 | + function hasAttribute($name) {return $this->__isset($name); } |
|
| 962 | + function removeAttribute($name) {$this->__set($name, null); } |
|
| 963 | + function getElementById($id) {return $this->find("#$id", 0); } |
|
| 964 | + function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); } |
|
| 965 | + function getElementByTagName($name) {return $this->find($name, 0); } |
|
| 966 | + function getElementsByTagName($name, $idx = null) {return $this->find($name, $idx); } |
|
| 967 | + function parentNode() {return $this->parent(); } |
|
| 968 | + function childNodes($idx = -1) {return $this->children($idx); } |
|
| 969 | + function firstChild() {return $this->first_child(); } |
|
| 970 | + function lastChild() {return $this->last_child(); } |
|
| 971 | + function nextSibling() {return $this->next_sibling(); } |
|
| 972 | + function previousSibling() {return $this->prev_sibling(); } |
|
| 973 | + function hasChildNodes() {return $this->has_child(); } |
|
| 974 | + function nodeName() {return $this->tag; } |
|
| 975 | + function appendChild($node) {$node->parent($this); return $node; } |
|
| 976 | 976 | |
| 977 | 977 | } |
| 978 | 978 | |
@@ -1028,11 +1028,11 @@ discard block |
||
| 1028 | 1028 | 'option'=>array('option'=>1), |
| 1029 | 1029 | ); |
| 1030 | 1030 | |
| 1031 | - function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
| 1031 | + function __construct($str = null, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
| 1032 | 1032 | { |
| 1033 | 1033 | if ($str) |
| 1034 | 1034 | { |
| 1035 | - if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
|
| 1035 | + if (preg_match("/^http:\/\//i", $str) || is_file($str)) |
|
| 1036 | 1036 | { |
| 1037 | 1037 | $this->load_file($str); |
| 1038 | 1038 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | } |
| 1044 | 1044 | // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html. |
| 1045 | 1045 | if (!$forceTagsClosed) { |
| 1046 | - $this->optional_closing_array=array(); |
|
| 1046 | + $this->optional_closing_array = array(); |
|
| 1047 | 1047 | } |
| 1048 | 1048 | $this->_target_charset = $target_charset; |
| 1049 | 1049 | } |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | // load html from string |
| 1057 | - function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
| 1057 | + function load($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
| 1058 | 1058 | { |
| 1059 | 1059 | global $debug_object; |
| 1060 | 1060 | |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | $args = func_get_args(); |
| 1097 | 1097 | $this->load(call_user_func_array('file_get_contents', $args), true); |
| 1098 | 1098 | // Throw an error if we can't properly load the dom. |
| 1099 | - if (($error=error_get_last())!==null) { |
|
| 1099 | + if (($error = error_get_last()) !== null) { |
|
| 1100 | 1100 | $this->clear(); |
| 1101 | 1101 | return false; |
| 1102 | 1102 | } |
@@ -1115,16 +1115,16 @@ discard block |
||
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | // save dom as string |
| 1118 | - function save($filepath='') |
|
| 1118 | + function save($filepath = '') |
|
| 1119 | 1119 | { |
| 1120 | 1120 | $ret = $this->root->innertext(); |
| 1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
| 1121 | + if ($filepath !== '') file_put_contents($filepath, $ret, LOCK_EX); |
|
| 1122 | 1122 | return $ret; |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | // find dom node by css selector |
| 1126 | 1126 | // Paperg - allow us to specify that we want case insensitive testing of the value of the selector. |
| 1127 | - function find($selector, $idx=null, $lowercase=false) |
|
| 1127 | + function find($selector, $idx = null, $lowercase = false) |
|
| 1128 | 1128 | { |
| 1129 | 1129 | return $this->root->find($selector, $idx, $lowercase); |
| 1130 | 1130 | } |
@@ -1132,22 +1132,22 @@ discard block |
||
| 1132 | 1132 | // clean up memory due to php5 circular references memory leak... |
| 1133 | 1133 | function clear() |
| 1134 | 1134 | { |
| 1135 | - foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
|
| 1135 | + foreach ($this->nodes as $n) {$n->clear(); $n = null; } |
|
| 1136 | 1136 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
| 1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
| 1138 | - if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
|
| 1139 | - if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
|
| 1137 | + if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null; } |
|
| 1138 | + if (isset($this->parent)) {$this->parent->clear(); unset($this->parent); } |
|
| 1139 | + if (isset($this->root)) {$this->root->clear(); unset($this->root); } |
|
| 1140 | 1140 | unset($this->doc); |
| 1141 | 1141 | unset($this->noise); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - function dump($show_attr=true) |
|
| 1144 | + function dump($show_attr = true) |
|
| 1145 | 1145 | { |
| 1146 | 1146 | $this->root->dump($show_attr); |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | // prepare HTML data and init everything |
| 1150 | - protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) |
|
| 1150 | + protected function prepare($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
|
| 1151 | 1151 | { |
| 1152 | 1152 | $this->clear(); |
| 1153 | 1153 | |
@@ -1178,13 +1178,13 @@ discard block |
||
| 1178 | 1178 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
| 1179 | 1179 | $this->root->nodetype = HDOM_TYPE_ROOT; |
| 1180 | 1180 | $this->parent = $this->root; |
| 1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
| 1181 | + if ($this->size > 0) $this->char = $this->doc[0]; |
|
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | // parse html content |
| 1185 | 1185 | protected function parse() |
| 1186 | 1186 | { |
| 1187 | - if (($s = $this->copy_until_char('<'))==='') |
|
| 1187 | + if (($s = $this->copy_until_char('<')) === '') |
|
| 1188 | 1188 | { |
| 1189 | 1189 | return $this->read_tag(); |
| 1190 | 1190 | } |
@@ -1213,18 +1213,18 @@ discard block |
||
| 1213 | 1213 | if ($success) |
| 1214 | 1214 | { |
| 1215 | 1215 | $charset = $matches[1]; |
| 1216 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: ' . $charset);} |
|
| 1216 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: '.$charset); } |
|
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | if (empty($charset)) |
| 1222 | 1222 | { |
| 1223 | - $el = $this->root->find('meta[http-equiv=Content-Type]',0, true); |
|
| 1223 | + $el = $this->root->find('meta[http-equiv=Content-Type]', 0, true); |
|
| 1224 | 1224 | if (!empty($el)) |
| 1225 | 1225 | { |
| 1226 | 1226 | $fullvalue = $el->content; |
| 1227 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found' . $fullvalue);} |
|
| 1227 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found'.$fullvalue); } |
|
| 1228 | 1228 | |
| 1229 | 1229 | if (!empty($fullvalue)) |
| 1230 | 1230 | { |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | else |
| 1237 | 1237 | { |
| 1238 | 1238 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
| 1239 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
|
| 1239 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.'); } |
|
| 1240 | 1240 | $charset = 'ISO-8859-1'; |
| 1241 | 1241 | } |
| 1242 | 1242 | } |
@@ -1251,14 +1251,14 @@ discard block |
||
| 1251 | 1251 | if (function_exists('mb_detect_encoding')) |
| 1252 | 1252 | { |
| 1253 | 1253 | // Have php try to detect the encoding from the text given to us. |
| 1254 | - $charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) ); |
|
| 1255 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: ' . $charset);} |
|
| 1254 | + $charset = mb_detect_encoding($this->root->plaintext."ascii", $encoding_list = array("UTF-8", "CP1252")); |
|
| 1255 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: '.$charset); } |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | // and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need... |
| 1259 | 1259 | if ($charset === false) |
| 1260 | 1260 | { |
| 1261 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8');} |
|
| 1261 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8'); } |
|
| 1262 | 1262 | $charset = 'UTF-8'; |
| 1263 | 1263 | } |
| 1264 | 1264 | } |
@@ -1266,11 +1266,11 @@ discard block |
||
| 1266 | 1266 | // Since CP1252 is a superset, if we get one of it's subsets, we want it instead. |
| 1267 | 1267 | if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1'))) |
| 1268 | 1268 | { |
| 1269 | - if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing ' . $charset . ' with CP1252 as its a superset');} |
|
| 1269 | + if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing '.$charset.' with CP1252 as its a superset'); } |
|
| 1270 | 1270 | $charset = 'CP1252'; |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - ' . $charset);} |
|
| 1273 | + if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - '.$charset); } |
|
| 1274 | 1274 | |
| 1275 | 1275 | return $this->_charset = $charset; |
| 1276 | 1276 | } |
@@ -1278,41 +1278,41 @@ discard block |
||
| 1278 | 1278 | // read tag info |
| 1279 | 1279 | protected function read_tag() |
| 1280 | 1280 | { |
| 1281 | - if ($this->char!=='<') |
|
| 1281 | + if ($this->char !== '<') |
|
| 1282 | 1282 | { |
| 1283 | 1283 | $this->root->_[HDOM_INFO_END] = $this->cursor; |
| 1284 | 1284 | return false; |
| 1285 | 1285 | } |
| 1286 | 1286 | $begin_tag_pos = $this->pos; |
| 1287 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1287 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1288 | 1288 | |
| 1289 | 1289 | // end tag |
| 1290 | - if ($this->char==='/') |
|
| 1290 | + if ($this->char === '/') |
|
| 1291 | 1291 | { |
| 1292 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1292 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1293 | 1293 | // This represents the change in the simple_html_dom trunk from revision 180 to 181. |
| 1294 | 1294 | // $this->skip($this->token_blank_t); |
| 1295 | 1295 | $this->skip($this->token_blank); |
| 1296 | 1296 | $tag = $this->copy_until_char('>'); |
| 1297 | 1297 | |
| 1298 | 1298 | // skip attributes in end tag |
| 1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
| 1299 | + if (($pos = strpos($tag, ' ')) !== false) |
|
| 1300 | 1300 | $tag = substr($tag, 0, $pos); |
| 1301 | 1301 | |
| 1302 | 1302 | $parent_lower = strtolower($this->parent->tag); |
| 1303 | 1303 | $tag_lower = strtolower($tag); |
| 1304 | 1304 | |
| 1305 | - if ($parent_lower!==$tag_lower) |
|
| 1305 | + if ($parent_lower !== $tag_lower) |
|
| 1306 | 1306 | { |
| 1307 | 1307 | if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) |
| 1308 | 1308 | { |
| 1309 | 1309 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1310 | 1310 | $org_parent = $this->parent; |
| 1311 | 1311 | |
| 1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
| 1312 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
| 1313 | 1313 | $this->parent = $this->parent->parent; |
| 1314 | 1314 | |
| 1315 | - if (strtolower($this->parent->tag)!==$tag_lower) { |
|
| 1315 | + if (strtolower($this->parent->tag) !== $tag_lower) { |
|
| 1316 | 1316 | $this->parent = $org_parent; // restore origonal parent |
| 1317 | 1317 | if ($this->parent->parent) $this->parent = $this->parent->parent; |
| 1318 | 1318 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
@@ -1324,17 +1324,17 @@ discard block |
||
| 1324 | 1324 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1325 | 1325 | $org_parent = $this->parent; |
| 1326 | 1326 | |
| 1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
| 1327 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
| 1328 | 1328 | $this->parent = $this->parent->parent; |
| 1329 | 1329 | |
| 1330 | - if (strtolower($this->parent->tag)!==$tag_lower) |
|
| 1330 | + if (strtolower($this->parent->tag) !== $tag_lower) |
|
| 1331 | 1331 | { |
| 1332 | 1332 | $this->parent = $org_parent; // restore origonal parent |
| 1333 | 1333 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1334 | 1334 | return $this->as_text_node($tag); |
| 1335 | 1335 | } |
| 1336 | 1336 | } |
| 1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
| 1337 | + else if (($this->parent->parent) && strtolower($this->parent->parent->tag) === $tag_lower) |
|
| 1338 | 1338 | { |
| 1339 | 1339 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1340 | 1340 | $this->parent = $this->parent->parent; |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1347 | 1347 | if ($this->parent->parent) $this->parent = $this->parent->parent; |
| 1348 | 1348 | |
| 1349 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1349 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1350 | 1350 | return true; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
@@ -1357,25 +1357,25 @@ discard block |
||
| 1357 | 1357 | $node->tag_start = $begin_tag_pos; |
| 1358 | 1358 | |
| 1359 | 1359 | // doctype, cdata & comments... |
| 1360 | - if (isset($tag[0]) && $tag[0]==='!') { |
|
| 1361 | - $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>'); |
|
| 1360 | + if (isset($tag[0]) && $tag[0] === '!') { |
|
| 1361 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until_char('>'); |
|
| 1362 | 1362 | |
| 1363 | - if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') { |
|
| 1363 | + if (isset($tag[2]) && $tag[1] === '-' && $tag[2] === '-') { |
|
| 1364 | 1364 | $node->nodetype = HDOM_TYPE_COMMENT; |
| 1365 | 1365 | $node->tag = 'comment'; |
| 1366 | 1366 | } else { |
| 1367 | 1367 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
| 1368 | 1368 | $node->tag = 'unknown'; |
| 1369 | 1369 | } |
| 1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1370 | + if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>'; |
|
| 1371 | 1371 | $this->link_nodes($node, true); |
| 1372 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1372 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1373 | 1373 | return true; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | // text |
| 1377 | - if ($pos=strpos($tag, '<')!==false) { |
|
| 1378 | - $tag = '<' . substr($tag, 0, -1); |
|
| 1377 | + if ($pos = strpos($tag, '<') !== false) { |
|
| 1378 | + $tag = '<'.substr($tag, 0, -1); |
|
| 1379 | 1379 | $node->_[HDOM_INFO_TEXT] = $tag; |
| 1380 | 1380 | $this->link_nodes($node, false); |
| 1381 | 1381 | $this->char = $this->doc[--$this->pos]; // prev |
@@ -1383,15 +1383,15 @@ discard block |
||
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | if (!preg_match("/^[\w-:]+$/", $tag)) { |
| 1386 | - $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>'); |
|
| 1387 | - if ($this->char==='<') { |
|
| 1386 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until('<>'); |
|
| 1387 | + if ($this->char === '<') { |
|
| 1388 | 1388 | $this->link_nodes($node, false); |
| 1389 | 1389 | return true; |
| 1390 | 1390 | } |
| 1391 | 1391 | |
| 1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1392 | + if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>'; |
|
| 1393 | 1393 | $this->link_nodes($node, false); |
| 1394 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1394 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1395 | 1395 | return true; |
| 1396 | 1396 | } |
| 1397 | 1397 | |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | $node->tag = ($this->lowercase) ? $tag_lower : $tag; |
| 1402 | 1402 | |
| 1403 | 1403 | // handle optional closing tags |
| 1404 | - if (isset($this->optional_closing_tags[$tag_lower]) ) |
|
| 1404 | + if (isset($this->optional_closing_tags[$tag_lower])) |
|
| 1405 | 1405 | { |
| 1406 | 1406 | while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) |
| 1407 | 1407 | { |
@@ -1417,67 +1417,67 @@ discard block |
||
| 1417 | 1417 | // attributes |
| 1418 | 1418 | do |
| 1419 | 1419 | { |
| 1420 | - if ($this->char!==null && $space[0]==='') |
|
| 1420 | + if ($this->char !== null && $space[0] === '') |
|
| 1421 | 1421 | { |
| 1422 | 1422 | break; |
| 1423 | 1423 | } |
| 1424 | 1424 | $name = $this->copy_until($this->token_equal); |
| 1425 | - if ($guard===$this->pos) |
|
| 1425 | + if ($guard === $this->pos) |
|
| 1426 | 1426 | { |
| 1427 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1427 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1428 | 1428 | continue; |
| 1429 | 1429 | } |
| 1430 | 1430 | $guard = $this->pos; |
| 1431 | 1431 | |
| 1432 | 1432 | // handle endless '<' |
| 1433 | - if ($this->pos>=$this->size-1 && $this->char!=='>') { |
|
| 1433 | + if ($this->pos >= $this->size - 1 && $this->char !== '>') { |
|
| 1434 | 1434 | $node->nodetype = HDOM_TYPE_TEXT; |
| 1435 | 1435 | $node->_[HDOM_INFO_END] = 0; |
| 1436 | - $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name; |
|
| 1436 | + $node->_[HDOM_INFO_TEXT] = '<'.$tag.$space[0].$name; |
|
| 1437 | 1437 | $node->tag = 'text'; |
| 1438 | 1438 | $this->link_nodes($node, false); |
| 1439 | 1439 | return true; |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | 1442 | // handle mismatch '<' |
| 1443 | - if ($this->doc[$this->pos-1]=='<') { |
|
| 1443 | + if ($this->doc[$this->pos - 1] == '<') { |
|
| 1444 | 1444 | $node->nodetype = HDOM_TYPE_TEXT; |
| 1445 | 1445 | $node->tag = 'text'; |
| 1446 | 1446 | $node->attr = array(); |
| 1447 | 1447 | $node->_[HDOM_INFO_END] = 0; |
| 1448 | - $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1); |
|
| 1448 | + $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos - $begin_tag_pos - 1); |
|
| 1449 | 1449 | $this->pos -= 2; |
| 1450 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1450 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1451 | 1451 | $this->link_nodes($node, false); |
| 1452 | 1452 | return true; |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | - if ($name!=='/' && $name!=='') { |
|
| 1455 | + if ($name !== '/' && $name !== '') { |
|
| 1456 | 1456 | $space[1] = $this->copy_skip($this->token_blank); |
| 1457 | 1457 | $name = $this->restore_noise($name); |
| 1458 | 1458 | if ($this->lowercase) $name = strtolower($name); |
| 1459 | - if ($this->char==='=') { |
|
| 1460 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1459 | + if ($this->char === '=') { |
|
| 1460 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1461 | 1461 | $this->parse_attr($node, $name, $space); |
| 1462 | 1462 | } |
| 1463 | 1463 | else { |
| 1464 | 1464 | //no value attr: nowrap, checked selected... |
| 1465 | 1465 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
| 1466 | 1466 | $node->attr[$name] = true; |
| 1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
| 1467 | + if ($this->char != '>') $this->char = $this->doc[--$this->pos]; // prev |
|
| 1468 | 1468 | } |
| 1469 | 1469 | $node->_[HDOM_INFO_SPACE][] = $space; |
| 1470 | 1470 | $space = array($this->copy_skip($this->token_blank), '', ''); |
| 1471 | 1471 | } |
| 1472 | 1472 | else |
| 1473 | 1473 | break; |
| 1474 | - } while ($this->char!=='>' && $this->char!=='/'); |
|
| 1474 | + } while ($this->char !== '>' && $this->char !== '/'); |
|
| 1475 | 1475 | |
| 1476 | 1476 | $this->link_nodes($node, true); |
| 1477 | 1477 | $node->_[HDOM_INFO_ENDSPACE] = $space[0]; |
| 1478 | 1478 | |
| 1479 | 1479 | // check self closing |
| 1480 | - if ($this->copy_until_char_escape('>')==='/') |
|
| 1480 | + if ($this->copy_until_char_escape('>') === '/') |
|
| 1481 | 1481 | { |
| 1482 | 1482 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
| 1483 | 1483 | $node->_[HDOM_INFO_END] = 0; |
@@ -1487,7 +1487,7 @@ discard block |
||
| 1487 | 1487 | // reset parent |
| 1488 | 1488 | if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
| 1489 | 1489 | } |
| 1490 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1490 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1491 | 1491 | |
| 1492 | 1492 | // If it's a BR tag, we need to set it's text to the default text. |
| 1493 | 1493 | // This way when we see it in plaintext, we can generate formatting that the user wants. |
@@ -1514,15 +1514,15 @@ discard block |
||
| 1514 | 1514 | switch ($this->char) { |
| 1515 | 1515 | case '"': |
| 1516 | 1516 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE; |
| 1517 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1517 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1518 | 1518 | $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"')); |
| 1519 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1519 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1520 | 1520 | break; |
| 1521 | 1521 | case '\'': |
| 1522 | 1522 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE; |
| 1523 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1523 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1524 | 1524 | $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\'')); |
| 1525 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1525 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1526 | 1526 | break; |
| 1527 | 1527 | default: |
| 1528 | 1528 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
@@ -1553,16 +1553,16 @@ discard block |
||
| 1553 | 1553 | { |
| 1554 | 1554 | $node = new simple_html_dom_node($this); |
| 1555 | 1555 | ++$this->cursor; |
| 1556 | - $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>'; |
|
| 1556 | + $node->_[HDOM_INFO_TEXT] = '</'.$tag.'>'; |
|
| 1557 | 1557 | $this->link_nodes($node, false); |
| 1558 | - $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1558 | + $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1559 | 1559 | return true; |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | 1562 | protected function skip($chars) |
| 1563 | 1563 | { |
| 1564 | 1564 | $this->pos += strspn($this->doc, $chars, $this->pos); |
| 1565 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1565 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1566 | 1566 | } |
| 1567 | 1567 | |
| 1568 | 1568 | protected function copy_skip($chars) |
@@ -1570,8 +1570,8 @@ discard block |
||
| 1570 | 1570 | $pos = $this->pos; |
| 1571 | 1571 | $len = strspn($this->doc, $chars, $pos); |
| 1572 | 1572 | $this->pos += $len; |
| 1573 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1574 | - if ($len===0) return ''; |
|
| 1573 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1574 | + if ($len === 0) return ''; |
|
| 1575 | 1575 | return substr($this->doc, $pos, $len); |
| 1576 | 1576 | } |
| 1577 | 1577 | |
@@ -1580,70 +1580,70 @@ discard block |
||
| 1580 | 1580 | $pos = $this->pos; |
| 1581 | 1581 | $len = strcspn($this->doc, $chars, $pos); |
| 1582 | 1582 | $this->pos += $len; |
| 1583 | - $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1583 | + $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
|
| 1584 | 1584 | return substr($this->doc, $pos, $len); |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | protected function copy_until_char($char) |
| 1588 | 1588 | { |
| 1589 | - if ($this->char===null) return ''; |
|
| 1589 | + if ($this->char === null) return ''; |
|
| 1590 | 1590 | |
| 1591 | - if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
|
| 1592 | - $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
|
| 1591 | + if (($pos = strpos($this->doc, $char, $this->pos)) === false) { |
|
| 1592 | + $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
|
| 1593 | 1593 | $this->char = null; |
| 1594 | 1594 | $this->pos = $this->size; |
| 1595 | 1595 | return $ret; |
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | - if ($pos===$this->pos) return ''; |
|
| 1598 | + if ($pos === $this->pos) return ''; |
|
| 1599 | 1599 | $pos_old = $this->pos; |
| 1600 | 1600 | $this->char = $this->doc[$pos]; |
| 1601 | 1601 | $this->pos = $pos; |
| 1602 | - return substr($this->doc, $pos_old, $pos-$pos_old); |
|
| 1602 | + return substr($this->doc, $pos_old, $pos - $pos_old); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | 1605 | protected function copy_until_char_escape($char) |
| 1606 | 1606 | { |
| 1607 | - if ($this->char===null) return ''; |
|
| 1607 | + if ($this->char === null) return ''; |
|
| 1608 | 1608 | |
| 1609 | 1609 | $start = $this->pos; |
| 1610 | 1610 | while (1) |
| 1611 | 1611 | { |
| 1612 | - if (($pos = strpos($this->doc, $char, $start))===false) |
|
| 1612 | + if (($pos = strpos($this->doc, $char, $start)) === false) |
|
| 1613 | 1613 | { |
| 1614 | - $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
|
| 1614 | + $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
|
| 1615 | 1615 | $this->char = null; |
| 1616 | 1616 | $this->pos = $this->size; |
| 1617 | 1617 | return $ret; |
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | - if ($pos===$this->pos) return ''; |
|
| 1620 | + if ($pos === $this->pos) return ''; |
|
| 1621 | 1621 | |
| 1622 | - if ($this->doc[$pos-1]==='\\') { |
|
| 1623 | - $start = $pos+1; |
|
| 1622 | + if ($this->doc[$pos - 1] === '\\') { |
|
| 1623 | + $start = $pos + 1; |
|
| 1624 | 1624 | continue; |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | $pos_old = $this->pos; |
| 1628 | 1628 | $this->char = $this->doc[$pos]; |
| 1629 | 1629 | $this->pos = $pos; |
| 1630 | - return substr($this->doc, $pos_old, $pos-$pos_old); |
|
| 1630 | + return substr($this->doc, $pos_old, $pos - $pos_old); |
|
| 1631 | 1631 | } |
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | // remove noise from html content |
| 1635 | 1635 | // save the noise in the $this->noise array. |
| 1636 | - protected function remove_noise($pattern, $remove_tag=false) |
|
| 1636 | + protected function remove_noise($pattern, $remove_tag = false) |
|
| 1637 | 1637 | { |
| 1638 | 1638 | global $debug_object; |
| 1639 | 1639 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
| 1640 | 1640 | |
| 1641 | 1641 | $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
| 1642 | 1642 | |
| 1643 | - for ($i=$count-1; $i>-1; --$i) |
|
| 1643 | + for ($i = $count - 1; $i > -1; --$i) |
|
| 1644 | 1644 | { |
| 1645 | - $key = '___noise___'.sprintf('% 5d', count($this->noise)+1000); |
|
| 1646 | - if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: ' . $key); } |
|
| 1645 | + $key = '___noise___'.sprintf('% 5d', count($this->noise) + 1000); |
|
| 1646 | + if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: '.$key); } |
|
| 1647 | 1647 | $idx = ($remove_tag) ? 0 : 1; |
| 1648 | 1648 | $this->noise[$key] = $matches[$i][$idx][0]; |
| 1649 | 1649 | $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0])); |
@@ -1651,7 +1651,7 @@ discard block |
||
| 1651 | 1651 | |
| 1652 | 1652 | // reset the length of content |
| 1653 | 1653 | $this->size = strlen($this->doc); |
| 1654 | - if ($this->size>0) |
|
| 1654 | + if ($this->size > 0) |
|
| 1655 | 1655 | { |
| 1656 | 1656 | $this->char = $this->doc[0]; |
| 1657 | 1657 | } |
@@ -1663,28 +1663,28 @@ discard block |
||
| 1663 | 1663 | global $debug_object; |
| 1664 | 1664 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
| 1665 | 1665 | |
| 1666 | - while (($pos=strpos($text, '___noise___'))!==false) |
|
| 1666 | + while (($pos = strpos($text, '___noise___')) !== false) |
|
| 1667 | 1667 | { |
| 1668 | 1668 | // Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us... |
| 1669 | - if (strlen($text) > $pos+15) |
|
| 1669 | + if (strlen($text) > $pos + 15) |
|
| 1670 | 1670 | { |
| 1671 | - $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15]; |
|
| 1672 | - if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: ' . $key); } |
|
| 1671 | + $key = '___noise___'.$text[$pos + 11].$text[$pos + 12].$text[$pos + 13].$text[$pos + 14].$text[$pos + 15]; |
|
| 1672 | + if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: '.$key); } |
|
| 1673 | 1673 | |
| 1674 | 1674 | if (isset($this->noise[$key])) |
| 1675 | 1675 | { |
| 1676 | - $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
|
| 1676 | + $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos + 16); |
|
| 1677 | 1677 | } |
| 1678 | 1678 | else |
| 1679 | 1679 | { |
| 1680 | 1680 | // do this to prevent an infinite loop. |
| 1681 | - $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
|
| 1681 | + $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key.substr($text, $pos + 16); |
|
| 1682 | 1682 | } |
| 1683 | 1683 | } |
| 1684 | 1684 | else |
| 1685 | 1685 | { |
| 1686 | 1686 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
| 1687 | - $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
|
| 1687 | + $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY'.substr($text, $pos + 11); |
|
| 1688 | 1688 | } |
| 1689 | 1689 | } |
| 1690 | 1690 | return $text; |
@@ -1696,9 +1696,9 @@ discard block |
||
| 1696 | 1696 | global $debug_object; |
| 1697 | 1697 | if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } |
| 1698 | 1698 | |
| 1699 | - foreach($this->noise as $noiseElement) |
|
| 1699 | + foreach ($this->noise as $noiseElement) |
|
| 1700 | 1700 | { |
| 1701 | - if (strpos($noiseElement, $text)!==false) |
|
| 1701 | + if (strpos($noiseElement, $text) !== false) |
|
| 1702 | 1702 | { |
| 1703 | 1703 | return $noiseElement; |
| 1704 | 1704 | } |
@@ -1727,16 +1727,16 @@ discard block |
||
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | // camel naming conventions |
| 1730 | - function childNodes($idx=-1) {return $this->root->childNodes($idx);} |
|
| 1731 | - function firstChild() {return $this->root->first_child();} |
|
| 1732 | - function lastChild() {return $this->root->last_child();} |
|
| 1733 | - function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();} |
|
| 1734 | - function createTextNode($value) {return @end(str_get_html($value)->nodes);} |
|
| 1735 | - function getElementById($id) {return $this->find("#$id", 0);} |
|
| 1736 | - function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} |
|
| 1737 | - function getElementByTagName($name) {return $this->find($name, 0);} |
|
| 1738 | - function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);} |
|
| 1739 | - function loadFile() {$args = func_get_args();$this->load_file($args);} |
|
| 1730 | + function childNodes($idx = -1) {return $this->root->childNodes($idx); } |
|
| 1731 | + function firstChild() {return $this->root->first_child(); } |
|
| 1732 | + function lastChild() {return $this->root->last_child(); } |
|
| 1733 | + function createElement($name, $value = null) {return @str_get_html("<$name>$value</$name>")->first_child(); } |
|
| 1734 | + function createTextNode($value) {return @end(str_get_html($value)->nodes); } |
|
| 1735 | + function getElementById($id) {return $this->find("#$id", 0); } |
|
| 1736 | + function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); } |
|
| 1737 | + function getElementByTagName($name) {return $this->find($name, 0); } |
|
| 1738 | + function getElementsByTagName($name, $idx = -1) {return $this->find($name, $idx); } |
|
| 1739 | + function loadFile() {$args = func_get_args(); $this->load_file($args); } |
|
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | ?> |
| 1743 | 1743 | \ No newline at end of file |
@@ -159,8 +159,9 @@ discard block |
||
| 159 | 159 | if ($show_attr && count($this->attr)>0) |
| 160 | 160 | { |
| 161 | 161 | echo '('; |
| 162 | - foreach ($this->attr as $k=>$v) |
|
| 163 | - echo "[$k]=>\"".$this->$k.'", '; |
|
| 162 | + foreach ($this->attr as $k=>$v) { |
|
| 163 | + echo "[$k]=>\"".$this->$k.'", '; |
|
| 164 | + } |
|
| 164 | 165 | echo ')'; |
| 165 | 166 | } |
| 166 | 167 | echo "\n"; |
@@ -218,8 +219,7 @@ discard block |
||
| 218 | 219 | if (isset($node->_[HDOM_INFO_INNER])) |
| 219 | 220 | { |
| 220 | 221 | $string .= $node->_[HDOM_INFO_INNER] . "'"; |
| 221 | - } |
|
| 222 | - else |
|
| 222 | + } else |
|
| 223 | 223 | { |
| 224 | 224 | $string .= ' NULL '; |
| 225 | 225 | } |
@@ -233,8 +233,7 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | echo $string; |
| 235 | 235 | return; |
| 236 | - } |
|
| 237 | - else |
|
| 236 | + } else |
|
| 238 | 237 | { |
| 239 | 238 | return $string; |
| 240 | 239 | } |
@@ -320,12 +319,17 @@ discard block |
||
| 320 | 319 | // returns the previous sibling of node |
| 321 | 320 | function prev_sibling() |
| 322 | 321 | { |
| 323 | - if ($this->parent===null) return null; |
|
| 322 | + if ($this->parent===null) { |
|
| 323 | + return null; |
|
| 324 | + } |
|
| 324 | 325 | $idx = 0; |
| 325 | 326 | $count = count($this->parent->children); |
| 326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
| 327 | - ++$idx; |
|
| 328 | - if (--$idx<0) return null; |
|
| 327 | + while ($idx<$count && $this!==$this->parent->children[$idx]) { |
|
| 328 | + ++$idx; |
|
| 329 | + } |
|
| 330 | + if (--$idx<0) { |
|
| 331 | + return null; |
|
| 332 | + } |
|
| 329 | 333 | return $this->parent->children[$idx]; |
| 330 | 334 | } |
| 331 | 335 | |
@@ -354,12 +358,17 @@ discard block |
||
| 354 | 358 | // get dom node's inner html |
| 355 | 359 | function innertext() |
| 356 | 360 | { |
| 357 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
| 358 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 361 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
| 362 | + return $this->_[HDOM_INFO_INNER]; |
|
| 363 | + } |
|
| 364 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 365 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 366 | + } |
|
| 359 | 367 | |
| 360 | 368 | $ret = ''; |
| 361 | - foreach ($this->nodes as $n) |
|
| 362 | - $ret .= $n->outertext(); |
|
| 369 | + foreach ($this->nodes as $n) { |
|
| 370 | + $ret .= $n->outertext(); |
|
| 371 | + } |
|
| 363 | 372 | return $ret; |
| 364 | 373 | } |
| 365 | 374 | |
@@ -380,7 +389,9 @@ discard block |
||
| 380 | 389 | $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
| 381 | 390 | } |
| 382 | 391 | |
| 383 | - if ($this->tag==='root') return $this->innertext(); |
|
| 392 | + if ($this->tag==='root') { |
|
| 393 | + return $this->innertext(); |
|
| 394 | + } |
|
| 384 | 395 | |
| 385 | 396 | // trigger callback |
| 386 | 397 | if ($this->dom && $this->dom->callback!==null) |
@@ -388,8 +399,12 @@ discard block |
||
| 388 | 399 | call_user_func_array($this->dom->callback, array($this)); |
| 389 | 400 | } |
| 390 | 401 | |
| 391 | - if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; |
|
| 392 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 402 | + if (isset($this->_[HDOM_INFO_OUTER])) { |
|
| 403 | + return $this->_[HDOM_INFO_OUTER]; |
|
| 404 | + } |
|
| 405 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 406 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 407 | + } |
|
| 393 | 408 | |
| 394 | 409 | // render begin tag |
| 395 | 410 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) |
@@ -418,23 +433,30 @@ discard block |
||
| 418 | 433 | } |
| 419 | 434 | |
| 420 | 435 | // render end tag |
| 421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
| 422 | - $ret .= '</'.$this->tag.'>'; |
|
| 436 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) { |
|
| 437 | + $ret .= '</'.$this->tag.'>'; |
|
| 438 | + } |
|
| 423 | 439 | return $ret; |
| 424 | 440 | } |
| 425 | 441 | |
| 426 | 442 | // get dom node's plain text |
| 427 | 443 | function text() |
| 428 | 444 | { |
| 429 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
| 445 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
| 446 | + return $this->_[HDOM_INFO_INNER]; |
|
| 447 | + } |
|
| 430 | 448 | switch ($this->nodetype) |
| 431 | 449 | { |
| 432 | 450 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
| 433 | 451 | case HDOM_TYPE_COMMENT: return ''; |
| 434 | 452 | case HDOM_TYPE_UNKNOWN: return ''; |
| 435 | 453 | } |
| 436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
| 437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
| 454 | + if (strcasecmp($this->tag, 'script')===0) { |
|
| 455 | + return ''; |
|
| 456 | + } |
|
| 457 | + if (strcasecmp($this->tag, 'style')===0) { |
|
| 458 | + return ''; |
|
| 459 | + } |
|
| 438 | 460 | |
| 439 | 461 | $ret = ''; |
| 440 | 462 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -470,7 +492,9 @@ discard block |
||
| 470 | 492 | function makeup() |
| 471 | 493 | { |
| 472 | 494 | // text, comment, unknown |
| 473 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 495 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 496 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 497 | + } |
|
| 474 | 498 | |
| 475 | 499 | $ret = '<'.$this->tag; |
| 476 | 500 | $i = -1; |
@@ -480,14 +504,15 @@ discard block |
||
| 480 | 504 | ++$i; |
| 481 | 505 | |
| 482 | 506 | // skip removed attribute |
| 483 | - if ($val===null || $val===false) |
|
| 484 | - continue; |
|
| 507 | + if ($val===null || $val===false) { |
|
| 508 | + continue; |
|
| 509 | + } |
|
| 485 | 510 | |
| 486 | 511 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
| 487 | 512 | //no value attr: nowrap, checked selected... |
| 488 | - if ($val===true) |
|
| 489 | - $ret .= $key; |
|
| 490 | - else { |
|
| 513 | + if ($val===true) { |
|
| 514 | + $ret .= $key; |
|
| 515 | + } else { |
|
| 491 | 516 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
| 492 | 517 | { |
| 493 | 518 | case HDOM_QUOTE_DOUBLE: $quote = '"'; break; |
@@ -506,7 +531,9 @@ discard block |
||
| 506 | 531 | function find($selector, $idx=null, $lowercase=false) |
| 507 | 532 | { |
| 508 | 533 | $selectors = $this->parse_selector($selector); |
| 509 | - if (($count=count($selectors))===0) return array(); |
|
| 534 | + if (($count=count($selectors))===0) { |
|
| 535 | + return array(); |
|
| 536 | + } |
|
| 510 | 537 | $found_keys = array(); |
| 511 | 538 | |
| 512 | 539 | // find each selector |
@@ -514,8 +541,12 @@ discard block |
||
| 514 | 541 | { |
| 515 | 542 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
| 516 | 543 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
| 517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
| 518 | - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
|
| 544 | + if (($levle=count($selectors[$c]))===0) { |
|
| 545 | + return array(); |
|
| 546 | + } |
|
| 547 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
| 548 | + return array(); |
|
| 549 | + } |
|
| 519 | 550 | |
| 520 | 551 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
| 521 | 552 | |
@@ -545,12 +576,16 @@ discard block |
||
| 545 | 576 | ksort($found_keys); |
| 546 | 577 | |
| 547 | 578 | $found = array(); |
| 548 | - foreach ($found_keys as $k=>$v) |
|
| 549 | - $found[] = $this->dom->nodes[$k]; |
|
| 579 | + foreach ($found_keys as $k=>$v) { |
|
| 580 | + $found[] = $this->dom->nodes[$k]; |
|
| 581 | + } |
|
| 550 | 582 | |
| 551 | 583 | // return nth-element or array |
| 552 | - if (is_null($idx)) return $found; |
|
| 553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
| 584 | + if (is_null($idx)) { |
|
| 585 | + return $found; |
|
| 586 | + } else if ($idx<0) { |
|
| 587 | + $idx = count($found) + $idx; |
|
| 588 | + } |
|
| 554 | 589 | return (isset($found[$idx])) ? $found[$idx] : null; |
| 555 | 590 | } |
| 556 | 591 | |
@@ -595,8 +630,9 @@ discard block |
||
| 595 | 630 | $pass = true; |
| 596 | 631 | |
| 597 | 632 | if ($tag==='*' && !$key) { |
| 598 | - if (in_array($node, $this->children, true)) |
|
| 599 | - $ret[$i] = 1; |
|
| 633 | + if (in_array($node, $this->children, true)) { |
|
| 634 | + $ret[$i] = 1; |
|
| 635 | + } |
|
| 600 | 636 | continue; |
| 601 | 637 | } |
| 602 | 638 | |
@@ -605,9 +641,13 @@ discard block |
||
| 605 | 641 | // compare key |
| 606 | 642 | if ($pass && $key) { |
| 607 | 643 | if ($no_key) { |
| 608 | - if (isset($node->attr[$key])) $pass=false; |
|
| 644 | + if (isset($node->attr[$key])) { |
|
| 645 | + $pass=false; |
|
| 646 | + } |
|
| 609 | 647 | } else { |
| 610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
| 648 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
| 649 | + $pass=false; |
|
| 650 | + } |
|
| 611 | 651 | } |
| 612 | 652 | } |
| 613 | 653 | // compare value |
@@ -640,13 +680,19 @@ discard block |
||
| 640 | 680 | } else { |
| 641 | 681 | $check = $this->match($exp, $val, $k); |
| 642 | 682 | } |
| 643 | - if ($check) break; |
|
| 683 | + if ($check) { |
|
| 684 | + break; |
|
| 685 | + } |
|
| 644 | 686 | } |
| 645 | 687 | } |
| 646 | 688 | } |
| 647 | - if (!$check) $pass = false; |
|
| 689 | + if (!$check) { |
|
| 690 | + $pass = false; |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + if ($pass) { |
|
| 694 | + $ret[$i] = 1; |
|
| 648 | 695 | } |
| 649 | - if ($pass) $ret[$i] = 1; |
|
| 650 | 696 | unset($node); |
| 651 | 697 | } |
| 652 | 698 | // It's passed by reference so this is actually what this function returns. |
@@ -696,9 +742,13 @@ discard block |
||
| 696 | 742 | |
| 697 | 743 | foreach ($matches as $m) { |
| 698 | 744 | $m[0] = trim($m[0]); |
| 699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
| 745 | + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') { |
|
| 746 | + continue; |
|
| 747 | + } |
|
| 700 | 748 | // for browser generated xpath |
| 701 | - if ($m[1]==='tbody') continue; |
|
| 749 | + if ($m[1]==='tbody') { |
|
| 750 | + continue; |
|
| 751 | + } |
|
| 702 | 752 | |
| 703 | 753 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
| 704 | 754 | if (!empty($m[2])) {$key='id'; $val=$m[2];} |
@@ -718,8 +768,9 @@ discard block |
||
| 718 | 768 | $result = array(); |
| 719 | 769 | } |
| 720 | 770 | } |
| 721 | - if (count($result)>0) |
|
| 722 | - $selectors[] = $result; |
|
| 771 | + if (count($result)>0) { |
|
| 772 | + $selectors[] = $result; |
|
| 773 | + } |
|
| 723 | 774 | return $selectors; |
| 724 | 775 | } |
| 725 | 776 | |
@@ -748,7 +799,9 @@ discard block |
||
| 748 | 799 | { |
| 749 | 800 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
| 750 | 801 | case 'innertext': |
| 751 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; |
|
| 802 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 803 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
| 804 | + } |
|
| 752 | 805 | return $this->_[HDOM_INFO_INNER] = $value; |
| 753 | 806 | } |
| 754 | 807 | if (!isset($this->attr[$name])) |
@@ -772,8 +825,9 @@ discard block |
||
| 772 | 825 | } |
| 773 | 826 | |
| 774 | 827 | function __unset($name) { |
| 775 | - if (isset($this->attr[$name])) |
|
| 776 | - unset($this->attr[$name]); |
|
| 828 | + if (isset($this->attr[$name])) { |
|
| 829 | + unset($this->attr[$name]); |
|
| 830 | + } |
|
| 777 | 831 | } |
| 778 | 832 | |
| 779 | 833 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
@@ -800,8 +854,7 @@ discard block |
||
| 800 | 854 | if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) |
| 801 | 855 | { |
| 802 | 856 | $converted_text = $text; |
| 803 | - } |
|
| 804 | - else |
|
| 857 | + } else |
|
| 805 | 858 | { |
| 806 | 859 | $converted_text = iconv($sourceCharset, $targetCharset, $text); |
| 807 | 860 | } |
@@ -839,19 +892,31 @@ discard block |
||
| 839 | 892 | $c=ord($str[$i]); |
| 840 | 893 | if($c > 128) |
| 841 | 894 | { |
| 842 | - if(($c >= 254)) return false; |
|
| 843 | - elseif($c >= 252) $bits=6; |
|
| 844 | - elseif($c >= 248) $bits=5; |
|
| 845 | - elseif($c >= 240) $bits=4; |
|
| 846 | - elseif($c >= 224) $bits=3; |
|
| 847 | - elseif($c >= 192) $bits=2; |
|
| 848 | - else return false; |
|
| 849 | - if(($i+$bits) > $len) return false; |
|
| 895 | + if(($c >= 254)) { |
|
| 896 | + return false; |
|
| 897 | + } elseif($c >= 252) { |
|
| 898 | + $bits=6; |
|
| 899 | + } elseif($c >= 248) { |
|
| 900 | + $bits=5; |
|
| 901 | + } elseif($c >= 240) { |
|
| 902 | + $bits=4; |
|
| 903 | + } elseif($c >= 224) { |
|
| 904 | + $bits=3; |
|
| 905 | + } elseif($c >= 192) { |
|
| 906 | + $bits=2; |
|
| 907 | + } else { |
|
| 908 | + return false; |
|
| 909 | + } |
|
| 910 | + if(($i+$bits) > $len) { |
|
| 911 | + return false; |
|
| 912 | + } |
|
| 850 | 913 | while($bits > 1) |
| 851 | 914 | { |
| 852 | 915 | $i++; |
| 853 | 916 | $b=ord($str[$i]); |
| 854 | - if($b < 128 || $b > 191) return false; |
|
| 917 | + if($b < 128 || $b > 191) { |
|
| 918 | + return false; |
|
| 919 | + } |
|
| 855 | 920 | $bits--; |
| 856 | 921 | } |
| 857 | 922 | } |
@@ -1035,8 +1100,7 @@ discard block |
||
| 1035 | 1100 | if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
| 1036 | 1101 | { |
| 1037 | 1102 | $this->load_file($str); |
| 1038 | - } |
|
| 1039 | - else |
|
| 1103 | + } else |
|
| 1040 | 1104 | { |
| 1041 | 1105 | $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); |
| 1042 | 1106 | } |
@@ -1118,7 +1182,9 @@ discard block |
||
| 1118 | 1182 | function save($filepath='') |
| 1119 | 1183 | { |
| 1120 | 1184 | $ret = $this->root->innertext(); |
| 1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
| 1185 | + if ($filepath!=='') { |
|
| 1186 | + file_put_contents($filepath, $ret, LOCK_EX); |
|
| 1187 | + } |
|
| 1122 | 1188 | return $ret; |
| 1123 | 1189 | } |
| 1124 | 1190 | |
@@ -1134,7 +1200,10 @@ discard block |
||
| 1134 | 1200 | { |
| 1135 | 1201 | foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
| 1136 | 1202 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
| 1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
| 1203 | + if (isset($this->children)) { |
|
| 1204 | + foreach ($this->children as $n) {$n->clear(); |
|
| 1205 | + } |
|
| 1206 | + $n = null;} |
|
| 1138 | 1207 | if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
| 1139 | 1208 | if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
| 1140 | 1209 | unset($this->doc); |
@@ -1178,7 +1247,9 @@ discard block |
||
| 1178 | 1247 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
| 1179 | 1248 | $this->root->nodetype = HDOM_TYPE_ROOT; |
| 1180 | 1249 | $this->parent = $this->root; |
| 1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
| 1250 | + if ($this->size>0) { |
|
| 1251 | + $this->char = $this->doc[0]; |
|
| 1252 | + } |
|
| 1182 | 1253 | } |
| 1183 | 1254 | |
| 1184 | 1255 | // parse html content |
@@ -1232,8 +1303,7 @@ discard block |
||
| 1232 | 1303 | if ($success) |
| 1233 | 1304 | { |
| 1234 | 1305 | $charset = $matches[1]; |
| 1235 | - } |
|
| 1236 | - else |
|
| 1306 | + } else |
|
| 1237 | 1307 | { |
| 1238 | 1308 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
| 1239 | 1309 | if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
@@ -1296,8 +1366,9 @@ discard block |
||
| 1296 | 1366 | $tag = $this->copy_until_char('>'); |
| 1297 | 1367 | |
| 1298 | 1368 | // skip attributes in end tag |
| 1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
| 1300 | - $tag = substr($tag, 0, $pos); |
|
| 1369 | + if (($pos = strpos($tag, ' '))!==false) { |
|
| 1370 | + $tag = substr($tag, 0, $pos); |
|
| 1371 | + } |
|
| 1301 | 1372 | |
| 1302 | 1373 | $parent_lower = strtolower($this->parent->tag); |
| 1303 | 1374 | $tag_lower = strtolower($tag); |
@@ -1309,23 +1380,26 @@ discard block |
||
| 1309 | 1380 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1310 | 1381 | $org_parent = $this->parent; |
| 1311 | 1382 | |
| 1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
| 1313 | - $this->parent = $this->parent->parent; |
|
| 1383 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
| 1384 | + $this->parent = $this->parent->parent; |
|
| 1385 | + } |
|
| 1314 | 1386 | |
| 1315 | 1387 | if (strtolower($this->parent->tag)!==$tag_lower) { |
| 1316 | 1388 | $this->parent = $org_parent; // restore origonal parent |
| 1317 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
| 1389 | + if ($this->parent->parent) { |
|
| 1390 | + $this->parent = $this->parent->parent; |
|
| 1391 | + } |
|
| 1318 | 1392 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1319 | 1393 | return $this->as_text_node($tag); |
| 1320 | 1394 | } |
| 1321 | - } |
|
| 1322 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
| 1395 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
| 1323 | 1396 | { |
| 1324 | 1397 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1325 | 1398 | $org_parent = $this->parent; |
| 1326 | 1399 | |
| 1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
| 1328 | - $this->parent = $this->parent->parent; |
|
| 1400 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
| 1401 | + $this->parent = $this->parent->parent; |
|
| 1402 | + } |
|
| 1329 | 1403 | |
| 1330 | 1404 | if (strtolower($this->parent->tag)!==$tag_lower) |
| 1331 | 1405 | { |
@@ -1333,18 +1407,19 @@ discard block |
||
| 1333 | 1407 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1334 | 1408 | return $this->as_text_node($tag); |
| 1335 | 1409 | } |
| 1336 | - } |
|
| 1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
| 1410 | + } else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
| 1338 | 1411 | { |
| 1339 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1340 | 1413 | $this->parent = $this->parent->parent; |
| 1414 | + } else { |
|
| 1415 | + return $this->as_text_node($tag); |
|
| 1341 | 1416 | } |
| 1342 | - else |
|
| 1343 | - return $this->as_text_node($tag); |
|
| 1344 | 1417 | } |
| 1345 | 1418 | |
| 1346 | 1419 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1347 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
| 1420 | + if ($this->parent->parent) { |
|
| 1421 | + $this->parent = $this->parent->parent; |
|
| 1422 | + } |
|
| 1348 | 1423 | |
| 1349 | 1424 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1350 | 1425 | return true; |
@@ -1367,7 +1442,9 @@ discard block |
||
| 1367 | 1442 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
| 1368 | 1443 | $node->tag = 'unknown'; |
| 1369 | 1444 | } |
| 1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1445 | + if ($this->char==='>') { |
|
| 1446 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1447 | + } |
|
| 1371 | 1448 | $this->link_nodes($node, true); |
| 1372 | 1449 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1373 | 1450 | return true; |
@@ -1389,7 +1466,9 @@ discard block |
||
| 1389 | 1466 | return true; |
| 1390 | 1467 | } |
| 1391 | 1468 | |
| 1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1469 | + if ($this->char==='>') { |
|
| 1470 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1471 | + } |
|
| 1393 | 1472 | $this->link_nodes($node, false); |
| 1394 | 1473 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1395 | 1474 | return true; |
@@ -1455,22 +1534,26 @@ discard block |
||
| 1455 | 1534 | if ($name!=='/' && $name!=='') { |
| 1456 | 1535 | $space[1] = $this->copy_skip($this->token_blank); |
| 1457 | 1536 | $name = $this->restore_noise($name); |
| 1458 | - if ($this->lowercase) $name = strtolower($name); |
|
| 1537 | + if ($this->lowercase) { |
|
| 1538 | + $name = strtolower($name); |
|
| 1539 | + } |
|
| 1459 | 1540 | if ($this->char==='=') { |
| 1460 | 1541 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1461 | 1542 | $this->parse_attr($node, $name, $space); |
| 1462 | - } |
|
| 1463 | - else { |
|
| 1543 | + } else { |
|
| 1464 | 1544 | //no value attr: nowrap, checked selected... |
| 1465 | 1545 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
| 1466 | 1546 | $node->attr[$name] = true; |
| 1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
| 1547 | + if ($this->char!='>') { |
|
| 1548 | + $this->char = $this->doc[--$this->pos]; |
|
| 1549 | + } |
|
| 1550 | + // prev |
|
| 1468 | 1551 | } |
| 1469 | 1552 | $node->_[HDOM_INFO_SPACE][] = $space; |
| 1470 | 1553 | $space = array($this->copy_skip($this->token_blank), '', ''); |
| 1554 | + } else { |
|
| 1555 | + break; |
|
| 1471 | 1556 | } |
| 1472 | - else |
|
| 1473 | - break; |
|
| 1474 | 1557 | } while ($this->char!=='>' && $this->char!=='/'); |
| 1475 | 1558 | |
| 1476 | 1559 | $this->link_nodes($node, true); |
@@ -1481,11 +1564,12 @@ discard block |
||
| 1481 | 1564 | { |
| 1482 | 1565 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
| 1483 | 1566 | $node->_[HDOM_INFO_END] = 0; |
| 1484 | - } |
|
| 1485 | - else |
|
| 1567 | + } else |
|
| 1486 | 1568 | { |
| 1487 | 1569 | // reset parent |
| 1488 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
|
| 1570 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
| 1571 | + $this->parent = $node; |
|
| 1572 | + } |
|
| 1489 | 1573 | } |
| 1490 | 1574 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1491 | 1575 | |
@@ -1571,7 +1655,9 @@ discard block |
||
| 1571 | 1655 | $len = strspn($this->doc, $chars, $pos); |
| 1572 | 1656 | $this->pos += $len; |
| 1573 | 1657 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1574 | - if ($len===0) return ''; |
|
| 1658 | + if ($len===0) { |
|
| 1659 | + return ''; |
|
| 1660 | + } |
|
| 1575 | 1661 | return substr($this->doc, $pos, $len); |
| 1576 | 1662 | } |
| 1577 | 1663 | |
@@ -1586,7 +1672,9 @@ discard block |
||
| 1586 | 1672 | |
| 1587 | 1673 | protected function copy_until_char($char) |
| 1588 | 1674 | { |
| 1589 | - if ($this->char===null) return ''; |
|
| 1675 | + if ($this->char===null) { |
|
| 1676 | + return ''; |
|
| 1677 | + } |
|
| 1590 | 1678 | |
| 1591 | 1679 | if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
| 1592 | 1680 | $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
@@ -1595,7 +1683,9 @@ discard block |
||
| 1595 | 1683 | return $ret; |
| 1596 | 1684 | } |
| 1597 | 1685 | |
| 1598 | - if ($pos===$this->pos) return ''; |
|
| 1686 | + if ($pos===$this->pos) { |
|
| 1687 | + return ''; |
|
| 1688 | + } |
|
| 1599 | 1689 | $pos_old = $this->pos; |
| 1600 | 1690 | $this->char = $this->doc[$pos]; |
| 1601 | 1691 | $this->pos = $pos; |
@@ -1604,7 +1694,9 @@ discard block |
||
| 1604 | 1694 | |
| 1605 | 1695 | protected function copy_until_char_escape($char) |
| 1606 | 1696 | { |
| 1607 | - if ($this->char===null) return ''; |
|
| 1697 | + if ($this->char===null) { |
|
| 1698 | + return ''; |
|
| 1699 | + } |
|
| 1608 | 1700 | |
| 1609 | 1701 | $start = $this->pos; |
| 1610 | 1702 | while (1) |
@@ -1617,7 +1709,9 @@ discard block |
||
| 1617 | 1709 | return $ret; |
| 1618 | 1710 | } |
| 1619 | 1711 | |
| 1620 | - if ($pos===$this->pos) return ''; |
|
| 1712 | + if ($pos===$this->pos) { |
|
| 1713 | + return ''; |
|
| 1714 | + } |
|
| 1621 | 1715 | |
| 1622 | 1716 | if ($this->doc[$pos-1]==='\\') { |
| 1623 | 1717 | $start = $pos+1; |
@@ -1674,14 +1768,12 @@ discard block |
||
| 1674 | 1768 | if (isset($this->noise[$key])) |
| 1675 | 1769 | { |
| 1676 | 1770 | $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
| 1677 | - } |
|
| 1678 | - else |
|
| 1771 | + } else |
|
| 1679 | 1772 | { |
| 1680 | 1773 | // do this to prevent an infinite loop. |
| 1681 | 1774 | $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
| 1682 | 1775 | } |
| 1683 | - } |
|
| 1684 | - else |
|
| 1776 | + } else |
|
| 1685 | 1777 | { |
| 1686 | 1778 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
| 1687 | 1779 | $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
@@ -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,14 +7,14 @@ discard block |
||
| 7 | 7 | public $latest_schema = 23; |
| 8 | 8 | |
| 9 | 9 | public function __construct($dbc = null,$dbname = null) { |
| 10 | - global $globalDBdriver; |
|
| 11 | - if ($dbc === null) { |
|
| 10 | + global $globalDBdriver; |
|
| 11 | + if ($dbc === null) { |
|
| 12 | 12 | if ($this->db === null && $dbname === null) { |
| 13 | - $this->createDBConnection(); |
|
| 13 | + $this->createDBConnection(); |
|
| 14 | 14 | } else { |
| 15 | - $this->createDBConnection($dbname); |
|
| 15 | + $this->createDBConnection($dbname); |
|
| 16 | 16 | } |
| 17 | - } elseif ($dbname === null || $dbname === 'default') { |
|
| 17 | + } elseif ($dbname === null || $dbname === 'default') { |
|
| 18 | 18 | $this->db = $dbc; |
| 19 | 19 | if ($this->connectionExists() === false) { |
| 20 | 20 | /* |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | $this->createDBConnection(); |
| 26 | 26 | } |
| 27 | - } else { |
|
| 27 | + } else { |
|
| 28 | 28 | //$this->connectionExists(); |
| 29 | 29 | $this->dbs[$dbname] = $dbc; |
| 30 | - } |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * Creates the database connection |
|
| 36 | - * |
|
| 37 | - * @return Boolean of the database connection |
|
| 38 | - * |
|
| 39 | - */ |
|
| 35 | + * Creates the database connection |
|
| 36 | + * |
|
| 37 | + * @return Boolean of the database connection |
|
| 38 | + * |
|
| 39 | + */ |
|
| 40 | 40 | |
| 41 | 41 | public function createDBConnection($DBname = null) |
| 42 | 42 | { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | if($results->rowCount()>0) { |
| 121 | - return true; |
|
| 121 | + return true; |
|
| 122 | 122 | } |
| 123 | 123 | else return false; |
| 124 | 124 | } |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | $sum = $sum->fetchColumn(0); |
| 136 | 136 | } else $sum = 0; |
| 137 | 137 | if (intval($sum) !== 2) { |
| 138 | - return false; |
|
| 138 | + return false; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | } catch(PDOException $e) { |
| 142 | 142 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
| 143 | - throw $e; |
|
| 144 | - } |
|
| 145 | - //echo 'error ! '.$e->getMessage(); |
|
| 143 | + throw $e; |
|
| 144 | + } |
|
| 145 | + //echo 'error ! '.$e->getMessage(); |
|
| 146 | 146 | return false; |
| 147 | 147 | } |
| 148 | 148 | return true; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | if($results->rowCount()>0) { |
| 169 | - return true; |
|
| 169 | + return true; |
|
| 170 | 170 | } |
| 171 | 171 | else return false; |
| 172 | 172 | } |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | $version = 0; |
| 221 | 221 | if ($this->tableExists('aircraft')) { |
| 222 | 222 | if (!$this->tableExists('config')) { |
| 223 | - $version = '1'; |
|
| 224 | - return $version; |
|
| 223 | + $version = '1'; |
|
| 224 | + return $version; |
|
| 225 | 225 | } else { |
| 226 | 226 | $Connection = new Connection(); |
| 227 | 227 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | * @return Boolean if latest version or not |
| 243 | 243 | */ |
| 244 | 244 | public function latest() { |
| 245 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 246 | - else return false; |
|
| 245 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 246 | + else return false; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | } |
@@ -1,12 +1,12 @@ 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) { |
|
| 9 | + public function __construct($dbc = null, $dbname = null) { |
|
| 10 | 10 | global $globalDBdriver; |
| 11 | 11 | if ($dbc === null) { |
| 12 | 12 | if ($this->db === null && $dbname === null) { |
@@ -65,32 +65,32 @@ discard block |
||
| 65 | 65 | while (true) { |
| 66 | 66 | try { |
| 67 | 67 | if ($globalDBSdriver == 'mysql') { |
| 68 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 68 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 69 | 69 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 70 | 70 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 71 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 72 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 73 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 74 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 75 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 71 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 72 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
| 73 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 74 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 75 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 76 | 76 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 77 | 77 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 78 | 78 | // FIXME : Workaround against "ONLY_FULL_GROUP_BY" mode |
| 79 | 79 | //$this->dbs[$DBname]->exec('SET sql_mode = "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY"'); |
| 80 | 80 | $this->dbs[$DBname]->exec('SET sql_mode = "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'); |
| 81 | 81 | } else { |
| 82 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 82 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 83 | 83 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 84 | 84 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 85 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 86 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 87 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 88 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 89 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 85 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 86 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
| 87 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 88 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 89 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 90 | 90 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | - } catch(PDOException $e) { |
|
| 93 | + } catch (PDOException $e) { |
|
| 94 | 94 | $i++; |
| 95 | 95 | if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
| 96 | 96 | //exit; |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | try { |
| 115 | 115 | //$Connection = new Connection(); |
| 116 | 116 | $results = $this->db->query($query); |
| 117 | - } catch(PDOException $e) { |
|
| 117 | + } catch (PDOException $e) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | - if($results->rowCount()>0) { |
|
| 120 | + if ($results->rowCount() > 0) { |
|
| 121 | 121 | return true; |
| 122 | 122 | } |
| 123 | 123 | else return false; |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - } catch(PDOException $e) { |
|
| 142 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 141 | + } catch (PDOException $e) { |
|
| 142 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 143 | 143 | throw $e; |
| 144 | 144 | } |
| 145 | 145 | //echo 'error ! '.$e->getMessage(); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | /* |
| 152 | 152 | * Check if index exist |
| 153 | 153 | */ |
| 154 | - public function indexExists($table,$index) |
|
| 154 | + public function indexExists($table, $index) |
|
| 155 | 155 | { |
| 156 | 156 | global $globalDBdriver, $globalDBname; |
| 157 | 157 | if ($globalDBdriver == 'mysql') { |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | try { |
| 163 | 163 | //$Connection = new Connection(); |
| 164 | 164 | $results = $this->db->query($query); |
| 165 | - } catch(PDOException $e) { |
|
| 165 | + } catch (PDOException $e) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | - if($results->rowCount()>0) { |
|
| 168 | + if ($results->rowCount() > 0) { |
|
| 169 | 169 | return true; |
| 170 | 170 | } |
| 171 | 171 | else return false; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 181 | 181 | try { |
| 182 | 182 | $results = $this->db->query($query); |
| 183 | - } catch(PDOException $e) { |
|
| 183 | + } catch (PDOException $e) { |
|
| 184 | 184 | return "error : ".$e->getMessage()."\n"; |
| 185 | 185 | } |
| 186 | 186 | $columns = array(); |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | * Check if a column name exist in a table |
| 197 | 197 | * @return Boolean column exist or not |
| 198 | 198 | */ |
| 199 | - public function checkColumnName($table,$name) |
|
| 199 | + public function checkColumnName($table, $name) |
|
| 200 | 200 | { |
| 201 | 201 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 202 | 202 | try { |
| 203 | 203 | $results = $this->db->query($query); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | return "error : ".$e->getMessage()."\n"; |
| 206 | 206 | } |
| 207 | 207 | $colcnt = $results->columnCount(); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | try { |
| 229 | 229 | $sth = $this->db->prepare($query); |
| 230 | 230 | $sth->execute(); |
| 231 | - } catch(PDOException $e) { |
|
| 231 | + } catch (PDOException $e) { |
|
| 232 | 232 | return "error : ".$e->getMessage()."\n"; |
| 233 | 233 | } |
| 234 | 234 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -48,19 +48,27 @@ discard block |
||
| 48 | 48 | $globalDBSname = $globalDBname; |
| 49 | 49 | $globalDBSuser = $globalDBuser; |
| 50 | 50 | $globalDBSpass = $globalDBpass; |
| 51 | - if (!isset($globalDBport) || $globalDBport === NULL) $globalDBSport = 3306; |
|
| 52 | - else $globalDBSport = $globalDBport; |
|
| 51 | + if (!isset($globalDBport) || $globalDBport === NULL) { |
|
| 52 | + $globalDBSport = 3306; |
|
| 53 | + } else { |
|
| 54 | + $globalDBSport = $globalDBport; |
|
| 55 | + } |
|
| 53 | 56 | } else { |
| 54 | 57 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
| 55 | 58 | $globalDBShost = $globalDB[$DBname]['host']; |
| 56 | 59 | $globalDBSname = $globalDB[$DBname]['name']; |
| 57 | 60 | $globalDBSuser = $globalDB[$DBname]['user']; |
| 58 | 61 | $globalDBSpass = $globalDB[$DBname]['pass']; |
| 59 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
| 60 | - else $globalDBSport = 3306; |
|
| 62 | + if (isset($globalDB[$DBname]['port'])) { |
|
| 63 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
| 64 | + } else { |
|
| 65 | + $globalDBSport = 3306; |
|
| 66 | + } |
|
| 61 | 67 | } |
| 62 | 68 | // Set number of try to connect to DB |
| 63 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
| 69 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
| 70 | + $globalDBretry = 5; |
|
| 71 | + } |
|
| 64 | 72 | $i = 0; |
| 65 | 73 | while (true) { |
| 66 | 74 | try { |
@@ -69,10 +77,16 @@ discard block |
||
| 69 | 77 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 70 | 78 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 71 | 79 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 72 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 73 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 74 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 75 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 80 | + if (!isset($globalDBTimeOut)) { |
|
| 81 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 82 | + } else { |
|
| 83 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 84 | + } |
|
| 85 | + if (!isset($globalDBPersistent)) { |
|
| 86 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 87 | + } else { |
|
| 88 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 89 | + } |
|
| 76 | 90 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 77 | 91 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 78 | 92 | // FIXME : Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -83,22 +97,34 @@ discard block |
||
| 83 | 97 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 84 | 98 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 85 | 99 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 86 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 87 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 88 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 89 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 100 | + if (!isset($globalDBTimeOut)) { |
|
| 101 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 102 | + } else { |
|
| 103 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 104 | + } |
|
| 105 | + if (!isset($globalDBPersistent)) { |
|
| 106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 107 | + } else { |
|
| 108 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 109 | + } |
|
| 90 | 110 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 91 | 111 | } |
| 92 | 112 | break; |
| 93 | 113 | } catch(PDOException $e) { |
| 94 | 114 | $i++; |
| 95 | - if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
|
| 115 | + if (isset($globalDebug) && $globalDebug) { |
|
| 116 | + echo $e->getMessage()."\n"; |
|
| 117 | + } |
|
| 96 | 118 | //exit; |
| 97 | - if ($i > $globalDBretry) return false; |
|
| 119 | + if ($i > $globalDBretry) { |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 98 | 122 | //return false; |
| 99 | 123 | } |
| 100 | 124 | } |
| 101 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
| 125 | + if ($DBname === 'default') { |
|
| 126 | + $this->db = $this->dbs['default']; |
|
| 127 | + } |
|
| 102 | 128 | return true; |
| 103 | 129 | } |
| 104 | 130 | |
@@ -110,7 +136,9 @@ discard block |
||
| 110 | 136 | } elseif ($globalDBdriver == 'pgsql') { |
| 111 | 137 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
| 112 | 138 | } |
| 113 | - if ($this->db == NULL) return false; |
|
| 139 | + if ($this->db == NULL) { |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 114 | 142 | try { |
| 115 | 143 | //$Connection = new Connection(); |
| 116 | 144 | $results = $this->db->query($query); |
@@ -119,21 +147,28 @@ discard block |
||
| 119 | 147 | } |
| 120 | 148 | if($results->rowCount()>0) { |
| 121 | 149 | return true; |
| 150 | + } else { |
|
| 151 | + return false; |
|
| 122 | 152 | } |
| 123 | - else return false; |
|
| 124 | 153 | } |
| 125 | 154 | |
| 126 | 155 | public function connectionExists() |
| 127 | 156 | { |
| 128 | 157 | global $globalDBdriver, $globalDBCheckConnection; |
| 129 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
| 158 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 130 | 161 | $query = "SELECT 1 + 1"; |
| 131 | - if ($this->db == NULL) return false; |
|
| 162 | + if ($this->db == NULL) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 132 | 165 | try { |
| 133 | 166 | $sum = @$this->db->query($query); |
| 134 | 167 | if ($sum instanceof \PDOStatement) { |
| 135 | 168 | $sum = $sum->fetchColumn(0); |
| 136 | - } else $sum = 0; |
|
| 169 | + } else { |
|
| 170 | + $sum = 0; |
|
| 171 | + } |
|
| 137 | 172 | if (intval($sum) !== 2) { |
| 138 | 173 | return false; |
| 139 | 174 | } |
@@ -167,8 +202,9 @@ discard block |
||
| 167 | 202 | } |
| 168 | 203 | if($results->rowCount()>0) { |
| 169 | 204 | return true; |
| 205 | + } else { |
|
| 206 | + return false; |
|
| 170 | 207 | } |
| 171 | - else return false; |
|
| 172 | 208 | } |
| 173 | 209 | |
| 174 | 210 | /* |
@@ -207,7 +243,9 @@ discard block |
||
| 207 | 243 | $colcnt = $results->columnCount(); |
| 208 | 244 | for ($i = 0; $i < $colcnt; $i++) { |
| 209 | 245 | $col = $results->getColumnMeta($i); |
| 210 | - if ($name == $col['name']) return true; |
|
| 246 | + if ($name == $col['name']) { |
|
| 247 | + return true; |
|
| 248 | + } |
|
| 211 | 249 | } |
| 212 | 250 | return false; |
| 213 | 251 | } |
@@ -234,7 +272,9 @@ discard block |
||
| 234 | 272 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 235 | 273 | return $result['value']; |
| 236 | 274 | } |
| 237 | - } else return $version; |
|
| 275 | + } else { |
|
| 276 | + return $version; |
|
| 277 | + } |
|
| 238 | 278 | } |
| 239 | 279 | |
| 240 | 280 | /* |
@@ -242,8 +282,11 @@ discard block |
||
| 242 | 282 | * @return Boolean if latest version or not |
| 243 | 283 | */ |
| 244 | 284 | public function latest() { |
| 245 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 246 | - else return false; |
|
| 285 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
| 286 | + return true; |
|
| 287 | + } else { |
|
| 288 | + return false; |
|
| 289 | + } |
|
| 247 | 290 | } |
| 248 | 291 | |
| 249 | 292 | } |
@@ -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 | |