@@ -20,20 +20,27 @@ discard block |
||
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
23 | + if (isset($source['source'])) { |
|
24 | + $filter['source'][] = $source['source']; |
|
25 | + } |
|
24 | 26 | } |
25 | 27 | } else { |
26 | 28 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | 29 | } |
28 | 30 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
31 | + if (is_array($globalFilter)) { |
|
32 | + $filter = array_merge($filter,$globalFilter); |
|
33 | + } |
|
30 | 34 | $filter_query_join = ''; |
31 | 35 | $filter_query_where = ''; |
32 | 36 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | 37 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
34 | 38 | } |
35 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
36 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
39 | + if ($filter_query_where == '' && $where) { |
|
40 | + $filter_query_where = ' WHERE'; |
|
41 | + } elseif ($filter_query_where != '' && $and) { |
|
42 | + $filter_query_where .= ' AND'; |
|
43 | + } |
|
37 | 44 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 45 | return $filter_query; |
39 | 46 | } |
@@ -90,7 +97,9 @@ discard block |
||
90 | 97 | $info = str_replace('^','<br />',$info); |
91 | 98 | $info = str_replace('&sect;','',$info); |
92 | 99 | $info = str_replace('"','',$info); |
93 | - if ($type == '') $type = NULL; |
|
100 | + if ($type == '') { |
|
101 | + $type = NULL; |
|
102 | + } |
|
94 | 103 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
95 | 104 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
96 | 105 | try { |
@@ -106,7 +115,9 @@ discard block |
||
106 | 115 | $info = str_replace('^','<br />',$info); |
107 | 116 | $info = str_replace('&sect;','',$info); |
108 | 117 | $info = str_replace('"','',$info); |
109 | - if ($type == '') $type = NULL; |
|
118 | + if ($type == '') { |
|
119 | + $type = NULL; |
|
120 | + } |
|
110 | 121 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
111 | 122 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
112 | 123 | try { |
@@ -202,7 +202,12 @@ discard block |
||
202 | 202 | // viewer.dataSources.get(dsn).entities.remove(entity); |
203 | 203 | // } |
204 | 204 | //console.log(entity.lastupdate); |
205 | - if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
205 | + if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
206 | + print $globalMapRefresh*2000; |
|
207 | +} else { |
|
208 | + print '60000'; |
|
209 | +} |
|
210 | +?>)) { |
|
206 | 211 | // console.log('Remove an entity date'); |
207 | 212 | viewer.dataSources.get(dsn).entities.remove(entity); |
208 | 213 | } else { |
@@ -276,7 +281,12 @@ discard block |
||
276 | 281 | } else { |
277 | 282 | for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { |
278 | 283 | var entity = viewer.dataSources.get(dsn).entities.values[i]; |
279 | - if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
284 | + if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
285 | + print $globalMapRefresh*2000; |
|
286 | +} else { |
|
287 | + print '60000'; |
|
288 | +} |
|
289 | +?>)) { |
|
280 | 290 | viewer.dataSources.get(dsn).entities.remove(entity); |
281 | 291 | } |
282 | 292 | } |
@@ -606,7 +616,12 @@ discard block |
||
606 | 616 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
607 | 617 | ?> |
608 | 618 | update_polarLayer(); |
609 | -setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
619 | +setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
620 | + print $globalMapRefresh*1000*2; |
|
621 | +} else { |
|
622 | + print '60000'; |
|
623 | +} |
|
624 | +?>); |
|
610 | 625 | <?php |
611 | 626 | } |
612 | 627 | ?> |
@@ -704,7 +719,12 @@ discard block |
||
704 | 719 | } |
705 | 720 | } |
706 | 721 | } |
707 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
722 | + ,<?php if (isset($globalMapRefresh)) { |
|
723 | + print $globalMapRefresh*1000; |
|
724 | +} else { |
|
725 | + print '30000'; |
|
726 | +} |
|
727 | +?>); |
|
708 | 728 | } else { |
709 | 729 | //var widget = new Cesium.CesiumWidget('archivebox'); |
710 | 730 | // var timeline = new Cesium.Timeline(viewer); |
@@ -723,7 +743,12 @@ discard block |
||
723 | 743 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
724 | 744 | ?> |
725 | 745 | update_atcLayer(); |
726 | -setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
746 | +setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
747 | + print $globalMapRefresh*1000*2; |
|
748 | +} else { |
|
749 | + print '60000'; |
|
750 | +} |
|
751 | +?>); |
|
727 | 752 | <?php |
728 | 753 | } |
729 | 754 | ?> |
@@ -13,13 +13,17 @@ discard block |
||
13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
16 | +if (isset($globalTracker) && $globalTracker) { |
|
17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | +} |
|
17 | 19 | if (isset($globalMarine) && $globalMarine) { |
18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
20 | 22 | } |
21 | 23 | |
22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
24 | +if (!isset($globalDebug)) { |
|
25 | + $globalDebug = FALSE; |
|
26 | +} |
|
23 | 27 | |
24 | 28 | // Check if schema is at latest version |
25 | 29 | $Connection = new Connection(); |
@@ -54,35 +58,62 @@ discard block |
||
54 | 58 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 59 | if (isset($options['s'])) { |
56 | 60 | $globalSources = array(); |
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
59 | -} elseif (isset($options['source'])) { |
|
61 | + if (isset($options['format'])) { |
|
62 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + } else { |
|
64 | + $globalSources[] = array('host' => $options['s']); |
|
65 | + } |
|
66 | + } elseif (isset($options['source'])) { |
|
60 | 67 | $globalSources = array(); |
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
63 | -} |
|
68 | + if (isset($options['format'])) { |
|
69 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
70 | + } else { |
|
71 | + $globalSources[] = array('host' => $options['source']); |
|
72 | + } |
|
73 | + } |
|
64 | 74 | if (isset($options['aprsserverhost'])) { |
65 | 75 | $globalServerAPRS = TRUE; |
66 | 76 | $globalServerAPRShost = $options['aprsserverhost']; |
67 | 77 | } |
68 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
69 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
70 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
71 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
72 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
73 | -if (isset($options['server'])) $globalServer = TRUE; |
|
74 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
75 | -else $id_source = 1; |
|
78 | +if (isset($options['aprsserverport'])) { |
|
79 | + $globalServerAPRSport = $options['aprsserverport']; |
|
80 | +} |
|
81 | +if (isset($options['aprsserverssid'])) { |
|
82 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
83 | +} |
|
84 | +if (isset($options['aprsserverpass'])) { |
|
85 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
86 | +} |
|
87 | +if (isset($options['noaprsserver'])) { |
|
88 | + $globalServerAPRS = FALSE; |
|
89 | +} |
|
90 | +if (isset($options['nodaemon'])) { |
|
91 | + $globalDaemon = FALSE; |
|
92 | +} |
|
93 | +if (isset($options['server'])) { |
|
94 | + $globalServer = TRUE; |
|
95 | +} |
|
96 | +if (isset($options['idsource'])) { |
|
97 | + $id_source = $options['idsource']; |
|
98 | +} else { |
|
99 | + $id_source = 1; |
|
100 | +} |
|
76 | 101 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo "Using Server Mode\n"; |
|
104 | + } |
|
78 | 105 | $SI=new SpotterServer(); |
79 | 106 | /* |
80 | 107 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 108 | $SI = new adsb2aprs(); |
82 | 109 | $SI->connect(); |
83 | 110 | */ |
84 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
111 | +} else { |
|
112 | + $SI=new SpotterImport($Connection->db); |
|
113 | +} |
|
114 | +if (isset($globalTracker) && $globalTracker) { |
|
115 | + $TI = new TrackerImport($Connection->db); |
|
116 | +} |
|
86 | 117 | if (isset($globalMarine) && $globalMarine) { |
87 | 118 | $AIS = new AIS(); |
88 | 119 | $MI = new MarineImport($Connection->db); |
@@ -104,7 +135,9 @@ discard block |
||
104 | 135 | } |
105 | 136 | |
106 | 137 | // let's try and connect |
107 | -if ($globalDebug) echo "Connecting...\n"; |
|
138 | +if ($globalDebug) { |
|
139 | + echo "Connecting...\n"; |
|
140 | +} |
|
108 | 141 | $use_aprs = false; |
109 | 142 | $aprs_full = false; |
110 | 143 | $reset = 0; |
@@ -113,7 +146,9 @@ discard block |
||
113 | 146 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
114 | 147 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
115 | 148 | $reset++; |
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
149 | + if ($globalDebug) { |
|
150 | + echo 'Connect to all...'."\n"; |
|
151 | + } |
|
117 | 152 | foreach ($hosts as $id => $value) { |
118 | 153 | $host = $value['host']; |
119 | 154 | $globalSources[$id]['last_exec'] = 0; |
@@ -123,22 +158,30 @@ discard block |
||
123 | 158 | //$formats[$id] = 'deltadbtxt'; |
124 | 159 | $globalSources[$id]['format'] = 'deltadbtxt'; |
125 | 160 | //$last_exec['deltadbtxt'] = 0; |
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
163 | + } |
|
127 | 164 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
128 | 165 | //$formats[$id] = 'vatsimtxt'; |
129 | 166 | $globalSources[$id]['format'] = 'vatsimtxt'; |
130 | 167 | //$last_exec['vatsimtxt'] = 0; |
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
168 | + if ($globalDebug) { |
|
169 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
170 | + } |
|
132 | 171 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
133 | 172 | //$formats[$id] = 'aircraftlistjson'; |
134 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
135 | 174 | //$last_exec['aircraftlistjson'] = 0; |
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
175 | + if ($globalDebug) { |
|
176 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
177 | + } |
|
137 | 178 | } else if (preg_match('/opensky/i',$host)) { |
138 | 179 | //$formats[$id] = 'aircraftlistjson'; |
139 | 180 | $globalSources[$id]['format'] = 'opensky'; |
140 | 181 | //$last_exec['aircraftlistjson'] = 0; |
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
182 | + if ($globalDebug) { |
|
183 | + echo "Connect to opensky source (".$host.")...\n"; |
|
184 | + } |
|
142 | 185 | /* |
143 | 186 | // Disabled for now, site change source format |
144 | 187 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -155,7 +198,9 @@ discard block |
||
155 | 198 | //$formats[$id] = 'planeupdatefaa'; |
156 | 199 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
157 | 200 | //$last_exec['planeupdatefaa'] = 0; |
158 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
201 | + if ($globalDebug) { |
|
202 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | + } |
|
159 | 204 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
160 | 205 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
161 | 206 | exit(0); |
@@ -164,26 +209,36 @@ discard block |
||
164 | 209 | //$formats[$id] = 'phpvmacars'; |
165 | 210 | $globalSources[$id]['format'] = 'phpvmacars'; |
166 | 211 | //$last_exec['phpvmacars'] = 0; |
167 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | + if ($globalDebug) { |
|
213 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
214 | + } |
|
168 | 215 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
169 | 216 | //$formats[$id] = 'phpvmacars'; |
170 | 217 | $globalSources[$id]['format'] = 'vam'; |
171 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
218 | + if ($globalDebug) { |
|
219 | + echo "Connect to Vam source (".$host.")...\n"; |
|
220 | + } |
|
172 | 221 | } else if (preg_match('/whazzup/i',$host)) { |
173 | 222 | //$formats[$id] = 'whazzup'; |
174 | 223 | $globalSources[$id]['format'] = 'whazzup'; |
175 | 224 | //$last_exec['whazzup'] = 0; |
176 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
225 | + if ($globalDebug) { |
|
226 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
227 | + } |
|
177 | 228 | } else if (preg_match('/recentpireps/i',$host)) { |
178 | 229 | //$formats[$id] = 'pirepsjson'; |
179 | 230 | $globalSources[$id]['format'] = 'pirepsjson'; |
180 | 231 | //$last_exec['pirepsjson'] = 0; |
181 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
232 | + if ($globalDebug) { |
|
233 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
234 | + } |
|
182 | 235 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
183 | 236 | //$formats[$id] = 'fr24json'; |
184 | 237 | $globalSources[$id]['format'] = 'fr24json'; |
185 | 238 | //$last_exec['fr24json'] = 0; |
186 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
239 | + if ($globalDebug) { |
|
240 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
241 | + } |
|
187 | 242 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
188 | 243 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
189 | 244 | exit(0); |
@@ -192,7 +247,9 @@ discard block |
||
192 | 247 | //$formats[$id] = 'fr24json'; |
193 | 248 | $globalSources[$id]['format'] = 'myshiptracking'; |
194 | 249 | //$last_exec['fr24json'] = 0; |
195 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
250 | + if ($globalDebug) { |
|
251 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
252 | + } |
|
196 | 253 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
197 | 254 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
198 | 255 | exit(0); |
@@ -201,17 +258,24 @@ discard block |
||
201 | 258 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
202 | 259 | //$formats[$id] = 'tsv'; |
203 | 260 | $globalSources[$id]['format'] = 'tsv'; |
204 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
261 | + if ($globalDebug) { |
|
262 | + echo "Connect to tsv source (".$host.")...\n"; |
|
263 | + } |
|
205 | 264 | } |
206 | 265 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
207 | 266 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
208 | 267 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
209 | 268 | if ($idf !== false) { |
210 | 269 | $httpfeeds[$id] = $idf; |
211 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
270 | + if ($globalDebug) { |
|
271 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
272 | + } |
|
273 | + } elseif ($globalDebug) { |
|
274 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
212 | 275 | } |
213 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
214 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
276 | + } elseif ($globalDebug) { |
|
277 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
278 | + } |
|
215 | 279 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
216 | 280 | $hostport = explode(':',$host); |
217 | 281 | if (isset($hostport[1])) { |
@@ -251,17 +315,25 @@ discard block |
||
251 | 315 | //$formats[$id] = 'beast'; |
252 | 316 | $globalSources[$id]['format'] = 'beast'; |
253 | 317 | //} else $formats[$id] = 'sbs'; |
254 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
318 | + } else { |
|
319 | + $globalSources[$id]['format'] = 'sbs'; |
|
320 | + } |
|
255 | 321 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
256 | 322 | } |
257 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
323 | + if ($globalDebug) { |
|
324 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
325 | + } |
|
258 | 326 | } else { |
259 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
327 | + if ($globalDebug) { |
|
328 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
329 | + } |
|
260 | 330 | } |
261 | 331 | } |
262 | 332 | } |
263 | 333 | } |
264 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
334 | +if (!isset($globalMinFetch)) { |
|
335 | + $globalMinFetch = 15; |
|
336 | +} |
|
265 | 337 | |
266 | 338 | // Initialize all |
267 | 339 | $status = array(); |
@@ -270,13 +342,19 @@ discard block |
||
270 | 342 | $formats = array(); |
271 | 343 | $last_exec = array(); |
272 | 344 | $time = time(); |
273 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
274 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
275 | -else $timeout = 20; |
|
345 | +if (isset($globalSourcesTimeout)) { |
|
346 | + $timeout = $globalSourcesTimeOut; |
|
347 | +} else if (isset($globalSBS1TimeOut)) { |
|
348 | + $timeout = $globalSBS1TimeOut; |
|
349 | +} else { |
|
350 | + $timeout = 20; |
|
351 | +} |
|
276 | 352 | $errno = ''; |
277 | 353 | $errstr=''; |
278 | 354 | |
279 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
355 | +if (!isset($globalDaemon)) { |
|
356 | + $globalDaemon = TRUE; |
|
357 | +} |
|
280 | 358 | /* Initiate connections to all the hosts simultaneously */ |
281 | 359 | //connect_all($hosts); |
282 | 360 | //connect_all($globalSources); |
@@ -302,7 +380,9 @@ discard block |
||
302 | 380 | if (isset($source['format']) && $source['format'] == 'aprs') { |
303 | 381 | $aprs_connect = 0; |
304 | 382 | $use_aprs = true; |
305 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
383 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
384 | + $aprs_full = true; |
|
385 | + } |
|
306 | 386 | break; |
307 | 387 | } |
308 | 388 | } |
@@ -313,25 +393,48 @@ discard block |
||
313 | 393 | $aprs_connect = 0; |
314 | 394 | $aprs_keep = 120; |
315 | 395 | $aprs_last_tx = time(); |
316 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
317 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
318 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
319 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
320 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
321 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
322 | - if ($aprs_full) $aprs_filter = ''; |
|
323 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
324 | - else $aprs_pass = '-1'; |
|
396 | + if (isset($globalAPRSversion)) { |
|
397 | + $aprs_version = $globalAPRSversion; |
|
398 | + } else { |
|
399 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
400 | + } |
|
401 | + if (isset($globalAPRSssid)) { |
|
402 | + $aprs_ssid = $globalAPRSssid; |
|
403 | + } else { |
|
404 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
405 | + } |
|
406 | + if (isset($globalAPRSfilter)) { |
|
407 | + $aprs_filter = $globalAPRSfilter; |
|
408 | + } else { |
|
409 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
410 | + } |
|
411 | + if ($aprs_full) { |
|
412 | + $aprs_filter = ''; |
|
413 | + } |
|
414 | + if (isset($globalAPRSpass)) { |
|
415 | + $aprs_pass = $globalAPRSpass; |
|
416 | + } else { |
|
417 | + $aprs_pass = '-1'; |
|
418 | + } |
|
325 | 419 | |
326 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
327 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
328 | -} |
|
420 | + if ($aprs_filter != '') { |
|
421 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
422 | + } else { |
|
423 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
424 | + } |
|
425 | + } |
|
329 | 426 | |
330 | 427 | // connected - lets do some work |
331 | -if ($globalDebug) echo "Connected!\n"; |
|
428 | +if ($globalDebug) { |
|
429 | + echo "Connected!\n"; |
|
430 | +} |
|
332 | 431 | sleep(1); |
333 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
334 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
432 | +if ($globalDebug) { |
|
433 | + echo "SCAN MODE \n\n"; |
|
434 | +} |
|
435 | +if (!isset($globalCronEnd)) { |
|
436 | + $globalCronEnd = 60; |
|
437 | +} |
|
335 | 438 | $endtime = time()+$globalCronEnd; |
336 | 439 | $i = 1; |
337 | 440 | $tt = array(); |
@@ -345,10 +448,14 @@ discard block |
||
345 | 448 | |
346 | 449 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
347 | 450 | while ($i > 0) { |
348 | - if (!$globalDaemon) $i = $endtime-time(); |
|
451 | + if (!$globalDaemon) { |
|
452 | + $i = $endtime-time(); |
|
453 | + } |
|
349 | 454 | // Delete old ATC |
350 | 455 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
351 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
456 | + if ($globalDebug) { |
|
457 | + echo 'Delete old ATC...'."\n"; |
|
458 | + } |
|
352 | 459 | $ATC->deleteOldATC(); |
353 | 460 | } |
354 | 461 | |
@@ -356,10 +463,14 @@ discard block |
||
356 | 463 | if (count($last_exec) == count($globalSources)) { |
357 | 464 | $max = $globalMinFetch; |
358 | 465 | foreach ($last_exec as $last) { |
359 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
466 | + if ((time() - $last['last']) < $max) { |
|
467 | + $max = time() - $last['last']; |
|
468 | + } |
|
360 | 469 | } |
361 | 470 | if ($max != $globalMinFetch) { |
362 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
471 | + if ($globalDebug) { |
|
472 | + echo 'Sleeping...'."\n"; |
|
473 | + } |
|
363 | 474 | sleep($globalMinFetch-$max+2); |
364 | 475 | } |
365 | 476 | } |
@@ -368,11 +479,15 @@ discard block |
||
368 | 479 | //foreach ($formats as $id => $value) { |
369 | 480 | foreach ($globalSources as $id => $value) { |
370 | 481 | date_default_timezone_set('UTC'); |
371 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
482 | + if (!isset($last_exec[$id]['last'])) { |
|
483 | + $last_exec[$id]['last'] = 0; |
|
484 | + } |
|
372 | 485 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
373 | 486 | //$buffer = $Common->getData($hosts[$id]); |
374 | 487 | $buffer = $Common->getData($value['host']); |
375 | - if ($buffer != '') $reset = 0; |
|
488 | + if ($buffer != '') { |
|
489 | + $reset = 0; |
|
490 | + } |
|
376 | 491 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
377 | 492 | $buffer = explode('\n',$buffer); |
378 | 493 | foreach ($buffer as $line) { |
@@ -381,20 +496,41 @@ discard block |
||
381 | 496 | $data = array(); |
382 | 497 | $data['hex'] = $line[1]; // hex |
383 | 498 | $data['ident'] = $line[2]; // ident |
384 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
385 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
386 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
387 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
388 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
499 | + if (isset($line[3])) { |
|
500 | + $data['altitude'] = $line[3]; |
|
501 | + } |
|
502 | + // altitude |
|
503 | + if (isset($line[4])) { |
|
504 | + $data['speed'] = $line[4]; |
|
505 | + } |
|
506 | + // speed |
|
507 | + if (isset($line[5])) { |
|
508 | + $data['heading'] = $line[5]; |
|
509 | + } |
|
510 | + // heading |
|
511 | + if (isset($line[6])) { |
|
512 | + $data['latitude'] = $line[6]; |
|
513 | + } |
|
514 | + // lat |
|
515 | + if (isset($line[7])) { |
|
516 | + $data['longitude'] = $line[7]; |
|
517 | + } |
|
518 | + // long |
|
389 | 519 | $data['verticalrate'] = ''; // vertical rate |
390 | 520 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
391 | 521 | $data['emergency'] = ''; // emergency |
392 | 522 | $data['datetime'] = date('Y-m-d H:i:s'); |
393 | 523 | $data['format_source'] = 'deltadbtxt'; |
394 | 524 | $data['id_source'] = $id_source; |
395 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
396 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
397 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
525 | + if (isset($value['name']) && $value['name'] != '') { |
|
526 | + $data['source_name'] = $value['name']; |
|
527 | + } |
|
528 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
529 | + $data['noarchive'] = true; |
|
530 | + } |
|
531 | + if (isset($value['sourcestats'])) { |
|
532 | + $data['sourcestats'] = $value['sourcestats']; |
|
533 | + } |
|
398 | 534 | $SI->add($data); |
399 | 535 | unset($data); |
400 | 536 | } |
@@ -404,7 +540,9 @@ discard block |
||
404 | 540 | date_default_timezone_set('CET'); |
405 | 541 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
406 | 542 | date_default_timezone_set('UTC'); |
407 | - if ($buffer != '') $reset = 0; |
|
543 | + if ($buffer != '') { |
|
544 | + $reset = 0; |
|
545 | + } |
|
408 | 546 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
409 | 547 | $buffer = explode('\n',$buffer); |
410 | 548 | foreach ($buffer as $line) { |
@@ -413,16 +551,36 @@ discard block |
||
413 | 551 | $add = false; |
414 | 552 | $ais_data = $AIS->parse_line(trim($line)); |
415 | 553 | $data = array(); |
416 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
417 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
418 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
419 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
420 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
421 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
422 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
423 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
424 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
425 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
554 | + if (isset($ais_data['ident'])) { |
|
555 | + $data['ident'] = $ais_data['ident']; |
|
556 | + } |
|
557 | + if (isset($ais_data['mmsi'])) { |
|
558 | + $data['mmsi'] = $ais_data['mmsi']; |
|
559 | + } |
|
560 | + if (isset($ais_data['speed'])) { |
|
561 | + $data['speed'] = $ais_data['speed']; |
|
562 | + } |
|
563 | + if (isset($ais_data['heading'])) { |
|
564 | + $data['heading'] = $ais_data['heading']; |
|
565 | + } |
|
566 | + if (isset($ais_data['latitude'])) { |
|
567 | + $data['latitude'] = $ais_data['latitude']; |
|
568 | + } |
|
569 | + if (isset($ais_data['longitude'])) { |
|
570 | + $data['longitude'] = $ais_data['longitude']; |
|
571 | + } |
|
572 | + if (isset($ais_data['status'])) { |
|
573 | + $data['status'] = $ais_data['status']; |
|
574 | + } |
|
575 | + if (isset($ais_data['type'])) { |
|
576 | + $data['type'] = $ais_data['type']; |
|
577 | + } |
|
578 | + if (isset($ais_data['imo'])) { |
|
579 | + $data['imo'] = $ais_data['imo']; |
|
580 | + } |
|
581 | + if (isset($ais_data['callsign'])) { |
|
582 | + $data['callsign'] = $ais_data['callsign']; |
|
583 | + } |
|
426 | 584 | if (isset($ais_data['timestamp'])) { |
427 | 585 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
428 | 586 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -436,8 +594,12 @@ discard block |
||
436 | 594 | $data['format_source'] = 'aisnmeatxt'; |
437 | 595 | $data['id_source'] = $id_source; |
438 | 596 | //print_r($data); |
439 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
440 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
597 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
598 | + $data['noarchive'] = true; |
|
599 | + } |
|
600 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
601 | + $MI->add($data); |
|
602 | + } |
|
441 | 603 | unset($data); |
442 | 604 | } |
443 | 605 | } |
@@ -457,20 +619,48 @@ discard block |
||
457 | 619 | if ($line != '') { |
458 | 620 | $ais_data = $AIS->parse_line(trim($line)); |
459 | 621 | $data = array(); |
460 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
461 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
462 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
463 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
464 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
465 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
466 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
467 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
468 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
469 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
470 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
471 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
472 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
473 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
622 | + if (isset($ais_data['ident'])) { |
|
623 | + $data['ident'] = $ais_data['ident']; |
|
624 | + } |
|
625 | + if (isset($ais_data['mmsi'])) { |
|
626 | + $data['mmsi'] = $ais_data['mmsi']; |
|
627 | + } |
|
628 | + if (isset($ais_data['speed'])) { |
|
629 | + $data['speed'] = $ais_data['speed']; |
|
630 | + } |
|
631 | + if (isset($ais_data['heading'])) { |
|
632 | + $data['heading'] = $ais_data['heading']; |
|
633 | + } |
|
634 | + if (isset($ais_data['latitude'])) { |
|
635 | + $data['latitude'] = $ais_data['latitude']; |
|
636 | + } |
|
637 | + if (isset($ais_data['longitude'])) { |
|
638 | + $data['longitude'] = $ais_data['longitude']; |
|
639 | + } |
|
640 | + if (isset($ais_data['status'])) { |
|
641 | + $data['status'] = $ais_data['status']; |
|
642 | + } |
|
643 | + if (isset($ais_data['statusid'])) { |
|
644 | + $data['status_id'] = $ais_data['statusid']; |
|
645 | + } |
|
646 | + if (isset($ais_data['type'])) { |
|
647 | + $data['type'] = $ais_data['type']; |
|
648 | + } |
|
649 | + if (isset($ais_data['typeid'])) { |
|
650 | + $data['type_id'] = $ais_data['typeid']; |
|
651 | + } |
|
652 | + if (isset($ais_data['imo'])) { |
|
653 | + $data['imo'] = $ais_data['imo']; |
|
654 | + } |
|
655 | + if (isset($ais_data['callsign'])) { |
|
656 | + $data['callsign'] = $ais_data['callsign']; |
|
657 | + } |
|
658 | + if (isset($ais_data['destination'])) { |
|
659 | + $data['arrival_code'] = $ais_data['destination']; |
|
660 | + } |
|
661 | + if (isset($ais_data['eta_ts'])) { |
|
662 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
663 | + } |
|
474 | 664 | if (isset($ais_data['timestamp'])) { |
475 | 665 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
476 | 666 | } else { |
@@ -478,18 +668,27 @@ discard block |
||
478 | 668 | } |
479 | 669 | $data['format_source'] = 'aisnmeahttp'; |
480 | 670 | $data['id_source'] = $id_source; |
481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
482 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
671 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
672 | + $data['noarchive'] = true; |
|
673 | + } |
|
674 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
675 | + $MI->add($data); |
|
676 | + } |
|
483 | 677 | unset($data); |
484 | 678 | } |
485 | 679 | } |
486 | 680 | } |
487 | 681 | } else { |
488 | 682 | $format = $value['format']; |
489 | - if (isset($tt[$format])) $tt[$format]++; |
|
490 | - else $tt[$format] = 0; |
|
683 | + if (isset($tt[$format])) { |
|
684 | + $tt[$format]++; |
|
685 | + } else { |
|
686 | + $tt[$format] = 0; |
|
687 | + } |
|
491 | 688 | if ($tt[$format] > 30) { |
492 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
689 | + if ($globalDebug) { |
|
690 | + echo 'Reconnect...'."\n"; |
|
691 | + } |
|
493 | 692 | sleep(2); |
494 | 693 | $sourceeen[] = $value; |
495 | 694 | connect_all($sourceeen); |
@@ -519,7 +718,9 @@ discard block |
||
519 | 718 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
520 | 719 | $data['format_source'] = 'myshiptracking'; |
521 | 720 | $data['id_source'] = $id_source; |
522 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
722 | + $data['noarchive'] = true; |
|
723 | + } |
|
523 | 724 | $MI->add($data); |
524 | 725 | unset($data); |
525 | 726 | } |
@@ -539,7 +740,9 @@ discard block |
||
539 | 740 | $data['callsign'] = $line['callsign']; |
540 | 741 | $data['mmsi'] = $line['mmsi']; |
541 | 742 | $data['speed'] = $line['sog']; |
542 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
743 | + if ($line['heading'] != '511') { |
|
744 | + $data['heading'] = $line['heading']; |
|
745 | + } |
|
543 | 746 | $data['latitude'] = $line['latitude']; |
544 | 747 | $data['longitude'] = $line['longitude']; |
545 | 748 | $data['type_id'] = $line['shiptype']; |
@@ -547,7 +750,9 @@ discard block |
||
547 | 750 | $data['datetime'] = $line['time']; |
548 | 751 | $data['format_source'] = 'boatbeaconapp'; |
549 | 752 | $data['id_source'] = $id_source; |
550 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
753 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
754 | + $data['noarchive'] = true; |
|
755 | + } |
|
551 | 756 | $MI->add($data); |
552 | 757 | unset($data); |
553 | 758 | } |
@@ -563,22 +768,44 @@ discard block |
||
563 | 768 | if (isset($all_data['features'][0]['id'])) { |
564 | 769 | foreach ($all_data['features'] as $line) { |
565 | 770 | $data = array(); |
566 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
567 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
568 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
569 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
570 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
571 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
771 | + if (isset($line['properties']['name'])) { |
|
772 | + $data['ident'] = $line['properties']['name']; |
|
773 | + } |
|
774 | + if (isset($line['properties']['callsign'])) { |
|
775 | + $data['callsign'] = $line['properties']['callsign']; |
|
776 | + } |
|
777 | + if (isset($line['properties']['mmsi'])) { |
|
778 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
779 | + } |
|
780 | + if (isset($line['properties']['imo'])) { |
|
781 | + $data['mmsi'] = $line['properties']['imo']; |
|
782 | + } |
|
783 | + if (isset($line['properties']['speed'])) { |
|
784 | + $data['speed'] = $line['properties']['speed']; |
|
785 | + } |
|
786 | + if (isset($line['properties']['heading'])) { |
|
787 | + $data['heading'] = $line['properties']['heading']; |
|
788 | + } |
|
572 | 789 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
573 | 790 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
574 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
575 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
576 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
791 | + if (isset($line['properties']['vesselType'])) { |
|
792 | + $data['type'] = $line['properties']['vesselType']; |
|
793 | + } |
|
794 | + if (isset($line['properties']['destination'])) { |
|
795 | + $data['arrival_code'] = $line['properties']['destination']; |
|
796 | + } |
|
797 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
798 | + $data['arrival_date'] = $line['properties']['eta']; |
|
799 | + } |
|
577 | 800 | $data['format_source'] = 'boatnerd'; |
578 | 801 | $data['id_source'] = $id_source; |
579 | 802 | $data['datetime'] = date('Y-m-d H:i:s'); |
580 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
581 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
803 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
804 | + $data['noarchive'] = true; |
|
805 | + } |
|
806 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
807 | + $MI->add($data); |
|
808 | + } |
|
582 | 809 | unset($data); |
583 | 810 | } |
584 | 811 | } |
@@ -589,7 +816,9 @@ discard block |
||
589 | 816 | echo 'download...'; |
590 | 817 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
591 | 818 | echo 'done !'."\n"; |
592 | - if ($buffer != '') $reset = 0; |
|
819 | + if ($buffer != '') { |
|
820 | + $reset = 0; |
|
821 | + } |
|
593 | 822 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
594 | 823 | $buffer = explode('\n',$buffer); |
595 | 824 | foreach ($buffer as $line) { |
@@ -614,7 +843,9 @@ discard block |
||
614 | 843 | //$data['etaTime'] = substr($line,135,5); |
615 | 844 | $data['format_source'] = 'shipplotter'; |
616 | 845 | $data['id_source'] = $id_source; |
617 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
846 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
847 | + $data['noarchive'] = true; |
|
848 | + } |
|
618 | 849 | //print_r($data); |
619 | 850 | echo 'Add...'."\n"; |
620 | 851 | $MI->add($data); |
@@ -634,16 +865,28 @@ discard block |
||
634 | 865 | $line = explode(':', $line); |
635 | 866 | if (count($line) > 30 && $line[0] != 'callsign') { |
636 | 867 | $data = array(); |
637 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
638 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
868 | + if (isset($line[37]) && $line[37] != '') { |
|
869 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
870 | + } else { |
|
871 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
872 | + } |
|
639 | 873 | $data['pilot_id'] = $line[1]; |
640 | 874 | $data['pilot_name'] = $line[2]; |
641 | 875 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
642 | 876 | $data['ident'] = $line[0]; // ident |
643 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
877 | + if ($line[7] != '' && $line[7] != 0) { |
|
878 | + $data['altitude'] = $line[7]; |
|
879 | + } |
|
880 | + // altitude |
|
644 | 881 | $data['speed'] = $line[8]; // speed |
645 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
646 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
882 | + if (isset($line[45])) { |
|
883 | + $data['heading'] = $line[45]; |
|
884 | + } |
|
885 | + // heading |
|
886 | + elseif (isset($line[38])) { |
|
887 | + $data['heading'] = $line[38]; |
|
888 | + } |
|
889 | + // heading |
|
647 | 890 | $data['latitude'] = $line[5]; // lat |
648 | 891 | $data['longitude'] = $line[6]; // long |
649 | 892 | $data['verticalrate'] = ''; // vertical rate |
@@ -659,7 +902,9 @@ discard block |
||
659 | 902 | $data['frequency'] = $line[4]; |
660 | 903 | $data['type'] = $line[18]; |
661 | 904 | $data['range'] = $line[19]; |
662 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
905 | + if (isset($line[35])) { |
|
906 | + $data['info'] = $line[35]; |
|
907 | + } |
|
663 | 908 | $data['id_source'] = $id_source; |
664 | 909 | //$data['arrival_airport_time'] = ; |
665 | 910 | if ($line[9] != '') { |
@@ -673,27 +918,47 @@ discard block |
||
673 | 918 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
674 | 919 | */ |
675 | 920 | $data['format_source'] = $value['format']; |
676 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
677 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
678 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
679 | - elseif ($line[3] == 'ATC') { |
|
921 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
922 | + $data['noarchive'] = true; |
|
923 | + } |
|
924 | + if (isset($value['name']) && $value['name'] != '') { |
|
925 | + $data['source_name'] = $value['name']; |
|
926 | + } |
|
927 | + if ($line[3] == 'PILOT') { |
|
928 | + $SI->add($data); |
|
929 | + } elseif ($line[3] == 'ATC') { |
|
680 | 930 | //print_r($data); |
681 | 931 | $data['info'] = str_replace('^§','<br />',$data['info']); |
682 | 932 | $data['info'] = str_replace('&sect;','',$data['info']); |
683 | 933 | $typec = substr($data['ident'],-3); |
684 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
685 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
686 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
687 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
688 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
689 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
690 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
691 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
692 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
693 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
934 | + if ($typec == 'APP') { |
|
935 | + $data['type'] = 'Approach'; |
|
936 | + } elseif ($typec == 'TWR') { |
|
937 | + $data['type'] = 'Tower'; |
|
938 | + } elseif ($typec == 'OBS') { |
|
939 | + $data['type'] = 'Observer'; |
|
940 | + } elseif ($typec == 'GND') { |
|
941 | + $data['type'] = 'Ground'; |
|
942 | + } elseif ($typec == 'DEL') { |
|
943 | + $data['type'] = 'Delivery'; |
|
944 | + } elseif ($typec == 'DEP') { |
|
945 | + $data['type'] = 'Departure'; |
|
946 | + } elseif ($typec == 'FSS') { |
|
947 | + $data['type'] = 'Flight Service Station'; |
|
948 | + } elseif ($typec == 'CTR') { |
|
949 | + $data['type'] = 'Control Radar or Centre'; |
|
950 | + } elseif ($data['type'] == '') { |
|
951 | + $data['type'] = 'Observer'; |
|
952 | + } |
|
953 | + if (!isset($data['source_name'])) { |
|
954 | + $data['source_name'] = ''; |
|
955 | + } |
|
694 | 956 | if (isset($ATC)) { |
695 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
696 | - else 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'],$data['format_source'],$data['source_name']); |
|
957 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
958 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
959 | + } else { |
|
960 | + 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'],$data['format_source'],$data['source_name']); |
|
961 | + } |
|
697 | 962 | } |
698 | 963 | } |
699 | 964 | unset($data); |
@@ -713,27 +978,61 @@ discard block |
||
713 | 978 | foreach ($all_data['acList'] as $line) { |
714 | 979 | $data = array(); |
715 | 980 | $data['hex'] = $line['Icao']; // hex |
716 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
717 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
718 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
719 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
720 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
721 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
981 | + if (isset($line['Call'])) { |
|
982 | + $data['ident'] = $line['Call']; |
|
983 | + } |
|
984 | + // ident |
|
985 | + if (isset($line['Alt'])) { |
|
986 | + $data['altitude'] = $line['Alt']; |
|
987 | + } |
|
988 | + // altitude |
|
989 | + if (isset($line['Spd'])) { |
|
990 | + $data['speed'] = $line['Spd']; |
|
991 | + } |
|
992 | + // speed |
|
993 | + if (isset($line['Trak'])) { |
|
994 | + $data['heading'] = $line['Trak']; |
|
995 | + } |
|
996 | + // heading |
|
997 | + if (isset($line['Lat'])) { |
|
998 | + $data['latitude'] = $line['Lat']; |
|
999 | + } |
|
1000 | + // lat |
|
1001 | + if (isset($line['Long'])) { |
|
1002 | + $data['longitude'] = $line['Long']; |
|
1003 | + } |
|
1004 | + // long |
|
722 | 1005 | //$data['verticalrate'] = $line['']; // verticale rate |
723 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1006 | + if (isset($line['Sqk'])) { |
|
1007 | + $data['squawk'] = $line['Sqk']; |
|
1008 | + } |
|
1009 | + // squawk |
|
724 | 1010 | $data['emergency'] = ''; // emergency |
725 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1011 | + if (isset($line['Reg'])) { |
|
1012 | + $data['registration'] = $line['Reg']; |
|
1013 | + } |
|
726 | 1014 | |
727 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
728 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1015 | + if (isset($line['PosTime'])) { |
|
1016 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1017 | + } else { |
|
1018 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1019 | + } |
|
729 | 1020 | |
730 | 1021 | //$data['datetime'] = date('Y-m-d H:i:s'); |
731 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1022 | + if (isset($line['Type'])) { |
|
1023 | + $data['aircraft_icao'] = $line['Type']; |
|
1024 | + } |
|
732 | 1025 | $data['format_source'] = 'aircraftlistjson'; |
733 | 1026 | $data['id_source'] = $id_source; |
734 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
735 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
736 | - if (isset($data['latitude'])) $SI->add($data); |
|
1027 | + if (isset($value['name']) && $value['name'] != '') { |
|
1028 | + $data['source_name'] = $value['name']; |
|
1029 | + } |
|
1030 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1031 | + $data['noarchive'] = true; |
|
1032 | + } |
|
1033 | + if (isset($data['latitude'])) { |
|
1034 | + $SI->add($data); |
|
1035 | + } |
|
737 | 1036 | unset($data); |
738 | 1037 | } |
739 | 1038 | } elseif (is_array($all_data)) { |
@@ -750,12 +1049,19 @@ discard block |
||
750 | 1049 | $data['verticalrate'] = $line['vrt']; // verticale rate |
751 | 1050 | $data['squawk'] = $line['squawk']; // squawk |
752 | 1051 | $data['emergency'] = ''; // emergency |
753 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
754 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1052 | + if (isset($line['PosTime'])) { |
|
1053 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1054 | + } else { |
|
1055 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1056 | + } |
|
755 | 1057 | $data['format_source'] = 'aircraftlistjson'; |
756 | 1058 | $data['id_source'] = $id_source; |
757 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1059 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1060 | + $data['noarchive'] = true; |
|
1061 | + } |
|
1062 | + if (isset($value['name']) && $value['name'] != '') { |
|
1063 | + $data['source_name'] = $value['name']; |
|
1064 | + } |
|
759 | 1065 | $SI->add($data); |
760 | 1066 | unset($data); |
761 | 1067 | } |
@@ -791,8 +1097,12 @@ discard block |
||
791 | 1097 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
792 | 1098 | $data['format_source'] = 'planeupdatefaa'; |
793 | 1099 | $data['id_source'] = $id_source; |
794 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
795 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1100 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1101 | + $data['noarchive'] = true; |
|
1102 | + } |
|
1103 | + if (isset($value['name']) && $value['name'] != '') { |
|
1104 | + $data['source_name'] = $value['name']; |
|
1105 | + } |
|
796 | 1106 | $SI->add($data); |
797 | 1107 | unset($data); |
798 | 1108 | } |
@@ -821,7 +1131,9 @@ discard block |
||
821 | 1131 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
822 | 1132 | $data['format_source'] = 'opensky'; |
823 | 1133 | $data['id_source'] = $id_source; |
824 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1134 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1135 | + $data['noarchive'] = true; |
|
1136 | + } |
|
825 | 1137 | $SI->add($data); |
826 | 1138 | unset($data); |
827 | 1139 | } |
@@ -833,7 +1145,9 @@ discard block |
||
833 | 1145 | //$buffer = $Common->getData($hosts[$id]); |
834 | 1146 | $buffer = $Common->getData($value['host']); |
835 | 1147 | $all_data = json_decode($buffer,true); |
836 | - if (!empty($all_data)) $reset = 0; |
|
1148 | + if (!empty($all_data)) { |
|
1149 | + $reset = 0; |
|
1150 | + } |
|
837 | 1151 | foreach ($all_data as $key => $line) { |
838 | 1152 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
839 | 1153 | $data = array(); |
@@ -854,8 +1168,12 @@ discard block |
||
854 | 1168 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
855 | 1169 | $data['format_source'] = 'fr24json'; |
856 | 1170 | $data['id_source'] = $id_source; |
857 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
858 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1171 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1172 | + $data['noarchive'] = true; |
|
1173 | + } |
|
1174 | + if (isset($value['name']) && $value['name'] != '') { |
|
1175 | + $data['source_name'] = $value['name']; |
|
1176 | + } |
|
859 | 1177 | $SI->add($data); |
860 | 1178 | unset($data); |
861 | 1179 | } |
@@ -879,24 +1197,42 @@ discard block |
||
879 | 1197 | if (isset($line['inf'])) { |
880 | 1198 | $data = array(); |
881 | 1199 | $data['hex'] = $line['inf']['ia']; |
882 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1200 | + if (isset($line['inf']['cs'])) { |
|
1201 | + $data['ident'] = $line['inf']['cs']; |
|
1202 | + } |
|
1203 | + //$line[13] |
|
883 | 1204 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
884 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
885 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1205 | + if (isset($line['inf']['gs'])) { |
|
1206 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1207 | + } |
|
1208 | + // speed |
|
1209 | + if (isset($line['inf']['tr'])) { |
|
1210 | + $data['heading'] = $line['inf']['tr']; |
|
1211 | + } |
|
1212 | + // heading |
|
886 | 1213 | $data['latitude'] = $line['pt'][0]; // lat |
887 | 1214 | $data['longitude'] = $line['pt'][1]; // long |
888 | 1215 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
889 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1216 | + if (isset($line['inf']['sq'])) { |
|
1217 | + $data['squawk'] = $line['inf']['sq']; |
|
1218 | + } |
|
1219 | + // squawk |
|
890 | 1220 | //$data['aircraft_icao'] = $line[8]; |
891 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1221 | + if (isset($line['inf']['rc'])) { |
|
1222 | + $data['registration'] = $line['inf']['rc']; |
|
1223 | + } |
|
892 | 1224 | //$data['departure_airport_iata'] = $line[11]; |
893 | 1225 | //$data['arrival_airport_iata'] = $line[12]; |
894 | 1226 | //$data['emergency'] = ''; // emergency |
895 | 1227 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
896 | 1228 | $data['format_source'] = 'radarvirtueljson'; |
897 | 1229 | $data['id_source'] = $id_source; |
898 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
899 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1230 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1231 | + $data['noarchive'] = true; |
|
1232 | + } |
|
1233 | + if (isset($value['name']) && $value['name'] != '') { |
|
1234 | + $data['source_name'] = $value['name']; |
|
1235 | + } |
|
900 | 1236 | $SI->add($data); |
901 | 1237 | unset($data); |
902 | 1238 | } |
@@ -917,30 +1253,65 @@ discard block |
||
917 | 1253 | $data['id'] = $line['id']; |
918 | 1254 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
919 | 1255 | $data['ident'] = $line['callsign']; // ident |
920 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
921 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
922 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
923 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
924 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
925 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1256 | + if (isset($line['pilotid'])) { |
|
1257 | + $data['pilot_id'] = $line['pilotid']; |
|
1258 | + } |
|
1259 | + // pilot id |
|
1260 | + if (isset($line['name'])) { |
|
1261 | + $data['pilot_name'] = $line['name']; |
|
1262 | + } |
|
1263 | + // pilot name |
|
1264 | + if (isset($line['alt'])) { |
|
1265 | + $data['altitude'] = $line['alt']; |
|
1266 | + } |
|
1267 | + // altitude |
|
1268 | + if (isset($line['gs'])) { |
|
1269 | + $data['speed'] = $line['gs']; |
|
1270 | + } |
|
1271 | + // speed |
|
1272 | + if (isset($line['heading'])) { |
|
1273 | + $data['heading'] = $line['heading']; |
|
1274 | + } |
|
1275 | + // heading |
|
1276 | + if (isset($line['route'])) { |
|
1277 | + $data['waypoints'] = $line['route']; |
|
1278 | + } |
|
1279 | + // route |
|
926 | 1280 | $data['latitude'] = $line['lat']; // lat |
927 | 1281 | $data['longitude'] = $line['lon']; // long |
928 | 1282 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
929 | 1283 | //$data['squawk'] = $line['squawk']; // squawk |
930 | 1284 | //$data['emergency'] = ''; // emergency |
931 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
932 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
933 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1285 | + if (isset($line['depicao'])) { |
|
1286 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1287 | + } |
|
1288 | + if (isset($line['deptime'])) { |
|
1289 | + $data['departure_airport_time'] = $line['deptime']; |
|
1290 | + } |
|
1291 | + if (isset($line['arricao'])) { |
|
1292 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1293 | + } |
|
934 | 1294 | //$data['arrival_airport_time'] = $line['arrtime']; |
935 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
936 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
937 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
938 | - else $data['info'] = ''; |
|
1295 | + if (isset($line['aircraft'])) { |
|
1296 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1297 | + } |
|
1298 | + if (isset($line['transponder'])) { |
|
1299 | + $data['squawk'] = $line['transponder']; |
|
1300 | + } |
|
1301 | + if (isset($line['atis'])) { |
|
1302 | + $data['info'] = $line['atis']; |
|
1303 | + } else { |
|
1304 | + $data['info'] = ''; |
|
1305 | + } |
|
939 | 1306 | $data['format_source'] = 'pireps'; |
940 | 1307 | $data['id_source'] = $id_source; |
941 | 1308 | $data['datetime'] = date('Y-m-d H:i:s'); |
942 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
943 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1309 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1310 | + $data['noarchive'] = true; |
|
1311 | + } |
|
1312 | + if (isset($value['name']) && $value['name'] != '') { |
|
1313 | + $data['source_name'] = $value['name']; |
|
1314 | + } |
|
944 | 1315 | if ($line['icon'] == 'plane') { |
945 | 1316 | $SI->add($data); |
946 | 1317 | // print_r($data); |
@@ -949,16 +1320,28 @@ discard block |
||
949 | 1320 | $data['info'] = str_replace('&sect;','',$data['info']); |
950 | 1321 | $typec = substr($data['ident'],-3); |
951 | 1322 | $data['type'] = ''; |
952 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
953 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
954 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
955 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
956 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
957 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
958 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
959 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
960 | - else $data['type'] = 'Observer'; |
|
961 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1323 | + if ($typec == 'APP') { |
|
1324 | + $data['type'] = 'Approach'; |
|
1325 | + } elseif ($typec == 'TWR') { |
|
1326 | + $data['type'] = 'Tower'; |
|
1327 | + } elseif ($typec == 'OBS') { |
|
1328 | + $data['type'] = 'Observer'; |
|
1329 | + } elseif ($typec == 'GND') { |
|
1330 | + $data['type'] = 'Ground'; |
|
1331 | + } elseif ($typec == 'DEL') { |
|
1332 | + $data['type'] = 'Delivery'; |
|
1333 | + } elseif ($typec == 'DEP') { |
|
1334 | + $data['type'] = 'Departure'; |
|
1335 | + } elseif ($typec == 'FSS') { |
|
1336 | + $data['type'] = 'Flight Service Station'; |
|
1337 | + } elseif ($typec == 'CTR') { |
|
1338 | + $data['type'] = 'Control Radar or Centre'; |
|
1339 | + } else { |
|
1340 | + $data['type'] = 'Observer'; |
|
1341 | + } |
|
1342 | + if (isset($ATC)) { |
|
1343 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1344 | + } |
|
962 | 1345 | } |
963 | 1346 | unset($data); |
964 | 1347 | } |
@@ -968,7 +1351,9 @@ discard block |
||
968 | 1351 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
969 | 1352 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
970 | 1353 | //$buffer = $Common->getData($hosts[$id]); |
971 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1354 | + if ($globalDebug) { |
|
1355 | + echo 'Get Data...'."\n"; |
|
1356 | + } |
|
972 | 1357 | $buffer = $Common->getData($value['host']); |
973 | 1358 | $all_data = json_decode($buffer,true); |
974 | 1359 | if ($buffer != '' && is_array($all_data)) { |
@@ -976,10 +1361,16 @@ discard block |
||
976 | 1361 | foreach ($all_data as $line) { |
977 | 1362 | $data = array(); |
978 | 1363 | //$data['id'] = $line['id']; // id not usable |
979 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1364 | + if (isset($line['pilotid'])) { |
|
1365 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1366 | + } |
|
980 | 1367 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
981 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
982 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1368 | + if (isset($line['pilotname'])) { |
|
1369 | + $data['pilot_name'] = $line['pilotname']; |
|
1370 | + } |
|
1371 | + if (isset($line['pilotid'])) { |
|
1372 | + $data['pilot_id'] = $line['pilotid']; |
|
1373 | + } |
|
983 | 1374 | $data['ident'] = $line['flightnum']; // ident |
984 | 1375 | $data['altitude'] = $line['alt']; // altitude |
985 | 1376 | $data['speed'] = $line['gs']; // speed |
@@ -997,28 +1388,44 @@ discard block |
||
997 | 1388 | $data['arrival_airport_icao'] = $line['arricao']; |
998 | 1389 | $data['arrival_airport_time'] = $line['arrtime']; |
999 | 1390 | $data['registration'] = $line['aircraft']; |
1000 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1001 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1391 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1392 | + $data['noarchive'] = true; |
|
1393 | + } |
|
1394 | + if (isset($line['route'])) { |
|
1395 | + $data['waypoints'] = $line['route']; |
|
1396 | + } |
|
1397 | + // route |
|
1002 | 1398 | if (isset($line['aircraftname'])) { |
1003 | 1399 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1004 | 1400 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1005 | 1401 | $aircraft_data = explode('-',$line['aircraftname']); |
1006 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1007 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1008 | - else { |
|
1402 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1403 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1404 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1405 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1406 | + } else { |
|
1009 | 1407 | $aircraft_data = explode(' ',$line['aircraftname']); |
1010 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1011 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1408 | + if (isset($aircraft_data[1])) { |
|
1409 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1410 | + } else { |
|
1411 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1412 | + } |
|
1012 | 1413 | } |
1013 | 1414 | } |
1014 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1415 | + if (isset($line['route'])) { |
|
1416 | + $data['waypoints'] = $line['route']; |
|
1417 | + } |
|
1015 | 1418 | $data['id_source'] = $id_source; |
1016 | 1419 | $data['format_source'] = 'phpvmacars'; |
1017 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1420 | + if (isset($value['name']) && $value['name'] != '') { |
|
1421 | + $data['source_name'] = $value['name']; |
|
1422 | + } |
|
1018 | 1423 | $SI->add($data); |
1019 | 1424 | unset($data); |
1020 | 1425 | } |
1021 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1426 | + if ($globalDebug) { |
|
1427 | + echo 'No more data...'."\n"; |
|
1428 | + } |
|
1022 | 1429 | unset($buffer); |
1023 | 1430 | unset($all_data); |
1024 | 1431 | } |
@@ -1026,7 +1433,9 @@ discard block |
||
1026 | 1433 | $last_exec[$id]['last'] = time(); |
1027 | 1434 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
1028 | 1435 | //$buffer = $Common->getData($hosts[$id]); |
1029 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1436 | + if ($globalDebug) { |
|
1437 | + echo 'Get Data...'."\n"; |
|
1438 | + } |
|
1030 | 1439 | $buffer = $Common->getData($value['host']); |
1031 | 1440 | $all_data = json_decode($buffer,true); |
1032 | 1441 | if ($buffer != '' && is_array($all_data)) { |
@@ -1055,16 +1464,25 @@ discard block |
||
1055 | 1464 | $data['arrival_airport_icao'] = $line['arrival']; |
1056 | 1465 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1057 | 1466 | //$data['registration'] = $line['aircraft']; |
1058 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1467 | + if (isset($line['route'])) { |
|
1468 | + $data['waypoints'] = $line['route']; |
|
1469 | + } |
|
1470 | + // route |
|
1059 | 1471 | $data['aircraft_icao'] = $line['plane_type']; |
1060 | 1472 | $data['id_source'] = $id_source; |
1061 | 1473 | $data['format_source'] = 'vam'; |
1062 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1063 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1474 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1475 | + $data['noarchive'] = true; |
|
1476 | + } |
|
1477 | + if (isset($value['name']) && $value['name'] != '') { |
|
1478 | + $data['source_name'] = $value['name']; |
|
1479 | + } |
|
1064 | 1480 | $SI->add($data); |
1065 | 1481 | unset($data); |
1066 | 1482 | } |
1067 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1483 | + if ($globalDebug) { |
|
1484 | + echo 'No more data...'."\n"; |
|
1485 | + } |
|
1068 | 1486 | unset($buffer); |
1069 | 1487 | unset($all_data); |
1070 | 1488 | } |
@@ -1072,7 +1490,9 @@ discard block |
||
1072 | 1490 | $last_exec[$id]['last'] = time(); |
1073 | 1491 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1074 | 1492 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1075 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1493 | + if (function_exists('pcntl_fork')) { |
|
1494 | + pcntl_signal_dispatch(); |
|
1495 | + } |
|
1076 | 1496 | //$last_exec[$id]['last'] = time(); |
1077 | 1497 | |
1078 | 1498 | //$read = array( $sockets[$id] ); |
@@ -1080,7 +1500,9 @@ discard block |
||
1080 | 1500 | $write = NULL; |
1081 | 1501 | $e = NULL; |
1082 | 1502 | $n = socket_select($read, $write, $e, $timeout); |
1083 | - if ($e != NULL) var_dump($e); |
|
1503 | + if ($e != NULL) { |
|
1504 | + var_dump($e); |
|
1505 | + } |
|
1084 | 1506 | if ($n > 0) { |
1085 | 1507 | $reset = 0; |
1086 | 1508 | foreach ($read as $nb => $r) { |
@@ -1101,12 +1523,16 @@ discard block |
||
1101 | 1523 | //$SI::del(); |
1102 | 1524 | if ($format == 'vrstcp') { |
1103 | 1525 | $buffer = explode('},{',$buffer); |
1104 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1526 | + } else { |
|
1527 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1528 | + } |
|
1105 | 1529 | // SBS format is CSV format |
1106 | 1530 | if ($buffer !== FALSE && $buffer != '') { |
1107 | 1531 | $tt[$format] = 0; |
1108 | 1532 | if ($format == 'acarssbs3') { |
1109 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1533 | + if ($globalDebug) { |
|
1534 | + echo 'ACARS : '.$buffer."\n"; |
|
1535 | + } |
|
1110 | 1536 | $ACARS->add(trim($buffer)); |
1111 | 1537 | $ACARS->deleteLiveAcarsData(); |
1112 | 1538 | } elseif ($format == 'raw') { |
@@ -1115,30 +1541,70 @@ discard block |
||
1115 | 1541 | if (is_array($data)) { |
1116 | 1542 | $data['datetime'] = date('Y-m-d H:i:s'); |
1117 | 1543 | $data['format_source'] = 'raw'; |
1118 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1119 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1120 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1121 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1544 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1545 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1546 | + } |
|
1547 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1548 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1549 | + } |
|
1550 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1551 | + $data['noarchive'] = true; |
|
1552 | + } |
|
1553 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1554 | + $SI->add($data); |
|
1555 | + } |
|
1122 | 1556 | } |
1123 | 1557 | } elseif ($format == 'ais') { |
1124 | 1558 | $ais_data = $AIS->parse_line(trim($buffer)); |
1125 | 1559 | $data = array(); |
1126 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1127 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1128 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1129 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1130 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1131 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1132 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1133 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1134 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1135 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1136 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1137 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1138 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1139 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1140 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1141 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1560 | + if (isset($ais_data['ident'])) { |
|
1561 | + $data['ident'] = $ais_data['ident']; |
|
1562 | + } |
|
1563 | + if (isset($ais_data['mmsi'])) { |
|
1564 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1565 | + } |
|
1566 | + if (isset($ais_data['speed'])) { |
|
1567 | + $data['speed'] = $ais_data['speed']; |
|
1568 | + } |
|
1569 | + if (isset($ais_data['heading'])) { |
|
1570 | + $data['heading'] = $ais_data['heading']; |
|
1571 | + } |
|
1572 | + if (isset($ais_data['latitude'])) { |
|
1573 | + $data['latitude'] = $ais_data['latitude']; |
|
1574 | + } |
|
1575 | + if (isset($ais_data['longitude'])) { |
|
1576 | + $data['longitude'] = $ais_data['longitude']; |
|
1577 | + } |
|
1578 | + if (isset($ais_data['status'])) { |
|
1579 | + $data['status'] = $ais_data['status']; |
|
1580 | + } |
|
1581 | + if (isset($ais_data['statusid'])) { |
|
1582 | + $data['status_id'] = $ais_data['statusid']; |
|
1583 | + } |
|
1584 | + if (isset($ais_data['type'])) { |
|
1585 | + $data['type'] = $ais_data['type']; |
|
1586 | + } |
|
1587 | + if (isset($ais_data['imo'])) { |
|
1588 | + $data['imo'] = $ais_data['imo']; |
|
1589 | + } |
|
1590 | + if (isset($ais_data['callsign'])) { |
|
1591 | + $data['callsign'] = $ais_data['callsign']; |
|
1592 | + } |
|
1593 | + if (isset($ais_data['destination'])) { |
|
1594 | + $data['arrival_code'] = $ais_data['destination']; |
|
1595 | + } |
|
1596 | + if (isset($ais_data['eta_ts'])) { |
|
1597 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1598 | + } |
|
1599 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1600 | + $data['noarchive'] = true; |
|
1601 | + } |
|
1602 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1603 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1604 | + } |
|
1605 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1606 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1607 | + } |
|
1142 | 1608 | |
1143 | 1609 | if (isset($ais_data['timestamp'])) { |
1144 | 1610 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1147,7 +1613,9 @@ discard block |
||
1147 | 1613 | } |
1148 | 1614 | $data['format_source'] = 'aisnmea'; |
1149 | 1615 | $data['id_source'] = $id_source; |
1150 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1616 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1617 | + $MI->add($data); |
|
1618 | + } |
|
1151 | 1619 | unset($data); |
1152 | 1620 | } elseif ($format == 'flightgearsp') { |
1153 | 1621 | //echo $buffer."\n"; |
@@ -1165,12 +1633,18 @@ discard block |
||
1165 | 1633 | $data['speed'] = round($line[5]*1.94384); |
1166 | 1634 | $data['datetime'] = date('Y-m-d H:i:s'); |
1167 | 1635 | $data['format_source'] = 'flightgearsp'; |
1168 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1169 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1636 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1637 | + $data['noarchive'] = true; |
|
1638 | + } |
|
1639 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1640 | + $SI->add($data); |
|
1641 | + } |
|
1170 | 1642 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1171 | 1643 | } |
1172 | 1644 | } elseif ($format == 'acars') { |
1173 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1645 | + if ($globalDebug) { |
|
1646 | + echo 'ACARS : '.$buffer."\n"; |
|
1647 | + } |
|
1174 | 1648 | $ACARS->add(trim($buffer)); |
1175 | 1649 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1176 | 1650 | $ACARS->deleteLiveAcarsData(); |
@@ -1191,8 +1665,12 @@ discard block |
||
1191 | 1665 | $aircraft_type = $line[10]; |
1192 | 1666 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1193 | 1667 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1194 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1195 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1668 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1669 | + $data['noarchive'] = true; |
|
1670 | + } |
|
1671 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1672 | + $SI->add($data); |
|
1673 | + } |
|
1196 | 1674 | } |
1197 | 1675 | } |
1198 | 1676 | } elseif ($format == 'beast') { |
@@ -1202,28 +1680,62 @@ discard block |
||
1202 | 1680 | foreach($buffer as $all_data) { |
1203 | 1681 | $line = json_decode('{'.$all_data.'}',true); |
1204 | 1682 | $data = array(); |
1205 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1206 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1207 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1208 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1209 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1210 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1211 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1683 | + if (isset($line['Icao'])) { |
|
1684 | + $data['hex'] = $line['Icao']; |
|
1685 | + } |
|
1686 | + // hex |
|
1687 | + if (isset($line['Call'])) { |
|
1688 | + $data['ident'] = $line['Call']; |
|
1689 | + } |
|
1690 | + // ident |
|
1691 | + if (isset($line['Alt'])) { |
|
1692 | + $data['altitude'] = $line['Alt']; |
|
1693 | + } |
|
1694 | + // altitude |
|
1695 | + if (isset($line['Spd'])) { |
|
1696 | + $data['speed'] = $line['Spd']; |
|
1697 | + } |
|
1698 | + // speed |
|
1699 | + if (isset($line['Trak'])) { |
|
1700 | + $data['heading'] = $line['Trak']; |
|
1701 | + } |
|
1702 | + // heading |
|
1703 | + if (isset($line['Lat'])) { |
|
1704 | + $data['latitude'] = $line['Lat']; |
|
1705 | + } |
|
1706 | + // lat |
|
1707 | + if (isset($line['Long'])) { |
|
1708 | + $data['longitude'] = $line['Long']; |
|
1709 | + } |
|
1710 | + // long |
|
1212 | 1711 | //$data['verticalrate'] = $line['']; // verticale rate |
1213 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1712 | + if (isset($line['Sqk'])) { |
|
1713 | + $data['squawk'] = $line['Sqk']; |
|
1714 | + } |
|
1715 | + // squawk |
|
1214 | 1716 | $data['emergency'] = ''; // emergency |
1215 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1717 | + if (isset($line['Reg'])) { |
|
1718 | + $data['registration'] = $line['Reg']; |
|
1719 | + } |
|
1216 | 1720 | /* |
1217 | 1721 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1218 | 1722 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1219 | 1723 | */ |
1220 | 1724 | $data['datetime'] = date('Y-m-d H:i:s'); |
1221 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1725 | + if (isset($line['Type'])) { |
|
1726 | + $data['aircraft_icao'] = $line['Type']; |
|
1727 | + } |
|
1222 | 1728 | $data['format_source'] = 'vrstcp'; |
1223 | 1729 | $data['id_source'] = $id_source; |
1224 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1225 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1226 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1730 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1731 | + $data['noarchive'] = true; |
|
1732 | + } |
|
1733 | + if (isset($value['name']) && $value['name'] != '') { |
|
1734 | + $data['source_name'] = $value['name']; |
|
1735 | + } |
|
1736 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1737 | + $SI->add($data); |
|
1738 | + } |
|
1227 | 1739 | unset($data); |
1228 | 1740 | } |
1229 | 1741 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1236,22 +1748,46 @@ discard block |
||
1236 | 1748 | $data['hex'] = $lined['hexid']; |
1237 | 1749 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1238 | 1750 | $data['datetime'] = date('Y-m-d H:i:s');; |
1239 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1240 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1241 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1242 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1243 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1244 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1245 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1751 | + if (isset($lined['ident'])) { |
|
1752 | + $data['ident'] = $lined['ident']; |
|
1753 | + } |
|
1754 | + if (isset($lined['lat'])) { |
|
1755 | + $data['latitude'] = $lined['lat']; |
|
1756 | + } |
|
1757 | + if (isset($lined['lon'])) { |
|
1758 | + $data['longitude'] = $lined['lon']; |
|
1759 | + } |
|
1760 | + if (isset($lined['speed'])) { |
|
1761 | + $data['speed'] = $lined['speed']; |
|
1762 | + } |
|
1763 | + if (isset($lined['squawk'])) { |
|
1764 | + $data['squawk'] = $lined['squawk']; |
|
1765 | + } |
|
1766 | + if (isset($lined['alt'])) { |
|
1767 | + $data['altitude'] = $lined['alt']; |
|
1768 | + } |
|
1769 | + if (isset($lined['heading'])) { |
|
1770 | + $data['heading'] = $lined['heading']; |
|
1771 | + } |
|
1246 | 1772 | $data['id_source'] = $id_source; |
1247 | 1773 | $data['format_source'] = 'tsv'; |
1248 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1249 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1250 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1251 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1774 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1775 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1776 | + } |
|
1777 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1778 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1779 | + } |
|
1780 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1781 | + $data['noarchive'] = true; |
|
1782 | + } |
|
1783 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1784 | + $SI->add($data); |
|
1785 | + } |
|
1252 | 1786 | unset($lined); |
1253 | 1787 | unset($data); |
1254 | - } else $error = true; |
|
1788 | + } else { |
|
1789 | + $error = true; |
|
1790 | + } |
|
1255 | 1791 | } elseif ($format == 'aprs' && $use_aprs) { |
1256 | 1792 | if ($aprs_connect == 0) { |
1257 | 1793 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1276,39 +1812,86 @@ discard block |
||
1276 | 1812 | $aprs_last_tx = time(); |
1277 | 1813 | $data = array(); |
1278 | 1814 | //print_r($line); |
1279 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1280 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1281 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1282 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1283 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1284 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1285 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1286 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1287 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1288 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1815 | + if (isset($line['address'])) { |
|
1816 | + $data['hex'] = $line['address']; |
|
1817 | + } |
|
1818 | + if (isset($line['mmsi'])) { |
|
1819 | + $data['mmsi'] = $line['mmsi']; |
|
1820 | + } |
|
1821 | + if (isset($line['imo'])) { |
|
1822 | + $data['imo'] = $line['imo']; |
|
1823 | + } |
|
1824 | + if (isset($line['squawk'])) { |
|
1825 | + $data['squawk'] = $line['squawk']; |
|
1826 | + } |
|
1827 | + if (isset($line['arrival_code'])) { |
|
1828 | + $data['arrical_code'] = $line['arrival_code']; |
|
1829 | + } |
|
1830 | + if (isset($line['arrival_date'])) { |
|
1831 | + $data['arrical_date'] = $line['arrival_date']; |
|
1832 | + } |
|
1833 | + if (isset($line['type_id'])) { |
|
1834 | + $data['type_id'] = $line['typeid']; |
|
1835 | + } |
|
1836 | + if (isset($line['status_id'])) { |
|
1837 | + $data['status_id'] = $line['statusid']; |
|
1838 | + } |
|
1839 | + if (isset($line['timestamp'])) { |
|
1840 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1841 | + } else { |
|
1842 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1843 | + } |
|
1289 | 1844 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1290 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1845 | + if (isset($line['ident'])) { |
|
1846 | + $data['ident'] = $line['ident']; |
|
1847 | + } |
|
1291 | 1848 | $data['latitude'] = $line['latitude']; |
1292 | 1849 | $data['longitude'] = $line['longitude']; |
1293 | 1850 | //$data['verticalrate'] = $line[16]; |
1294 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1295 | - else $data['speed'] = 0; |
|
1296 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1297 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1298 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1299 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1851 | + if (isset($line['speed'])) { |
|
1852 | + $data['speed'] = $line['speed']; |
|
1853 | + } else { |
|
1854 | + $data['speed'] = 0; |
|
1855 | + } |
|
1856 | + if (isset($line['altitude'])) { |
|
1857 | + $data['altitude'] = $line['altitude']; |
|
1858 | + } |
|
1859 | + if (isset($line['comment'])) { |
|
1860 | + $data['comment'] = $line['comment']; |
|
1861 | + } |
|
1862 | + if (isset($line['symbol'])) { |
|
1863 | + $data['type'] = $line['symbol']; |
|
1864 | + } |
|
1865 | + if (isset($line['heading'])) { |
|
1866 | + $data['heading'] = $line['heading']; |
|
1867 | + } |
|
1300 | 1868 | //else $data['heading'] = 0; |
1301 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1302 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1303 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1304 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1869 | + if (isset($line['stealth'])) { |
|
1870 | + $data['aircraft_type'] = $line['stealth']; |
|
1871 | + } |
|
1872 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) { |
|
1873 | + $data['noarchive'] = true; |
|
1874 | + } |
|
1875 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1876 | + $data['noarchive'] = true; |
|
1877 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
1878 | + $data['noarchive'] = false; |
|
1879 | + } |
|
1305 | 1880 | $data['id_source'] = $id_source; |
1306 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1307 | - else $data['format_source'] = 'aprs'; |
|
1881 | + if (isset($line['format_source'])) { |
|
1882 | + $data['format_source'] = $line['format_source']; |
|
1883 | + } else { |
|
1884 | + $data['format_source'] = 'aprs'; |
|
1885 | + } |
|
1308 | 1886 | $data['source_name'] = $line['source']; |
1309 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1310 | - else $data['source_type'] = 'flarm'; |
|
1311 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1887 | + if (isset($line['source_type'])) { |
|
1888 | + $data['source_type'] = $line['source_type']; |
|
1889 | + } else { |
|
1890 | + $data['source_type'] = 'flarm'; |
|
1891 | + } |
|
1892 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1893 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1894 | + } |
|
1312 | 1895 | $currentdate = date('Y-m-d H:i:s'); |
1313 | 1896 | $aprsdate = strtotime($data['datetime']); |
1314 | 1897 | // Accept data if time <= system time + 20s |
@@ -1316,21 +1899,26 @@ discard block |
||
1316 | 1899 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1317 | 1900 | $send = $SI->add($data); |
1318 | 1901 | } elseif ($data['source_type'] == 'ais') { |
1319 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
1902 | + if (isset($globalMarine) && $globalMarine) { |
|
1903 | + $send = $MI->add($data); |
|
1904 | + } |
|
1320 | 1905 | } elseif (isset($line['stealth'])) { |
1321 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1322 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1906 | + if ($line['stealth'] != 0) { |
|
1907 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1908 | + } else { |
|
1909 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1910 | + } |
|
1323 | 1911 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1324 | 1912 | } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1325 | 1913 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1326 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
1914 | + if (isset($globalTracker) && $globalTracker) { |
|
1915 | + $send = $TI->add($data); |
|
1916 | + } |
|
1327 | 1917 | } |
1328 | 1918 | unset($data); |
1329 | - } |
|
1330 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1919 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1331 | 1920 | echo '!! Weather Station not yet supported'."\n"; |
1332 | - } |
|
1333 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1921 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1334 | 1922 | echo '!! Car & Trucks not yet supported'."\n"; |
1335 | 1923 | } |
1336 | 1924 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1363,26 +1951,45 @@ discard block |
||
1363 | 1951 | $data['ground'] = $line[21]; |
1364 | 1952 | $data['emergency'] = $line[19]; |
1365 | 1953 | $data['format_source'] = 'sbs'; |
1366 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1367 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1368 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1954 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1955 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1956 | + } |
|
1957 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1958 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1959 | + } |
|
1960 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1961 | + $data['noarchive'] = true; |
|
1962 | + } |
|
1369 | 1963 | $data['id_source'] = $id_source; |
1370 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1371 | - else $error = true; |
|
1964 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1965 | + $send = $SI->add($data); |
|
1966 | + } else { |
|
1967 | + $error = true; |
|
1968 | + } |
|
1372 | 1969 | unset($data); |
1373 | - } else $error = true; |
|
1970 | + } else { |
|
1971 | + $error = true; |
|
1972 | + } |
|
1374 | 1973 | if ($error) { |
1375 | 1974 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1376 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1975 | + if ($globalDebug) { |
|
1976 | + echo "Not a message. Ignoring... \n"; |
|
1977 | + } |
|
1377 | 1978 | } else { |
1378 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1979 | + if ($globalDebug) { |
|
1980 | + echo "Wrong line format. Ignoring... \n"; |
|
1981 | + } |
|
1379 | 1982 | if ($globalDebug) { |
1380 | 1983 | echo $buffer; |
1381 | 1984 | //print_r($line); |
1382 | 1985 | } |
1383 | 1986 | //socket_close($r); |
1384 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1385 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1987 | + if ($globalDebug) { |
|
1988 | + echo "Reconnect after an error...\n"; |
|
1989 | + } |
|
1990 | + if ($format == 'aprs') { |
|
1991 | + $aprs_connect = 0; |
|
1992 | + } |
|
1386 | 1993 | $sourceer[$nb] = $globalSources[$nb]; |
1387 | 1994 | connect_all($sourceer); |
1388 | 1995 | $sourceer = array(); |
@@ -1390,10 +1997,14 @@ discard block |
||
1390 | 1997 | } |
1391 | 1998 | } |
1392 | 1999 | // Sleep for xxx microseconds |
1393 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2000 | + if (isset($globalSBSSleep)) { |
|
2001 | + usleep($globalSBSSleep); |
|
2002 | + } |
|
1394 | 2003 | } else { |
1395 | 2004 | if ($format == 'flightgearmp') { |
1396 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2005 | + if ($globalDebug) { |
|
2006 | + echo "Reconnect FlightGear MP..."; |
|
2007 | + } |
|
1397 | 2008 | //@socket_close($r); |
1398 | 2009 | sleep($globalMinFetch); |
1399 | 2010 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1402,10 +2013,15 @@ discard block |
||
1402 | 2013 | break; |
1403 | 2014 | |
1404 | 2015 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1405 | - if (isset($tt[$format])) $tt[$format]++; |
|
1406 | - else $tt[$format] = 0; |
|
2016 | + if (isset($tt[$format])) { |
|
2017 | + $tt[$format]++; |
|
2018 | + } else { |
|
2019 | + $tt[$format] = 0; |
|
2020 | + } |
|
1407 | 2021 | if ($tt[$format] > 30) { |
1408 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2022 | + if ($globalDebug) { |
|
2023 | + echo "ERROR : Reconnect ".$format."..."; |
|
2024 | + } |
|
1409 | 2025 | //@socket_close($r); |
1410 | 2026 | sleep(2); |
1411 | 2027 | $aprs_connect = 0; |
@@ -1422,11 +2038,17 @@ discard block |
||
1422 | 2038 | } else { |
1423 | 2039 | $error = socket_strerror(socket_last_error()); |
1424 | 2040 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1425 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1426 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2041 | + if ($globalDebug) { |
|
2042 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2043 | + } |
|
2044 | + if (isset($globalDebug)) { |
|
2045 | + echo "Restarting...\n"; |
|
2046 | + } |
|
1427 | 2047 | // Restart the script if possible |
1428 | 2048 | if (is_array($sockets)) { |
1429 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2049 | + if ($globalDebug) { |
|
2050 | + echo "Shutdown all sockets..."; |
|
2051 | + } |
|
1430 | 2052 | |
1431 | 2053 | foreach ($sockets as $sock) { |
1432 | 2054 | @socket_shutdown($sock,2); |
@@ -1434,22 +2056,36 @@ discard block |
||
1434 | 2056 | } |
1435 | 2057 | |
1436 | 2058 | } |
1437 | - if ($globalDebug) echo "Waiting..."; |
|
2059 | + if ($globalDebug) { |
|
2060 | + echo "Waiting..."; |
|
2061 | + } |
|
1438 | 2062 | sleep(2); |
1439 | 2063 | $time = time(); |
1440 | 2064 | //connect_all($hosts); |
1441 | 2065 | $aprs_connect = 0; |
1442 | - if ($reset%5 == 0) sleep(20); |
|
1443 | - if ($reset%10 == 0) sleep(100); |
|
1444 | - if ($reset%20 == 0) sleep(200); |
|
1445 | - if ($reset > 100) exit('Too many attempts...'); |
|
1446 | - if ($globalDebug) echo "Restart all connections..."; |
|
2066 | + if ($reset%5 == 0) { |
|
2067 | + sleep(20); |
|
2068 | + } |
|
2069 | + if ($reset%10 == 0) { |
|
2070 | + sleep(100); |
|
2071 | + } |
|
2072 | + if ($reset%20 == 0) { |
|
2073 | + sleep(200); |
|
2074 | + } |
|
2075 | + if ($reset > 100) { |
|
2076 | + exit('Too many attempts...'); |
|
2077 | + } |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo "Restart all connections..."; |
|
2080 | + } |
|
1447 | 2081 | connect_all($globalSources); |
1448 | 2082 | } |
1449 | 2083 | } |
1450 | 2084 | } |
1451 | 2085 | if ($globalDaemon === false) { |
1452 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2086 | + if ($globalDebug) { |
|
2087 | + echo 'Check all...'."\n"; |
|
2088 | + } |
|
1453 | 2089 | $SI->checkAll(); |
1454 | 2090 | } |
1455 | 2091 | } |
@@ -8,7 +8,9 @@ |
||
8 | 8 | $atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT); |
9 | 9 | $atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING); |
10 | 10 | $atc_data = $ATC->getById($atcid); |
11 | - if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident); |
|
11 | + if (!isset($atc_data[0])) { |
|
12 | + $atc_data = $ATC->getByIdent($atcident); |
|
13 | + } |
|
12 | 14 | ?> |
13 | 15 | <div class="alldetails"> |
14 | 16 | <button type="button" class="close">×</button> |