@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
80 | 80 | else $id_source = 1; |
81 | 81 | if (isset($globalServer) && $globalServer) { |
82 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
83 | - $SI=new SpotterServer(); |
|
82 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
83 | + $SI=new SpotterServer(); |
|
84 | 84 | /* |
85 | 85 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
86 | 86 | $SI = new adsb2aprs(); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | } else $SI=new SpotterImport($Connection->db); |
90 | 90 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
91 | 91 | if (isset($globalMarine) && $globalMarine) { |
92 | - $AIS = new AIS(); |
|
93 | - $MI = new MarineImport($Connection->db); |
|
92 | + $AIS = new AIS(); |
|
93 | + $MI = new MarineImport($Connection->db); |
|
94 | 94 | } |
95 | 95 | //$APRS=new APRS($Connection->db); |
96 | 96 | $SBS=new SBS(); |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | //$servertz = system('date +%Z'); |
102 | 102 | // signal handler - playing nice with sockets and dump1090 |
103 | 103 | if (function_exists('pcntl_fork')) { |
104 | - pcntl_signal(SIGINT, function() { |
|
105 | - global $sockets; |
|
106 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
107 | - die("Bye!\n"); |
|
108 | - }); |
|
109 | - pcntl_signal_dispatch(); |
|
104 | + pcntl_signal(SIGINT, function() { |
|
105 | + global $sockets; |
|
106 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
107 | + die("Bye!\n"); |
|
108 | + }); |
|
109 | + pcntl_signal_dispatch(); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // let's try and connect |
@@ -116,36 +116,36 @@ discard block |
||
116 | 116 | $reset = 0; |
117 | 117 | |
118 | 118 | function connect_all($hosts) { |
119 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
120 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
121 | - $reset++; |
|
122 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
123 | - foreach ($hosts as $id => $value) { |
|
119 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
120 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
121 | + $reset++; |
|
122 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
123 | + foreach ($hosts as $id => $value) { |
|
124 | 124 | $host = $value['host']; |
125 | 125 | $globalSources[$id]['last_exec'] = 0; |
126 | 126 | // Here we check type of source(s) |
127 | 127 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
128 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
129 | - //$formats[$id] = 'deltadbtxt'; |
|
130 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
131 | - //$last_exec['deltadbtxt'] = 0; |
|
132 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
133 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
134 | - //$formats[$id] = 'vatsimtxt'; |
|
135 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
136 | - //$last_exec['vatsimtxt'] = 0; |
|
137 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
138 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
139 | - //$formats[$id] = 'aircraftlistjson'; |
|
140 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
141 | - //$last_exec['aircraftlistjson'] = 0; |
|
142 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
143 | - } else if (preg_match('/opensky/i',$host)) { |
|
144 | - //$formats[$id] = 'aircraftlistjson'; |
|
145 | - $globalSources[$id]['format'] = 'opensky'; |
|
146 | - //$last_exec['aircraftlistjson'] = 0; |
|
147 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
148 | - /* |
|
128 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
129 | + //$formats[$id] = 'deltadbtxt'; |
|
130 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
131 | + //$last_exec['deltadbtxt'] = 0; |
|
132 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
133 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
134 | + //$formats[$id] = 'vatsimtxt'; |
|
135 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
136 | + //$last_exec['vatsimtxt'] = 0; |
|
137 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
138 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
139 | + //$formats[$id] = 'aircraftlistjson'; |
|
140 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
141 | + //$last_exec['aircraftlistjson'] = 0; |
|
142 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
143 | + } else if (preg_match('/opensky/i',$host)) { |
|
144 | + //$formats[$id] = 'aircraftlistjson'; |
|
145 | + $globalSources[$id]['format'] = 'opensky'; |
|
146 | + //$last_exec['aircraftlistjson'] = 0; |
|
147 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
148 | + /* |
|
149 | 149 | // Disabled for now, site change source format |
150 | 150 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
151 | 151 | //$formats[$id] = 'radarvirtueljson'; |
@@ -157,121 +157,121 @@ discard block |
||
157 | 157 | exit(0); |
158 | 158 | } |
159 | 159 | */ |
160 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
161 | - //$formats[$id] = 'planeupdatefaa'; |
|
162 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
163 | - //$last_exec['planeupdatefaa'] = 0; |
|
164 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
165 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
166 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
167 | - exit(0); |
|
168 | - } |
|
169 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
170 | - //$formats[$id] = 'phpvmacars'; |
|
171 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
172 | - //$last_exec['phpvmacars'] = 0; |
|
173 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
175 | - //$formats[$id] = 'phpvmacars'; |
|
176 | - $globalSources[$id]['format'] = 'vam'; |
|
177 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
178 | - } else if (preg_match('/whazzup/i',$host)) { |
|
179 | - //$formats[$id] = 'whazzup'; |
|
180 | - $globalSources[$id]['format'] = 'whazzup'; |
|
181 | - //$last_exec['whazzup'] = 0; |
|
182 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
183 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
184 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
185 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
186 | - } else if (preg_match('/airwhere/i',$host)) { |
|
187 | - $globalSources[$id]['format'] = 'airwhere'; |
|
188 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
189 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
190 | - //$formats[$id] = 'pirepsjson'; |
|
191 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
192 | - //$last_exec['pirepsjson'] = 0; |
|
193 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
194 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
195 | - //$formats[$id] = 'fr24json'; |
|
196 | - $globalSources[$id]['format'] = 'fr24json'; |
|
197 | - //$last_exec['fr24json'] = 0; |
|
198 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
199 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
200 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
201 | - exit(0); |
|
202 | - } |
|
203 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
204 | - //$formats[$id] = 'fr24json'; |
|
205 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
206 | - //$last_exec['fr24json'] = 0; |
|
207 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
208 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
209 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210 | - exit(0); |
|
211 | - } |
|
212 | - //} else if (preg_match('/10001/',$host)) { |
|
213 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
214 | - //$formats[$id] = 'tsv'; |
|
215 | - $globalSources[$id]['format'] = 'tsv'; |
|
216 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
217 | - } |
|
218 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
219 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
220 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
221 | - if ($idf !== false) { |
|
222 | - $httpfeeds[$id] = $idf; |
|
223 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
224 | - } |
|
225 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
226 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
227 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
228 | - $hostport = explode(':',$host); |
|
229 | - if (isset($hostport[1])) { |
|
160 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
161 | + //$formats[$id] = 'planeupdatefaa'; |
|
162 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
163 | + //$last_exec['planeupdatefaa'] = 0; |
|
164 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
165 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
166 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
167 | + exit(0); |
|
168 | + } |
|
169 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
170 | + //$formats[$id] = 'phpvmacars'; |
|
171 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
172 | + //$last_exec['phpvmacars'] = 0; |
|
173 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
175 | + //$formats[$id] = 'phpvmacars'; |
|
176 | + $globalSources[$id]['format'] = 'vam'; |
|
177 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
178 | + } else if (preg_match('/whazzup/i',$host)) { |
|
179 | + //$formats[$id] = 'whazzup'; |
|
180 | + $globalSources[$id]['format'] = 'whazzup'; |
|
181 | + //$last_exec['whazzup'] = 0; |
|
182 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
183 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
184 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
185 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
186 | + } else if (preg_match('/airwhere/i',$host)) { |
|
187 | + $globalSources[$id]['format'] = 'airwhere'; |
|
188 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
189 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
190 | + //$formats[$id] = 'pirepsjson'; |
|
191 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
192 | + //$last_exec['pirepsjson'] = 0; |
|
193 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
194 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
195 | + //$formats[$id] = 'fr24json'; |
|
196 | + $globalSources[$id]['format'] = 'fr24json'; |
|
197 | + //$last_exec['fr24json'] = 0; |
|
198 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
199 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
200 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
201 | + exit(0); |
|
202 | + } |
|
203 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
204 | + //$formats[$id] = 'fr24json'; |
|
205 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
206 | + //$last_exec['fr24json'] = 0; |
|
207 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
208 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
209 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210 | + exit(0); |
|
211 | + } |
|
212 | + //} else if (preg_match('/10001/',$host)) { |
|
213 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
214 | + //$formats[$id] = 'tsv'; |
|
215 | + $globalSources[$id]['format'] = 'tsv'; |
|
216 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
217 | + } |
|
218 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
219 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
220 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
221 | + if ($idf !== false) { |
|
222 | + $httpfeeds[$id] = $idf; |
|
223 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
224 | + } |
|
225 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
226 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
227 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
228 | + $hostport = explode(':',$host); |
|
229 | + if (isset($hostport[1])) { |
|
230 | 230 | $port = $hostport[1]; |
231 | 231 | $hostn = $hostport[0]; |
232 | - } else { |
|
232 | + } else { |
|
233 | 233 | $port = $globalSources[$id]['port']; |
234 | 234 | $hostn = $globalSources[$id]['host']; |
235 | - } |
|
236 | - $Common = new Common(); |
|
237 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
238 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
239 | - } else { |
|
240 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
241 | - } |
|
242 | - if ($s) { |
|
243 | - $sockets[$id] = $s; |
|
244 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
245 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
235 | + } |
|
236 | + $Common = new Common(); |
|
237 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
238 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
239 | + } else { |
|
240 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
241 | + } |
|
242 | + if ($s) { |
|
243 | + $sockets[$id] = $s; |
|
244 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
245 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
246 | 246 | //$formats[$id] = 'aprs'; |
247 | 247 | $globalSources[$id]['format'] = 'aprs'; |
248 | 248 | //$aprs_connect = 0; |
249 | 249 | //$use_aprs = true; |
250 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
250 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
251 | 251 | $globalSources[$id]['format'] = 'vrstcp'; |
252 | - } elseif ($port == '10001') { |
|
253 | - //$formats[$id] = 'tsv'; |
|
254 | - $globalSources[$id]['format'] = 'tsv'; |
|
255 | - } elseif ($port == '30002') { |
|
256 | - //$formats[$id] = 'raw'; |
|
257 | - $globalSources[$id]['format'] = 'raw'; |
|
258 | - } elseif ($port == '5001') { |
|
259 | - //$formats[$id] = 'raw'; |
|
260 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
261 | - } elseif ($port == '30005') { |
|
252 | + } elseif ($port == '10001') { |
|
253 | + //$formats[$id] = 'tsv'; |
|
254 | + $globalSources[$id]['format'] = 'tsv'; |
|
255 | + } elseif ($port == '30002') { |
|
256 | + //$formats[$id] = 'raw'; |
|
257 | + $globalSources[$id]['format'] = 'raw'; |
|
258 | + } elseif ($port == '5001') { |
|
259 | + //$formats[$id] = 'raw'; |
|
260 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
261 | + } elseif ($port == '30005') { |
|
262 | 262 | // Not yet supported |
263 | - //$formats[$id] = 'beast'; |
|
264 | - $globalSources[$id]['format'] = 'beast'; |
|
265 | - //} else $formats[$id] = 'sbs'; |
|
266 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
267 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
263 | + //$formats[$id] = 'beast'; |
|
264 | + $globalSources[$id]['format'] = 'beast'; |
|
265 | + //} else $formats[$id] = 'sbs'; |
|
266 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
267 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
268 | 268 | } |
269 | 269 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
270 | - } else { |
|
270 | + } else { |
|
271 | 271 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
272 | - } |
|
273 | - } |
|
274 | - } |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | } |
276 | 276 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
277 | 277 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | //connect_all($globalSources); |
295 | 295 | |
296 | 296 | if (isset($globalProxy) && $globalProxy) { |
297 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
297 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
298 | 298 | } else { |
299 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
299 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // APRS Configuration |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | die; |
306 | 306 | } |
307 | 307 | foreach ($globalSources as $key => $source) { |
308 | - if (!isset($source['format'])) { |
|
309 | - $globalSources[$key]['format'] = 'auto'; |
|
310 | - } |
|
311 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
312 | - unset($globalSources[$key]); |
|
313 | - } |
|
308 | + if (!isset($source['format'])) { |
|
309 | + $globalSources[$key]['format'] = 'auto'; |
|
310 | + } |
|
311 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
312 | + unset($globalSources[$key]); |
|
313 | + } |
|
314 | 314 | } |
315 | 315 | connect_all($globalSources); |
316 | 316 | foreach ($globalSources as $key => $source) { |
317 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
317 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
318 | 318 | $aprs_connect = 0; |
319 | 319 | $use_aprs = true; |
320 | 320 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
321 | 321 | break; |
322 | - } |
|
322 | + } |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if ($use_aprs) { |
@@ -360,126 +360,126 @@ discard block |
||
360 | 360 | |
361 | 361 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
362 | 362 | while ($i > 0) { |
363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
364 | - // Delete old ATC |
|
365 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
363 | + if (!$globalDaemon) $i = $endtime-time(); |
|
364 | + // Delete old ATC |
|
365 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
366 | 366 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
367 | - $ATC->deleteOldATC(); |
|
368 | - } |
|
367 | + $ATC->deleteOldATC(); |
|
368 | + } |
|
369 | 369 | |
370 | - if (count($last_exec) == count($globalSources)) { |
|
370 | + if (count($last_exec) == count($globalSources)) { |
|
371 | 371 | $max = $globalMinFetch; |
372 | 372 | foreach ($last_exec as $last) { |
373 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
373 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
374 | 374 | } |
375 | 375 | if ($max != $globalMinFetch) { |
376 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
377 | - sleep($globalMinFetch-$max+2); |
|
376 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
377 | + sleep($globalMinFetch-$max+2); |
|
378 | + } |
|
378 | 379 | } |
379 | - } |
|
380 | 380 | |
381 | 381 | |
382 | - //foreach ($formats as $id => $value) { |
|
383 | - foreach ($globalSources as $id => $value) { |
|
382 | + //foreach ($formats as $id => $value) { |
|
383 | + foreach ($globalSources as $id => $value) { |
|
384 | 384 | date_default_timezone_set('UTC'); |
385 | 385 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
386 | 386 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
387 | 387 | if ($value['format'] == 'deltadbtxt' && |
388 | - ( |
|
388 | + ( |
|
389 | 389 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
390 | 390 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
391 | - ) |
|
391 | + ) |
|
392 | 392 | ) { |
393 | - //$buffer = $Common->getData($hosts[$id]); |
|
394 | - $buffer = $Common->getData($value['host']); |
|
395 | - if ($buffer != '') $reset = 0; |
|
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
398 | - foreach ($buffer as $line) { |
|
399 | - if ($line != '' && count($line) > 7) { |
|
400 | - $line = explode(',', $line); |
|
401 | - $data = array(); |
|
402 | - $data['hex'] = $line[1]; // hex |
|
403 | - $data['ident'] = $line[2]; // ident |
|
404 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
405 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
406 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
407 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
408 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
409 | - $data['verticalrate'] = ''; // vertical rate |
|
410 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
411 | - $data['emergency'] = ''; // emergency |
|
412 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
413 | - $data['format_source'] = 'deltadbtxt'; |
|
414 | - $data['id_source'] = $id_source; |
|
415 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
416 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
417 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
418 | - $SI->add($data); |
|
419 | - unset($data); |
|
420 | - } |
|
421 | - } |
|
422 | - $last_exec[$id]['last'] = time(); |
|
393 | + //$buffer = $Common->getData($hosts[$id]); |
|
394 | + $buffer = $Common->getData($value['host']); |
|
395 | + if ($buffer != '') $reset = 0; |
|
396 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | + $buffer = explode('\n',$buffer); |
|
398 | + foreach ($buffer as $line) { |
|
399 | + if ($line != '' && count($line) > 7) { |
|
400 | + $line = explode(',', $line); |
|
401 | + $data = array(); |
|
402 | + $data['hex'] = $line[1]; // hex |
|
403 | + $data['ident'] = $line[2]; // ident |
|
404 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
405 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
406 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
407 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
408 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
409 | + $data['verticalrate'] = ''; // vertical rate |
|
410 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
411 | + $data['emergency'] = ''; // emergency |
|
412 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
413 | + $data['format_source'] = 'deltadbtxt'; |
|
414 | + $data['id_source'] = $id_source; |
|
415 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
416 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
417 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
418 | + $SI->add($data); |
|
419 | + unset($data); |
|
420 | + } |
|
421 | + } |
|
422 | + $last_exec[$id]['last'] = time(); |
|
423 | 423 | } elseif ($value['format'] == 'aisnmeatxt' && |
424 | - ( |
|
424 | + ( |
|
425 | 425 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
426 | 426 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
427 | - ) |
|
427 | + ) |
|
428 | 428 | ) { |
429 | - date_default_timezone_set('CET'); |
|
430 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
431 | - date_default_timezone_set('UTC'); |
|
432 | - if ($buffer != '') $reset = 0; |
|
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
435 | - foreach ($buffer as $line) { |
|
429 | + date_default_timezone_set('CET'); |
|
430 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
431 | + date_default_timezone_set('UTC'); |
|
432 | + if ($buffer != '') $reset = 0; |
|
433 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | + $buffer = explode('\n',$buffer); |
|
435 | + foreach ($buffer as $line) { |
|
436 | 436 | if ($line != '') { |
437 | - //echo "'".$line."'\n"; |
|
438 | - $add = false; |
|
439 | - $ais_data = $AIS->parse_line(trim($line)); |
|
440 | - $data = array(); |
|
441 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
442 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
443 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
444 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
445 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
446 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
447 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
448 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
449 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
450 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
451 | - if (isset($ais_data['timestamp'])) { |
|
437 | + //echo "'".$line."'\n"; |
|
438 | + $add = false; |
|
439 | + $ais_data = $AIS->parse_line(trim($line)); |
|
440 | + $data = array(); |
|
441 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
442 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
443 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
444 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
445 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
446 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
447 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
448 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
449 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
450 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
451 | + if (isset($ais_data['timestamp'])) { |
|
452 | 452 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
453 | 453 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
454 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
455 | - $add = true; |
|
454 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
455 | + $add = true; |
|
456 | 456 | } |
457 | - } else { |
|
457 | + } else { |
|
458 | 458 | $data['datetime'] = date('Y-m-d H:i:s'); |
459 | 459 | $add = true; |
460 | - } |
|
461 | - $data['format_source'] = 'aisnmeatxt'; |
|
462 | - $data['id_source'] = $id_source; |
|
463 | - //print_r($data); |
|
464 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
465 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
466 | - unset($data); |
|
460 | + } |
|
461 | + $data['format_source'] = 'aisnmeatxt'; |
|
462 | + $data['id_source'] = $id_source; |
|
463 | + //print_r($data); |
|
464 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
465 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
466 | + unset($data); |
|
467 | 467 | } |
468 | - } |
|
469 | - $last_exec[$id]['last'] = time(); |
|
468 | + } |
|
469 | + $last_exec[$id]['last'] = time(); |
|
470 | 470 | } elseif ($value['format'] == 'aisnmeahttp') { |
471 | - $arr = $httpfeeds; |
|
472 | - $w = $e = null; |
|
471 | + $arr = $httpfeeds; |
|
472 | + $w = $e = null; |
|
473 | 473 | |
474 | - if (isset($arr[$id])) { |
|
474 | + if (isset($arr[$id])) { |
|
475 | 475 | $nn = stream_select($arr,$w,$e,$timeout); |
476 | 476 | if ($nn > 0) { |
477 | - foreach ($httpfeeds as $feed) { |
|
477 | + foreach ($httpfeeds as $feed) { |
|
478 | 478 | $buffer = stream_get_line($feed,2000,"\n"); |
479 | 479 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
480 | 480 | $buffer = explode('\n',$buffer); |
481 | 481 | foreach ($buffer as $line) { |
482 | - if ($line != '') { |
|
482 | + if ($line != '') { |
|
483 | 483 | $ais_data = $AIS->parse_line(trim($line)); |
484 | 484 | $data = array(); |
485 | 485 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -497,111 +497,111 @@ discard block |
||
497 | 497 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
498 | 498 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
499 | 499 | if (isset($ais_data['timestamp'])) { |
500 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
500 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
501 | 501 | } else { |
502 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
502 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
503 | 503 | } |
504 | 504 | $data['format_source'] = 'aisnmeahttp'; |
505 | 505 | $data['id_source'] = $id_source; |
506 | 506 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
507 | 507 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
508 | 508 | unset($data); |
509 | - } |
|
509 | + } |
|
510 | + } |
|
510 | 511 | } |
511 | - } |
|
512 | 512 | } else { |
513 | - $format = $value['format']; |
|
514 | - if (isset($tt[$format])) $tt[$format]++; |
|
515 | - else $tt[$format] = 0; |
|
516 | - if ($tt[$format] > 30) { |
|
513 | + $format = $value['format']; |
|
514 | + if (isset($tt[$format])) $tt[$format]++; |
|
515 | + else $tt[$format] = 0; |
|
516 | + if ($tt[$format] > 30) { |
|
517 | 517 | if ($globalDebug) echo 'Reconnect...'."\n"; |
518 | 518 | sleep(2); |
519 | 519 | $sourceeen[] = $value; |
520 | 520 | connect_all($sourceeen); |
521 | 521 | $sourceeen = array(); |
522 | - } |
|
522 | + } |
|
523 | + } |
|
523 | 524 | } |
524 | - } |
|
525 | 525 | } elseif ($value['format'] == 'myshiptracking' && |
526 | - ( |
|
526 | + ( |
|
527 | 527 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
528 | 528 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
529 | - ) |
|
529 | + ) |
|
530 | 530 | ) { |
531 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
532 | - if ($buffer != '') { |
|
531 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
532 | + if ($buffer != '') { |
|
533 | 533 | //echo $buffer; |
534 | 534 | $all_data = json_decode($buffer,true); |
535 | 535 | //print_r($all_data); |
536 | 536 | if (isset($all_data[0]['DATA'])) { |
537 | - foreach ($all_data[0]['DATA'] as $line) { |
|
537 | + foreach ($all_data[0]['DATA'] as $line) { |
|
538 | 538 | if ($line != '') { |
539 | - $data = array(); |
|
540 | - $data['ident'] = $line['NAME']; |
|
541 | - $data['mmsi'] = $line['MMSI']; |
|
542 | - $data['speed'] = $line['SOG']; |
|
543 | - $data['heading'] = $line['COG']; |
|
544 | - $data['latitude'] = $line['LAT']; |
|
545 | - $data['longitude'] = $line['LNG']; |
|
546 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
547 | - $data['imo'] = $line['IMO']; |
|
548 | - //$data['arrival_code'] = $ais_data['destination']; |
|
549 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
550 | - $data['format_source'] = 'myshiptracking'; |
|
551 | - $data['id_source'] = $id_source; |
|
552 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
553 | - $MI->add($data); |
|
554 | - unset($data); |
|
539 | + $data = array(); |
|
540 | + $data['ident'] = $line['NAME']; |
|
541 | + $data['mmsi'] = $line['MMSI']; |
|
542 | + $data['speed'] = $line['SOG']; |
|
543 | + $data['heading'] = $line['COG']; |
|
544 | + $data['latitude'] = $line['LAT']; |
|
545 | + $data['longitude'] = $line['LNG']; |
|
546 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
547 | + $data['imo'] = $line['IMO']; |
|
548 | + //$data['arrival_code'] = $ais_data['destination']; |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
550 | + $data['format_source'] = 'myshiptracking'; |
|
551 | + $data['id_source'] = $id_source; |
|
552 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
553 | + $MI->add($data); |
|
554 | + unset($data); |
|
555 | + } |
|
555 | 556 | } |
556 | - } |
|
557 | 557 | } |
558 | - } |
|
559 | - $last_exec[$id]['last'] = time(); |
|
558 | + } |
|
559 | + $last_exec[$id]['last'] = time(); |
|
560 | 560 | } elseif ($value['format'] == 'boatbeaconapp' && |
561 | - ( |
|
561 | + ( |
|
562 | 562 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
563 | 563 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
564 | - ) |
|
564 | + ) |
|
565 | 565 | ) { |
566 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
567 | - if ($buffer != '') { |
|
566 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
567 | + if ($buffer != '') { |
|
568 | 568 | $all_data = json_decode($buffer,true); |
569 | 569 | if (isset($all_data[0]['mmsi'])) { |
570 | - foreach ($all_data as $line) { |
|
570 | + foreach ($all_data as $line) { |
|
571 | 571 | if ($line != '') { |
572 | - $data = array(); |
|
573 | - $data['ident'] = $line['shipname']; |
|
574 | - $data['callsign'] = $line['callsign']; |
|
575 | - $data['mmsi'] = $line['mmsi']; |
|
576 | - $data['speed'] = $line['sog']; |
|
577 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
578 | - $data['latitude'] = $line['latitude']; |
|
579 | - $data['longitude'] = $line['longitude']; |
|
580 | - $data['type_id'] = $line['shiptype']; |
|
581 | - $data['arrival_code'] = $line['destination']; |
|
582 | - $data['datetime'] = $line['time']; |
|
583 | - $data['format_source'] = 'boatbeaconapp'; |
|
584 | - $data['id_source'] = $id_source; |
|
585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
586 | - $MI->add($data); |
|
587 | - unset($data); |
|
572 | + $data = array(); |
|
573 | + $data['ident'] = $line['shipname']; |
|
574 | + $data['callsign'] = $line['callsign']; |
|
575 | + $data['mmsi'] = $line['mmsi']; |
|
576 | + $data['speed'] = $line['sog']; |
|
577 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
578 | + $data['latitude'] = $line['latitude']; |
|
579 | + $data['longitude'] = $line['longitude']; |
|
580 | + $data['type_id'] = $line['shiptype']; |
|
581 | + $data['arrival_code'] = $line['destination']; |
|
582 | + $data['datetime'] = $line['time']; |
|
583 | + $data['format_source'] = 'boatbeaconapp'; |
|
584 | + $data['id_source'] = $id_source; |
|
585 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
586 | + $MI->add($data); |
|
587 | + unset($data); |
|
588 | + } |
|
588 | 589 | } |
589 | - } |
|
590 | 590 | } |
591 | 591 | |
592 | - } |
|
593 | - $last_exec[$id]['last'] = time(); |
|
592 | + } |
|
593 | + $last_exec[$id]['last'] = time(); |
|
594 | 594 | } elseif ($value['format'] == 'boatnerd' && |
595 | - ( |
|
595 | + ( |
|
596 | 596 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
597 | 597 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
598 | - ) |
|
598 | + ) |
|
599 | 599 | ) { |
600 | - $buffer = $Common->getData($value['host']); |
|
601 | - if ($buffer != '') { |
|
600 | + $buffer = $Common->getData($value['host']); |
|
601 | + if ($buffer != '') { |
|
602 | 602 | $all_data = json_decode($buffer,true); |
603 | 603 | if (isset($all_data['features'][0]['id'])) { |
604 | - foreach ($all_data['features'] as $line) { |
|
604 | + foreach ($all_data['features'] as $line) { |
|
605 | 605 | $data = array(); |
606 | 606 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
607 | 607 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -620,78 +620,78 @@ discard block |
||
620 | 620 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
621 | 621 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
622 | 622 | unset($data); |
623 | - } |
|
623 | + } |
|
624 | 624 | } |
625 | 625 | |
626 | - } |
|
627 | - $last_exec[$id]['last'] = time(); |
|
626 | + } |
|
627 | + $last_exec[$id]['last'] = time(); |
|
628 | 628 | } elseif ($value['format'] == 'shipplotter' && |
629 | - ( |
|
629 | + ( |
|
630 | 630 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
631 | 631 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
632 | - ) |
|
632 | + ) |
|
633 | 633 | ) { |
634 | - echo 'download...'; |
|
635 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
636 | - echo 'done !'."\n"; |
|
637 | - if ($buffer != '') $reset = 0; |
|
638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
639 | - $buffer = explode('\n',$buffer); |
|
640 | - foreach ($buffer as $line) { |
|
634 | + echo 'download...'; |
|
635 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
636 | + echo 'done !'."\n"; |
|
637 | + if ($buffer != '') $reset = 0; |
|
638 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
639 | + $buffer = explode('\n',$buffer); |
|
640 | + foreach ($buffer as $line) { |
|
641 | 641 | if ($line != '') { |
642 | - $data = array(); |
|
643 | - $data['mmsi'] = (int)substr($line,0,9); |
|
644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
645 | - //$data['status'] = substr($line,21,2); |
|
646 | - //$data['type'] = substr($line,24,3); |
|
647 | - $data['latitude'] = substr($line,29,9); |
|
648 | - $data['longitude'] = substr($line,41,9); |
|
649 | - $data['speed'] = round(substr($line,51,5)); |
|
650 | - //$data['course'] = substr($line,57,5); |
|
651 | - $data['heading'] = round(substr($line,63,3)); |
|
652 | - //$data['draft'] = substr($line,67,4); |
|
653 | - //$data['length'] = substr($line,72,3); |
|
654 | - //$data['beam'] = substr($line,76,2); |
|
655 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
656 | - //$data['callsign'] = trim(substr($line,100,7); |
|
657 | - //$data['dest'] = substr($line,108,20); |
|
658 | - //$data['etaDate'] = substr($line,129,5); |
|
659 | - //$data['etaTime'] = substr($line,135,5); |
|
660 | - $data['format_source'] = 'shipplotter'; |
|
661 | - $data['id_source'] = $id_source; |
|
662 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
663 | - //print_r($data); |
|
664 | - echo 'Add...'."\n"; |
|
665 | - $MI->add($data); |
|
666 | - unset($data); |
|
642 | + $data = array(); |
|
643 | + $data['mmsi'] = (int)substr($line,0,9); |
|
644 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
645 | + //$data['status'] = substr($line,21,2); |
|
646 | + //$data['type'] = substr($line,24,3); |
|
647 | + $data['latitude'] = substr($line,29,9); |
|
648 | + $data['longitude'] = substr($line,41,9); |
|
649 | + $data['speed'] = round(substr($line,51,5)); |
|
650 | + //$data['course'] = substr($line,57,5); |
|
651 | + $data['heading'] = round(substr($line,63,3)); |
|
652 | + //$data['draft'] = substr($line,67,4); |
|
653 | + //$data['length'] = substr($line,72,3); |
|
654 | + //$data['beam'] = substr($line,76,2); |
|
655 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
656 | + //$data['callsign'] = trim(substr($line,100,7); |
|
657 | + //$data['dest'] = substr($line,108,20); |
|
658 | + //$data['etaDate'] = substr($line,129,5); |
|
659 | + //$data['etaTime'] = substr($line,135,5); |
|
660 | + $data['format_source'] = 'shipplotter'; |
|
661 | + $data['id_source'] = $id_source; |
|
662 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
663 | + //print_r($data); |
|
664 | + echo 'Add...'."\n"; |
|
665 | + $MI->add($data); |
|
666 | + unset($data); |
|
667 | 667 | } |
668 | - } |
|
669 | - $last_exec[$id]['last'] = time(); |
|
668 | + } |
|
669 | + $last_exec[$id]['last'] = time(); |
|
670 | 670 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
671 | 671 | } elseif ( |
672 | - ( |
|
672 | + ( |
|
673 | 673 | $value['format'] == 'whazzup' && |
674 | 674 | ( |
675 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
676 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
675 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
676 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
677 | 677 | ) |
678 | - ) || ( |
|
678 | + ) || ( |
|
679 | 679 | $value['format'] == 'vatsimtxt' && |
680 | 680 | ( |
681 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
682 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
681 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
682 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
683 | + ) |
|
683 | 684 | ) |
684 | - ) |
|
685 | 685 | ) { |
686 | - //$buffer = $Common->getData($hosts[$id]); |
|
687 | - $buffer = $Common->getData($value['host']); |
|
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
690 | - $reset = 0; |
|
691 | - foreach ($buffer as $line) { |
|
692 | - if ($line != '') { |
|
693 | - $line = explode(':', $line); |
|
694 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
686 | + //$buffer = $Common->getData($hosts[$id]); |
|
687 | + $buffer = $Common->getData($value['host']); |
|
688 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | + $buffer = explode('\n',$buffer); |
|
690 | + $reset = 0; |
|
691 | + foreach ($buffer as $line) { |
|
692 | + if ($line != '') { |
|
693 | + $line = explode(':', $line); |
|
694 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
695 | 695 | $data = array(); |
696 | 696 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
697 | 697 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -704,37 +704,37 @@ discard block |
||
704 | 704 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
705 | 705 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
706 | 706 | $data['latitude'] = $line[5]; // lat |
707 | - $data['longitude'] = $line[6]; // long |
|
708 | - $data['verticalrate'] = ''; // vertical rate |
|
709 | - $data['squawk'] = ''; // squawk |
|
710 | - $data['emergency'] = ''; // emergency |
|
711 | - $data['waypoints'] = $line[30]; |
|
707 | + $data['longitude'] = $line[6]; // long |
|
708 | + $data['verticalrate'] = ''; // vertical rate |
|
709 | + $data['squawk'] = ''; // squawk |
|
710 | + $data['emergency'] = ''; // emergency |
|
711 | + $data['waypoints'] = $line[30]; |
|
712 | 712 | $data['datetime'] = date('Y-m-d H:i:s'); |
713 | 713 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
714 | 714 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
715 | - $data['departure_airport_icao'] = $line[11]; |
|
716 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
717 | - $data['arrival_airport_icao'] = $line[13]; |
|
715 | + $data['departure_airport_icao'] = $line[11]; |
|
716 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
717 | + $data['arrival_airport_icao'] = $line[13]; |
|
718 | 718 | $data['frequency'] = $line[4]; |
719 | 719 | $data['type'] = $line[18]; |
720 | 720 | $data['range'] = $line[19]; |
721 | 721 | if (isset($line[35])) $data['info'] = $line[35]; |
722 | - $data['id_source'] = $id_source; |
|
723 | - //$data['arrival_airport_time'] = ; |
|
724 | - if ($line[9] != '') { |
|
725 | - $aircraft_data = explode('/',$line[9]); |
|
726 | - if (isset($aircraft_data[1])) { |
|
727 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
728 | - } |
|
729 | - } |
|
730 | - /* |
|
722 | + $data['id_source'] = $id_source; |
|
723 | + //$data['arrival_airport_time'] = ; |
|
724 | + if ($line[9] != '') { |
|
725 | + $aircraft_data = explode('/',$line[9]); |
|
726 | + if (isset($aircraft_data[1])) { |
|
727 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
728 | + } |
|
729 | + } |
|
730 | + /* |
|
731 | 731 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
732 | 732 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
733 | 733 | */ |
734 | - $data['format_source'] = $value['format']; |
|
734 | + $data['format_source'] = $value['format']; |
|
735 | 735 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
736 | 736 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
737 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
737 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
738 | 738 | elseif ($line[3] == 'ATC') { |
739 | 739 | //print_r($data); |
740 | 740 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -755,21 +755,21 @@ discard block |
||
755 | 755 | 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']); |
756 | 756 | } |
757 | 757 | } |
758 | - unset($data); |
|
759 | - } |
|
760 | - } |
|
761 | - } |
|
762 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
763 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
764 | - $last_exec[$id]['last'] = time(); |
|
765 | - } elseif ($value['format'] == 'airwhere' && |
|
766 | - ( |
|
767 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
768 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
769 | - ) |
|
770 | - ) { |
|
771 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
772 | - if ($buffer != '') { |
|
758 | + unset($data); |
|
759 | + } |
|
760 | + } |
|
761 | + } |
|
762 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
763 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
764 | + $last_exec[$id]['last'] = time(); |
|
765 | + } elseif ($value['format'] == 'airwhere' && |
|
766 | + ( |
|
767 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
768 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
769 | + ) |
|
770 | + ) { |
|
771 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
772 | + if ($buffer != '') { |
|
773 | 773 | $all_data = simplexml_load_string($buffer); |
774 | 774 | foreach($all_data->children() as $childdata) { |
775 | 775 | $data = array(); |
@@ -791,10 +791,10 @@ discard block |
||
791 | 791 | $SI->add($data); |
792 | 792 | unset($data); |
793 | 793 | } |
794 | - } |
|
795 | - $Source->deleteOldLocationByType('gs'); |
|
796 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
797 | - if ($buffer != '') { |
|
794 | + } |
|
795 | + $Source->deleteOldLocationByType('gs'); |
|
796 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
797 | + if ($buffer != '') { |
|
798 | 798 | $all_data = simplexml_load_string($buffer); |
799 | 799 | foreach($all_data->children() as $childdata) { |
800 | 800 | $data = array(); |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | } |
813 | 813 | unset($data); |
814 | 814 | } |
815 | - } |
|
816 | - $last_exec[$id]['last'] = time(); |
|
815 | + } |
|
816 | + $last_exec[$id]['last'] = time(); |
|
817 | 817 | /* |
818 | 818 | } if ($value['format'] == 'aircraftlistjson') { |
819 | 819 | print_r($globalSources); |
@@ -821,17 +821,17 @@ discard block |
||
821 | 821 | echo $globalMinFetch; |
822 | 822 | */ |
823 | 823 | } elseif ($value['format'] == 'aircraftlistjson' && |
824 | - ( |
|
824 | + ( |
|
825 | 825 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
826 | 826 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
827 | - ) |
|
827 | + ) |
|
828 | 828 | ) { |
829 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
830 | - if ($buffer != '') { |
|
831 | - $all_data = json_decode($buffer,true); |
|
829 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
830 | + if ($buffer != '') { |
|
831 | + $all_data = json_decode($buffer,true); |
|
832 | 832 | if (isset($all_data['acList'])) { |
833 | - $reset = 0; |
|
834 | - foreach ($all_data['acList'] as $line) { |
|
833 | + $reset = 0; |
|
834 | + foreach ($all_data['acList'] as $line) { |
|
835 | 835 | $data = array(); |
836 | 836 | $data['hex'] = $line['Icao']; // hex |
837 | 837 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -854,10 +854,10 @@ discard block |
||
854 | 854 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
855 | 855 | if (isset($data['latitude'])) $SI->add($data); |
856 | 856 | unset($data); |
857 | - } |
|
857 | + } |
|
858 | 858 | } elseif (is_array($all_data)) { |
859 | - $reset = 0; |
|
860 | - foreach ($all_data as $line) { |
|
859 | + $reset = 0; |
|
860 | + foreach ($all_data as $line) { |
|
861 | 861 | $data = array(); |
862 | 862 | $data['hex'] = $line['hex']; // hex |
863 | 863 | $data['ident'] = $line['flight']; // ident |
@@ -877,218 +877,218 @@ discard block |
||
877 | 877 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
878 | 878 | $SI->add($data); |
879 | 879 | unset($data); |
880 | - } |
|
880 | + } |
|
881 | 881 | } |
882 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
883 | - //$last_exec['aircraftlistjson'] = time(); |
|
884 | - $last_exec[$id]['last'] = time(); |
|
885 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
886 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
887 | - ( |
|
888 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
889 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
890 | - ) |
|
891 | - ) { |
|
892 | - $buffer = $Common->getData($value['host']); |
|
893 | - $all_data = json_decode($buffer,true); |
|
894 | - if (isset($all_data['planes'])) { |
|
882 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
883 | + //$last_exec['aircraftlistjson'] = time(); |
|
884 | + $last_exec[$id]['last'] = time(); |
|
885 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
886 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
887 | + ( |
|
888 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
889 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
890 | + ) |
|
891 | + ) { |
|
892 | + $buffer = $Common->getData($value['host']); |
|
893 | + $all_data = json_decode($buffer,true); |
|
894 | + if (isset($all_data['planes'])) { |
|
895 | 895 | $reset = 0; |
896 | 896 | foreach ($all_data['planes'] as $key => $line) { |
897 | - $data = array(); |
|
898 | - $data['hex'] = $key; // hex |
|
899 | - $data['ident'] = $line[3]; // ident |
|
900 | - $data['altitude'] = $line[6]; // altitude |
|
901 | - $data['speed'] = $line[8]; // speed |
|
902 | - $data['heading'] = $line[7]; // heading |
|
903 | - $data['latitude'] = $line[4]; // lat |
|
904 | - $data['longitude'] = $line[5]; // long |
|
905 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
906 | - $data['squawk'] = $line[10]; // squawk |
|
907 | - $data['emergency'] = ''; // emergency |
|
908 | - $data['registration'] = $line[2]; |
|
909 | - $data['aircraft_icao'] = $line[0]; |
|
910 | - $deparr = explode('-',$line[1]); |
|
911 | - if (count($deparr) == 2) { |
|
897 | + $data = array(); |
|
898 | + $data['hex'] = $key; // hex |
|
899 | + $data['ident'] = $line[3]; // ident |
|
900 | + $data['altitude'] = $line[6]; // altitude |
|
901 | + $data['speed'] = $line[8]; // speed |
|
902 | + $data['heading'] = $line[7]; // heading |
|
903 | + $data['latitude'] = $line[4]; // lat |
|
904 | + $data['longitude'] = $line[5]; // long |
|
905 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
906 | + $data['squawk'] = $line[10]; // squawk |
|
907 | + $data['emergency'] = ''; // emergency |
|
908 | + $data['registration'] = $line[2]; |
|
909 | + $data['aircraft_icao'] = $line[0]; |
|
910 | + $deparr = explode('-',$line[1]); |
|
911 | + if (count($deparr) == 2) { |
|
912 | 912 | $data['departure_airport_icao'] = $deparr[0]; |
913 | 913 | $data['arrival_airport_icao'] = $deparr[1]; |
914 | - } |
|
915 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
916 | - $data['format_source'] = 'planeupdatefaa'; |
|
917 | - $data['id_source'] = $id_source; |
|
918 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
919 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
920 | - $SI->add($data); |
|
921 | - unset($data); |
|
914 | + } |
|
915 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
916 | + $data['format_source'] = 'planeupdatefaa'; |
|
917 | + $data['id_source'] = $id_source; |
|
918 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
919 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
920 | + $SI->add($data); |
|
921 | + unset($data); |
|
922 | + } |
|
922 | 923 | } |
923 | - } |
|
924 | - //$last_exec['planeupdatefaa'] = time(); |
|
925 | - $last_exec[$id]['last'] = time(); |
|
924 | + //$last_exec['planeupdatefaa'] = time(); |
|
925 | + $last_exec[$id]['last'] = time(); |
|
926 | 926 | } elseif ($value['format'] == 'opensky' && |
927 | - ( |
|
927 | + ( |
|
928 | 928 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
929 | 929 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
930 | - ) |
|
930 | + ) |
|
931 | 931 | ) { |
932 | - $buffer = $Common->getData($value['host']); |
|
933 | - $all_data = json_decode($buffer,true); |
|
934 | - if (isset($all_data['states'])) { |
|
932 | + $buffer = $Common->getData($value['host']); |
|
933 | + $all_data = json_decode($buffer,true); |
|
934 | + if (isset($all_data['states'])) { |
|
935 | 935 | $reset = 0; |
936 | 936 | foreach ($all_data['states'] as $key => $line) { |
937 | - $data = array(); |
|
938 | - $data['hex'] = $line[0]; // hex |
|
939 | - $data['ident'] = trim($line[1]); // ident |
|
940 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
941 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
942 | - $data['heading'] = round($line[10]); // heading |
|
943 | - $data['latitude'] = $line[6]; // lat |
|
944 | - $data['longitude'] = $line[5]; // long |
|
945 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
946 | - //$data['squawk'] = $line[10]; // squawk |
|
947 | - //$data['emergency'] = ''; // emergency |
|
948 | - //$data['registration'] = $line[2]; |
|
949 | - //$data['aircraft_icao'] = $line[0]; |
|
950 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
951 | - $data['format_source'] = 'opensky'; |
|
952 | - $data['id_source'] = $id_source; |
|
953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
954 | - $SI->add($data); |
|
955 | - unset($data); |
|
937 | + $data = array(); |
|
938 | + $data['hex'] = $line[0]; // hex |
|
939 | + $data['ident'] = trim($line[1]); // ident |
|
940 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
941 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
942 | + $data['heading'] = round($line[10]); // heading |
|
943 | + $data['latitude'] = $line[6]; // lat |
|
944 | + $data['longitude'] = $line[5]; // long |
|
945 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
946 | + //$data['squawk'] = $line[10]; // squawk |
|
947 | + //$data['emergency'] = ''; // emergency |
|
948 | + //$data['registration'] = $line[2]; |
|
949 | + //$data['aircraft_icao'] = $line[0]; |
|
950 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
951 | + $data['format_source'] = 'opensky'; |
|
952 | + $data['id_source'] = $id_source; |
|
953 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
954 | + $SI->add($data); |
|
955 | + unset($data); |
|
956 | 956 | } |
957 | - } |
|
958 | - //$last_exec['planeupdatefaa'] = time(); |
|
959 | - $last_exec[$id]['last'] = time(); |
|
957 | + } |
|
958 | + //$last_exec['planeupdatefaa'] = time(); |
|
959 | + $last_exec[$id]['last'] = time(); |
|
960 | 960 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
961 | 961 | } elseif ($value['format'] == 'fr24json' && |
962 | - ( |
|
962 | + ( |
|
963 | 963 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
964 | 964 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
965 | - ) |
|
965 | + ) |
|
966 | 966 | ) { |
967 | - //$buffer = $Common->getData($hosts[$id]); |
|
968 | - $buffer = $Common->getData($value['host']); |
|
969 | - $all_data = json_decode($buffer,true); |
|
970 | - if (!empty($all_data)) $reset = 0; |
|
971 | - foreach ($all_data as $key => $line) { |
|
967 | + //$buffer = $Common->getData($hosts[$id]); |
|
968 | + $buffer = $Common->getData($value['host']); |
|
969 | + $all_data = json_decode($buffer,true); |
|
970 | + if (!empty($all_data)) $reset = 0; |
|
971 | + foreach ($all_data as $key => $line) { |
|
972 | 972 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
973 | - $data = array(); |
|
974 | - $data['hex'] = $line[0]; |
|
975 | - $data['ident'] = $line[16]; //$line[13] |
|
976 | - $data['altitude'] = $line[4]; // altitude |
|
977 | - $data['speed'] = $line[5]; // speed |
|
978 | - $data['heading'] = $line[3]; // heading |
|
979 | - $data['latitude'] = $line[1]; // lat |
|
980 | - $data['longitude'] = $line[2]; // long |
|
981 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
982 | - $data['squawk'] = $line[6]; // squawk |
|
983 | - $data['aircraft_icao'] = $line[8]; |
|
984 | - $data['registration'] = $line[9]; |
|
985 | - $data['departure_airport_iata'] = $line[11]; |
|
986 | - $data['arrival_airport_iata'] = $line[12]; |
|
987 | - $data['emergency'] = ''; // emergency |
|
988 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
989 | - $data['format_source'] = 'fr24json'; |
|
990 | - $data['id_source'] = $id_source; |
|
991 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | - $SI->add($data); |
|
994 | - unset($data); |
|
973 | + $data = array(); |
|
974 | + $data['hex'] = $line[0]; |
|
975 | + $data['ident'] = $line[16]; //$line[13] |
|
976 | + $data['altitude'] = $line[4]; // altitude |
|
977 | + $data['speed'] = $line[5]; // speed |
|
978 | + $data['heading'] = $line[3]; // heading |
|
979 | + $data['latitude'] = $line[1]; // lat |
|
980 | + $data['longitude'] = $line[2]; // long |
|
981 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
982 | + $data['squawk'] = $line[6]; // squawk |
|
983 | + $data['aircraft_icao'] = $line[8]; |
|
984 | + $data['registration'] = $line[9]; |
|
985 | + $data['departure_airport_iata'] = $line[11]; |
|
986 | + $data['arrival_airport_iata'] = $line[12]; |
|
987 | + $data['emergency'] = ''; // emergency |
|
988 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
989 | + $data['format_source'] = 'fr24json'; |
|
990 | + $data['id_source'] = $id_source; |
|
991 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
992 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | + $SI->add($data); |
|
994 | + unset($data); |
|
995 | 995 | } |
996 | - } |
|
997 | - //$last_exec['fr24json'] = time(); |
|
998 | - $last_exec[$id]['last'] = time(); |
|
996 | + } |
|
997 | + //$last_exec['fr24json'] = time(); |
|
998 | + $last_exec[$id]['last'] = time(); |
|
999 | 999 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1000 | 1000 | } elseif ($value['format'] == 'radarvirtueljson' && |
1001 | - ( |
|
1001 | + ( |
|
1002 | 1002 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1003 | 1003 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1004 | - ) |
|
1004 | + ) |
|
1005 | 1005 | ) { |
1006 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1007 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1008 | - //echo $buffer; |
|
1009 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1010 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1011 | - $all_data = json_decode($buffer,true); |
|
1012 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1006 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1007 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1008 | + //echo $buffer; |
|
1009 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1010 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1011 | + $all_data = json_decode($buffer,true); |
|
1012 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1013 | 1013 | die(json_last_error_msg()); |
1014 | - } |
|
1015 | - if (isset($all_data['mrkrs'])) { |
|
1014 | + } |
|
1015 | + if (isset($all_data['mrkrs'])) { |
|
1016 | 1016 | $reset = 0; |
1017 | 1017 | foreach ($all_data['mrkrs'] as $key => $line) { |
1018 | - if (isset($line['inf'])) { |
|
1018 | + if (isset($line['inf'])) { |
|
1019 | 1019 | $data = array(); |
1020 | 1020 | $data['hex'] = $line['inf']['ia']; |
1021 | 1021 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1022 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1023 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1024 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1025 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1026 | - $data['longitude'] = $line['pt'][1]; // long |
|
1027 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1028 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1029 | - //$data['aircraft_icao'] = $line[8]; |
|
1030 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1022 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1023 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1024 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1025 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1026 | + $data['longitude'] = $line['pt'][1]; // long |
|
1027 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1028 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1029 | + //$data['aircraft_icao'] = $line[8]; |
|
1030 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1031 | 1031 | //$data['departure_airport_iata'] = $line[11]; |
1032 | 1032 | //$data['arrival_airport_iata'] = $line[12]; |
1033 | - //$data['emergency'] = ''; // emergency |
|
1033 | + //$data['emergency'] = ''; // emergency |
|
1034 | 1034 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1035 | - $data['format_source'] = 'radarvirtueljson'; |
|
1036 | - $data['id_source'] = $id_source; |
|
1035 | + $data['format_source'] = 'radarvirtueljson'; |
|
1036 | + $data['id_source'] = $id_source; |
|
1037 | 1037 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1038 | 1038 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1039 | 1039 | $SI->add($data); |
1040 | 1040 | unset($data); |
1041 | - } |
|
1041 | + } |
|
1042 | + } |
|
1042 | 1043 | } |
1043 | - } |
|
1044 | - //$last_exec['radarvirtueljson'] = time(); |
|
1045 | - $last_exec[$id]['last'] = time(); |
|
1044 | + //$last_exec['radarvirtueljson'] = time(); |
|
1045 | + $last_exec[$id]['last'] = time(); |
|
1046 | 1046 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1047 | 1047 | } elseif ($value['format'] == 'pirepsjson' && |
1048 | - ( |
|
1048 | + ( |
|
1049 | 1049 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1050 | 1050 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1051 | - ) |
|
1051 | + ) |
|
1052 | 1052 | ) { |
1053 | - //$buffer = $Common->getData($hosts[$id]); |
|
1054 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1055 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1053 | + //$buffer = $Common->getData($hosts[$id]); |
|
1054 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1055 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1056 | 1056 | |
1057 | - if (isset($all_data['pireps'])) { |
|
1057 | + if (isset($all_data['pireps'])) { |
|
1058 | 1058 | $reset = 0; |
1059 | - foreach ($all_data['pireps'] as $line) { |
|
1060 | - $data = array(); |
|
1061 | - $data['id'] = $line['id']; |
|
1062 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1063 | - $data['ident'] = $line['callsign']; // ident |
|
1064 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1065 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1066 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1067 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1068 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1069 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1070 | - $data['latitude'] = $line['lat']; // lat |
|
1071 | - $data['longitude'] = $line['lon']; // long |
|
1072 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1073 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1074 | - //$data['emergency'] = ''; // emergency |
|
1075 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1076 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1077 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1078 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1079 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1080 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1081 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1082 | - else $data['info'] = ''; |
|
1083 | - $data['format_source'] = 'pireps'; |
|
1084 | - $data['id_source'] = $id_source; |
|
1085 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1086 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1087 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1088 | - if ($line['icon'] == 'plane') { |
|
1059 | + foreach ($all_data['pireps'] as $line) { |
|
1060 | + $data = array(); |
|
1061 | + $data['id'] = $line['id']; |
|
1062 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1063 | + $data['ident'] = $line['callsign']; // ident |
|
1064 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1065 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1066 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1067 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1068 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1069 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1070 | + $data['latitude'] = $line['lat']; // lat |
|
1071 | + $data['longitude'] = $line['lon']; // long |
|
1072 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1073 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1074 | + //$data['emergency'] = ''; // emergency |
|
1075 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1076 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1077 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1078 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1079 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1080 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1081 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1082 | + else $data['info'] = ''; |
|
1083 | + $data['format_source'] = 'pireps'; |
|
1084 | + $data['id_source'] = $id_source; |
|
1085 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1086 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1087 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1088 | + if ($line['icon'] == 'plane') { |
|
1089 | 1089 | $SI->add($data); |
1090 | - // print_r($data); |
|
1091 | - } elseif ($line['icon'] == 'ct') { |
|
1090 | + // print_r($data); |
|
1091 | + } elseif ($line['icon'] == 'ct') { |
|
1092 | 1092 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1093 | 1093 | $data['info'] = str_replace('&sect;','',$data['info']); |
1094 | 1094 | $typec = substr($data['ident'],-3); |
@@ -1103,148 +1103,148 @@ discard block |
||
1103 | 1103 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1104 | 1104 | else $data['type'] = 'Observer'; |
1105 | 1105 | 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']); |
1106 | - } |
|
1107 | - unset($data); |
|
1106 | + } |
|
1107 | + unset($data); |
|
1108 | + } |
|
1108 | 1109 | } |
1109 | - } |
|
1110 | - //$last_exec['pirepsjson'] = time(); |
|
1111 | - $last_exec[$id]['last'] = time(); |
|
1110 | + //$last_exec['pirepsjson'] = time(); |
|
1111 | + $last_exec[$id]['last'] = time(); |
|
1112 | 1112 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1113 | 1113 | } elseif ($value['format'] == 'phpvmacars' && |
1114 | - ( |
|
1114 | + ( |
|
1115 | 1115 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1116 | 1116 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1117 | - ) |
|
1117 | + ) |
|
1118 | 1118 | ) { |
1119 | - //$buffer = $Common->getData($hosts[$id]); |
|
1120 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1121 | - $buffer = $Common->getData($value['host']); |
|
1122 | - $all_data = json_decode($buffer,true); |
|
1123 | - if ($buffer != '' && is_array($all_data)) { |
|
1119 | + //$buffer = $Common->getData($hosts[$id]); |
|
1120 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1121 | + $buffer = $Common->getData($value['host']); |
|
1122 | + $all_data = json_decode($buffer,true); |
|
1123 | + if ($buffer != '' && is_array($all_data)) { |
|
1124 | 1124 | $reset = 0; |
1125 | 1125 | foreach ($all_data as $line) { |
1126 | - $data = array(); |
|
1127 | - //$data['id'] = $line['id']; // id not usable |
|
1128 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1129 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1130 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1131 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1132 | - $data['ident'] = $line['flightnum']; // ident |
|
1133 | - $data['altitude'] = $line['alt']; // altitude |
|
1134 | - $data['speed'] = $line['gs']; // speed |
|
1135 | - $data['heading'] = $line['heading']; // heading |
|
1136 | - $data['latitude'] = $line['lat']; // lat |
|
1137 | - $data['longitude'] = $line['lng']; // long |
|
1138 | - $data['verticalrate'] = ''; // verticale rate |
|
1139 | - $data['squawk'] = ''; // squawk |
|
1140 | - $data['emergency'] = ''; // emergency |
|
1141 | - //$data['datetime'] = $line['lastupdate']; |
|
1142 | - //$data['last_update'] = $line['lastupdate']; |
|
1143 | - if (isset($value['timezone'])) { |
|
1144 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1145 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1146 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1147 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1148 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1149 | - $data['departure_airport_time'] = $line['deptime']; |
|
1150 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1151 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1152 | - $data['registration'] = $line['aircraft']; |
|
1153 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1154 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1155 | - if (isset($line['aircraftname'])) { |
|
1126 | + $data = array(); |
|
1127 | + //$data['id'] = $line['id']; // id not usable |
|
1128 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1129 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1130 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1131 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1132 | + $data['ident'] = $line['flightnum']; // ident |
|
1133 | + $data['altitude'] = $line['alt']; // altitude |
|
1134 | + $data['speed'] = $line['gs']; // speed |
|
1135 | + $data['heading'] = $line['heading']; // heading |
|
1136 | + $data['latitude'] = $line['lat']; // lat |
|
1137 | + $data['longitude'] = $line['lng']; // long |
|
1138 | + $data['verticalrate'] = ''; // verticale rate |
|
1139 | + $data['squawk'] = ''; // squawk |
|
1140 | + $data['emergency'] = ''; // emergency |
|
1141 | + //$data['datetime'] = $line['lastupdate']; |
|
1142 | + //$data['last_update'] = $line['lastupdate']; |
|
1143 | + if (isset($value['timezone'])) { |
|
1144 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1145 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1146 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1147 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1148 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1149 | + $data['departure_airport_time'] = $line['deptime']; |
|
1150 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1151 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1152 | + $data['registration'] = $line['aircraft']; |
|
1153 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1154 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1155 | + if (isset($line['aircraftname'])) { |
|
1156 | 1156 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1157 | 1157 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1158 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1159 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1160 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1161 | - else { |
|
1162 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1165 | - } |
|
1166 | - } |
|
1167 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1168 | - $data['id_source'] = $id_source; |
|
1169 | - $data['format_source'] = 'phpvmacars'; |
|
1170 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1171 | - $SI->add($data); |
|
1172 | - unset($data); |
|
1158 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1159 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1160 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1161 | + else { |
|
1162 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1163 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1165 | + } |
|
1166 | + } |
|
1167 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1168 | + $data['id_source'] = $id_source; |
|
1169 | + $data['format_source'] = 'phpvmacars'; |
|
1170 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1171 | + $SI->add($data); |
|
1172 | + unset($data); |
|
1173 | 1173 | } |
1174 | 1174 | if ($globalDebug) echo 'No more data...'."\n"; |
1175 | 1175 | unset($buffer); |
1176 | 1176 | unset($all_data); |
1177 | - } |
|
1178 | - //$last_exec['phpvmacars'] = time(); |
|
1179 | - $last_exec[$id]['last'] = time(); |
|
1177 | + } |
|
1178 | + //$last_exec['phpvmacars'] = time(); |
|
1179 | + $last_exec[$id]['last'] = time(); |
|
1180 | 1180 | } elseif ($value['format'] == 'vam' && |
1181 | - ( |
|
1181 | + ( |
|
1182 | 1182 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1183 | 1183 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1184 | - ) |
|
1184 | + ) |
|
1185 | 1185 | ) { |
1186 | - //$buffer = $Common->getData($hosts[$id]); |
|
1187 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1188 | - $buffer = $Common->getData($value['host']); |
|
1189 | - $all_data = json_decode($buffer,true); |
|
1190 | - if ($buffer != '' && is_array($all_data)) { |
|
1186 | + //$buffer = $Common->getData($hosts[$id]); |
|
1187 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1188 | + $buffer = $Common->getData($value['host']); |
|
1189 | + $all_data = json_decode($buffer,true); |
|
1190 | + if ($buffer != '' && is_array($all_data)) { |
|
1191 | 1191 | $reset = 0; |
1192 | 1192 | foreach ($all_data as $line) { |
1193 | - $data = array(); |
|
1194 | - //$data['id'] = $line['id']; // id not usable |
|
1195 | - $data['id'] = trim($line['flight_id']); |
|
1196 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1197 | - $data['pilot_name'] = $line['pilot_name']; |
|
1198 | - $data['pilot_id'] = $line['pilot_id']; |
|
1199 | - $data['ident'] = trim($line['callsign']); // ident |
|
1200 | - $data['altitude'] = $line['altitude']; // altitude |
|
1201 | - $data['speed'] = $line['gs']; // speed |
|
1202 | - $data['heading'] = $line['heading']; // heading |
|
1203 | - $data['latitude'] = $line['latitude']; // lat |
|
1204 | - $data['longitude'] = $line['longitude']; // long |
|
1205 | - $data['verticalrate'] = ''; // verticale rate |
|
1206 | - $data['squawk'] = ''; // squawk |
|
1207 | - $data['emergency'] = ''; // emergency |
|
1208 | - //$data['datetime'] = $line['lastupdate']; |
|
1209 | - $data['last_update'] = $line['last_update']; |
|
1210 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1211 | - $data['departure_airport_icao'] = $line['departure']; |
|
1212 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1213 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1214 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1215 | - //$data['registration'] = $line['aircraft']; |
|
1216 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1217 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1218 | - $data['id_source'] = $id_source; |
|
1219 | - $data['format_source'] = 'vam'; |
|
1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1222 | - $SI->add($data); |
|
1223 | - unset($data); |
|
1193 | + $data = array(); |
|
1194 | + //$data['id'] = $line['id']; // id not usable |
|
1195 | + $data['id'] = trim($line['flight_id']); |
|
1196 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1197 | + $data['pilot_name'] = $line['pilot_name']; |
|
1198 | + $data['pilot_id'] = $line['pilot_id']; |
|
1199 | + $data['ident'] = trim($line['callsign']); // ident |
|
1200 | + $data['altitude'] = $line['altitude']; // altitude |
|
1201 | + $data['speed'] = $line['gs']; // speed |
|
1202 | + $data['heading'] = $line['heading']; // heading |
|
1203 | + $data['latitude'] = $line['latitude']; // lat |
|
1204 | + $data['longitude'] = $line['longitude']; // long |
|
1205 | + $data['verticalrate'] = ''; // verticale rate |
|
1206 | + $data['squawk'] = ''; // squawk |
|
1207 | + $data['emergency'] = ''; // emergency |
|
1208 | + //$data['datetime'] = $line['lastupdate']; |
|
1209 | + $data['last_update'] = $line['last_update']; |
|
1210 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1211 | + $data['departure_airport_icao'] = $line['departure']; |
|
1212 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1213 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1214 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1215 | + //$data['registration'] = $line['aircraft']; |
|
1216 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1217 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1218 | + $data['id_source'] = $id_source; |
|
1219 | + $data['format_source'] = 'vam'; |
|
1220 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1222 | + $SI->add($data); |
|
1223 | + unset($data); |
|
1224 | 1224 | } |
1225 | 1225 | if ($globalDebug) echo 'No more data...'."\n"; |
1226 | 1226 | unset($buffer); |
1227 | 1227 | unset($all_data); |
1228 | - } |
|
1229 | - //$last_exec['phpvmacars'] = time(); |
|
1230 | - $last_exec[$id]['last'] = time(); |
|
1228 | + } |
|
1229 | + //$last_exec['phpvmacars'] = time(); |
|
1230 | + $last_exec[$id]['last'] = time(); |
|
1231 | 1231 | } elseif ($value['format'] == 'blitzortung' && |
1232 | - ( |
|
1232 | + ( |
|
1233 | 1233 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1234 | 1234 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1235 | - ) |
|
1235 | + ) |
|
1236 | 1236 | ) { |
1237 | - //$buffer = $Common->getData($hosts[$id]); |
|
1238 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1239 | - $buffer = $Common->getData($value['host']); |
|
1240 | - $all_data = json_decode($buffer,true); |
|
1241 | - if ($buffer != '') { |
|
1237 | + //$buffer = $Common->getData($hosts[$id]); |
|
1238 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1239 | + $buffer = $Common->getData($value['host']); |
|
1240 | + $all_data = json_decode($buffer,true); |
|
1241 | + if ($buffer != '') { |
|
1242 | 1242 | $Source->deleteLocationBySource('blitzortung'); |
1243 | 1243 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1244 | 1244 | $buffer = explode('\n',$buffer); |
1245 | 1245 | foreach ($buffer as $buffer_line) { |
1246 | - $line = json_decode($buffer_line,true); |
|
1247 | - if (isset($line['time'])) { |
|
1246 | + $line = json_decode($buffer_line,true); |
|
1247 | + if (isset($line['time'])) { |
|
1248 | 1248 | $data = array(); |
1249 | 1249 | $data['altitude'] = $line['alt']; // altitude |
1250 | 1250 | $data['latitude'] = $line['lat']; // lat |
@@ -1256,94 +1256,94 @@ discard block |
||
1256 | 1256 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1257 | 1257 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1258 | 1258 | unset($data); |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | } |
1261 | 1261 | if ($globalDebug) echo 'No more data...'."\n"; |
1262 | 1262 | unset($buffer); |
1263 | - } |
|
1264 | - $last_exec[$id]['last'] = time(); |
|
1263 | + } |
|
1264 | + $last_exec[$id]['last'] = time(); |
|
1265 | 1265 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1266 | 1266 | } 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') { |
1267 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1268 | - //$last_exec[$id]['last'] = time(); |
|
1267 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1268 | + //$last_exec[$id]['last'] = time(); |
|
1269 | 1269 | |
1270 | - //$read = array( $sockets[$id] ); |
|
1271 | - $read = $sockets; |
|
1272 | - $write = NULL; |
|
1273 | - $e = NULL; |
|
1274 | - $n = socket_select($read, $write, $e, $timeout); |
|
1275 | - if ($e != NULL) var_dump($e); |
|
1276 | - if ($n > 0) { |
|
1270 | + //$read = array( $sockets[$id] ); |
|
1271 | + $read = $sockets; |
|
1272 | + $write = NULL; |
|
1273 | + $e = NULL; |
|
1274 | + $n = socket_select($read, $write, $e, $timeout); |
|
1275 | + if ($e != NULL) var_dump($e); |
|
1276 | + if ($n > 0) { |
|
1277 | 1277 | $reset = 0; |
1278 | 1278 | foreach ($read as $nb => $r) { |
1279 | - //$value = $formats[$nb]; |
|
1280 | - $format = $globalSources[$nb]['format']; |
|
1281 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1279 | + //$value = $formats[$nb]; |
|
1280 | + $format = $globalSources[$nb]['format']; |
|
1281 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1282 | 1282 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1283 | - } elseif ($format == 'vrstcp') { |
|
1283 | + } elseif ($format == 'vrstcp') { |
|
1284 | 1284 | $buffer = @socket_read($r, 6000); |
1285 | - } else { |
|
1285 | + } else { |
|
1286 | 1286 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1287 | - } |
|
1288 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1289 | - //echo $buffer."\n"; |
|
1290 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1291 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1292 | - $error = false; |
|
1293 | - //$SI::del(); |
|
1294 | - if ($format == 'vrstcp') { |
|
1287 | + } |
|
1288 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1289 | + //echo $buffer."\n"; |
|
1290 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1291 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1292 | + $error = false; |
|
1293 | + //$SI::del(); |
|
1294 | + if ($format == 'vrstcp') { |
|
1295 | 1295 | $buffer = explode('},{',$buffer); |
1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1297 | - // SBS format is CSV format |
|
1298 | - if ($buffer !== FALSE && $buffer != '') { |
|
1296 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1297 | + // SBS format is CSV format |
|
1298 | + if ($buffer !== FALSE && $buffer != '') { |
|
1299 | 1299 | $tt[$format] = 0; |
1300 | 1300 | if ($format == 'acarssbs3') { |
1301 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1302 | - $ACARS->add(trim($buffer)); |
|
1303 | - $ACARS->deleteLiveAcarsData(); |
|
1301 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1302 | + $ACARS->add(trim($buffer)); |
|
1303 | + $ACARS->deleteLiveAcarsData(); |
|
1304 | 1304 | } elseif ($format == 'raw') { |
1305 | - // AVR format |
|
1306 | - $data = $SBS->parse($buffer); |
|
1307 | - if (is_array($data)) { |
|
1305 | + // AVR format |
|
1306 | + $data = $SBS->parse($buffer); |
|
1307 | + if (is_array($data)) { |
|
1308 | 1308 | $data['datetime'] = date('Y-m-d H:i:s'); |
1309 | 1309 | $data['format_source'] = 'raw'; |
1310 | 1310 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1311 | 1311 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1312 | 1312 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1313 | 1313 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1314 | - } |
|
1314 | + } |
|
1315 | 1315 | } elseif ($format == 'ais') { |
1316 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1317 | - $data = array(); |
|
1318 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1319 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1320 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1321 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1322 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1323 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1324 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1325 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1326 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1327 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1328 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1329 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1331 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1332 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1333 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1316 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1317 | + $data = array(); |
|
1318 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1319 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1320 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1321 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1322 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1323 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1324 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1325 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1326 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1327 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1328 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1329 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1330 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1331 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1332 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1333 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1334 | 1334 | |
1335 | - if (isset($ais_data['timestamp'])) { |
|
1335 | + if (isset($ais_data['timestamp'])) { |
|
1336 | 1336 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1337 | - } else { |
|
1337 | + } else { |
|
1338 | 1338 | $data['datetime'] = date('Y-m-d H:i:s'); |
1339 | - } |
|
1340 | - $data['format_source'] = 'aisnmea'; |
|
1341 | - $data['id_source'] = $id_source; |
|
1342 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1343 | - unset($data); |
|
1344 | - } elseif ($format == 'flightgearsp') { |
|
1345 | - //echo $buffer."\n"; |
|
1346 | - if (strlen($buffer) > 5) { |
|
1339 | + } |
|
1340 | + $data['format_source'] = 'aisnmea'; |
|
1341 | + $data['id_source'] = $id_source; |
|
1342 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1343 | + unset($data); |
|
1344 | + } elseif ($format == 'flightgearsp') { |
|
1345 | + //echo $buffer."\n"; |
|
1346 | + if (strlen($buffer) > 5) { |
|
1347 | 1347 | $line = explode(',',$buffer); |
1348 | 1348 | $data = array(); |
1349 | 1349 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1360,38 +1360,38 @@ discard block |
||
1360 | 1360 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1361 | 1361 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1362 | 1362 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1363 | - } |
|
1364 | - } elseif ($format == 'acars') { |
|
1365 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1366 | - $ACARS->add(trim($buffer)); |
|
1367 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1368 | - $ACARS->deleteLiveAcarsData(); |
|
1363 | + } |
|
1364 | + } elseif ($format == 'acars') { |
|
1365 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1366 | + $ACARS->add(trim($buffer)); |
|
1367 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1368 | + $ACARS->deleteLiveAcarsData(); |
|
1369 | 1369 | } elseif ($format == 'flightgearmp') { |
1370 | - if (substr($buffer,0,1) != '#') { |
|
1370 | + if (substr($buffer,0,1) != '#') { |
|
1371 | 1371 | $data = array(); |
1372 | 1372 | //echo $buffer."\n"; |
1373 | 1373 | $line = explode(' ',$buffer); |
1374 | 1374 | if (count($line) == 11) { |
1375 | - $userserver = explode('@',$line[0]); |
|
1376 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1377 | - $data['ident'] = $userserver[0]; |
|
1378 | - $data['registration'] = $userserver[0]; |
|
1379 | - $data['latitude'] = $line[4]; |
|
1380 | - $data['longitude'] = $line[5]; |
|
1381 | - $data['altitude'] = $line[6]; |
|
1382 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1383 | - $aircraft_type = $line[10]; |
|
1384 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1385 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1386 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1387 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1375 | + $userserver = explode('@',$line[0]); |
|
1376 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1377 | + $data['ident'] = $userserver[0]; |
|
1378 | + $data['registration'] = $userserver[0]; |
|
1379 | + $data['latitude'] = $line[4]; |
|
1380 | + $data['longitude'] = $line[5]; |
|
1381 | + $data['altitude'] = $line[6]; |
|
1382 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1383 | + $aircraft_type = $line[10]; |
|
1384 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1385 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1386 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1387 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1388 | + } |
|
1388 | 1389 | } |
1389 | - } |
|
1390 | 1390 | } elseif ($format == 'beast') { |
1391 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1392 | - die; |
|
1391 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1392 | + die; |
|
1393 | 1393 | } elseif ($format == 'vrstcp') { |
1394 | - foreach($buffer as $all_data) { |
|
1394 | + foreach($buffer as $all_data) { |
|
1395 | 1395 | $line = json_decode('{'.$all_data.'}',true); |
1396 | 1396 | $data = array(); |
1397 | 1397 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1411,151 +1411,151 @@ discard block |
||
1411 | 1411 | */ |
1412 | 1412 | $data['datetime'] = date('Y-m-d H:i:s'); |
1413 | 1413 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1414 | - $data['format_source'] = 'vrstcp'; |
|
1414 | + $data['format_source'] = 'vrstcp'; |
|
1415 | 1415 | $data['id_source'] = $id_source; |
1416 | 1416 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1417 | 1417 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1418 | 1418 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1419 | 1419 | unset($data); |
1420 | - } |
|
1420 | + } |
|
1421 | 1421 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1422 | - $line = explode("\t", $buffer); |
|
1423 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1422 | + $line = explode("\t", $buffer); |
|
1423 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1424 | 1424 | $key = $line[$k]; |
1425 | - $lined[$key] = $line[$k+1]; |
|
1426 | - } |
|
1427 | - if (count($lined) > 3) { |
|
1428 | - $data['hex'] = $lined['hexid']; |
|
1429 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1430 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1431 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1432 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1433 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1434 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1435 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1436 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1437 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1438 | - $data['id_source'] = $id_source; |
|
1439 | - $data['format_source'] = 'tsv'; |
|
1440 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1441 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1425 | + $lined[$key] = $line[$k+1]; |
|
1426 | + } |
|
1427 | + if (count($lined) > 3) { |
|
1428 | + $data['hex'] = $lined['hexid']; |
|
1429 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1430 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1431 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1432 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1433 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1434 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1435 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1436 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1437 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1438 | + $data['id_source'] = $id_source; |
|
1439 | + $data['format_source'] = 'tsv'; |
|
1440 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1441 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1442 | 1442 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1443 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1444 | - unset($lined); |
|
1445 | - unset($data); |
|
1446 | - } else $error = true; |
|
1443 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1444 | + unset($lined); |
|
1445 | + unset($data); |
|
1446 | + } else $error = true; |
|
1447 | 1447 | } elseif ($format == 'aprs' && $use_aprs) { |
1448 | - if ($aprs_connect == 0) { |
|
1448 | + if ($aprs_connect == 0) { |
|
1449 | 1449 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1450 | 1450 | $aprs_connect = 1; |
1451 | - } |
|
1451 | + } |
|
1452 | 1452 | |
1453 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1453 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1454 | 1454 | $aprs_last_tx = time(); |
1455 | 1455 | $data_aprs = "# Keep alive"; |
1456 | 1456 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1457 | - } |
|
1457 | + } |
|
1458 | 1458 | |
1459 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1460 | - //echo 'APRS data : '.$buffer."\n"; |
|
1461 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1462 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1463 | - //echo $buffer."\n"; |
|
1464 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1459 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1460 | + //echo 'APRS data : '.$buffer."\n"; |
|
1461 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1462 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1463 | + //echo $buffer."\n"; |
|
1464 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1465 | 1465 | $line = $APRS->parse($buffer); |
1466 | 1466 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1467 | 1467 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1468 | - $aprs_last_tx = time(); |
|
1469 | - $data = array(); |
|
1470 | - //print_r($line); |
|
1471 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1472 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1473 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1474 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1475 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1476 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1477 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1478 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1480 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1481 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1482 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1483 | - $data['latitude'] = $line['latitude']; |
|
1484 | - $data['longitude'] = $line['longitude']; |
|
1485 | - //$data['verticalrate'] = $line[16]; |
|
1486 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1487 | - //else $data['speed'] = 0; |
|
1488 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1489 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1490 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1491 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1468 | + $aprs_last_tx = time(); |
|
1469 | + $data = array(); |
|
1470 | + //print_r($line); |
|
1471 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1472 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1473 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1474 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1475 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1476 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1477 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1478 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1479 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1480 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1481 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1482 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1483 | + $data['latitude'] = $line['latitude']; |
|
1484 | + $data['longitude'] = $line['longitude']; |
|
1485 | + //$data['verticalrate'] = $line[16]; |
|
1486 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1487 | + //else $data['speed'] = 0; |
|
1488 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1489 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1490 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1491 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1492 | 1492 | |
1493 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1494 | - //else echo 'No heading...'."\n"; |
|
1495 | - //else $data['heading'] = 0; |
|
1496 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1497 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1498 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1499 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1500 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1502 | - $data['id_source'] = $id_source; |
|
1503 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1504 | - else $data['format_source'] = 'aprs'; |
|
1505 | - $data['source_name'] = $line['source']; |
|
1506 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1507 | - else $data['source_type'] = 'flarm'; |
|
1508 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1509 | - $currentdate = date('Y-m-d H:i:s'); |
|
1510 | - $aprsdate = strtotime($data['datetime']); |
|
1511 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1512 | - // Accept data if time <= system time + 20s |
|
1513 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1514 | - 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'])))) { |
|
1493 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1494 | + //else echo 'No heading...'."\n"; |
|
1495 | + //else $data['heading'] = 0; |
|
1496 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1497 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1498 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1499 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1500 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1502 | + $data['id_source'] = $id_source; |
|
1503 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1504 | + else $data['format_source'] = 'aprs'; |
|
1505 | + $data['source_name'] = $line['source']; |
|
1506 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1507 | + else $data['source_type'] = 'flarm'; |
|
1508 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1509 | + $currentdate = date('Y-m-d H:i:s'); |
|
1510 | + $aprsdate = strtotime($data['datetime']); |
|
1511 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1512 | + // Accept data if time <= system time + 20s |
|
1513 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1514 | + 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'])))) { |
|
1515 | 1515 | $send = $SI->add($data); |
1516 | - } elseif ($data['source_type'] == 'ais') { |
|
1516 | + } elseif ($data['source_type'] == 'ais') { |
|
1517 | 1517 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1518 | - } elseif (isset($line['stealth'])) { |
|
1518 | + } elseif (isset($line['stealth'])) { |
|
1519 | 1519 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1520 | 1520 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1521 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1522 | - //$line['symbol'] == 'Balloon' || |
|
1523 | - $line['symbol'] == 'Glider' || |
|
1524 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1525 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1526 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1527 | - $send = $SI->add($data); |
|
1528 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1529 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1530 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1531 | - $send = $MI->add($data); |
|
1532 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1533 | - $line['symbol'] == 'Car' || |
|
1534 | - $line['symbol'] == 'Ambulance' || |
|
1535 | - $line['symbol'] == 'Van' || |
|
1536 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1537 | - $line['symbol'] == 'Motorcycle' || |
|
1538 | - $line['symbol'] == 'Tractor' || |
|
1539 | - $line['symbol'] == 'Police' || |
|
1540 | - $line['symbol'] == 'Bike' || |
|
1541 | - $line['symbol'] == 'Jogger' || |
|
1542 | - $line['symbol'] == 'Horse' || |
|
1543 | - $line['symbol'] == 'Bus' || |
|
1544 | - $line['symbol'] == 'Jeep' || |
|
1545 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1546 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1547 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1548 | - $line['symbol'] == 'Firetruck' || |
|
1549 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1550 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1551 | - $line['symbol'] == 'SUV' || |
|
1552 | - $line['symbol'] == 'Snowmobile' || |
|
1553 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1554 | - //} 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') { |
|
1521 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1522 | + //$line['symbol'] == 'Balloon' || |
|
1523 | + $line['symbol'] == 'Glider' || |
|
1524 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1525 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1526 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1527 | + $send = $SI->add($data); |
|
1528 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1529 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1530 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1531 | + $send = $MI->add($data); |
|
1532 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1533 | + $line['symbol'] == 'Car' || |
|
1534 | + $line['symbol'] == 'Ambulance' || |
|
1535 | + $line['symbol'] == 'Van' || |
|
1536 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1537 | + $line['symbol'] == 'Motorcycle' || |
|
1538 | + $line['symbol'] == 'Tractor' || |
|
1539 | + $line['symbol'] == 'Police' || |
|
1540 | + $line['symbol'] == 'Bike' || |
|
1541 | + $line['symbol'] == 'Jogger' || |
|
1542 | + $line['symbol'] == 'Horse' || |
|
1543 | + $line['symbol'] == 'Bus' || |
|
1544 | + $line['symbol'] == 'Jeep' || |
|
1545 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1546 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1547 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1548 | + $line['symbol'] == 'Firetruck' || |
|
1549 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1550 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1551 | + $line['symbol'] == 'SUV' || |
|
1552 | + $line['symbol'] == 'Snowmobile' || |
|
1553 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1554 | + //} 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') { |
|
1555 | 1555 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') { |
1556 | 1556 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1557 | 1557 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1558 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1558 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1559 | 1559 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1560 | 1560 | $Source->deleteOldLocationByType('gs'); |
1561 | 1561 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | } else { |
1564 | 1564 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1565 | 1565 | } |
1566 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1566 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1567 | 1567 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1568 | 1568 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1569 | 1569 | $Source->deleteOldLocationByType('wx'); |
@@ -1573,7 +1573,7 @@ discard block |
||
1573 | 1573 | } else { |
1574 | 1574 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1575 | 1575 | } |
1576 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1576 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1577 | 1577 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1578 | 1578 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1579 | 1579 | $Source->deleteOldLocationByType('lightning'); |
@@ -1582,11 +1582,11 @@ discard block |
||
1582 | 1582 | } else { |
1583 | 1583 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1584 | 1584 | } |
1585 | - } elseif ($globalDebug) { |
|
1586 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1587 | - print_r($line); |
|
1588 | - } |
|
1589 | - unset($data); |
|
1585 | + } elseif ($globalDebug) { |
|
1586 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1587 | + print_r($line); |
|
1588 | + } |
|
1589 | + unset($data); |
|
1590 | 1590 | } |
1591 | 1591 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1592 | 1592 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1605,12 +1605,12 @@ discard block |
||
1605 | 1605 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1606 | 1606 | $globalSources[$nb]['last_weather_clean'] = time(); |
1607 | 1607 | } |
1608 | - } |
|
1608 | + } |
|
1609 | 1609 | } else { |
1610 | - $line = explode(',', $buffer); |
|
1611 | - if (count($line) > 20) { |
|
1612 | - $data['hex'] = $line[4]; |
|
1613 | - /* |
|
1610 | + $line = explode(',', $buffer); |
|
1611 | + if (count($line) > 20) { |
|
1612 | + $data['hex'] = $line[4]; |
|
1613 | + /* |
|
1614 | 1614 | $data['datetime'] = $line[6].' '.$line[7]; |
1615 | 1615 | date_default_timezone_set($globalTimezone); |
1616 | 1616 | $datetime = new DateTime($data['datetime']); |
@@ -1618,30 +1618,30 @@ discard block |
||
1618 | 1618 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1619 | 1619 | date_default_timezone_set('UTC'); |
1620 | 1620 | */ |
1621 | - // Force datetime to current UTC datetime |
|
1622 | - date_default_timezone_set('UTC'); |
|
1623 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1624 | - $data['ident'] = trim($line[10]); |
|
1625 | - $data['latitude'] = $line[14]; |
|
1626 | - $data['longitude'] = $line[15]; |
|
1627 | - $data['verticalrate'] = $line[16]; |
|
1628 | - $data['emergency'] = $line[20]; |
|
1629 | - $data['speed'] = $line[12]; |
|
1630 | - $data['squawk'] = $line[17]; |
|
1631 | - $data['altitude'] = $line[11]; |
|
1632 | - $data['heading'] = $line[13]; |
|
1633 | - $data['ground'] = $line[21]; |
|
1634 | - $data['emergency'] = $line[19]; |
|
1635 | - $data['format_source'] = 'sbs'; |
|
1621 | + // Force datetime to current UTC datetime |
|
1622 | + date_default_timezone_set('UTC'); |
|
1623 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1624 | + $data['ident'] = trim($line[10]); |
|
1625 | + $data['latitude'] = $line[14]; |
|
1626 | + $data['longitude'] = $line[15]; |
|
1627 | + $data['verticalrate'] = $line[16]; |
|
1628 | + $data['emergency'] = $line[20]; |
|
1629 | + $data['speed'] = $line[12]; |
|
1630 | + $data['squawk'] = $line[17]; |
|
1631 | + $data['altitude'] = $line[11]; |
|
1632 | + $data['heading'] = $line[13]; |
|
1633 | + $data['ground'] = $line[21]; |
|
1634 | + $data['emergency'] = $line[19]; |
|
1635 | + $data['format_source'] = 'sbs'; |
|
1636 | 1636 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1637 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1637 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1638 | 1638 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1639 | - $data['id_source'] = $id_source; |
|
1640 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1641 | - else $error = true; |
|
1642 | - unset($data); |
|
1643 | - } else $error = true; |
|
1644 | - if ($error) { |
|
1639 | + $data['id_source'] = $id_source; |
|
1640 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1641 | + else $error = true; |
|
1642 | + unset($data); |
|
1643 | + } else $error = true; |
|
1644 | + if ($error) { |
|
1645 | 1645 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1646 | 1646 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1647 | 1647 | } else { |
@@ -1657,13 +1657,13 @@ discard block |
||
1657 | 1657 | connect_all($sourceer); |
1658 | 1658 | $sourceer = array(); |
1659 | 1659 | } |
1660 | - } |
|
1660 | + } |
|
1661 | 1661 | } |
1662 | 1662 | // Sleep for xxx microseconds |
1663 | 1663 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1664 | - } else { |
|
1664 | + } else { |
|
1665 | 1665 | if ($format == 'flightgearmp') { |
1666 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1666 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1667 | 1667 | //@socket_close($r); |
1668 | 1668 | sleep($globalMinFetch); |
1669 | 1669 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1672,9 +1672,9 @@ discard block |
||
1672 | 1672 | break; |
1673 | 1673 | |
1674 | 1674 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1675 | - if (isset($tt[$format])) $tt[$format]++; |
|
1676 | - else $tt[$format] = 0; |
|
1677 | - if ($tt[$format] > 30) { |
|
1675 | + if (isset($tt[$format])) $tt[$format]++; |
|
1676 | + else $tt[$format] = 0; |
|
1677 | + if ($tt[$format] > 30) { |
|
1678 | 1678 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1679 | 1679 | //@socket_close($r); |
1680 | 1680 | sleep(2); |
@@ -1685,23 +1685,23 @@ discard block |
||
1685 | 1685 | //connect_all($globalSources); |
1686 | 1686 | $tt[$format]=0; |
1687 | 1687 | break; |
1688 | - } |
|
1688 | + } |
|
1689 | + } |
|
1689 | 1690 | } |
1690 | - } |
|
1691 | 1691 | } |
1692 | - } else { |
|
1692 | + } else { |
|
1693 | 1693 | $error = socket_strerror(socket_last_error()); |
1694 | 1694 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1695 | 1695 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1696 | 1696 | if (isset($globalDebug)) echo "Restarting...\n"; |
1697 | 1697 | // Restart the script if possible |
1698 | 1698 | if (is_array($sockets)) { |
1699 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1699 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1700 | 1700 | |
1701 | - foreach ($sockets as $sock) { |
|
1701 | + foreach ($sockets as $sock) { |
|
1702 | 1702 | @socket_shutdown($sock,2); |
1703 | 1703 | @socket_close($sock); |
1704 | - } |
|
1704 | + } |
|
1705 | 1705 | |
1706 | 1706 | } |
1707 | 1707 | if ($globalDebug) echo "Waiting..."; |
@@ -1716,15 +1716,15 @@ discard block |
||
1716 | 1716 | if ($globalDebug) echo "Restart all connections..."; |
1717 | 1717 | connect_all($globalSources); |
1718 | 1718 | } |
1719 | - } |
|
1719 | + } |
|
1720 | 1720 | } |
1721 | 1721 | if ($globalDaemon === false) { |
1722 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1723 | - if (isset($SI)) $SI->checkAll(); |
|
1724 | - if (isset($TI)) $TI->checkAll(); |
|
1725 | - if (isset($MI)) $MI->checkAll(); |
|
1722 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1723 | + if (isset($SI)) $SI->checkAll(); |
|
1724 | + if (isset($TI)) $TI->checkAll(); |
|
1725 | + if (isset($MI)) $MI->checkAll(); |
|
1726 | + } |
|
1726 | 1727 | } |
1727 | - } |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | ?> |
@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,35 +63,62 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
77 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
78 | -if (isset($options['server'])) $globalServer = TRUE; |
|
79 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
80 | -else $id_source = 1; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
95 | +if (isset($options['nodaemon'])) { |
|
96 | + $globalDaemon = FALSE; |
|
97 | +} |
|
98 | +if (isset($options['server'])) { |
|
99 | + $globalServer = TRUE; |
|
100 | +} |
|
101 | +if (isset($options['idsource'])) { |
|
102 | + $id_source = $options['idsource']; |
|
103 | +} else { |
|
104 | + $id_source = 1; |
|
105 | +} |
|
81 | 106 | if (isset($globalServer) && $globalServer) { |
82 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo "Using Server Mode\n"; |
|
109 | + } |
|
83 | 110 | $SI=new SpotterServer(); |
84 | 111 | /* |
85 | 112 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
86 | 113 | $SI = new adsb2aprs(); |
87 | 114 | $SI->connect(); |
88 | 115 | */ |
89 | -} else $SI=new SpotterImport($Connection->db); |
|
90 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
116 | +} else { |
|
117 | + $SI=new SpotterImport($Connection->db); |
|
118 | +} |
|
119 | +if (isset($globalTracker) && $globalTracker) { |
|
120 | + $TI = new TrackerImport($Connection->db); |
|
121 | +} |
|
91 | 122 | if (isset($globalMarine) && $globalMarine) { |
92 | 123 | $AIS = new AIS(); |
93 | 124 | $MI = new MarineImport($Connection->db); |
@@ -110,7 +141,9 @@ discard block |
||
110 | 141 | } |
111 | 142 | |
112 | 143 | // let's try and connect |
113 | -if ($globalDebug) echo "Connecting...\n"; |
|
144 | +if ($globalDebug) { |
|
145 | + echo "Connecting...\n"; |
|
146 | +} |
|
114 | 147 | $use_aprs = false; |
115 | 148 | $aprs_full = false; |
116 | 149 | $reset = 0; |
@@ -119,7 +152,9 @@ discard block |
||
119 | 152 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
120 | 153 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
121 | 154 | $reset++; |
122 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
155 | + if ($globalDebug) { |
|
156 | + echo 'Connect to all...'."\n"; |
|
157 | + } |
|
123 | 158 | foreach ($hosts as $id => $value) { |
124 | 159 | $host = $value['host']; |
125 | 160 | $globalSources[$id]['last_exec'] = 0; |
@@ -129,22 +164,30 @@ discard block |
||
129 | 164 | //$formats[$id] = 'deltadbtxt'; |
130 | 165 | $globalSources[$id]['format'] = 'deltadbtxt'; |
131 | 166 | //$last_exec['deltadbtxt'] = 0; |
132 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
167 | + if ($globalDebug) { |
|
168 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
169 | + } |
|
133 | 170 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
134 | 171 | //$formats[$id] = 'vatsimtxt'; |
135 | 172 | $globalSources[$id]['format'] = 'vatsimtxt'; |
136 | 173 | //$last_exec['vatsimtxt'] = 0; |
137 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
174 | + if ($globalDebug) { |
|
175 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
176 | + } |
|
138 | 177 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
139 | 178 | //$formats[$id] = 'aircraftlistjson'; |
140 | 179 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
141 | 180 | //$last_exec['aircraftlistjson'] = 0; |
142 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | + if ($globalDebug) { |
|
182 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
183 | + } |
|
143 | 184 | } else if (preg_match('/opensky/i',$host)) { |
144 | 185 | //$formats[$id] = 'aircraftlistjson'; |
145 | 186 | $globalSources[$id]['format'] = 'opensky'; |
146 | 187 | //$last_exec['aircraftlistjson'] = 0; |
147 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
188 | + if ($globalDebug) { |
|
189 | + echo "Connect to opensky source (".$host.")...\n"; |
|
190 | + } |
|
148 | 191 | /* |
149 | 192 | // Disabled for now, site change source format |
150 | 193 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -161,7 +204,9 @@ discard block |
||
161 | 204 | //$formats[$id] = 'planeupdatefaa'; |
162 | 205 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
163 | 206 | //$last_exec['planeupdatefaa'] = 0; |
164 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
207 | + if ($globalDebug) { |
|
208 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
209 | + } |
|
165 | 210 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
166 | 211 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
167 | 212 | exit(0); |
@@ -170,32 +215,46 @@ discard block |
||
170 | 215 | //$formats[$id] = 'phpvmacars'; |
171 | 216 | $globalSources[$id]['format'] = 'phpvmacars'; |
172 | 217 | //$last_exec['phpvmacars'] = 0; |
173 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
218 | + if ($globalDebug) { |
|
219 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
220 | + } |
|
174 | 221 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
175 | 222 | //$formats[$id] = 'phpvmacars'; |
176 | 223 | $globalSources[$id]['format'] = 'vam'; |
177 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
224 | + if ($globalDebug) { |
|
225 | + echo "Connect to Vam source (".$host.")...\n"; |
|
226 | + } |
|
178 | 227 | } else if (preg_match('/whazzup/i',$host)) { |
179 | 228 | //$formats[$id] = 'whazzup'; |
180 | 229 | $globalSources[$id]['format'] = 'whazzup'; |
181 | 230 | //$last_exec['whazzup'] = 0; |
182 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
231 | + if ($globalDebug) { |
|
232 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
233 | + } |
|
183 | 234 | } else if (preg_match('/blitzortung/i',$host)) { |
184 | 235 | $globalSources[$id]['format'] = 'blitzortung'; |
185 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
236 | + if ($globalDebug) { |
|
237 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
238 | + } |
|
186 | 239 | } else if (preg_match('/airwhere/i',$host)) { |
187 | 240 | $globalSources[$id]['format'] = 'airwhere'; |
188 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
241 | + if ($globalDebug) { |
|
242 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
243 | + } |
|
189 | 244 | } else if (preg_match('/recentpireps/i',$host)) { |
190 | 245 | //$formats[$id] = 'pirepsjson'; |
191 | 246 | $globalSources[$id]['format'] = 'pirepsjson'; |
192 | 247 | //$last_exec['pirepsjson'] = 0; |
193 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
248 | + if ($globalDebug) { |
|
249 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
250 | + } |
|
194 | 251 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
195 | 252 | //$formats[$id] = 'fr24json'; |
196 | 253 | $globalSources[$id]['format'] = 'fr24json'; |
197 | 254 | //$last_exec['fr24json'] = 0; |
198 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
255 | + if ($globalDebug) { |
|
256 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
257 | + } |
|
199 | 258 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
200 | 259 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
201 | 260 | exit(0); |
@@ -204,7 +263,9 @@ discard block |
||
204 | 263 | //$formats[$id] = 'fr24json'; |
205 | 264 | $globalSources[$id]['format'] = 'myshiptracking'; |
206 | 265 | //$last_exec['fr24json'] = 0; |
207 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
266 | + if ($globalDebug) { |
|
267 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
268 | + } |
|
208 | 269 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
209 | 270 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
210 | 271 | exit(0); |
@@ -213,17 +274,24 @@ discard block |
||
213 | 274 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
214 | 275 | //$formats[$id] = 'tsv'; |
215 | 276 | $globalSources[$id]['format'] = 'tsv'; |
216 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
277 | + if ($globalDebug) { |
|
278 | + echo "Connect to tsv source (".$host.")...\n"; |
|
279 | + } |
|
217 | 280 | } |
218 | 281 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
219 | 282 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
220 | 283 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
221 | 284 | if ($idf !== false) { |
222 | 285 | $httpfeeds[$id] = $idf; |
223 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
286 | + if ($globalDebug) { |
|
287 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
288 | + } |
|
289 | + } elseif ($globalDebug) { |
|
290 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
224 | 291 | } |
225 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
226 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
292 | + } elseif ($globalDebug) { |
|
293 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
294 | + } |
|
227 | 295 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
228 | 296 | $hostport = explode(':',$host); |
229 | 297 | if (isset($hostport[1])) { |
@@ -263,17 +331,25 @@ discard block |
||
263 | 331 | //$formats[$id] = 'beast'; |
264 | 332 | $globalSources[$id]['format'] = 'beast'; |
265 | 333 | //} else $formats[$id] = 'sbs'; |
266 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
334 | + } else { |
|
335 | + $globalSources[$id]['format'] = 'sbs'; |
|
336 | + } |
|
267 | 337 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
268 | 338 | } |
269 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
339 | + if ($globalDebug) { |
|
340 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
341 | + } |
|
270 | 342 | } else { |
271 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
343 | + if ($globalDebug) { |
|
344 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
345 | + } |
|
272 | 346 | } |
273 | 347 | } |
274 | 348 | } |
275 | 349 | } |
276 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
350 | +if (!isset($globalMinFetch)) { |
|
351 | + $globalMinFetch = 15; |
|
352 | +} |
|
277 | 353 | |
278 | 354 | // Initialize all |
279 | 355 | $status = array(); |
@@ -282,13 +358,19 @@ discard block |
||
282 | 358 | $formats = array(); |
283 | 359 | $last_exec = array(); |
284 | 360 | $time = time(); |
285 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
286 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
287 | -else $timeout = 20; |
|
361 | +if (isset($globalSourcesTimeout)) { |
|
362 | + $timeout = $globalSourcesTimeOut; |
|
363 | +} else if (isset($globalSBS1TimeOut)) { |
|
364 | + $timeout = $globalSBS1TimeOut; |
|
365 | +} else { |
|
366 | + $timeout = 20; |
|
367 | +} |
|
288 | 368 | $errno = ''; |
289 | 369 | $errstr=''; |
290 | 370 | |
291 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
371 | +if (!isset($globalDaemon)) { |
|
372 | + $globalDaemon = TRUE; |
|
373 | +} |
|
292 | 374 | /* Initiate connections to all the hosts simultaneously */ |
293 | 375 | //connect_all($hosts); |
294 | 376 | //connect_all($globalSources); |
@@ -317,7 +399,9 @@ discard block |
||
317 | 399 | if (isset($source['format']) && $source['format'] == 'aprs') { |
318 | 400 | $aprs_connect = 0; |
319 | 401 | $use_aprs = true; |
320 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
402 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
403 | + $aprs_full = true; |
|
404 | + } |
|
321 | 405 | break; |
322 | 406 | } |
323 | 407 | } |
@@ -328,25 +412,48 @@ discard block |
||
328 | 412 | $aprs_connect = 0; |
329 | 413 | $aprs_keep = 120; |
330 | 414 | $aprs_last_tx = time(); |
331 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
332 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
333 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
334 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
335 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
336 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
337 | - if ($aprs_full) $aprs_filter = ''; |
|
338 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
339 | - else $aprs_pass = '-1'; |
|
415 | + if (isset($globalAPRSversion)) { |
|
416 | + $aprs_version = $globalAPRSversion; |
|
417 | + } else { |
|
418 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
419 | + } |
|
420 | + if (isset($globalAPRSssid)) { |
|
421 | + $aprs_ssid = $globalAPRSssid; |
|
422 | + } else { |
|
423 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
424 | + } |
|
425 | + if (isset($globalAPRSfilter)) { |
|
426 | + $aprs_filter = $globalAPRSfilter; |
|
427 | + } else { |
|
428 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
429 | + } |
|
430 | + if ($aprs_full) { |
|
431 | + $aprs_filter = ''; |
|
432 | + } |
|
433 | + if (isset($globalAPRSpass)) { |
|
434 | + $aprs_pass = $globalAPRSpass; |
|
435 | + } else { |
|
436 | + $aprs_pass = '-1'; |
|
437 | + } |
|
340 | 438 | |
341 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
342 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
343 | -} |
|
439 | + if ($aprs_filter != '') { |
|
440 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
441 | + } else { |
|
442 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
443 | + } |
|
444 | + } |
|
344 | 445 | |
345 | 446 | // connected - lets do some work |
346 | -if ($globalDebug) echo "Connected!\n"; |
|
447 | +if ($globalDebug) { |
|
448 | + echo "Connected!\n"; |
|
449 | +} |
|
347 | 450 | sleep(1); |
348 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
349 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
451 | +if ($globalDebug) { |
|
452 | + echo "SCAN MODE \n\n"; |
|
453 | +} |
|
454 | +if (!isset($globalCronEnd)) { |
|
455 | + $globalCronEnd = 60; |
|
456 | +} |
|
350 | 457 | $endtime = time()+$globalCronEnd; |
351 | 458 | $i = 1; |
352 | 459 | $tt = array(); |
@@ -360,20 +467,28 @@ discard block |
||
360 | 467 | |
361 | 468 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
362 | 469 | while ($i > 0) { |
363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
470 | + if (!$globalDaemon) { |
|
471 | + $i = $endtime-time(); |
|
472 | + } |
|
364 | 473 | // Delete old ATC |
365 | 474 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
366 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
475 | + if ($globalDebug) { |
|
476 | + echo 'Delete old ATC...'."\n"; |
|
477 | + } |
|
367 | 478 | $ATC->deleteOldATC(); |
368 | 479 | } |
369 | 480 | |
370 | 481 | if (count($last_exec) == count($globalSources)) { |
371 | 482 | $max = $globalMinFetch; |
372 | 483 | foreach ($last_exec as $last) { |
373 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
484 | + if ((time() - $last['last']) < $max) { |
|
485 | + $max = time() - $last['last']; |
|
486 | + } |
|
374 | 487 | } |
375 | 488 | if ($max != $globalMinFetch) { |
376 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
489 | + if ($globalDebug) { |
|
490 | + echo 'Sleeping...'."\n"; |
|
491 | + } |
|
377 | 492 | sleep($globalMinFetch-$max+2); |
378 | 493 | } |
379 | 494 | } |
@@ -383,7 +498,9 @@ discard block |
||
383 | 498 | foreach ($globalSources as $id => $value) { |
384 | 499 | date_default_timezone_set('UTC'); |
385 | 500 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
386 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
501 | + if (!isset($last_exec[$id]['last'])) { |
|
502 | + $last_exec[$id]['last'] = 0; |
|
503 | + } |
|
387 | 504 | if ($value['format'] == 'deltadbtxt' && |
388 | 505 | ( |
389 | 506 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -392,7 +509,9 @@ discard block |
||
392 | 509 | ) { |
393 | 510 | //$buffer = $Common->getData($hosts[$id]); |
394 | 511 | $buffer = $Common->getData($value['host']); |
395 | - if ($buffer != '') $reset = 0; |
|
512 | + if ($buffer != '') { |
|
513 | + $reset = 0; |
|
514 | + } |
|
396 | 515 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
397 | 516 | $buffer = explode('\n',$buffer); |
398 | 517 | foreach ($buffer as $line) { |
@@ -401,20 +520,41 @@ discard block |
||
401 | 520 | $data = array(); |
402 | 521 | $data['hex'] = $line[1]; // hex |
403 | 522 | $data['ident'] = $line[2]; // ident |
404 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
405 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
406 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
407 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
408 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
523 | + if (isset($line[3])) { |
|
524 | + $data['altitude'] = $line[3]; |
|
525 | + } |
|
526 | + // altitude |
|
527 | + if (isset($line[4])) { |
|
528 | + $data['speed'] = $line[4]; |
|
529 | + } |
|
530 | + // speed |
|
531 | + if (isset($line[5])) { |
|
532 | + $data['heading'] = $line[5]; |
|
533 | + } |
|
534 | + // heading |
|
535 | + if (isset($line[6])) { |
|
536 | + $data['latitude'] = $line[6]; |
|
537 | + } |
|
538 | + // lat |
|
539 | + if (isset($line[7])) { |
|
540 | + $data['longitude'] = $line[7]; |
|
541 | + } |
|
542 | + // long |
|
409 | 543 | $data['verticalrate'] = ''; // vertical rate |
410 | 544 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
411 | 545 | $data['emergency'] = ''; // emergency |
412 | 546 | $data['datetime'] = date('Y-m-d H:i:s'); |
413 | 547 | $data['format_source'] = 'deltadbtxt'; |
414 | 548 | $data['id_source'] = $id_source; |
415 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
416 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
417 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
549 | + if (isset($value['name']) && $value['name'] != '') { |
|
550 | + $data['source_name'] = $value['name']; |
|
551 | + } |
|
552 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
553 | + $data['noarchive'] = true; |
|
554 | + } |
|
555 | + if (isset($value['sourcestats'])) { |
|
556 | + $data['sourcestats'] = $value['sourcestats']; |
|
557 | + } |
|
418 | 558 | $SI->add($data); |
419 | 559 | unset($data); |
420 | 560 | } |
@@ -429,7 +569,9 @@ discard block |
||
429 | 569 | date_default_timezone_set('CET'); |
430 | 570 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
431 | 571 | date_default_timezone_set('UTC'); |
432 | - if ($buffer != '') $reset = 0; |
|
572 | + if ($buffer != '') { |
|
573 | + $reset = 0; |
|
574 | + } |
|
433 | 575 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
434 | 576 | $buffer = explode('\n',$buffer); |
435 | 577 | foreach ($buffer as $line) { |
@@ -438,16 +580,36 @@ discard block |
||
438 | 580 | $add = false; |
439 | 581 | $ais_data = $AIS->parse_line(trim($line)); |
440 | 582 | $data = array(); |
441 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
442 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
443 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
444 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
445 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
446 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
447 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
448 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
449 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
450 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
583 | + if (isset($ais_data['ident'])) { |
|
584 | + $data['ident'] = $ais_data['ident']; |
|
585 | + } |
|
586 | + if (isset($ais_data['mmsi'])) { |
|
587 | + $data['mmsi'] = $ais_data['mmsi']; |
|
588 | + } |
|
589 | + if (isset($ais_data['speed'])) { |
|
590 | + $data['speed'] = $ais_data['speed']; |
|
591 | + } |
|
592 | + if (isset($ais_data['heading'])) { |
|
593 | + $data['heading'] = $ais_data['heading']; |
|
594 | + } |
|
595 | + if (isset($ais_data['latitude'])) { |
|
596 | + $data['latitude'] = $ais_data['latitude']; |
|
597 | + } |
|
598 | + if (isset($ais_data['longitude'])) { |
|
599 | + $data['longitude'] = $ais_data['longitude']; |
|
600 | + } |
|
601 | + if (isset($ais_data['status'])) { |
|
602 | + $data['status'] = $ais_data['status']; |
|
603 | + } |
|
604 | + if (isset($ais_data['type'])) { |
|
605 | + $data['type'] = $ais_data['type']; |
|
606 | + } |
|
607 | + if (isset($ais_data['imo'])) { |
|
608 | + $data['imo'] = $ais_data['imo']; |
|
609 | + } |
|
610 | + if (isset($ais_data['callsign'])) { |
|
611 | + $data['callsign'] = $ais_data['callsign']; |
|
612 | + } |
|
451 | 613 | if (isset($ais_data['timestamp'])) { |
452 | 614 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
453 | 615 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -461,8 +623,12 @@ discard block |
||
461 | 623 | $data['format_source'] = 'aisnmeatxt'; |
462 | 624 | $data['id_source'] = $id_source; |
463 | 625 | //print_r($data); |
464 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
465 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
626 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
627 | + $data['noarchive'] = true; |
|
628 | + } |
|
629 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
630 | + $MI->add($data); |
|
631 | + } |
|
466 | 632 | unset($data); |
467 | 633 | } |
468 | 634 | } |
@@ -482,20 +648,48 @@ discard block |
||
482 | 648 | if ($line != '') { |
483 | 649 | $ais_data = $AIS->parse_line(trim($line)); |
484 | 650 | $data = array(); |
485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
498 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
651 | + if (isset($ais_data['ident'])) { |
|
652 | + $data['ident'] = $ais_data['ident']; |
|
653 | + } |
|
654 | + if (isset($ais_data['mmsi'])) { |
|
655 | + $data['mmsi'] = $ais_data['mmsi']; |
|
656 | + } |
|
657 | + if (isset($ais_data['speed'])) { |
|
658 | + $data['speed'] = $ais_data['speed']; |
|
659 | + } |
|
660 | + if (isset($ais_data['heading'])) { |
|
661 | + $data['heading'] = $ais_data['heading']; |
|
662 | + } |
|
663 | + if (isset($ais_data['latitude'])) { |
|
664 | + $data['latitude'] = $ais_data['latitude']; |
|
665 | + } |
|
666 | + if (isset($ais_data['longitude'])) { |
|
667 | + $data['longitude'] = $ais_data['longitude']; |
|
668 | + } |
|
669 | + if (isset($ais_data['status'])) { |
|
670 | + $data['status'] = $ais_data['status']; |
|
671 | + } |
|
672 | + if (isset($ais_data['statusid'])) { |
|
673 | + $data['status_id'] = $ais_data['statusid']; |
|
674 | + } |
|
675 | + if (isset($ais_data['type'])) { |
|
676 | + $data['type'] = $ais_data['type']; |
|
677 | + } |
|
678 | + if (isset($ais_data['typeid'])) { |
|
679 | + $data['type_id'] = $ais_data['typeid']; |
|
680 | + } |
|
681 | + if (isset($ais_data['imo'])) { |
|
682 | + $data['imo'] = $ais_data['imo']; |
|
683 | + } |
|
684 | + if (isset($ais_data['callsign'])) { |
|
685 | + $data['callsign'] = $ais_data['callsign']; |
|
686 | + } |
|
687 | + if (isset($ais_data['destination'])) { |
|
688 | + $data['arrival_code'] = $ais_data['destination']; |
|
689 | + } |
|
690 | + if (isset($ais_data['eta_ts'])) { |
|
691 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
692 | + } |
|
499 | 693 | if (isset($ais_data['timestamp'])) { |
500 | 694 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
501 | 695 | } else { |
@@ -503,18 +697,27 @@ discard block |
||
503 | 697 | } |
504 | 698 | $data['format_source'] = 'aisnmeahttp'; |
505 | 699 | $data['id_source'] = $id_source; |
506 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
507 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
700 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
701 | + $data['noarchive'] = true; |
|
702 | + } |
|
703 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
704 | + $MI->add($data); |
|
705 | + } |
|
508 | 706 | unset($data); |
509 | 707 | } |
510 | 708 | } |
511 | 709 | } |
512 | 710 | } else { |
513 | 711 | $format = $value['format']; |
514 | - if (isset($tt[$format])) $tt[$format]++; |
|
515 | - else $tt[$format] = 0; |
|
712 | + if (isset($tt[$format])) { |
|
713 | + $tt[$format]++; |
|
714 | + } else { |
|
715 | + $tt[$format] = 0; |
|
716 | + } |
|
516 | 717 | if ($tt[$format] > 30) { |
517 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
718 | + if ($globalDebug) { |
|
719 | + echo 'Reconnect...'."\n"; |
|
720 | + } |
|
518 | 721 | sleep(2); |
519 | 722 | $sourceeen[] = $value; |
520 | 723 | connect_all($sourceeen); |
@@ -549,7 +752,9 @@ discard block |
||
549 | 752 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
550 | 753 | $data['format_source'] = 'myshiptracking'; |
551 | 754 | $data['id_source'] = $id_source; |
552 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
755 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
756 | + $data['noarchive'] = true; |
|
757 | + } |
|
553 | 758 | $MI->add($data); |
554 | 759 | unset($data); |
555 | 760 | } |
@@ -574,7 +779,9 @@ discard block |
||
574 | 779 | $data['callsign'] = $line['callsign']; |
575 | 780 | $data['mmsi'] = $line['mmsi']; |
576 | 781 | $data['speed'] = $line['sog']; |
577 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
782 | + if ($line['heading'] != '511') { |
|
783 | + $data['heading'] = $line['heading']; |
|
784 | + } |
|
578 | 785 | $data['latitude'] = $line['latitude']; |
579 | 786 | $data['longitude'] = $line['longitude']; |
580 | 787 | $data['type_id'] = $line['shiptype']; |
@@ -582,7 +789,9 @@ discard block |
||
582 | 789 | $data['datetime'] = $line['time']; |
583 | 790 | $data['format_source'] = 'boatbeaconapp'; |
584 | 791 | $data['id_source'] = $id_source; |
585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
793 | + $data['noarchive'] = true; |
|
794 | + } |
|
586 | 795 | $MI->add($data); |
587 | 796 | unset($data); |
588 | 797 | } |
@@ -603,22 +812,44 @@ discard block |
||
603 | 812 | if (isset($all_data['features'][0]['id'])) { |
604 | 813 | foreach ($all_data['features'] as $line) { |
605 | 814 | $data = array(); |
606 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
607 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
608 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
609 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
610 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
611 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
815 | + if (isset($line['properties']['name'])) { |
|
816 | + $data['ident'] = $line['properties']['name']; |
|
817 | + } |
|
818 | + if (isset($line['properties']['callsign'])) { |
|
819 | + $data['callsign'] = $line['properties']['callsign']; |
|
820 | + } |
|
821 | + if (isset($line['properties']['mmsi'])) { |
|
822 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
823 | + } |
|
824 | + if (isset($line['properties']['imo'])) { |
|
825 | + $data['mmsi'] = $line['properties']['imo']; |
|
826 | + } |
|
827 | + if (isset($line['properties']['speed'])) { |
|
828 | + $data['speed'] = $line['properties']['speed']; |
|
829 | + } |
|
830 | + if (isset($line['properties']['heading'])) { |
|
831 | + $data['heading'] = $line['properties']['heading']; |
|
832 | + } |
|
612 | 833 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
613 | 834 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
614 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
615 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
616 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
835 | + if (isset($line['properties']['vesselType'])) { |
|
836 | + $data['type'] = $line['properties']['vesselType']; |
|
837 | + } |
|
838 | + if (isset($line['properties']['destination'])) { |
|
839 | + $data['arrival_code'] = $line['properties']['destination']; |
|
840 | + } |
|
841 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
842 | + $data['arrival_date'] = $line['properties']['eta']; |
|
843 | + } |
|
617 | 844 | $data['format_source'] = 'boatnerd'; |
618 | 845 | $data['id_source'] = $id_source; |
619 | 846 | $data['datetime'] = date('Y-m-d H:i:s'); |
620 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
621 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
847 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
848 | + $data['noarchive'] = true; |
|
849 | + } |
|
850 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
851 | + $MI->add($data); |
|
852 | + } |
|
622 | 853 | unset($data); |
623 | 854 | } |
624 | 855 | } |
@@ -634,7 +865,9 @@ discard block |
||
634 | 865 | echo 'download...'; |
635 | 866 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
636 | 867 | echo 'done !'."\n"; |
637 | - if ($buffer != '') $reset = 0; |
|
868 | + if ($buffer != '') { |
|
869 | + $reset = 0; |
|
870 | + } |
|
638 | 871 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
639 | 872 | $buffer = explode('\n',$buffer); |
640 | 873 | foreach ($buffer as $line) { |
@@ -659,7 +892,9 @@ discard block |
||
659 | 892 | //$data['etaTime'] = substr($line,135,5); |
660 | 893 | $data['format_source'] = 'shipplotter'; |
661 | 894 | $data['id_source'] = $id_source; |
662 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
895 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
896 | + $data['noarchive'] = true; |
|
897 | + } |
|
663 | 898 | //print_r($data); |
664 | 899 | echo 'Add...'."\n"; |
665 | 900 | $MI->add($data); |
@@ -693,16 +928,28 @@ discard block |
||
693 | 928 | $line = explode(':', $line); |
694 | 929 | if (count($line) > 30 && $line[0] != 'callsign') { |
695 | 930 | $data = array(); |
696 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
697 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
931 | + if (isset($line[37]) && $line[37] != '') { |
|
932 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
933 | + } else { |
|
934 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
935 | + } |
|
698 | 936 | $data['pilot_id'] = $line[1]; |
699 | 937 | $data['pilot_name'] = $line[2]; |
700 | 938 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
701 | 939 | $data['ident'] = $line[0]; // ident |
702 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
940 | + if ($line[7] != '' && $line[7] != 0) { |
|
941 | + $data['altitude'] = $line[7]; |
|
942 | + } |
|
943 | + // altitude |
|
703 | 944 | $data['speed'] = $line[8]; // speed |
704 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
705 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
945 | + if (isset($line[45])) { |
|
946 | + $data['heading'] = $line[45]; |
|
947 | + } |
|
948 | + // heading |
|
949 | + elseif (isset($line[38])) { |
|
950 | + $data['heading'] = $line[38]; |
|
951 | + } |
|
952 | + // heading |
|
706 | 953 | $data['latitude'] = $line[5]; // lat |
707 | 954 | $data['longitude'] = $line[6]; // long |
708 | 955 | $data['verticalrate'] = ''; // vertical rate |
@@ -718,7 +965,9 @@ discard block |
||
718 | 965 | $data['frequency'] = $line[4]; |
719 | 966 | $data['type'] = $line[18]; |
720 | 967 | $data['range'] = $line[19]; |
721 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
968 | + if (isset($line[35])) { |
|
969 | + $data['info'] = $line[35]; |
|
970 | + } |
|
722 | 971 | $data['id_source'] = $id_source; |
723 | 972 | //$data['arrival_airport_time'] = ; |
724 | 973 | if ($line[9] != '') { |
@@ -732,27 +981,47 @@ discard block |
||
732 | 981 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
733 | 982 | */ |
734 | 983 | $data['format_source'] = $value['format']; |
735 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
736 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
737 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
738 | - elseif ($line[3] == 'ATC') { |
|
984 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
985 | + $data['noarchive'] = true; |
|
986 | + } |
|
987 | + if (isset($value['name']) && $value['name'] != '') { |
|
988 | + $data['source_name'] = $value['name']; |
|
989 | + } |
|
990 | + if ($line[3] == 'PILOT') { |
|
991 | + $SI->add($data); |
|
992 | + } elseif ($line[3] == 'ATC') { |
|
739 | 993 | //print_r($data); |
740 | 994 | $data['info'] = str_replace('^§','<br />',$data['info']); |
741 | 995 | $data['info'] = str_replace('&sect;','',$data['info']); |
742 | 996 | $typec = substr($data['ident'],-3); |
743 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
744 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
745 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
746 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
747 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
748 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
749 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
750 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
751 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
752 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
997 | + if ($typec == 'APP') { |
|
998 | + $data['type'] = 'Approach'; |
|
999 | + } elseif ($typec == 'TWR') { |
|
1000 | + $data['type'] = 'Tower'; |
|
1001 | + } elseif ($typec == 'OBS') { |
|
1002 | + $data['type'] = 'Observer'; |
|
1003 | + } elseif ($typec == 'GND') { |
|
1004 | + $data['type'] = 'Ground'; |
|
1005 | + } elseif ($typec == 'DEL') { |
|
1006 | + $data['type'] = 'Delivery'; |
|
1007 | + } elseif ($typec == 'DEP') { |
|
1008 | + $data['type'] = 'Departure'; |
|
1009 | + } elseif ($typec == 'FSS') { |
|
1010 | + $data['type'] = 'Flight Service Station'; |
|
1011 | + } elseif ($typec == 'CTR') { |
|
1012 | + $data['type'] = 'Control Radar or Centre'; |
|
1013 | + } elseif ($data['type'] == '') { |
|
1014 | + $data['type'] = 'Observer'; |
|
1015 | + } |
|
1016 | + if (!isset($data['source_name'])) { |
|
1017 | + $data['source_name'] = ''; |
|
1018 | + } |
|
753 | 1019 | if (isset($ATC)) { |
754 | - 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']); |
|
755 | - 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']); |
|
1020 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1021 | + 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']); |
|
1022 | + } else { |
|
1023 | + 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']); |
|
1024 | + } |
|
756 | 1025 | } |
757 | 1026 | } |
758 | 1027 | unset($data); |
@@ -779,14 +1048,20 @@ discard block |
||
779 | 1048 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
780 | 1049 | $data['latitude'] = (float)$line['pktLatitude']; |
781 | 1050 | $data['longitude'] = (float)$line['pktLongitude']; |
782 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
783 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1051 | + if ((float)$line['pktTrack'] != 0) { |
|
1052 | + $data['heading'] = (float)$line['pktTrack']; |
|
1053 | + } |
|
1054 | + if ((int)$line['pktSpeed'] != 0) { |
|
1055 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1056 | + } |
|
784 | 1057 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
785 | 1058 | $data['altitude_relative'] = 'AMSL'; |
786 | 1059 | $data['pilot_id'] = (int)$line['pktPilotID']; |
787 | 1060 | $data['aircraft_icao'] = 'PARAGLIDER'; |
788 | 1061 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
789 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1062 | + if (isset($pilot_data[4])) { |
|
1063 | + $data['pilot_name'] = $pilot_data[4]; |
|
1064 | + } |
|
790 | 1065 | $data['format_source'] = $value['format']; |
791 | 1066 | $SI->add($data); |
792 | 1067 | unset($data); |
@@ -834,25 +1109,59 @@ discard block |
||
834 | 1109 | foreach ($all_data['acList'] as $line) { |
835 | 1110 | $data = array(); |
836 | 1111 | $data['hex'] = $line['Icao']; // hex |
837 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
838 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
839 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
840 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
841 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
842 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1112 | + if (isset($line['Call'])) { |
|
1113 | + $data['ident'] = $line['Call']; |
|
1114 | + } |
|
1115 | + // ident |
|
1116 | + if (isset($line['Alt'])) { |
|
1117 | + $data['altitude'] = $line['Alt']; |
|
1118 | + } |
|
1119 | + // altitude |
|
1120 | + if (isset($line['Spd'])) { |
|
1121 | + $data['speed'] = $line['Spd']; |
|
1122 | + } |
|
1123 | + // speed |
|
1124 | + if (isset($line['Trak'])) { |
|
1125 | + $data['heading'] = $line['Trak']; |
|
1126 | + } |
|
1127 | + // heading |
|
1128 | + if (isset($line['Lat'])) { |
|
1129 | + $data['latitude'] = $line['Lat']; |
|
1130 | + } |
|
1131 | + // lat |
|
1132 | + if (isset($line['Long'])) { |
|
1133 | + $data['longitude'] = $line['Long']; |
|
1134 | + } |
|
1135 | + // long |
|
843 | 1136 | //$data['verticalrate'] = $line['']; // verticale rate |
844 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1137 | + if (isset($line['Sqk'])) { |
|
1138 | + $data['squawk'] = $line['Sqk']; |
|
1139 | + } |
|
1140 | + // squawk |
|
845 | 1141 | $data['emergency'] = ''; // emergency |
846 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
847 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
848 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1142 | + if (isset($line['Reg'])) { |
|
1143 | + $data['registration'] = $line['Reg']; |
|
1144 | + } |
|
1145 | + if (isset($line['PosTime'])) { |
|
1146 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1147 | + } else { |
|
1148 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1149 | + } |
|
849 | 1150 | //$data['datetime'] = date('Y-m-d H:i:s'); |
850 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1151 | + if (isset($line['Type'])) { |
|
1152 | + $data['aircraft_icao'] = $line['Type']; |
|
1153 | + } |
|
851 | 1154 | $data['format_source'] = 'aircraftlistjson'; |
852 | 1155 | $data['id_source'] = $id_source; |
853 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
854 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
855 | - if (isset($data['latitude'])) $SI->add($data); |
|
1156 | + if (isset($value['name']) && $value['name'] != '') { |
|
1157 | + $data['source_name'] = $value['name']; |
|
1158 | + } |
|
1159 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1160 | + $data['noarchive'] = true; |
|
1161 | + } |
|
1162 | + if (isset($data['latitude'])) { |
|
1163 | + $SI->add($data); |
|
1164 | + } |
|
856 | 1165 | unset($data); |
857 | 1166 | } |
858 | 1167 | } elseif (is_array($all_data)) { |
@@ -869,17 +1178,26 @@ discard block |
||
869 | 1178 | $data['verticalrate'] = $line['vrt']; // verticale rate |
870 | 1179 | $data['squawk'] = $line['squawk']; // squawk |
871 | 1180 | $data['emergency'] = ''; // emergency |
872 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
873 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1181 | + if (isset($line['PosTime'])) { |
|
1182 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1183 | + } else { |
|
1184 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1185 | + } |
|
874 | 1186 | $data['format_source'] = 'aircraftlistjson'; |
875 | 1187 | $data['id_source'] = $id_source; |
876 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
877 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1188 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1189 | + $data['noarchive'] = true; |
|
1190 | + } |
|
1191 | + if (isset($value['name']) && $value['name'] != '') { |
|
1192 | + $data['source_name'] = $value['name']; |
|
1193 | + } |
|
878 | 1194 | $SI->add($data); |
879 | 1195 | unset($data); |
880 | 1196 | } |
881 | 1197 | } |
882 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1198 | + } elseif ($globalDebug) { |
|
1199 | + echo 'No data'."\n"; |
|
1200 | + } |
|
883 | 1201 | //$last_exec['aircraftlistjson'] = time(); |
884 | 1202 | $last_exec[$id]['last'] = time(); |
885 | 1203 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -915,8 +1233,12 @@ discard block |
||
915 | 1233 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
916 | 1234 | $data['format_source'] = 'planeupdatefaa'; |
917 | 1235 | $data['id_source'] = $id_source; |
918 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
919 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1236 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1237 | + $data['noarchive'] = true; |
|
1238 | + } |
|
1239 | + if (isset($value['name']) && $value['name'] != '') { |
|
1240 | + $data['source_name'] = $value['name']; |
|
1241 | + } |
|
920 | 1242 | $SI->add($data); |
921 | 1243 | unset($data); |
922 | 1244 | } |
@@ -950,7 +1272,9 @@ discard block |
||
950 | 1272 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
951 | 1273 | $data['format_source'] = 'opensky'; |
952 | 1274 | $data['id_source'] = $id_source; |
953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1275 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1276 | + $data['noarchive'] = true; |
|
1277 | + } |
|
954 | 1278 | $SI->add($data); |
955 | 1279 | unset($data); |
956 | 1280 | } |
@@ -967,7 +1291,9 @@ discard block |
||
967 | 1291 | //$buffer = $Common->getData($hosts[$id]); |
968 | 1292 | $buffer = $Common->getData($value['host']); |
969 | 1293 | $all_data = json_decode($buffer,true); |
970 | - if (!empty($all_data)) $reset = 0; |
|
1294 | + if (!empty($all_data)) { |
|
1295 | + $reset = 0; |
|
1296 | + } |
|
971 | 1297 | foreach ($all_data as $key => $line) { |
972 | 1298 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
973 | 1299 | $data = array(); |
@@ -988,8 +1314,12 @@ discard block |
||
988 | 1314 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
989 | 1315 | $data['format_source'] = 'fr24json'; |
990 | 1316 | $data['id_source'] = $id_source; |
991 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1317 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1318 | + $data['noarchive'] = true; |
|
1319 | + } |
|
1320 | + if (isset($value['name']) && $value['name'] != '') { |
|
1321 | + $data['source_name'] = $value['name']; |
|
1322 | + } |
|
993 | 1323 | $SI->add($data); |
994 | 1324 | unset($data); |
995 | 1325 | } |
@@ -1018,24 +1348,42 @@ discard block |
||
1018 | 1348 | if (isset($line['inf'])) { |
1019 | 1349 | $data = array(); |
1020 | 1350 | $data['hex'] = $line['inf']['ia']; |
1021 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1351 | + if (isset($line['inf']['cs'])) { |
|
1352 | + $data['ident'] = $line['inf']['cs']; |
|
1353 | + } |
|
1354 | + //$line[13] |
|
1022 | 1355 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1023 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1024 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1356 | + if (isset($line['inf']['gs'])) { |
|
1357 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1358 | + } |
|
1359 | + // speed |
|
1360 | + if (isset($line['inf']['tr'])) { |
|
1361 | + $data['heading'] = $line['inf']['tr']; |
|
1362 | + } |
|
1363 | + // heading |
|
1025 | 1364 | $data['latitude'] = $line['pt'][0]; // lat |
1026 | 1365 | $data['longitude'] = $line['pt'][1]; // long |
1027 | 1366 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1028 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1367 | + if (isset($line['inf']['sq'])) { |
|
1368 | + $data['squawk'] = $line['inf']['sq']; |
|
1369 | + } |
|
1370 | + // squawk |
|
1029 | 1371 | //$data['aircraft_icao'] = $line[8]; |
1030 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1372 | + if (isset($line['inf']['rc'])) { |
|
1373 | + $data['registration'] = $line['inf']['rc']; |
|
1374 | + } |
|
1031 | 1375 | //$data['departure_airport_iata'] = $line[11]; |
1032 | 1376 | //$data['arrival_airport_iata'] = $line[12]; |
1033 | 1377 | //$data['emergency'] = ''; // emergency |
1034 | 1378 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1035 | 1379 | $data['format_source'] = 'radarvirtueljson'; |
1036 | 1380 | $data['id_source'] = $id_source; |
1037 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1038 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1381 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1382 | + $data['noarchive'] = true; |
|
1383 | + } |
|
1384 | + if (isset($value['name']) && $value['name'] != '') { |
|
1385 | + $data['source_name'] = $value['name']; |
|
1386 | + } |
|
1039 | 1387 | $SI->add($data); |
1040 | 1388 | unset($data); |
1041 | 1389 | } |
@@ -1061,30 +1409,65 @@ discard block |
||
1061 | 1409 | $data['id'] = $line['id']; |
1062 | 1410 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1063 | 1411 | $data['ident'] = $line['callsign']; // ident |
1064 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1065 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1066 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1067 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1068 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1069 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1412 | + if (isset($line['pilotid'])) { |
|
1413 | + $data['pilot_id'] = $line['pilotid']; |
|
1414 | + } |
|
1415 | + // pilot id |
|
1416 | + if (isset($line['name'])) { |
|
1417 | + $data['pilot_name'] = $line['name']; |
|
1418 | + } |
|
1419 | + // pilot name |
|
1420 | + if (isset($line['alt'])) { |
|
1421 | + $data['altitude'] = $line['alt']; |
|
1422 | + } |
|
1423 | + // altitude |
|
1424 | + if (isset($line['gs'])) { |
|
1425 | + $data['speed'] = $line['gs']; |
|
1426 | + } |
|
1427 | + // speed |
|
1428 | + if (isset($line['heading'])) { |
|
1429 | + $data['heading'] = $line['heading']; |
|
1430 | + } |
|
1431 | + // heading |
|
1432 | + if (isset($line['route'])) { |
|
1433 | + $data['waypoints'] = $line['route']; |
|
1434 | + } |
|
1435 | + // route |
|
1070 | 1436 | $data['latitude'] = $line['lat']; // lat |
1071 | 1437 | $data['longitude'] = $line['lon']; // long |
1072 | 1438 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1073 | 1439 | //$data['squawk'] = $line['squawk']; // squawk |
1074 | 1440 | //$data['emergency'] = ''; // emergency |
1075 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1076 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1077 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1441 | + if (isset($line['depicao'])) { |
|
1442 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1443 | + } |
|
1444 | + if (isset($line['deptime'])) { |
|
1445 | + $data['departure_airport_time'] = $line['deptime']; |
|
1446 | + } |
|
1447 | + if (isset($line['arricao'])) { |
|
1448 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1449 | + } |
|
1078 | 1450 | //$data['arrival_airport_time'] = $line['arrtime']; |
1079 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1080 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1081 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1082 | - else $data['info'] = ''; |
|
1451 | + if (isset($line['aircraft'])) { |
|
1452 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1453 | + } |
|
1454 | + if (isset($line['transponder'])) { |
|
1455 | + $data['squawk'] = $line['transponder']; |
|
1456 | + } |
|
1457 | + if (isset($line['atis'])) { |
|
1458 | + $data['info'] = $line['atis']; |
|
1459 | + } else { |
|
1460 | + $data['info'] = ''; |
|
1461 | + } |
|
1083 | 1462 | $data['format_source'] = 'pireps'; |
1084 | 1463 | $data['id_source'] = $id_source; |
1085 | 1464 | $data['datetime'] = date('Y-m-d H:i:s'); |
1086 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1087 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1465 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1466 | + $data['noarchive'] = true; |
|
1467 | + } |
|
1468 | + if (isset($value['name']) && $value['name'] != '') { |
|
1469 | + $data['source_name'] = $value['name']; |
|
1470 | + } |
|
1088 | 1471 | if ($line['icon'] == 'plane') { |
1089 | 1472 | $SI->add($data); |
1090 | 1473 | // print_r($data); |
@@ -1093,16 +1476,28 @@ discard block |
||
1093 | 1476 | $data['info'] = str_replace('&sect;','',$data['info']); |
1094 | 1477 | $typec = substr($data['ident'],-3); |
1095 | 1478 | $data['type'] = ''; |
1096 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
1097 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
1098 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
1099 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
1100 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
1101 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
1102 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
1103 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1104 | - else $data['type'] = 'Observer'; |
|
1105 | - 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']); |
|
1479 | + if ($typec == 'APP') { |
|
1480 | + $data['type'] = 'Approach'; |
|
1481 | + } elseif ($typec == 'TWR') { |
|
1482 | + $data['type'] = 'Tower'; |
|
1483 | + } elseif ($typec == 'OBS') { |
|
1484 | + $data['type'] = 'Observer'; |
|
1485 | + } elseif ($typec == 'GND') { |
|
1486 | + $data['type'] = 'Ground'; |
|
1487 | + } elseif ($typec == 'DEL') { |
|
1488 | + $data['type'] = 'Delivery'; |
|
1489 | + } elseif ($typec == 'DEP') { |
|
1490 | + $data['type'] = 'Departure'; |
|
1491 | + } elseif ($typec == 'FSS') { |
|
1492 | + $data['type'] = 'Flight Service Station'; |
|
1493 | + } elseif ($typec == 'CTR') { |
|
1494 | + $data['type'] = 'Control Radar or Centre'; |
|
1495 | + } else { |
|
1496 | + $data['type'] = 'Observer'; |
|
1497 | + } |
|
1498 | + if (isset($ATC)) { |
|
1499 | + 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']); |
|
1500 | + } |
|
1106 | 1501 | } |
1107 | 1502 | unset($data); |
1108 | 1503 | } |
@@ -1117,7 +1512,9 @@ discard block |
||
1117 | 1512 | ) |
1118 | 1513 | ) { |
1119 | 1514 | //$buffer = $Common->getData($hosts[$id]); |
1120 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1515 | + if ($globalDebug) { |
|
1516 | + echo 'Get Data...'."\n"; |
|
1517 | + } |
|
1121 | 1518 | $buffer = $Common->getData($value['host']); |
1122 | 1519 | $all_data = json_decode($buffer,true); |
1123 | 1520 | if ($buffer != '' && is_array($all_data)) { |
@@ -1125,10 +1522,16 @@ discard block |
||
1125 | 1522 | foreach ($all_data as $line) { |
1126 | 1523 | $data = array(); |
1127 | 1524 | //$data['id'] = $line['id']; // id not usable |
1128 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1525 | + if (isset($line['pilotid'])) { |
|
1526 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1527 | + } |
|
1129 | 1528 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1130 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1131 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1529 | + if (isset($line['pilotname'])) { |
|
1530 | + $data['pilot_name'] = $line['pilotname']; |
|
1531 | + } |
|
1532 | + if (isset($line['pilotid'])) { |
|
1533 | + $data['pilot_id'] = $line['pilotid']; |
|
1534 | + } |
|
1132 | 1535 | $data['ident'] = $line['flightnum']; // ident |
1133 | 1536 | $data['altitude'] = $line['alt']; // altitude |
1134 | 1537 | $data['speed'] = $line['gs']; // speed |
@@ -1144,34 +1547,52 @@ discard block |
||
1144 | 1547 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1145 | 1548 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1146 | 1549 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1147 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1550 | + } else { |
|
1551 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1552 | + } |
|
1148 | 1553 | $data['departure_airport_icao'] = $line['depicao']; |
1149 | 1554 | $data['departure_airport_time'] = $line['deptime']; |
1150 | 1555 | $data['arrival_airport_icao'] = $line['arricao']; |
1151 | 1556 | $data['arrival_airport_time'] = $line['arrtime']; |
1152 | 1557 | $data['registration'] = $line['aircraft']; |
1153 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1154 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1558 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1559 | + $data['noarchive'] = true; |
|
1560 | + } |
|
1561 | + if (isset($line['route'])) { |
|
1562 | + $data['waypoints'] = $line['route']; |
|
1563 | + } |
|
1564 | + // route |
|
1155 | 1565 | if (isset($line['aircraftname'])) { |
1156 | 1566 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1157 | 1567 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1158 | 1568 | $aircraft_data = explode('-',$line['aircraftname']); |
1159 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1160 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1161 | - else { |
|
1569 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1570 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1571 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1572 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1573 | + } else { |
|
1162 | 1574 | $aircraft_data = explode(' ',$line['aircraftname']); |
1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1575 | + if (isset($aircraft_data[1])) { |
|
1576 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1577 | + } else { |
|
1578 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1579 | + } |
|
1165 | 1580 | } |
1166 | 1581 | } |
1167 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1582 | + if (isset($line['route'])) { |
|
1583 | + $data['waypoints'] = $line['route']; |
|
1584 | + } |
|
1168 | 1585 | $data['id_source'] = $id_source; |
1169 | 1586 | $data['format_source'] = 'phpvmacars'; |
1170 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1587 | + if (isset($value['name']) && $value['name'] != '') { |
|
1588 | + $data['source_name'] = $value['name']; |
|
1589 | + } |
|
1171 | 1590 | $SI->add($data); |
1172 | 1591 | unset($data); |
1173 | 1592 | } |
1174 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1593 | + if ($globalDebug) { |
|
1594 | + echo 'No more data...'."\n"; |
|
1595 | + } |
|
1175 | 1596 | unset($buffer); |
1176 | 1597 | unset($all_data); |
1177 | 1598 | } |
@@ -1184,7 +1605,9 @@ discard block |
||
1184 | 1605 | ) |
1185 | 1606 | ) { |
1186 | 1607 | //$buffer = $Common->getData($hosts[$id]); |
1187 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1608 | + if ($globalDebug) { |
|
1609 | + echo 'Get Data...'."\n"; |
|
1610 | + } |
|
1188 | 1611 | $buffer = $Common->getData($value['host']); |
1189 | 1612 | $all_data = json_decode($buffer,true); |
1190 | 1613 | if ($buffer != '' && is_array($all_data)) { |
@@ -1213,16 +1636,25 @@ discard block |
||
1213 | 1636 | $data['arrival_airport_icao'] = $line['arrival']; |
1214 | 1637 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1215 | 1638 | //$data['registration'] = $line['aircraft']; |
1216 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1639 | + if (isset($line['route'])) { |
|
1640 | + $data['waypoints'] = $line['route']; |
|
1641 | + } |
|
1642 | + // route |
|
1217 | 1643 | $data['aircraft_icao'] = $line['plane_type']; |
1218 | 1644 | $data['id_source'] = $id_source; |
1219 | 1645 | $data['format_source'] = 'vam'; |
1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1646 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1647 | + $data['noarchive'] = true; |
|
1648 | + } |
|
1649 | + if (isset($value['name']) && $value['name'] != '') { |
|
1650 | + $data['source_name'] = $value['name']; |
|
1651 | + } |
|
1222 | 1652 | $SI->add($data); |
1223 | 1653 | unset($data); |
1224 | 1654 | } |
1225 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1655 | + if ($globalDebug) { |
|
1656 | + echo 'No more data...'."\n"; |
|
1657 | + } |
|
1226 | 1658 | unset($buffer); |
1227 | 1659 | unset($all_data); |
1228 | 1660 | } |
@@ -1235,7 +1667,9 @@ discard block |
||
1235 | 1667 | ) |
1236 | 1668 | ) { |
1237 | 1669 | //$buffer = $Common->getData($hosts[$id]); |
1238 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1670 | + if ($globalDebug) { |
|
1671 | + echo 'Get Data...'."\n"; |
|
1672 | + } |
|
1239 | 1673 | $buffer = $Common->getData($value['host']); |
1240 | 1674 | $all_data = json_decode($buffer,true); |
1241 | 1675 | if ($buffer != '') { |
@@ -1253,18 +1687,24 @@ discard block |
||
1253 | 1687 | $data['id_source'] = $id_source; |
1254 | 1688 | $data['format_source'] = 'blitzortung'; |
1255 | 1689 | $SI->add($data); |
1256 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1690 | + if ($globalDebug) { |
|
1691 | + echo '☈ Lightning added'."\n"; |
|
1692 | + } |
|
1257 | 1693 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1258 | 1694 | unset($data); |
1259 | 1695 | } |
1260 | 1696 | } |
1261 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1697 | + if ($globalDebug) { |
|
1698 | + echo 'No more data...'."\n"; |
|
1699 | + } |
|
1262 | 1700 | unset($buffer); |
1263 | 1701 | } |
1264 | 1702 | $last_exec[$id]['last'] = time(); |
1265 | 1703 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1266 | 1704 | } 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') { |
1267 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1705 | + if (function_exists('pcntl_fork')) { |
|
1706 | + pcntl_signal_dispatch(); |
|
1707 | + } |
|
1268 | 1708 | //$last_exec[$id]['last'] = time(); |
1269 | 1709 | |
1270 | 1710 | //$read = array( $sockets[$id] ); |
@@ -1272,7 +1712,9 @@ discard block |
||
1272 | 1712 | $write = NULL; |
1273 | 1713 | $e = NULL; |
1274 | 1714 | $n = socket_select($read, $write, $e, $timeout); |
1275 | - if ($e != NULL) var_dump($e); |
|
1715 | + if ($e != NULL) { |
|
1716 | + var_dump($e); |
|
1717 | + } |
|
1276 | 1718 | if ($n > 0) { |
1277 | 1719 | $reset = 0; |
1278 | 1720 | foreach ($read as $nb => $r) { |
@@ -1293,12 +1735,16 @@ discard block |
||
1293 | 1735 | //$SI::del(); |
1294 | 1736 | if ($format == 'vrstcp') { |
1295 | 1737 | $buffer = explode('},{',$buffer); |
1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1738 | + } else { |
|
1739 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1740 | + } |
|
1297 | 1741 | // SBS format is CSV format |
1298 | 1742 | if ($buffer !== FALSE && $buffer != '') { |
1299 | 1743 | $tt[$format] = 0; |
1300 | 1744 | if ($format == 'acarssbs3') { |
1301 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1745 | + if ($globalDebug) { |
|
1746 | + echo 'ACARS : '.$buffer."\n"; |
|
1747 | + } |
|
1302 | 1748 | $ACARS->add(trim($buffer)); |
1303 | 1749 | $ACARS->deleteLiveAcarsData(); |
1304 | 1750 | } elseif ($format == 'raw') { |
@@ -1307,30 +1753,70 @@ discard block |
||
1307 | 1753 | if (is_array($data)) { |
1308 | 1754 | $data['datetime'] = date('Y-m-d H:i:s'); |
1309 | 1755 | $data['format_source'] = 'raw'; |
1310 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1311 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1312 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1313 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1756 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1757 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1758 | + } |
|
1759 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1760 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1761 | + } |
|
1762 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1763 | + $data['noarchive'] = true; |
|
1764 | + } |
|
1765 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1766 | + $SI->add($data); |
|
1767 | + } |
|
1314 | 1768 | } |
1315 | 1769 | } elseif ($format == 'ais') { |
1316 | 1770 | $ais_data = $AIS->parse_line(trim($buffer)); |
1317 | 1771 | $data = array(); |
1318 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1319 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1320 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1321 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1322 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1323 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1324 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1325 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1326 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1327 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1328 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1329 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1331 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1332 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1333 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1772 | + if (isset($ais_data['ident'])) { |
|
1773 | + $data['ident'] = $ais_data['ident']; |
|
1774 | + } |
|
1775 | + if (isset($ais_data['mmsi'])) { |
|
1776 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1777 | + } |
|
1778 | + if (isset($ais_data['speed'])) { |
|
1779 | + $data['speed'] = $ais_data['speed']; |
|
1780 | + } |
|
1781 | + if (isset($ais_data['heading'])) { |
|
1782 | + $data['heading'] = $ais_data['heading']; |
|
1783 | + } |
|
1784 | + if (isset($ais_data['latitude'])) { |
|
1785 | + $data['latitude'] = $ais_data['latitude']; |
|
1786 | + } |
|
1787 | + if (isset($ais_data['longitude'])) { |
|
1788 | + $data['longitude'] = $ais_data['longitude']; |
|
1789 | + } |
|
1790 | + if (isset($ais_data['status'])) { |
|
1791 | + $data['status'] = $ais_data['status']; |
|
1792 | + } |
|
1793 | + if (isset($ais_data['statusid'])) { |
|
1794 | + $data['status_id'] = $ais_data['statusid']; |
|
1795 | + } |
|
1796 | + if (isset($ais_data['type'])) { |
|
1797 | + $data['type'] = $ais_data['type']; |
|
1798 | + } |
|
1799 | + if (isset($ais_data['imo'])) { |
|
1800 | + $data['imo'] = $ais_data['imo']; |
|
1801 | + } |
|
1802 | + if (isset($ais_data['callsign'])) { |
|
1803 | + $data['callsign'] = $ais_data['callsign']; |
|
1804 | + } |
|
1805 | + if (isset($ais_data['destination'])) { |
|
1806 | + $data['arrival_code'] = $ais_data['destination']; |
|
1807 | + } |
|
1808 | + if (isset($ais_data['eta_ts'])) { |
|
1809 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1810 | + } |
|
1811 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1812 | + $data['noarchive'] = true; |
|
1813 | + } |
|
1814 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1815 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1816 | + } |
|
1817 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1818 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1819 | + } |
|
1334 | 1820 | |
1335 | 1821 | if (isset($ais_data['timestamp'])) { |
1336 | 1822 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1339,7 +1825,9 @@ discard block |
||
1339 | 1825 | } |
1340 | 1826 | $data['format_source'] = 'aisnmea'; |
1341 | 1827 | $data['id_source'] = $id_source; |
1342 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1828 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1829 | + $MI->add($data); |
|
1830 | + } |
|
1343 | 1831 | unset($data); |
1344 | 1832 | } elseif ($format == 'flightgearsp') { |
1345 | 1833 | //echo $buffer."\n"; |
@@ -1357,12 +1845,18 @@ discard block |
||
1357 | 1845 | $data['speed'] = round($line[5]*1.94384); |
1358 | 1846 | $data['datetime'] = date('Y-m-d H:i:s'); |
1359 | 1847 | $data['format_source'] = 'flightgearsp'; |
1360 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1361 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1848 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1849 | + $data['noarchive'] = true; |
|
1850 | + } |
|
1851 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1852 | + $SI->add($data); |
|
1853 | + } |
|
1362 | 1854 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1363 | 1855 | } |
1364 | 1856 | } elseif ($format == 'acars') { |
1365 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1857 | + if ($globalDebug) { |
|
1858 | + echo 'ACARS : '.$buffer."\n"; |
|
1859 | + } |
|
1366 | 1860 | $ACARS->add(trim($buffer)); |
1367 | 1861 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1368 | 1862 | $ACARS->deleteLiveAcarsData(); |
@@ -1383,8 +1877,12 @@ discard block |
||
1383 | 1877 | $aircraft_type = $line[10]; |
1384 | 1878 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1385 | 1879 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1386 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1387 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1880 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1881 | + $data['noarchive'] = true; |
|
1882 | + } |
|
1883 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1884 | + $SI->add($data); |
|
1885 | + } |
|
1388 | 1886 | } |
1389 | 1887 | } |
1390 | 1888 | } elseif ($format == 'beast') { |
@@ -1394,28 +1892,62 @@ discard block |
||
1394 | 1892 | foreach($buffer as $all_data) { |
1395 | 1893 | $line = json_decode('{'.$all_data.'}',true); |
1396 | 1894 | $data = array(); |
1397 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1398 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1399 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1400 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1401 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1402 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1403 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1895 | + if (isset($line['Icao'])) { |
|
1896 | + $data['hex'] = $line['Icao']; |
|
1897 | + } |
|
1898 | + // hex |
|
1899 | + if (isset($line['Call'])) { |
|
1900 | + $data['ident'] = $line['Call']; |
|
1901 | + } |
|
1902 | + // ident |
|
1903 | + if (isset($line['Alt'])) { |
|
1904 | + $data['altitude'] = $line['Alt']; |
|
1905 | + } |
|
1906 | + // altitude |
|
1907 | + if (isset($line['Spd'])) { |
|
1908 | + $data['speed'] = $line['Spd']; |
|
1909 | + } |
|
1910 | + // speed |
|
1911 | + if (isset($line['Trak'])) { |
|
1912 | + $data['heading'] = $line['Trak']; |
|
1913 | + } |
|
1914 | + // heading |
|
1915 | + if (isset($line['Lat'])) { |
|
1916 | + $data['latitude'] = $line['Lat']; |
|
1917 | + } |
|
1918 | + // lat |
|
1919 | + if (isset($line['Long'])) { |
|
1920 | + $data['longitude'] = $line['Long']; |
|
1921 | + } |
|
1922 | + // long |
|
1404 | 1923 | //$data['verticalrate'] = $line['']; // verticale rate |
1405 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1924 | + if (isset($line['Sqk'])) { |
|
1925 | + $data['squawk'] = $line['Sqk']; |
|
1926 | + } |
|
1927 | + // squawk |
|
1406 | 1928 | $data['emergency'] = ''; // emergency |
1407 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1929 | + if (isset($line['Reg'])) { |
|
1930 | + $data['registration'] = $line['Reg']; |
|
1931 | + } |
|
1408 | 1932 | /* |
1409 | 1933 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1410 | 1934 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1411 | 1935 | */ |
1412 | 1936 | $data['datetime'] = date('Y-m-d H:i:s'); |
1413 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1937 | + if (isset($line['Type'])) { |
|
1938 | + $data['aircraft_icao'] = $line['Type']; |
|
1939 | + } |
|
1414 | 1940 | $data['format_source'] = 'vrstcp'; |
1415 | 1941 | $data['id_source'] = $id_source; |
1416 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1417 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1418 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1942 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1943 | + $data['noarchive'] = true; |
|
1944 | + } |
|
1945 | + if (isset($value['name']) && $value['name'] != '') { |
|
1946 | + $data['source_name'] = $value['name']; |
|
1947 | + } |
|
1948 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1949 | + $SI->add($data); |
|
1950 | + } |
|
1419 | 1951 | unset($data); |
1420 | 1952 | } |
1421 | 1953 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1428,22 +1960,46 @@ discard block |
||
1428 | 1960 | $data['hex'] = $lined['hexid']; |
1429 | 1961 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1430 | 1962 | $data['datetime'] = date('Y-m-d H:i:s');; |
1431 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1432 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1433 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1434 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1435 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1436 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1437 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1963 | + if (isset($lined['ident'])) { |
|
1964 | + $data['ident'] = $lined['ident']; |
|
1965 | + } |
|
1966 | + if (isset($lined['lat'])) { |
|
1967 | + $data['latitude'] = $lined['lat']; |
|
1968 | + } |
|
1969 | + if (isset($lined['lon'])) { |
|
1970 | + $data['longitude'] = $lined['lon']; |
|
1971 | + } |
|
1972 | + if (isset($lined['speed'])) { |
|
1973 | + $data['speed'] = $lined['speed']; |
|
1974 | + } |
|
1975 | + if (isset($lined['squawk'])) { |
|
1976 | + $data['squawk'] = $lined['squawk']; |
|
1977 | + } |
|
1978 | + if (isset($lined['alt'])) { |
|
1979 | + $data['altitude'] = $lined['alt']; |
|
1980 | + } |
|
1981 | + if (isset($lined['heading'])) { |
|
1982 | + $data['heading'] = $lined['heading']; |
|
1983 | + } |
|
1438 | 1984 | $data['id_source'] = $id_source; |
1439 | 1985 | $data['format_source'] = 'tsv'; |
1440 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1441 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1442 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1443 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1986 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1987 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1988 | + } |
|
1989 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1990 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1991 | + } |
|
1992 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1993 | + $data['noarchive'] = true; |
|
1994 | + } |
|
1995 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1996 | + $SI->add($data); |
|
1997 | + } |
|
1444 | 1998 | unset($lined); |
1445 | 1999 | unset($data); |
1446 | - } else $error = true; |
|
2000 | + } else { |
|
2001 | + $error = true; |
|
2002 | + } |
|
1447 | 2003 | } elseif ($format == 'aprs' && $use_aprs) { |
1448 | 2004 | if ($aprs_connect == 0) { |
1449 | 2005 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1468,62 +2024,120 @@ discard block |
||
1468 | 2024 | $aprs_last_tx = time(); |
1469 | 2025 | $data = array(); |
1470 | 2026 | //print_r($line); |
1471 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1472 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1473 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1474 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1475 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1476 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1477 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1478 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1480 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2027 | + if (isset($line['address'])) { |
|
2028 | + $data['hex'] = $line['address']; |
|
2029 | + } |
|
2030 | + if (isset($line['mmsi'])) { |
|
2031 | + $data['mmsi'] = $line['mmsi']; |
|
2032 | + } |
|
2033 | + if (isset($line['imo'])) { |
|
2034 | + $data['imo'] = $line['imo']; |
|
2035 | + } |
|
2036 | + if (isset($line['squawk'])) { |
|
2037 | + $data['squawk'] = $line['squawk']; |
|
2038 | + } |
|
2039 | + if (isset($line['arrival_code'])) { |
|
2040 | + $data['arrical_code'] = $line['arrival_code']; |
|
2041 | + } |
|
2042 | + if (isset($line['arrival_date'])) { |
|
2043 | + $data['arrical_date'] = $line['arrival_date']; |
|
2044 | + } |
|
2045 | + if (isset($line['type_id'])) { |
|
2046 | + $data['type_id'] = $line['typeid']; |
|
2047 | + } |
|
2048 | + if (isset($line['status_id'])) { |
|
2049 | + $data['status_id'] = $line['statusid']; |
|
2050 | + } |
|
2051 | + if (isset($line['timestamp'])) { |
|
2052 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2053 | + } else { |
|
2054 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2055 | + } |
|
1481 | 2056 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1482 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2057 | + if (isset($line['ident'])) { |
|
2058 | + $data['ident'] = $line['ident']; |
|
2059 | + } |
|
1483 | 2060 | $data['latitude'] = $line['latitude']; |
1484 | 2061 | $data['longitude'] = $line['longitude']; |
1485 | 2062 | //$data['verticalrate'] = $line[16]; |
1486 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2063 | + if (isset($line['speed'])) { |
|
2064 | + $data['speed'] = $line['speed']; |
|
2065 | + } |
|
1487 | 2066 | //else $data['speed'] = 0; |
1488 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1489 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1490 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2067 | + if (isset($line['altitude'])) { |
|
2068 | + $data['altitude'] = $line['altitude']; |
|
2069 | + } |
|
2070 | + if (isset($line['comment'])) { |
|
2071 | + $data['comment'] = $line['comment']; |
|
2072 | + } |
|
2073 | + if (isset($line['symbol'])) { |
|
2074 | + $data['type'] = $line['symbol']; |
|
2075 | + } |
|
1491 | 2076 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1492 | 2077 | |
1493 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2078 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2079 | + $data['heading'] = $line['heading']; |
|
2080 | + } |
|
1494 | 2081 | //else echo 'No heading...'."\n"; |
1495 | 2082 | //else $data['heading'] = 0; |
1496 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2083 | + if (isset($line['stealth'])) { |
|
2084 | + $data['aircraft_type'] = $line['stealth']; |
|
2085 | + } |
|
1497 | 2086 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1498 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1499 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1500 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2087 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2088 | + $data['noarchive'] = true; |
|
2089 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2090 | + $data['noarchive'] = false; |
|
2091 | + } |
|
2092 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2093 | + $data['noarchive'] = true; |
|
2094 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2095 | + $data['noarchive'] = false; |
|
2096 | + } |
|
1502 | 2097 | $data['id_source'] = $id_source; |
1503 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1504 | - else $data['format_source'] = 'aprs'; |
|
2098 | + if (isset($line['format_source'])) { |
|
2099 | + $data['format_source'] = $line['format_source']; |
|
2100 | + } else { |
|
2101 | + $data['format_source'] = 'aprs'; |
|
2102 | + } |
|
1505 | 2103 | $data['source_name'] = $line['source']; |
1506 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1507 | - else $data['source_type'] = 'flarm'; |
|
1508 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2104 | + if (isset($line['source_type'])) { |
|
2105 | + $data['source_type'] = $line['source_type']; |
|
2106 | + } else { |
|
2107 | + $data['source_type'] = 'flarm'; |
|
2108 | + } |
|
2109 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2110 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2111 | + } |
|
1509 | 2112 | $currentdate = date('Y-m-d H:i:s'); |
1510 | 2113 | $aprsdate = strtotime($data['datetime']); |
1511 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2114 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2115 | + $data['altitude_relative'] = 'AMSL'; |
|
2116 | + } |
|
1512 | 2117 | // Accept data if time <= system time + 20s |
1513 | 2118 | //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1514 | 2119 | 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'])))) { |
1515 | 2120 | $send = $SI->add($data); |
1516 | 2121 | } elseif ($data['source_type'] == 'ais') { |
1517 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2122 | + if (isset($globalMarine) && $globalMarine) { |
|
2123 | + $send = $MI->add($data); |
|
2124 | + } |
|
1518 | 2125 | } elseif (isset($line['stealth'])) { |
1519 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1520 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2126 | + if ($line['stealth'] != 0) { |
|
2127 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2128 | + } else { |
|
2129 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2130 | + } |
|
1521 | 2131 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1522 | 2132 | //$line['symbol'] == 'Balloon' || |
1523 | 2133 | $line['symbol'] == 'Glider' || |
1524 | 2134 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1525 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1526 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2135 | + if ($line['symbol'] == 'Ballon') { |
|
2136 | + $data['aircraft_icao'] = 'BALL'; |
|
2137 | + } |
|
2138 | + if ($line['symbol'] == 'Glider') { |
|
2139 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2140 | + } |
|
1527 | 2141 | $send = $SI->add($data); |
1528 | 2142 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1529 | 2143 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1554,9 +2168,13 @@ discard block |
||
1554 | 2168 | //} 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') { |
1555 | 2169 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') { |
1556 | 2170 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1557 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2171 | + if (isset($globalTracker) && $globalTracker) { |
|
2172 | + $send = $TI->add($data); |
|
2173 | + } |
|
1558 | 2174 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1559 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2175 | + if (!isset($data['altitude'])) { |
|
2176 | + $data['altitude'] = 0; |
|
2177 | + } |
|
1560 | 2178 | $Source->deleteOldLocationByType('gs'); |
1561 | 2179 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1562 | 2180 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1565,7 +2183,9 @@ discard block |
||
1565 | 2183 | } |
1566 | 2184 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1567 | 2185 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1568 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2186 | + if ($globalDebug) { |
|
2187 | + echo '# Weather Station added'."\n"; |
|
2188 | + } |
|
1569 | 2189 | $Source->deleteOldLocationByType('wx'); |
1570 | 2190 | $weather_data = json_encode($line); |
1571 | 2191 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1575,7 +2195,9 @@ discard block |
||
1575 | 2195 | } |
1576 | 2196 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
1577 | 2197 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1578 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2198 | + if ($globalDebug) { |
|
2199 | + echo '☈ Lightning added'."\n"; |
|
2200 | + } |
|
1579 | 2201 | $Source->deleteOldLocationByType('lightning'); |
1580 | 2202 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1581 | 2203 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1587,8 +2209,7 @@ discard block |
||
1587 | 2209 | print_r($line); |
1588 | 2210 | } |
1589 | 2211 | unset($data); |
1590 | - } |
|
1591 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2212 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1592 | 2213 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1593 | 2214 | } |
1594 | 2215 | /* |
@@ -1597,7 +2218,9 @@ discard block |
||
1597 | 2218 | } |
1598 | 2219 | */ |
1599 | 2220 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1600 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2221 | + elseif ($line == true && $globalDebug) { |
|
2222 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2223 | + } |
|
1601 | 2224 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1602 | 2225 | $Source->deleteOldLocationByType('lightning'); |
1603 | 2226 | $Source->deleteOldLocationByType('wx'); |
@@ -1633,26 +2256,45 @@ discard block |
||
1633 | 2256 | $data['ground'] = $line[21]; |
1634 | 2257 | $data['emergency'] = $line[19]; |
1635 | 2258 | $data['format_source'] = 'sbs'; |
1636 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1637 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1638 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2259 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2260 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2261 | + } |
|
2262 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2263 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2264 | + } |
|
2265 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2266 | + $data['noarchive'] = true; |
|
2267 | + } |
|
1639 | 2268 | $data['id_source'] = $id_source; |
1640 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1641 | - else $error = true; |
|
2269 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2270 | + $send = $SI->add($data); |
|
2271 | + } else { |
|
2272 | + $error = true; |
|
2273 | + } |
|
1642 | 2274 | unset($data); |
1643 | - } else $error = true; |
|
2275 | + } else { |
|
2276 | + $error = true; |
|
2277 | + } |
|
1644 | 2278 | if ($error) { |
1645 | 2279 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1646 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2280 | + if ($globalDebug) { |
|
2281 | + echo "Not a message. Ignoring... \n"; |
|
2282 | + } |
|
1647 | 2283 | } else { |
1648 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2284 | + if ($globalDebug) { |
|
2285 | + echo "Wrong line format. Ignoring... \n"; |
|
2286 | + } |
|
1649 | 2287 | if ($globalDebug) { |
1650 | 2288 | echo $buffer; |
1651 | 2289 | //print_r($line); |
1652 | 2290 | } |
1653 | 2291 | //socket_close($r); |
1654 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1655 | - if ($format == 'aprs') $aprs_connect = 0; |
|
2292 | + if ($globalDebug) { |
|
2293 | + echo "Reconnect after an error...\n"; |
|
2294 | + } |
|
2295 | + if ($format == 'aprs') { |
|
2296 | + $aprs_connect = 0; |
|
2297 | + } |
|
1656 | 2298 | $sourceer[$nb] = $globalSources[$nb]; |
1657 | 2299 | connect_all($sourceer); |
1658 | 2300 | $sourceer = array(); |
@@ -1660,10 +2302,14 @@ discard block |
||
1660 | 2302 | } |
1661 | 2303 | } |
1662 | 2304 | // Sleep for xxx microseconds |
1663 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2305 | + if (isset($globalSBSSleep)) { |
|
2306 | + usleep($globalSBSSleep); |
|
2307 | + } |
|
1664 | 2308 | } else { |
1665 | 2309 | if ($format == 'flightgearmp') { |
1666 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2310 | + if ($globalDebug) { |
|
2311 | + echo "Reconnect FlightGear MP..."; |
|
2312 | + } |
|
1667 | 2313 | //@socket_close($r); |
1668 | 2314 | sleep($globalMinFetch); |
1669 | 2315 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1672,10 +2318,15 @@ discard block |
||
1672 | 2318 | break; |
1673 | 2319 | |
1674 | 2320 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1675 | - if (isset($tt[$format])) $tt[$format]++; |
|
1676 | - else $tt[$format] = 0; |
|
2321 | + if (isset($tt[$format])) { |
|
2322 | + $tt[$format]++; |
|
2323 | + } else { |
|
2324 | + $tt[$format] = 0; |
|
2325 | + } |
|
1677 | 2326 | if ($tt[$format] > 30) { |
1678 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2327 | + if ($globalDebug) { |
|
2328 | + echo "ERROR : Reconnect ".$format."..."; |
|
2329 | + } |
|
1679 | 2330 | //@socket_close($r); |
1680 | 2331 | sleep(2); |
1681 | 2332 | $aprs_connect = 0; |
@@ -1692,11 +2343,17 @@ discard block |
||
1692 | 2343 | } else { |
1693 | 2344 | $error = socket_strerror(socket_last_error()); |
1694 | 2345 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1695 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1696 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2346 | + if ($globalDebug) { |
|
2347 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2348 | + } |
|
2349 | + if (isset($globalDebug)) { |
|
2350 | + echo "Restarting...\n"; |
|
2351 | + } |
|
1697 | 2352 | // Restart the script if possible |
1698 | 2353 | if (is_array($sockets)) { |
1699 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2354 | + if ($globalDebug) { |
|
2355 | + echo "Shutdown all sockets..."; |
|
2356 | + } |
|
1700 | 2357 | |
1701 | 2358 | foreach ($sockets as $sock) { |
1702 | 2359 | @socket_shutdown($sock,2); |
@@ -1704,25 +2361,45 @@ discard block |
||
1704 | 2361 | } |
1705 | 2362 | |
1706 | 2363 | } |
1707 | - if ($globalDebug) echo "Waiting..."; |
|
2364 | + if ($globalDebug) { |
|
2365 | + echo "Waiting..."; |
|
2366 | + } |
|
1708 | 2367 | sleep(2); |
1709 | 2368 | $time = time(); |
1710 | 2369 | //connect_all($hosts); |
1711 | 2370 | $aprs_connect = 0; |
1712 | - if ($reset%5 == 0) sleep(20); |
|
1713 | - if ($reset%10 == 0) sleep(100); |
|
1714 | - if ($reset%20 == 0) sleep(200); |
|
1715 | - if ($reset > 100) exit('Too many attempts...'); |
|
1716 | - if ($globalDebug) echo "Restart all connections..."; |
|
2371 | + if ($reset%5 == 0) { |
|
2372 | + sleep(20); |
|
2373 | + } |
|
2374 | + if ($reset%10 == 0) { |
|
2375 | + sleep(100); |
|
2376 | + } |
|
2377 | + if ($reset%20 == 0) { |
|
2378 | + sleep(200); |
|
2379 | + } |
|
2380 | + if ($reset > 100) { |
|
2381 | + exit('Too many attempts...'); |
|
2382 | + } |
|
2383 | + if ($globalDebug) { |
|
2384 | + echo "Restart all connections..."; |
|
2385 | + } |
|
1717 | 2386 | connect_all($globalSources); |
1718 | 2387 | } |
1719 | 2388 | } |
1720 | 2389 | } |
1721 | 2390 | if ($globalDaemon === false) { |
1722 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1723 | - if (isset($SI)) $SI->checkAll(); |
|
1724 | - if (isset($TI)) $TI->checkAll(); |
|
1725 | - if (isset($MI)) $MI->checkAll(); |
|
2391 | + if ($globalDebug) { |
|
2392 | + echo 'Check all...'."\n"; |
|
2393 | + } |
|
2394 | + if (isset($SI)) { |
|
2395 | + $SI->checkAll(); |
|
2396 | + } |
|
2397 | + if (isset($TI)) { |
|
2398 | + $TI->checkAll(); |
|
2399 | + } |
|
2400 | + if (isset($MI)) { |
|
2401 | + $MI->checkAll(); |
|
2402 | + } |
|
1726 | 2403 | } |
1727 | 2404 | } |
1728 | 2405 | } |