@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | date_default_timezone_set('UTC'); |
27 | 27 | //waypoint plotting |
28 | 28 | $output .= '{"type": "Feature",'; |
29 | - $output .= '"properties": {'; |
|
29 | + $output .= '"properties": {'; |
|
30 | 30 | $output .= '"segment_name": "'.$spotter_item['segment_name'].'",'; |
31 | 31 | $output .= '"base": "'.$spotter_item['base'].'",'; |
32 | 32 | $output .= '"top": "'.$spotter_item['top'].'",'; |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | $output .= '"stroke": "#f0f0f0",'; |
50 | 50 | $output .= '"stroke-width": 2'; |
51 | 51 | // } |
52 | - $output .= '},'; |
|
53 | - $output .= '"geometry": {'; |
|
52 | + $output .= '},'; |
|
53 | + $output .= '"geometry": {'; |
|
54 | 54 | $output .= '"type": "LineString",'; |
55 | 55 | $output .= '"coordinates": ['; |
56 | - //$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']'; |
|
57 | - $output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']'; |
|
56 | + //$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']'; |
|
57 | + $output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']'; |
|
58 | 58 | // $output .= '['.$spotter_item['latitude_begin'].', '.$spotter_item['longitude_begin'].'], ['.$spotter_item['latitude_end'].', '.$spotter_item['longitude_end'].']'; |
59 | 59 | $output .= ']'; |
60 | - $output .= '}'; |
|
60 | + $output .= '}'; |
|
61 | 61 | /* $output .= '"geometry": {'; |
62 | 62 | $output .= '"type": "Point",'; |
63 | 63 | $output .= '"coordinates": ['; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $output .= '},'; |
69 | 69 | //waypoint plotting |
70 | 70 | $output .= '{"type": "Feature",'; |
71 | - $output .= '"properties": {'; |
|
71 | + $output .= '"properties": {'; |
|
72 | 72 | $output .= '"ident": "'.$spotter_item['name_begin'].'",'; |
73 | 73 | $output .= '"high": "'.$spotter_item['high'].'",'; |
74 | 74 | $output .= '"alt": "'.$spotter_item['base'].'",'; |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | $output .= '"marker-size": "small",'; |
99 | 99 | $output .= '"marker-color": "#0000ff"'; |
100 | 100 | } |
101 | - $output .= '},'; |
|
102 | - $output .= '"geometry": {'; |
|
101 | + $output .= '},'; |
|
102 | + $output .= '"geometry": {'; |
|
103 | 103 | $output .= '"type": "Point",'; |
104 | 104 | $output .= '"coordinates": ['; |
105 | - $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);; |
|
105 | + $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);; |
|
106 | 106 | $output .= ']'; |
107 | - $output .= '}'; |
|
107 | + $output .= '}'; |
|
108 | 108 | |
109 | 109 | $output .= '},'; |
110 | 110 | $output .= '{"type": "Feature",'; |
111 | - $output .= '"properties": {'; |
|
111 | + $output .= '"properties": {'; |
|
112 | 112 | $output .= '"ident": "'.$spotter_item['name_end'].'",'; |
113 | 113 | $output .= '"high": "'.$spotter_item['high'].'",'; |
114 | 114 | $output .= '"alt": "'.$spotter_item['top'].'",'; |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | $output .= '"marker-size": "small",'; |
146 | 146 | $output .= '"marker-color": "#0000ff"'; |
147 | 147 | } |
148 | - $output .= '},'; |
|
149 | - $output .= '"geometry": {'; |
|
148 | + $output .= '},'; |
|
149 | + $output .= '"geometry": {'; |
|
150 | 150 | $output .= '"type": "Point",'; |
151 | 151 | $output .= '"coordinates": ['; |
152 | - $output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048); |
|
152 | + $output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048); |
|
153 | 153 | $output .= ']'; |
154 | - $output .= '}'; |
|
154 | + $output .= '}'; |
|
155 | 155 | |
156 | 156 | $output .= '},'; |
157 | 157 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | if (isset($_GET['coord'])) |
12 | 12 | { |
13 | - $coords = explode(',',$_GET['coord']); |
|
13 | + $coords = explode(',', $_GET['coord']); |
|
14 | 14 | $spotter_array = $Spotter->getAllWaypointsInfobyCoord($coords); |
15 | 15 | } else { |
16 | 16 | die; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | if (!empty($spotter_array)) |
22 | 22 | { |
23 | 23 | // print_r($spotter_array); |
24 | - foreach($spotter_array as $spotter_item) |
|
24 | + foreach ($spotter_array as $spotter_item) |
|
25 | 25 | { |
26 | 26 | date_default_timezone_set('UTC'); |
27 | 27 | //waypoint plotting |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $output .= '"geometry": {'; |
103 | 103 | $output .= '"type": "Point",'; |
104 | 104 | $output .= '"coordinates": ['; |
105 | - $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);; |
|
105 | + $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048); ; |
|
106 | 106 | $output .= ']'; |
107 | 107 | $output .= '}'; |
108 | 108 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | <button type="button" class="close">×</button> |
8 | 8 | <?php |
9 | 9 | |
10 | -$airspaceid = filter_input(INPUT_GET,'airspace',FILTER_SANITIZE_NUMBER_INT); |
|
10 | +$airspaceid = filter_input(INPUT_GET, 'airspace', FILTER_SANITIZE_NUMBER_INT); |
|
11 | 11 | //$notamref = urldecode($notamref); |
12 | 12 | if ($globalDBdriver == 'mysql') { |
13 | 13 | $query = "SELECT * FROM airspace WHERE ogr_fid = :id"; |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | try { |
19 | 19 | $sth = $Connection->db->prepare($query); |
20 | 20 | $sth->execute(array(':id' => $airspaceid)); |
21 | -} catch(PDOException $e) { |
|
21 | +} catch (PDOException $e) { |
|
22 | 22 | echo "error"; |
23 | 23 | } |
24 | -$result=$sth->fetchAll(PDO::FETCH_ASSOC); |
|
24 | +$result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
25 | 25 | $airspace = $result[0]; |
26 | 26 | date_default_timezone_set('UTC'); |
27 | 27 | print '<div class="top">'; |
@@ -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']; |
@@ -9,7 +9,7 @@ |
||
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) if (strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
13 | 13 | if ($j > 1) { |
14 | 14 | echo "Script is already runnning..."; |
15 | 15 | die(); |
@@ -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..."; |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | die; |
38 | 38 | } |
39 | 39 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
40 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
40 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
44 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
45 | 45 | //if (isset($options['s'])) $hosts = array($options['s']); |
46 | 46 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
47 | 47 | if (isset($options['s'])) { |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | else $id_source = 1; |
57 | 57 | if (isset($globalServer) && $globalServer) { |
58 | 58 | if ($globalDebug) echo "Using Server Mode\n"; |
59 | - $SI=new SpotterServer(); |
|
60 | -} else $SI=new SpotterImport($Connection->db); |
|
59 | + $SI = new SpotterServer(); |
|
60 | +} else $SI = new SpotterImport($Connection->db); |
|
61 | 61 | //$APRS=new APRS($Connection->db); |
62 | -$SBS=new SBS(); |
|
63 | -$ACARS=new ACARS($Connection->db); |
|
64 | -$Common=new Common(); |
|
62 | +$SBS = new SBS(); |
|
63 | +$ACARS = new ACARS($Connection->db); |
|
64 | +$Common = new Common(); |
|
65 | 65 | date_default_timezone_set('UTC'); |
66 | 66 | //$servertz = system('date +%Z'); |
67 | 67 | // signal handler - playing nice with sockets and dump1090 |
68 | 68 | if (function_exists('pcntl_fork')) { |
69 | - pcntl_signal(SIGINT, function() { |
|
69 | + pcntl_signal(SIGINT, function() { |
|
70 | 70 | global $sockets; |
71 | 71 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
72 | 72 | die("Bye!\n"); |
@@ -109,34 +109,34 @@ discard block |
||
109 | 109 | |
110 | 110 | function connect_all($hosts) { |
111 | 111 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
112 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
112 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs; |
|
113 | 113 | if ($globalDebug) echo 'Connect to all...'."\n"; |
114 | 114 | foreach ($hosts as $id => $value) { |
115 | 115 | $host = $value['host']; |
116 | 116 | $globalSources[$id]['last_exec'] = 0; |
117 | 117 | // Here we check type of source(s) |
118 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
119 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
118 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
119 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
120 | 120 | //$formats[$id] = 'deltadbtxt'; |
121 | 121 | $globalSources[$id]['format'] = 'deltadbtxt'; |
122 | 122 | //$last_exec['deltadbtxt'] = 0; |
123 | 123 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
124 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
124 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'vatsimtxt'; |
126 | 126 | $globalSources[$id]['format'] = 'vatsimtxt'; |
127 | 127 | //$last_exec['vatsimtxt'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
129 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
129 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'aircraftlistjson'; |
131 | 131 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
132 | 132 | //$last_exec['aircraftlistjson'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
134 | - } else if (preg_match('/opensky/i',$host)) { |
|
134 | + } else if (preg_match('/opensky/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
136 | 136 | $globalSources[$id]['format'] = 'opensky'; |
137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
138 | 138 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
139 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
139 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
140 | 140 | //$formats[$id] = 'radarvirtueljson'; |
141 | 141 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
142 | 142 | //$last_exec['radarvirtueljson'] = 0; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
146 | 146 | exit(0); |
147 | 147 | } |
148 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
148 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
149 | 149 | //$formats[$id] = 'planeupdatefaa'; |
150 | 150 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
151 | 151 | //$last_exec['planeupdatefaa'] = 0; |
@@ -154,26 +154,26 @@ discard block |
||
154 | 154 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
155 | 155 | exit(0); |
156 | 156 | } |
157 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
157 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
158 | 158 | //$formats[$id] = 'phpvmacars'; |
159 | 159 | $globalSources[$id]['format'] = 'phpvmacars'; |
160 | 160 | //$last_exec['phpvmacars'] = 0; |
161 | 161 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
162 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
162 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
163 | 163 | //$formats[$id] = 'phpvmacars'; |
164 | 164 | $globalSources[$id]['format'] = 'vam'; |
165 | 165 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
166 | - } else if (preg_match('/whazzup/i',$host)) { |
|
166 | + } else if (preg_match('/whazzup/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'whazzup'; |
168 | 168 | $globalSources[$id]['format'] = 'whazzup'; |
169 | 169 | //$last_exec['whazzup'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
171 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
171 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
172 | 172 | //$formats[$id] = 'pirepsjson'; |
173 | 173 | $globalSources[$id]['format'] = 'pirepsjson'; |
174 | 174 | //$last_exec['pirepsjson'] = 0; |
175 | 175 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
176 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
176 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
177 | 177 | //$formats[$id] = 'fr24json'; |
178 | 178 | $globalSources[$id]['format'] = 'fr24json'; |
179 | 179 | //$last_exec['fr24json'] = 0; |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | exit(0); |
184 | 184 | } |
185 | 185 | //} else if (preg_match('/10001/',$host)) { |
186 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
186 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
187 | 187 | //$formats[$id] = 'tsv'; |
188 | 188 | $globalSources[$id]['format'] = 'tsv'; |
189 | 189 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
190 | 190 | } |
191 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
191 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
192 | 192 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
193 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
194 | - $hostport = explode(':',$host); |
|
193 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
194 | + $hostport = explode(':', $host); |
|
195 | 195 | if (isset($hostport[1])) { |
196 | 196 | $port = $hostport[1]; |
197 | 197 | $hostn = $hostport[0]; |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | $hostn = $globalSources[$id]['host']; |
201 | 201 | } |
202 | 202 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
203 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
203 | + $s = create_socket($hostn, $port, $errno, $errstr); |
|
204 | 204 | } else { |
205 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
205 | + $s = create_socket_udp($hostn, $port, $errno, $errstr); |
|
206 | 206 | } |
207 | 207 | if ($s) { |
208 | 208 | $sockets[$id] = $s; |
209 | 209 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
210 | - if (preg_match('/aprs/',$hostn)) { |
|
210 | + if (preg_match('/aprs/', $hostn)) { |
|
211 | 211 | //$formats[$id] = 'aprs'; |
212 | 212 | $globalSources[$id]['format'] = 'aprs'; |
213 | 213 | //$aprs_connect = 0; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
249 | 249 | else $timeout = 20; |
250 | 250 | $errno = ''; |
251 | -$errstr=''; |
|
251 | +$errstr = ''; |
|
252 | 252 | |
253 | 253 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
254 | 254 | /* Initiate connections to all the hosts simultaneously */ |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | if ($use_aprs) { |
279 | 279 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
280 | - $APRS=new APRS(); |
|
280 | + $APRS = new APRS(); |
|
281 | 281 | $aprs_connect = 0; |
282 | 282 | $aprs_keep = 120; |
283 | 283 | $aprs_last_tx = time(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | else $aprs_ssid = 'FAM'; |
289 | 289 | //else $aprs_ssid = 'PerlEx'; |
290 | 290 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
291 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
291 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
292 | 292 | if ($aprs_full) $aprs_filter = ''; |
293 | 293 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
294 | 294 | else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | sleep(1); |
300 | 300 | if ($globalDebug) echo "SCAN MODE \n\n"; |
301 | 301 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
302 | -$endtime = time()+$globalCronEnd; |
|
302 | +$endtime = time() + $globalCronEnd; |
|
303 | 303 | $i = 1; |
304 | 304 | $tt = array(); |
305 | 305 | // Delete all ATC |
306 | 306 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
307 | - $ATC=new ATC($Connection->db); |
|
307 | + $ATC = new ATC($Connection->db); |
|
308 | 308 | } |
309 | 309 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
310 | 310 | $ATC->deleteAll(); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
314 | 314 | while ($i > 0) { |
315 | - if (!$globalDaemon) $i = $endtime-time(); |
|
315 | + if (!$globalDaemon) $i = $endtime - time(); |
|
316 | 316 | // Delete old ATC |
317 | 317 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
318 | 318 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | if ($max != $globalMinFetch) { |
328 | 328 | if ($globalDebug) echo 'Sleeping...'."\n"; |
329 | - sleep($globalMinFetch-$max+2); |
|
329 | + sleep($globalMinFetch - $max + 2); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
338 | 338 | //$buffer = $Common->getData($hosts[$id]); |
339 | 339 | $buffer = $Common->getData($value['host']); |
340 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
341 | - $buffer = explode('\n',$buffer); |
|
340 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
341 | + $buffer = explode('\n', $buffer); |
|
342 | 342 | foreach ($buffer as $line) { |
343 | 343 | if ($line != '') { |
344 | 344 | $line = explode(',', $line); |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) { |
368 | 368 | //$buffer = $Common->getData($hosts[$id]); |
369 | 369 | $buffer = $Common->getData($value['host']); |
370 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
371 | - $buffer = explode('\n',$buffer); |
|
370 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
371 | + $buffer = explode('\n', $buffer); |
|
372 | 372 | foreach ($buffer as $line) { |
373 | 373 | if ($line != '') { |
374 | 374 | $line = explode(':', $line); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $data['id'] = $line[1].'-'.$line[0]; |
378 | 378 | $data['pilot_id'] = $line[1]; |
379 | 379 | $data['pilot_name'] = $line[2]; |
380 | - $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
|
380 | + $data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT); |
|
381 | 381 | $data['ident'] = $line[0]; // ident |
382 | 382 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
383 | 383 | $data['speed'] = $line[8]; // speed |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
394 | 394 | if (isset($line[37])) $data['last_update'] = $line[37]; |
395 | 395 | $data['departure_airport_icao'] = $line[11]; |
396 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
396 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
397 | 397 | $data['arrival_airport_icao'] = $line[13]; |
398 | 398 | $data['frequency'] = $line[4]; |
399 | 399 | $data['type'] = $line[18]; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $data['id_source'] = $id_source; |
403 | 403 | //$data['arrival_airport_time'] = ; |
404 | 404 | if ($line[9] != '') { |
405 | - $aircraft_data = explode('/',$line[9]); |
|
405 | + $aircraft_data = explode('/', $line[9]); |
|
406 | 406 | if (isset($aircraft_data[1])) { |
407 | 407 | $data['aircraft_icao'] = $aircraft_data[1]; |
408 | 408 | } |
@@ -416,9 +416,9 @@ discard block |
||
416 | 416 | if ($line[3] == 'PILOT') $SI->add($data); |
417 | 417 | elseif ($line[3] == 'ATC') { |
418 | 418 | //print_r($data); |
419 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
420 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
421 | - $typec = substr($data['ident'],-3); |
|
419 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
420 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
421 | + $typec = substr($data['ident'], -3); |
|
422 | 422 | if ($typec == 'APP') $data['type'] = 'Approach'; |
423 | 423 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
424 | 424 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
430 | 430 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
431 | 431 | |
432 | - 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']); |
|
432 | + 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 | 433 | } |
434 | 434 | unset($data); |
435 | 435 | } |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | $last_exec[$id]['last'] = time(); |
441 | 441 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
442 | 442 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
443 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
443 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
444 | 444 | if ($buffer != '') { |
445 | - $all_data = json_decode($buffer,true); |
|
445 | + $all_data = json_decode($buffer, true); |
|
446 | 446 | if (isset($all_data['acList'])) { |
447 | 447 | foreach ($all_data['acList'] as $line) { |
448 | 448 | $data = array(); |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
497 | 497 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
498 | 498 | $buffer = $Common->getData($value['host']); |
499 | - $all_data = json_decode($buffer,true); |
|
499 | + $all_data = json_decode($buffer, true); |
|
500 | 500 | if (isset($all_data['planes'])) { |
501 | 501 | foreach ($all_data['planes'] as $key => $line) { |
502 | 502 | $data = array(); |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | $data['emergency'] = ''; // emergency |
513 | 513 | $data['registration'] = $line[2]; |
514 | 514 | $data['aircraft_icao'] = $line[0]; |
515 | - $deparr = explode('-',$line[1]); |
|
515 | + $deparr = explode('-', $line[1]); |
|
516 | 516 | if (count($deparr) == 2) { |
517 | 517 | $data['departure_airport_icao'] = $deparr[0]; |
518 | 518 | $data['arrival_airport_icao'] = $deparr[1]; |
519 | 519 | } |
520 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
520 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
521 | 521 | $data['format_source'] = 'planeupdatefaa'; |
522 | 522 | $data['id_source'] = $id_source; |
523 | 523 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $last_exec[$id]['last'] = time(); |
530 | 530 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
531 | 531 | $buffer = $Common->getData($value['host']); |
532 | - $all_data = json_decode($buffer,true); |
|
532 | + $all_data = json_decode($buffer, true); |
|
533 | 533 | if (isset($all_data['states'])) { |
534 | 534 | foreach ($all_data['states'] as $key => $line) { |
535 | 535 | $data = array(); |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | //$data['emergency'] = ''; // emergency |
546 | 546 | //$data['registration'] = $line[2]; |
547 | 547 | //$data['aircraft_icao'] = $line[0]; |
548 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
548 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
549 | 549 | $data['format_source'] = 'opensky'; |
550 | 550 | $data['id_source'] = $id_source; |
551 | 551 | $SI->add($data); |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
559 | 559 | //$buffer = $Common->getData($hosts[$id]); |
560 | 560 | $buffer = $Common->getData($value['host']); |
561 | - $all_data = json_decode($buffer,true); |
|
561 | + $all_data = json_decode($buffer, true); |
|
562 | 562 | foreach ($all_data as $key => $line) { |
563 | 563 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
564 | 564 | $data = array(); |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
590 | 590 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
591 | 591 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
592 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
592 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
593 | 593 | //echo $buffer; |
594 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
595 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
596 | - $all_data = json_decode($buffer,true); |
|
594 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
595 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
596 | + $all_data = json_decode($buffer, true); |
|
597 | 597 | if (json_last_error() != JSON_ERROR_NONE) { |
598 | 598 | die(json_last_error_msg()); |
599 | 599 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | //$data['departure_airport_iata'] = $line[11]; |
616 | 616 | //$data['arrival_airport_iata'] = $line[12]; |
617 | 617 | //$data['emergency'] = ''; // emergency |
618 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
618 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
619 | 619 | $data['format_source'] = 'radarvirtueljson'; |
620 | 620 | $data['id_source'] = $id_source; |
621 | 621 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -630,13 +630,13 @@ discard block |
||
630 | 630 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
631 | 631 | //$buffer = $Common->getData($hosts[$id]); |
632 | 632 | $buffer = $Common->getData($value['host'].'?'.time()); |
633 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
633 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
634 | 634 | |
635 | 635 | if (isset($all_data['pireps'])) { |
636 | 636 | foreach ($all_data['pireps'] as $line) { |
637 | 637 | $data = array(); |
638 | 638 | $data['id'] = $line['id']; |
639 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
639 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
640 | 640 | $data['ident'] = $line['callsign']; // ident |
641 | 641 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
642 | 642 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -665,9 +665,9 @@ discard block |
||
665 | 665 | $SI->add($data); |
666 | 666 | // print_r($data); |
667 | 667 | } elseif ($line['icon'] == 'ct') { |
668 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
669 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
670 | - $typec = substr($data['ident'],-3); |
|
668 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
669 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
670 | + $typec = substr($data['ident'], -3); |
|
671 | 671 | $data['type'] = ''; |
672 | 672 | if ($typec == 'APP') $data['type'] = 'Approach'; |
673 | 673 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
679 | 679 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
680 | 680 | else $data['type'] = 'Observer'; |
681 | - echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
|
681 | + echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']); |
|
682 | 682 | } |
683 | 683 | unset($data); |
684 | 684 | } |
@@ -690,13 +690,13 @@ discard block |
||
690 | 690 | //$buffer = $Common->getData($hosts[$id]); |
691 | 691 | if ($globalDebug) echo 'Get Data...'."\n"; |
692 | 692 | $buffer = $Common->getData($value['host']); |
693 | - $all_data = json_decode($buffer,true); |
|
693 | + $all_data = json_decode($buffer, true); |
|
694 | 694 | if ($buffer != '' && is_array($all_data)) { |
695 | 695 | foreach ($all_data as $line) { |
696 | 696 | $data = array(); |
697 | 697 | //$data['id'] = $line['id']; // id not usable |
698 | 698 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
699 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
699 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
700 | 700 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
701 | 701 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
702 | 702 | $data['ident'] = $line['flightnum']; // ident |
@@ -719,12 +719,12 @@ discard block |
||
719 | 719 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
720 | 720 | if (isset($line['aircraftname'])) { |
721 | 721 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
722 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
723 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
722 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
723 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
724 | 724 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
725 | 725 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
726 | 726 | else { |
727 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
727 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
728 | 728 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
729 | 729 | else $data['aircraft_icao'] = $line['aircraftname']; |
730 | 730 | } |
@@ -746,13 +746,13 @@ discard block |
||
746 | 746 | //$buffer = $Common->getData($hosts[$id]); |
747 | 747 | if ($globalDebug) echo 'Get Data...'."\n"; |
748 | 748 | $buffer = $Common->getData($value['host']); |
749 | - $all_data = json_decode($buffer,true); |
|
749 | + $all_data = json_decode($buffer, true); |
|
750 | 750 | if ($buffer != '' && is_array($all_data)) { |
751 | 751 | foreach ($all_data as $line) { |
752 | 752 | $data = array(); |
753 | 753 | //$data['id'] = $line['id']; // id not usable |
754 | 754 | $data['id'] = $line['flight_id']; |
755 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
755 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
756 | 756 | $data['pilot_name'] = $line['pilot_name']; |
757 | 757 | $data['pilot_id'] = $line['pilot_id']; |
758 | 758 | $data['ident'] = $line['callsign']; // ident |
@@ -802,9 +802,9 @@ discard block |
||
802 | 802 | //$value = $formats[$nb]; |
803 | 803 | $format = $globalSources[$nb]['format']; |
804 | 804 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') { |
805 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
805 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
806 | 806 | } else { |
807 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
807 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
808 | 808 | } |
809 | 809 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
810 | 810 | //echo $buffer."\n"; |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
813 | 813 | $error = false; |
814 | 814 | //$SI::del(); |
815 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
815 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
816 | 816 | // SBS format is CSV format |
817 | 817 | if ($buffer != '') { |
818 | 818 | $tt[$format] = 0; |
@@ -831,10 +831,10 @@ discard block |
||
831 | 831 | } elseif ($format == 'flightgearsp') { |
832 | 832 | //echo $buffer."\n"; |
833 | 833 | if (strlen($buffer) > 5) { |
834 | - $line = explode(',',$buffer); |
|
834 | + $line = explode(',', $buffer); |
|
835 | 835 | $data = array(); |
836 | 836 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
837 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
837 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
838 | 838 | $data['ident'] = $line[6]; |
839 | 839 | $data['aircraft_name'] = $line[7]; |
840 | 840 | $data['longitude'] = $line[1]; |
@@ -845,21 +845,21 @@ discard block |
||
845 | 845 | $data['datetime'] = date('Y-m-d H:i:s'); |
846 | 846 | $data['format_source'] = 'flightgearsp'; |
847 | 847 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
848 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
848 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
849 | 849 | } |
850 | 850 | } elseif ($format == 'acars') { |
851 | 851 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
852 | 852 | $ACARS->add(trim($buffer)); |
853 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
853 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
854 | 854 | $ACARS->deleteLiveAcarsData(); |
855 | 855 | } elseif ($format == 'flightgearmp') { |
856 | - if (substr($buffer,0,1) != '#') { |
|
856 | + if (substr($buffer, 0, 1) != '#') { |
|
857 | 857 | $data = array(); |
858 | 858 | //echo $buffer."\n"; |
859 | - $line = explode(' ',$buffer); |
|
859 | + $line = explode(' ', $buffer); |
|
860 | 860 | if (count($line) == 11) { |
861 | - $userserver = explode('@',$line[0]); |
|
862 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
861 | + $userserver = explode('@', $line[0]); |
|
862 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
863 | 863 | $data['ident'] = $userserver[0]; |
864 | 864 | $data['registration'] = $userserver[0]; |
865 | 865 | $data['latitude'] = $line[4]; |
@@ -867,24 +867,24 @@ discard block |
||
867 | 867 | $data['altitude'] = $line[6]; |
868 | 868 | $data['datetime'] = date('Y-m-d H:i:s'); |
869 | 869 | $aircraft_type = $line[10]; |
870 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
871 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
870 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
871 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
872 | 872 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
873 | 873 | } |
874 | 874 | } |
875 | 875 | } elseif ($format == 'beast') { |
876 | 876 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
877 | 877 | die; |
878 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
878 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
879 | 879 | $line = explode("\t", $buffer); |
880 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
880 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
881 | 881 | $key = $line[$k]; |
882 | - $lined[$key] = $line[$k+1]; |
|
882 | + $lined[$key] = $line[$k + 1]; |
|
883 | 883 | } |
884 | 884 | if (count($lined) > 3) { |
885 | 885 | $data['hex'] = $lined['hexid']; |
886 | 886 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
887 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
887 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
888 | 888 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
889 | 889 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
890 | 890 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -902,24 +902,24 @@ discard block |
||
902 | 902 | } else $error = true; |
903 | 903 | } elseif ($format == 'aprs' && $use_aprs) { |
904 | 904 | if ($aprs_connect == 0) { |
905 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
905 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
906 | 906 | $aprs_connect = 1; |
907 | 907 | } |
908 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
908 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
909 | 909 | $aprs_last_tx = time(); |
910 | 910 | $data_aprs = "# Keep alive"; |
911 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
911 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
912 | 912 | } |
913 | 913 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
914 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
915 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
916 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
914 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
915 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
916 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
917 | 917 | $line = $APRS->parse($buffer); |
918 | 918 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
919 | 919 | $data = array(); |
920 | 920 | //print_r($line); |
921 | 921 | $data['hex'] = $line['address']; |
922 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
922 | + $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
923 | 923 | //$data['datetime'] = date('Y-m-d H:i:s'); |
924 | 924 | $data['ident'] = $line['ident']; |
925 | 925 | $data['latitude'] = $line['latitude']; |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | $currentdate = date('Y-m-d H:i:s'); |
940 | 940 | $aprsdate = strtotime($data['datetime']); |
941 | 941 | // Accept data if time <= system time + 20s |
942 | - 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); |
|
942 | + 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); |
|
943 | 943 | else { |
944 | 944 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
945 | 945 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | connect_all($sourceee); |
1025 | 1025 | $sourceee = array(); |
1026 | 1026 | //connect_all($globalSources); |
1027 | - $tt[$format]=0; |
|
1027 | + $tt[$format] = 0; |
|
1028 | 1028 | break; |
1029 | 1029 | } |
1030 | 1030 | } |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | } |
1033 | 1033 | } else { |
1034 | 1034 | $error = socket_strerror(socket_last_error()); |
1035 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1035 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1036 | 1036 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) { |
1037 | 1037 | if (isset($globalDebug)) echo "Restarting...\n"; |
1038 | 1038 | // Restart the script if possible |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | if ($globalDebug) echo "Shutdown all sockets..."; |
1041 | 1041 | |
1042 | 1042 | foreach ($sockets as $sock) { |
1043 | - @socket_shutdown($sock,2); |
|
1043 | + @socket_shutdown($sock, 2); |
|
1044 | 1044 | @socket_close($sock); |
1045 | 1045 | } |
1046 | 1046 |
@@ -19,44 +19,44 @@ discard block |
||
19 | 19 | // Check if schema is at latest version |
20 | 20 | $Connection = new Connection(); |
21 | 21 | if ($Connection->latest() === false) { |
22 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
23 | - exit(); |
|
22 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
23 | + exit(); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | // This is to be compatible with old version of settings.php |
28 | 28 | if (!isset($globalSources)) { |
29 | - if (isset($globalSBS1Hosts)) { |
|
30 | - //$hosts = $globalSBS1Hosts; |
|
31 | - foreach ($globalSBS1Hosts as $host) { |
|
32 | - $globalSources[] = array('host' => $host); |
|
33 | - } |
|
34 | - } else { |
|
35 | - if (!isset($globalSBS1Host)) { |
|
36 | - echo '$globalSources MUST be defined !'; |
|
37 | - die; |
|
29 | + if (isset($globalSBS1Hosts)) { |
|
30 | + //$hosts = $globalSBS1Hosts; |
|
31 | + foreach ($globalSBS1Hosts as $host) { |
|
32 | + $globalSources[] = array('host' => $host); |
|
33 | + } |
|
34 | + } else { |
|
35 | + if (!isset($globalSBS1Host)) { |
|
36 | + echo '$globalSources MUST be defined !'; |
|
37 | + die; |
|
38 | 38 | } |
39 | 39 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
40 | 40 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
41 | - } |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $options = getopt('s::',array('source::','server','idsource::')); |
45 | 45 | //if (isset($options['s'])) $hosts = array($options['s']); |
46 | 46 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
47 | 47 | if (isset($options['s'])) { |
48 | - $globalSources = array(); |
|
49 | - $globalSources[] = array('host' => $options['s']); |
|
48 | + $globalSources = array(); |
|
49 | + $globalSources[] = array('host' => $options['s']); |
|
50 | 50 | } elseif (isset($options['source'])) { |
51 | - $globalSources = array(); |
|
52 | - $globalSources[] = array('host' => $options['source']); |
|
51 | + $globalSources = array(); |
|
52 | + $globalSources[] = array('host' => $options['source']); |
|
53 | 53 | } |
54 | 54 | if (isset($options['server'])) $globalServer = TRUE; |
55 | 55 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
56 | 56 | else $id_source = 1; |
57 | 57 | if (isset($globalServer) && $globalServer) { |
58 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
59 | - $SI=new SpotterServer(); |
|
58 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
59 | + $SI=new SpotterServer(); |
|
60 | 60 | } else $SI=new SpotterImport($Connection->db); |
61 | 61 | //$APRS=new APRS($Connection->db); |
62 | 62 | $SBS=new SBS(); |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | //$servertz = system('date +%Z'); |
67 | 67 | // signal handler - playing nice with sockets and dump1090 |
68 | 68 | if (function_exists('pcntl_fork')) { |
69 | - pcntl_signal(SIGINT, function() { |
|
70 | - global $sockets; |
|
71 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
72 | - die("Bye!\n"); |
|
73 | - }); |
|
74 | - pcntl_signal_dispatch(); |
|
69 | + pcntl_signal(SIGINT, function() { |
|
70 | + global $sockets; |
|
71 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
72 | + die("Bye!\n"); |
|
73 | + }); |
|
74 | + pcntl_signal_dispatch(); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // let's try and connect |
@@ -80,161 +80,161 @@ discard block |
||
80 | 80 | $aprs_full = false; |
81 | 81 | |
82 | 82 | function create_socket($host, $port, &$errno, &$errstr) { |
83 | - $ip = gethostbyname($host); |
|
84 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
85 | - $r = @socket_connect($s, $ip, $port); |
|
86 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
87 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
88 | - return $s; |
|
89 | - } |
|
90 | - $errno = socket_last_error($s); |
|
91 | - $errstr = socket_strerror($errno); |
|
92 | - socket_close($s); |
|
93 | - return false; |
|
83 | + $ip = gethostbyname($host); |
|
84 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
85 | + $r = @socket_connect($s, $ip, $port); |
|
86 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
87 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
88 | + return $s; |
|
89 | + } |
|
90 | + $errno = socket_last_error($s); |
|
91 | + $errstr = socket_strerror($errno); |
|
92 | + socket_close($s); |
|
93 | + return false; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | function create_socket_udp($host, $port, &$errno, &$errstr) { |
97 | - echo "UDP !!"; |
|
98 | - $ip = gethostbyname($host); |
|
99 | - $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
100 | - $r = @socket_bind($s, $ip, $port); |
|
101 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
102 | - return $s; |
|
103 | - } |
|
104 | - $errno = socket_last_error($s); |
|
105 | - $errstr = socket_strerror($errno); |
|
106 | - socket_close($s); |
|
107 | - return false; |
|
97 | + echo "UDP !!"; |
|
98 | + $ip = gethostbyname($host); |
|
99 | + $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
100 | + $r = @socket_bind($s, $ip, $port); |
|
101 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
102 | + return $s; |
|
103 | + } |
|
104 | + $errno = socket_last_error($s); |
|
105 | + $errstr = socket_strerror($errno); |
|
106 | + socket_close($s); |
|
107 | + return false; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | function connect_all($hosts) { |
111 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
112 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
113 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
114 | - foreach ($hosts as $id => $value) { |
|
111 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
112 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
113 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
114 | + foreach ($hosts as $id => $value) { |
|
115 | 115 | $host = $value['host']; |
116 | 116 | $globalSources[$id]['last_exec'] = 0; |
117 | 117 | // Here we check type of source(s) |
118 | 118 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
119 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
120 | - //$formats[$id] = 'deltadbtxt'; |
|
121 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
122 | - //$last_exec['deltadbtxt'] = 0; |
|
123 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
124 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
125 | - //$formats[$id] = 'vatsimtxt'; |
|
126 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
127 | - //$last_exec['vatsimtxt'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
130 | - //$formats[$id] = 'aircraftlistjson'; |
|
131 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
132 | - //$last_exec['aircraftlistjson'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/opensky/i',$host)) { |
|
135 | - //$formats[$id] = 'aircraftlistjson'; |
|
136 | - $globalSources[$id]['format'] = 'opensky'; |
|
137 | - //$last_exec['aircraftlistjson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
139 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
140 | - //$formats[$id] = 'radarvirtueljson'; |
|
141 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
142 | - //$last_exec['radarvirtueljson'] = 0; |
|
143 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
144 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
145 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
146 | - exit(0); |
|
147 | - } |
|
148 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
149 | - //$formats[$id] = 'planeupdatefaa'; |
|
150 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
151 | - //$last_exec['planeupdatefaa'] = 0; |
|
152 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
153 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
154 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
155 | - exit(0); |
|
156 | - } |
|
157 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
158 | - //$formats[$id] = 'phpvmacars'; |
|
159 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
160 | - //$last_exec['phpvmacars'] = 0; |
|
161 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
162 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
163 | - //$formats[$id] = 'phpvmacars'; |
|
164 | - $globalSources[$id]['format'] = 'vam'; |
|
165 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/whazzup/i',$host)) { |
|
167 | - //$formats[$id] = 'whazzup'; |
|
168 | - $globalSources[$id]['format'] = 'whazzup'; |
|
169 | - //$last_exec['whazzup'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
172 | - //$formats[$id] = 'pirepsjson'; |
|
173 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
174 | - //$last_exec['pirepsjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
176 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
177 | - //$formats[$id] = 'fr24json'; |
|
178 | - $globalSources[$id]['format'] = 'fr24json'; |
|
179 | - //$last_exec['fr24json'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
181 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
182 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
183 | - exit(0); |
|
184 | - } |
|
185 | - //} else if (preg_match('/10001/',$host)) { |
|
186 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
187 | - //$formats[$id] = 'tsv'; |
|
188 | - $globalSources[$id]['format'] = 'tsv'; |
|
189 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
190 | - } |
|
191 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
192 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
193 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
194 | - $hostport = explode(':',$host); |
|
195 | - if (isset($hostport[1])) { |
|
119 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
120 | + //$formats[$id] = 'deltadbtxt'; |
|
121 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
122 | + //$last_exec['deltadbtxt'] = 0; |
|
123 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
124 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
125 | + //$formats[$id] = 'vatsimtxt'; |
|
126 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
127 | + //$last_exec['vatsimtxt'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
130 | + //$formats[$id] = 'aircraftlistjson'; |
|
131 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
132 | + //$last_exec['aircraftlistjson'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/opensky/i',$host)) { |
|
135 | + //$formats[$id] = 'aircraftlistjson'; |
|
136 | + $globalSources[$id]['format'] = 'opensky'; |
|
137 | + //$last_exec['aircraftlistjson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
139 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
140 | + //$formats[$id] = 'radarvirtueljson'; |
|
141 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
142 | + //$last_exec['radarvirtueljson'] = 0; |
|
143 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
144 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
145 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
146 | + exit(0); |
|
147 | + } |
|
148 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
149 | + //$formats[$id] = 'planeupdatefaa'; |
|
150 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
151 | + //$last_exec['planeupdatefaa'] = 0; |
|
152 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
153 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
154 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
155 | + exit(0); |
|
156 | + } |
|
157 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
158 | + //$formats[$id] = 'phpvmacars'; |
|
159 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
160 | + //$last_exec['phpvmacars'] = 0; |
|
161 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
162 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
163 | + //$formats[$id] = 'phpvmacars'; |
|
164 | + $globalSources[$id]['format'] = 'vam'; |
|
165 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/whazzup/i',$host)) { |
|
167 | + //$formats[$id] = 'whazzup'; |
|
168 | + $globalSources[$id]['format'] = 'whazzup'; |
|
169 | + //$last_exec['whazzup'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
172 | + //$formats[$id] = 'pirepsjson'; |
|
173 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
174 | + //$last_exec['pirepsjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
176 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
177 | + //$formats[$id] = 'fr24json'; |
|
178 | + $globalSources[$id]['format'] = 'fr24json'; |
|
179 | + //$last_exec['fr24json'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
181 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
182 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
183 | + exit(0); |
|
184 | + } |
|
185 | + //} else if (preg_match('/10001/',$host)) { |
|
186 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
187 | + //$formats[$id] = 'tsv'; |
|
188 | + $globalSources[$id]['format'] = 'tsv'; |
|
189 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
190 | + } |
|
191 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
192 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
193 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
194 | + $hostport = explode(':',$host); |
|
195 | + if (isset($hostport[1])) { |
|
196 | 196 | $port = $hostport[1]; |
197 | 197 | $hostn = $hostport[0]; |
198 | - } else { |
|
198 | + } else { |
|
199 | 199 | $port = $globalSources[$id]['port']; |
200 | 200 | $hostn = $globalSources[$id]['host']; |
201 | - } |
|
202 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
203 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
204 | - } else { |
|
205 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
206 | - } |
|
207 | - if ($s) { |
|
208 | - $sockets[$id] = $s; |
|
209 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
210 | - if (preg_match('/aprs/',$hostn)) { |
|
201 | + } |
|
202 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
203 | + $s = create_socket($hostn,$port, $errno, $errstr); |
|
204 | + } else { |
|
205 | + $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
206 | + } |
|
207 | + if ($s) { |
|
208 | + $sockets[$id] = $s; |
|
209 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
210 | + if (preg_match('/aprs/',$hostn)) { |
|
211 | 211 | //$formats[$id] = 'aprs'; |
212 | 212 | $globalSources[$id]['format'] = 'aprs'; |
213 | 213 | //$aprs_connect = 0; |
214 | 214 | //$use_aprs = true; |
215 | - } elseif ($port == '10001') { |
|
216 | - //$formats[$id] = 'tsv'; |
|
217 | - $globalSources[$id]['format'] = 'tsv'; |
|
218 | - } elseif ($port == '30002') { |
|
219 | - //$formats[$id] = 'raw'; |
|
220 | - $globalSources[$id]['format'] = 'raw'; |
|
221 | - } elseif ($port == '5001') { |
|
222 | - //$formats[$id] = 'raw'; |
|
223 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
224 | - } elseif ($port == '30005') { |
|
215 | + } elseif ($port == '10001') { |
|
216 | + //$formats[$id] = 'tsv'; |
|
217 | + $globalSources[$id]['format'] = 'tsv'; |
|
218 | + } elseif ($port == '30002') { |
|
219 | + //$formats[$id] = 'raw'; |
|
220 | + $globalSources[$id]['format'] = 'raw'; |
|
221 | + } elseif ($port == '5001') { |
|
222 | + //$formats[$id] = 'raw'; |
|
223 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
224 | + } elseif ($port == '30005') { |
|
225 | 225 | // Not yet supported |
226 | - //$formats[$id] = 'beast'; |
|
227 | - $globalSources[$id]['format'] = 'beast'; |
|
228 | - //} else $formats[$id] = 'sbs'; |
|
229 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
230 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
226 | + //$formats[$id] = 'beast'; |
|
227 | + $globalSources[$id]['format'] = 'beast'; |
|
228 | + //} else $formats[$id] = 'sbs'; |
|
229 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
230 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
231 | 231 | } |
232 | 232 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
233 | - } else { |
|
233 | + } else { |
|
234 | 234 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
235 | - } |
|
236 | - } |
|
237 | - } |
|
235 | + } |
|
236 | + } |
|
237 | + } |
|
238 | 238 | } |
239 | 239 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
240 | 240 | |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | die; |
262 | 262 | } |
263 | 263 | foreach ($globalSources as $key => $source) { |
264 | - if (!isset($source['format'])) { |
|
265 | - $globalSources[$key]['format'] = 'auto'; |
|
266 | - } |
|
264 | + if (!isset($source['format'])) { |
|
265 | + $globalSources[$key]['format'] = 'auto'; |
|
266 | + } |
|
267 | 267 | } |
268 | 268 | connect_all($globalSources); |
269 | 269 | foreach ($globalSources as $key => $source) { |
270 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
270 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
271 | 271 | $aprs_connect = 0; |
272 | 272 | $use_aprs = true; |
273 | 273 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
274 | 274 | break; |
275 | - } |
|
275 | + } |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | if ($use_aprs) { |
@@ -312,67 +312,67 @@ discard block |
||
312 | 312 | |
313 | 313 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
314 | 314 | while ($i > 0) { |
315 | - if (!$globalDaemon) $i = $endtime-time(); |
|
316 | - // Delete old ATC |
|
317 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
315 | + if (!$globalDaemon) $i = $endtime-time(); |
|
316 | + // Delete old ATC |
|
317 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
318 | 318 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
319 | - $ATC->deleteOldATC(); |
|
320 | - } |
|
319 | + $ATC->deleteOldATC(); |
|
320 | + } |
|
321 | 321 | |
322 | - if (count($last_exec) > 0) { |
|
322 | + if (count($last_exec) > 0) { |
|
323 | 323 | $max = $globalMinFetch; |
324 | 324 | foreach ($last_exec as $last) { |
325 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
325 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
326 | 326 | } |
327 | 327 | if ($max != $globalMinFetch) { |
328 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
329 | - sleep($globalMinFetch-$max+2); |
|
328 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
329 | + sleep($globalMinFetch-$max+2); |
|
330 | + } |
|
330 | 331 | } |
331 | - } |
|
332 | 332 | |
333 | 333 | |
334 | - //foreach ($formats as $id => $value) { |
|
335 | - foreach ($globalSources as $id => $value) { |
|
334 | + //foreach ($formats as $id => $value) { |
|
335 | + foreach ($globalSources as $id => $value) { |
|
336 | 336 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
337 | 337 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
338 | - //$buffer = $Common->getData($hosts[$id]); |
|
339 | - $buffer = $Common->getData($value['host']); |
|
340 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
341 | - $buffer = explode('\n',$buffer); |
|
342 | - foreach ($buffer as $line) { |
|
343 | - if ($line != '' && count($line) > 7) { |
|
344 | - $line = explode(',', $line); |
|
345 | - $data = array(); |
|
346 | - $data['hex'] = $line[1]; // hex |
|
347 | - $data['ident'] = $line[2]; // ident |
|
348 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
349 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
350 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
351 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
352 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
353 | - $data['verticalrate'] = ''; // vertical rate |
|
354 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
355 | - $data['emergency'] = ''; // emergency |
|
356 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
357 | - $data['format_source'] = 'deltadbtxt'; |
|
358 | - $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']; |
|
361 | - $SI->add($data); |
|
362 | - unset($data); |
|
363 | - } |
|
364 | - } |
|
365 | - $last_exec[$id]['last'] = time(); |
|
338 | + //$buffer = $Common->getData($hosts[$id]); |
|
339 | + $buffer = $Common->getData($value['host']); |
|
340 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
341 | + $buffer = explode('\n',$buffer); |
|
342 | + foreach ($buffer as $line) { |
|
343 | + if ($line != '' && count($line) > 7) { |
|
344 | + $line = explode(',', $line); |
|
345 | + $data = array(); |
|
346 | + $data['hex'] = $line[1]; // hex |
|
347 | + $data['ident'] = $line[2]; // ident |
|
348 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
349 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
350 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
351 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
352 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
353 | + $data['verticalrate'] = ''; // vertical rate |
|
354 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
355 | + $data['emergency'] = ''; // emergency |
|
356 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
357 | + $data['format_source'] = 'deltadbtxt'; |
|
358 | + $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']; |
|
361 | + $SI->add($data); |
|
362 | + unset($data); |
|
363 | + } |
|
364 | + } |
|
365 | + $last_exec[$id]['last'] = time(); |
|
366 | 366 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
367 | 367 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) { |
368 | - //$buffer = $Common->getData($hosts[$id]); |
|
369 | - $buffer = $Common->getData($value['host']); |
|
370 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
371 | - $buffer = explode('\n',$buffer); |
|
372 | - foreach ($buffer as $line) { |
|
373 | - if ($line != '') { |
|
374 | - $line = explode(':', $line); |
|
375 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
368 | + //$buffer = $Common->getData($hosts[$id]); |
|
369 | + $buffer = $Common->getData($value['host']); |
|
370 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
371 | + $buffer = explode('\n',$buffer); |
|
372 | + foreach ($buffer as $line) { |
|
373 | + if ($line != '') { |
|
374 | + $line = explode(':', $line); |
|
375 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
376 | 376 | $data = array(); |
377 | 377 | $data['id'] = $line[1].'-'.$line[0]; |
378 | 378 | $data['pilot_id'] = $line[1]; |
@@ -384,36 +384,36 @@ discard block |
||
384 | 384 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
385 | 385 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
386 | 386 | $data['latitude'] = $line[5]; // lat |
387 | - $data['longitude'] = $line[6]; // long |
|
388 | - $data['verticalrate'] = ''; // vertical rate |
|
389 | - $data['squawk'] = ''; // squawk |
|
390 | - $data['emergency'] = ''; // emergency |
|
391 | - $data['waypoints'] = $line[30]; |
|
387 | + $data['longitude'] = $line[6]; // long |
|
388 | + $data['verticalrate'] = ''; // vertical rate |
|
389 | + $data['squawk'] = ''; // squawk |
|
390 | + $data['emergency'] = ''; // emergency |
|
391 | + $data['waypoints'] = $line[30]; |
|
392 | 392 | $data['datetime'] = date('Y-m-d H:i:s'); |
393 | 393 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
394 | 394 | if (isset($line[37])) $data['last_update'] = $line[37]; |
395 | - $data['departure_airport_icao'] = $line[11]; |
|
396 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
397 | - $data['arrival_airport_icao'] = $line[13]; |
|
395 | + $data['departure_airport_icao'] = $line[11]; |
|
396 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
397 | + $data['arrival_airport_icao'] = $line[13]; |
|
398 | 398 | $data['frequency'] = $line[4]; |
399 | 399 | $data['type'] = $line[18]; |
400 | 400 | $data['range'] = $line[19]; |
401 | 401 | if (isset($line[35])) $data['info'] = $line[35]; |
402 | - $data['id_source'] = $id_source; |
|
403 | - //$data['arrival_airport_time'] = ; |
|
404 | - if ($line[9] != '') { |
|
405 | - $aircraft_data = explode('/',$line[9]); |
|
406 | - if (isset($aircraft_data[1])) { |
|
407 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
408 | - } |
|
409 | - } |
|
410 | - /* |
|
402 | + $data['id_source'] = $id_source; |
|
403 | + //$data['arrival_airport_time'] = ; |
|
404 | + if ($line[9] != '') { |
|
405 | + $aircraft_data = explode('/',$line[9]); |
|
406 | + if (isset($aircraft_data[1])) { |
|
407 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
408 | + } |
|
409 | + } |
|
410 | + /* |
|
411 | 411 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
412 | 412 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
413 | 413 | */ |
414 | - $data['format_source'] = $value['format']; |
|
414 | + $data['format_source'] = $value['format']; |
|
415 | 415 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
416 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
416 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
417 | 417 | elseif ($line[3] == 'ATC') { |
418 | 418 | //print_r($data); |
419 | 419 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -431,240 +431,240 @@ discard block |
||
431 | 431 | |
432 | 432 | 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 | 433 | } |
434 | - unset($data); |
|
435 | - } |
|
436 | - } |
|
437 | - } |
|
438 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
439 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
440 | - $last_exec[$id]['last'] = time(); |
|
441 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
442 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
443 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
444 | - if ($buffer != '') { |
|
445 | - $all_data = json_decode($buffer,true); |
|
446 | - if (isset($all_data['acList'])) { |
|
434 | + unset($data); |
|
435 | + } |
|
436 | + } |
|
437 | + } |
|
438 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
439 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
440 | + $last_exec[$id]['last'] = time(); |
|
441 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
442 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
443 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
444 | + if ($buffer != '') { |
|
445 | + $all_data = json_decode($buffer,true); |
|
446 | + if (isset($all_data['acList'])) { |
|
447 | 447 | foreach ($all_data['acList'] as $line) { |
448 | - $data = array(); |
|
449 | - $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 |
|
456 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
457 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
458 | - $data['emergency'] = ''; // emergency |
|
459 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
460 | - /* |
|
448 | + $data = array(); |
|
449 | + $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 |
|
456 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
457 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
458 | + $data['emergency'] = ''; // emergency |
|
459 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
460 | + /* |
|
461 | 461 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
462 | 462 | else $data['datetime'] = date('Y-m-d H:i:s'); |
463 | 463 | */ |
464 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
465 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
466 | - $data['format_source'] = 'aircraftlistjson'; |
|
467 | - $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); |
|
470 | - unset($data); |
|
464 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
465 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
466 | + $data['format_source'] = 'aircraftlistjson'; |
|
467 | + $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); |
|
470 | + unset($data); |
|
471 | 471 | } |
472 | - } else { |
|
472 | + } else { |
|
473 | 473 | foreach ($all_data as $line) { |
474 | - $data = array(); |
|
475 | - $data['hex'] = $line['hex']; // hex |
|
476 | - $data['ident'] = $line['flight']; // ident |
|
477 | - $data['altitude'] = $line['altitude']; // altitude |
|
478 | - $data['speed'] = $line['speed']; // speed |
|
479 | - $data['heading'] = $line['track']; // heading |
|
480 | - $data['latitude'] = $line['lat']; // lat |
|
481 | - $data['longitude'] = $line['lon']; // long |
|
482 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
483 | - $data['squawk'] = $line['squawk']; // squawk |
|
484 | - $data['emergency'] = ''; // emergency |
|
485 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
486 | - $data['format_source'] = 'aircraftlistjson'; |
|
487 | - $data['id_source'] = $id_source; |
|
488 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
489 | - $SI->add($data); |
|
490 | - unset($data); |
|
474 | + $data = array(); |
|
475 | + $data['hex'] = $line['hex']; // hex |
|
476 | + $data['ident'] = $line['flight']; // ident |
|
477 | + $data['altitude'] = $line['altitude']; // altitude |
|
478 | + $data['speed'] = $line['speed']; // speed |
|
479 | + $data['heading'] = $line['track']; // heading |
|
480 | + $data['latitude'] = $line['lat']; // lat |
|
481 | + $data['longitude'] = $line['lon']; // long |
|
482 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
483 | + $data['squawk'] = $line['squawk']; // squawk |
|
484 | + $data['emergency'] = ''; // emergency |
|
485 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
486 | + $data['format_source'] = 'aircraftlistjson'; |
|
487 | + $data['id_source'] = $id_source; |
|
488 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
489 | + $SI->add($data); |
|
490 | + unset($data); |
|
491 | + } |
|
492 | + } |
|
491 | 493 | } |
492 | - } |
|
493 | - } |
|
494 | - //$last_exec['aircraftlistjson'] = time(); |
|
495 | - $last_exec[$id]['last'] = time(); |
|
496 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
497 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
498 | - $buffer = $Common->getData($value['host']); |
|
499 | - $all_data = json_decode($buffer,true); |
|
500 | - if (isset($all_data['planes'])) { |
|
494 | + //$last_exec['aircraftlistjson'] = time(); |
|
495 | + $last_exec[$id]['last'] = time(); |
|
496 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
497 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
498 | + $buffer = $Common->getData($value['host']); |
|
499 | + $all_data = json_decode($buffer,true); |
|
500 | + if (isset($all_data['planes'])) { |
|
501 | 501 | foreach ($all_data['planes'] as $key => $line) { |
502 | - $data = array(); |
|
503 | - $data['hex'] = $key; // hex |
|
504 | - $data['ident'] = $line[3]; // ident |
|
505 | - $data['altitude'] = $line[6]; // altitude |
|
506 | - $data['speed'] = $line[8]; // speed |
|
507 | - $data['heading'] = $line[7]; // heading |
|
508 | - $data['latitude'] = $line[4]; // lat |
|
509 | - $data['longitude'] = $line[5]; // long |
|
510 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
511 | - $data['squawk'] = $line[10]; // squawk |
|
512 | - $data['emergency'] = ''; // emergency |
|
513 | - $data['registration'] = $line[2]; |
|
514 | - $data['aircraft_icao'] = $line[0]; |
|
515 | - $deparr = explode('-',$line[1]); |
|
516 | - if (count($deparr) == 2) { |
|
502 | + $data = array(); |
|
503 | + $data['hex'] = $key; // hex |
|
504 | + $data['ident'] = $line[3]; // ident |
|
505 | + $data['altitude'] = $line[6]; // altitude |
|
506 | + $data['speed'] = $line[8]; // speed |
|
507 | + $data['heading'] = $line[7]; // heading |
|
508 | + $data['latitude'] = $line[4]; // lat |
|
509 | + $data['longitude'] = $line[5]; // long |
|
510 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
511 | + $data['squawk'] = $line[10]; // squawk |
|
512 | + $data['emergency'] = ''; // emergency |
|
513 | + $data['registration'] = $line[2]; |
|
514 | + $data['aircraft_icao'] = $line[0]; |
|
515 | + $deparr = explode('-',$line[1]); |
|
516 | + if (count($deparr) == 2) { |
|
517 | 517 | $data['departure_airport_icao'] = $deparr[0]; |
518 | 518 | $data['arrival_airport_icao'] = $deparr[1]; |
519 | - } |
|
520 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
521 | - $data['format_source'] = 'planeupdatefaa'; |
|
522 | - $data['id_source'] = $id_source; |
|
523 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
524 | - $SI->add($data); |
|
525 | - unset($data); |
|
519 | + } |
|
520 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
521 | + $data['format_source'] = 'planeupdatefaa'; |
|
522 | + $data['id_source'] = $id_source; |
|
523 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
524 | + $SI->add($data); |
|
525 | + unset($data); |
|
526 | 526 | } |
527 | - } |
|
528 | - //$last_exec['planeupdatefaa'] = time(); |
|
529 | - $last_exec[$id]['last'] = time(); |
|
530 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
531 | - $buffer = $Common->getData($value['host']); |
|
532 | - $all_data = json_decode($buffer,true); |
|
533 | - if (isset($all_data['states'])) { |
|
527 | + } |
|
528 | + //$last_exec['planeupdatefaa'] = time(); |
|
529 | + $last_exec[$id]['last'] = time(); |
|
530 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
531 | + $buffer = $Common->getData($value['host']); |
|
532 | + $all_data = json_decode($buffer,true); |
|
533 | + if (isset($all_data['states'])) { |
|
534 | 534 | foreach ($all_data['states'] as $key => $line) { |
535 | - $data = array(); |
|
536 | - $data['hex'] = $line[0]; // hex |
|
537 | - $data['ident'] = trim($line[1]); // ident |
|
538 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
539 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
540 | - $data['heading'] = round($line[10]); // heading |
|
541 | - $data['latitude'] = $line[5]; // lat |
|
542 | - $data['longitude'] = $line[6]; // long |
|
543 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
544 | - //$data['squawk'] = $line[10]; // squawk |
|
545 | - //$data['emergency'] = ''; // emergency |
|
546 | - //$data['registration'] = $line[2]; |
|
547 | - //$data['aircraft_icao'] = $line[0]; |
|
548 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
549 | - $data['format_source'] = 'opensky'; |
|
550 | - $data['id_source'] = $id_source; |
|
551 | - $SI->add($data); |
|
552 | - unset($data); |
|
535 | + $data = array(); |
|
536 | + $data['hex'] = $line[0]; // hex |
|
537 | + $data['ident'] = trim($line[1]); // ident |
|
538 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
539 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
540 | + $data['heading'] = round($line[10]); // heading |
|
541 | + $data['latitude'] = $line[5]; // lat |
|
542 | + $data['longitude'] = $line[6]; // long |
|
543 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
544 | + //$data['squawk'] = $line[10]; // squawk |
|
545 | + //$data['emergency'] = ''; // emergency |
|
546 | + //$data['registration'] = $line[2]; |
|
547 | + //$data['aircraft_icao'] = $line[0]; |
|
548 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
549 | + $data['format_source'] = 'opensky'; |
|
550 | + $data['id_source'] = $id_source; |
|
551 | + $SI->add($data); |
|
552 | + unset($data); |
|
553 | 553 | } |
554 | - } |
|
555 | - //$last_exec['planeupdatefaa'] = time(); |
|
556 | - $last_exec[$id]['last'] = time(); |
|
557 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
558 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
559 | - //$buffer = $Common->getData($hosts[$id]); |
|
560 | - $buffer = $Common->getData($value['host']); |
|
561 | - $all_data = json_decode($buffer,true); |
|
562 | - foreach ($all_data as $key => $line) { |
|
554 | + } |
|
555 | + //$last_exec['planeupdatefaa'] = time(); |
|
556 | + $last_exec[$id]['last'] = time(); |
|
557 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
558 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
559 | + //$buffer = $Common->getData($hosts[$id]); |
|
560 | + $buffer = $Common->getData($value['host']); |
|
561 | + $all_data = json_decode($buffer,true); |
|
562 | + foreach ($all_data as $key => $line) { |
|
563 | 563 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
564 | - $data = array(); |
|
565 | - $data['hex'] = $line[0]; |
|
566 | - $data['ident'] = $line[16]; //$line[13] |
|
567 | - $data['altitude'] = $line[4]; // altitude |
|
568 | - $data['speed'] = $line[5]; // speed |
|
569 | - $data['heading'] = $line[3]; // heading |
|
570 | - $data['latitude'] = $line[1]; // lat |
|
571 | - $data['longitude'] = $line[2]; // long |
|
572 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
573 | - $data['squawk'] = $line[6]; // squawk |
|
574 | - $data['aircraft_icao'] = $line[8]; |
|
575 | - $data['registration'] = $line[9]; |
|
576 | - $data['departure_airport_iata'] = $line[11]; |
|
577 | - $data['arrival_airport_iata'] = $line[12]; |
|
578 | - $data['emergency'] = ''; // emergency |
|
579 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
580 | - $data['format_source'] = 'fr24json'; |
|
581 | - $data['id_source'] = $id_source; |
|
582 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
583 | - $SI->add($data); |
|
584 | - unset($data); |
|
564 | + $data = array(); |
|
565 | + $data['hex'] = $line[0]; |
|
566 | + $data['ident'] = $line[16]; //$line[13] |
|
567 | + $data['altitude'] = $line[4]; // altitude |
|
568 | + $data['speed'] = $line[5]; // speed |
|
569 | + $data['heading'] = $line[3]; // heading |
|
570 | + $data['latitude'] = $line[1]; // lat |
|
571 | + $data['longitude'] = $line[2]; // long |
|
572 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
573 | + $data['squawk'] = $line[6]; // squawk |
|
574 | + $data['aircraft_icao'] = $line[8]; |
|
575 | + $data['registration'] = $line[9]; |
|
576 | + $data['departure_airport_iata'] = $line[11]; |
|
577 | + $data['arrival_airport_iata'] = $line[12]; |
|
578 | + $data['emergency'] = ''; // emergency |
|
579 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
580 | + $data['format_source'] = 'fr24json'; |
|
581 | + $data['id_source'] = $id_source; |
|
582 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
583 | + $SI->add($data); |
|
584 | + unset($data); |
|
585 | 585 | } |
586 | - } |
|
587 | - //$last_exec['fr24json'] = time(); |
|
588 | - $last_exec[$id]['last'] = time(); |
|
589 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
590 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
591 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
592 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
593 | - //echo $buffer; |
|
594 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
595 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
596 | - $all_data = json_decode($buffer,true); |
|
597 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
586 | + } |
|
587 | + //$last_exec['fr24json'] = time(); |
|
588 | + $last_exec[$id]['last'] = time(); |
|
589 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
590 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
591 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
592 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
593 | + //echo $buffer; |
|
594 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
595 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
596 | + $all_data = json_decode($buffer,true); |
|
597 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
598 | 598 | die(json_last_error_msg()); |
599 | - } |
|
600 | - if (isset($all_data['mrkrs'])) { |
|
599 | + } |
|
600 | + if (isset($all_data['mrkrs'])) { |
|
601 | 601 | foreach ($all_data['mrkrs'] as $key => $line) { |
602 | - if (isset($line['inf'])) { |
|
602 | + if (isset($line['inf'])) { |
|
603 | 603 | $data = array(); |
604 | 604 | $data['hex'] = $line['inf']['ia']; |
605 | 605 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
606 | - $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 |
|
609 | - $data['latitude'] = $line['pt'][0]; // lat |
|
610 | - $data['longitude'] = $line['pt'][1]; // long |
|
611 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
612 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
613 | - //$data['aircraft_icao'] = $line[8]; |
|
614 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
606 | + $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 |
|
609 | + $data['latitude'] = $line['pt'][0]; // lat |
|
610 | + $data['longitude'] = $line['pt'][1]; // long |
|
611 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
612 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
613 | + //$data['aircraft_icao'] = $line[8]; |
|
614 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
615 | 615 | //$data['departure_airport_iata'] = $line[11]; |
616 | 616 | //$data['arrival_airport_iata'] = $line[12]; |
617 | - //$data['emergency'] = ''; // emergency |
|
617 | + //$data['emergency'] = ''; // emergency |
|
618 | 618 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
619 | - $data['format_source'] = 'radarvirtueljson'; |
|
620 | - $data['id_source'] = $id_source; |
|
619 | + $data['format_source'] = 'radarvirtueljson'; |
|
620 | + $data['id_source'] = $id_source; |
|
621 | 621 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
622 | 622 | $SI->add($data); |
623 | 623 | unset($data); |
624 | - } |
|
624 | + } |
|
625 | 625 | } |
626 | - } |
|
627 | - //$last_exec['radarvirtueljson'] = time(); |
|
628 | - $last_exec[$id]['last'] = time(); |
|
629 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
630 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
631 | - //$buffer = $Common->getData($hosts[$id]); |
|
632 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
633 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
626 | + } |
|
627 | + //$last_exec['radarvirtueljson'] = time(); |
|
628 | + $last_exec[$id]['last'] = time(); |
|
629 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
630 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
631 | + //$buffer = $Common->getData($hosts[$id]); |
|
632 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
633 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
634 | 634 | |
635 | - if (isset($all_data['pireps'])) { |
|
636 | - foreach ($all_data['pireps'] as $line) { |
|
637 | - $data = array(); |
|
638 | - $data['id'] = $line['id']; |
|
639 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
640 | - $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 |
|
647 | - $data['latitude'] = $line['lat']; // lat |
|
648 | - $data['longitude'] = $line['lon']; // long |
|
649 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
650 | - //$data['squawk'] = $line['squawk']; // squawk |
|
651 | - //$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']; |
|
655 | - //$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'] = ''; |
|
660 | - $data['format_source'] = 'pireps'; |
|
661 | - $data['id_source'] = $id_source; |
|
662 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
663 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
664 | - if ($line['icon'] == 'plane') { |
|
635 | + if (isset($all_data['pireps'])) { |
|
636 | + foreach ($all_data['pireps'] as $line) { |
|
637 | + $data = array(); |
|
638 | + $data['id'] = $line['id']; |
|
639 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
640 | + $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 |
|
647 | + $data['latitude'] = $line['lat']; // lat |
|
648 | + $data['longitude'] = $line['lon']; // long |
|
649 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
650 | + //$data['squawk'] = $line['squawk']; // squawk |
|
651 | + //$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']; |
|
655 | + //$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'] = ''; |
|
660 | + $data['format_source'] = 'pireps'; |
|
661 | + $data['id_source'] = $id_source; |
|
662 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
663 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
664 | + if ($line['icon'] == 'plane') { |
|
665 | 665 | $SI->add($data); |
666 | - // print_r($data); |
|
667 | - } elseif ($line['icon'] == 'ct') { |
|
666 | + // print_r($data); |
|
667 | + } elseif ($line['icon'] == 'ct') { |
|
668 | 668 | $data['info'] = str_replace('^§','<br />',$data['info']); |
669 | 669 | $data['info'] = str_replace('&sect;','',$data['info']); |
670 | 670 | $typec = substr($data['ident'],-3); |
@@ -679,160 +679,160 @@ discard block |
||
679 | 679 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
680 | 680 | else $data['type'] = 'Observer'; |
681 | 681 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
682 | - } |
|
683 | - unset($data); |
|
682 | + } |
|
683 | + unset($data); |
|
684 | 684 | } |
685 | - } |
|
686 | - //$last_exec['pirepsjson'] = time(); |
|
687 | - $last_exec[$id]['last'] = time(); |
|
688 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
689 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
690 | - //$buffer = $Common->getData($hosts[$id]); |
|
691 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
692 | - $buffer = $Common->getData($value['host']); |
|
693 | - $all_data = json_decode($buffer,true); |
|
694 | - if ($buffer != '' && is_array($all_data)) { |
|
685 | + } |
|
686 | + //$last_exec['pirepsjson'] = time(); |
|
687 | + $last_exec[$id]['last'] = time(); |
|
688 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
689 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
690 | + //$buffer = $Common->getData($hosts[$id]); |
|
691 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
692 | + $buffer = $Common->getData($value['host']); |
|
693 | + $all_data = json_decode($buffer,true); |
|
694 | + if ($buffer != '' && is_array($all_data)) { |
|
695 | 695 | foreach ($all_data as $line) { |
696 | - $data = array(); |
|
697 | - //$data['id'] = $line['id']; // id not usable |
|
698 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
699 | - $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']; |
|
702 | - $data['ident'] = $line['flightnum']; // ident |
|
703 | - $data['altitude'] = $line['alt']; // altitude |
|
704 | - $data['speed'] = $line['gs']; // speed |
|
705 | - $data['heading'] = $line['heading']; // heading |
|
706 | - $data['latitude'] = $line['lat']; // lat |
|
707 | - $data['longitude'] = $line['lng']; // long |
|
708 | - $data['verticalrate'] = ''; // verticale rate |
|
709 | - $data['squawk'] = ''; // squawk |
|
710 | - $data['emergency'] = ''; // emergency |
|
711 | - //$data['datetime'] = $line['lastupdate']; |
|
712 | - $data['last_update'] = $line['lastupdate']; |
|
713 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
714 | - $data['departure_airport_icao'] = $line['depicao']; |
|
715 | - $data['departure_airport_time'] = $line['deptime']; |
|
716 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
717 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
718 | - $data['registration'] = $line['aircraft']; |
|
719 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
720 | - if (isset($line['aircraftname'])) { |
|
696 | + $data = array(); |
|
697 | + //$data['id'] = $line['id']; // id not usable |
|
698 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
699 | + $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']; |
|
702 | + $data['ident'] = $line['flightnum']; // ident |
|
703 | + $data['altitude'] = $line['alt']; // altitude |
|
704 | + $data['speed'] = $line['gs']; // speed |
|
705 | + $data['heading'] = $line['heading']; // heading |
|
706 | + $data['latitude'] = $line['lat']; // lat |
|
707 | + $data['longitude'] = $line['lng']; // long |
|
708 | + $data['verticalrate'] = ''; // verticale rate |
|
709 | + $data['squawk'] = ''; // squawk |
|
710 | + $data['emergency'] = ''; // emergency |
|
711 | + //$data['datetime'] = $line['lastupdate']; |
|
712 | + $data['last_update'] = $line['lastupdate']; |
|
713 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
714 | + $data['departure_airport_icao'] = $line['depicao']; |
|
715 | + $data['departure_airport_time'] = $line['deptime']; |
|
716 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
717 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
718 | + $data['registration'] = $line['aircraft']; |
|
719 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
720 | + if (isset($line['aircraftname'])) { |
|
721 | 721 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
722 | 722 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
723 | - $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 { |
|
727 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
728 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
729 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
730 | - } |
|
731 | - } |
|
732 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
733 | - $data['id_source'] = $id_source; |
|
734 | - $data['format_source'] = 'phpvmacars'; |
|
735 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
736 | - $SI->add($data); |
|
737 | - unset($data); |
|
723 | + $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 { |
|
727 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
728 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
729 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
730 | + } |
|
731 | + } |
|
732 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
733 | + $data['id_source'] = $id_source; |
|
734 | + $data['format_source'] = 'phpvmacars'; |
|
735 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
736 | + $SI->add($data); |
|
737 | + unset($data); |
|
738 | 738 | } |
739 | 739 | if ($globalDebug) echo 'No more data...'."\n"; |
740 | 740 | unset($buffer); |
741 | 741 | unset($all_data); |
742 | - } |
|
743 | - //$last_exec['phpvmacars'] = time(); |
|
744 | - $last_exec[$id]['last'] = time(); |
|
745 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
746 | - //$buffer = $Common->getData($hosts[$id]); |
|
747 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
748 | - $buffer = $Common->getData($value['host']); |
|
749 | - $all_data = json_decode($buffer,true); |
|
750 | - if ($buffer != '' && is_array($all_data)) { |
|
742 | + } |
|
743 | + //$last_exec['phpvmacars'] = time(); |
|
744 | + $last_exec[$id]['last'] = time(); |
|
745 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
746 | + //$buffer = $Common->getData($hosts[$id]); |
|
747 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
748 | + $buffer = $Common->getData($value['host']); |
|
749 | + $all_data = json_decode($buffer,true); |
|
750 | + if ($buffer != '' && is_array($all_data)) { |
|
751 | 751 | foreach ($all_data as $line) { |
752 | - $data = array(); |
|
753 | - //$data['id'] = $line['id']; // id not usable |
|
754 | - $data['id'] = trim($line['flight_id']); |
|
755 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
756 | - $data['pilot_name'] = $line['pilot_name']; |
|
757 | - $data['pilot_id'] = $line['pilot_id']; |
|
758 | - $data['ident'] = trim($line['callsign']); // ident |
|
759 | - $data['altitude'] = $line['altitude']; // altitude |
|
760 | - $data['speed'] = $line['gs']; // speed |
|
761 | - $data['heading'] = $line['heading']; // heading |
|
762 | - $data['latitude'] = $line['latitude']; // lat |
|
763 | - $data['longitude'] = $line['longitude']; // long |
|
764 | - $data['verticalrate'] = ''; // verticale rate |
|
765 | - $data['squawk'] = ''; // squawk |
|
766 | - $data['emergency'] = ''; // emergency |
|
767 | - //$data['datetime'] = $line['lastupdate']; |
|
768 | - $data['last_update'] = $line['last_update']; |
|
769 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
770 | - $data['departure_airport_icao'] = $line['departure']; |
|
771 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
772 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
773 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
774 | - //$data['registration'] = $line['aircraft']; |
|
775 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
776 | - $data['aircraft_icao'] = $line['plane_type']; |
|
777 | - $data['id_source'] = $id_source; |
|
778 | - $data['format_source'] = 'vam'; |
|
779 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
780 | - $SI->add($data); |
|
781 | - unset($data); |
|
752 | + $data = array(); |
|
753 | + //$data['id'] = $line['id']; // id not usable |
|
754 | + $data['id'] = trim($line['flight_id']); |
|
755 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
756 | + $data['pilot_name'] = $line['pilot_name']; |
|
757 | + $data['pilot_id'] = $line['pilot_id']; |
|
758 | + $data['ident'] = trim($line['callsign']); // ident |
|
759 | + $data['altitude'] = $line['altitude']; // altitude |
|
760 | + $data['speed'] = $line['gs']; // speed |
|
761 | + $data['heading'] = $line['heading']; // heading |
|
762 | + $data['latitude'] = $line['latitude']; // lat |
|
763 | + $data['longitude'] = $line['longitude']; // long |
|
764 | + $data['verticalrate'] = ''; // verticale rate |
|
765 | + $data['squawk'] = ''; // squawk |
|
766 | + $data['emergency'] = ''; // emergency |
|
767 | + //$data['datetime'] = $line['lastupdate']; |
|
768 | + $data['last_update'] = $line['last_update']; |
|
769 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
770 | + $data['departure_airport_icao'] = $line['departure']; |
|
771 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
772 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
773 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
774 | + //$data['registration'] = $line['aircraft']; |
|
775 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
776 | + $data['aircraft_icao'] = $line['plane_type']; |
|
777 | + $data['id_source'] = $id_source; |
|
778 | + $data['format_source'] = 'vam'; |
|
779 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
780 | + $SI->add($data); |
|
781 | + unset($data); |
|
782 | 782 | } |
783 | 783 | if ($globalDebug) echo 'No more data...'."\n"; |
784 | 784 | unset($buffer); |
785 | 785 | unset($all_data); |
786 | - } |
|
787 | - //$last_exec['phpvmacars'] = time(); |
|
788 | - $last_exec[$id]['last'] = time(); |
|
786 | + } |
|
787 | + //$last_exec['phpvmacars'] = time(); |
|
788 | + $last_exec[$id]['last'] = time(); |
|
789 | 789 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
790 | 790 | } 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(); |
|
792 | - //$last_exec[$id]['last'] = time(); |
|
791 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
792 | + //$last_exec[$id]['last'] = time(); |
|
793 | 793 | |
794 | - //$read = array( $sockets[$id] ); |
|
795 | - $read = $sockets; |
|
796 | - $write = NULL; |
|
797 | - $e = NULL; |
|
798 | - $n = socket_select($read, $write, $e, $timeout); |
|
799 | - if ($e != NULL) var_dump($e); |
|
800 | - if ($n > 0) { |
|
794 | + //$read = array( $sockets[$id] ); |
|
795 | + $read = $sockets; |
|
796 | + $write = NULL; |
|
797 | + $e = NULL; |
|
798 | + $n = socket_select($read, $write, $e, $timeout); |
|
799 | + if ($e != NULL) var_dump($e); |
|
800 | + if ($n > 0) { |
|
801 | 801 | foreach ($read as $nb => $r) { |
802 | - //$value = $formats[$nb]; |
|
803 | - $format = $globalSources[$nb]['format']; |
|
804 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
805 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
806 | - } else { |
|
807 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
808 | - } |
|
809 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
810 | - //echo $buffer."\n"; |
|
811 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
812 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
813 | - $error = false; |
|
814 | - //$SI::del(); |
|
815 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
816 | - // SBS format is CSV format |
|
817 | - if ($buffer != '') { |
|
802 | + //$value = $formats[$nb]; |
|
803 | + $format = $globalSources[$nb]['format']; |
|
804 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
805 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
806 | + } else { |
|
807 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
808 | + } |
|
809 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
810 | + //echo $buffer."\n"; |
|
811 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
812 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
813 | + $error = false; |
|
814 | + //$SI::del(); |
|
815 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
816 | + // SBS format is CSV format |
|
817 | + if ($buffer != '') { |
|
818 | 818 | $tt[$format] = 0; |
819 | 819 | if ($format == 'acarssbs3') { |
820 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
821 | - $ACARS->add(trim($buffer)); |
|
822 | - $ACARS->deleteLiveAcarsData(); |
|
820 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
821 | + $ACARS->add(trim($buffer)); |
|
822 | + $ACARS->deleteLiveAcarsData(); |
|
823 | 823 | } elseif ($format == 'raw') { |
824 | - // AVR format |
|
825 | - $data = $SBS->parse($buffer); |
|
826 | - if (is_array($data)) { |
|
824 | + // AVR format |
|
825 | + $data = $SBS->parse($buffer); |
|
826 | + if (is_array($data)) { |
|
827 | 827 | $data['datetime'] = date('Y-m-d H:i:s'); |
828 | 828 | $data['format_source'] = 'raw'; |
829 | 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); |
|
832 | - } |
|
833 | - } elseif ($format == 'flightgearsp') { |
|
834 | - //echo $buffer."\n"; |
|
835 | - if (strlen($buffer) > 5) { |
|
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); |
|
832 | + } |
|
833 | + } elseif ($format == 'flightgearsp') { |
|
834 | + //echo $buffer."\n"; |
|
835 | + if (strlen($buffer) > 5) { |
|
836 | 836 | $line = explode(',',$buffer); |
837 | 837 | $data = array(); |
838 | 838 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -848,114 +848,114 @@ discard block |
||
848 | 848 | $data['format_source'] = 'flightgearsp'; |
849 | 849 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
850 | 850 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
851 | - } |
|
852 | - } elseif ($format == 'acars') { |
|
853 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
854 | - $ACARS->add(trim($buffer)); |
|
855 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
856 | - $ACARS->deleteLiveAcarsData(); |
|
851 | + } |
|
852 | + } elseif ($format == 'acars') { |
|
853 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
854 | + $ACARS->add(trim($buffer)); |
|
855 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
856 | + $ACARS->deleteLiveAcarsData(); |
|
857 | 857 | } elseif ($format == 'flightgearmp') { |
858 | - if (substr($buffer,0,1) != '#') { |
|
858 | + if (substr($buffer,0,1) != '#') { |
|
859 | 859 | $data = array(); |
860 | 860 | //echo $buffer."\n"; |
861 | 861 | $line = explode(' ',$buffer); |
862 | 862 | if (count($line) == 11) { |
863 | - $userserver = explode('@',$line[0]); |
|
864 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
865 | - $data['ident'] = $userserver[0]; |
|
866 | - $data['registration'] = $userserver[0]; |
|
867 | - $data['latitude'] = $line[4]; |
|
868 | - $data['longitude'] = $line[5]; |
|
869 | - $data['altitude'] = $line[6]; |
|
870 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
871 | - $aircraft_type = $line[10]; |
|
872 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
873 | - $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); |
|
863 | + $userserver = explode('@',$line[0]); |
|
864 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
865 | + $data['ident'] = $userserver[0]; |
|
866 | + $data['registration'] = $userserver[0]; |
|
867 | + $data['latitude'] = $line[4]; |
|
868 | + $data['longitude'] = $line[5]; |
|
869 | + $data['altitude'] = $line[6]; |
|
870 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
871 | + $aircraft_type = $line[10]; |
|
872 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
873 | + $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); |
|
875 | + } |
|
875 | 876 | } |
876 | - } |
|
877 | 877 | } elseif ($format == 'beast') { |
878 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
879 | - die; |
|
878 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
879 | + die; |
|
880 | 880 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
881 | - $line = explode("\t", $buffer); |
|
882 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
881 | + $line = explode("\t", $buffer); |
|
882 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
883 | 883 | $key = $line[$k]; |
884 | - $lined[$key] = $line[$k+1]; |
|
885 | - } |
|
886 | - if (count($lined) > 3) { |
|
887 | - $data['hex'] = $lined['hexid']; |
|
888 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
889 | - $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']; |
|
897 | - $data['id_source'] = $id_source; |
|
898 | - $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); |
|
902 | - unset($lined); |
|
903 | - unset($data); |
|
904 | - } else $error = true; |
|
884 | + $lined[$key] = $line[$k+1]; |
|
885 | + } |
|
886 | + if (count($lined) > 3) { |
|
887 | + $data['hex'] = $lined['hexid']; |
|
888 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
889 | + $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']; |
|
897 | + $data['id_source'] = $id_source; |
|
898 | + $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); |
|
902 | + unset($lined); |
|
903 | + unset($data); |
|
904 | + } else $error = true; |
|
905 | 905 | } elseif ($format == 'aprs' && $use_aprs) { |
906 | - if ($aprs_connect == 0) { |
|
906 | + if ($aprs_connect == 0) { |
|
907 | 907 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
908 | 908 | $aprs_connect = 1; |
909 | - } |
|
910 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
909 | + } |
|
910 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
911 | 911 | $aprs_last_tx = time(); |
912 | 912 | $data_aprs = "# Keep alive"; |
913 | 913 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
914 | - } |
|
915 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
916 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
917 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
918 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
914 | + } |
|
915 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
916 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
917 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
918 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
919 | 919 | $line = $APRS->parse($buffer); |
920 | 920 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
921 | - $data = array(); |
|
922 | - //print_r($line); |
|
923 | - $data['hex'] = $line['address']; |
|
924 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
925 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
926 | - $data['ident'] = $line['ident']; |
|
927 | - $data['latitude'] = $line['latitude']; |
|
928 | - $data['longitude'] = $line['longitude']; |
|
929 | - //$data['verticalrate'] = $line[16]; |
|
930 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
931 | - else $data['speed'] = 0; |
|
932 | - $data['altitude'] = $line['altitude']; |
|
933 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
934 | - //else $data['heading'] = 0; |
|
935 | - $data['aircraft_type'] = $line['stealth']; |
|
936 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
937 | - $data['id_source'] = $id_source; |
|
938 | - $data['format_source'] = 'aprs'; |
|
939 | - $data['source_name'] = $line['source']; |
|
940 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
941 | - $currentdate = date('Y-m-d H:i:s'); |
|
942 | - $aprsdate = strtotime($data['datetime']); |
|
943 | - // 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 { |
|
921 | + $data = array(); |
|
922 | + //print_r($line); |
|
923 | + $data['hex'] = $line['address']; |
|
924 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
925 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
926 | + $data['ident'] = $line['ident']; |
|
927 | + $data['latitude'] = $line['latitude']; |
|
928 | + $data['longitude'] = $line['longitude']; |
|
929 | + //$data['verticalrate'] = $line[16]; |
|
930 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
931 | + else $data['speed'] = 0; |
|
932 | + $data['altitude'] = $line['altitude']; |
|
933 | + if (isset($line['course'])) $data['heading'] = $line['course']; |
|
934 | + //else $data['heading'] = 0; |
|
935 | + $data['aircraft_type'] = $line['stealth']; |
|
936 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
937 | + $data['id_source'] = $id_source; |
|
938 | + $data['format_source'] = 'aprs'; |
|
939 | + $data['source_name'] = $line['source']; |
|
940 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
941 | + $currentdate = date('Y-m-d H:i:s'); |
|
942 | + $aprsdate = strtotime($data['datetime']); |
|
943 | + // 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 | 946 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
947 | 947 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
948 | - } |
|
949 | - unset($data); |
|
948 | + } |
|
949 | + unset($data); |
|
950 | 950 | } |
951 | 951 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
952 | 952 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
953 | - } |
|
953 | + } |
|
954 | 954 | } else { |
955 | - $line = explode(',', $buffer); |
|
956 | - if (count($line) > 20) { |
|
957 | - $data['hex'] = $line[4]; |
|
958 | - /* |
|
955 | + $line = explode(',', $buffer); |
|
956 | + if (count($line) > 20) { |
|
957 | + $data['hex'] = $line[4]; |
|
958 | + /* |
|
959 | 959 | $data['datetime'] = $line[6].' '.$line[7]; |
960 | 960 | date_default_timezone_set($globalTimezone); |
961 | 961 | $datetime = new DateTime($data['datetime']); |
@@ -963,28 +963,28 @@ discard block |
||
963 | 963 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
964 | 964 | date_default_timezone_set('UTC'); |
965 | 965 | */ |
966 | - // Force datetime to current UTC datetime |
|
967 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
968 | - $data['ident'] = trim($line[10]); |
|
969 | - $data['latitude'] = $line[14]; |
|
970 | - $data['longitude'] = $line[15]; |
|
971 | - $data['verticalrate'] = $line[16]; |
|
972 | - $data['emergency'] = $line[20]; |
|
973 | - $data['speed'] = $line[12]; |
|
974 | - $data['squawk'] = $line[17]; |
|
975 | - $data['altitude'] = $line[11]; |
|
976 | - $data['heading'] = $line[13]; |
|
977 | - $data['ground'] = $line[21]; |
|
978 | - $data['emergency'] = $line[19]; |
|
979 | - $data['format_source'] = 'sbs'; |
|
966 | + // Force datetime to current UTC datetime |
|
967 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
968 | + $data['ident'] = trim($line[10]); |
|
969 | + $data['latitude'] = $line[14]; |
|
970 | + $data['longitude'] = $line[15]; |
|
971 | + $data['verticalrate'] = $line[16]; |
|
972 | + $data['emergency'] = $line[20]; |
|
973 | + $data['speed'] = $line[12]; |
|
974 | + $data['squawk'] = $line[17]; |
|
975 | + $data['altitude'] = $line[11]; |
|
976 | + $data['heading'] = $line[13]; |
|
977 | + $data['ground'] = $line[21]; |
|
978 | + $data['emergency'] = $line[19]; |
|
979 | + $data['format_source'] = 'sbs'; |
|
980 | 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']; |
|
982 | - $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; |
|
985 | - unset($data); |
|
986 | - } else $error = true; |
|
987 | - if ($error) { |
|
981 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
982 | + $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; |
|
985 | + unset($data); |
|
986 | + } else $error = true; |
|
987 | + if ($error) { |
|
988 | 988 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
989 | 989 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
990 | 990 | } else { |
@@ -1000,13 +1000,13 @@ discard block |
||
1000 | 1000 | connect_all($sourceer); |
1001 | 1001 | $sourceer = array(); |
1002 | 1002 | } |
1003 | - } |
|
1003 | + } |
|
1004 | 1004 | } |
1005 | 1005 | // Sleep for xxx microseconds |
1006 | 1006 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1007 | - } else { |
|
1007 | + } else { |
|
1008 | 1008 | if ($format == 'flightgearmp') { |
1009 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1009 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1010 | 1010 | //@socket_close($r); |
1011 | 1011 | sleep($globalMinFetch); |
1012 | 1012 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1015,9 +1015,9 @@ discard block |
||
1015 | 1015 | break; |
1016 | 1016 | |
1017 | 1017 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1018 | - if (isset($tt[$format])) $tt[$format]++; |
|
1019 | - else $tt[$format] = 0; |
|
1020 | - if ($tt[$format] > 30) { |
|
1018 | + if (isset($tt[$format])) $tt[$format]++; |
|
1019 | + else $tt[$format] = 0; |
|
1020 | + if ($tt[$format] > 30) { |
|
1021 | 1021 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1022 | 1022 | //@socket_close($r); |
1023 | 1023 | sleep(2); |
@@ -1028,40 +1028,40 @@ discard block |
||
1028 | 1028 | //connect_all($globalSources); |
1029 | 1029 | $tt[$format]=0; |
1030 | 1030 | break; |
1031 | - } |
|
1031 | + } |
|
1032 | + } |
|
1032 | 1033 | } |
1033 | - } |
|
1034 | 1034 | } |
1035 | - } else { |
|
1035 | + } else { |
|
1036 | 1036 | $error = socket_strerror(socket_last_error()); |
1037 | 1037 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1038 | 1038 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
1039 | 1039 | if (isset($globalDebug)) echo "Restarting...\n"; |
1040 | 1040 | // Restart the script if possible |
1041 | 1041 | if (is_array($sockets)) { |
1042 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1042 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1043 | 1043 | |
1044 | - foreach ($sockets as $sock) { |
|
1044 | + foreach ($sockets as $sock) { |
|
1045 | 1045 | @socket_shutdown($sock,2); |
1046 | 1046 | @socket_close($sock); |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | |
1049 | 1049 | } |
1050 | - if ($globalDebug) echo "Restart all connections..."; |
|
1051 | - sleep(2); |
|
1052 | - $time = time(); |
|
1053 | - //connect_all($hosts); |
|
1054 | - $aprs_connect = 0; |
|
1055 | - connect_all($globalSources); |
|
1050 | + if ($globalDebug) echo "Restart all connections..."; |
|
1051 | + sleep(2); |
|
1052 | + $time = time(); |
|
1053 | + //connect_all($hosts); |
|
1054 | + $aprs_connect = 0; |
|
1055 | + connect_all($globalSources); |
|
1056 | 1056 | |
1057 | 1057 | } |
1058 | - } |
|
1058 | + } |
|
1059 | 1059 | } |
1060 | 1060 | if ($globalDaemon === false) { |
1061 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1062 | - $SI->checkAll(); |
|
1061 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1062 | + $SI->checkAll(); |
|
1063 | + } |
|
1063 | 1064 | } |
1064 | - } |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | ?> |
@@ -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']); |
@@ -345,19 +434,38 @@ discard block |
||
345 | 434 | $data = array(); |
346 | 435 | $data['hex'] = $line[1]; // hex |
347 | 436 | $data['ident'] = $line[2]; // ident |
348 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
349 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
350 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
351 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
352 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
437 | + if (isset($line[3])) { |
|
438 | + $data['altitude'] = $line[3]; |
|
439 | + } |
|
440 | + // altitude |
|
441 | + if (isset($line[4])) { |
|
442 | + $data['speed'] = $line[4]; |
|
443 | + } |
|
444 | + // speed |
|
445 | + if (isset($line[5])) { |
|
446 | + $data['heading'] = $line[5]; |
|
447 | + } |
|
448 | + // heading |
|
449 | + if (isset($line[6])) { |
|
450 | + $data['latitude'] = $line[6]; |
|
451 | + } |
|
452 | + // lat |
|
453 | + if (isset($line[7])) { |
|
454 | + $data['longitude'] = $line[7]; |
|
455 | + } |
|
456 | + // long |
|
353 | 457 | $data['verticalrate'] = ''; // vertical rate |
354 | 458 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
355 | 459 | $data['emergency'] = ''; // emergency |
356 | 460 | $data['datetime'] = date('Y-m-d H:i:s'); |
357 | 461 | $data['format_source'] = 'deltadbtxt'; |
358 | 462 | $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']; |
|
463 | + if (isset($value['name']) && $value['name'] != '') { |
|
464 | + $data['source_name'] = $value['name']; |
|
465 | + } |
|
466 | + if (isset($value['sourcestats'])) { |
|
467 | + $data['sourcestats'] = $value['sourcestats']; |
|
468 | + } |
|
361 | 469 | $SI->add($data); |
362 | 470 | unset($data); |
363 | 471 | } |
@@ -379,10 +487,19 @@ discard block |
||
379 | 487 | $data['pilot_name'] = $line[2]; |
380 | 488 | $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
381 | 489 | $data['ident'] = $line[0]; // ident |
382 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
490 | + if ($line[7] != '' && $line[7] != 0) { |
|
491 | + $data['altitude'] = $line[7]; |
|
492 | + } |
|
493 | + // altitude |
|
383 | 494 | $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 |
|
495 | + if (isset($line[45])) { |
|
496 | + $data['heading'] = $line[45]; |
|
497 | + } |
|
498 | + // heading |
|
499 | + elseif (isset($line[38])) { |
|
500 | + $data['heading'] = $line[38]; |
|
501 | + } |
|
502 | + // heading |
|
386 | 503 | $data['latitude'] = $line[5]; // lat |
387 | 504 | $data['longitude'] = $line[6]; // long |
388 | 505 | $data['verticalrate'] = ''; // vertical rate |
@@ -391,14 +508,18 @@ discard block |
||
391 | 508 | $data['waypoints'] = $line[30]; |
392 | 509 | $data['datetime'] = date('Y-m-d H:i:s'); |
393 | 510 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
394 | - if (isset($line[37])) $data['last_update'] = $line[37]; |
|
511 | + if (isset($line[37])) { |
|
512 | + $data['last_update'] = $line[37]; |
|
513 | + } |
|
395 | 514 | $data['departure_airport_icao'] = $line[11]; |
396 | 515 | $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
397 | 516 | $data['arrival_airport_icao'] = $line[13]; |
398 | 517 | $data['frequency'] = $line[4]; |
399 | 518 | $data['type'] = $line[18]; |
400 | 519 | $data['range'] = $line[19]; |
401 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
520 | + if (isset($line[35])) { |
|
521 | + $data['info'] = $line[35]; |
|
522 | + } |
|
402 | 523 | $data['id_source'] = $id_source; |
403 | 524 | //$data['arrival_airport_time'] = ; |
404 | 525 | if ($line[9] != '') { |
@@ -412,22 +533,35 @@ discard block |
||
412 | 533 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
413 | 534 | */ |
414 | 535 | $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') { |
|
536 | + if (isset($value['name']) && $value['name'] != '') { |
|
537 | + $data['source_name'] = $value['name']; |
|
538 | + } |
|
539 | + if ($line[3] == 'PILOT') { |
|
540 | + $SI->add($data); |
|
541 | + } elseif ($line[3] == 'ATC') { |
|
418 | 542 | //print_r($data); |
419 | 543 | $data['info'] = str_replace('^§','<br />',$data['info']); |
420 | 544 | $data['info'] = str_replace('&sect;','',$data['info']); |
421 | 545 | $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'; |
|
546 | + if ($typec == 'APP') { |
|
547 | + $data['type'] = 'Approach'; |
|
548 | + } elseif ($typec == 'TWR') { |
|
549 | + $data['type'] = 'Tower'; |
|
550 | + } elseif ($typec == 'OBS') { |
|
551 | + $data['type'] = 'Observer'; |
|
552 | + } elseif ($typec == 'GND') { |
|
553 | + $data['type'] = 'Ground'; |
|
554 | + } elseif ($typec == 'DEL') { |
|
555 | + $data['type'] = 'Delivery'; |
|
556 | + } elseif ($typec == 'DEP') { |
|
557 | + $data['type'] = 'Departure'; |
|
558 | + } elseif ($typec == 'FSS') { |
|
559 | + $data['type'] = 'Flight Service Station'; |
|
560 | + } elseif ($typec == 'CTR') { |
|
561 | + $data['type'] = 'Control Radar or Centre'; |
|
562 | + } elseif ($data['type'] == '') { |
|
563 | + $data['type'] = 'Observer'; |
|
564 | + } |
|
431 | 565 | |
432 | 566 | 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 | 567 | } |
@@ -447,26 +581,55 @@ discard block |
||
447 | 581 | foreach ($all_data['acList'] as $line) { |
448 | 582 | $data = array(); |
449 | 583 | $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 |
|
584 | + if (isset($line['Call'])) { |
|
585 | + $data['ident'] = $line['Call']; |
|
586 | + } |
|
587 | + // ident |
|
588 | + if (isset($line['Alt'])) { |
|
589 | + $data['altitude'] = $line['Alt']; |
|
590 | + } |
|
591 | + // altitude |
|
592 | + if (isset($line['Spd'])) { |
|
593 | + $data['speed'] = $line['Spd']; |
|
594 | + } |
|
595 | + // speed |
|
596 | + if (isset($line['Trak'])) { |
|
597 | + $data['heading'] = $line['Trak']; |
|
598 | + } |
|
599 | + // heading |
|
600 | + if (isset($line['Lat'])) { |
|
601 | + $data['latitude'] = $line['Lat']; |
|
602 | + } |
|
603 | + // lat |
|
604 | + if (isset($line['Long'])) { |
|
605 | + $data['longitude'] = $line['Long']; |
|
606 | + } |
|
607 | + // long |
|
456 | 608 | //$data['verticalrate'] = $line['']; // verticale rate |
457 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
609 | + if (isset($line['Sqk'])) { |
|
610 | + $data['squawk'] = $line['Sqk']; |
|
611 | + } |
|
612 | + // squawk |
|
458 | 613 | $data['emergency'] = ''; // emergency |
459 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
614 | + if (isset($line['Reg'])) { |
|
615 | + $data['registration'] = $line['Reg']; |
|
616 | + } |
|
460 | 617 | /* |
461 | 618 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
462 | 619 | else $data['datetime'] = date('Y-m-d H:i:s'); |
463 | 620 | */ |
464 | 621 | $data['datetime'] = date('Y-m-d H:i:s'); |
465 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
622 | + if (isset($line['Type'])) { |
|
623 | + $data['aircraft_icao'] = $line['Type']; |
|
624 | + } |
|
466 | 625 | $data['format_source'] = 'aircraftlistjson'; |
467 | 626 | $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); |
|
627 | + if (isset($value['name']) && $value['name'] != '') { |
|
628 | + $data['source_name'] = $value['name']; |
|
629 | + } |
|
630 | + if (isset($data['datetime'])) { |
|
631 | + $SI->add($data); |
|
632 | + } |
|
470 | 633 | unset($data); |
471 | 634 | } |
472 | 635 | } else { |
@@ -485,7 +648,9 @@ discard block |
||
485 | 648 | $data['datetime'] = date('Y-m-d H:i:s'); |
486 | 649 | $data['format_source'] = 'aircraftlistjson'; |
487 | 650 | $data['id_source'] = $id_source; |
488 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
651 | + if (isset($value['name']) && $value['name'] != '') { |
|
652 | + $data['source_name'] = $value['name']; |
|
653 | + } |
|
489 | 654 | $SI->add($data); |
490 | 655 | unset($data); |
491 | 656 | } |
@@ -520,7 +685,9 @@ discard block |
||
520 | 685 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
521 | 686 | $data['format_source'] = 'planeupdatefaa'; |
522 | 687 | $data['id_source'] = $id_source; |
523 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
688 | + if (isset($value['name']) && $value['name'] != '') { |
|
689 | + $data['source_name'] = $value['name']; |
|
690 | + } |
|
524 | 691 | $SI->add($data); |
525 | 692 | unset($data); |
526 | 693 | } |
@@ -579,7 +746,9 @@ discard block |
||
579 | 746 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
580 | 747 | $data['format_source'] = 'fr24json'; |
581 | 748 | $data['id_source'] = $id_source; |
582 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
749 | + if (isset($value['name']) && $value['name'] != '') { |
|
750 | + $data['source_name'] = $value['name']; |
|
751 | + } |
|
583 | 752 | $SI->add($data); |
584 | 753 | unset($data); |
585 | 754 | } |
@@ -602,23 +771,39 @@ discard block |
||
602 | 771 | if (isset($line['inf'])) { |
603 | 772 | $data = array(); |
604 | 773 | $data['hex'] = $line['inf']['ia']; |
605 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
774 | + if (isset($line['inf']['cs'])) { |
|
775 | + $data['ident'] = $line['inf']['cs']; |
|
776 | + } |
|
777 | + //$line[13] |
|
606 | 778 | $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 |
|
779 | + if (isset($line['inf']['gs'])) { |
|
780 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
781 | + } |
|
782 | + // speed |
|
783 | + if (isset($line['inf']['tr'])) { |
|
784 | + $data['heading'] = $line['inf']['tr']; |
|
785 | + } |
|
786 | + // heading |
|
609 | 787 | $data['latitude'] = $line['pt'][0]; // lat |
610 | 788 | $data['longitude'] = $line['pt'][1]; // long |
611 | 789 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
612 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
790 | + if (isset($line['inf']['sq'])) { |
|
791 | + $data['squawk'] = $line['inf']['sq']; |
|
792 | + } |
|
793 | + // squawk |
|
613 | 794 | //$data['aircraft_icao'] = $line[8]; |
614 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
795 | + if (isset($line['inf']['rc'])) { |
|
796 | + $data['registration'] = $line['inf']['rc']; |
|
797 | + } |
|
615 | 798 | //$data['departure_airport_iata'] = $line[11]; |
616 | 799 | //$data['arrival_airport_iata'] = $line[12]; |
617 | 800 | //$data['emergency'] = ''; // emergency |
618 | 801 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
619 | 802 | $data['format_source'] = 'radarvirtueljson'; |
620 | 803 | $data['id_source'] = $id_source; |
621 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
804 | + if (isset($value['name']) && $value['name'] != '') { |
|
805 | + $data['source_name'] = $value['name']; |
|
806 | + } |
|
622 | 807 | $SI->add($data); |
623 | 808 | unset($data); |
624 | 809 | } |
@@ -638,29 +823,62 @@ discard block |
||
638 | 823 | $data['id'] = $line['id']; |
639 | 824 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
640 | 825 | $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 |
|
826 | + if (isset($line['pilotid'])) { |
|
827 | + $data['pilot_id'] = $line['pilotid']; |
|
828 | + } |
|
829 | + // pilot id |
|
830 | + if (isset($line['name'])) { |
|
831 | + $data['pilot_name'] = $line['name']; |
|
832 | + } |
|
833 | + // pilot name |
|
834 | + if (isset($line['alt'])) { |
|
835 | + $data['altitude'] = $line['alt']; |
|
836 | + } |
|
837 | + // altitude |
|
838 | + if (isset($line['gs'])) { |
|
839 | + $data['speed'] = $line['gs']; |
|
840 | + } |
|
841 | + // speed |
|
842 | + if (isset($line['heading'])) { |
|
843 | + $data['heading'] = $line['heading']; |
|
844 | + } |
|
845 | + // heading |
|
846 | + if (isset($line['route'])) { |
|
847 | + $data['waypoints'] = $line['route']; |
|
848 | + } |
|
849 | + // route |
|
647 | 850 | $data['latitude'] = $line['lat']; // lat |
648 | 851 | $data['longitude'] = $line['lon']; // long |
649 | 852 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
650 | 853 | //$data['squawk'] = $line['squawk']; // squawk |
651 | 854 | //$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']; |
|
855 | + if (isset($line['depicao'])) { |
|
856 | + $data['departure_airport_icao'] = $line['depicao']; |
|
857 | + } |
|
858 | + if (isset($line['deptime'])) { |
|
859 | + $data['departure_airport_time'] = $line['deptime']; |
|
860 | + } |
|
861 | + if (isset($line['arricao'])) { |
|
862 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
863 | + } |
|
655 | 864 | //$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'] = ''; |
|
865 | + if (isset($line['aircraft'])) { |
|
866 | + $data['aircraft_icao'] = $line['aircraft']; |
|
867 | + } |
|
868 | + if (isset($line['transponder'])) { |
|
869 | + $data['squawk'] = $line['transponder']; |
|
870 | + } |
|
871 | + if (isset($line['atis'])) { |
|
872 | + $data['info'] = $line['atis']; |
|
873 | + } else { |
|
874 | + $data['info'] = ''; |
|
875 | + } |
|
660 | 876 | $data['format_source'] = 'pireps'; |
661 | 877 | $data['id_source'] = $id_source; |
662 | 878 | $data['datetime'] = date('Y-m-d H:i:s'); |
663 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
879 | + if (isset($value['name']) && $value['name'] != '') { |
|
880 | + $data['source_name'] = $value['name']; |
|
881 | + } |
|
664 | 882 | if ($line['icon'] == 'plane') { |
665 | 883 | $SI->add($data); |
666 | 884 | // print_r($data); |
@@ -669,15 +887,25 @@ discard block |
||
669 | 887 | $data['info'] = str_replace('&sect;','',$data['info']); |
670 | 888 | $typec = substr($data['ident'],-3); |
671 | 889 | $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'; |
|
890 | + if ($typec == 'APP') { |
|
891 | + $data['type'] = 'Approach'; |
|
892 | + } elseif ($typec == 'TWR') { |
|
893 | + $data['type'] = 'Tower'; |
|
894 | + } elseif ($typec == 'OBS') { |
|
895 | + $data['type'] = 'Observer'; |
|
896 | + } elseif ($typec == 'GND') { |
|
897 | + $data['type'] = 'Ground'; |
|
898 | + } elseif ($typec == 'DEL') { |
|
899 | + $data['type'] = 'Delivery'; |
|
900 | + } elseif ($typec == 'DEP') { |
|
901 | + $data['type'] = 'Departure'; |
|
902 | + } elseif ($typec == 'FSS') { |
|
903 | + $data['type'] = 'Flight Service Station'; |
|
904 | + } elseif ($typec == 'CTR') { |
|
905 | + $data['type'] = 'Control Radar or Centre'; |
|
906 | + } else { |
|
907 | + $data['type'] = 'Observer'; |
|
908 | + } |
|
681 | 909 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
682 | 910 | } |
683 | 911 | unset($data); |
@@ -688,17 +916,25 @@ discard block |
||
688 | 916 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
689 | 917 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
690 | 918 | //$buffer = $Common->getData($hosts[$id]); |
691 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
919 | + if ($globalDebug) { |
|
920 | + echo 'Get Data...'."\n"; |
|
921 | + } |
|
692 | 922 | $buffer = $Common->getData($value['host']); |
693 | 923 | $all_data = json_decode($buffer,true); |
694 | 924 | if ($buffer != '' && is_array($all_data)) { |
695 | 925 | foreach ($all_data as $line) { |
696 | 926 | $data = array(); |
697 | 927 | //$data['id'] = $line['id']; // id not usable |
698 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
928 | + if (isset($line['pilotid'])) { |
|
929 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
930 | + } |
|
699 | 931 | $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']; |
|
932 | + if (isset($line['pilotname'])) { |
|
933 | + $data['pilot_name'] = $line['pilotname']; |
|
934 | + } |
|
935 | + if (isset($line['pilotid'])) { |
|
936 | + $data['pilot_id'] = $line['pilotid']; |
|
937 | + } |
|
702 | 938 | $data['ident'] = $line['flightnum']; // ident |
703 | 939 | $data['altitude'] = $line['alt']; // altitude |
704 | 940 | $data['speed'] = $line['gs']; // speed |
@@ -716,27 +952,41 @@ discard block |
||
716 | 952 | $data['arrival_airport_icao'] = $line['arricao']; |
717 | 953 | $data['arrival_airport_time'] = $line['arrtime']; |
718 | 954 | $data['registration'] = $line['aircraft']; |
719 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
955 | + if (isset($line['route'])) { |
|
956 | + $data['waypoints'] = $line['route']; |
|
957 | + } |
|
958 | + // route |
|
720 | 959 | if (isset($line['aircraftname'])) { |
721 | 960 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
722 | 961 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
723 | 962 | $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 { |
|
963 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
964 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
965 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
966 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
967 | + } else { |
|
727 | 968 | $aircraft_data = explode(' ',$line['aircraftname']); |
728 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
729 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
969 | + if (isset($aircraft_data[1])) { |
|
970 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
971 | + } else { |
|
972 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
973 | + } |
|
730 | 974 | } |
731 | 975 | } |
732 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
976 | + if (isset($line['route'])) { |
|
977 | + $data['waypoints'] = $line['route']; |
|
978 | + } |
|
733 | 979 | $data['id_source'] = $id_source; |
734 | 980 | $data['format_source'] = 'phpvmacars'; |
735 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
981 | + if (isset($value['name']) && $value['name'] != '') { |
|
982 | + $data['source_name'] = $value['name']; |
|
983 | + } |
|
736 | 984 | $SI->add($data); |
737 | 985 | unset($data); |
738 | 986 | } |
739 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
987 | + if ($globalDebug) { |
|
988 | + echo 'No more data...'."\n"; |
|
989 | + } |
|
740 | 990 | unset($buffer); |
741 | 991 | unset($all_data); |
742 | 992 | } |
@@ -744,7 +994,9 @@ discard block |
||
744 | 994 | $last_exec[$id]['last'] = time(); |
745 | 995 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
746 | 996 | //$buffer = $Common->getData($hosts[$id]); |
747 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
997 | + if ($globalDebug) { |
|
998 | + echo 'Get Data...'."\n"; |
|
999 | + } |
|
748 | 1000 | $buffer = $Common->getData($value['host']); |
749 | 1001 | $all_data = json_decode($buffer,true); |
750 | 1002 | if ($buffer != '' && is_array($all_data)) { |
@@ -772,15 +1024,22 @@ discard block |
||
772 | 1024 | $data['arrival_airport_icao'] = $line['arrival']; |
773 | 1025 | //$data['arrival_airport_time'] = $line['arrival_time']; |
774 | 1026 | //$data['registration'] = $line['aircraft']; |
775 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1027 | + if (isset($line['route'])) { |
|
1028 | + $data['waypoints'] = $line['route']; |
|
1029 | + } |
|
1030 | + // route |
|
776 | 1031 | $data['aircraft_icao'] = $line['plane_type']; |
777 | 1032 | $data['id_source'] = $id_source; |
778 | 1033 | $data['format_source'] = 'vam'; |
779 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1034 | + if (isset($value['name']) && $value['name'] != '') { |
|
1035 | + $data['source_name'] = $value['name']; |
|
1036 | + } |
|
780 | 1037 | $SI->add($data); |
781 | 1038 | unset($data); |
782 | 1039 | } |
783 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1040 | + if ($globalDebug) { |
|
1041 | + echo 'No more data...'."\n"; |
|
1042 | + } |
|
784 | 1043 | unset($buffer); |
785 | 1044 | unset($all_data); |
786 | 1045 | } |
@@ -788,7 +1047,9 @@ discard block |
||
788 | 1047 | $last_exec[$id]['last'] = time(); |
789 | 1048 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
790 | 1049 | } 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(); |
|
1050 | + if (function_exists('pcntl_fork')) { |
|
1051 | + pcntl_signal_dispatch(); |
|
1052 | + } |
|
792 | 1053 | //$last_exec[$id]['last'] = time(); |
793 | 1054 | |
794 | 1055 | //$read = array( $sockets[$id] ); |
@@ -796,7 +1057,9 @@ discard block |
||
796 | 1057 | $write = NULL; |
797 | 1058 | $e = NULL; |
798 | 1059 | $n = socket_select($read, $write, $e, $timeout); |
799 | - if ($e != NULL) var_dump($e); |
|
1060 | + if ($e != NULL) { |
|
1061 | + var_dump($e); |
|
1062 | + } |
|
800 | 1063 | if ($n > 0) { |
801 | 1064 | foreach ($read as $nb => $r) { |
802 | 1065 | //$value = $formats[$nb]; |
@@ -817,7 +1080,9 @@ discard block |
||
817 | 1080 | if ($buffer != '') { |
818 | 1081 | $tt[$format] = 0; |
819 | 1082 | if ($format == 'acarssbs3') { |
820 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1083 | + if ($globalDebug) { |
|
1084 | + echo 'ACARS : '.$buffer."\n"; |
|
1085 | + } |
|
821 | 1086 | $ACARS->add(trim($buffer)); |
822 | 1087 | $ACARS->deleteLiveAcarsData(); |
823 | 1088 | } elseif ($format == 'raw') { |
@@ -826,9 +1091,15 @@ discard block |
||
826 | 1091 | if (is_array($data)) { |
827 | 1092 | $data['datetime'] = date('Y-m-d H:i:s'); |
828 | 1093 | $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); |
|
1094 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1095 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1096 | + } |
|
1097 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1098 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1099 | + } |
|
1100 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1101 | + $SI->add($data); |
|
1102 | + } |
|
832 | 1103 | } |
833 | 1104 | } elseif ($format == 'flightgearsp') { |
834 | 1105 | //echo $buffer."\n"; |
@@ -846,11 +1117,15 @@ discard block |
||
846 | 1117 | $data['speed'] = round($line[5]*1.94384); |
847 | 1118 | $data['datetime'] = date('Y-m-d H:i:s'); |
848 | 1119 | $data['format_source'] = 'flightgearsp'; |
849 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1120 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1121 | + $SI->add($data); |
|
1122 | + } |
|
850 | 1123 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
851 | 1124 | } |
852 | 1125 | } elseif ($format == 'acars') { |
853 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1126 | + if ($globalDebug) { |
|
1127 | + echo 'ACARS : '.$buffer."\n"; |
|
1128 | + } |
|
854 | 1129 | $ACARS->add(trim($buffer)); |
855 | 1130 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
856 | 1131 | $ACARS->deleteLiveAcarsData(); |
@@ -871,7 +1146,9 @@ discard block |
||
871 | 1146 | $aircraft_type = $line[10]; |
872 | 1147 | $aircraft_type = preg_split(':/:',$aircraft_type); |
873 | 1148 | $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); |
|
1149 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1150 | + $SI->add($data); |
|
1151 | + } |
|
875 | 1152 | } |
876 | 1153 | } |
877 | 1154 | } elseif ($format == 'beast') { |
@@ -887,21 +1164,43 @@ discard block |
||
887 | 1164 | $data['hex'] = $lined['hexid']; |
888 | 1165 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
889 | 1166 | $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']; |
|
1167 | + if (isset($lined['ident'])) { |
|
1168 | + $data['ident'] = $lined['ident']; |
|
1169 | + } |
|
1170 | + if (isset($lined['lat'])) { |
|
1171 | + $data['latitude'] = $lined['lat']; |
|
1172 | + } |
|
1173 | + if (isset($lined['lon'])) { |
|
1174 | + $data['longitude'] = $lined['lon']; |
|
1175 | + } |
|
1176 | + if (isset($lined['speed'])) { |
|
1177 | + $data['speed'] = $lined['speed']; |
|
1178 | + } |
|
1179 | + if (isset($lined['squawk'])) { |
|
1180 | + $data['squawk'] = $lined['squawk']; |
|
1181 | + } |
|
1182 | + if (isset($lined['alt'])) { |
|
1183 | + $data['altitude'] = $lined['alt']; |
|
1184 | + } |
|
1185 | + if (isset($lined['heading'])) { |
|
1186 | + $data['heading'] = $lined['heading']; |
|
1187 | + } |
|
897 | 1188 | $data['id_source'] = $id_source; |
898 | 1189 | $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); |
|
1190 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1191 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1192 | + } |
|
1193 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1194 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1195 | + } |
|
1196 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1197 | + $SI->add($data); |
|
1198 | + } |
|
902 | 1199 | unset($lined); |
903 | 1200 | unset($data); |
904 | - } else $error = true; |
|
1201 | + } else { |
|
1202 | + $error = true; |
|
1203 | + } |
|
905 | 1204 | } elseif ($format == 'aprs' && $use_aprs) { |
906 | 1205 | if ($aprs_connect == 0) { |
907 | 1206 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -927,29 +1226,44 @@ discard block |
||
927 | 1226 | $data['latitude'] = $line['latitude']; |
928 | 1227 | $data['longitude'] = $line['longitude']; |
929 | 1228 | //$data['verticalrate'] = $line[16]; |
930 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
931 | - else $data['speed'] = 0; |
|
1229 | + if (isset($line['speed'])) { |
|
1230 | + $data['speed'] = $line['speed']; |
|
1231 | + } else { |
|
1232 | + $data['speed'] = 0; |
|
1233 | + } |
|
932 | 1234 | $data['altitude'] = $line['altitude']; |
933 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
1235 | + if (isset($line['course'])) { |
|
1236 | + $data['heading'] = $line['course']; |
|
1237 | + } |
|
934 | 1238 | //else $data['heading'] = 0; |
935 | 1239 | $data['aircraft_type'] = $line['stealth']; |
936 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1240 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
1241 | + $data['noarchive'] = true; |
|
1242 | + } |
|
937 | 1243 | $data['id_source'] = $id_source; |
938 | 1244 | $data['format_source'] = 'aprs'; |
939 | 1245 | $data['source_name'] = $line['source']; |
940 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1246 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1247 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1248 | + } |
|
941 | 1249 | $currentdate = date('Y-m-d H:i:s'); |
942 | 1250 | $aprsdate = strtotime($data['datetime']); |
943 | 1251 | // 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"; |
|
1252 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1253 | + $send = $SI->add($data); |
|
1254 | + } else { |
|
1255 | + if ($line['stealth'] != 0) { |
|
1256 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1257 | + } else { |
|
1258 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1259 | + } |
|
948 | 1260 | } |
949 | 1261 | unset($data); |
950 | 1262 | } |
951 | 1263 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
952 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
1264 | + elseif ($line == true && $globalDebug) { |
|
1265 | + echo '!! Failed : '.$buffer."!!\n"; |
|
1266 | + } |
|
953 | 1267 | } |
954 | 1268 | } else { |
955 | 1269 | $line = explode(',', $buffer); |
@@ -977,25 +1291,42 @@ discard block |
||
977 | 1291 | $data['ground'] = $line[21]; |
978 | 1292 | $data['emergency'] = $line[19]; |
979 | 1293 | $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']; |
|
1294 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1295 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1296 | + } |
|
1297 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1298 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1299 | + } |
|
982 | 1300 | $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; |
|
1301 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1302 | + $send = $SI->add($data); |
|
1303 | + } else { |
|
1304 | + $error = true; |
|
1305 | + } |
|
985 | 1306 | unset($data); |
986 | - } else $error = true; |
|
1307 | + } else { |
|
1308 | + $error = true; |
|
1309 | + } |
|
987 | 1310 | if ($error) { |
988 | 1311 | 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"; |
|
1312 | + if ($globalDebug) { |
|
1313 | + echo "Not a message. Ignoring... \n"; |
|
1314 | + } |
|
990 | 1315 | } else { |
991 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1316 | + if ($globalDebug) { |
|
1317 | + echo "Wrong line format. Ignoring... \n"; |
|
1318 | + } |
|
992 | 1319 | if ($globalDebug) { |
993 | 1320 | echo $buffer; |
994 | 1321 | print_r($line); |
995 | 1322 | } |
996 | 1323 | //socket_close($r); |
997 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
998 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1324 | + if ($globalDebug) { |
|
1325 | + echo "Reconnect after an error...\n"; |
|
1326 | + } |
|
1327 | + if ($format == 'aprs') { |
|
1328 | + $aprs_connect = 0; |
|
1329 | + } |
|
999 | 1330 | $sourceer[$nb] = $globalSources[$nb]; |
1000 | 1331 | connect_all($sourceer); |
1001 | 1332 | $sourceer = array(); |
@@ -1003,10 +1334,14 @@ discard block |
||
1003 | 1334 | } |
1004 | 1335 | } |
1005 | 1336 | // Sleep for xxx microseconds |
1006 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1337 | + if (isset($globalSBSSleep)) { |
|
1338 | + usleep($globalSBSSleep); |
|
1339 | + } |
|
1007 | 1340 | } else { |
1008 | 1341 | if ($format == 'flightgearmp') { |
1009 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1342 | + if ($globalDebug) { |
|
1343 | + echo "Reconnect FlightGear MP..."; |
|
1344 | + } |
|
1010 | 1345 | //@socket_close($r); |
1011 | 1346 | sleep($globalMinFetch); |
1012 | 1347 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1015,10 +1350,15 @@ discard block |
||
1015 | 1350 | break; |
1016 | 1351 | |
1017 | 1352 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1018 | - if (isset($tt[$format])) $tt[$format]++; |
|
1019 | - else $tt[$format] = 0; |
|
1353 | + if (isset($tt[$format])) { |
|
1354 | + $tt[$format]++; |
|
1355 | + } else { |
|
1356 | + $tt[$format] = 0; |
|
1357 | + } |
|
1020 | 1358 | if ($tt[$format] > 30) { |
1021 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1359 | + if ($globalDebug) { |
|
1360 | + echo "ERROR : Reconnect ".$format."..."; |
|
1361 | + } |
|
1022 | 1362 | //@socket_close($r); |
1023 | 1363 | sleep(2); |
1024 | 1364 | $aprs_connect = 0; |
@@ -1034,12 +1374,18 @@ discard block |
||
1034 | 1374 | } |
1035 | 1375 | } else { |
1036 | 1376 | $error = socket_strerror(socket_last_error()); |
1037 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1377 | + if ($globalDebug) { |
|
1378 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1379 | + } |
|
1038 | 1380 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
1039 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1381 | + if (isset($globalDebug)) { |
|
1382 | + echo "Restarting...\n"; |
|
1383 | + } |
|
1040 | 1384 | // Restart the script if possible |
1041 | 1385 | if (is_array($sockets)) { |
1042 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1386 | + if ($globalDebug) { |
|
1387 | + echo "Shutdown all sockets..."; |
|
1388 | + } |
|
1043 | 1389 | |
1044 | 1390 | foreach ($sockets as $sock) { |
1045 | 1391 | @socket_shutdown($sock,2); |
@@ -1047,7 +1393,9 @@ discard block |
||
1047 | 1393 | } |
1048 | 1394 | |
1049 | 1395 | } |
1050 | - if ($globalDebug) echo "Restart all connections..."; |
|
1396 | + if ($globalDebug) { |
|
1397 | + echo "Restart all connections..."; |
|
1398 | + } |
|
1051 | 1399 | sleep(2); |
1052 | 1400 | $time = time(); |
1053 | 1401 | //connect_all($hosts); |
@@ -1058,7 +1406,9 @@ discard block |
||
1058 | 1406 | } |
1059 | 1407 | } |
1060 | 1408 | if ($globalDaemon === false) { |
1061 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1409 | + if ($globalDebug) { |
|
1410 | + echo 'Check all...'."\n"; |
|
1411 | + } |
|
1062 | 1412 | $SI->checkAll(); |
1063 | 1413 | } |
1064 | 1414 | } |
@@ -11,27 +11,27 @@ |
||
11 | 11 | die(); |
12 | 12 | } |
13 | 13 | $query = 'select * from vam_live_flights rc, gvausers gu where gu.gvauser_id = rc.gvauser_id'; |
14 | -$json_data=array(); |
|
14 | +$json_data = array(); |
|
15 | 15 | $result = $db->query($query); |
16 | 16 | while ($rec = $result->fetch_assoc()) |
17 | 17 | { |
18 | - $json_array['gvauser_id']=$rec['gvauser_id']; // users "pilot unique ID" "40" |
|
19 | - $json_array['flight_id']=$rec['flight_id']; // flight_id |
|
20 | - $json_array['pilot_id']=$rec['callsign']; // users pilot_id "VAM500" |
|
21 | - $json_array['callsign']=substr($rec['flight_id'],-7); // substr icao Flight "AFR524" |
|
22 | - $json_array['pilot_name']=$rec['name'] .' '.$rec['surname'] ; // Users "name + surname" |
|
23 | - $json_array['plane_type']=$rec['plane_type']; // type Plane "B739" |
|
24 | - $json_array['departure']=$rec['departure']; // departure ICAO |
|
25 | - $json_array['arrival']=$rec['arrival']; // arrival Ident |
|
26 | - $json_array['latitude']=$rec['latitude']; // return 55.7328860921521 |
|
27 | - $json_array['longitude']=$rec['longitude']; // return 8.87433614409404 |
|
28 | - $json_array['altitude']=$rec['altitude']; // return "147" |
|
29 | - $json_array['heading']=$rec['heading']; // return "307" |
|
30 | - $json_array['ias']=$rec['ias']; // return speed "IAS" |
|
31 | - $json_array['gs']=$rec['gs']; // return speed "GS" |
|
18 | + $json_array['gvauser_id'] = $rec['gvauser_id']; // users "pilot unique ID" "40" |
|
19 | + $json_array['flight_id'] = $rec['flight_id']; // flight_id |
|
20 | + $json_array['pilot_id'] = $rec['callsign']; // users pilot_id "VAM500" |
|
21 | + $json_array['callsign'] = substr($rec['flight_id'], -7); // substr icao Flight "AFR524" |
|
22 | + $json_array['pilot_name'] = $rec['name'].' '.$rec['surname']; // Users "name + surname" |
|
23 | + $json_array['plane_type'] = $rec['plane_type']; // type Plane "B739" |
|
24 | + $json_array['departure'] = $rec['departure']; // departure ICAO |
|
25 | + $json_array['arrival'] = $rec['arrival']; // arrival Ident |
|
26 | + $json_array['latitude'] = $rec['latitude']; // return 55.7328860921521 |
|
27 | + $json_array['longitude'] = $rec['longitude']; // return 8.87433614409404 |
|
28 | + $json_array['altitude'] = $rec['altitude']; // return "147" |
|
29 | + $json_array['heading'] = $rec['heading']; // return "307" |
|
30 | + $json_array['ias'] = $rec['ias']; // return speed "IAS" |
|
31 | + $json_array['gs'] = $rec['gs']; // return speed "GS" |
|
32 | 32 | // $json_array['routes']=$rec['routes']; // (unusable) |
33 | - $json_array['flight_status']=$rec['flight_status']; // "return Status" |
|
34 | - $json_array['last_update']=$rec['last_update']; // return "DateTime" |
|
33 | + $json_array['flight_status'] = $rec['flight_status']; // "return Status" |
|
34 | + $json_array['last_update'] = $rec['last_update']; // return "DateTime" |
|
35 | 35 | $json_data[] = $json_array; |
36 | 36 | } |
37 | 37 | echo json_encode($json_data); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | |
8 | 8 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
9 | 9 | if ($airline_icao == 'all') { |
10 | - unset($_COOKIE['stats_airline_icao']); |
|
11 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | - $airline_icao = ''; |
|
10 | + unset($_COOKIE['stats_airline_icao']); |
|
11 | + setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + $airline_icao = ''; |
|
13 | 13 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
14 | - $airline_icao = $_COOKIE['stats_airline_icao']; |
|
14 | + $airline_icao = $_COOKIE['stats_airline_icao']; |
|
15 | 15 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
16 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
16 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
17 | 17 | } |
18 | 18 | setcookie('stats_airline_icao',$airline_icao); |
19 | 19 | |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | function drawChart() { |
35 | 35 | var data = google.visualization.arrayToDataTable([ |
36 | 36 | ["'._("Pilot").'", "'._("# of times").'"], '; |
37 | - $pilot_data = ''; |
|
37 | + $pilot_data = ''; |
|
38 | 38 | foreach($pilot_array as $pilot_item) |
39 | 39 | { |
40 | 40 | $pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
41 | 41 | } |
42 | 42 | $pilot_data = substr($pilot_data, 0, -1); |
43 | 43 | print $pilot_data; |
44 | - print ']); |
|
44 | + print ']); |
|
45 | 45 | |
46 | 46 | var options = { |
47 | 47 | chartArea: {"width": "80%", "height": "60%"}, |
@@ -6,17 +6,17 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Pilots"); |
7 | 7 | |
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
10 | 10 | if ($airline_icao == 'all') { |
11 | 11 | unset($_COOKIE['stats_airline_icao']); |
12 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + setcookie('stats_airline_icao', '', time() - 3600); |
|
13 | 13 | $airline_icao = ''; |
14 | 14 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 15 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 16 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | 17 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
18 | 18 | } |
19 | -setcookie('stats_airline_icao',$airline_icao); |
|
19 | +setcookie('stats_airline_icao', $airline_icao); |
|
20 | 20 | |
21 | 21 | require_once('header.php'); |
22 | 22 | include('statistics-sub-menu.php'); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | </div> |
28 | 28 | <p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>'; |
29 | 29 | |
30 | - $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name); |
|
30 | + $pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name); |
|
31 | 31 | print '<div id="chart" class="chart" width="100%"></div> |
32 | 32 | <script> |
33 | 33 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | var data = google.visualization.arrayToDataTable([ |
37 | 37 | ["'._("Pilot").'", "'._("# of times").'"], '; |
38 | 38 | $pilot_data = ''; |
39 | - foreach($pilot_array as $pilot_item) |
|
39 | + foreach ($pilot_array as $pilot_item) |
|
40 | 40 | { |
41 | 41 | $pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
42 | 42 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | print '</thead>'; |
70 | 70 | print '<tbody>'; |
71 | 71 | $i = 1; |
72 | - foreach($pilot_array as $pilot_item) |
|
72 | + foreach ($pilot_array as $pilot_item) |
|
73 | 73 | { |
74 | 74 | print '<tr>'; |
75 | 75 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Callsign"); |
7 | 7 | |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 12 | if ($airline_icao == 'all') { |
11 | 13 | unset($_COOKIE['stats_airline_icao']); |
@@ -14,8 +16,10 @@ discard block |
||
14 | 16 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 17 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 18 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
18 | -} |
|
19 | + if (isset($globalFilter['airline'])) { |
|
20 | + $airline_icao = $globalFilter['airline'][0]; |
|
21 | + } |
|
22 | + } |
|
19 | 23 | setcookie('stats_airline_icao',$airline_icao); |
20 | 24 | |
21 | 25 | require_once('header.php'); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | |
8 | 8 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
9 | 9 | if ($airline_icao == 'all') { |
10 | - unset($_COOKIE['stats_airline_icao']); |
|
11 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | - $airline_icao = ''; |
|
10 | + unset($_COOKIE['stats_airline_icao']); |
|
11 | + setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + $airline_icao = ''; |
|
13 | 13 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
14 | - $airline_icao = $_COOKIE['stats_airline_icao']; |
|
14 | + $airline_icao = $_COOKIE['stats_airline_icao']; |
|
15 | 15 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
16 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
16 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
17 | 17 | } |
18 | 18 | setcookie('stats_airline_icao',$airline_icao); |
19 | 19 | |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | function drawChart() { |
34 | 34 | var data = google.visualization.arrayToDataTable([ |
35 | 35 | ["'._("Owner").'", "'._("# of times").'"], '; |
36 | - $owner_data = ''; |
|
36 | + $owner_data = ''; |
|
37 | 37 | foreach($owner_array as $owner_item) |
38 | 38 | { |
39 | 39 | $owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],'; |
40 | 40 | } |
41 | 41 | $owner_data = substr($owner_data, 0, -1); |
42 | 42 | print $owner_data; |
43 | - print ']); |
|
43 | + print ']); |
|
44 | 44 | |
45 | 45 | var options = { |
46 | 46 | chartArea: {"width": "80%", "height": "60%"}, |
@@ -6,17 +6,17 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common owners"); |
7 | 7 | |
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
10 | 10 | if ($airline_icao == 'all') { |
11 | 11 | unset($_COOKIE['stats_airline_icao']); |
12 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + setcookie('stats_airline_icao', '', time() - 3600); |
|
13 | 13 | $airline_icao = ''; |
14 | 14 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 15 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 16 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | 17 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
18 | 18 | } |
19 | -setcookie('stats_airline_icao',$airline_icao); |
|
19 | +setcookie('stats_airline_icao', $airline_icao); |
|
20 | 20 | |
21 | 21 | require_once('header.php'); |
22 | 22 | include('statistics-sub-menu.php'); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | </div> |
27 | 27 | <p>'._("Below are the <strong>Top 10</strong> most common owner.").'</p>'; |
28 | 28 | |
29 | - $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name); |
|
29 | + $owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name); |
|
30 | 30 | print '<div id="chart" class="chart" width="100%"></div> |
31 | 31 | <script> |
32 | 32 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | var data = google.visualization.arrayToDataTable([ |
36 | 36 | ["'._("Owner").'", "'._("# of times").'"], '; |
37 | 37 | $owner_data = ''; |
38 | - foreach($owner_array as $owner_item) |
|
38 | + foreach ($owner_array as $owner_item) |
|
39 | 39 | { |
40 | 40 | $owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],'; |
41 | 41 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | print '</thead>'; |
69 | 69 | print '<tbody>'; |
70 | 70 | $i = 1; |
71 | - foreach($owner_array as $owner_item) |
|
71 | + foreach ($owner_array as $owner_item) |
|
72 | 72 | { |
73 | 73 | print '<tr>'; |
74 | 74 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Callsign"); |
7 | 7 | |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 12 | if ($airline_icao == 'all') { |
11 | 13 | unset($_COOKIE['stats_airline_icao']); |
@@ -14,8 +16,10 @@ discard block |
||
14 | 16 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 17 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 18 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
18 | -} |
|
19 | + if (isset($globalFilter['airline'])) { |
|
20 | + $airline_icao = $globalFilter['airline'][0]; |
|
21 | + } |
|
22 | + } |
|
19 | 23 | setcookie('stats_airline_icao',$airline_icao); |
20 | 24 | |
21 | 25 | require_once('header.php'); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | |
8 | 8 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
9 | 9 | if ($airline_icao == 'all') { |
10 | - unset($_COOKIE['stats_airline_icao']); |
|
11 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | - $airline_icao = ''; |
|
10 | + unset($_COOKIE['stats_airline_icao']); |
|
11 | + setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + $airline_icao = ''; |
|
13 | 13 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
14 | - $airline_icao = $_COOKIE['stats_airline_icao']; |
|
14 | + $airline_icao = $_COOKIE['stats_airline_icao']; |
|
15 | 15 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
16 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
16 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
17 | 17 | } |
18 | 18 | setcookie('stats_airline_icao',$airline_icao); |
19 | 19 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | function drawChart() { |
35 | 35 | var data = google.visualization.arrayToDataTable([ |
36 | 36 | ["'._("Aircraft Manufacturer").'", "'._("# of times").'"], '; |
37 | - $registration_data = ''; |
|
37 | + $registration_data = ''; |
|
38 | 38 | foreach($registration_array as $registration_item) |
39 | 39 | { |
40 | 40 | $registration_data .= '[ "'.$registration_item['registration'].' - '.$registration_item['aircraft_name'].' ('.$registration_item['aircraft_icao'].')",'.$registration_item['aircraft_registration_count'].'],'; |
@@ -6,17 +6,17 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Aircraft Registrations"); |
7 | 7 | |
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
10 | 10 | if ($airline_icao == 'all') { |
11 | 11 | unset($_COOKIE['stats_airline_icao']); |
12 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + setcookie('stats_airline_icao', '', time() - 3600); |
|
13 | 13 | $airline_icao = ''; |
14 | 14 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 15 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 16 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | 17 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
18 | 18 | } |
19 | -setcookie('stats_airline_icao',$airline_icao); |
|
19 | +setcookie('stats_airline_icao', $airline_icao); |
|
20 | 20 | |
21 | 21 | require_once('header.php'); |
22 | 22 | include('statistics-sub-menu.php'); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | </div> |
28 | 28 | <p>'._("Below are the <strong>Top 10</strong> most common aircraft registrations.").'</p>'; |
29 | 29 | |
30 | -$registration_array = $Stats->countAllAircraftRegistrations(true,$airline_icao,$filter_name); |
|
30 | +$registration_array = $Stats->countAllAircraftRegistrations(true, $airline_icao, $filter_name); |
|
31 | 31 | print '<div id="chart" class="chart" width="100%"></div> |
32 | 32 | <script> |
33 | 33 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | var data = google.visualization.arrayToDataTable([ |
37 | 37 | ["'._("Aircraft Manufacturer").'", "'._("# of times").'"], '; |
38 | 38 | $registration_data = ''; |
39 | -foreach($registration_array as $registration_item) |
|
39 | +foreach ($registration_array as $registration_item) |
|
40 | 40 | { |
41 | 41 | $registration_data .= '[ "'.$registration_item['registration'].' - '.$registration_item['aircraft_name'].' ('.$registration_item['aircraft_icao'].')",'.$registration_item['aircraft_registration_count'].'],'; |
42 | 42 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | print '</thead>'; |
72 | 72 | print '<tbody>'; |
73 | 73 | $i = 1; |
74 | - foreach($registration_array as $registration_item) |
|
74 | + foreach ($registration_array as $registration_item) |
|
75 | 75 | { |
76 | 76 | print '<tr>'; |
77 | 77 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Callsign"); |
7 | 7 | |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 12 | if ($airline_icao == 'all') { |
11 | 13 | unset($_COOKIE['stats_airline_icao']); |
@@ -14,8 +16,10 @@ discard block |
||
14 | 16 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 17 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 18 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
18 | -} |
|
19 | + if (isset($globalFilter['airline'])) { |
|
20 | + $airline_icao = $globalFilter['airline'][0]; |
|
21 | + } |
|
22 | + } |
|
19 | 23 | setcookie('stats_airline_icao',$airline_icao); |
20 | 24 | |
21 | 25 | require_once('header.php'); |
@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
9 | 9 | if ($airline_icao == 'all') { |
10 | - unset($_COOKIE['stats_airline_icao']); |
|
11 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | - $airline_icao = ''; |
|
10 | + unset($_COOKIE['stats_airline_icao']); |
|
11 | + setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + $airline_icao = ''; |
|
13 | 13 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
14 | - $airline_icao = $_COOKIE['stats_airline_icao']; |
|
14 | + $airline_icao = $_COOKIE['stats_airline_icao']; |
|
15 | 15 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
16 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
16 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
17 | 17 | } |
18 | 18 | setcookie('stats_airline_icao',$airline_icao); |
19 | 19 |
@@ -6,17 +6,17 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Country a flight was over"); |
7 | 7 | |
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
10 | 10 | if ($airline_icao == 'all') { |
11 | 11 | unset($_COOKIE['stats_airline_icao']); |
12 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + setcookie('stats_airline_icao', '', time() - 3600); |
|
13 | 13 | $airline_icao = ''; |
14 | 14 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 15 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 16 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | 17 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
18 | 18 | } |
19 | -setcookie('stats_airline_icao',$airline_icao); |
|
19 | +setcookie('stats_airline_icao', $airline_icao); |
|
20 | 20 | |
21 | 21 | require_once('header.php'); |
22 | 22 | include('statistics-sub-menu.php'); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | </div> |
28 | 28 | <p>'._("Below are the <strong>Top 10</strong> most common country a flight was over.").'</p>'; |
29 | 29 | |
30 | -$flightover_array = $Stats->countAllFlightOverCountries(true,$airline_icao,$filter_name); |
|
30 | +$flightover_array = $Stats->countAllFlightOverCountries(true, $airline_icao, $filter_name); |
|
31 | 31 | print '<div id="chart" class="chart" width="100%"></div> |
32 | 32 | <script> |
33 | 33 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | var data = google.visualization.arrayToDataTable([ |
37 | 37 | ["'._("Country").'", "'._("# of times").'"], '; |
38 | 38 | $flightover_data = ''; |
39 | -foreach($flightover_array as $flightover_item) |
|
39 | +foreach ($flightover_array as $flightover_item) |
|
40 | 40 | { |
41 | 41 | $flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],'; |
42 | 42 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | print '</thead>'; |
72 | 72 | print '<tbody>'; |
73 | 73 | $i = 1; |
74 | - foreach($flightover_array as $flightover_item) |
|
74 | + foreach ($flightover_array as $flightover_item) |
|
75 | 75 | { |
76 | 76 | print '<tr>'; |
77 | 77 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Callsign"); |
7 | 7 | |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 12 | if ($airline_icao == 'all') { |
11 | 13 | unset($_COOKIE['stats_airline_icao']); |
@@ -14,8 +16,10 @@ discard block |
||
14 | 16 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
15 | 17 | $airline_icao = $_COOKIE['stats_airline_icao']; |
16 | 18 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
17 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
18 | -} |
|
19 | + if (isset($globalFilter['airline'])) { |
|
20 | + $airline_icao = $globalFilter['airline'][0]; |
|
21 | + } |
|
22 | + } |
|
19 | 23 | setcookie('stats_airline_icao',$airline_icao); |
20 | 24 | |
21 | 25 | require_once('header.php'); |