@@ -25,7 +25,9 @@ discard block |
||
| 25 | 25 | $airspace = $result[0]; |
| 26 | 26 | date_default_timezone_set('UTC'); |
| 27 | 27 | print '<div class="top">'; |
| 28 | -if (isset($airspace['name'])) $airspace['title'] = $airspace['name']; |
|
| 28 | +if (isset($airspace['name'])) { |
|
| 29 | + $airspace['title'] = $airspace['name']; |
|
| 30 | +} |
|
| 29 | 31 | print '<div class="right"><div class="callsign-details"><div class="callsign">'.$airspace['title'].'</a></div>'; |
| 30 | 32 | print '</div>'; |
| 31 | 33 | print '<div class="details">'; |
@@ -44,13 +46,17 @@ discard block |
||
| 44 | 46 | print '</div>'; |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | -if (isset($airspace['ceiling'])) $airspace['tops'] = $airspace['ceiling']; |
|
| 49 | +if (isset($airspace['ceiling'])) { |
|
| 50 | + $airspace['tops'] = $airspace['ceiling']; |
|
| 51 | +} |
|
| 48 | 52 | print '<div>'; |
| 49 | 53 | print '<span>'._("Tops").'</span>'; |
| 50 | 54 | print $airspace['tops']; |
| 51 | 55 | print '</div>'; |
| 52 | 56 | |
| 53 | -if (isset($airspace['floor'])) $airspace['base'] = $airspace['floor']; |
|
| 57 | +if (isset($airspace['floor'])) { |
|
| 58 | + $airspace['base'] = $airspace['floor']; |
|
| 59 | +} |
|
| 54 | 60 | print '<div>'; |
| 55 | 61 | print '<span>'._("Base").'</span>'; |
| 56 | 62 | print $airspace['base']; |
@@ -67,12 +67,22 @@ |
||
| 67 | 67 | } else { |
| 68 | 68 | $geom = geoPHP::load(stream_get_contents($row['wkb'])); |
| 69 | 69 | } |
| 70 | - if (isset($properties['type'])) $properties['type'] = trim($properties['type']); |
|
| 71 | - elseif (isset($properties['class'])) $properties['type'] = trim($properties['class']); |
|
| 72 | - if (isset($properties['ogr_fid'])) $properties['id'] = $properties['ogr_fid']; |
|
| 73 | - elseif (isset($properties['ogc_fid'])) $properties['id'] = $properties['ogc_fid']; |
|
| 74 | - if (isset($properties['ceiling'])) $properties['tops'] = $properties['ceiling']; |
|
| 75 | - if (isset($properties['floor'])) $properties['base'] = $properties['floor']; |
|
| 70 | + if (isset($properties['type'])) { |
|
| 71 | + $properties['type'] = trim($properties['type']); |
|
| 72 | + } elseif (isset($properties['class'])) { |
|
| 73 | + $properties['type'] = trim($properties['class']); |
|
| 74 | + } |
|
| 75 | + if (isset($properties['ogr_fid'])) { |
|
| 76 | + $properties['id'] = $properties['ogr_fid']; |
|
| 77 | + } elseif (isset($properties['ogc_fid'])) { |
|
| 78 | + $properties['id'] = $properties['ogc_fid']; |
|
| 79 | + } |
|
| 80 | + if (isset($properties['ceiling'])) { |
|
| 81 | + $properties['tops'] = $properties['ceiling']; |
|
| 82 | + } |
|
| 83 | + if (isset($properties['floor'])) { |
|
| 84 | + $properties['base'] = $properties['floor']; |
|
| 85 | + } |
|
| 76 | 86 | if (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['tops']),$matches)) { |
| 77 | 87 | $properties['upper_limit'] = round($matches['alt']*100*0.38048); |
| 78 | 88 | } elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/',strtoupper($properties['tops']),$matches)) { |
@@ -9,7 +9,9 @@ discard block |
||
| 9 | 9 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
| 10 | 10 | exec("ps ux", $output, $result); |
| 11 | 11 | $j = 0; |
| 12 | - foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 12 | + foreach ($output as $line) { |
|
| 13 | + if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 14 | + } |
|
| 13 | 15 | if ($j > 1) { |
| 14 | 16 | echo "Script is already runnning..."; |
| 15 | 17 | die(); |
@@ -28,8 +30,10 @@ discard block |
||
| 28 | 30 | $update_db->update_notam(); |
| 29 | 31 | } |
| 30 | 32 | $update_db->insert_last_notam_update(); |
| 31 | - } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n"; |
|
| 32 | -} |
|
| 33 | + } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) { |
|
| 34 | + echo "NOTAM are only updated once a day.\n"; |
|
| 35 | + } |
|
| 36 | + } |
|
| 33 | 37 | |
| 34 | 38 | if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 35 | 39 | $update_db->update_all(); |
@@ -37,7 +41,9 @@ discard block |
||
| 37 | 41 | // $Spotter = new Spotter(); |
| 38 | 42 | // $Spotter->updateFieldsFromOtherTables(); |
| 39 | 43 | $update_db->insert_last_update(); |
| 40 | -} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
| 44 | +} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) { |
|
| 45 | + echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
| 46 | +} |
|
| 41 | 47 | |
| 42 | 48 | |
| 43 | 49 | if (isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) { |
@@ -47,22 +53,28 @@ discard block |
||
| 47 | 53 | if ($METAR->check_last_update()) { |
| 48 | 54 | $METAR->addMETARCycle(); |
| 49 | 55 | $METAR->insert_last_update(); |
| 50 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
| 51 | -} |
|
| 56 | + } else { |
|
| 57 | + echo "METAR are only updated every 30 minutes.\n"; |
|
| 58 | + } |
|
| 59 | + } |
|
| 52 | 60 | |
| 53 | 61 | |
| 54 | 62 | if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 55 | 63 | echo "Updating private aircraft's owners..."; |
| 56 | 64 | $update_db->update_owner(); |
| 57 | 65 | $update_db->insert_last_owner_update(); |
| 58 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
| 66 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 67 | + echo "Owner are only updated every 15 days.\n"; |
|
| 68 | +} |
|
| 59 | 69 | |
| 60 | 70 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 61 | 71 | echo "Updating schedules..."; |
| 62 | 72 | $update_db->update_oneworld(); |
| 63 | 73 | $update_db->update_skyteam(); |
| 64 | 74 | $update_db->insert_last_schedules_update(); |
| 65 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
| 75 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 76 | + echo "Schedules are only updated every 15 days.\n"; |
|
| 77 | +} |
|
| 66 | 78 | |
| 67 | 79 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
| 68 | 80 | echo "Updating statistics and archive old data..."; |
@@ -14,7 +14,9 @@ discard block |
||
| 14 | 14 | //foreach ($lines as $line) |
| 15 | 15 | while (($line = fgets($handle,4096)) !== false) |
| 16 | 16 | { |
| 17 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
| 17 | + if (substr($line,0,2) == '--' || $line == '') { |
|
| 18 | + continue; |
|
| 19 | + } |
|
| 18 | 20 | $templine .= $line; |
| 19 | 21 | if (substr(trim($line), -1,1) == ';') |
| 20 | 22 | { |
@@ -40,7 +42,9 @@ discard block |
||
| 40 | 42 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
| 41 | 43 | while(false !== ($filename = readdir($dh))) |
| 42 | 44 | { |
| 43 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
| 45 | + if (preg_match('/\.sql$/',$filename)) { |
|
| 46 | + $error .= create_db::import_file($directory.$filename); |
|
| 47 | + } |
|
| 44 | 48 | } |
| 45 | 49 | return $error; |
| 46 | 50 | } |
@@ -56,13 +60,17 @@ discard block |
||
| 56 | 60 | // Dirty hack |
| 57 | 61 | if ($host != 'localhost' && $host != '127.0.0.1') { |
| 58 | 62 | $grantright = $_SERVER['SERVER_ADDR']; |
| 59 | - } else $grantright = 'localhost'; |
|
| 63 | + } else { |
|
| 64 | + $grantright = 'localhost'; |
|
| 65 | + } |
|
| 60 | 66 | try { |
| 61 | 67 | $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |
| 62 | 68 | $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 63 | 69 | if ($db_type == 'mysql') { |
| 64 | 70 | $dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
| 65 | - if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
| 71 | + if ($grantright == 'localhost') { |
|
| 72 | + $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
| 73 | + } |
|
| 66 | 74 | } else if ($db_type == 'pgsql') { |
| 67 | 75 | $dbh->exec("CREATE DATABASE ".$db.";"); |
| 68 | 76 | $dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."'; |
@@ -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 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
| 27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
| 28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 31 | $buffer_size = 4096; // read 4kb at a time |
| 30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 32 | + if ($out_file_name == '') { |
|
| 33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 34 | + } |
|
| 31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 35 | - else { |
|
| 37 | + if (function_exists('gzopen')) { |
|
| 38 | + $file = gzopen($in_file,'rb'); |
|
| 39 | + } elseif (function_exists('gzopen64')) { |
|
| 40 | + $file = gzopen64($in_file,'rb'); |
|
| 41 | + } else { |
|
| 36 | 42 | echo 'gzopen not available'; |
| 37 | 43 | die; |
| 38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
| 53 | 59 | if ($res === TRUE) { |
| 54 | 60 | $zip->extractTo($path); |
| 55 | 61 | $zip->close(); |
| 56 | - } else return false; |
|
| 57 | - } else return false; |
|
| 62 | + } else { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | + } else { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 58 | 68 | } |
| 59 | 69 | |
| 60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
| 69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 70 | 80 | global $globalDebug, $globalTransaction; |
| 71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
| 72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 82 | + if ($globalDebug) { |
|
| 83 | + echo " - Delete previous routes from DB -"; |
|
| 84 | + } |
|
| 73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 74 | 86 | $Connection = new Connection(); |
| 75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
| 80 | 92 | return "error : ".$e->getMessage(); |
| 81 | 93 | } |
| 82 | 94 | |
| 83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 95 | + if ($globalDebug) { |
|
| 96 | + echo " - Add routes to DB -"; |
|
| 97 | + } |
|
| 84 | 98 | update_db::connect_sqlite($database_file); |
| 85 | 99 | //$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'; |
| 86 | 100 | $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"; |
@@ -95,15 +109,21 @@ discard block |
||
| 95 | 109 | $Connection = new Connection(); |
| 96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
| 97 | 111 | try { |
| 98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 112 | + if ($globalTransaction) { |
|
| 113 | + $Connection->db->beginTransaction(); |
|
| 114 | + } |
|
| 99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 116 | //$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); |
| 101 | 117 | $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); |
| 102 | 118 | $sth_dest->execute($query_dest_values); |
| 103 | 119 | } |
| 104 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 120 | + if ($globalTransaction) { |
|
| 121 | + $Connection->db->commit(); |
|
| 122 | + } |
|
| 105 | 123 | } catch(PDOException $e) { |
| 106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 124 | + if ($globalTransaction) { |
|
| 125 | + $Connection->db->rollBack(); |
|
| 126 | + } |
|
| 107 | 127 | return "error : ".$e->getMessage(); |
| 108 | 128 | } |
| 109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
| 111 | 131 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 132 | global $globalDebug, $globalTransaction; |
| 113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
| 114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 134 | + if ($globalDebug) { |
|
| 135 | + echo " - Delete previous routes from DB -"; |
|
| 136 | + } |
|
| 115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 116 | 138 | $Connection = new Connection(); |
| 117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
| 122 | 144 | return "error : ".$e->getMessage(); |
| 123 | 145 | } |
| 124 | 146 | |
| 125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 147 | + if ($globalDebug) { |
|
| 148 | + echo " - Add routes to DB -"; |
|
| 149 | + } |
|
| 126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 151 | $Spotter = new Spotter(); |
| 128 | 152 | if ($fh = fopen($database_file,"r")) { |
| 129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 154 | $Connection = new Connection(); |
| 131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 156 | + if ($globalTransaction) { |
|
| 157 | + $Connection->db->beginTransaction(); |
|
| 158 | + } |
|
| 133 | 159 | while (!feof($fh)) { |
| 134 | 160 | $line = fgetcsv($fh,9999,','); |
| 135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
| 138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 139 | 165 | $sth_dest->execute($query_dest_values); |
| 140 | 166 | } catch(PDOException $e) { |
| 141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 167 | + if ($globalTransaction) { |
|
| 168 | + $Connection->db->rollBack(); |
|
| 169 | + } |
|
| 142 | 170 | return "error : ".$e->getMessage(); |
| 143 | 171 | } |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 175 | + if ($globalTransaction) { |
|
| 176 | + $Connection->db->commit(); |
|
| 177 | + } |
|
| 148 | 178 | } |
| 149 | 179 | return ''; |
| 150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
| 152 | 182 | public static function retrieve_route_skyteam($database_file) { |
| 153 | 183 | global $globalDebug, $globalTransaction; |
| 154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
| 155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 185 | + if ($globalDebug) { |
|
| 186 | + echo " - Delete previous routes from DB -"; |
|
| 187 | + } |
|
| 156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 157 | 189 | $Connection = new Connection(); |
| 158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
| 163 | 195 | return "error : ".$e->getMessage(); |
| 164 | 196 | } |
| 165 | 197 | |
| 166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 198 | + if ($globalDebug) { |
|
| 199 | + echo " - Add routes to DB -"; |
|
| 200 | + } |
|
| 167 | 201 | |
| 168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
| 172 | 206 | $Connection = new Connection(); |
| 173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 208 | try { |
| 175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 209 | + if ($globalTransaction) { |
|
| 210 | + $Connection->db->beginTransaction(); |
|
| 211 | + } |
|
| 176 | 212 | while (!feof($fh)) { |
| 177 | 213 | $line = fgetcsv($fh,9999,','); |
| 178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
| 183 | 219 | //} |
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 222 | + if ($globalTransaction) { |
|
| 223 | + $Connection->db->commit(); |
|
| 224 | + } |
|
| 187 | 225 | } catch(PDOException $e) { |
| 188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 226 | + if ($globalTransaction) { |
|
| 227 | + $Connection->db->rollBack(); |
|
| 228 | + } |
|
| 189 | 229 | return "error : ".$e->getMessage(); |
| 190 | 230 | } |
| 191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
| 228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
| 229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 230 | 270 | try { |
| 231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 271 | + if ($globalTransaction) { |
|
| 272 | + $Connection->db->beginTransaction(); |
|
| 273 | + } |
|
| 232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 233 | 275 | //$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']); |
| 234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 235 | - else $type = null; |
|
| 276 | + if ($values['UserString4'] == 'M') { |
|
| 277 | + $type = 'military'; |
|
| 278 | + } else { |
|
| 279 | + $type = null; |
|
| 280 | + } |
|
| 236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 237 | 282 | $sth_dest->execute($query_dest_values); |
| 238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
| 240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 286 | } |
| 242 | 287 | } |
| 243 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 288 | + if ($globalTransaction) { |
|
| 289 | + $Connection->db->commit(); |
|
| 290 | + } |
|
| 244 | 291 | } catch(PDOException $e) { |
| 245 | 292 | return "error : ".$e->getMessage(); |
| 246 | 293 | } |
@@ -276,7 +323,9 @@ discard block |
||
| 276 | 323 | $Connection = new Connection(); |
| 277 | 324 | $sth_dest = $Connection->db->prepare($query_dest); |
| 278 | 325 | try { |
| 279 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 326 | + if ($globalTransaction) { |
|
| 327 | + $Connection->db->beginTransaction(); |
|
| 328 | + } |
|
| 280 | 329 | while (!feof($fh)) { |
| 281 | 330 | $values = array(); |
| 282 | 331 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -287,7 +336,9 @@ discard block |
||
| 287 | 336 | // Check if we can find ICAO, else set it to GLID |
| 288 | 337 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 289 | 338 | $search_more = ''; |
| 290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 339 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 340 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + } |
|
| 291 | 342 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 292 | 343 | $sth_search = $Connection->db->prepare($query_search); |
| 293 | 344 | try { |
@@ -300,7 +351,9 @@ discard block |
||
| 300 | 351 | } catch(PDOException $e) { |
| 301 | 352 | return "error : ".$e->getMessage(); |
| 302 | 353 | } |
| 303 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 354 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 355 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + } |
|
| 304 | 357 | // Add data to db |
| 305 | 358 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 359 | //$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']); |
@@ -309,7 +362,9 @@ discard block |
||
| 309 | 362 | $sth_dest->execute($query_dest_values); |
| 310 | 363 | } |
| 311 | 364 | } |
| 312 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 365 | + if ($globalTransaction) { |
|
| 366 | + $Connection->db->commit(); |
|
| 367 | + } |
|
| 313 | 368 | } catch(PDOException $e) { |
| 314 | 369 | return "error : ".$e->getMessage(); |
| 315 | 370 | } |
@@ -345,7 +400,9 @@ discard block |
||
| 345 | 400 | $Connection = new Connection(); |
| 346 | 401 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 402 | try { |
| 348 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 403 | + if ($globalTransaction) { |
|
| 404 | + $Connection->db->beginTransaction(); |
|
| 405 | + } |
|
| 349 | 406 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 350 | 407 | while (!feof($fh)) { |
| 351 | 408 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -358,13 +415,17 @@ discard block |
||
| 358 | 415 | // Check if we can find ICAO, else set it to GLID |
| 359 | 416 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 360 | 417 | $search_more = ''; |
| 361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 418 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 419 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 420 | + } |
|
| 362 | 421 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 363 | 422 | $sth_search = $Connection->db->prepare($query_search); |
| 364 | 423 | try { |
| 365 | 424 | $sth_search->execute(); |
| 366 | 425 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 426 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 427 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 428 | + } |
|
| 368 | 429 | } catch(PDOException $e) { |
| 369 | 430 | return "error : ".$e->getMessage(); |
| 370 | 431 | } |
@@ -377,7 +438,9 @@ discard block |
||
| 377 | 438 | $sth_dest->execute($query_dest_values); |
| 378 | 439 | } |
| 379 | 440 | } |
| 380 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 441 | + if ($globalTransaction) { |
|
| 442 | + $Connection->db->commit(); |
|
| 443 | + } |
|
| 381 | 444 | } catch(PDOException $e) { |
| 382 | 445 | return "error : ".$e->getMessage(); |
| 383 | 446 | } |
@@ -413,7 +476,9 @@ discard block |
||
| 413 | 476 | $Connection = new Connection(); |
| 414 | 477 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 478 | try { |
| 416 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 479 | + if ($globalTransaction) { |
|
| 480 | + $Connection->db->beginTransaction(); |
|
| 481 | + } |
|
| 417 | 482 | $tmp = fgetcsv($fh,9999,',','"'); |
| 418 | 483 | while (!feof($fh)) { |
| 419 | 484 | $line = fgetcsv($fh,9999,',','"'); |
@@ -423,16 +488,22 @@ discard block |
||
| 423 | 488 | $values['registration'] = $line[0]; |
| 424 | 489 | $values['base'] = $line[4]; |
| 425 | 490 | $values['owner'] = $line[5]; |
| 426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 491 | + if ($line[6] == '') { |
|
| 492 | + $values['date_first_reg'] = null; |
|
| 493 | + } else { |
|
| 494 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 495 | + } |
|
| 428 | 496 | $values['cancel'] = $line[7]; |
| 429 | 497 | } elseif ($country == 'EI') { |
| 430 | 498 | // TODO : add modeS & reg to aircraft_modes |
| 431 | 499 | $values['registration'] = $line[0]; |
| 432 | 500 | $values['base'] = $line[3]; |
| 433 | 501 | $values['owner'] = $line[2]; |
| 434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 502 | + if ($line[1] == '') { |
|
| 503 | + $values['date_first_reg'] = null; |
|
| 504 | + } else { |
|
| 505 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 506 | + } |
|
| 436 | 507 | $values['cancel'] = ''; |
| 437 | 508 | } elseif ($country == 'HB') { |
| 438 | 509 | // TODO : add modeS & reg to aircraft_modes |
@@ -446,16 +517,22 @@ discard block |
||
| 446 | 517 | $values['registration'] = $line[3]; |
| 447 | 518 | $values['base'] = null; |
| 448 | 519 | $values['owner'] = $line[5]; |
| 449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 520 | + if ($line[18] == '') { |
|
| 521 | + $values['date_first_reg'] = null; |
|
| 522 | + } else { |
|
| 523 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 524 | + } |
|
| 451 | 525 | $values['cancel'] = ''; |
| 452 | 526 | } elseif ($country == 'VH') { |
| 453 | 527 | // TODO : add modeS & reg to aircraft_modes |
| 454 | 528 | $values['registration'] = $line[0]; |
| 455 | 529 | $values['base'] = null; |
| 456 | 530 | $values['owner'] = $line[12]; |
| 457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 531 | + if ($line[28] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 535 | + } |
|
| 459 | 536 | |
| 460 | 537 | $values['cancel'] = $line[39]; |
| 461 | 538 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -474,29 +551,41 @@ discard block |
||
| 474 | 551 | $values['registration'] = $line[0]; |
| 475 | 552 | $values['base'] = null; |
| 476 | 553 | $values['owner'] = $line[8]; |
| 477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 554 | + if ($line[7] == '') { |
|
| 555 | + $values['date_first_reg'] = null; |
|
| 556 | + } else { |
|
| 557 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 558 | + } |
|
| 479 | 559 | $values['cancel'] = ''; |
| 480 | 560 | } elseif ($country == 'PP') { |
| 481 | 561 | $values['registration'] = $line[0]; |
| 482 | 562 | $values['base'] = null; |
| 483 | 563 | $values['owner'] = $line[4]; |
| 484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 564 | + if ($line[6] == '') { |
|
| 565 | + $values['date_first_reg'] = null; |
|
| 566 | + } else { |
|
| 567 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 568 | + } |
|
| 486 | 569 | $values['cancel'] = $line[7]; |
| 487 | 570 | } elseif ($country == 'E7') { |
| 488 | 571 | $values['registration'] = $line[0]; |
| 489 | 572 | $values['base'] = null; |
| 490 | 573 | $values['owner'] = $line[4]; |
| 491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 574 | + if ($line[5] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 578 | + } |
|
| 493 | 579 | $values['cancel'] = ''; |
| 494 | 580 | } elseif ($country == '8Q') { |
| 495 | 581 | $values['registration'] = $line[0]; |
| 496 | 582 | $values['base'] = null; |
| 497 | 583 | $values['owner'] = $line[3]; |
| 498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 584 | + if ($line[7] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 588 | + } |
|
| 500 | 589 | $values['cancel'] = ''; |
| 501 | 590 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 591 | $values['registration'] = $line[0]; |
@@ -510,7 +599,9 @@ discard block |
||
| 510 | 599 | $sth_dest->execute($query_dest_values); |
| 511 | 600 | } |
| 512 | 601 | } |
| 513 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 602 | + if ($globalTransaction) { |
|
| 603 | + $Connection->db->commit(); |
|
| 604 | + } |
|
| 514 | 605 | } catch(PDOException $e) { |
| 515 | 606 | return "error : ".$e->getMessage(); |
| 516 | 607 | } |
@@ -644,25 +735,45 @@ discard block |
||
| 644 | 735 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 645 | 736 | $Connection = new Connection(); |
| 646 | 737 | $sth_dest = $Connection->db->prepare($query_dest); |
| 647 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 738 | + if ($globalTransaction) { |
|
| 739 | + $Connection->db->beginTransaction(); |
|
| 740 | + } |
|
| 648 | 741 | |
| 649 | 742 | $i = 0; |
| 650 | 743 | while($row = sparql_fetch_array($result)) |
| 651 | 744 | { |
| 652 | 745 | if ($i >= 1) { |
| 653 | 746 | //print_r($row); |
| 654 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 655 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 656 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 657 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 747 | + if (!isset($row['iata'])) { |
|
| 748 | + $row['iata'] = ''; |
|
| 749 | + } |
|
| 750 | + if (!isset($row['icao'])) { |
|
| 751 | + $row['icao'] = ''; |
|
| 752 | + } |
|
| 753 | + if (!isset($row['type'])) { |
|
| 754 | + $row['type'] = ''; |
|
| 755 | + } |
|
| 756 | + if (!isset($row['altitude'])) { |
|
| 757 | + $row['altitude'] = ''; |
|
| 758 | + } |
|
| 658 | 759 | if (isset($row['city_bis'])) { |
| 659 | 760 | $row['city'] = $row['city_bis']; |
| 660 | 761 | } |
| 661 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 662 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 663 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 664 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 665 | - if (!isset($row['name'])) continue; |
|
| 762 | + if (!isset($row['city'])) { |
|
| 763 | + $row['city'] = ''; |
|
| 764 | + } |
|
| 765 | + if (!isset($row['country'])) { |
|
| 766 | + $row['country'] = ''; |
|
| 767 | + } |
|
| 768 | + if (!isset($row['homepage'])) { |
|
| 769 | + $row['homepage'] = ''; |
|
| 770 | + } |
|
| 771 | + if (!isset($row['wikipedia_page'])) { |
|
| 772 | + $row['wikipedia_page'] = ''; |
|
| 773 | + } |
|
| 774 | + if (!isset($row['name'])) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 666 | 777 | if (!isset($row['image'])) { |
| 667 | 778 | $row['image'] = ''; |
| 668 | 779 | $row['image_thumb'] = ''; |
@@ -698,7 +809,9 @@ discard block |
||
| 698 | 809 | |
| 699 | 810 | $i++; |
| 700 | 811 | } |
| 701 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 812 | + if ($globalTransaction) { |
|
| 813 | + $Connection->db->commit(); |
|
| 814 | + } |
|
| 702 | 815 | echo "Delete duplicate rows...\n"; |
| 703 | 816 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
| 704 | 817 | try { |
@@ -710,7 +823,9 @@ discard block |
||
| 710 | 823 | } |
| 711 | 824 | |
| 712 | 825 | |
| 713 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
| 826 | + if ($globalDebug) { |
|
| 827 | + echo "Insert Not available Airport...\n"; |
|
| 828 | + } |
|
| 714 | 829 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 830 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | 831 | $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' => ''); |
@@ -737,7 +852,9 @@ discard block |
||
| 737 | 852 | $delimiter = ','; |
| 738 | 853 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | 854 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 740 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 855 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 856 | + return FALSE; |
|
| 857 | + } |
|
| 741 | 858 | echo "Add data from ourairports.com...\n"; |
| 742 | 859 | |
| 743 | 860 | $header = NULL; |
@@ -747,8 +864,9 @@ discard block |
||
| 747 | 864 | //$Connection->db->beginTransaction(); |
| 748 | 865 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 866 | { |
| 750 | - if(!$header) $header = $row; |
|
| 751 | - else { |
|
| 867 | + if(!$header) { |
|
| 868 | + $header = $row; |
|
| 869 | + } else { |
|
| 752 | 870 | $data = array(); |
| 753 | 871 | $data = array_combine($header, $row); |
| 754 | 872 | try { |
@@ -786,7 +904,9 @@ discard block |
||
| 786 | 904 | echo "Download data from another free database...\n"; |
| 787 | 905 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | 906 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 789 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 907 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 908 | + return FALSE; |
|
| 909 | + } |
|
| 790 | 910 | update_db::unzip($out_file); |
| 791 | 911 | $header = NULL; |
| 792 | 912 | echo "Add data from another free database...\n"; |
@@ -797,8 +917,9 @@ discard block |
||
| 797 | 917 | //$Connection->db->beginTransaction(); |
| 798 | 918 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 919 | { |
| 800 | - if(!$header) $header = $row; |
|
| 801 | - else { |
|
| 920 | + if(!$header) { |
|
| 921 | + $header = $row; |
|
| 922 | + } else { |
|
| 802 | 923 | $data = $row; |
| 803 | 924 | |
| 804 | 925 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -1090,7 +1211,9 @@ discard block |
||
| 1090 | 1211 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1091 | 1212 | { |
| 1092 | 1213 | $i = 0; |
| 1093 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1214 | + if ($globalTransaction) { |
|
| 1215 | + $Connection->db->beginTransaction(); |
|
| 1216 | + } |
|
| 1094 | 1217 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1218 | { |
| 1096 | 1219 | $i++; |
@@ -1118,7 +1241,9 @@ discard block |
||
| 1118 | 1241 | } |
| 1119 | 1242 | } |
| 1120 | 1243 | fclose($handle); |
| 1121 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1244 | + if ($globalTransaction) { |
|
| 1245 | + $Connection->db->commit(); |
|
| 1246 | + } |
|
| 1122 | 1247 | } |
| 1123 | 1248 | return ''; |
| 1124 | 1249 | } |
@@ -1141,7 +1266,9 @@ discard block |
||
| 1141 | 1266 | $Connection = new Connection(); |
| 1142 | 1267 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1143 | 1268 | { |
| 1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1145 | 1272 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1273 | { |
| 1147 | 1274 | if(count($row) > 1) { |
@@ -1155,7 +1282,9 @@ discard block |
||
| 1155 | 1282 | } |
| 1156 | 1283 | } |
| 1157 | 1284 | fclose($handle); |
| 1158 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1285 | + if ($globalTransaction) { |
|
| 1286 | + $Connection->db->commit(); |
|
| 1287 | + } |
|
| 1159 | 1288 | } |
| 1160 | 1289 | return ''; |
| 1161 | 1290 | } |
@@ -1175,8 +1304,9 @@ discard block |
||
| 1175 | 1304 | } |
| 1176 | 1305 | |
| 1177 | 1306 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1179 | - else { |
|
| 1307 | + if ($globalDBdriver == 'mysql') { |
|
| 1308 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1309 | + } else { |
|
| 1180 | 1310 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1181 | 1311 | $query = "CREATE EXTENSION postgis"; |
| 1182 | 1312 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1195,20 +1325,30 @@ discard block |
||
| 1195 | 1325 | global $tmp_dir, $globalDebug; |
| 1196 | 1326 | include_once('class.create_db.php'); |
| 1197 | 1327 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1328 | + if ($globalDebug) { |
|
| 1329 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1330 | + } |
|
| 1199 | 1331 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1200 | 1332 | $error = ''; |
| 1201 | 1333 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1202 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1334 | + if ($globalDebug) { |
|
| 1335 | + echo "Gunzip..."; |
|
| 1336 | + } |
|
| 1203 | 1337 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1204 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1338 | + if ($globalDebug) { |
|
| 1339 | + echo "Add to DB..."; |
|
| 1340 | + } |
|
| 1205 | 1341 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1206 | 1342 | $NOTAM = new NOTAM(); |
| 1207 | 1343 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1208 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1344 | + } else { |
|
| 1345 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1346 | + } |
|
| 1209 | 1347 | if ($error != '') { |
| 1210 | 1348 | return $error; |
| 1211 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1349 | + } elseif ($globalDebug) { |
|
| 1350 | + echo "Done\n"; |
|
| 1351 | + } |
|
| 1212 | 1352 | return ''; |
| 1213 | 1353 | } |
| 1214 | 1354 | |
@@ -1262,67 +1402,111 @@ discard block |
||
| 1262 | 1402 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1263 | 1403 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1264 | 1404 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1265 | - if ($globalDebug) echo "Unzip..."; |
|
| 1405 | + if ($globalDebug) { |
|
| 1406 | + echo "Unzip..."; |
|
| 1407 | + } |
|
| 1266 | 1408 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1267 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1409 | + if ($globalDebug) { |
|
| 1410 | + echo "Add to DB..."; |
|
| 1411 | + } |
|
| 1268 | 1412 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1269 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1413 | + if ($globalDebug) { |
|
| 1414 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1415 | + } |
|
| 1270 | 1416 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1271 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1272 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1273 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1417 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1418 | + $error = "Failed to copy airlines logo."; |
|
| 1419 | + } |
|
| 1420 | + } else { |
|
| 1421 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1422 | + } |
|
| 1423 | + } else { |
|
| 1424 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1425 | + } |
|
| 1274 | 1426 | if ($error != '') { |
| 1275 | 1427 | return $error; |
| 1276 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1428 | + } elseif ($globalDebug) { |
|
| 1429 | + echo "Done\n"; |
|
| 1430 | + } |
|
| 1277 | 1431 | return ''; |
| 1278 | 1432 | } |
| 1279 | 1433 | |
| 1280 | 1434 | public static function update_routes() { |
| 1281 | 1435 | global $tmp_dir, $globalDebug; |
| 1282 | 1436 | $error = ''; |
| 1283 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1437 | + if ($globalDebug) { |
|
| 1438 | + echo "Routes : Download..."; |
|
| 1439 | + } |
|
| 1284 | 1440 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1285 | 1441 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1286 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1442 | + if ($globalDebug) { |
|
| 1443 | + echo "Gunzip..."; |
|
| 1444 | + } |
|
| 1287 | 1445 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1288 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1446 | + if ($globalDebug) { |
|
| 1447 | + echo "Add to DB..."; |
|
| 1448 | + } |
|
| 1289 | 1449 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1290 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1450 | + } else { |
|
| 1451 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1452 | + } |
|
| 1291 | 1453 | if ($error != '') { |
| 1292 | 1454 | return $error; |
| 1293 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1455 | + } elseif ($globalDebug) { |
|
| 1456 | + echo "Done\n"; |
|
| 1457 | + } |
|
| 1294 | 1458 | return ''; |
| 1295 | 1459 | } |
| 1296 | 1460 | public static function update_oneworld() { |
| 1297 | 1461 | global $tmp_dir, $globalDebug; |
| 1298 | 1462 | $error = ''; |
| 1299 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1463 | + if ($globalDebug) { |
|
| 1464 | + echo "Schedules Oneworld : Download..."; |
|
| 1465 | + } |
|
| 1300 | 1466 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1301 | 1467 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1302 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1468 | + if ($globalDebug) { |
|
| 1469 | + echo "Gunzip..."; |
|
| 1470 | + } |
|
| 1303 | 1471 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1304 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1472 | + if ($globalDebug) { |
|
| 1473 | + echo "Add to DB..."; |
|
| 1474 | + } |
|
| 1305 | 1475 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1306 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1476 | + } else { |
|
| 1477 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1478 | + } |
|
| 1307 | 1479 | if ($error != '') { |
| 1308 | 1480 | return $error; |
| 1309 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1481 | + } elseif ($globalDebug) { |
|
| 1482 | + echo "Done\n"; |
|
| 1483 | + } |
|
| 1310 | 1484 | return ''; |
| 1311 | 1485 | } |
| 1312 | 1486 | public static function update_skyteam() { |
| 1313 | 1487 | global $tmp_dir, $globalDebug; |
| 1314 | 1488 | $error = ''; |
| 1315 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1489 | + if ($globalDebug) { |
|
| 1490 | + echo "Schedules Skyteam : Download..."; |
|
| 1491 | + } |
|
| 1316 | 1492 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1317 | 1493 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1318 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1494 | + if ($globalDebug) { |
|
| 1495 | + echo "Gunzip..."; |
|
| 1496 | + } |
|
| 1319 | 1497 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1320 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1498 | + if ($globalDebug) { |
|
| 1499 | + echo "Add to DB..."; |
|
| 1500 | + } |
|
| 1321 | 1501 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1322 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1502 | + } else { |
|
| 1503 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1504 | + } |
|
| 1323 | 1505 | if ($error != '') { |
| 1324 | 1506 | return $error; |
| 1325 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1507 | + } elseif ($globalDebug) { |
|
| 1508 | + echo "Done\n"; |
|
| 1509 | + } |
|
| 1326 | 1510 | return ''; |
| 1327 | 1511 | } |
| 1328 | 1512 | public static function update_ModeS() { |
@@ -1339,263 +1523,463 @@ discard block |
||
| 1339 | 1523 | exit; |
| 1340 | 1524 | } elseif ($globalDebug) echo "Done\n"; |
| 1341 | 1525 | */ |
| 1342 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1526 | + if ($globalDebug) { |
|
| 1527 | + echo "Modes : Download..."; |
|
| 1528 | + } |
|
| 1343 | 1529 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1344 | 1530 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1345 | - if ($globalDebug) echo "Unzip..."; |
|
| 1531 | + if ($globalDebug) { |
|
| 1532 | + echo "Unzip..."; |
|
| 1533 | + } |
|
| 1346 | 1534 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
| 1347 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1535 | + if ($globalDebug) { |
|
| 1536 | + echo "Add to DB..."; |
|
| 1537 | + } |
|
| 1348 | 1538 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1349 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1539 | + } else { |
|
| 1540 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1541 | + } |
|
| 1350 | 1542 | if ($error != '') { |
| 1351 | 1543 | return $error; |
| 1352 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1544 | + } elseif ($globalDebug) { |
|
| 1545 | + echo "Done\n"; |
|
| 1546 | + } |
|
| 1353 | 1547 | return ''; |
| 1354 | 1548 | } |
| 1355 | 1549 | |
| 1356 | 1550 | public static function update_ModeS_flarm() { |
| 1357 | 1551 | global $tmp_dir, $globalDebug; |
| 1358 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1552 | + if ($globalDebug) { |
|
| 1553 | + echo "Modes Flarmnet: Download..."; |
|
| 1554 | + } |
|
| 1359 | 1555 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1360 | 1556 | if (file_exists($tmp_dir.'data.fln')) { |
| 1361 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1557 | + if ($globalDebug) { |
|
| 1558 | + echo "Add to DB..."; |
|
| 1559 | + } |
|
| 1362 | 1560 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1363 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1561 | + } else { |
|
| 1562 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1563 | + } |
|
| 1364 | 1564 | if ($error != '') { |
| 1365 | 1565 | return $error; |
| 1366 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1566 | + } elseif ($globalDebug) { |
|
| 1567 | + echo "Done\n"; |
|
| 1568 | + } |
|
| 1367 | 1569 | return ''; |
| 1368 | 1570 | } |
| 1369 | 1571 | |
| 1370 | 1572 | public static function update_ModeS_ogn() { |
| 1371 | 1573 | global $tmp_dir, $globalDebug; |
| 1372 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1574 | + if ($globalDebug) { |
|
| 1575 | + echo "Modes OGN: Download..."; |
|
| 1576 | + } |
|
| 1373 | 1577 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1374 | 1578 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1375 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1579 | + if ($globalDebug) { |
|
| 1580 | + echo "Add to DB..."; |
|
| 1581 | + } |
|
| 1376 | 1582 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1377 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1583 | + } else { |
|
| 1584 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1585 | + } |
|
| 1378 | 1586 | if ($error != '') { |
| 1379 | 1587 | return $error; |
| 1380 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1588 | + } elseif ($globalDebug) { |
|
| 1589 | + echo "Done\n"; |
|
| 1590 | + } |
|
| 1381 | 1591 | return ''; |
| 1382 | 1592 | } |
| 1383 | 1593 | |
| 1384 | 1594 | public static function update_owner() { |
| 1385 | 1595 | global $tmp_dir, $globalDebug; |
| 1386 | 1596 | |
| 1387 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1597 | + if ($globalDebug) { |
|
| 1598 | + echo "Owner France: Download..."; |
|
| 1599 | + } |
|
| 1388 | 1600 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1389 | 1601 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1390 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1602 | + if ($globalDebug) { |
|
| 1603 | + echo "Add to DB..."; |
|
| 1604 | + } |
|
| 1391 | 1605 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1392 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1606 | + } else { |
|
| 1607 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1608 | + } |
|
| 1393 | 1609 | if ($error != '') { |
| 1394 | 1610 | return $error; |
| 1395 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1611 | + } elseif ($globalDebug) { |
|
| 1612 | + echo "Done\n"; |
|
| 1613 | + } |
|
| 1396 | 1614 | |
| 1397 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1615 | + if ($globalDebug) { |
|
| 1616 | + echo "Owner Ireland: Download..."; |
|
| 1617 | + } |
|
| 1398 | 1618 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1399 | 1619 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1400 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1620 | + if ($globalDebug) { |
|
| 1621 | + echo "Add to DB..."; |
|
| 1622 | + } |
|
| 1401 | 1623 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1402 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1624 | + } else { |
|
| 1625 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1626 | + } |
|
| 1403 | 1627 | if ($error != '') { |
| 1404 | 1628 | return $error; |
| 1405 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1406 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1629 | + } elseif ($globalDebug) { |
|
| 1630 | + echo "Done\n"; |
|
| 1631 | + } |
|
| 1632 | + if ($globalDebug) { |
|
| 1633 | + echo "Owner Switzerland: Download..."; |
|
| 1634 | + } |
|
| 1407 | 1635 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1408 | 1636 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1409 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1637 | + if ($globalDebug) { |
|
| 1638 | + echo "Add to DB..."; |
|
| 1639 | + } |
|
| 1410 | 1640 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1411 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1641 | + } else { |
|
| 1642 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1643 | + } |
|
| 1412 | 1644 | if ($error != '') { |
| 1413 | 1645 | return $error; |
| 1414 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1415 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1646 | + } elseif ($globalDebug) { |
|
| 1647 | + echo "Done\n"; |
|
| 1648 | + } |
|
| 1649 | + if ($globalDebug) { |
|
| 1650 | + echo "Owner Czech Republic: Download..."; |
|
| 1651 | + } |
|
| 1416 | 1652 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1417 | 1653 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1418 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1654 | + if ($globalDebug) { |
|
| 1655 | + echo "Add to DB..."; |
|
| 1656 | + } |
|
| 1419 | 1657 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1420 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1658 | + } else { |
|
| 1659 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1660 | + } |
|
| 1421 | 1661 | if ($error != '') { |
| 1422 | 1662 | return $error; |
| 1423 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1424 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1663 | + } elseif ($globalDebug) { |
|
| 1664 | + echo "Done\n"; |
|
| 1665 | + } |
|
| 1666 | + if ($globalDebug) { |
|
| 1667 | + echo "Owner Australia: Download..."; |
|
| 1668 | + } |
|
| 1425 | 1669 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1426 | 1670 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1427 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1671 | + if ($globalDebug) { |
|
| 1672 | + echo "Add to DB..."; |
|
| 1673 | + } |
|
| 1428 | 1674 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1429 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1675 | + } else { |
|
| 1676 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1677 | + } |
|
| 1430 | 1678 | if ($error != '') { |
| 1431 | 1679 | return $error; |
| 1432 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1433 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1680 | + } elseif ($globalDebug) { |
|
| 1681 | + echo "Done\n"; |
|
| 1682 | + } |
|
| 1683 | + if ($globalDebug) { |
|
| 1684 | + echo "Owner Austria: Download..."; |
|
| 1685 | + } |
|
| 1434 | 1686 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1435 | 1687 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1436 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1688 | + if ($globalDebug) { |
|
| 1689 | + echo "Add to DB..."; |
|
| 1690 | + } |
|
| 1437 | 1691 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1438 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1692 | + } else { |
|
| 1693 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1694 | + } |
|
| 1439 | 1695 | if ($error != '') { |
| 1440 | 1696 | return $error; |
| 1441 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1442 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1697 | + } elseif ($globalDebug) { |
|
| 1698 | + echo "Done\n"; |
|
| 1699 | + } |
|
| 1700 | + if ($globalDebug) { |
|
| 1701 | + echo "Owner Chile: Download..."; |
|
| 1702 | + } |
|
| 1443 | 1703 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1444 | 1704 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1445 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1705 | + if ($globalDebug) { |
|
| 1706 | + echo "Add to DB..."; |
|
| 1707 | + } |
|
| 1446 | 1708 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1447 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1709 | + } else { |
|
| 1710 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1711 | + } |
|
| 1448 | 1712 | if ($error != '') { |
| 1449 | 1713 | return $error; |
| 1450 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1451 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1714 | + } elseif ($globalDebug) { |
|
| 1715 | + echo "Done\n"; |
|
| 1716 | + } |
|
| 1717 | + if ($globalDebug) { |
|
| 1718 | + echo "Owner Colombia: Download..."; |
|
| 1719 | + } |
|
| 1452 | 1720 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1453 | 1721 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1454 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1722 | + if ($globalDebug) { |
|
| 1723 | + echo "Add to DB..."; |
|
| 1724 | + } |
|
| 1455 | 1725 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1456 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1726 | + } else { |
|
| 1727 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1728 | + } |
|
| 1457 | 1729 | if ($error != '') { |
| 1458 | 1730 | return $error; |
| 1459 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1460 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1731 | + } elseif ($globalDebug) { |
|
| 1732 | + echo "Done\n"; |
|
| 1733 | + } |
|
| 1734 | + if ($globalDebug) { |
|
| 1735 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1736 | + } |
|
| 1461 | 1737 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1462 | 1738 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1463 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1739 | + if ($globalDebug) { |
|
| 1740 | + echo "Add to DB..."; |
|
| 1741 | + } |
|
| 1464 | 1742 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1465 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1743 | + } else { |
|
| 1744 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1745 | + } |
|
| 1466 | 1746 | if ($error != '') { |
| 1467 | 1747 | return $error; |
| 1468 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1469 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1748 | + } elseif ($globalDebug) { |
|
| 1749 | + echo "Done\n"; |
|
| 1750 | + } |
|
| 1751 | + if ($globalDebug) { |
|
| 1752 | + echo "Owner Brazil: Download..."; |
|
| 1753 | + } |
|
| 1470 | 1754 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1471 | 1755 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1472 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1756 | + if ($globalDebug) { |
|
| 1757 | + echo "Add to DB..."; |
|
| 1758 | + } |
|
| 1473 | 1759 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1474 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1760 | + } else { |
|
| 1761 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1762 | + } |
|
| 1475 | 1763 | if ($error != '') { |
| 1476 | 1764 | return $error; |
| 1477 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1478 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1765 | + } elseif ($globalDebug) { |
|
| 1766 | + echo "Done\n"; |
|
| 1767 | + } |
|
| 1768 | + if ($globalDebug) { |
|
| 1769 | + echo "Owner Cayman Islands: Download..."; |
|
| 1770 | + } |
|
| 1479 | 1771 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1480 | 1772 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1481 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1773 | + if ($globalDebug) { |
|
| 1774 | + echo "Add to DB..."; |
|
| 1775 | + } |
|
| 1482 | 1776 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1483 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1777 | + } else { |
|
| 1778 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1779 | + } |
|
| 1484 | 1780 | if ($error != '') { |
| 1485 | 1781 | return $error; |
| 1486 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1487 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1782 | + } elseif ($globalDebug) { |
|
| 1783 | + echo "Done\n"; |
|
| 1784 | + } |
|
| 1785 | + if ($globalDebug) { |
|
| 1786 | + echo "Owner Croatia: Download..."; |
|
| 1787 | + } |
|
| 1488 | 1788 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1489 | 1789 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1490 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1790 | + if ($globalDebug) { |
|
| 1791 | + echo "Add to DB..."; |
|
| 1792 | + } |
|
| 1491 | 1793 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1492 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1794 | + } else { |
|
| 1795 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1796 | + } |
|
| 1493 | 1797 | if ($error != '') { |
| 1494 | 1798 | return $error; |
| 1495 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1496 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1799 | + } elseif ($globalDebug) { |
|
| 1800 | + echo "Done\n"; |
|
| 1801 | + } |
|
| 1802 | + if ($globalDebug) { |
|
| 1803 | + echo "Owner Luxembourg: Download..."; |
|
| 1804 | + } |
|
| 1497 | 1805 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1498 | 1806 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1499 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1807 | + if ($globalDebug) { |
|
| 1808 | + echo "Add to DB..."; |
|
| 1809 | + } |
|
| 1500 | 1810 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1501 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1811 | + } else { |
|
| 1812 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1813 | + } |
|
| 1502 | 1814 | if ($error != '') { |
| 1503 | 1815 | return $error; |
| 1504 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1505 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1816 | + } elseif ($globalDebug) { |
|
| 1817 | + echo "Done\n"; |
|
| 1818 | + } |
|
| 1819 | + if ($globalDebug) { |
|
| 1820 | + echo "Owner Maldives: Download..."; |
|
| 1821 | + } |
|
| 1506 | 1822 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1507 | 1823 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1508 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1824 | + if ($globalDebug) { |
|
| 1825 | + echo "Add to DB..."; |
|
| 1826 | + } |
|
| 1509 | 1827 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1510 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1828 | + } else { |
|
| 1829 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1830 | + } |
|
| 1511 | 1831 | if ($error != '') { |
| 1512 | 1832 | return $error; |
| 1513 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1514 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1833 | + } elseif ($globalDebug) { |
|
| 1834 | + echo "Done\n"; |
|
| 1835 | + } |
|
| 1836 | + if ($globalDebug) { |
|
| 1837 | + echo "Owner New Zealand: Download..."; |
|
| 1838 | + } |
|
| 1515 | 1839 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1516 | 1840 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1517 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1841 | + if ($globalDebug) { |
|
| 1842 | + echo "Add to DB..."; |
|
| 1843 | + } |
|
| 1518 | 1844 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1519 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1845 | + } else { |
|
| 1846 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1847 | + } |
|
| 1520 | 1848 | if ($error != '') { |
| 1521 | 1849 | return $error; |
| 1522 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1523 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1850 | + } elseif ($globalDebug) { |
|
| 1851 | + echo "Done\n"; |
|
| 1852 | + } |
|
| 1853 | + if ($globalDebug) { |
|
| 1854 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1855 | + } |
|
| 1524 | 1856 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1525 | 1857 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1526 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1858 | + if ($globalDebug) { |
|
| 1859 | + echo "Add to DB..."; |
|
| 1860 | + } |
|
| 1527 | 1861 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1528 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1862 | + } else { |
|
| 1863 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1864 | + } |
|
| 1529 | 1865 | if ($error != '') { |
| 1530 | 1866 | return $error; |
| 1531 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1532 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1867 | + } elseif ($globalDebug) { |
|
| 1868 | + echo "Done\n"; |
|
| 1869 | + } |
|
| 1870 | + if ($globalDebug) { |
|
| 1871 | + echo "Owner Slovakia: Download..."; |
|
| 1872 | + } |
|
| 1533 | 1873 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1534 | 1874 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1535 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1875 | + if ($globalDebug) { |
|
| 1876 | + echo "Add to DB..."; |
|
| 1877 | + } |
|
| 1536 | 1878 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1537 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1879 | + } else { |
|
| 1880 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1881 | + } |
|
| 1538 | 1882 | if ($error != '') { |
| 1539 | 1883 | return $error; |
| 1540 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1541 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1884 | + } elseif ($globalDebug) { |
|
| 1885 | + echo "Done\n"; |
|
| 1886 | + } |
|
| 1887 | + if ($globalDebug) { |
|
| 1888 | + echo "Owner Ecuador: Download..."; |
|
| 1889 | + } |
|
| 1542 | 1890 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1543 | 1891 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1544 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1892 | + if ($globalDebug) { |
|
| 1893 | + echo "Add to DB..."; |
|
| 1894 | + } |
|
| 1545 | 1895 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1546 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1896 | + } else { |
|
| 1897 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1898 | + } |
|
| 1547 | 1899 | if ($error != '') { |
| 1548 | 1900 | return $error; |
| 1549 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1550 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1901 | + } elseif ($globalDebug) { |
|
| 1902 | + echo "Done\n"; |
|
| 1903 | + } |
|
| 1904 | + if ($globalDebug) { |
|
| 1905 | + echo "Owner Iceland: Download..."; |
|
| 1906 | + } |
|
| 1551 | 1907 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1552 | 1908 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1553 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1909 | + if ($globalDebug) { |
|
| 1910 | + echo "Add to DB..."; |
|
| 1911 | + } |
|
| 1554 | 1912 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1555 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1913 | + } else { |
|
| 1914 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1915 | + } |
|
| 1556 | 1916 | if ($error != '') { |
| 1557 | 1917 | return $error; |
| 1558 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1918 | + } elseif ($globalDebug) { |
|
| 1919 | + echo "Done\n"; |
|
| 1920 | + } |
|
| 1559 | 1921 | return ''; |
| 1560 | 1922 | } |
| 1561 | 1923 | |
| 1562 | 1924 | public static function update_translation() { |
| 1563 | 1925 | global $tmp_dir, $globalDebug; |
| 1564 | 1926 | $error = ''; |
| 1565 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo "Translation : Download..."; |
|
| 1929 | + } |
|
| 1566 | 1930 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1567 | 1931 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1568 | - if ($globalDebug) echo "Unzip..."; |
|
| 1932 | + if ($globalDebug) { |
|
| 1933 | + echo "Unzip..."; |
|
| 1934 | + } |
|
| 1569 | 1935 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1570 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1936 | + if ($globalDebug) { |
|
| 1937 | + echo "Add to DB..."; |
|
| 1938 | + } |
|
| 1571 | 1939 | $error = update_db::translation(); |
| 1572 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1940 | + } else { |
|
| 1941 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1942 | + } |
|
| 1573 | 1943 | if ($error != '') { |
| 1574 | 1944 | return $error; |
| 1575 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1945 | + } elseif ($globalDebug) { |
|
| 1946 | + echo "Done\n"; |
|
| 1947 | + } |
|
| 1576 | 1948 | return ''; |
| 1577 | 1949 | } |
| 1578 | 1950 | |
| 1579 | 1951 | public static function update_translation_fam() { |
| 1580 | 1952 | global $tmp_dir, $globalDebug; |
| 1581 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1953 | + if ($globalDebug) { |
|
| 1954 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1955 | + } |
|
| 1582 | 1956 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1583 | 1957 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1584 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1958 | + if ($globalDebug) { |
|
| 1959 | + echo "Gunzip..."; |
|
| 1960 | + } |
|
| 1585 | 1961 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1586 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1962 | + if ($globalDebug) { |
|
| 1963 | + echo "Add to DB..."; |
|
| 1964 | + } |
|
| 1587 | 1965 | $error = update_db::translation_fam(); |
| 1588 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1966 | + } else { |
|
| 1967 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1968 | + } |
|
| 1589 | 1969 | if ($error != '') { |
| 1590 | 1970 | return $error; |
| 1591 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1971 | + } elseif ($globalDebug) { |
|
| 1972 | + echo "Done\n"; |
|
| 1973 | + } |
|
| 1592 | 1974 | return ''; |
| 1593 | 1975 | } |
| 1594 | 1976 | |
| 1595 | 1977 | public static function update_airspace_fam() { |
| 1596 | 1978 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 1597 | 1979 | include_once('class.create_db.php'); |
| 1598 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 1980 | + if ($globalDebug) { |
|
| 1981 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 1982 | + } |
|
| 1599 | 1983 | if ($globalDBdriver == 'mysql') { |
| 1600 | 1984 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 1601 | 1985 | } else { |
@@ -1611,9 +1995,13 @@ discard block |
||
| 1611 | 1995 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 1612 | 1996 | } |
| 1613 | 1997 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1614 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1998 | + if ($globalDebug) { |
|
| 1999 | + echo "Gunzip..."; |
|
| 2000 | + } |
|
| 1615 | 2001 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 1616 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2002 | + if ($globalDebug) { |
|
| 2003 | + echo "Add to DB..."; |
|
| 2004 | + } |
|
| 1617 | 2005 | $Connection = new Connection(); |
| 1618 | 2006 | if ($Connection->tableExists('airspace')) { |
| 1619 | 2007 | $query = 'DROP TABLE airspace'; |
@@ -1626,31 +2014,47 @@ discard block |
||
| 1626 | 2014 | } |
| 1627 | 2015 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1628 | 2016 | update_db::insert_airspace_version($airspace_md5); |
| 1629 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2017 | + } else { |
|
| 2018 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2019 | + } |
|
| 1630 | 2020 | } |
| 1631 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2021 | + } else { |
|
| 2022 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2023 | + } |
|
| 1632 | 2024 | if ($error != '') { |
| 1633 | 2025 | return $error; |
| 1634 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2026 | + } elseif ($globalDebug) { |
|
| 2027 | + echo "Done\n"; |
|
| 2028 | + } |
|
| 1635 | 2029 | return ''; |
| 1636 | 2030 | } |
| 1637 | 2031 | |
| 1638 | 2032 | public static function update_tle() { |
| 1639 | 2033 | global $tmp_dir, $globalDebug; |
| 1640 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2034 | + if ($globalDebug) { |
|
| 2035 | + echo "Download TLE : Download..."; |
|
| 2036 | + } |
|
| 1641 | 2037 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
| 1642 | 2038 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
| 1643 | 2039 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 1644 | 2040 | foreach ($alltle as $filename) { |
| 1645 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2041 | + if ($globalDebug) { |
|
| 2042 | + echo "downloading ".$filename.'...'; |
|
| 2043 | + } |
|
| 1646 | 2044 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 1647 | 2045 | if (file_exists($tmp_dir.$filename)) { |
| 1648 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2046 | + if ($globalDebug) { |
|
| 2047 | + echo "Add to DB ".$filename."..."; |
|
| 2048 | + } |
|
| 1649 | 2049 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 1650 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2050 | + } else { |
|
| 2051 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2052 | + } |
|
| 1651 | 2053 | if ($error != '') { |
| 1652 | 2054 | echo $error."\n"; |
| 1653 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2055 | + } elseif ($globalDebug) { |
|
| 2056 | + echo "Done\n"; |
|
| 2057 | + } |
|
| 1654 | 2058 | } |
| 1655 | 2059 | return ''; |
| 1656 | 2060 | } |
@@ -1658,10 +2062,14 @@ discard block |
||
| 1658 | 2062 | public static function update_models() { |
| 1659 | 2063 | global $tmp_dir, $globalDebug; |
| 1660 | 2064 | $error = ''; |
| 1661 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2065 | + if ($globalDebug) { |
|
| 2066 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2067 | + } |
|
| 1662 | 2068 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 1663 | 2069 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1664 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2070 | + if ($globalDebug) { |
|
| 2071 | + echo "Check files...\n"; |
|
| 2072 | + } |
|
| 1665 | 2073 | $newmodelsdb = array(); |
| 1666 | 2074 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 1667 | 2075 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1680,25 +2088,35 @@ discard block |
||
| 1680 | 2088 | } |
| 1681 | 2089 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1682 | 2090 | foreach ($diff as $key => $value) { |
| 1683 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2091 | + if ($globalDebug) { |
|
| 2092 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2093 | + } |
|
| 1684 | 2094 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 1685 | 2095 | |
| 1686 | 2096 | } |
| 1687 | 2097 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 1688 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2098 | + } else { |
|
| 2099 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2100 | + } |
|
| 1689 | 2101 | if ($error != '') { |
| 1690 | 2102 | return $error; |
| 1691 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2103 | + } elseif ($globalDebug) { |
|
| 2104 | + echo "Done\n"; |
|
| 2105 | + } |
|
| 1692 | 2106 | return ''; |
| 1693 | 2107 | } |
| 1694 | 2108 | |
| 1695 | 2109 | public static function update_space_models() { |
| 1696 | 2110 | global $tmp_dir, $globalDebug; |
| 1697 | 2111 | $error = ''; |
| 1698 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2114 | + } |
|
| 1699 | 2115 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 1700 | 2116 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1701 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2117 | + if ($globalDebug) { |
|
| 2118 | + echo "Check files...\n"; |
|
| 2119 | + } |
|
| 1702 | 2120 | $newmodelsdb = array(); |
| 1703 | 2121 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 1704 | 2122 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1717,15 +2135,21 @@ discard block |
||
| 1717 | 2135 | } |
| 1718 | 2136 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1719 | 2137 | foreach ($diff as $key => $value) { |
| 1720 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2138 | + if ($globalDebug) { |
|
| 2139 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2140 | + } |
|
| 1721 | 2141 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 1722 | 2142 | |
| 1723 | 2143 | } |
| 1724 | 2144 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 1725 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2145 | + } else { |
|
| 2146 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2147 | + } |
|
| 1726 | 2148 | if ($error != '') { |
| 1727 | 2149 | return $error; |
| 1728 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2150 | + } elseif ($globalDebug) { |
|
| 2151 | + echo "Done\n"; |
|
| 2152 | + } |
|
| 1729 | 2153 | return ''; |
| 1730 | 2154 | } |
| 1731 | 2155 | |
@@ -1768,7 +2192,9 @@ discard block |
||
| 1768 | 2192 | } |
| 1769 | 2193 | |
| 1770 | 2194 | $error = ''; |
| 1771 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2195 | + if ($globalDebug) { |
|
| 2196 | + echo "Notam : Download..."; |
|
| 2197 | + } |
|
| 1772 | 2198 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1773 | 2199 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1774 | 2200 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1783,14 +2209,30 @@ discard block |
||
| 1783 | 2209 | $data['fir'] = $q[0]; |
| 1784 | 2210 | $data['code'] = $q[1]; |
| 1785 | 2211 | $ifrvfr = $q[2]; |
| 1786 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1787 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1788 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1789 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1790 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1791 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1792 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1793 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2212 | + if ($ifrvfr == 'IV') { |
|
| 2213 | + $data['rules'] = 'IFR/VFR'; |
|
| 2214 | + } |
|
| 2215 | + if ($ifrvfr == 'I') { |
|
| 2216 | + $data['rules'] = 'IFR'; |
|
| 2217 | + } |
|
| 2218 | + if ($ifrvfr == 'V') { |
|
| 2219 | + $data['rules'] = 'VFR'; |
|
| 2220 | + } |
|
| 2221 | + if ($q[4] == 'A') { |
|
| 2222 | + $data['scope'] = 'Airport warning'; |
|
| 2223 | + } |
|
| 2224 | + if ($q[4] == 'E') { |
|
| 2225 | + $data['scope'] = 'Enroute warning'; |
|
| 2226 | + } |
|
| 2227 | + if ($q[4] == 'W') { |
|
| 2228 | + $data['scope'] = 'Navigation warning'; |
|
| 2229 | + } |
|
| 2230 | + if ($q[4] == 'AE') { |
|
| 2231 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2232 | + } |
|
| 2233 | + if ($q[4] == 'AW') { |
|
| 2234 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2235 | + } |
|
| 1794 | 2236 | //$data['scope'] = $q[4]; |
| 1795 | 2237 | $data['lower_limit'] = $q[5]; |
| 1796 | 2238 | $data['upper_limit'] = $q[6]; |
@@ -1798,8 +2240,12 @@ discard block |
||
| 1798 | 2240 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1799 | 2241 | $latitude = $Common->convertDec($las,'latitude'); |
| 1800 | 2242 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1801 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1802 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2243 | + if ($lac == 'S') { |
|
| 2244 | + $latitude = '-'.$latitude; |
|
| 2245 | + } |
|
| 2246 | + if ($lnc == 'W') { |
|
| 2247 | + $longitude = '-'.$longitude; |
|
| 2248 | + } |
|
| 1803 | 2249 | $data['center_latitude'] = $latitude; |
| 1804 | 2250 | $data['center_longitude'] = $longitude; |
| 1805 | 2251 | $data['radius'] = intval($radius); |
@@ -1829,10 +2275,14 @@ discard block |
||
| 1829 | 2275 | $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']); |
| 1830 | 2276 | unset($data); |
| 1831 | 2277 | } |
| 1832 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2278 | + } else { |
|
| 2279 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2280 | + } |
|
| 1833 | 2281 | if ($error != '') { |
| 1834 | 2282 | return $error; |
| 1835 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2283 | + } elseif ($globalDebug) { |
|
| 2284 | + echo "Done\n"; |
|
| 2285 | + } |
|
| 1836 | 2286 | return ''; |
| 1837 | 2287 | } |
| 1838 | 2288 | |
@@ -1857,7 +2307,9 @@ discard block |
||
| 1857 | 2307 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1858 | 2308 | $airspace_json = json_decode($airspace_lst,true); |
| 1859 | 2309 | foreach ($airspace_json['records'] as $airspace) { |
| 1860 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo $airspace['name']."...\n"; |
|
| 2312 | + } |
|
| 1861 | 2313 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 1862 | 2314 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1863 | 2315 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -1886,8 +2338,11 @@ discard block |
||
| 1886 | 2338 | return "error : ".$e->getMessage(); |
| 1887 | 2339 | } |
| 1888 | 2340 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1889 | - if ($row['nb'] > 0) return false; |
|
| 1890 | - else return true; |
|
| 2341 | + if ($row['nb'] > 0) { |
|
| 2342 | + return false; |
|
| 2343 | + } else { |
|
| 2344 | + return true; |
|
| 2345 | + } |
|
| 1891 | 2346 | } |
| 1892 | 2347 | |
| 1893 | 2348 | public static function insert_last_update() { |
@@ -1912,8 +2367,11 @@ discard block |
||
| 1912 | 2367 | return "error : ".$e->getMessage(); |
| 1913 | 2368 | } |
| 1914 | 2369 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1915 | - if ($row['nb'] > 0) return true; |
|
| 1916 | - else return false; |
|
| 2370 | + if ($row['nb'] > 0) { |
|
| 2371 | + return true; |
|
| 2372 | + } else { |
|
| 2373 | + return false; |
|
| 2374 | + } |
|
| 1917 | 2375 | } |
| 1918 | 2376 | |
| 1919 | 2377 | |
@@ -1944,8 +2402,11 @@ discard block |
||
| 1944 | 2402 | return "error : ".$e->getMessage(); |
| 1945 | 2403 | } |
| 1946 | 2404 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1947 | - if ($row['nb'] > 0) return false; |
|
| 1948 | - else return true; |
|
| 2405 | + if ($row['nb'] > 0) { |
|
| 2406 | + return false; |
|
| 2407 | + } else { |
|
| 2408 | + return true; |
|
| 2409 | + } |
|
| 1949 | 2410 | } |
| 1950 | 2411 | |
| 1951 | 2412 | public static function insert_last_notam_update() { |
@@ -1974,8 +2435,11 @@ discard block |
||
| 1974 | 2435 | return "error : ".$e->getMessage(); |
| 1975 | 2436 | } |
| 1976 | 2437 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1977 | - if ($row['nb'] > 0) return false; |
|
| 1978 | - else return true; |
|
| 2438 | + if ($row['nb'] > 0) { |
|
| 2439 | + return false; |
|
| 2440 | + } else { |
|
| 2441 | + return true; |
|
| 2442 | + } |
|
| 1979 | 2443 | } |
| 1980 | 2444 | |
| 1981 | 2445 | public static function insert_last_airspace_update() { |
@@ -2005,8 +2469,11 @@ discard block |
||
| 2005 | 2469 | return "error : ".$e->getMessage(); |
| 2006 | 2470 | } |
| 2007 | 2471 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2008 | - if ($row['nb'] > 0) return false; |
|
| 2009 | - else return true; |
|
| 2472 | + if ($row['nb'] > 0) { |
|
| 2473 | + return false; |
|
| 2474 | + } else { |
|
| 2475 | + return true; |
|
| 2476 | + } |
|
| 2010 | 2477 | } |
| 2011 | 2478 | |
| 2012 | 2479 | public static function insert_last_owner_update() { |
@@ -2035,8 +2502,11 @@ discard block |
||
| 2035 | 2502 | return "error : ".$e->getMessage(); |
| 2036 | 2503 | } |
| 2037 | 2504 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2038 | - if ($row['nb'] > 0) return false; |
|
| 2039 | - else return true; |
|
| 2505 | + if ($row['nb'] > 0) { |
|
| 2506 | + return false; |
|
| 2507 | + } else { |
|
| 2508 | + return true; |
|
| 2509 | + } |
|
| 2040 | 2510 | } |
| 2041 | 2511 | |
| 2042 | 2512 | public static function insert_last_schedules_update() { |
@@ -2065,8 +2535,11 @@ discard block |
||
| 2065 | 2535 | return "error : ".$e->getMessage(); |
| 2066 | 2536 | } |
| 2067 | 2537 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2068 | - if ($row['nb'] > 0) return false; |
|
| 2069 | - else return true; |
|
| 2538 | + if ($row['nb'] > 0) { |
|
| 2539 | + return false; |
|
| 2540 | + } else { |
|
| 2541 | + return true; |
|
| 2542 | + } |
|
| 2070 | 2543 | } |
| 2071 | 2544 | |
| 2072 | 2545 | public static function insert_last_tle_update() { |
@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | $dbc = $this->db; |
| 54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
| 55 | 55 | if ($globalSchedulesFetch) { |
| 56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 56 | + if ($globalDebug) { |
|
| 57 | + echo 'Getting schedule info...'."\n"; |
|
| 58 | + } |
|
| 57 | 59 | $Spotter = new Spotter($dbc); |
| 58 | 60 | $Schedule = new Schedule($dbc); |
| 59 | 61 | $Translation = new Translation($dbc); |
@@ -63,7 +65,9 @@ discard block |
||
| 63 | 65 | if ($Schedule->checkSchedule($operator) == 0) { |
| 64 | 66 | $schedule = $Schedule->fetchSchedule($operator); |
| 65 | 67 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 66 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 68 | + if ($globalDebug) { |
|
| 69 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 70 | + } |
|
| 67 | 71 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 69 | 73 | // Should also check if route schedule = route from DB |
@@ -72,7 +76,9 @@ discard block |
||
| 72 | 76 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 73 | 77 | if ($airport_icao != '') { |
| 74 | 78 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 75 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 79 | + if ($globalDebug) { |
|
| 80 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 81 | + } |
|
| 76 | 82 | } |
| 77 | 83 | } |
| 78 | 84 | } |
@@ -81,7 +87,9 @@ discard block |
||
| 81 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 82 | 88 | if ($airport_icao != '') { |
| 83 | 89 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 84 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 90 | + if ($globalDebug) { |
|
| 91 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 92 | + } |
|
| 85 | 93 | } |
| 86 | 94 | } |
| 87 | 95 | } |
@@ -109,7 +117,9 @@ discard block |
||
| 109 | 117 | |
| 110 | 118 | public function checkAll() { |
| 111 | 119 | global $globalDebug; |
| 112 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 120 | + if ($globalDebug) { |
|
| 121 | + echo "Update last seen flights data...\n"; |
|
| 122 | + } |
|
| 113 | 123 | foreach ($this->all_flights as $key => $flight) { |
| 114 | 124 | if (isset($this->all_flights[$key]['id'])) { |
| 115 | 125 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -122,24 +132,32 @@ discard block |
||
| 122 | 132 | |
| 123 | 133 | public function arrival($key) { |
| 124 | 134 | global $globalClosestMinDist, $globalDebug; |
| 125 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 135 | + if ($globalDebug) { |
|
| 136 | + echo 'Update arrival...'."\n"; |
|
| 137 | + } |
|
| 126 | 138 | $Spotter = new Spotter($this->db); |
| 127 | 139 | $airport_icao = ''; |
| 128 | 140 | $airport_time = ''; |
| 129 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 141 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 142 | + $globalClosestMinDist = 50; |
|
| 143 | + } |
|
| 130 | 144 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 131 | 145 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 132 | 146 | if (isset($closestAirports[0])) { |
| 133 | 147 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 134 | 148 | $airport_icao = $closestAirports[0]['icao']; |
| 135 | 149 | $airport_time = $this->all_flights[$key]['datetime']; |
| 136 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 152 | + } |
|
| 137 | 153 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 138 | 154 | foreach ($closestAirports as $airport) { |
| 139 | 155 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 140 | 156 | $airport_icao = $airport['icao']; |
| 141 | 157 | $airport_time = $this->all_flights[$key]['datetime']; |
| 142 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 158 | + if ($globalDebug) { |
|
| 159 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 160 | + } |
|
| 143 | 161 | break; |
| 144 | 162 | } |
| 145 | 163 | } |
@@ -147,14 +165,20 @@ discard block |
||
| 147 | 165 | $airport_icao = $closestAirports[0]['icao']; |
| 148 | 166 | $airport_time = $this->all_flights[$key]['datetime']; |
| 149 | 167 | } else { |
| 150 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 168 | + if ($globalDebug) { |
|
| 169 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 170 | + } |
|
| 151 | 171 | } |
| 152 | 172 | } else { |
| 153 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 173 | + if ($globalDebug) { |
|
| 174 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 175 | + } |
|
| 154 | 176 | } |
| 155 | 177 | |
| 156 | 178 | } else { |
| 157 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 179 | + if ($globalDebug) { |
|
| 180 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 181 | + } |
|
| 158 | 182 | } |
| 159 | 183 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 160 | 184 | } |
@@ -164,12 +188,16 @@ discard block |
||
| 164 | 188 | public function del() { |
| 165 | 189 | global $globalDebug; |
| 166 | 190 | // Delete old infos |
| 167 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 191 | + if ($globalDebug) { |
|
| 192 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 193 | + } |
|
| 168 | 194 | foreach ($this->all_flights as $key => $flight) { |
| 169 | 195 | if (isset($flight['lastupdate'])) { |
| 170 | 196 | if ($flight['lastupdate'] < (time()-3000)) { |
| 171 | 197 | if (isset($this->all_flights[$key]['id'])) { |
| 172 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 198 | + if ($globalDebug) { |
|
| 199 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 200 | + } |
|
| 173 | 201 | /* |
| 174 | 202 | $SpotterLive = new SpotterLive(); |
| 175 | 203 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -179,7 +207,9 @@ discard block |
||
| 179 | 207 | $Spotter = new Spotter($this->db); |
| 180 | 208 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 181 | 209 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 182 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 210 | + if ($globalDebug && $result != 'success') { |
|
| 211 | + echo '!!! ERROR : '.$result."\n"; |
|
| 212 | + } |
|
| 183 | 213 | } |
| 184 | 214 | // Put in archive |
| 185 | 215 | // $Spotter->db = null; |
@@ -193,8 +223,10 @@ discard block |
||
| 193 | 223 | public function add($line) { |
| 194 | 224 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM; |
| 195 | 225 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 196 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 197 | -/* |
|
| 226 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 227 | + $globalCoordMinChange = '0.02'; |
|
| 228 | + } |
|
| 229 | + /* |
|
| 198 | 230 | $Spotter = new Spotter(); |
| 199 | 231 | $dbc = $Spotter->db; |
| 200 | 232 | $SpotterLive = new SpotterLive($dbc); |
@@ -222,11 +254,15 @@ discard block |
||
| 222 | 254 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 223 | 255 | $current_date = date('Y-m-d'); |
| 224 | 256 | $source = $line['source_name']; |
| 225 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 257 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 258 | + $source = $line['format_source']; |
|
| 259 | + } |
|
| 226 | 260 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 227 | 261 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 228 | 262 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 229 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 263 | + } else { |
|
| 264 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 265 | + } |
|
| 230 | 266 | } |
| 231 | 267 | |
| 232 | 268 | /* |
@@ -242,8 +278,11 @@ discard block |
||
| 242 | 278 | //$this->db = $dbc; |
| 243 | 279 | |
| 244 | 280 | $hex = trim($line['hex']); |
| 245 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 246 | - else $id = trim($line['id']); |
|
| 281 | + if (!isset($line['id'])) { |
|
| 282 | + $id = trim($line['hex']); |
|
| 283 | + } else { |
|
| 284 | + $id = trim($line['id']); |
|
| 285 | + } |
|
| 247 | 286 | |
| 248 | 287 | //print_r($this->all_flights); |
| 249 | 288 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -258,13 +297,20 @@ discard block |
||
| 258 | 297 | $Spotter = new Spotter($this->db); |
| 259 | 298 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
| 260 | 299 | $Spotter->db = null; |
| 261 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 300 | + if ($globalDebugTimeElapsed) { |
|
| 301 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 302 | + } |
|
| 262 | 303 | |
| 263 | 304 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
| 264 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 265 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 266 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 267 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 305 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 306 | + $aircraft_icao = 'GLID'; |
|
| 307 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 308 | + $aircraft_icao = 'UHEL'; |
|
| 309 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 310 | + $aircraft_icao = 'TOWPLANE'; |
|
| 311 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 312 | + $aircraft_icao = 'POWAIRC'; |
|
| 313 | + } |
|
| 268 | 314 | } |
| 269 | 315 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
| 270 | 316 | } else if (isset($line['aircraft_name'])) { |
@@ -272,28 +318,44 @@ discard block |
||
| 272 | 318 | $Spotter = new Spotter($this->db); |
| 273 | 319 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 274 | 320 | $Spotter->db = null; |
| 275 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 276 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 277 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 321 | + if ($aircraft_icao != '') { |
|
| 322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 323 | + } else { |
|
| 324 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 325 | + } |
|
| 326 | + } else { |
|
| 327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 328 | + } |
|
| 278 | 329 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false)); |
| 279 | 330 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
| 280 | 331 | if (!isset($line['id'])) { |
| 281 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 282 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 332 | + if (!isset($globalDaemon)) { |
|
| 333 | + $globalDaemon = TRUE; |
|
| 334 | + } |
|
| 335 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 283 | 336 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 284 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 337 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 339 | + } |
|
| 285 | 340 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 286 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 341 | + } else { |
|
| 342 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 343 | + } |
|
| 287 | 344 | |
| 288 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
| 347 | + } |
|
| 289 | 348 | } |
| 290 | 349 | |
| 291 | 350 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 292 | 351 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 293 | 352 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 294 | 353 | } else { |
| 295 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 296 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 354 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 355 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 356 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 357 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 358 | + } |
|
| 297 | 359 | /* |
| 298 | 360 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 299 | 361 | print_r($this->all_flights[$id]); |
@@ -301,7 +363,9 @@ discard block |
||
| 301 | 363 | */ |
| 302 | 364 | return ''; |
| 303 | 365 | } |
| 304 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 366 | + } else { |
|
| 367 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 368 | + } |
|
| 305 | 369 | |
| 306 | 370 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 307 | 371 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -322,15 +386,25 @@ discard block |
||
| 322 | 386 | $timeelapsed = microtime(true); |
| 323 | 387 | $Spotter = new Spotter($this->db); |
| 324 | 388 | $fromsource = NULL; |
| 325 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 326 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 327 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 328 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 329 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 389 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 390 | + $fromsource = $globalAirlinesSource; |
|
| 391 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 392 | + $fromsource = 'vatsim'; |
|
| 393 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 394 | + $fromsource = 'ivao'; |
|
| 395 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 396 | + $fromsource = 'vatsim'; |
|
| 397 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 398 | + $fromsource = 'ivao'; |
|
| 399 | + } |
|
| 330 | 400 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
| 331 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 401 | + if ($globalDebug && $result != 'success') { |
|
| 402 | + echo '!!! ERROR : '.$result."\n"; |
|
| 403 | + } |
|
| 332 | 404 | $Spotter->db = null; |
| 333 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 405 | + if ($globalDebugTimeElapsed) { |
|
| 406 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 407 | + } |
|
| 334 | 408 | } |
| 335 | 409 | |
| 336 | 410 | /* |
@@ -341,7 +415,9 @@ discard block |
||
| 341 | 415 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 342 | 416 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 343 | 417 | */ |
| 344 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 418 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 419 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 420 | + } |
|
| 345 | 421 | |
| 346 | 422 | //$putinarchive = true; |
| 347 | 423 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -358,7 +434,9 @@ discard block |
||
| 358 | 434 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 359 | 435 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 360 | 436 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
| 361 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 437 | + if ($globalDebugTimeElapsed) { |
|
| 438 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 439 | + } |
|
| 362 | 440 | |
| 363 | 441 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 364 | 442 | $timeelapsed = microtime(true); |
@@ -371,7 +449,9 @@ discard block |
||
| 371 | 449 | $Translation->db = null; |
| 372 | 450 | } |
| 373 | 451 | $Spotter->db = null; |
| 374 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 452 | + if ($globalDebugTimeElapsed) { |
|
| 453 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 454 | + } |
|
| 375 | 455 | |
| 376 | 456 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 377 | 457 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -380,9 +460,13 @@ discard block |
||
| 380 | 460 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
| 381 | 461 | } |
| 382 | 462 | } |
| 383 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 463 | + if (!isset($globalFork)) { |
|
| 464 | + $globalFork = TRUE; |
|
| 465 | + } |
|
| 384 | 466 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 385 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 467 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 468 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 469 | + } |
|
| 386 | 470 | } |
| 387 | 471 | } |
| 388 | 472 | } |
@@ -398,16 +482,23 @@ discard block |
||
| 398 | 482 | // use datetime |
| 399 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 400 | 484 | $speed = $speed*3.6; |
| 401 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 402 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 485 | + if ($speed < 1000) { |
|
| 486 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 487 | + } |
|
| 488 | + if ($globalDebug) { |
|
| 489 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 490 | + } |
|
| 403 | 491 | } |
| 404 | 492 | } |
| 405 | 493 | |
| 406 | 494 | |
| 407 | 495 | |
| 408 | 496 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 409 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 410 | - else unset($timediff); |
|
| 497 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 498 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 499 | + } else { |
|
| 500 | + unset($timediff); |
|
| 501 | + } |
|
| 411 | 502 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
| 412 | 503 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
| 413 | 504 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -420,9 +511,13 @@ discard block |
||
| 420 | 511 | $timeelapsed = microtime(true); |
| 421 | 512 | $Spotter = new Spotter($this->db); |
| 422 | 513 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 423 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 514 | + if (!empty($all_country)) { |
|
| 515 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 516 | + } |
|
| 424 | 517 | $Spotter->db = null; |
| 425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 518 | + if ($globalDebugTimeElapsed) { |
|
| 519 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 520 | + } |
|
| 426 | 521 | $this->tmd = 0; |
| 427 | 522 | //echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 428 | 523 | //$putinarchive = true; |
@@ -437,7 +532,9 @@ discard block |
||
| 437 | 532 | |
| 438 | 533 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 439 | 534 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 440 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
| 535 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
| 536 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
| 537 | + } |
|
| 441 | 538 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 442 | 539 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 443 | 540 | $dataFound = true; |
@@ -459,9 +556,13 @@ discard block |
||
| 459 | 556 | */ |
| 460 | 557 | } |
| 461 | 558 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 462 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 559 | + if ($line['longitude'] > 180) { |
|
| 560 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 561 | + } |
|
| 463 | 562 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 464 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
| 563 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
| 564 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
| 565 | + } |
|
| 465 | 566 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 466 | 567 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 467 | 568 | $dataFound = true; |
@@ -492,7 +593,9 @@ discard block |
||
| 492 | 593 | } |
| 493 | 594 | } |
| 494 | 595 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 495 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 596 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 597 | + $dataFound = true; |
|
| 598 | + } |
|
| 496 | 599 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 497 | 600 | } |
| 498 | 601 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -514,11 +617,17 @@ discard block |
||
| 514 | 617 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 515 | 618 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 516 | 619 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 517 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 518 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 519 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 620 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
| 621 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 622 | + } elseif (isset($line['id'])) { |
|
| 623 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 624 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 625 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 626 | + } |
|
| 627 | + } |
|
| 628 | + if ($line['ground'] != 1) { |
|
| 629 | + $line['ground'] = 0; |
|
| 520 | 630 | } |
| 521 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 522 | 631 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 523 | 632 | //$dataFound = true; |
| 524 | 633 | } |
@@ -526,28 +635,40 @@ discard block |
||
| 526 | 635 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 527 | 636 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 528 | 637 | $highlight = ''; |
| 529 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 530 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 531 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 638 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 639 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 640 | + } |
|
| 641 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 642 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 643 | + } |
|
| 644 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 645 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 646 | + } |
|
| 532 | 647 | if ($highlight != '') { |
| 533 | 648 | $timeelapsed = microtime(true); |
| 534 | 649 | $Spotter = new Spotter($this->db); |
| 535 | 650 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 536 | 651 | $Spotter->db = null; |
| 537 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 652 | + if ($globalDebugTimeElapsed) { |
|
| 653 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 654 | + } |
|
| 538 | 655 | |
| 539 | 656 | $this->all_flights[$id]['putinarchive'] = true; |
| 540 | 657 | //$putinarchive = true; |
| 541 | 658 | //$highlight = ''; |
| 542 | 659 | } |
| 543 | 660 | |
| 544 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 661 | + } else { |
|
| 662 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 663 | + } |
|
| 545 | 664 | //$dataFound = true; |
| 546 | 665 | } |
| 547 | 666 | |
| 548 | 667 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 549 | 668 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 550 | - if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
| 669 | + if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
| 670 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 671 | + } |
|
| 551 | 672 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 552 | 673 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 553 | 674 | //$dataFound = true; |
@@ -559,21 +680,30 @@ discard block |
||
| 559 | 680 | } |
| 560 | 681 | |
| 561 | 682 | if (isset($line['heading']) && $line['heading'] != '') { |
| 562 | - if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
| 683 | + if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
| 684 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 685 | + } |
|
| 563 | 686 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 564 | 687 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 565 | 688 | //$dataFound = true; |
| 566 | 689 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 567 | 690 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 568 | 691 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 569 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
| 570 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 692 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
| 693 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 694 | + } |
|
| 695 | + if ($globalDebug) { |
|
| 696 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 697 | + } |
|
| 571 | 698 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 572 | 699 | // If not enough messages and ACARS set heading to 0 |
| 573 | 700 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 574 | 701 | } |
| 575 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 576 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 702 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 703 | + $dataFound = false; |
|
| 704 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 705 | + $dataFound = false; |
|
| 706 | + } |
|
| 577 | 707 | |
| 578 | 708 | // print_r($this->all_flights[$id]); |
| 579 | 709 | //gets the callsign from the last hour |
@@ -587,23 +717,36 @@ discard block |
||
| 587 | 717 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 588 | 718 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 589 | 719 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 590 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 720 | + if ($globalDebug) { |
|
| 721 | + echo "Check if aircraft is already in DB..."; |
|
| 722 | + } |
|
| 591 | 723 | $timeelapsed = microtime(true); |
| 592 | 724 | $SpotterLive = new SpotterLive($this->db); |
| 593 | 725 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
| 594 | 726 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 595 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 727 | + if ($globalDebugTimeElapsed) { |
|
| 728 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 729 | + } |
|
| 596 | 730 | } elseif (isset($line['id'])) { |
| 597 | 731 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 598 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 732 | + if ($globalDebugTimeElapsed) { |
|
| 733 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 734 | + } |
|
| 599 | 735 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 600 | 736 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 601 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 602 | - } else $recent_ident = ''; |
|
| 737 | + if ($globalDebugTimeElapsed) { |
|
| 738 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 739 | + } |
|
| 740 | + } else { |
|
| 741 | + $recent_ident = ''; |
|
| 742 | + } |
|
| 603 | 743 | $SpotterLive->db=null; |
| 604 | 744 | |
| 605 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 606 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 745 | + if ($globalDebug && $recent_ident == '') { |
|
| 746 | + echo " Not in DB.\n"; |
|
| 747 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 748 | + echo " Already in DB.\n"; |
|
| 749 | + } |
|
| 607 | 750 | } else { |
| 608 | 751 | $recent_ident = ''; |
| 609 | 752 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -611,7 +754,9 @@ discard block |
||
| 611 | 754 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 612 | 755 | if($recent_ident == "") |
| 613 | 756 | { |
| 614 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 757 | + if ($globalDebug) { |
|
| 758 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 759 | + } |
|
| 615 | 760 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 616 | 761 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 617 | 762 | //adds the spotter data for the archive |
@@ -655,26 +800,44 @@ discard block |
||
| 655 | 800 | |
| 656 | 801 | if (!$ignoreImport) { |
| 657 | 802 | $highlight = ''; |
| 658 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 659 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 660 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 661 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 803 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 804 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 805 | + } |
|
| 806 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 807 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 808 | + } |
|
| 809 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 810 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 811 | + } |
|
| 812 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 813 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 814 | + } |
|
| 662 | 815 | $timeelapsed = microtime(true); |
| 663 | 816 | $Spotter = new Spotter($this->db); |
| 664 | 817 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
| 665 | 818 | $Spotter->db = null; |
| 666 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 667 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 819 | + if ($globalDebug && isset($result)) { |
|
| 820 | + echo $result."\n"; |
|
| 821 | + } |
|
| 822 | + if ($globalDebugTimeElapsed) { |
|
| 823 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 824 | + } |
|
| 668 | 825 | |
| 669 | 826 | // Add source stat in DB |
| 670 | 827 | $Stats = new Stats($this->db); |
| 671 | 828 | if (!empty($this->stats)) { |
| 672 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 829 | + if ($globalDebug) { |
|
| 830 | + echo 'Add source stats : '; |
|
| 831 | + } |
|
| 673 | 832 | foreach($this->stats as $date => $data) { |
| 674 | 833 | foreach($data as $source => $sourced) { |
| 675 | 834 | //print_r($sourced); |
| 676 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 677 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 835 | + if (isset($sourced['polar'])) { |
|
| 836 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 837 | + } |
|
| 838 | + if (isset($sourced['hist'])) { |
|
| 839 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 840 | + } |
|
| 678 | 841 | if (isset($sourced['msg'])) { |
| 679 | 842 | if (time() - $sourced['msg']['date'] > 10) { |
| 680 | 843 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -687,13 +850,17 @@ discard block |
||
| 687 | 850 | unset($this->stats[$date]); |
| 688 | 851 | } |
| 689 | 852 | } |
| 690 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 853 | + if ($globalDebug) { |
|
| 854 | + echo 'Done'."\n"; |
|
| 855 | + } |
|
| 691 | 856 | |
| 692 | 857 | } |
| 693 | 858 | $Stats->db = null; |
| 694 | 859 | |
| 695 | 860 | $this->del(); |
| 696 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 861 | + } elseif ($globalDebug) { |
|
| 862 | + echo 'Ignore data'."\n"; |
|
| 863 | + } |
|
| 697 | 864 | //$ignoreImport = false; |
| 698 | 865 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 699 | 866 | //print_r($this->all_flights[$id]); |
@@ -710,12 +877,16 @@ discard block |
||
| 710 | 877 | */ |
| 711 | 878 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 712 | 879 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 713 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 880 | + if ($globalDebug) { |
|
| 881 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 882 | + } |
|
| 714 | 883 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 715 | 884 | $SpotterLive = new SpotterLive($this->db); |
| 716 | 885 | $SpotterLive->deleteLiveSpotterData(); |
| 717 | 886 | $SpotterLive->db=null; |
| 718 | - if ($globalDebug) echo " Done\n"; |
|
| 887 | + if ($globalDebug) { |
|
| 888 | + echo " Done\n"; |
|
| 889 | + } |
|
| 719 | 890 | $this->last_delete = time(); |
| 720 | 891 | } |
| 721 | 892 | } else { |
@@ -738,11 +909,17 @@ discard block |
||
| 738 | 909 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
| 739 | 910 | if ($globalDebug) { |
| 740 | 911 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 741 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 742 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 912 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 913 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 914 | + } else { |
|
| 915 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 916 | + } |
|
| 743 | 917 | } else { |
| 744 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 745 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 918 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 919 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 920 | + } else { |
|
| 921 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 922 | + } |
|
| 746 | 923 | } |
| 747 | 924 | } |
| 748 | 925 | $ignoreImport = false; |
@@ -788,19 +965,25 @@ discard block |
||
| 788 | 965 | |
| 789 | 966 | if (!$ignoreImport) { |
| 790 | 967 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 791 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 968 | + if ($globalDebug) { |
|
| 969 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 970 | + } |
|
| 792 | 971 | $timeelapsed = microtime(true); |
| 793 | 972 | $SpotterLive = new SpotterLive($this->db); |
| 794 | 973 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 795 | 974 | $SpotterLive->db = null; |
| 796 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 975 | + if ($globalDebugTimeElapsed) { |
|
| 976 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 977 | + } |
|
| 797 | 978 | |
| 798 | 979 | // Put statistics in $this->stats variable |
| 799 | 980 | //if ($line['format_source'] != 'aprs') { |
| 800 | 981 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 801 | 982 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs') { |
| 802 | 983 | $source = $this->all_flights[$id]['source_name']; |
| 803 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 984 | + if ($source == '') { |
|
| 985 | + $source = $this->all_flights[$id]['format_source']; |
|
| 986 | + } |
|
| 804 | 987 | if (!isset($this->source_location[$source])) { |
| 805 | 988 | $Location = new Source(); |
| 806 | 989 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -821,7 +1004,9 @@ discard block |
||
| 821 | 1004 | $stats_heading = round($stats_heading/22.5); |
| 822 | 1005 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 823 | 1006 | $current_date = date('Y-m-d'); |
| 824 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1007 | + if ($stats_heading == 16) { |
|
| 1008 | + $stats_heading = 0; |
|
| 1009 | + } |
|
| 825 | 1010 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 826 | 1011 | for ($i=0;$i<=15;$i++) { |
| 827 | 1012 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -839,7 +1024,9 @@ discard block |
||
| 839 | 1024 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 840 | 1025 | end($this->stats[$current_date][$source]['hist']); |
| 841 | 1026 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 842 | - } else $mini = 0; |
|
| 1027 | + } else { |
|
| 1028 | + $mini = 0; |
|
| 1029 | + } |
|
| 843 | 1030 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 844 | 1031 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 845 | 1032 | } |
@@ -850,20 +1037,30 @@ discard block |
||
| 850 | 1037 | } |
| 851 | 1038 | |
| 852 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
| 853 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1040 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1041 | + $send = true; |
|
| 1042 | + } |
|
| 854 | 1043 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 855 | - if ($globalDebug) echo $result."\n"; |
|
| 856 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1044 | + if ($globalDebug) { |
|
| 1045 | + echo $result."\n"; |
|
| 1046 | + } |
|
| 1047 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1048 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1049 | + } |
|
| 857 | 1050 | //$this->del(); |
| 858 | 1051 | |
| 859 | 1052 | |
| 860 | 1053 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 861 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1054 | + if ($globalDebug) { |
|
| 1055 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1056 | + } |
|
| 862 | 1057 | $SpotterLive = new SpotterLive($this->db); |
| 863 | 1058 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 864 | 1059 | $SpotterLive->db = null; |
| 865 | 1060 | //SpotterLive->deleteLiveSpotterData(); |
| 866 | - if ($globalDebug) echo " Done\n"; |
|
| 1061 | + if ($globalDebug) { |
|
| 1062 | + echo " Done\n"; |
|
| 1063 | + } |
|
| 867 | 1064 | $this->last_delete_hourly = time(); |
| 868 | 1065 | } |
| 869 | 1066 | |
@@ -871,7 +1068,9 @@ discard block |
||
| 871 | 1068 | //$ignoreImport = false; |
| 872 | 1069 | } |
| 873 | 1070 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 874 | - if ($send) return $this->all_flights[$id]; |
|
| 1071 | + if ($send) { |
|
| 1072 | + return $this->all_flights[$id]; |
|
| 1073 | + } |
|
| 875 | 1074 | } |
| 876 | 1075 | } |
| 877 | 1076 | } |
@@ -64,8 +64,11 @@ discard block |
||
| 64 | 64 | $globalDBSname = $globalDBname; |
| 65 | 65 | $globalDBSuser = $globalDBuser; |
| 66 | 66 | $globalDBSpass = $globalDBpass; |
| 67 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
| 68 | - else $globalDBSport = $globalDBport; |
|
| 67 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
| 68 | + $globalDBSport = 3306; |
|
| 69 | + } else { |
|
| 70 | + $globalDBSport = $globalDBport; |
|
| 71 | + } |
|
| 69 | 72 | } else { |
| 70 | 73 | $DBname = 'default'; |
| 71 | 74 | $globalDBSdriver = $globalDBdriver; |
@@ -73,8 +76,11 @@ discard block |
||
| 73 | 76 | $globalDBSname = $globalDBname; |
| 74 | 77 | $globalDBSuser = $user; |
| 75 | 78 | $globalDBSpass = $pass; |
| 76 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
| 77 | - else $globalDBSport = $globalDBport; |
|
| 79 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
| 80 | + $globalDBSport = 3306; |
|
| 81 | + } else { |
|
| 82 | + $globalDBSport = $globalDBport; |
|
| 83 | + } |
|
| 78 | 84 | } |
| 79 | 85 | } else { |
| 80 | 86 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -82,11 +88,16 @@ discard block |
||
| 82 | 88 | $globalDBSname = $globalDB[$DBname]['name']; |
| 83 | 89 | $globalDBSuser = $globalDB[$DBname]['user']; |
| 84 | 90 | $globalDBSpass = $globalDB[$DBname]['pass']; |
| 85 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
| 86 | - else $globalDBSport = 3306; |
|
| 91 | + if (isset($globalDB[$DBname]['port'])) { |
|
| 92 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
| 93 | + } else { |
|
| 94 | + $globalDBSport = 3306; |
|
| 95 | + } |
|
| 87 | 96 | } |
| 88 | 97 | // Set number of try to connect to DB |
| 89 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
| 98 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
| 99 | + $globalDBretry = 5; |
|
| 100 | + } |
|
| 90 | 101 | $i = 0; |
| 91 | 102 | while (true) { |
| 92 | 103 | try { |
@@ -95,10 +106,16 @@ discard block |
||
| 95 | 106 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 96 | 107 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 97 | 108 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 98 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 99 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 100 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 101 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 109 | + if (!isset($globalDBTimeOut)) { |
|
| 110 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 111 | + } else { |
|
| 112 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 113 | + } |
|
| 114 | + if (!isset($globalDBPersistent)) { |
|
| 115 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 116 | + } else { |
|
| 117 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 118 | + } |
|
| 102 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 103 | 120 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 104 | 121 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -112,22 +129,34 @@ discard block |
||
| 112 | 129 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 113 | 130 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 114 | 131 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 115 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 116 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 117 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 118 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 132 | + if (!isset($globalDBTimeOut)) { |
|
| 133 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 134 | + } else { |
|
| 135 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 136 | + } |
|
| 137 | + if (!isset($globalDBPersistent)) { |
|
| 138 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 139 | + } else { |
|
| 140 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 141 | + } |
|
| 119 | 142 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 120 | 143 | } |
| 121 | 144 | break; |
| 122 | 145 | } catch(PDOException $e) { |
| 123 | 146 | $i++; |
| 124 | - if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
|
| 147 | + if (isset($globalDebug) && $globalDebug) { |
|
| 148 | + echo $e->getMessage()."\n"; |
|
| 149 | + } |
|
| 125 | 150 | //exit; |
| 126 | - if ($i > $globalDBretry) return false; |
|
| 151 | + if ($i > $globalDBretry) { |
|
| 152 | + return false; |
|
| 153 | + } |
|
| 127 | 154 | //return false; |
| 128 | 155 | } |
| 129 | 156 | } |
| 130 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
| 157 | + if ($DBname === 'default') { |
|
| 158 | + $this->db = $this->dbs['default']; |
|
| 159 | + } |
|
| 131 | 160 | return true; |
| 132 | 161 | } |
| 133 | 162 | |
@@ -139,7 +168,9 @@ discard block |
||
| 139 | 168 | } else { |
| 140 | 169 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
| 141 | 170 | } |
| 142 | - if ($this->db == NULL) return false; |
|
| 171 | + if ($this->db == NULL) { |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 143 | 174 | try { |
| 144 | 175 | //$Connection = new Connection(); |
| 145 | 176 | $results = $this->db->query($query); |
@@ -148,21 +179,28 @@ discard block |
||
| 148 | 179 | } |
| 149 | 180 | if($results->rowCount()>0) { |
| 150 | 181 | return true; |
| 182 | + } else { |
|
| 183 | + return false; |
|
| 151 | 184 | } |
| 152 | - else return false; |
|
| 153 | 185 | } |
| 154 | 186 | |
| 155 | 187 | public function connectionExists() |
| 156 | 188 | { |
| 157 | 189 | global $globalDBdriver, $globalDBCheckConnection; |
| 158 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
| 190 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 159 | 193 | $query = "SELECT 1 + 1"; |
| 160 | - if ($this->db === null) return false; |
|
| 194 | + if ($this->db === null) { |
|
| 195 | + return false; |
|
| 196 | + } |
|
| 161 | 197 | try { |
| 162 | 198 | $sum = @$this->db->query($query); |
| 163 | 199 | if ($sum instanceof \PDOStatement) { |
| 164 | 200 | $sum = $sum->fetchColumn(0); |
| 165 | - } else $sum = 0; |
|
| 201 | + } else { |
|
| 202 | + $sum = 0; |
|
| 203 | + } |
|
| 166 | 204 | if (intval($sum) !== 2) { |
| 167 | 205 | return false; |
| 168 | 206 | } |
@@ -196,8 +234,9 @@ discard block |
||
| 196 | 234 | } |
| 197 | 235 | if($results->rowCount()>0) { |
| 198 | 236 | return true; |
| 237 | + } else { |
|
| 238 | + return false; |
|
| 199 | 239 | } |
| 200 | - else return false; |
|
| 201 | 240 | } |
| 202 | 241 | |
| 203 | 242 | /* |
@@ -240,9 +279,12 @@ discard block |
||
| 240 | 279 | echo "error : ".$e->getMessage()."\n"; |
| 241 | 280 | } |
| 242 | 281 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 243 | - if ($result['nb'] > 0) return true; |
|
| 244 | - else return false; |
|
| 245 | -/* } else { |
|
| 282 | + if ($result['nb'] > 0) { |
|
| 283 | + return true; |
|
| 284 | + } else { |
|
| 285 | + return false; |
|
| 286 | + } |
|
| 287 | + /* } else { |
|
| 246 | 288 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 247 | 289 | try { |
| 248 | 290 | $results = $this->db->query($query); |
@@ -280,7 +322,9 @@ discard block |
||
| 280 | 322 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 281 | 323 | return $result['value']; |
| 282 | 324 | } |
| 283 | - } else return $version; |
|
| 325 | + } else { |
|
| 326 | + return $version; |
|
| 327 | + } |
|
| 284 | 328 | } |
| 285 | 329 | |
| 286 | 330 | /* |
@@ -288,8 +332,11 @@ discard block |
||
| 288 | 332 | * @return Boolean if latest version or not |
| 289 | 333 | */ |
| 290 | 334 | public function latest() { |
| 291 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 292 | - else return false; |
|
| 335 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
| 336 | + return true; |
|
| 337 | + } else { |
|
| 338 | + return false; |
|
| 339 | + } |
|
| 293 | 340 | } |
| 294 | 341 | |
| 295 | 342 | } |
@@ -124,45 +124,72 @@ discard block |
||
| 124 | 124 | </div> |
| 125 | 125 | <p> |
| 126 | 126 | <label for="dbhost">Database hostname</label> |
| 127 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
| 127 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
| 128 | + print $globalDBhost; |
|
| 129 | +} |
|
| 130 | +?>" /> |
|
| 128 | 131 | </p> |
| 129 | 132 | <p> |
| 130 | 133 | <label for="dbport">Database port</label> |
| 131 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
| 134 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
| 135 | + print $globalDBport; |
|
| 136 | +} |
|
| 137 | +?>" /> |
|
| 132 | 138 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
| 133 | 139 | </p> |
| 134 | 140 | <p> |
| 135 | 141 | <label for="dbname">Database name</label> |
| 136 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
| 142 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
| 143 | + print $globalDBname; |
|
| 144 | +} |
|
| 145 | +?>" /> |
|
| 137 | 146 | </p> |
| 138 | 147 | <p> |
| 139 | 148 | <label for="dbuser">Database user</label> |
| 140 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
| 149 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
| 150 | + print $globalDBuser; |
|
| 151 | +} |
|
| 152 | +?>" /> |
|
| 141 | 153 | </p> |
| 142 | 154 | <p> |
| 143 | 155 | <label for="dbuserpass">Database user password</label> |
| 144 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
| 156 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
| 157 | + print $globalDBpass; |
|
| 158 | +} |
|
| 159 | +?>" /> |
|
| 145 | 160 | </p> |
| 146 | 161 | </fieldset> |
| 147 | 162 | <fieldset id="site"> |
| 148 | 163 | <legend>Site configuration</legend> |
| 149 | 164 | <p> |
| 150 | 165 | <label for="sitename">Site name</label> |
| 151 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
| 166 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
| 167 | + print $globalName; |
|
| 168 | +} |
|
| 169 | +?>" /> |
|
| 152 | 170 | </p> |
| 153 | 171 | <p> |
| 154 | 172 | <label for="siteurl">Site directory</label> |
| 155 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
| 173 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
| 174 | + print $globalURL; |
|
| 175 | +} |
|
| 176 | +?>" /> |
|
| 156 | 177 | <p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
| 157 | 178 | </p> |
| 158 | 179 | <p> |
| 159 | 180 | <label for="timezone">Timezone</label> |
| 160 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
| 181 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
| 182 | + print $globalTimezone; |
|
| 183 | +} |
|
| 184 | +?>" /> |
|
| 161 | 185 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
| 162 | 186 | </p> |
| 163 | 187 | <p> |
| 164 | 188 | <label for="language">Language</label> |
| 165 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
| 189 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
| 190 | + print $globalLanguage; |
|
| 191 | +} |
|
| 192 | +?>" /> |
|
| 166 | 193 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
| 167 | 194 | </p> |
| 168 | 195 | </fieldset> |
@@ -183,11 +210,17 @@ discard block |
||
| 183 | 210 | <div id="mapbox_data"> |
| 184 | 211 | <p> |
| 185 | 212 | <label for="mapboxid">Mapbox id</label> |
| 186 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
| 213 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
| 214 | + print $globalMapboxId; |
|
| 215 | +} |
|
| 216 | +?>" /> |
|
| 187 | 217 | </p> |
| 188 | 218 | <p> |
| 189 | 219 | <label for="mapboxtoken">Mapbox token</label> |
| 190 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
| 220 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
| 221 | + print $globalMapboxToken; |
|
| 222 | +} |
|
| 223 | +?>" /> |
|
| 191 | 224 | </p> |
| 192 | 225 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
| 193 | 226 | </div> |
@@ -195,7 +228,10 @@ discard block |
||
| 195 | 228 | <div id="google_data"> |
| 196 | 229 | <p> |
| 197 | 230 | <label for="googlekey">Google API key</label> |
| 198 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
| 231 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
| 232 | + print $globalGoogleAPIKey; |
|
| 233 | +} |
|
| 234 | +?>" /> |
|
| 199 | 235 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
| 200 | 236 | </p> |
| 201 | 237 | </div> |
@@ -203,7 +239,10 @@ discard block |
||
| 203 | 239 | <div id="bing_data"> |
| 204 | 240 | <p> |
| 205 | 241 | <label for="bingkey">Bing Map key</label> |
| 206 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
| 242 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
| 243 | + print $globalBingMapKey; |
|
| 244 | +} |
|
| 245 | +?>" /> |
|
| 207 | 246 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
| 208 | 247 | </p> |
| 209 | 248 | </div> |
@@ -211,7 +250,10 @@ discard block |
||
| 211 | 250 | <div id="mapquest_data"> |
| 212 | 251 | <p> |
| 213 | 252 | <label for="mapquestkey">MapQuest key</label> |
| 214 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
| 253 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
| 254 | + print $globalMapQuestKey; |
|
| 255 | +} |
|
| 256 | +?>" /> |
|
| 215 | 257 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
| 216 | 258 | </p> |
| 217 | 259 | </div> |
@@ -219,11 +261,17 @@ discard block |
||
| 219 | 261 | <div id="here_data"> |
| 220 | 262 | <p> |
| 221 | 263 | <label for="hereappid">Here App_Id</label> |
| 222 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
| 264 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
| 265 | + print $globalHereappId; |
|
| 266 | +} |
|
| 267 | +?>" /> |
|
| 223 | 268 | </p> |
| 224 | 269 | <p> |
| 225 | 270 | <label for="hereappcode">Here App_Code</label> |
| 226 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
| 271 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
| 272 | + print $globalHereappCode; |
|
| 273 | +} |
|
| 274 | +?>" /> |
|
| 227 | 275 | </p> |
| 228 | 276 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
| 229 | 277 | </div> |
@@ -232,42 +280,86 @@ discard block |
||
| 232 | 280 | <legend>Coverage area</legend> |
| 233 | 281 | <p> |
| 234 | 282 | <label for="latitudemax">The maximum latitude (north)</label> |
| 235 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
| 283 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
| 284 | + print $globalLatitudeMax; |
|
| 285 | +} |
|
| 286 | +?>" /> |
|
| 236 | 287 | </p> |
| 237 | 288 | <p> |
| 238 | 289 | <label for="latitudemin">The minimum latitude (south)</label> |
| 239 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
| 290 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
| 291 | + print $globalLatitudeMin; |
|
| 292 | +} |
|
| 293 | +?>" /> |
|
| 240 | 294 | </p> |
| 241 | 295 | <p> |
| 242 | 296 | <label for="longitudemax">The maximum longitude (west)</label> |
| 243 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
| 297 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
| 298 | + print $globalLongitudeMax; |
|
| 299 | +} |
|
| 300 | +?>" /> |
|
| 244 | 301 | </p> |
| 245 | 302 | <p> |
| 246 | 303 | <label for="longitudemin">The minimum longitude (east)</label> |
| 247 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
| 304 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
| 305 | + print $globalLongitudeMin; |
|
| 306 | +} |
|
| 307 | +?>" /> |
|
| 248 | 308 | </p> |
| 249 | 309 | <p> |
| 250 | 310 | <label for="latitudecenter">The latitude center</label> |
| 251 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
| 311 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
| 312 | + print $globalCenterLatitude; |
|
| 313 | +} |
|
| 314 | +?>" /> |
|
| 252 | 315 | </p> |
| 253 | 316 | <p> |
| 254 | 317 | <label for="longitudecenter">The longitude center</label> |
| 255 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
| 318 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
| 319 | + print $globalCenterLongitude; |
|
| 320 | +} |
|
| 321 | +?>" /> |
|
| 256 | 322 | </p> |
| 257 | 323 | <p> |
| 258 | 324 | <label for="livezoom">Default Zoom on live map</label> |
| 259 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
| 325 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
| 326 | + print $globalLiveZoom; |
|
| 327 | +} else { |
|
| 328 | + print '9'; |
|
| 329 | +} |
|
| 330 | +?>" /> |
|
| 260 | 331 | </p> |
| 261 | 332 | <p> |
| 262 | 333 | <label for="squawk_country">Country for squawk usage</label> |
| 263 | 334 | <select name="squawk_country" id="squawk_country"> |
| 264 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
| 265 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
| 266 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
| 267 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
| 268 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
| 269 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
| 270 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
| 335 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
| 336 | + print ' selected '; |
|
| 337 | +} |
|
| 338 | +?>>UK</option> |
|
| 339 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
| 340 | + print ' selected '; |
|
| 341 | +} |
|
| 342 | +?>>NZ</option> |
|
| 343 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
| 344 | + print ' selected '; |
|
| 345 | +} |
|
| 346 | +?>>US</option> |
|
| 347 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
| 348 | + print ' selected '; |
|
| 349 | +} |
|
| 350 | +?>>AU</option> |
|
| 351 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
| 352 | + print ' selected '; |
|
| 353 | +} |
|
| 354 | +?>>NL</option> |
|
| 355 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
| 356 | + print ' selected '; |
|
| 357 | +} |
|
| 358 | +?>>FR</option> |
|
| 359 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
| 360 | + print ' selected '; |
|
| 361 | +} |
|
| 362 | +?>>TR</option> |
|
| 271 | 363 | </select> |
| 272 | 364 | </p> |
| 273 | 365 | </fieldset> |
@@ -276,15 +368,24 @@ discard block |
||
| 276 | 368 | <p><i>Only put in DB flights that are inside a circle</i></p> |
| 277 | 369 | <p> |
| 278 | 370 | <label for="latitude">Center latitude</label> |
| 279 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
| 371 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
| 372 | + echo $globalDistanceIgnore['latitude']; |
|
| 373 | +} |
|
| 374 | +?>" /> |
|
| 280 | 375 | </p> |
| 281 | 376 | <p> |
| 282 | 377 | <label for="longitude">Center longitude</label> |
| 283 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
| 378 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
| 379 | + echo $globalDistanceIgnore['longitude']; |
|
| 380 | +} |
|
| 381 | +?>" /> |
|
| 284 | 382 | </p> |
| 285 | 383 | <p> |
| 286 | 384 | <label for="Distance">Distance (in km)</label> |
| 287 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
| 385 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
| 386 | + echo $globalDistanceIgnore['distance']; |
|
| 387 | +} |
|
| 388 | +?>" /> |
|
| 288 | 389 | </p> |
| 289 | 390 | </fieldset> |
| 290 | 391 | <fieldset id="sourceloc"> |
@@ -379,11 +480,17 @@ discard block |
||
| 379 | 480 | <div id="flightaware_data"> |
| 380 | 481 | <p> |
| 381 | 482 | <label for="flightawareusername">FlightAware username</label> |
| 382 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
| 483 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
| 484 | + print $globalFlightAwareUsername; |
|
| 485 | +} |
|
| 486 | +?>" /> |
|
| 383 | 487 | </p> |
| 384 | 488 | <p> |
| 385 | 489 | <label for="flightawarepassword">FlightAware password/API key</label> |
| 386 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
| 490 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
| 491 | + print $globalFlightAwarePassword; |
|
| 492 | +} |
|
| 493 | +?>" /> |
|
| 387 | 494 | </p> |
| 388 | 495 | </div> |
| 389 | 496 | --> |
@@ -442,25 +549,76 @@ discard block |
||
| 442 | 549 | ?> |
| 443 | 550 | <td> |
| 444 | 551 | <select name="format[]" id="format"> |
| 445 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
| 446 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
| 447 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
| 448 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
| 449 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
| 450 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
| 451 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
| 452 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option> |
|
| 453 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
| 454 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
| 455 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
| 456 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
| 457 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
| 458 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
| 459 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS over SBS-3 TCP</option> |
|
| 552 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
| 553 | + print 'selected'; |
|
| 554 | +} |
|
| 555 | +?>>Auto</option> |
|
| 556 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
| 557 | + print 'selected'; |
|
| 558 | +} |
|
| 559 | +?>>SBS</option> |
|
| 560 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
| 561 | + print 'selected'; |
|
| 562 | +} |
|
| 563 | +?>>TSV</option> |
|
| 564 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
| 565 | + print 'selected'; |
|
| 566 | +} |
|
| 567 | +?>>Raw</option> |
|
| 568 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 569 | + print 'selected'; |
|
| 570 | +} |
|
| 571 | +?>>APRS</option> |
|
| 572 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
| 573 | + print 'selected'; |
|
| 574 | +} |
|
| 575 | +?>>Radarcape deltadb.txt</option> |
|
| 576 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
| 577 | + print 'selected'; |
|
| 578 | +} |
|
| 579 | +?>>Vatsim</option> |
|
| 580 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
| 581 | + print 'selected'; |
|
| 582 | +} |
|
| 583 | +?>>Virtual Radar Server</option> |
|
| 584 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
| 585 | + print 'selected'; |
|
| 586 | +} |
|
| 587 | +?>>phpVMS</option> |
|
| 588 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
| 589 | + print 'selected'; |
|
| 590 | +} |
|
| 591 | +?>>Virtual Airlines Manager</option> |
|
| 592 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
| 593 | + print 'selected'; |
|
| 594 | +} |
|
| 595 | +?>>IVAO</option> |
|
| 596 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
| 597 | + print 'selected'; |
|
| 598 | +} |
|
| 599 | +?>>FlightGear Multiplayer</option> |
|
| 600 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
| 601 | + print 'selected'; |
|
| 602 | +} |
|
| 603 | +?>>FlightGear Singleplayer</option> |
|
| 604 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
| 605 | + print 'selected'; |
|
| 606 | +} |
|
| 607 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
| 608 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
| 609 | + print 'selected'; |
|
| 610 | +} |
|
| 611 | +?>>ACARS over SBS-3 TCP</option> |
|
| 460 | 612 | </select> |
| 461 | 613 | </td> |
| 462 | - <td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td> |
|
| 463 | - <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
| 614 | + <td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) { |
|
| 615 | + print $source['name']; |
|
| 616 | +} |
|
| 617 | +?>" /></td> |
|
| 618 | + <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
| 619 | + print 'checked'; |
|
| 620 | +} |
|
| 621 | +?> /></td> |
|
| 464 | 622 | <td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td> |
| 465 | 623 | </tr> |
| 466 | 624 | <?php |
@@ -506,11 +664,17 @@ discard block |
||
| 506 | 664 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
| 507 | 665 | <p> |
| 508 | 666 | <label for="acarshost">ACARS UDP host</label> |
| 509 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
| 667 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
| 668 | + print $globalACARSHost; |
|
| 669 | +} |
|
| 670 | +?>" /> |
|
| 510 | 671 | </p> |
| 511 | 672 | <p> |
| 512 | 673 | <label for="acarsport">ACARS UDP port</label> |
| 513 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
| 674 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
| 675 | + print $globalACARSPort; |
|
| 676 | +} |
|
| 677 | +?>" /> |
|
| 514 | 678 | </p> |
| 515 | 679 | </fieldset> |
| 516 | 680 | </div> |
@@ -585,13 +749,19 @@ discard block |
||
| 585 | 749 | <div id="schedules_options"> |
| 586 | 750 | <p> |
| 587 | 751 | <label for="britishairways">British Airways API Key</label> |
| 588 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
| 752 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) { |
|
| 753 | + print $globalBritishAirwaysKey; |
|
| 754 | +} |
|
| 755 | +?>" /> |
|
| 589 | 756 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
| 590 | 757 | </p> |
| 591 | 758 | <!-- |
| 592 | 759 | <p> |
| 593 | 760 | <label for="transavia">Transavia Test API Consumer Key</label> |
| 594 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
| 761 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
| 762 | + print $globalTransaviaKey; |
|
| 763 | +} |
|
| 764 | +?>" /> |
|
| 595 | 765 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
| 596 | 766 | </p> |
| 597 | 767 | --> |
@@ -600,10 +770,16 @@ discard block |
||
| 600 | 770 | <b>Lufthansa API Key</b> |
| 601 | 771 | <p> |
| 602 | 772 | <label for="lufthansakey">Key</label> |
| 603 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
| 773 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
| 774 | + print $globalLufthansaKey['key']; |
|
| 775 | +} |
|
| 776 | +?>" /> |
|
| 604 | 777 | </p><p> |
| 605 | 778 | <label for="lufthansasecret">Secret</label> |
| 606 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
| 779 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
| 780 | + print $globalLufthansaKey['secret']; |
|
| 781 | +} |
|
| 782 | +?>" /> |
|
| 607 | 783 | </p> |
| 608 | 784 | </div> |
| 609 | 785 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -623,7 +799,10 @@ discard block |
||
| 623 | 799 | </p> |
| 624 | 800 | <p> |
| 625 | 801 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
| 626 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
| 802 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
| 803 | + print $globalNOTAMSource; |
|
| 804 | +} |
|
| 805 | +?>" /> |
|
| 627 | 806 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
| 628 | 807 | </p> |
| 629 | 808 | <br /> |
@@ -639,14 +818,20 @@ discard block |
||
| 639 | 818 | <div id="metarsrc"> |
| 640 | 819 | <p> |
| 641 | 820 | <label for="metarsource">URL of your METAR source</label> |
| 642 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
| 821 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
| 822 | + print $globalMETARurl; |
|
| 823 | +} |
|
| 824 | +?>" /> |
|
| 643 | 825 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
| 644 | 826 | </p> |
| 645 | 827 | </div> |
| 646 | 828 | <br /> |
| 647 | 829 | <p> |
| 648 | 830 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
| 649 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
| 831 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
| 832 | + print $globalBitlyAccessToken; |
|
| 833 | +} |
|
| 834 | +?>" /> |
|
| 650 | 835 | </p> |
| 651 | 836 | <br /> |
| 652 | 837 | <p> |
@@ -660,7 +845,12 @@ discard block |
||
| 660 | 845 | </p> |
| 661 | 846 | <p> |
| 662 | 847 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
| 663 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" /> |
|
| 848 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
| 849 | + print $globalArchiveMonths; |
|
| 850 | +} else { |
|
| 851 | + echo '0'; |
|
| 852 | +} |
|
| 853 | +?>" /> |
|
| 664 | 854 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
| 665 | 855 | </p> |
| 666 | 856 | <p> |
@@ -670,12 +860,22 @@ discard block |
||
| 670 | 860 | </p> |
| 671 | 861 | <p> |
| 672 | 862 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
| 673 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" /> |
|
| 863 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
| 864 | + print $globalArchiveKeepMonths; |
|
| 865 | +} else { |
|
| 866 | + echo '0'; |
|
| 867 | +} |
|
| 868 | +?>" /> |
|
| 674 | 869 | <p class="help-block">0 to disable</p> |
| 675 | 870 | </p> |
| 676 | 871 | <p> |
| 677 | 872 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
| 678 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" /> |
|
| 873 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
| 874 | + print $globalArchiveKeepTrackMonths; |
|
| 875 | +} else { |
|
| 876 | + echo '0'; |
|
| 877 | +} |
|
| 878 | +?>" /> |
|
| 679 | 879 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
| 680 | 880 | </p> |
| 681 | 881 | <br /> |
@@ -685,7 +885,12 @@ discard block |
||
| 685 | 885 | <p class="help-block">Uncheck if the script is running as cron job</p> |
| 686 | 886 | <div id="cronends"> |
| 687 | 887 | <label for="cronend">Run script for xx seconds</label> |
| 688 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
| 888 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
| 889 | + print $globalCronEnd; |
|
| 890 | +} else { |
|
| 891 | + print '0'; |
|
| 892 | +} |
|
| 893 | +?>" /> |
|
| 689 | 894 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
| 690 | 895 | </div> |
| 691 | 896 | </p> |
@@ -725,26 +930,49 @@ discard block |
||
| 725 | 930 | <br /> |
| 726 | 931 | <p> |
| 727 | 932 | <label for="refresh">Show flights detected since xxx seconds</label> |
| 728 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
| 933 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
| 934 | + echo $globalLiveInterval; |
|
| 935 | +} else { |
|
| 936 | + echo '200'; |
|
| 937 | +} |
|
| 938 | +?>" /> |
|
| 729 | 939 | </p> |
| 730 | 940 | <p> |
| 731 | 941 | <label for="maprefresh">Live map refresh (in seconds)</label> |
| 732 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
| 942 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
| 943 | + echo $globalMapRefresh; |
|
| 944 | +} else { |
|
| 945 | + echo '30'; |
|
| 946 | +} |
|
| 947 | +?>" /> |
|
| 733 | 948 | </p> |
| 734 | 949 | <p> |
| 735 | 950 | <label for="mapidle">Map idle timeout (in minutes)</label> |
| 736 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
| 951 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
| 952 | + echo $globalMapIdleTimeout; |
|
| 953 | +} else { |
|
| 954 | + echo '30'; |
|
| 955 | +} |
|
| 956 | +?>" /> |
|
| 737 | 957 | <p class="help-block">0 to disable</p> |
| 738 | 958 | </p> |
| 739 | 959 | <br /> |
| 740 | 960 | <p> |
| 741 | 961 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
| 742 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
| 962 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
| 963 | + echo $globalClosestMinDist; |
|
| 964 | +} else { |
|
| 965 | + echo '50'; |
|
| 966 | +} |
|
| 967 | +?>" /> |
|
| 743 | 968 | </p> |
| 744 | 969 | <br /> |
| 745 | 970 | <p> |
| 746 | 971 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
| 747 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
| 972 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
| 973 | + echo $globalAircraftSize; |
|
| 974 | +} |
|
| 975 | +?>" /> |
|
| 748 | 976 | </p> |
| 749 | 977 | <br /> |
| 750 | 978 | <p> |
@@ -752,7 +980,12 @@ discard block |
||
| 752 | 980 | if (extension_loaded('gd') && function_exists('gd_info')) { |
| 753 | 981 | ?> |
| 754 | 982 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
| 755 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
| 983 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
| 984 | + echo $globalAircraftIconColor; |
|
| 985 | +} else { |
|
| 986 | + echo '1a3151'; |
|
| 987 | +} |
|
| 988 | +?>" /> |
|
| 756 | 989 | <?php |
| 757 | 990 | if (!is_writable('../cache')) { |
| 758 | 991 | ?> |
@@ -770,8 +1003,18 @@ discard block |
||
| 770 | 1003 | <p> |
| 771 | 1004 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
| 772 | 1005 | <div class="range"> |
| 773 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
| 774 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
| 1006 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
| 1007 | + echo $globalAirportZoom; |
|
| 1008 | +} else { |
|
| 1009 | + echo '7'; |
|
| 1010 | +} |
|
| 1011 | +?>" /> |
|
| 1012 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
| 1013 | + echo $globalAirportZoom; |
|
| 1014 | +} else { |
|
| 1015 | + echo '7'; |
|
| 1016 | +} |
|
| 1017 | +?></output> |
|
| 775 | 1018 | </div> |
| 776 | 1019 | </p> |
| 777 | 1020 | </fieldset> |
@@ -799,8 +1042,12 @@ discard block |
||
| 799 | 1042 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
| 800 | 1043 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
| 801 | 1044 | |
| 802 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
| 803 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1045 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
| 1046 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
| 1047 | + } |
|
| 1048 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
| 1049 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1050 | + } |
|
| 804 | 1051 | |
| 805 | 1052 | $_SESSION['database_root'] = $dbroot; |
| 806 | 1053 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -867,15 +1114,23 @@ discard block |
||
| 867 | 1114 | $source_city = $_POST['source_city']; |
| 868 | 1115 | $source_country = $_POST['source_country']; |
| 869 | 1116 | $source_ref = $_POST['source_ref']; |
| 870 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
| 871 | - else $source_id = array(); |
|
| 1117 | + if (isset($source_id)) { |
|
| 1118 | + $source_id = $_POST['source_id']; |
|
| 1119 | + } else { |
|
| 1120 | + $source_id = array(); |
|
| 1121 | + } |
|
| 872 | 1122 | |
| 873 | 1123 | $sources = array(); |
| 874 | 1124 | foreach ($source_name as $keys => $name) { |
| 875 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 876 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1125 | + if (isset($source_id[$keys])) { |
|
| 1126 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 1127 | + } else { |
|
| 1128 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1129 | + } |
|
| 1130 | + } |
|
| 1131 | + if (count($sources) > 0) { |
|
| 1132 | + $_SESSION['sources'] = $sources; |
|
| 877 | 1133 | } |
| 878 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
| 879 | 1134 | |
| 880 | 1135 | //$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING); |
| 881 | 1136 | //$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT); |
@@ -913,13 +1168,21 @@ discard block |
||
| 913 | 1168 | $port = $_POST['port']; |
| 914 | 1169 | $name = $_POST['name']; |
| 915 | 1170 | $format = $_POST['format']; |
| 916 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
| 917 | - else $sourcestats = array(); |
|
| 1171 | + if (isset($_POST['sourcestats'])) { |
|
| 1172 | + $sourcestats = $_POST['sourcestats']; |
|
| 1173 | + } else { |
|
| 1174 | + $sourcestats = array(); |
|
| 1175 | + } |
|
| 918 | 1176 | $gSources = array(); |
| 919 | 1177 | foreach ($host as $key => $h) { |
| 920 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
| 921 | - else $cov = 'FALSE'; |
|
| 922 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov); |
|
| 1178 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
| 1179 | + $cov = 'TRUE'; |
|
| 1180 | + } else { |
|
| 1181 | + $cov = 'FALSE'; |
|
| 1182 | + } |
|
| 1183 | + if ($h != '') { |
|
| 1184 | + $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov); |
|
| 1185 | + } |
|
| 923 | 1186 | } |
| 924 | 1187 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
| 925 | 1188 | |
@@ -943,7 +1206,9 @@ discard block |
||
| 943 | 1206 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
| 944 | 1207 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
| 945 | 1208 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
| 946 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1209 | + } else { |
|
| 1210 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1211 | + } |
|
| 947 | 1212 | |
| 948 | 1213 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
| 949 | 1214 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -982,7 +1247,9 @@ discard block |
||
| 982 | 1247 | |
| 983 | 1248 | // Create in settings.php keys not yet configurable if not already here |
| 984 | 1249 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
| 985 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1250 | + if (!isset($globalDebug)) { |
|
| 1251 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1252 | + } |
|
| 986 | 1253 | |
| 987 | 1254 | $archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING); |
| 988 | 1255 | if ($archive == 'archive') { |
@@ -1012,27 +1279,43 @@ discard block |
||
| 1012 | 1279 | } |
| 1013 | 1280 | */ |
| 1014 | 1281 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
| 1015 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1016 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1017 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1018 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 1282 | + if ($globalsbs == 'sbs') { |
|
| 1283 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1284 | + } else { |
|
| 1285 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1286 | + } |
|
| 1287 | + if ($globalaprs == 'aprs') { |
|
| 1288 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1289 | + } else { |
|
| 1290 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 1291 | + } |
|
| 1019 | 1292 | if ($globalivao == 'ivao') { |
| 1020 | 1293 | //$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE')); |
| 1021 | 1294 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
| 1022 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 1295 | + } else { |
|
| 1296 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 1297 | + } |
|
| 1023 | 1298 | if ($globalvatsim == 'vatsim') { |
| 1024 | 1299 | //$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE')); |
| 1025 | 1300 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
| 1026 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 1301 | + } else { |
|
| 1302 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 1303 | + } |
|
| 1027 | 1304 | if ($globalphpvms == 'phpvms') { |
| 1028 | 1305 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
| 1029 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 1306 | + } else { |
|
| 1307 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 1308 | + } |
|
| 1030 | 1309 | if ($globalvam == 'vam') { |
| 1031 | 1310 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
| 1032 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 1311 | + } else { |
|
| 1312 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 1313 | + } |
|
| 1033 | 1314 | if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') { |
| 1034 | 1315 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
| 1035 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 1316 | + } else { |
|
| 1317 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 1318 | + } |
|
| 1036 | 1319 | |
| 1037 | 1320 | |
| 1038 | 1321 | |
@@ -1156,7 +1439,9 @@ discard block |
||
| 1156 | 1439 | $settings = array_merge($settings,array('globalWaypoints' => 'FALSE')); |
| 1157 | 1440 | } |
| 1158 | 1441 | |
| 1159 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 1442 | + if (!isset($globalTransaction)) { |
|
| 1443 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 1444 | + } |
|
| 1160 | 1445 | |
| 1161 | 1446 | // Set some defaults values... |
| 1162 | 1447 | if (!isset($globalAircraftImageSources)) { |
@@ -1171,15 +1456,23 @@ discard block |
||
| 1171 | 1456 | |
| 1172 | 1457 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
| 1173 | 1458 | |
| 1174 | - if ($error == '') settings::modify_settings($settings); |
|
| 1175 | - if ($error == '') settings::comment_settings($settings_comment); |
|
| 1459 | + if ($error == '') { |
|
| 1460 | + settings::modify_settings($settings); |
|
| 1461 | + } |
|
| 1462 | + if ($error == '') { |
|
| 1463 | + settings::comment_settings($settings_comment); |
|
| 1464 | + } |
|
| 1176 | 1465 | if ($error != '') { |
| 1177 | 1466 | print '<div class="info column">'.$error.'</div>'; |
| 1178 | 1467 | require('../footer.php'); |
| 1179 | 1468 | exit; |
| 1180 | 1469 | } else { |
| 1181 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
| 1182 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
| 1470 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
| 1471 | + $_SESSION['waypoints'] = 1; |
|
| 1472 | + } |
|
| 1473 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
| 1474 | + $_SESSION['owner'] = 1; |
|
| 1475 | + } |
|
| 1183 | 1476 | if (isset($_POST['createdb'])) { |
| 1184 | 1477 | $_SESSION['install'] = 'database_create'; |
| 1185 | 1478 | } else { |
@@ -1220,10 +1513,18 @@ discard block |
||
| 1220 | 1513 | $popw = false; |
| 1221 | 1514 | foreach ($_SESSION['done'] as $done) { |
| 1222 | 1515 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
| 1223 | - if ($done == 'Create database') $pop = true; |
|
| 1224 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
| 1225 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
| 1226 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
| 1516 | + if ($done == 'Create database') { |
|
| 1517 | + $pop = true; |
|
| 1518 | + } |
|
| 1519 | + if ($_SESSION['install'] == 'database_create') { |
|
| 1520 | + $pop = true; |
|
| 1521 | + } |
|
| 1522 | + if ($_SESSION['install'] == 'database_import') { |
|
| 1523 | + $popi = true; |
|
| 1524 | + } |
|
| 1525 | + if ($_SESSION['install'] == 'waypoints') { |
|
| 1526 | + $popw = true; |
|
| 1527 | + } |
|
| 1227 | 1528 | } |
| 1228 | 1529 | if ($pop) { |
| 1229 | 1530 | sleep(5); |
@@ -1234,7 +1535,9 @@ discard block |
||
| 1234 | 1535 | } else if ($popw) { |
| 1235 | 1536 | sleep(5); |
| 1236 | 1537 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
| 1237 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 1538 | + } else { |
|
| 1539 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 1540 | + } |
|
| 1238 | 1541 | print '</div></ul>'; |
| 1239 | 1542 | print '<div id="error"></div>'; |
| 1240 | 1543 | /* foreach ($_SESSION['done'] as $done) { |
@@ -14,7 +14,9 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | 16 | |
| 17 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 17 | +if (!isset($globalDebug)) { |
|
| 18 | + $globalDebug = FALSE; |
|
| 19 | +} |
|
| 18 | 20 | |
| 19 | 21 | // Check if schema is at latest version |
| 20 | 22 | $Connection = new Connection(); |
@@ -51,13 +53,22 @@ discard block |
||
| 51 | 53 | $globalSources = array(); |
| 52 | 54 | $globalSources[] = array('host' => $options['source']); |
| 53 | 55 | } |
| 54 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 55 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 56 | -else $id_source = 1; |
|
| 56 | +if (isset($options['server'])) { |
|
| 57 | + $globalServer = TRUE; |
|
| 58 | +} |
|
| 59 | +if (isset($options['idsource'])) { |
|
| 60 | + $id_source = $options['idsource']; |
|
| 61 | +} else { |
|
| 62 | + $id_source = 1; |
|
| 63 | +} |
|
| 57 | 64 | if (isset($globalServer) && $globalServer) { |
| 58 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 65 | + if ($globalDebug) { |
|
| 66 | + echo "Using Server Mode\n"; |
|
| 67 | + } |
|
| 59 | 68 | $SI=new SpotterServer(); |
| 60 | -} else $SI=new SpotterImport($Connection->db); |
|
| 69 | +} else { |
|
| 70 | + $SI=new SpotterImport($Connection->db); |
|
| 71 | +} |
|
| 61 | 72 | //$APRS=new APRS($Connection->db); |
| 62 | 73 | $SBS=new SBS(); |
| 63 | 74 | $ACARS=new ACARS($Connection->db); |
@@ -75,7 +86,9 @@ discard block |
||
| 75 | 86 | } |
| 76 | 87 | |
| 77 | 88 | // let's try and connect |
| 78 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 89 | +if ($globalDebug) { |
|
| 90 | + echo "Connecting...\n"; |
|
| 91 | +} |
|
| 79 | 92 | $use_aprs = false; |
| 80 | 93 | $aprs_full = false; |
| 81 | 94 | |
@@ -83,7 +96,9 @@ discard block |
||
| 83 | 96 | $ip = gethostbyname($host); |
| 84 | 97 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
| 85 | 98 | $r = @socket_connect($s, $ip, $port); |
| 86 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 99 | + if (!socket_set_nonblock($s)) { |
|
| 100 | + echo "Unable to set nonblock on socket\n"; |
|
| 101 | + } |
|
| 87 | 102 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
| 88 | 103 | return $s; |
| 89 | 104 | } |
@@ -110,7 +125,9 @@ discard block |
||
| 110 | 125 | function connect_all($hosts) { |
| 111 | 126 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 112 | 127 | global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 113 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 128 | + if ($globalDebug) { |
|
| 129 | + echo 'Connect to all...'."\n"; |
|
| 130 | + } |
|
| 114 | 131 | foreach ($hosts as $id => $value) { |
| 115 | 132 | $host = $value['host']; |
| 116 | 133 | $globalSources[$id]['last_exec'] = 0; |
@@ -120,27 +137,37 @@ discard block |
||
| 120 | 137 | //$formats[$id] = 'deltadbtxt'; |
| 121 | 138 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 122 | 139 | //$last_exec['deltadbtxt'] = 0; |
| 123 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 140 | + if ($globalDebug) { |
|
| 141 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 142 | + } |
|
| 124 | 143 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 125 | 144 | //$formats[$id] = 'vatsimtxt'; |
| 126 | 145 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 127 | 146 | //$last_exec['vatsimtxt'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 147 | + if ($globalDebug) { |
|
| 148 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 149 | + } |
|
| 129 | 150 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 130 | 151 | //$formats[$id] = 'aircraftlistjson'; |
| 131 | 152 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 132 | 153 | //$last_exec['aircraftlistjson'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 154 | + if ($globalDebug) { |
|
| 155 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 156 | + } |
|
| 134 | 157 | } else if (preg_match('/opensky/i',$host)) { |
| 135 | 158 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 159 | $globalSources[$id]['format'] = 'opensky'; |
| 137 | 160 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 161 | + if ($globalDebug) { |
|
| 162 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 163 | + } |
|
| 139 | 164 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 140 | 165 | //$formats[$id] = 'radarvirtueljson'; |
| 141 | 166 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 142 | 167 | //$last_exec['radarvirtueljson'] = 0; |
| 143 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 168 | + if ($globalDebug) { |
|
| 169 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 170 | + } |
|
| 144 | 171 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 145 | 172 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 146 | 173 | exit(0); |
@@ -149,7 +176,9 @@ discard block |
||
| 149 | 176 | //$formats[$id] = 'planeupdatefaa'; |
| 150 | 177 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 151 | 178 | //$last_exec['planeupdatefaa'] = 0; |
| 152 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 179 | + if ($globalDebug) { |
|
| 180 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 181 | + } |
|
| 153 | 182 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 154 | 183 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 155 | 184 | exit(0); |
@@ -158,26 +187,36 @@ discard block |
||
| 158 | 187 | //$formats[$id] = 'phpvmacars'; |
| 159 | 188 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 160 | 189 | //$last_exec['phpvmacars'] = 0; |
| 161 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 190 | + if ($globalDebug) { |
|
| 191 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 192 | + } |
|
| 162 | 193 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 163 | 194 | //$formats[$id] = 'phpvmacars'; |
| 164 | 195 | $globalSources[$id]['format'] = 'vam'; |
| 165 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 196 | + if ($globalDebug) { |
|
| 197 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 198 | + } |
|
| 166 | 199 | } else if (preg_match('/whazzup/i',$host)) { |
| 167 | 200 | //$formats[$id] = 'whazzup'; |
| 168 | 201 | $globalSources[$id]['format'] = 'whazzup'; |
| 169 | 202 | //$last_exec['whazzup'] = 0; |
| 170 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 203 | + if ($globalDebug) { |
|
| 204 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 205 | + } |
|
| 171 | 206 | } else if (preg_match('/recentpireps/i',$host)) { |
| 172 | 207 | //$formats[$id] = 'pirepsjson'; |
| 173 | 208 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 174 | 209 | //$last_exec['pirepsjson'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 210 | + if ($globalDebug) { |
|
| 211 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 212 | + } |
|
| 176 | 213 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 177 | 214 | //$formats[$id] = 'fr24json'; |
| 178 | 215 | $globalSources[$id]['format'] = 'fr24json'; |
| 179 | 216 | //$last_exec['fr24json'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 217 | + if ($globalDebug) { |
|
| 218 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 219 | + } |
|
| 181 | 220 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 182 | 221 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 183 | 222 | exit(0); |
@@ -186,10 +225,14 @@ discard block |
||
| 186 | 225 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 187 | 226 | //$formats[$id] = 'tsv'; |
| 188 | 227 | $globalSources[$id]['format'] = 'tsv'; |
| 189 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 230 | + } |
|
| 190 | 231 | } |
| 191 | 232 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 192 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 233 | + if ($globalDebug) { |
|
| 234 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 235 | + } |
|
| 193 | 236 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 194 | 237 | $hostport = explode(':',$host); |
| 195 | 238 | if (isset($hostport[1])) { |
@@ -226,17 +269,25 @@ discard block |
||
| 226 | 269 | //$formats[$id] = 'beast'; |
| 227 | 270 | $globalSources[$id]['format'] = 'beast'; |
| 228 | 271 | //} else $formats[$id] = 'sbs'; |
| 229 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 272 | + } else { |
|
| 273 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 274 | + } |
|
| 230 | 275 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 231 | 276 | } |
| 232 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 279 | + } |
|
| 233 | 280 | } else { |
| 234 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 281 | + if ($globalDebug) { |
|
| 282 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 283 | + } |
|
| 235 | 284 | } |
| 236 | 285 | } |
| 237 | 286 | } |
| 238 | 287 | } |
| 239 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 288 | +if (!isset($globalMinFetch)) { |
|
| 289 | + $globalMinFetch = 15; |
|
| 290 | +} |
|
| 240 | 291 | |
| 241 | 292 | // Initialize all |
| 242 | 293 | $status = array(); |
@@ -244,13 +295,19 @@ discard block |
||
| 244 | 295 | $formats = array(); |
| 245 | 296 | $last_exec = array(); |
| 246 | 297 | $time = time(); |
| 247 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 248 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 249 | -else $timeout = 20; |
|
| 298 | +if (isset($globalSourcesTimeout)) { |
|
| 299 | + $timeout = $globalSourcesTimeOut; |
|
| 300 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 301 | + $timeout = $globalSBS1TimeOut; |
|
| 302 | +} else { |
|
| 303 | + $timeout = 20; |
|
| 304 | +} |
|
| 250 | 305 | $errno = ''; |
| 251 | 306 | $errstr=''; |
| 252 | 307 | |
| 253 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 308 | +if (!isset($globalDaemon)) { |
|
| 309 | + $globalDaemon = TRUE; |
|
| 310 | +} |
|
| 254 | 311 | /* Initiate connections to all the hosts simultaneously */ |
| 255 | 312 | //connect_all($hosts); |
| 256 | 313 | //connect_all($globalSources); |
@@ -270,7 +327,9 @@ discard block |
||
| 270 | 327 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 271 | 328 | $aprs_connect = 0; |
| 272 | 329 | $use_aprs = true; |
| 273 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 330 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 331 | + $aprs_full = true; |
|
| 332 | + } |
|
| 274 | 333 | break; |
| 275 | 334 | } |
| 276 | 335 | } |
@@ -281,24 +340,44 @@ discard block |
||
| 281 | 340 | $aprs_connect = 0; |
| 282 | 341 | $aprs_keep = 120; |
| 283 | 342 | $aprs_last_tx = time(); |
| 284 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 285 | - else $aprs_version = $globalName.' using FlightAirMap'; |
|
| 343 | + if (isset($globalAPRSversion)) { |
|
| 344 | + $aprs_version = $globalAPRSversion; |
|
| 345 | + } else { |
|
| 346 | + $aprs_version = $globalName.' using FlightAirMap'; |
|
| 347 | + } |
|
| 286 | 348 | //else $aprs_version = 'Perl Example App'; |
| 287 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 288 | - else $aprs_ssid = 'FAM'; |
|
| 349 | + if (isset($globalAPRSssid)) { |
|
| 350 | + $aprs_ssid = $globalAPRSssid; |
|
| 351 | + } else { |
|
| 352 | + $aprs_ssid = 'FAM'; |
|
| 353 | + } |
|
| 289 | 354 | //else $aprs_ssid = 'PerlEx'; |
| 290 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 291 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 292 | - if ($aprs_full) $aprs_filter = ''; |
|
| 293 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
|
| 294 | - else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
|
| 295 | -} |
|
| 355 | + if (isset($globalAPRSfilter)) { |
|
| 356 | + $aprs_filter = $globalAPRSfilter; |
|
| 357 | + } else { |
|
| 358 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 359 | + } |
|
| 360 | + if ($aprs_full) { |
|
| 361 | + $aprs_filter = ''; |
|
| 362 | + } |
|
| 363 | + if ($aprs_filter != '') { |
|
| 364 | + $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
|
| 365 | + } else { |
|
| 366 | + $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
|
| 367 | + } |
|
| 368 | + } |
|
| 296 | 369 | |
| 297 | 370 | // connected - lets do some work |
| 298 | -if ($globalDebug) echo "Connected!\n"; |
|
| 371 | +if ($globalDebug) { |
|
| 372 | + echo "Connected!\n"; |
|
| 373 | +} |
|
| 299 | 374 | sleep(1); |
| 300 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 301 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 375 | +if ($globalDebug) { |
|
| 376 | + echo "SCAN MODE \n\n"; |
|
| 377 | +} |
|
| 378 | +if (!isset($globalCronEnd)) { |
|
| 379 | + $globalCronEnd = 60; |
|
| 380 | +} |
|
| 302 | 381 | $endtime = time()+$globalCronEnd; |
| 303 | 382 | $i = 1; |
| 304 | 383 | $tt = array(); |
@@ -312,20 +391,28 @@ discard block |
||
| 312 | 391 | |
| 313 | 392 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 314 | 393 | while ($i > 0) { |
| 315 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 394 | + if (!$globalDaemon) { |
|
| 395 | + $i = $endtime-time(); |
|
| 396 | + } |
|
| 316 | 397 | // Delete old ATC |
| 317 | 398 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 318 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 399 | + if ($globalDebug) { |
|
| 400 | + echo 'Delete old ATC...'."\n"; |
|
| 401 | + } |
|
| 319 | 402 | $ATC->deleteOldATC(); |
| 320 | 403 | } |
| 321 | 404 | |
| 322 | 405 | if (count($last_exec) > 0) { |
| 323 | 406 | $max = $globalMinFetch; |
| 324 | 407 | foreach ($last_exec as $last) { |
| 325 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 408 | + if ((time() - $last['last']) < $max) { |
|
| 409 | + $max = time() - $last['last']; |
|
| 410 | + } |
|
| 326 | 411 | } |
| 327 | 412 | if ($max != $globalMinFetch) { |
| 328 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 413 | + if ($globalDebug) { |
|
| 414 | + echo 'Sleeping...'."\n"; |
|
| 415 | + } |
|
| 329 | 416 | sleep($globalMinFetch-$max+2); |
| 330 | 417 | } |
| 331 | 418 | } |
@@ -333,7 +420,9 @@ discard block |
||
| 333 | 420 | |
| 334 | 421 | //foreach ($formats as $id => $value) { |
| 335 | 422 | foreach ($globalSources as $id => $value) { |
| 336 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 423 | + if (!isset($last_exec[$id]['last'])) { |
|
| 424 | + $last_exec[$id]['last'] = 0; |
|
| 425 | + } |
|
| 337 | 426 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 338 | 427 | //$buffer = $Common->getData($hosts[$id]); |
| 339 | 428 | $buffer = $Common->getData($value['host']); |
@@ -356,8 +445,12 @@ discard block |
||
| 356 | 445 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 357 | 446 | $data['format_source'] = 'deltadbtxt'; |
| 358 | 447 | $data['id_source'] = $id_source; |
| 359 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 360 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 448 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 449 | + $data['source_name'] = $value['name']; |
|
| 450 | + } |
|
| 451 | + if (isset($value['sourcestats'])) { |
|
| 452 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 453 | + } |
|
| 361 | 454 | $SI->add($data); |
| 362 | 455 | unset($data); |
| 363 | 456 | } |
@@ -379,10 +472,19 @@ discard block |
||
| 379 | 472 | $data['pilot_name'] = $line[2]; |
| 380 | 473 | $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
| 381 | 474 | $data['ident'] = $line[0]; // ident |
| 382 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 475 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 476 | + $data['altitude'] = $line[7]; |
|
| 477 | + } |
|
| 478 | + // altitude |
|
| 383 | 479 | $data['speed'] = $line[8]; // speed |
| 384 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 385 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 480 | + if (isset($line[45])) { |
|
| 481 | + $data['heading'] = $line[45]; |
|
| 482 | + } |
|
| 483 | + // heading |
|
| 484 | + elseif (isset($line[38])) { |
|
| 485 | + $data['heading'] = $line[38]; |
|
| 486 | + } |
|
| 487 | + // heading |
|
| 386 | 488 | $data['latitude'] = $line[5]; // lat |
| 387 | 489 | $data['longitude'] = $line[6]; // long |
| 388 | 490 | $data['verticalrate'] = ''; // vertical rate |
@@ -391,14 +493,18 @@ discard block |
||
| 391 | 493 | $data['waypoints'] = $line[30]; |
| 392 | 494 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 393 | 495 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 394 | - if (isset($line[37])) $data['last_update'] = $line[37]; |
|
| 496 | + if (isset($line[37])) { |
|
| 497 | + $data['last_update'] = $line[37]; |
|
| 498 | + } |
|
| 395 | 499 | $data['departure_airport_icao'] = $line[11]; |
| 396 | 500 | $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
| 397 | 501 | $data['arrival_airport_icao'] = $line[13]; |
| 398 | 502 | $data['frequency'] = $line[4]; |
| 399 | 503 | $data['type'] = $line[18]; |
| 400 | 504 | $data['range'] = $line[19]; |
| 401 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 505 | + if (isset($line[35])) { |
|
| 506 | + $data['info'] = $line[35]; |
|
| 507 | + } |
|
| 402 | 508 | $data['id_source'] = $id_source; |
| 403 | 509 | //$data['arrival_airport_time'] = ; |
| 404 | 510 | if ($line[9] != '') { |
@@ -412,22 +518,35 @@ discard block |
||
| 412 | 518 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 413 | 519 | */ |
| 414 | 520 | $data['format_source'] = $value['format']; |
| 415 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 416 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 417 | - elseif ($line[3] == 'ATC') { |
|
| 521 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 522 | + $data['source_name'] = $value['name']; |
|
| 523 | + } |
|
| 524 | + if ($line[3] == 'PILOT') { |
|
| 525 | + $SI->add($data); |
|
| 526 | + } elseif ($line[3] == 'ATC') { |
|
| 418 | 527 | //print_r($data); |
| 419 | 528 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 420 | 529 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 421 | 530 | $typec = substr($data['ident'],-3); |
| 422 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 423 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 424 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 425 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 426 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 427 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 428 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 429 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 430 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 531 | + if ($typec == 'APP') { |
|
| 532 | + $data['type'] = 'Approach'; |
|
| 533 | + } elseif ($typec == 'TWR') { |
|
| 534 | + $data['type'] = 'Tower'; |
|
| 535 | + } elseif ($typec == 'OBS') { |
|
| 536 | + $data['type'] = 'Observer'; |
|
| 537 | + } elseif ($typec == 'GND') { |
|
| 538 | + $data['type'] = 'Ground'; |
|
| 539 | + } elseif ($typec == 'DEL') { |
|
| 540 | + $data['type'] = 'Delivery'; |
|
| 541 | + } elseif ($typec == 'DEP') { |
|
| 542 | + $data['type'] = 'Departure'; |
|
| 543 | + } elseif ($typec == 'FSS') { |
|
| 544 | + $data['type'] = 'Flight Service Station'; |
|
| 545 | + } elseif ($typec == 'CTR') { |
|
| 546 | + $data['type'] = 'Control Radar or Centre'; |
|
| 547 | + } elseif ($data['type'] == '') { |
|
| 548 | + $data['type'] = 'Observer'; |
|
| 549 | + } |
|
| 431 | 550 | |
| 432 | 551 | echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
| 433 | 552 | } |
@@ -447,26 +566,55 @@ discard block |
||
| 447 | 566 | foreach ($all_data['acList'] as $line) { |
| 448 | 567 | $data = array(); |
| 449 | 568 | $data['hex'] = $line['Icao']; // hex |
| 450 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 451 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 452 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 453 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 454 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 455 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 569 | + if (isset($line['Call'])) { |
|
| 570 | + $data['ident'] = $line['Call']; |
|
| 571 | + } |
|
| 572 | + // ident |
|
| 573 | + if (isset($line['Alt'])) { |
|
| 574 | + $data['altitude'] = $line['Alt']; |
|
| 575 | + } |
|
| 576 | + // altitude |
|
| 577 | + if (isset($line['Spd'])) { |
|
| 578 | + $data['speed'] = $line['Spd']; |
|
| 579 | + } |
|
| 580 | + // speed |
|
| 581 | + if (isset($line['Trak'])) { |
|
| 582 | + $data['heading'] = $line['Trak']; |
|
| 583 | + } |
|
| 584 | + // heading |
|
| 585 | + if (isset($line['Lat'])) { |
|
| 586 | + $data['latitude'] = $line['Lat']; |
|
| 587 | + } |
|
| 588 | + // lat |
|
| 589 | + if (isset($line['Long'])) { |
|
| 590 | + $data['longitude'] = $line['Long']; |
|
| 591 | + } |
|
| 592 | + // long |
|
| 456 | 593 | //$data['verticalrate'] = $line['']; // verticale rate |
| 457 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 594 | + if (isset($line['Sqk'])) { |
|
| 595 | + $data['squawk'] = $line['Sqk']; |
|
| 596 | + } |
|
| 597 | + // squawk |
|
| 458 | 598 | $data['emergency'] = ''; // emergency |
| 459 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 599 | + if (isset($line['Reg'])) { |
|
| 600 | + $data['registration'] = $line['Reg']; |
|
| 601 | + } |
|
| 460 | 602 | /* |
| 461 | 603 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 462 | 604 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 463 | 605 | */ |
| 464 | 606 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 465 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 607 | + if (isset($line['Type'])) { |
|
| 608 | + $data['aircraft_icao'] = $line['Type']; |
|
| 609 | + } |
|
| 466 | 610 | $data['format_source'] = 'aircraftlistjson'; |
| 467 | 611 | $data['id_source'] = $id_source; |
| 468 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 469 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 612 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 613 | + $data['source_name'] = $value['name']; |
|
| 614 | + } |
|
| 615 | + if (isset($data['datetime'])) { |
|
| 616 | + $SI->add($data); |
|
| 617 | + } |
|
| 470 | 618 | unset($data); |
| 471 | 619 | } |
| 472 | 620 | } else { |
@@ -485,7 +633,9 @@ discard block |
||
| 485 | 633 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 486 | 634 | $data['format_source'] = 'aircraftlistjson'; |
| 487 | 635 | $data['id_source'] = $id_source; |
| 488 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 636 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 637 | + $data['source_name'] = $value['name']; |
|
| 638 | + } |
|
| 489 | 639 | $SI->add($data); |
| 490 | 640 | unset($data); |
| 491 | 641 | } |
@@ -520,7 +670,9 @@ discard block |
||
| 520 | 670 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 521 | 671 | $data['format_source'] = 'planeupdatefaa'; |
| 522 | 672 | $data['id_source'] = $id_source; |
| 523 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 673 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 674 | + $data['source_name'] = $value['name']; |
|
| 675 | + } |
|
| 524 | 676 | $SI->add($data); |
| 525 | 677 | unset($data); |
| 526 | 678 | } |
@@ -579,7 +731,9 @@ discard block |
||
| 579 | 731 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 580 | 732 | $data['format_source'] = 'fr24json'; |
| 581 | 733 | $data['id_source'] = $id_source; |
| 582 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 734 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 735 | + $data['source_name'] = $value['name']; |
|
| 736 | + } |
|
| 583 | 737 | $SI->add($data); |
| 584 | 738 | unset($data); |
| 585 | 739 | } |
@@ -602,23 +756,39 @@ discard block |
||
| 602 | 756 | if (isset($line['inf'])) { |
| 603 | 757 | $data = array(); |
| 604 | 758 | $data['hex'] = $line['inf']['ia']; |
| 605 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 759 | + if (isset($line['inf']['cs'])) { |
|
| 760 | + $data['ident'] = $line['inf']['cs']; |
|
| 761 | + } |
|
| 762 | + //$line[13] |
|
| 606 | 763 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 607 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 608 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 764 | + if (isset($line['inf']['gs'])) { |
|
| 765 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 766 | + } |
|
| 767 | + // speed |
|
| 768 | + if (isset($line['inf']['tr'])) { |
|
| 769 | + $data['heading'] = $line['inf']['tr']; |
|
| 770 | + } |
|
| 771 | + // heading |
|
| 609 | 772 | $data['latitude'] = $line['pt'][0]; // lat |
| 610 | 773 | $data['longitude'] = $line['pt'][1]; // long |
| 611 | 774 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 612 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 775 | + if (isset($line['inf']['sq'])) { |
|
| 776 | + $data['squawk'] = $line['inf']['sq']; |
|
| 777 | + } |
|
| 778 | + // squawk |
|
| 613 | 779 | //$data['aircraft_icao'] = $line[8]; |
| 614 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 780 | + if (isset($line['inf']['rc'])) { |
|
| 781 | + $data['registration'] = $line['inf']['rc']; |
|
| 782 | + } |
|
| 615 | 783 | //$data['departure_airport_iata'] = $line[11]; |
| 616 | 784 | //$data['arrival_airport_iata'] = $line[12]; |
| 617 | 785 | //$data['emergency'] = ''; // emergency |
| 618 | 786 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 619 | 787 | $data['format_source'] = 'radarvirtueljson'; |
| 620 | 788 | $data['id_source'] = $id_source; |
| 621 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 789 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 790 | + $data['source_name'] = $value['name']; |
|
| 791 | + } |
|
| 622 | 792 | $SI->add($data); |
| 623 | 793 | unset($data); |
| 624 | 794 | } |
@@ -638,29 +808,62 @@ discard block |
||
| 638 | 808 | $data['id'] = $line['id']; |
| 639 | 809 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 640 | 810 | $data['ident'] = $line['callsign']; // ident |
| 641 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 642 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 643 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 644 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 645 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 646 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 811 | + if (isset($line['pilotid'])) { |
|
| 812 | + $data['pilot_id'] = $line['pilotid']; |
|
| 813 | + } |
|
| 814 | + // pilot id |
|
| 815 | + if (isset($line['name'])) { |
|
| 816 | + $data['pilot_name'] = $line['name']; |
|
| 817 | + } |
|
| 818 | + // pilot name |
|
| 819 | + if (isset($line['alt'])) { |
|
| 820 | + $data['altitude'] = $line['alt']; |
|
| 821 | + } |
|
| 822 | + // altitude |
|
| 823 | + if (isset($line['gs'])) { |
|
| 824 | + $data['speed'] = $line['gs']; |
|
| 825 | + } |
|
| 826 | + // speed |
|
| 827 | + if (isset($line['heading'])) { |
|
| 828 | + $data['heading'] = $line['heading']; |
|
| 829 | + } |
|
| 830 | + // heading |
|
| 831 | + if (isset($line['route'])) { |
|
| 832 | + $data['waypoints'] = $line['route']; |
|
| 833 | + } |
|
| 834 | + // route |
|
| 647 | 835 | $data['latitude'] = $line['lat']; // lat |
| 648 | 836 | $data['longitude'] = $line['lon']; // long |
| 649 | 837 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 650 | 838 | //$data['squawk'] = $line['squawk']; // squawk |
| 651 | 839 | //$data['emergency'] = ''; // emergency |
| 652 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 653 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 654 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 840 | + if (isset($line['depicao'])) { |
|
| 841 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 842 | + } |
|
| 843 | + if (isset($line['deptime'])) { |
|
| 844 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 845 | + } |
|
| 846 | + if (isset($line['arricao'])) { |
|
| 847 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 848 | + } |
|
| 655 | 849 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 656 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 657 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 658 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 659 | - else $data['info'] = ''; |
|
| 850 | + if (isset($line['aircraft'])) { |
|
| 851 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 852 | + } |
|
| 853 | + if (isset($line['transponder'])) { |
|
| 854 | + $data['squawk'] = $line['transponder']; |
|
| 855 | + } |
|
| 856 | + if (isset($line['atis'])) { |
|
| 857 | + $data['info'] = $line['atis']; |
|
| 858 | + } else { |
|
| 859 | + $data['info'] = ''; |
|
| 860 | + } |
|
| 660 | 861 | $data['format_source'] = 'pireps'; |
| 661 | 862 | $data['id_source'] = $id_source; |
| 662 | 863 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 663 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 864 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 865 | + $data['source_name'] = $value['name']; |
|
| 866 | + } |
|
| 664 | 867 | if ($line['icon'] == 'plane') { |
| 665 | 868 | $SI->add($data); |
| 666 | 869 | // print_r($data); |
@@ -669,15 +872,25 @@ discard block |
||
| 669 | 872 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 670 | 873 | $typec = substr($data['ident'],-3); |
| 671 | 874 | $data['type'] = ''; |
| 672 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 673 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 674 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 675 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 676 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 677 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 678 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 679 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 680 | - else $data['type'] = 'Observer'; |
|
| 875 | + if ($typec == 'APP') { |
|
| 876 | + $data['type'] = 'Approach'; |
|
| 877 | + } elseif ($typec == 'TWR') { |
|
| 878 | + $data['type'] = 'Tower'; |
|
| 879 | + } elseif ($typec == 'OBS') { |
|
| 880 | + $data['type'] = 'Observer'; |
|
| 881 | + } elseif ($typec == 'GND') { |
|
| 882 | + $data['type'] = 'Ground'; |
|
| 883 | + } elseif ($typec == 'DEL') { |
|
| 884 | + $data['type'] = 'Delivery'; |
|
| 885 | + } elseif ($typec == 'DEP') { |
|
| 886 | + $data['type'] = 'Departure'; |
|
| 887 | + } elseif ($typec == 'FSS') { |
|
| 888 | + $data['type'] = 'Flight Service Station'; |
|
| 889 | + } elseif ($typec == 'CTR') { |
|
| 890 | + $data['type'] = 'Control Radar or Centre'; |
|
| 891 | + } else { |
|
| 892 | + $data['type'] = 'Observer'; |
|
| 893 | + } |
|
| 681 | 894 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
| 682 | 895 | } |
| 683 | 896 | unset($data); |
@@ -688,17 +901,25 @@ discard block |
||
| 688 | 901 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 689 | 902 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 690 | 903 | //$buffer = $Common->getData($hosts[$id]); |
| 691 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 904 | + if ($globalDebug) { |
|
| 905 | + echo 'Get Data...'."\n"; |
|
| 906 | + } |
|
| 692 | 907 | $buffer = $Common->getData($value['host']); |
| 693 | 908 | $all_data = json_decode($buffer,true); |
| 694 | 909 | if ($buffer != '' && is_array($all_data)) { |
| 695 | 910 | foreach ($all_data as $line) { |
| 696 | 911 | $data = array(); |
| 697 | 912 | //$data['id'] = $line['id']; // id not usable |
| 698 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 913 | + if (isset($line['pilotid'])) { |
|
| 914 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 915 | + } |
|
| 699 | 916 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 700 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 701 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 917 | + if (isset($line['pilotname'])) { |
|
| 918 | + $data['pilot_name'] = $line['pilotname']; |
|
| 919 | + } |
|
| 920 | + if (isset($line['pilotid'])) { |
|
| 921 | + $data['pilot_id'] = $line['pilotid']; |
|
| 922 | + } |
|
| 702 | 923 | $data['ident'] = $line['flightnum']; // ident |
| 703 | 924 | $data['altitude'] = $line['alt']; // altitude |
| 704 | 925 | $data['speed'] = $line['gs']; // speed |
@@ -716,27 +937,41 @@ discard block |
||
| 716 | 937 | $data['arrival_airport_icao'] = $line['arricao']; |
| 717 | 938 | $data['arrival_airport_time'] = $line['arrtime']; |
| 718 | 939 | $data['registration'] = $line['aircraft']; |
| 719 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 940 | + if (isset($line['route'])) { |
|
| 941 | + $data['waypoints'] = $line['route']; |
|
| 942 | + } |
|
| 943 | + // route |
|
| 720 | 944 | if (isset($line['aircraftname'])) { |
| 721 | 945 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 722 | 946 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 723 | 947 | $aircraft_data = explode('-',$line['aircraftname']); |
| 724 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 725 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 726 | - else { |
|
| 948 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
| 949 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 950 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
| 951 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 952 | + } else { |
|
| 727 | 953 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 728 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 729 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 954 | + if (isset($aircraft_data[1])) { |
|
| 955 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 956 | + } else { |
|
| 957 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
| 958 | + } |
|
| 730 | 959 | } |
| 731 | 960 | } |
| 732 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 961 | + if (isset($line['route'])) { |
|
| 962 | + $data['waypoints'] = $line['route']; |
|
| 963 | + } |
|
| 733 | 964 | $data['id_source'] = $id_source; |
| 734 | 965 | $data['format_source'] = 'phpvmacars'; |
| 735 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 966 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 967 | + $data['source_name'] = $value['name']; |
|
| 968 | + } |
|
| 736 | 969 | $SI->add($data); |
| 737 | 970 | unset($data); |
| 738 | 971 | } |
| 739 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 972 | + if ($globalDebug) { |
|
| 973 | + echo 'No more data...'."\n"; |
|
| 974 | + } |
|
| 740 | 975 | unset($buffer); |
| 741 | 976 | unset($all_data); |
| 742 | 977 | } |
@@ -744,7 +979,9 @@ discard block |
||
| 744 | 979 | $last_exec[$id]['last'] = time(); |
| 745 | 980 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 746 | 981 | //$buffer = $Common->getData($hosts[$id]); |
| 747 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 982 | + if ($globalDebug) { |
|
| 983 | + echo 'Get Data...'."\n"; |
|
| 984 | + } |
|
| 748 | 985 | $buffer = $Common->getData($value['host']); |
| 749 | 986 | $all_data = json_decode($buffer,true); |
| 750 | 987 | if ($buffer != '' && is_array($all_data)) { |
@@ -772,15 +1009,22 @@ discard block |
||
| 772 | 1009 | $data['arrival_airport_icao'] = $line['arrival']; |
| 773 | 1010 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 774 | 1011 | //$data['registration'] = $line['aircraft']; |
| 775 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1012 | + if (isset($line['route'])) { |
|
| 1013 | + $data['waypoints'] = $line['route']; |
|
| 1014 | + } |
|
| 1015 | + // route |
|
| 776 | 1016 | $data['aircraft_icao'] = $line['plane_type']; |
| 777 | 1017 | $data['id_source'] = $id_source; |
| 778 | 1018 | $data['format_source'] = 'vam'; |
| 779 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1019 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1020 | + $data['source_name'] = $value['name']; |
|
| 1021 | + } |
|
| 780 | 1022 | $SI->add($data); |
| 781 | 1023 | unset($data); |
| 782 | 1024 | } |
| 783 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1025 | + if ($globalDebug) { |
|
| 1026 | + echo 'No more data...'."\n"; |
|
| 1027 | + } |
|
| 784 | 1028 | unset($buffer); |
| 785 | 1029 | unset($all_data); |
| 786 | 1030 | } |
@@ -788,7 +1032,9 @@ discard block |
||
| 788 | 1032 | $last_exec[$id]['last'] = time(); |
| 789 | 1033 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 790 | 1034 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
| 791 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1035 | + if (function_exists('pcntl_fork')) { |
|
| 1036 | + pcntl_signal_dispatch(); |
|
| 1037 | + } |
|
| 792 | 1038 | //$last_exec[$id]['last'] = time(); |
| 793 | 1039 | |
| 794 | 1040 | //$read = array( $sockets[$id] ); |
@@ -796,7 +1042,9 @@ discard block |
||
| 796 | 1042 | $write = NULL; |
| 797 | 1043 | $e = NULL; |
| 798 | 1044 | $n = socket_select($read, $write, $e, $timeout); |
| 799 | - if ($e != NULL) var_dump($e); |
|
| 1045 | + if ($e != NULL) { |
|
| 1046 | + var_dump($e); |
|
| 1047 | + } |
|
| 800 | 1048 | if ($n > 0) { |
| 801 | 1049 | foreach ($read as $nb => $r) { |
| 802 | 1050 | //$value = $formats[$nb]; |
@@ -817,7 +1065,9 @@ discard block |
||
| 817 | 1065 | if ($buffer != '') { |
| 818 | 1066 | $tt[$format] = 0; |
| 819 | 1067 | if ($format == 'acarssbs3') { |
| 820 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1068 | + if ($globalDebug) { |
|
| 1069 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1070 | + } |
|
| 821 | 1071 | $ACARS->add(trim($buffer)); |
| 822 | 1072 | $ACARS->deleteLiveAcarsData(); |
| 823 | 1073 | } elseif ($format == 'raw') { |
@@ -826,9 +1076,15 @@ discard block |
||
| 826 | 1076 | if (is_array($data)) { |
| 827 | 1077 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 828 | 1078 | $data['format_source'] = 'raw'; |
| 829 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 830 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 831 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1079 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1080 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1081 | + } |
|
| 1082 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1083 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1084 | + } |
|
| 1085 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1086 | + $SI->add($data); |
|
| 1087 | + } |
|
| 832 | 1088 | } |
| 833 | 1089 | } elseif ($format == 'flightgearsp') { |
| 834 | 1090 | //echo $buffer."\n"; |
@@ -846,11 +1102,15 @@ discard block |
||
| 846 | 1102 | $data['speed'] = round($line[5]*1.94384); |
| 847 | 1103 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 848 | 1104 | $data['format_source'] = 'flightgearsp'; |
| 849 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1105 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1106 | + $SI->add($data); |
|
| 1107 | + } |
|
| 850 | 1108 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 851 | 1109 | } |
| 852 | 1110 | } elseif ($format == 'acars') { |
| 853 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1111 | + if ($globalDebug) { |
|
| 1112 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1113 | + } |
|
| 854 | 1114 | $ACARS->add(trim($buffer)); |
| 855 | 1115 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 856 | 1116 | $ACARS->deleteLiveAcarsData(); |
@@ -871,7 +1131,9 @@ discard block |
||
| 871 | 1131 | $aircraft_type = $line[10]; |
| 872 | 1132 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 873 | 1133 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 874 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1134 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1135 | + $SI->add($data); |
|
| 1136 | + } |
|
| 875 | 1137 | } |
| 876 | 1138 | } |
| 877 | 1139 | } elseif ($format == 'beast') { |
@@ -887,21 +1149,43 @@ discard block |
||
| 887 | 1149 | $data['hex'] = $lined['hexid']; |
| 888 | 1150 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 889 | 1151 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 890 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 891 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 892 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 893 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 894 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 895 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 896 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1152 | + if (isset($lined['ident'])) { |
|
| 1153 | + $data['ident'] = $lined['ident']; |
|
| 1154 | + } |
|
| 1155 | + if (isset($lined['lat'])) { |
|
| 1156 | + $data['latitude'] = $lined['lat']; |
|
| 1157 | + } |
|
| 1158 | + if (isset($lined['lon'])) { |
|
| 1159 | + $data['longitude'] = $lined['lon']; |
|
| 1160 | + } |
|
| 1161 | + if (isset($lined['speed'])) { |
|
| 1162 | + $data['speed'] = $lined['speed']; |
|
| 1163 | + } |
|
| 1164 | + if (isset($lined['squawk'])) { |
|
| 1165 | + $data['squawk'] = $lined['squawk']; |
|
| 1166 | + } |
|
| 1167 | + if (isset($lined['alt'])) { |
|
| 1168 | + $data['altitude'] = $lined['alt']; |
|
| 1169 | + } |
|
| 1170 | + if (isset($lined['heading'])) { |
|
| 1171 | + $data['heading'] = $lined['heading']; |
|
| 1172 | + } |
|
| 897 | 1173 | $data['id_source'] = $id_source; |
| 898 | 1174 | $data['format_source'] = 'tsv'; |
| 899 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 900 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 901 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1175 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1176 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1177 | + } |
|
| 1178 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1179 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1180 | + } |
|
| 1181 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1182 | + $SI->add($data); |
|
| 1183 | + } |
|
| 902 | 1184 | unset($lined); |
| 903 | 1185 | unset($data); |
| 904 | - } else $error = true; |
|
| 1186 | + } else { |
|
| 1187 | + $error = true; |
|
| 1188 | + } |
|
| 905 | 1189 | } elseif ($format == 'aprs' && $use_aprs) { |
| 906 | 1190 | if ($aprs_connect == 0) { |
| 907 | 1191 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -927,29 +1211,44 @@ discard block |
||
| 927 | 1211 | $data['latitude'] = $line['latitude']; |
| 928 | 1212 | $data['longitude'] = $line['longitude']; |
| 929 | 1213 | //$data['verticalrate'] = $line[16]; |
| 930 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 931 | - else $data['speed'] = 0; |
|
| 1214 | + if (isset($line['speed'])) { |
|
| 1215 | + $data['speed'] = $line['speed']; |
|
| 1216 | + } else { |
|
| 1217 | + $data['speed'] = 0; |
|
| 1218 | + } |
|
| 932 | 1219 | $data['altitude'] = $line['altitude']; |
| 933 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 1220 | + if (isset($line['course'])) { |
|
| 1221 | + $data['heading'] = $line['course']; |
|
| 1222 | + } |
|
| 934 | 1223 | //else $data['heading'] = 0; |
| 935 | 1224 | $data['aircraft_type'] = $line['stealth']; |
| 936 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1225 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
| 1226 | + $data['noarchive'] = true; |
|
| 1227 | + } |
|
| 937 | 1228 | $data['id_source'] = $id_source; |
| 938 | 1229 | $data['format_source'] = 'aprs'; |
| 939 | 1230 | $data['source_name'] = $line['source']; |
| 940 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1231 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1232 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1233 | + } |
|
| 941 | 1234 | $currentdate = date('Y-m-d H:i:s'); |
| 942 | 1235 | $aprsdate = strtotime($data['datetime']); |
| 943 | 1236 | // Accept data if time <= system time + 20s |
| 944 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 945 | - else { |
|
| 946 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 947 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1237 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1238 | + $send = $SI->add($data); |
|
| 1239 | + } else { |
|
| 1240 | + if ($line['stealth'] != 0) { |
|
| 1241 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1242 | + } else { |
|
| 1243 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1244 | + } |
|
| 948 | 1245 | } |
| 949 | 1246 | unset($data); |
| 950 | 1247 | } |
| 951 | 1248 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 952 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 1249 | + elseif ($line == true && $globalDebug) { |
|
| 1250 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 1251 | + } |
|
| 953 | 1252 | } |
| 954 | 1253 | } else { |
| 955 | 1254 | $line = explode(',', $buffer); |
@@ -977,25 +1276,42 @@ discard block |
||
| 977 | 1276 | $data['ground'] = $line[21]; |
| 978 | 1277 | $data['emergency'] = $line[19]; |
| 979 | 1278 | $data['format_source'] = 'sbs'; |
| 980 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 981 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1279 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1280 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1281 | + } |
|
| 1282 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1283 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1284 | + } |
|
| 982 | 1285 | $data['id_source'] = $id_source; |
| 983 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 984 | - else $error = true; |
|
| 1286 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1287 | + $send = $SI->add($data); |
|
| 1288 | + } else { |
|
| 1289 | + $error = true; |
|
| 1290 | + } |
|
| 985 | 1291 | unset($data); |
| 986 | - } else $error = true; |
|
| 1292 | + } else { |
|
| 1293 | + $error = true; |
|
| 1294 | + } |
|
| 987 | 1295 | if ($error) { |
| 988 | 1296 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 989 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1297 | + if ($globalDebug) { |
|
| 1298 | + echo "Not a message. Ignoring... \n"; |
|
| 1299 | + } |
|
| 990 | 1300 | } else { |
| 991 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1301 | + if ($globalDebug) { |
|
| 1302 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1303 | + } |
|
| 992 | 1304 | if ($globalDebug) { |
| 993 | 1305 | echo $buffer; |
| 994 | 1306 | print_r($line); |
| 995 | 1307 | } |
| 996 | 1308 | //socket_close($r); |
| 997 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 998 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1309 | + if ($globalDebug) { |
|
| 1310 | + echo "Reconnect after an error...\n"; |
|
| 1311 | + } |
|
| 1312 | + if ($format == 'aprs') { |
|
| 1313 | + $aprs_connect = 0; |
|
| 1314 | + } |
|
| 999 | 1315 | $sourceer[$nb] = $globalSources[$nb]; |
| 1000 | 1316 | connect_all($sourceer); |
| 1001 | 1317 | $sourceer = array(); |
@@ -1003,10 +1319,14 @@ discard block |
||
| 1003 | 1319 | } |
| 1004 | 1320 | } |
| 1005 | 1321 | // Sleep for xxx microseconds |
| 1006 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1322 | + if (isset($globalSBSSleep)) { |
|
| 1323 | + usleep($globalSBSSleep); |
|
| 1324 | + } |
|
| 1007 | 1325 | } else { |
| 1008 | 1326 | if ($format == 'flightgearmp') { |
| 1009 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1327 | + if ($globalDebug) { |
|
| 1328 | + echo "Reconnect FlightGear MP..."; |
|
| 1329 | + } |
|
| 1010 | 1330 | //@socket_close($r); |
| 1011 | 1331 | sleep($globalMinFetch); |
| 1012 | 1332 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1015,10 +1335,15 @@ discard block |
||
| 1015 | 1335 | break; |
| 1016 | 1336 | |
| 1017 | 1337 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1018 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1019 | - else $tt[$format] = 0; |
|
| 1338 | + if (isset($tt[$format])) { |
|
| 1339 | + $tt[$format]++; |
|
| 1340 | + } else { |
|
| 1341 | + $tt[$format] = 0; |
|
| 1342 | + } |
|
| 1020 | 1343 | if ($tt[$format] > 30) { |
| 1021 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1344 | + if ($globalDebug) { |
|
| 1345 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1346 | + } |
|
| 1022 | 1347 | //@socket_close($r); |
| 1023 | 1348 | sleep(2); |
| 1024 | 1349 | $aprs_connect = 0; |
@@ -1034,12 +1359,18 @@ discard block |
||
| 1034 | 1359 | } |
| 1035 | 1360 | } else { |
| 1036 | 1361 | $error = socket_strerror(socket_last_error()); |
| 1037 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1362 | + if ($globalDebug) { |
|
| 1363 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1364 | + } |
|
| 1038 | 1365 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1039 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1366 | + if (isset($globalDebug)) { |
|
| 1367 | + echo "Restarting...\n"; |
|
| 1368 | + } |
|
| 1040 | 1369 | // Restart the script if possible |
| 1041 | 1370 | if (is_array($sockets)) { |
| 1042 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1371 | + if ($globalDebug) { |
|
| 1372 | + echo "Shutdown all sockets..."; |
|
| 1373 | + } |
|
| 1043 | 1374 | |
| 1044 | 1375 | foreach ($sockets as $sock) { |
| 1045 | 1376 | @socket_shutdown($sock,2); |
@@ -1047,7 +1378,9 @@ discard block |
||
| 1047 | 1378 | } |
| 1048 | 1379 | |
| 1049 | 1380 | } |
| 1050 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1381 | + if ($globalDebug) { |
|
| 1382 | + echo "Restart all connections..."; |
|
| 1383 | + } |
|
| 1051 | 1384 | sleep(2); |
| 1052 | 1385 | $time = time(); |
| 1053 | 1386 | //connect_all($hosts); |
@@ -1058,7 +1391,9 @@ discard block |
||
| 1058 | 1391 | } |
| 1059 | 1392 | } |
| 1060 | 1393 | if ($globalDaemon === false) { |
| 1061 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1394 | + if ($globalDebug) { |
|
| 1395 | + echo 'Check all...'."\n"; |
|
| 1396 | + } |
|
| 1062 | 1397 | $SI->checkAll(); |
| 1063 | 1398 | } |
| 1064 | 1399 | } |