@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + $globalSources[] = array('host' => $options['s']); |
|
58 | 58 | } elseif (isset($options['source'])) { |
59 | - $globalSources = array(); |
|
60 | - $globalSources[] = array('host' => $options['source']); |
|
59 | + $globalSources = array(); |
|
60 | + $globalSources[] = array('host' => $options['source']); |
|
61 | 61 | } |
62 | 62 | if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
63 | 63 | if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | - $SI=new SpotterServer(); |
|
69 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | + $SI=new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } else $SI=new SpotterImport($Connection->db); |
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | - $AIS = new AIS(); |
|
80 | - $MI = new MarineImport($Connection->db); |
|
79 | + $AIS = new AIS(); |
|
80 | + $MI = new MarineImport($Connection->db); |
|
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | 83 | $SBS=new SBS(); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
91 | - global $sockets; |
|
92 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | - die("Bye!\n"); |
|
94 | - }); |
|
95 | - pcntl_signal_dispatch(); |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | + global $sockets; |
|
92 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | + die("Bye!\n"); |
|
94 | + }); |
|
95 | + pcntl_signal_dispatch(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // let's try and connect |
@@ -102,153 +102,153 @@ discard block |
||
102 | 102 | $reset = 0; |
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | - $reset++; |
|
108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | - foreach ($hosts as $id => $value) { |
|
105 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | + $reset++; |
|
108 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | + foreach ($hosts as $id => $value) { |
|
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | 113 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | - //$formats[$id] = 'deltadbtxt'; |
|
116 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | - //$last_exec['deltadbtxt'] = 0; |
|
118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | - //$formats[$id] = 'vatsimtxt'; |
|
121 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | - //$last_exec['vatsimtxt'] = 0; |
|
123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | - //$formats[$id] = 'aircraftlistjson'; |
|
126 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | - //$last_exec['aircraftlistjson'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
130 | - //$formats[$id] = 'aircraftlistjson'; |
|
131 | - $globalSources[$id]['format'] = 'opensky'; |
|
132 | - //$last_exec['aircraftlistjson'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'radarvirtueljson'; |
|
136 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | - //$last_exec['radarvirtueljson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | - exit(0); |
|
142 | - } |
|
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | - //$formats[$id] = 'planeupdatefaa'; |
|
145 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | - //$last_exec['planeupdatefaa'] = 0; |
|
147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | - exit(0); |
|
151 | - } |
|
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | - //$formats[$id] = 'phpvmacars'; |
|
154 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | - //$last_exec['phpvmacars'] = 0; |
|
156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | - //$formats[$id] = 'phpvmacars'; |
|
159 | - $globalSources[$id]['format'] = 'vam'; |
|
160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
162 | - //$formats[$id] = 'whazzup'; |
|
163 | - $globalSources[$id]['format'] = 'whazzup'; |
|
164 | - //$last_exec['whazzup'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | - //$formats[$id] = 'pirepsjson'; |
|
168 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | - //$last_exec['pirepsjson'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | - //$formats[$id] = 'fr24json'; |
|
173 | - $globalSources[$id]['format'] = 'fr24json'; |
|
174 | - //$last_exec['fr24json'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | - exit(0); |
|
179 | - } |
|
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | - //$formats[$id] = 'fr24json'; |
|
182 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | - //$last_exec['fr24json'] = 0; |
|
184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | - exit(0); |
|
188 | - } |
|
189 | - //} else if (preg_match('/10001/',$host)) { |
|
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | - //$formats[$id] = 'tsv'; |
|
192 | - $globalSources[$id]['format'] = 'tsv'; |
|
193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | - } |
|
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | - if ($idf !== false) { |
|
199 | - $httpfeeds[$id] = $idf; |
|
200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | - } |
|
202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
206 | - if (isset($hostport[1])) { |
|
114 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | + //$formats[$id] = 'deltadbtxt'; |
|
116 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | + //$last_exec['deltadbtxt'] = 0; |
|
118 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | + //$formats[$id] = 'vatsimtxt'; |
|
121 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | + //$last_exec['vatsimtxt'] = 0; |
|
123 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | + //$formats[$id] = 'aircraftlistjson'; |
|
126 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | + //$last_exec['aircraftlistjson'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/opensky/i',$host)) { |
|
130 | + //$formats[$id] = 'aircraftlistjson'; |
|
131 | + $globalSources[$id]['format'] = 'opensky'; |
|
132 | + //$last_exec['aircraftlistjson'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'radarvirtueljson'; |
|
136 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | + //$last_exec['radarvirtueljson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | + exit(0); |
|
142 | + } |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | + //$formats[$id] = 'planeupdatefaa'; |
|
145 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | + //$last_exec['planeupdatefaa'] = 0; |
|
147 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | + exit(0); |
|
151 | + } |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | + //$formats[$id] = 'phpvmacars'; |
|
154 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | + //$last_exec['phpvmacars'] = 0; |
|
156 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | + //$formats[$id] = 'phpvmacars'; |
|
159 | + $globalSources[$id]['format'] = 'vam'; |
|
160 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | + } else if (preg_match('/whazzup/i',$host)) { |
|
162 | + //$formats[$id] = 'whazzup'; |
|
163 | + $globalSources[$id]['format'] = 'whazzup'; |
|
164 | + //$last_exec['whazzup'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | + //$formats[$id] = 'pirepsjson'; |
|
168 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | + //$last_exec['pirepsjson'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | + //$formats[$id] = 'fr24json'; |
|
173 | + $globalSources[$id]['format'] = 'fr24json'; |
|
174 | + //$last_exec['fr24json'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | + exit(0); |
|
179 | + } |
|
180 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | + //$formats[$id] = 'fr24json'; |
|
182 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | + //$last_exec['fr24json'] = 0; |
|
184 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | + exit(0); |
|
188 | + } |
|
189 | + //} else if (preg_match('/10001/',$host)) { |
|
190 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | + //$formats[$id] = 'tsv'; |
|
192 | + $globalSources[$id]['format'] = 'tsv'; |
|
193 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | + } |
|
195 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | + if ($idf !== false) { |
|
199 | + $httpfeeds[$id] = $idf; |
|
200 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | + } |
|
202 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':',$host); |
|
206 | + if (isset($hostport[1])) { |
|
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | $port = $globalSources[$id]['port']; |
211 | 211 | $hostn = $globalSources[$id]['host']; |
212 | - } |
|
213 | - $Common = new Common(); |
|
214 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | - } else { |
|
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | - } |
|
219 | - if ($s) { |
|
220 | - $sockets[$id] = $s; |
|
221 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
212 | + } |
|
213 | + $Common = new Common(); |
|
214 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | + } else { |
|
217 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | + } |
|
219 | + if ($s) { |
|
220 | + $sockets[$id] = $s; |
|
221 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | - } elseif ($port == '10001') { |
|
230 | - //$formats[$id] = 'tsv'; |
|
231 | - $globalSources[$id]['format'] = 'tsv'; |
|
232 | - } elseif ($port == '30002') { |
|
233 | - //$formats[$id] = 'raw'; |
|
234 | - $globalSources[$id]['format'] = 'raw'; |
|
235 | - } elseif ($port == '5001') { |
|
236 | - //$formats[$id] = 'raw'; |
|
237 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | - } elseif ($port == '30005') { |
|
229 | + } elseif ($port == '10001') { |
|
230 | + //$formats[$id] = 'tsv'; |
|
231 | + $globalSources[$id]['format'] = 'tsv'; |
|
232 | + } elseif ($port == '30002') { |
|
233 | + //$formats[$id] = 'raw'; |
|
234 | + $globalSources[$id]['format'] = 'raw'; |
|
235 | + } elseif ($port == '5001') { |
|
236 | + //$formats[$id] = 'raw'; |
|
237 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | + } elseif ($port == '30005') { |
|
239 | 239 | // Not yet supported |
240 | - //$formats[$id] = 'beast'; |
|
241 | - $globalSources[$id]['format'] = 'beast'; |
|
242 | - //} else $formats[$id] = 'sbs'; |
|
243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
240 | + //$formats[$id] = 'beast'; |
|
241 | + $globalSources[$id]['format'] = 'beast'; |
|
242 | + //} else $formats[$id] = 'sbs'; |
|
243 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
245 | 245 | } |
246 | 246 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
247 | - } else { |
|
247 | + } else { |
|
248 | 248 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
249 | - } |
|
250 | - } |
|
251 | - } |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
254 | 254 | |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
276 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // APRS Configuration |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | die; |
283 | 283 | } |
284 | 284 | foreach ($globalSources as $key => $source) { |
285 | - if (!isset($source['format'])) { |
|
286 | - $globalSources[$key]['format'] = 'auto'; |
|
287 | - } |
|
285 | + if (!isset($source['format'])) { |
|
286 | + $globalSources[$key]['format'] = 'auto'; |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | connect_all($globalSources); |
290 | 290 | foreach ($globalSources as $key => $source) { |
291 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
291 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
292 | 292 | $aprs_connect = 0; |
293 | 293 | $use_aprs = true; |
294 | 294 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
295 | 295 | break; |
296 | - } |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | if ($use_aprs) { |
@@ -335,152 +335,152 @@ discard block |
||
335 | 335 | |
336 | 336 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
337 | 337 | while ($i > 0) { |
338 | - if (!$globalDaemon) $i = $endtime-time(); |
|
339 | - // Delete old ATC |
|
340 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
338 | + if (!$globalDaemon) $i = $endtime-time(); |
|
339 | + // Delete old ATC |
|
340 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
341 | 341 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
342 | - $ATC->deleteOldATC(); |
|
343 | - } |
|
342 | + $ATC->deleteOldATC(); |
|
343 | + } |
|
344 | 344 | |
345 | - //if (count($last_exec) > 0) { |
|
346 | - if (count($last_exec) == count($globalSources)) { |
|
345 | + //if (count($last_exec) > 0) { |
|
346 | + if (count($last_exec) == count($globalSources)) { |
|
347 | 347 | $max = $globalMinFetch; |
348 | 348 | foreach ($last_exec as $last) { |
349 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
349 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
350 | 350 | } |
351 | 351 | if ($max != $globalMinFetch) { |
352 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
353 | - sleep($globalMinFetch-$max+2); |
|
352 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
353 | + sleep($globalMinFetch-$max+2); |
|
354 | + } |
|
354 | 355 | } |
355 | - } |
|
356 | 356 | |
357 | 357 | |
358 | - //foreach ($formats as $id => $value) { |
|
359 | - foreach ($globalSources as $id => $value) { |
|
358 | + //foreach ($formats as $id => $value) { |
|
359 | + foreach ($globalSources as $id => $value) { |
|
360 | 360 | date_default_timezone_set('UTC'); |
361 | 361 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
362 | 362 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
363 | - //$buffer = $Common->getData($hosts[$id]); |
|
364 | - $buffer = $Common->getData($value['host']); |
|
365 | - if ($buffer != '') $reset = 0; |
|
366 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
367 | - $buffer = explode('\n',$buffer); |
|
368 | - foreach ($buffer as $line) { |
|
369 | - if ($line != '' && count($line) > 7) { |
|
370 | - $line = explode(',', $line); |
|
371 | - $data = array(); |
|
372 | - $data['hex'] = $line[1]; // hex |
|
373 | - $data['ident'] = $line[2]; // ident |
|
374 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
375 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
376 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
377 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
378 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
379 | - $data['verticalrate'] = ''; // vertical rate |
|
380 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
381 | - $data['emergency'] = ''; // emergency |
|
382 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
383 | - $data['format_source'] = 'deltadbtxt'; |
|
384 | - $data['id_source'] = $id_source; |
|
385 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
386 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
387 | - $SI->add($data); |
|
388 | - unset($data); |
|
389 | - } |
|
390 | - } |
|
391 | - $last_exec[$id]['last'] = time(); |
|
363 | + //$buffer = $Common->getData($hosts[$id]); |
|
364 | + $buffer = $Common->getData($value['host']); |
|
365 | + if ($buffer != '') $reset = 0; |
|
366 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
367 | + $buffer = explode('\n',$buffer); |
|
368 | + foreach ($buffer as $line) { |
|
369 | + if ($line != '' && count($line) > 7) { |
|
370 | + $line = explode(',', $line); |
|
371 | + $data = array(); |
|
372 | + $data['hex'] = $line[1]; // hex |
|
373 | + $data['ident'] = $line[2]; // ident |
|
374 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
375 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
376 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
377 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
378 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
379 | + $data['verticalrate'] = ''; // vertical rate |
|
380 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
381 | + $data['emergency'] = ''; // emergency |
|
382 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
383 | + $data['format_source'] = 'deltadbtxt'; |
|
384 | + $data['id_source'] = $id_source; |
|
385 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
386 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
387 | + $SI->add($data); |
|
388 | + unset($data); |
|
389 | + } |
|
390 | + } |
|
391 | + $last_exec[$id]['last'] = time(); |
|
392 | 392 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
393 | - date_default_timezone_set('CET'); |
|
394 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
395 | - date_default_timezone_set('UTC'); |
|
396 | - if ($buffer != '') $reset = 0; |
|
397 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
398 | - $buffer = explode('\n',$buffer); |
|
399 | - foreach ($buffer as $line) { |
|
393 | + date_default_timezone_set('CET'); |
|
394 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
395 | + date_default_timezone_set('UTC'); |
|
396 | + if ($buffer != '') $reset = 0; |
|
397 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
398 | + $buffer = explode('\n',$buffer); |
|
399 | + foreach ($buffer as $line) { |
|
400 | 400 | if ($line != '') { |
401 | - echo "'".$line."'\n"; |
|
402 | - $add = false; |
|
403 | - $ais_data = $AIS->parse_line(trim($line)); |
|
404 | - $data = array(); |
|
405 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
406 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
407 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
408 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
409 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
410 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
411 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
412 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
413 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
414 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
415 | - if (isset($ais_data['timestamp'])) { |
|
401 | + echo "'".$line."'\n"; |
|
402 | + $add = false; |
|
403 | + $ais_data = $AIS->parse_line(trim($line)); |
|
404 | + $data = array(); |
|
405 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
406 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
407 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
408 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
409 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
410 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
411 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
412 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
413 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
414 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
415 | + if (isset($ais_data['timestamp'])) { |
|
416 | 416 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
417 | 417 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
418 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
419 | - $add = true; |
|
418 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
419 | + $add = true; |
|
420 | 420 | } |
421 | - } else { |
|
421 | + } else { |
|
422 | 422 | $data['datetime'] = date('Y-m-d H:i:s'); |
423 | 423 | $add = true; |
424 | - } |
|
425 | - $data['format_source'] = 'aisnmeatxt'; |
|
426 | - $data['id_source'] = $id_source; |
|
427 | - print_r($data); |
|
428 | - echo 'Add...'."\n"; |
|
429 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
430 | - unset($data); |
|
424 | + } |
|
425 | + $data['format_source'] = 'aisnmeatxt'; |
|
426 | + $data['id_source'] = $id_source; |
|
427 | + print_r($data); |
|
428 | + echo 'Add...'."\n"; |
|
429 | + if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
430 | + unset($data); |
|
431 | 431 | } |
432 | - } |
|
433 | - $last_exec[$id]['last'] = time(); |
|
432 | + } |
|
433 | + $last_exec[$id]['last'] = time(); |
|
434 | 434 | } elseif ($value['format'] == 'aisnmeahttp') { |
435 | - $arr = $httpfeeds; |
|
436 | - $w = $e = null; |
|
435 | + $arr = $httpfeeds; |
|
436 | + $w = $e = null; |
|
437 | 437 | |
438 | - if (isset($arr[$id])) { |
|
439 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
440 | - if ($nn > 0) { |
|
438 | + if (isset($arr[$id])) { |
|
439 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
440 | + if ($nn > 0) { |
|
441 | 441 | foreach ($httpfeeds as $feed) { |
442 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
443 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
444 | - $buffer = explode('\n',$buffer); |
|
445 | - foreach ($buffer as $line) { |
|
442 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
443 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
444 | + $buffer = explode('\n',$buffer); |
|
445 | + foreach ($buffer as $line) { |
|
446 | 446 | if ($line != '') { |
447 | - $ais_data = $AIS->parse_line(trim($line)); |
|
448 | - $data = array(); |
|
449 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
450 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
451 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
452 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
453 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
454 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
455 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
456 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
457 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
458 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
459 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
460 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
461 | - if (isset($ais_data['timestamp'])) { |
|
447 | + $ais_data = $AIS->parse_line(trim($line)); |
|
448 | + $data = array(); |
|
449 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
450 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
451 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
452 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
453 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
454 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
455 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
456 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
457 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
458 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
459 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
460 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
461 | + if (isset($ais_data['timestamp'])) { |
|
462 | 462 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
463 | - } else { |
|
463 | + } else { |
|
464 | 464 | $data['datetime'] = date('Y-m-d H:i:s'); |
465 | - } |
|
466 | - $data['format_source'] = 'aisnmeahttp'; |
|
467 | - $data['id_source'] = $id_source; |
|
468 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
469 | - unset($data); |
|
465 | + } |
|
466 | + $data['format_source'] = 'aisnmeahttp'; |
|
467 | + $data['id_source'] = $id_source; |
|
468 | + if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
469 | + unset($data); |
|
470 | 470 | } |
471 | - } |
|
471 | + } |
|
472 | + } |
|
472 | 473 | } |
473 | 474 | } |
474 | - } |
|
475 | 475 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
476 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
477 | - if ($buffer != '') { |
|
476 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
477 | + if ($buffer != '') { |
|
478 | 478 | //echo $buffer; |
479 | 479 | $all_data = json_decode($buffer,true); |
480 | 480 | //print_r($all_data); |
481 | 481 | if (isset($all_data[0]['DATA'])) { |
482 | 482 | foreach ($all_data[0]['DATA'] as $line) { |
483 | - if ($line != '') { |
|
483 | + if ($line != '') { |
|
484 | 484 | $data = array(); |
485 | 485 | $data['ident'] = $line['NAME']; |
486 | 486 | $data['mmsi'] = $line['MMSI']; |
@@ -496,87 +496,87 @@ discard block |
||
496 | 496 | $data['id_source'] = $id_source; |
497 | 497 | $MI->add($data); |
498 | 498 | unset($data); |
499 | - } |
|
499 | + } |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - } |
|
504 | - $last_exec[$id]['last'] = time(); |
|
503 | + } |
|
504 | + $last_exec[$id]['last'] = time(); |
|
505 | 505 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
506 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
507 | - if ($buffer != '') { |
|
506 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
507 | + if ($buffer != '') { |
|
508 | 508 | $all_data = json_decode($buffer,true); |
509 | 509 | if (isset($all_data[0]['mmsi'])) { |
510 | - foreach ($all_data as $line) { |
|
510 | + foreach ($all_data as $line) { |
|
511 | 511 | if ($line != '') { |
512 | - $data = array(); |
|
513 | - $data['ident'] = $line['shipname']; |
|
514 | - $data['callsign'] = $line['callsign']; |
|
515 | - $data['mmsi'] = $line['mmsi']; |
|
516 | - $data['speed'] = $line['sog']; |
|
517 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
518 | - $data['latitude'] = $line['latitude']; |
|
519 | - $data['longitude'] = $line['longitude']; |
|
520 | - $data['type_id'] = $line['shiptype']; |
|
521 | - $data['arrival_code'] = $line['destination']; |
|
522 | - $data['datetime'] = $line['time']; |
|
523 | - $data['format_source'] = 'boatbeaconapp'; |
|
524 | - $data['id_source'] = $id_source; |
|
525 | - $MI->add($data); |
|
526 | - unset($data); |
|
512 | + $data = array(); |
|
513 | + $data['ident'] = $line['shipname']; |
|
514 | + $data['callsign'] = $line['callsign']; |
|
515 | + $data['mmsi'] = $line['mmsi']; |
|
516 | + $data['speed'] = $line['sog']; |
|
517 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
518 | + $data['latitude'] = $line['latitude']; |
|
519 | + $data['longitude'] = $line['longitude']; |
|
520 | + $data['type_id'] = $line['shiptype']; |
|
521 | + $data['arrival_code'] = $line['destination']; |
|
522 | + $data['datetime'] = $line['time']; |
|
523 | + $data['format_source'] = 'boatbeaconapp'; |
|
524 | + $data['id_source'] = $id_source; |
|
525 | + $MI->add($data); |
|
526 | + unset($data); |
|
527 | + } |
|
527 | 528 | } |
528 | - } |
|
529 | 529 | } |
530 | 530 | |
531 | - } |
|
532 | - $last_exec[$id]['last'] = time(); |
|
531 | + } |
|
532 | + $last_exec[$id]['last'] = time(); |
|
533 | 533 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
534 | - echo 'download...'; |
|
535 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
536 | - echo 'done !'."\n"; |
|
537 | - if ($buffer != '') $reset = 0; |
|
538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | - $buffer = explode('\n',$buffer); |
|
540 | - foreach ($buffer as $line) { |
|
534 | + echo 'download...'; |
|
535 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
536 | + echo 'done !'."\n"; |
|
537 | + if ($buffer != '') $reset = 0; |
|
538 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | + $buffer = explode('\n',$buffer); |
|
540 | + foreach ($buffer as $line) { |
|
541 | 541 | if ($line != '') { |
542 | - $data = array(); |
|
543 | - $data['mmsi'] = (int)substr($line,0,9); |
|
544 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
545 | - //$data['status'] = substr($line,21,2); |
|
546 | - //$data['type'] = substr($line,24,3); |
|
547 | - $data['latitude'] = substr($line,29,9); |
|
548 | - $data['longitude'] = substr($line,41,9); |
|
549 | - $data['speed'] = round(substr($line,51,5)); |
|
550 | - //$data['course'] = substr($line,57,5); |
|
551 | - $data['heading'] = round(substr($line,63,3)); |
|
552 | - //$data['draft'] = substr($line,67,4); |
|
553 | - //$data['length'] = substr($line,72,3); |
|
554 | - //$data['beam'] = substr($line,76,2); |
|
555 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
556 | - //$data['callsign'] = trim(substr($line,100,7); |
|
557 | - //$data['dest'] = substr($line,108,20); |
|
558 | - //$data['etaDate'] = substr($line,129,5); |
|
559 | - //$data['etaTime'] = substr($line,135,5); |
|
560 | - $data['format_source'] = 'shipplotter'; |
|
561 | - $data['id_source'] = $id_source; |
|
562 | - print_r($data); |
|
563 | - echo 'Add...'."\n"; |
|
564 | - $MI->add($data); |
|
565 | - unset($data); |
|
542 | + $data = array(); |
|
543 | + $data['mmsi'] = (int)substr($line,0,9); |
|
544 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
545 | + //$data['status'] = substr($line,21,2); |
|
546 | + //$data['type'] = substr($line,24,3); |
|
547 | + $data['latitude'] = substr($line,29,9); |
|
548 | + $data['longitude'] = substr($line,41,9); |
|
549 | + $data['speed'] = round(substr($line,51,5)); |
|
550 | + //$data['course'] = substr($line,57,5); |
|
551 | + $data['heading'] = round(substr($line,63,3)); |
|
552 | + //$data['draft'] = substr($line,67,4); |
|
553 | + //$data['length'] = substr($line,72,3); |
|
554 | + //$data['beam'] = substr($line,76,2); |
|
555 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
556 | + //$data['callsign'] = trim(substr($line,100,7); |
|
557 | + //$data['dest'] = substr($line,108,20); |
|
558 | + //$data['etaDate'] = substr($line,129,5); |
|
559 | + //$data['etaTime'] = substr($line,135,5); |
|
560 | + $data['format_source'] = 'shipplotter'; |
|
561 | + $data['id_source'] = $id_source; |
|
562 | + print_r($data); |
|
563 | + echo 'Add...'."\n"; |
|
564 | + $MI->add($data); |
|
565 | + unset($data); |
|
566 | 566 | } |
567 | - } |
|
568 | - $last_exec[$id]['last'] = time(); |
|
567 | + } |
|
568 | + $last_exec[$id]['last'] = time(); |
|
569 | 569 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
570 | 570 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
571 | - //$buffer = $Common->getData($hosts[$id]); |
|
572 | - $buffer = $Common->getData($value['host']); |
|
573 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
574 | - $buffer = explode('\n',$buffer); |
|
575 | - $reset = 0; |
|
576 | - foreach ($buffer as $line) { |
|
577 | - if ($line != '') { |
|
578 | - $line = explode(':', $line); |
|
579 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
571 | + //$buffer = $Common->getData($hosts[$id]); |
|
572 | + $buffer = $Common->getData($value['host']); |
|
573 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
574 | + $buffer = explode('\n',$buffer); |
|
575 | + $reset = 0; |
|
576 | + foreach ($buffer as $line) { |
|
577 | + if ($line != '') { |
|
578 | + $line = explode(':', $line); |
|
579 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
580 | 580 | $data = array(); |
581 | 581 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
582 | 582 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -589,36 +589,36 @@ discard block |
||
589 | 589 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
590 | 590 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
591 | 591 | $data['latitude'] = $line[5]; // lat |
592 | - $data['longitude'] = $line[6]; // long |
|
593 | - $data['verticalrate'] = ''; // vertical rate |
|
594 | - $data['squawk'] = ''; // squawk |
|
595 | - $data['emergency'] = ''; // emergency |
|
596 | - $data['waypoints'] = $line[30]; |
|
592 | + $data['longitude'] = $line[6]; // long |
|
593 | + $data['verticalrate'] = ''; // vertical rate |
|
594 | + $data['squawk'] = ''; // squawk |
|
595 | + $data['emergency'] = ''; // emergency |
|
596 | + $data['waypoints'] = $line[30]; |
|
597 | 597 | $data['datetime'] = date('Y-m-d H:i:s'); |
598 | 598 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
599 | 599 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
600 | - $data['departure_airport_icao'] = $line[11]; |
|
601 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
602 | - $data['arrival_airport_icao'] = $line[13]; |
|
600 | + $data['departure_airport_icao'] = $line[11]; |
|
601 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
602 | + $data['arrival_airport_icao'] = $line[13]; |
|
603 | 603 | $data['frequency'] = $line[4]; |
604 | 604 | $data['type'] = $line[18]; |
605 | 605 | $data['range'] = $line[19]; |
606 | 606 | if (isset($line[35])) $data['info'] = $line[35]; |
607 | - $data['id_source'] = $id_source; |
|
608 | - //$data['arrival_airport_time'] = ; |
|
609 | - if ($line[9] != '') { |
|
610 | - $aircraft_data = explode('/',$line[9]); |
|
611 | - if (isset($aircraft_data[1])) { |
|
612 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
613 | - } |
|
614 | - } |
|
615 | - /* |
|
607 | + $data['id_source'] = $id_source; |
|
608 | + //$data['arrival_airport_time'] = ; |
|
609 | + if ($line[9] != '') { |
|
610 | + $aircraft_data = explode('/',$line[9]); |
|
611 | + if (isset($aircraft_data[1])) { |
|
612 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
613 | + } |
|
614 | + } |
|
615 | + /* |
|
616 | 616 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
617 | 617 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
618 | 618 | */ |
619 | - $data['format_source'] = $value['format']; |
|
619 | + $data['format_source'] = $value['format']; |
|
620 | 620 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
621 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
621 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
622 | 622 | elseif ($line[3] == 'ATC') { |
623 | 623 | //print_r($data); |
624 | 624 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -636,247 +636,247 @@ discard block |
||
636 | 636 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
637 | 637 | if (isset($ATC)) 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']); |
638 | 638 | } |
639 | - unset($data); |
|
640 | - } |
|
641 | - } |
|
642 | - } |
|
643 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
644 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
645 | - $last_exec[$id]['last'] = time(); |
|
646 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
647 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
648 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
649 | - if ($buffer != '') { |
|
650 | - $all_data = json_decode($buffer,true); |
|
651 | - if (isset($all_data['acList'])) { |
|
639 | + unset($data); |
|
640 | + } |
|
641 | + } |
|
642 | + } |
|
643 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
644 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
645 | + $last_exec[$id]['last'] = time(); |
|
646 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
647 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
648 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
649 | + if ($buffer != '') { |
|
650 | + $all_data = json_decode($buffer,true); |
|
651 | + if (isset($all_data['acList'])) { |
|
652 | 652 | $reset = 0; |
653 | 653 | foreach ($all_data['acList'] as $line) { |
654 | - $data = array(); |
|
655 | - $data['hex'] = $line['Icao']; // hex |
|
656 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
657 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
658 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
659 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
660 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
661 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
662 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
663 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
664 | - $data['emergency'] = ''; // emergency |
|
665 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
666 | - /* |
|
654 | + $data = array(); |
|
655 | + $data['hex'] = $line['Icao']; // hex |
|
656 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
657 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
658 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
659 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
660 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
661 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
662 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
663 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
664 | + $data['emergency'] = ''; // emergency |
|
665 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
666 | + /* |
|
667 | 667 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
668 | 668 | else $data['datetime'] = date('Y-m-d H:i:s'); |
669 | 669 | */ |
670 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
671 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
672 | - $data['format_source'] = 'aircraftlistjson'; |
|
673 | - $data['id_source'] = $id_source; |
|
674 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
675 | - if (isset($data['latitude'])) $SI->add($data); |
|
676 | - unset($data); |
|
670 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
671 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
672 | + $data['format_source'] = 'aircraftlistjson'; |
|
673 | + $data['id_source'] = $id_source; |
|
674 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
675 | + if (isset($data['latitude'])) $SI->add($data); |
|
676 | + unset($data); |
|
677 | 677 | } |
678 | - } elseif (is_array($all_data)) { |
|
678 | + } elseif (is_array($all_data)) { |
|
679 | 679 | $reset = 0; |
680 | 680 | foreach ($all_data as $line) { |
681 | - $data = array(); |
|
682 | - $data['hex'] = $line['hex']; // hex |
|
683 | - $data['ident'] = $line['flight']; // ident |
|
684 | - $data['altitude'] = $line['altitude']; // altitude |
|
685 | - $data['speed'] = $line['speed']; // speed |
|
686 | - $data['heading'] = $line['track']; // heading |
|
687 | - $data['latitude'] = $line['lat']; // lat |
|
688 | - $data['longitude'] = $line['lon']; // long |
|
689 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
690 | - $data['squawk'] = $line['squawk']; // squawk |
|
691 | - $data['emergency'] = ''; // emergency |
|
692 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
693 | - $data['format_source'] = 'aircraftlistjson'; |
|
694 | - $data['id_source'] = $id_source; |
|
695 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
696 | - $SI->add($data); |
|
697 | - unset($data); |
|
681 | + $data = array(); |
|
682 | + $data['hex'] = $line['hex']; // hex |
|
683 | + $data['ident'] = $line['flight']; // ident |
|
684 | + $data['altitude'] = $line['altitude']; // altitude |
|
685 | + $data['speed'] = $line['speed']; // speed |
|
686 | + $data['heading'] = $line['track']; // heading |
|
687 | + $data['latitude'] = $line['lat']; // lat |
|
688 | + $data['longitude'] = $line['lon']; // long |
|
689 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
690 | + $data['squawk'] = $line['squawk']; // squawk |
|
691 | + $data['emergency'] = ''; // emergency |
|
692 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
693 | + $data['format_source'] = 'aircraftlistjson'; |
|
694 | + $data['id_source'] = $id_source; |
|
695 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
696 | + $SI->add($data); |
|
697 | + unset($data); |
|
698 | + } |
|
698 | 699 | } |
699 | - } |
|
700 | - } |
|
701 | - //$last_exec['aircraftlistjson'] = time(); |
|
702 | - $last_exec[$id]['last'] = time(); |
|
703 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
704 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
705 | - $buffer = $Common->getData($value['host']); |
|
706 | - $all_data = json_decode($buffer,true); |
|
707 | - if (isset($all_data['planes'])) { |
|
700 | + } |
|
701 | + //$last_exec['aircraftlistjson'] = time(); |
|
702 | + $last_exec[$id]['last'] = time(); |
|
703 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
704 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
705 | + $buffer = $Common->getData($value['host']); |
|
706 | + $all_data = json_decode($buffer,true); |
|
707 | + if (isset($all_data['planes'])) { |
|
708 | 708 | $reset = 0; |
709 | 709 | foreach ($all_data['planes'] as $key => $line) { |
710 | - $data = array(); |
|
711 | - $data['hex'] = $key; // hex |
|
712 | - $data['ident'] = $line[3]; // ident |
|
713 | - $data['altitude'] = $line[6]; // altitude |
|
714 | - $data['speed'] = $line[8]; // speed |
|
715 | - $data['heading'] = $line[7]; // heading |
|
716 | - $data['latitude'] = $line[4]; // lat |
|
717 | - $data['longitude'] = $line[5]; // long |
|
718 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
719 | - $data['squawk'] = $line[10]; // squawk |
|
720 | - $data['emergency'] = ''; // emergency |
|
721 | - $data['registration'] = $line[2]; |
|
722 | - $data['aircraft_icao'] = $line[0]; |
|
723 | - $deparr = explode('-',$line[1]); |
|
724 | - if (count($deparr) == 2) { |
|
710 | + $data = array(); |
|
711 | + $data['hex'] = $key; // hex |
|
712 | + $data['ident'] = $line[3]; // ident |
|
713 | + $data['altitude'] = $line[6]; // altitude |
|
714 | + $data['speed'] = $line[8]; // speed |
|
715 | + $data['heading'] = $line[7]; // heading |
|
716 | + $data['latitude'] = $line[4]; // lat |
|
717 | + $data['longitude'] = $line[5]; // long |
|
718 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
719 | + $data['squawk'] = $line[10]; // squawk |
|
720 | + $data['emergency'] = ''; // emergency |
|
721 | + $data['registration'] = $line[2]; |
|
722 | + $data['aircraft_icao'] = $line[0]; |
|
723 | + $deparr = explode('-',$line[1]); |
|
724 | + if (count($deparr) == 2) { |
|
725 | 725 | $data['departure_airport_icao'] = $deparr[0]; |
726 | 726 | $data['arrival_airport_icao'] = $deparr[1]; |
727 | - } |
|
728 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
729 | - $data['format_source'] = 'planeupdatefaa'; |
|
730 | - $data['id_source'] = $id_source; |
|
731 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
732 | - $SI->add($data); |
|
733 | - unset($data); |
|
727 | + } |
|
728 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
729 | + $data['format_source'] = 'planeupdatefaa'; |
|
730 | + $data['id_source'] = $id_source; |
|
731 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
732 | + $SI->add($data); |
|
733 | + unset($data); |
|
734 | + } |
|
734 | 735 | } |
735 | - } |
|
736 | - //$last_exec['planeupdatefaa'] = time(); |
|
737 | - $last_exec[$id]['last'] = time(); |
|
738 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
739 | - $buffer = $Common->getData($value['host']); |
|
740 | - $all_data = json_decode($buffer,true); |
|
741 | - if (isset($all_data['states'])) { |
|
736 | + //$last_exec['planeupdatefaa'] = time(); |
|
737 | + $last_exec[$id]['last'] = time(); |
|
738 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
739 | + $buffer = $Common->getData($value['host']); |
|
740 | + $all_data = json_decode($buffer,true); |
|
741 | + if (isset($all_data['states'])) { |
|
742 | 742 | $reset = 0; |
743 | 743 | foreach ($all_data['states'] as $key => $line) { |
744 | - $data = array(); |
|
745 | - $data['hex'] = $line[0]; // hex |
|
746 | - $data['ident'] = trim($line[1]); // ident |
|
747 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
748 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
749 | - $data['heading'] = round($line[10]); // heading |
|
750 | - $data['latitude'] = $line[5]; // lat |
|
751 | - $data['longitude'] = $line[6]; // long |
|
752 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
753 | - //$data['squawk'] = $line[10]; // squawk |
|
754 | - //$data['emergency'] = ''; // emergency |
|
755 | - //$data['registration'] = $line[2]; |
|
756 | - //$data['aircraft_icao'] = $line[0]; |
|
757 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
758 | - $data['format_source'] = 'opensky'; |
|
759 | - $data['id_source'] = $id_source; |
|
760 | - $SI->add($data); |
|
761 | - unset($data); |
|
744 | + $data = array(); |
|
745 | + $data['hex'] = $line[0]; // hex |
|
746 | + $data['ident'] = trim($line[1]); // ident |
|
747 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
748 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
749 | + $data['heading'] = round($line[10]); // heading |
|
750 | + $data['latitude'] = $line[5]; // lat |
|
751 | + $data['longitude'] = $line[6]; // long |
|
752 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
753 | + //$data['squawk'] = $line[10]; // squawk |
|
754 | + //$data['emergency'] = ''; // emergency |
|
755 | + //$data['registration'] = $line[2]; |
|
756 | + //$data['aircraft_icao'] = $line[0]; |
|
757 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
758 | + $data['format_source'] = 'opensky'; |
|
759 | + $data['id_source'] = $id_source; |
|
760 | + $SI->add($data); |
|
761 | + unset($data); |
|
762 | + } |
|
762 | 763 | } |
763 | - } |
|
764 | - //$last_exec['planeupdatefaa'] = time(); |
|
765 | - $last_exec[$id]['last'] = time(); |
|
766 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
767 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | - //$buffer = $Common->getData($hosts[$id]); |
|
769 | - $buffer = $Common->getData($value['host']); |
|
770 | - $all_data = json_decode($buffer,true); |
|
771 | - if (!empty($all_data)) $reset = 0; |
|
772 | - foreach ($all_data as $key => $line) { |
|
764 | + //$last_exec['planeupdatefaa'] = time(); |
|
765 | + $last_exec[$id]['last'] = time(); |
|
766 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
767 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | + //$buffer = $Common->getData($hosts[$id]); |
|
769 | + $buffer = $Common->getData($value['host']); |
|
770 | + $all_data = json_decode($buffer,true); |
|
771 | + if (!empty($all_data)) $reset = 0; |
|
772 | + foreach ($all_data as $key => $line) { |
|
773 | 773 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
774 | - $data = array(); |
|
775 | - $data['hex'] = $line[0]; |
|
776 | - $data['ident'] = $line[16]; //$line[13] |
|
777 | - $data['altitude'] = $line[4]; // altitude |
|
778 | - $data['speed'] = $line[5]; // speed |
|
779 | - $data['heading'] = $line[3]; // heading |
|
780 | - $data['latitude'] = $line[1]; // lat |
|
781 | - $data['longitude'] = $line[2]; // long |
|
782 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
783 | - $data['squawk'] = $line[6]; // squawk |
|
784 | - $data['aircraft_icao'] = $line[8]; |
|
785 | - $data['registration'] = $line[9]; |
|
786 | - $data['departure_airport_iata'] = $line[11]; |
|
787 | - $data['arrival_airport_iata'] = $line[12]; |
|
788 | - $data['emergency'] = ''; // emergency |
|
789 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
790 | - $data['format_source'] = 'fr24json'; |
|
791 | - $data['id_source'] = $id_source; |
|
792 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
793 | - $SI->add($data); |
|
794 | - unset($data); |
|
774 | + $data = array(); |
|
775 | + $data['hex'] = $line[0]; |
|
776 | + $data['ident'] = $line[16]; //$line[13] |
|
777 | + $data['altitude'] = $line[4]; // altitude |
|
778 | + $data['speed'] = $line[5]; // speed |
|
779 | + $data['heading'] = $line[3]; // heading |
|
780 | + $data['latitude'] = $line[1]; // lat |
|
781 | + $data['longitude'] = $line[2]; // long |
|
782 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
783 | + $data['squawk'] = $line[6]; // squawk |
|
784 | + $data['aircraft_icao'] = $line[8]; |
|
785 | + $data['registration'] = $line[9]; |
|
786 | + $data['departure_airport_iata'] = $line[11]; |
|
787 | + $data['arrival_airport_iata'] = $line[12]; |
|
788 | + $data['emergency'] = ''; // emergency |
|
789 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
790 | + $data['format_source'] = 'fr24json'; |
|
791 | + $data['id_source'] = $id_source; |
|
792 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
793 | + $SI->add($data); |
|
794 | + unset($data); |
|
795 | + } |
|
795 | 796 | } |
796 | - } |
|
797 | - //$last_exec['fr24json'] = time(); |
|
798 | - $last_exec[$id]['last'] = time(); |
|
799 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
800 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
801 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
802 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
803 | - //echo $buffer; |
|
804 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
805 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
806 | - $all_data = json_decode($buffer,true); |
|
807 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
797 | + //$last_exec['fr24json'] = time(); |
|
798 | + $last_exec[$id]['last'] = time(); |
|
799 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
800 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
801 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
802 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
803 | + //echo $buffer; |
|
804 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
805 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
806 | + $all_data = json_decode($buffer,true); |
|
807 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
808 | 808 | die(json_last_error_msg()); |
809 | - } |
|
810 | - if (isset($all_data['mrkrs'])) { |
|
809 | + } |
|
810 | + if (isset($all_data['mrkrs'])) { |
|
811 | 811 | $reset = 0; |
812 | 812 | foreach ($all_data['mrkrs'] as $key => $line) { |
813 | - if (isset($line['inf'])) { |
|
813 | + if (isset($line['inf'])) { |
|
814 | 814 | $data = array(); |
815 | 815 | $data['hex'] = $line['inf']['ia']; |
816 | 816 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
817 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
818 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
819 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
820 | - $data['latitude'] = $line['pt'][0]; // lat |
|
821 | - $data['longitude'] = $line['pt'][1]; // long |
|
822 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
823 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
824 | - //$data['aircraft_icao'] = $line[8]; |
|
825 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
817 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
818 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
819 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
820 | + $data['latitude'] = $line['pt'][0]; // lat |
|
821 | + $data['longitude'] = $line['pt'][1]; // long |
|
822 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
823 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
824 | + //$data['aircraft_icao'] = $line[8]; |
|
825 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
826 | 826 | //$data['departure_airport_iata'] = $line[11]; |
827 | 827 | //$data['arrival_airport_iata'] = $line[12]; |
828 | - //$data['emergency'] = ''; // emergency |
|
828 | + //$data['emergency'] = ''; // emergency |
|
829 | 829 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
830 | - $data['format_source'] = 'radarvirtueljson'; |
|
831 | - $data['id_source'] = $id_source; |
|
830 | + $data['format_source'] = 'radarvirtueljson'; |
|
831 | + $data['id_source'] = $id_source; |
|
832 | 832 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
833 | 833 | $SI->add($data); |
834 | 834 | unset($data); |
835 | - } |
|
835 | + } |
|
836 | 836 | } |
837 | - } |
|
838 | - //$last_exec['radarvirtueljson'] = time(); |
|
839 | - $last_exec[$id]['last'] = time(); |
|
840 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
841 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
842 | - //$buffer = $Common->getData($hosts[$id]); |
|
843 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
844 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
837 | + } |
|
838 | + //$last_exec['radarvirtueljson'] = time(); |
|
839 | + $last_exec[$id]['last'] = time(); |
|
840 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
841 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
842 | + //$buffer = $Common->getData($hosts[$id]); |
|
843 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
844 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
845 | 845 | |
846 | - if (isset($all_data['pireps'])) { |
|
846 | + if (isset($all_data['pireps'])) { |
|
847 | 847 | $reset = 0; |
848 | - foreach ($all_data['pireps'] as $line) { |
|
849 | - $data = array(); |
|
850 | - $data['id'] = $line['id']; |
|
851 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
852 | - $data['ident'] = $line['callsign']; // ident |
|
853 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
854 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
855 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
856 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
857 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
858 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
859 | - $data['latitude'] = $line['lat']; // lat |
|
860 | - $data['longitude'] = $line['lon']; // long |
|
861 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
862 | - //$data['squawk'] = $line['squawk']; // squawk |
|
863 | - //$data['emergency'] = ''; // emergency |
|
864 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
865 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
866 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
867 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
868 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
869 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
870 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
871 | - else $data['info'] = ''; |
|
872 | - $data['format_source'] = 'pireps'; |
|
873 | - $data['id_source'] = $id_source; |
|
874 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
875 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
876 | - if ($line['icon'] == 'plane') { |
|
848 | + foreach ($all_data['pireps'] as $line) { |
|
849 | + $data = array(); |
|
850 | + $data['id'] = $line['id']; |
|
851 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
852 | + $data['ident'] = $line['callsign']; // ident |
|
853 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
854 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
855 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
856 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
857 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
858 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
859 | + $data['latitude'] = $line['lat']; // lat |
|
860 | + $data['longitude'] = $line['lon']; // long |
|
861 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
862 | + //$data['squawk'] = $line['squawk']; // squawk |
|
863 | + //$data['emergency'] = ''; // emergency |
|
864 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
865 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
866 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
867 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
868 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
869 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
870 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
871 | + else $data['info'] = ''; |
|
872 | + $data['format_source'] = 'pireps'; |
|
873 | + $data['id_source'] = $id_source; |
|
874 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
875 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
876 | + if ($line['icon'] == 'plane') { |
|
877 | 877 | $SI->add($data); |
878 | - // print_r($data); |
|
879 | - } elseif ($line['icon'] == 'ct') { |
|
878 | + // print_r($data); |
|
879 | + } elseif ($line['icon'] == 'ct') { |
|
880 | 880 | $data['info'] = str_replace('^§','<br />',$data['info']); |
881 | 881 | $data['info'] = str_replace('&sect;','',$data['info']); |
882 | 882 | $typec = substr($data['ident'],-3); |
@@ -891,190 +891,190 @@ discard block |
||
891 | 891 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
892 | 892 | else $data['type'] = 'Observer'; |
893 | 893 | 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']); |
894 | - } |
|
895 | - unset($data); |
|
894 | + } |
|
895 | + unset($data); |
|
896 | 896 | } |
897 | - } |
|
898 | - //$last_exec['pirepsjson'] = time(); |
|
899 | - $last_exec[$id]['last'] = time(); |
|
900 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
901 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
902 | - //$buffer = $Common->getData($hosts[$id]); |
|
903 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
904 | - $buffer = $Common->getData($value['host']); |
|
905 | - $all_data = json_decode($buffer,true); |
|
906 | - if ($buffer != '' && is_array($all_data)) { |
|
897 | + } |
|
898 | + //$last_exec['pirepsjson'] = time(); |
|
899 | + $last_exec[$id]['last'] = time(); |
|
900 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
901 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
902 | + //$buffer = $Common->getData($hosts[$id]); |
|
903 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
904 | + $buffer = $Common->getData($value['host']); |
|
905 | + $all_data = json_decode($buffer,true); |
|
906 | + if ($buffer != '' && is_array($all_data)) { |
|
907 | 907 | $reset = 0; |
908 | 908 | foreach ($all_data as $line) { |
909 | - $data = array(); |
|
910 | - //$data['id'] = $line['id']; // id not usable |
|
911 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
912 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
913 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
914 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
915 | - $data['ident'] = $line['flightnum']; // ident |
|
916 | - $data['altitude'] = $line['alt']; // altitude |
|
917 | - $data['speed'] = $line['gs']; // speed |
|
918 | - $data['heading'] = $line['heading']; // heading |
|
919 | - $data['latitude'] = $line['lat']; // lat |
|
920 | - $data['longitude'] = $line['lng']; // long |
|
921 | - $data['verticalrate'] = ''; // verticale rate |
|
922 | - $data['squawk'] = ''; // squawk |
|
923 | - $data['emergency'] = ''; // emergency |
|
924 | - //$data['datetime'] = $line['lastupdate']; |
|
925 | - $data['last_update'] = $line['lastupdate']; |
|
926 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
927 | - $data['departure_airport_icao'] = $line['depicao']; |
|
928 | - $data['departure_airport_time'] = $line['deptime']; |
|
929 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
930 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
931 | - $data['registration'] = $line['aircraft']; |
|
932 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
933 | - if (isset($line['aircraftname'])) { |
|
909 | + $data = array(); |
|
910 | + //$data['id'] = $line['id']; // id not usable |
|
911 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
912 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
913 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
914 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
915 | + $data['ident'] = $line['flightnum']; // ident |
|
916 | + $data['altitude'] = $line['alt']; // altitude |
|
917 | + $data['speed'] = $line['gs']; // speed |
|
918 | + $data['heading'] = $line['heading']; // heading |
|
919 | + $data['latitude'] = $line['lat']; // lat |
|
920 | + $data['longitude'] = $line['lng']; // long |
|
921 | + $data['verticalrate'] = ''; // verticale rate |
|
922 | + $data['squawk'] = ''; // squawk |
|
923 | + $data['emergency'] = ''; // emergency |
|
924 | + //$data['datetime'] = $line['lastupdate']; |
|
925 | + $data['last_update'] = $line['lastupdate']; |
|
926 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
927 | + $data['departure_airport_icao'] = $line['depicao']; |
|
928 | + $data['departure_airport_time'] = $line['deptime']; |
|
929 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
930 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
931 | + $data['registration'] = $line['aircraft']; |
|
932 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
933 | + if (isset($line['aircraftname'])) { |
|
934 | 934 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
935 | 935 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
936 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
937 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
938 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
939 | - else { |
|
940 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
941 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
942 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
943 | - } |
|
944 | - } |
|
945 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
946 | - $data['id_source'] = $id_source; |
|
947 | - $data['format_source'] = 'phpvmacars'; |
|
948 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
949 | - $SI->add($data); |
|
950 | - unset($data); |
|
936 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
937 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
938 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
939 | + else { |
|
940 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
941 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
942 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
943 | + } |
|
944 | + } |
|
945 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
946 | + $data['id_source'] = $id_source; |
|
947 | + $data['format_source'] = 'phpvmacars'; |
|
948 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
949 | + $SI->add($data); |
|
950 | + unset($data); |
|
951 | 951 | } |
952 | 952 | if ($globalDebug) echo 'No more data...'."\n"; |
953 | 953 | unset($buffer); |
954 | 954 | unset($all_data); |
955 | - } |
|
956 | - //$last_exec['phpvmacars'] = time(); |
|
957 | - $last_exec[$id]['last'] = time(); |
|
958 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
959 | - //$buffer = $Common->getData($hosts[$id]); |
|
960 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
961 | - $buffer = $Common->getData($value['host']); |
|
962 | - $all_data = json_decode($buffer,true); |
|
963 | - if ($buffer != '' && is_array($all_data)) { |
|
955 | + } |
|
956 | + //$last_exec['phpvmacars'] = time(); |
|
957 | + $last_exec[$id]['last'] = time(); |
|
958 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
959 | + //$buffer = $Common->getData($hosts[$id]); |
|
960 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
961 | + $buffer = $Common->getData($value['host']); |
|
962 | + $all_data = json_decode($buffer,true); |
|
963 | + if ($buffer != '' && is_array($all_data)) { |
|
964 | 964 | $reset = 0; |
965 | 965 | foreach ($all_data as $line) { |
966 | - $data = array(); |
|
967 | - //$data['id'] = $line['id']; // id not usable |
|
968 | - $data['id'] = trim($line['flight_id']); |
|
969 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
970 | - $data['pilot_name'] = $line['pilot_name']; |
|
971 | - $data['pilot_id'] = $line['pilot_id']; |
|
972 | - $data['ident'] = trim($line['callsign']); // ident |
|
973 | - $data['altitude'] = $line['altitude']; // altitude |
|
974 | - $data['speed'] = $line['gs']; // speed |
|
975 | - $data['heading'] = $line['heading']; // heading |
|
976 | - $data['latitude'] = $line['latitude']; // lat |
|
977 | - $data['longitude'] = $line['longitude']; // long |
|
978 | - $data['verticalrate'] = ''; // verticale rate |
|
979 | - $data['squawk'] = ''; // squawk |
|
980 | - $data['emergency'] = ''; // emergency |
|
981 | - //$data['datetime'] = $line['lastupdate']; |
|
982 | - $data['last_update'] = $line['last_update']; |
|
983 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
984 | - $data['departure_airport_icao'] = $line['departure']; |
|
985 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
986 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
987 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
988 | - //$data['registration'] = $line['aircraft']; |
|
989 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
990 | - $data['aircraft_icao'] = $line['plane_type']; |
|
991 | - $data['id_source'] = $id_source; |
|
992 | - $data['format_source'] = 'vam'; |
|
993 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
994 | - $SI->add($data); |
|
995 | - unset($data); |
|
966 | + $data = array(); |
|
967 | + //$data['id'] = $line['id']; // id not usable |
|
968 | + $data['id'] = trim($line['flight_id']); |
|
969 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
970 | + $data['pilot_name'] = $line['pilot_name']; |
|
971 | + $data['pilot_id'] = $line['pilot_id']; |
|
972 | + $data['ident'] = trim($line['callsign']); // ident |
|
973 | + $data['altitude'] = $line['altitude']; // altitude |
|
974 | + $data['speed'] = $line['gs']; // speed |
|
975 | + $data['heading'] = $line['heading']; // heading |
|
976 | + $data['latitude'] = $line['latitude']; // lat |
|
977 | + $data['longitude'] = $line['longitude']; // long |
|
978 | + $data['verticalrate'] = ''; // verticale rate |
|
979 | + $data['squawk'] = ''; // squawk |
|
980 | + $data['emergency'] = ''; // emergency |
|
981 | + //$data['datetime'] = $line['lastupdate']; |
|
982 | + $data['last_update'] = $line['last_update']; |
|
983 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
984 | + $data['departure_airport_icao'] = $line['departure']; |
|
985 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
986 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
987 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
988 | + //$data['registration'] = $line['aircraft']; |
|
989 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
990 | + $data['aircraft_icao'] = $line['plane_type']; |
|
991 | + $data['id_source'] = $id_source; |
|
992 | + $data['format_source'] = 'vam'; |
|
993 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
994 | + $SI->add($data); |
|
995 | + unset($data); |
|
996 | 996 | } |
997 | 997 | if ($globalDebug) echo 'No more data...'."\n"; |
998 | 998 | unset($buffer); |
999 | 999 | unset($all_data); |
1000 | - } |
|
1001 | - //$last_exec['phpvmacars'] = time(); |
|
1002 | - $last_exec[$id]['last'] = time(); |
|
1000 | + } |
|
1001 | + //$last_exec['phpvmacars'] = time(); |
|
1002 | + $last_exec[$id]['last'] = time(); |
|
1003 | 1003 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1004 | 1004 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1005 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1006 | - //$last_exec[$id]['last'] = time(); |
|
1005 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1006 | + //$last_exec[$id]['last'] = time(); |
|
1007 | 1007 | |
1008 | - //$read = array( $sockets[$id] ); |
|
1009 | - $read = $sockets; |
|
1010 | - $write = NULL; |
|
1011 | - $e = NULL; |
|
1012 | - $n = socket_select($read, $write, $e, $timeout); |
|
1013 | - if ($e != NULL) var_dump($e); |
|
1014 | - if ($n > 0) { |
|
1008 | + //$read = array( $sockets[$id] ); |
|
1009 | + $read = $sockets; |
|
1010 | + $write = NULL; |
|
1011 | + $e = NULL; |
|
1012 | + $n = socket_select($read, $write, $e, $timeout); |
|
1013 | + if ($e != NULL) var_dump($e); |
|
1014 | + if ($n > 0) { |
|
1015 | 1015 | $reset = 0; |
1016 | 1016 | foreach ($read as $nb => $r) { |
1017 | - //$value = $formats[$nb]; |
|
1018 | - $format = $globalSources[$nb]['format']; |
|
1019 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
|
1020 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1021 | - } else { |
|
1022 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1023 | - } |
|
1024 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1025 | - //echo $buffer."\n"; |
|
1026 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1027 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1028 | - $error = false; |
|
1029 | - //$SI::del(); |
|
1030 | - if ($format == 'vrstcp') { |
|
1017 | + //$value = $formats[$nb]; |
|
1018 | + $format = $globalSources[$nb]['format']; |
|
1019 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
|
1020 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1021 | + } else { |
|
1022 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1023 | + } |
|
1024 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1025 | + //echo $buffer."\n"; |
|
1026 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1027 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1028 | + $error = false; |
|
1029 | + //$SI::del(); |
|
1030 | + if ($format == 'vrstcp') { |
|
1031 | 1031 | $buffer = explode('},{',$buffer); |
1032 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1033 | - // SBS format is CSV format |
|
1034 | - if ($buffer != '') { |
|
1032 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1033 | + // SBS format is CSV format |
|
1034 | + if ($buffer != '') { |
|
1035 | 1035 | $tt[$format] = 0; |
1036 | 1036 | if ($format == 'acarssbs3') { |
1037 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1038 | - $ACARS->add(trim($buffer)); |
|
1039 | - $ACARS->deleteLiveAcarsData(); |
|
1037 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1038 | + $ACARS->add(trim($buffer)); |
|
1039 | + $ACARS->deleteLiveAcarsData(); |
|
1040 | 1040 | } elseif ($format == 'raw') { |
1041 | - // AVR format |
|
1042 | - $data = $SBS->parse($buffer); |
|
1043 | - if (is_array($data)) { |
|
1041 | + // AVR format |
|
1042 | + $data = $SBS->parse($buffer); |
|
1043 | + if (is_array($data)) { |
|
1044 | 1044 | $data['datetime'] = date('Y-m-d H:i:s'); |
1045 | 1045 | $data['format_source'] = 'raw'; |
1046 | 1046 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1047 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1048 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1049 | - } |
|
1050 | - } elseif ($format == 'ais') { |
|
1051 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1052 | - $data = array(); |
|
1053 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1054 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1055 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1056 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1057 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1058 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1059 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1060 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1061 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1062 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1063 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1064 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1047 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1048 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1049 | + } |
|
1050 | + } elseif ($format == 'ais') { |
|
1051 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1052 | + $data = array(); |
|
1053 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1054 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1055 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1056 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1057 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1058 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1059 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1060 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1061 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1062 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1063 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1064 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1065 | 1065 | |
1066 | - if (isset($ais_data['timestamp'])) { |
|
1066 | + if (isset($ais_data['timestamp'])) { |
|
1067 | 1067 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1068 | - } else { |
|
1068 | + } else { |
|
1069 | 1069 | $data['datetime'] = date('Y-m-d H:i:s'); |
1070 | - } |
|
1071 | - $data['format_source'] = 'aisnmea'; |
|
1072 | - $data['id_source'] = $id_source; |
|
1073 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1074 | - unset($data); |
|
1075 | - } elseif ($format == 'flightgearsp') { |
|
1076 | - //echo $buffer."\n"; |
|
1077 | - if (strlen($buffer) > 5) { |
|
1070 | + } |
|
1071 | + $data['format_source'] = 'aisnmea'; |
|
1072 | + $data['id_source'] = $id_source; |
|
1073 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1074 | + unset($data); |
|
1075 | + } elseif ($format == 'flightgearsp') { |
|
1076 | + //echo $buffer."\n"; |
|
1077 | + if (strlen($buffer) > 5) { |
|
1078 | 1078 | $line = explode(',',$buffer); |
1079 | 1079 | $data = array(); |
1080 | 1080 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1090,37 +1090,37 @@ discard block |
||
1090 | 1090 | $data['format_source'] = 'flightgearsp'; |
1091 | 1091 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1092 | 1092 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1093 | - } |
|
1094 | - } elseif ($format == 'acars') { |
|
1095 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1096 | - $ACARS->add(trim($buffer)); |
|
1097 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1098 | - $ACARS->deleteLiveAcarsData(); |
|
1093 | + } |
|
1094 | + } elseif ($format == 'acars') { |
|
1095 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1096 | + $ACARS->add(trim($buffer)); |
|
1097 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1098 | + $ACARS->deleteLiveAcarsData(); |
|
1099 | 1099 | } elseif ($format == 'flightgearmp') { |
1100 | - if (substr($buffer,0,1) != '#') { |
|
1100 | + if (substr($buffer,0,1) != '#') { |
|
1101 | 1101 | $data = array(); |
1102 | 1102 | //echo $buffer."\n"; |
1103 | 1103 | $line = explode(' ',$buffer); |
1104 | 1104 | if (count($line) == 11) { |
1105 | - $userserver = explode('@',$line[0]); |
|
1106 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1107 | - $data['ident'] = $userserver[0]; |
|
1108 | - $data['registration'] = $userserver[0]; |
|
1109 | - $data['latitude'] = $line[4]; |
|
1110 | - $data['longitude'] = $line[5]; |
|
1111 | - $data['altitude'] = $line[6]; |
|
1112 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | - $aircraft_type = $line[10]; |
|
1114 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1115 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1116 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1105 | + $userserver = explode('@',$line[0]); |
|
1106 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1107 | + $data['ident'] = $userserver[0]; |
|
1108 | + $data['registration'] = $userserver[0]; |
|
1109 | + $data['latitude'] = $line[4]; |
|
1110 | + $data['longitude'] = $line[5]; |
|
1111 | + $data['altitude'] = $line[6]; |
|
1112 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | + $aircraft_type = $line[10]; |
|
1114 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1115 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1116 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1117 | + } |
|
1117 | 1118 | } |
1118 | - } |
|
1119 | 1119 | } elseif ($format == 'beast') { |
1120 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1121 | - die; |
|
1120 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1121 | + die; |
|
1122 | 1122 | } elseif ($format == 'vrstcp') { |
1123 | - foreach($buffer as $all_data) { |
|
1123 | + foreach($buffer as $all_data) { |
|
1124 | 1124 | $line = json_decode('{'.$all_data.'}',true); |
1125 | 1125 | $data = array(); |
1126 | 1126 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1140,100 +1140,100 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | $data['datetime'] = date('Y-m-d H:i:s'); |
1142 | 1142 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1143 | - $data['format_source'] = 'vrstcp'; |
|
1143 | + $data['format_source'] = 'vrstcp'; |
|
1144 | 1144 | $data['id_source'] = $id_source; |
1145 | 1145 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1146 | 1146 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1147 | 1147 | unset($data); |
1148 | - } |
|
1148 | + } |
|
1149 | 1149 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1150 | - $line = explode("\t", $buffer); |
|
1151 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1150 | + $line = explode("\t", $buffer); |
|
1151 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1152 | 1152 | $key = $line[$k]; |
1153 | - $lined[$key] = $line[$k+1]; |
|
1154 | - } |
|
1155 | - if (count($lined) > 3) { |
|
1156 | - $data['hex'] = $lined['hexid']; |
|
1157 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1158 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1159 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1160 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1161 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1162 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1163 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1164 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1165 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1166 | - $data['id_source'] = $id_source; |
|
1167 | - $data['format_source'] = 'tsv'; |
|
1168 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1169 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1170 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1171 | - unset($lined); |
|
1172 | - unset($data); |
|
1173 | - } else $error = true; |
|
1153 | + $lined[$key] = $line[$k+1]; |
|
1154 | + } |
|
1155 | + if (count($lined) > 3) { |
|
1156 | + $data['hex'] = $lined['hexid']; |
|
1157 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1158 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1159 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1160 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1161 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1162 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1163 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1164 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1165 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1166 | + $data['id_source'] = $id_source; |
|
1167 | + $data['format_source'] = 'tsv'; |
|
1168 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1169 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1170 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1171 | + unset($lined); |
|
1172 | + unset($data); |
|
1173 | + } else $error = true; |
|
1174 | 1174 | } elseif ($format == 'aprs' && $use_aprs) { |
1175 | - if ($aprs_connect == 0) { |
|
1175 | + if ($aprs_connect == 0) { |
|
1176 | 1176 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1177 | 1177 | $aprs_connect = 1; |
1178 | - } |
|
1178 | + } |
|
1179 | 1179 | |
1180 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1180 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1181 | 1181 | $aprs_last_tx = time(); |
1182 | 1182 | $data_aprs = "# Keep alive"; |
1183 | 1183 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1184 | - } |
|
1184 | + } |
|
1185 | 1185 | |
1186 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1187 | - //echo 'APRS data : '.$buffer."\n"; |
|
1188 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1189 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1190 | - //echo $buffer."\n"; |
|
1191 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1186 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1187 | + //echo 'APRS data : '.$buffer."\n"; |
|
1188 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1189 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1190 | + //echo $buffer."\n"; |
|
1191 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1192 | 1192 | $line = $APRS->parse($buffer); |
1193 | 1193 | //print_r($line); |
1194 | 1194 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1195 | 1195 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) { |
1196 | - $aprs_last_tx = time(); |
|
1197 | - $data = array(); |
|
1198 | - //print_r($line); |
|
1199 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1200 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1201 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1202 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1204 | - $data['latitude'] = $line['latitude']; |
|
1205 | - $data['longitude'] = $line['longitude']; |
|
1206 | - //$data['verticalrate'] = $line[16]; |
|
1207 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1208 | - else $data['speed'] = 0; |
|
1209 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1210 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1211 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1212 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1213 | - //else $data['heading'] = 0; |
|
1214 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1215 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1216 | - $data['id_source'] = $id_source; |
|
1217 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1218 | - else $data['format_source'] = 'aprs'; |
|
1219 | - $data['source_name'] = $line['source']; |
|
1220 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1221 | - else $data['source_type'] = 'flarm'; |
|
1222 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1223 | - $currentdate = date('Y-m-d H:i:s'); |
|
1224 | - $aprsdate = strtotime($data['datetime']); |
|
1225 | - // Accept data if time <= system time + 20s |
|
1226 | - 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'])))) { |
|
1196 | + $aprs_last_tx = time(); |
|
1197 | + $data = array(); |
|
1198 | + //print_r($line); |
|
1199 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1200 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1201 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1202 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1204 | + $data['latitude'] = $line['latitude']; |
|
1205 | + $data['longitude'] = $line['longitude']; |
|
1206 | + //$data['verticalrate'] = $line[16]; |
|
1207 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1208 | + else $data['speed'] = 0; |
|
1209 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1210 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1211 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1212 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1213 | + //else $data['heading'] = 0; |
|
1214 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1215 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1216 | + $data['id_source'] = $id_source; |
|
1217 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1218 | + else $data['format_source'] = 'aprs'; |
|
1219 | + $data['source_name'] = $line['source']; |
|
1220 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1221 | + else $data['source_type'] = 'flarm'; |
|
1222 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1223 | + $currentdate = date('Y-m-d H:i:s'); |
|
1224 | + $aprsdate = strtotime($data['datetime']); |
|
1225 | + // Accept data if time <= system time + 20s |
|
1226 | + 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'])))) { |
|
1227 | 1227 | $send = $SI->add($data); |
1228 | - } elseif (isset($line['stealth'])) { |
|
1228 | + } elseif (isset($line['stealth'])) { |
|
1229 | 1229 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1230 | 1230 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1231 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1232 | - } 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') { |
|
1231 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1232 | + } 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') { |
|
1233 | 1233 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1234 | 1234 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1235 | - } |
|
1236 | - unset($data); |
|
1235 | + } |
|
1236 | + unset($data); |
|
1237 | 1237 | } |
1238 | 1238 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1239 | 1239 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1243,12 +1243,12 @@ discard block |
||
1243 | 1243 | } |
1244 | 1244 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1245 | 1245 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1246 | - } |
|
1246 | + } |
|
1247 | 1247 | } else { |
1248 | - $line = explode(',', $buffer); |
|
1249 | - if (count($line) > 20) { |
|
1250 | - $data['hex'] = $line[4]; |
|
1251 | - /* |
|
1248 | + $line = explode(',', $buffer); |
|
1249 | + if (count($line) > 20) { |
|
1250 | + $data['hex'] = $line[4]; |
|
1251 | + /* |
|
1252 | 1252 | $data['datetime'] = $line[6].' '.$line[7]; |
1253 | 1253 | date_default_timezone_set($globalTimezone); |
1254 | 1254 | $datetime = new DateTime($data['datetime']); |
@@ -1256,29 +1256,29 @@ discard block |
||
1256 | 1256 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1257 | 1257 | date_default_timezone_set('UTC'); |
1258 | 1258 | */ |
1259 | - // Force datetime to current UTC datetime |
|
1260 | - date_default_timezone_set('UTC'); |
|
1261 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1262 | - $data['ident'] = trim($line[10]); |
|
1263 | - $data['latitude'] = $line[14]; |
|
1264 | - $data['longitude'] = $line[15]; |
|
1265 | - $data['verticalrate'] = $line[16]; |
|
1266 | - $data['emergency'] = $line[20]; |
|
1267 | - $data['speed'] = $line[12]; |
|
1268 | - $data['squawk'] = $line[17]; |
|
1269 | - $data['altitude'] = $line[11]; |
|
1270 | - $data['heading'] = $line[13]; |
|
1271 | - $data['ground'] = $line[21]; |
|
1272 | - $data['emergency'] = $line[19]; |
|
1273 | - $data['format_source'] = 'sbs'; |
|
1259 | + // Force datetime to current UTC datetime |
|
1260 | + date_default_timezone_set('UTC'); |
|
1261 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1262 | + $data['ident'] = trim($line[10]); |
|
1263 | + $data['latitude'] = $line[14]; |
|
1264 | + $data['longitude'] = $line[15]; |
|
1265 | + $data['verticalrate'] = $line[16]; |
|
1266 | + $data['emergency'] = $line[20]; |
|
1267 | + $data['speed'] = $line[12]; |
|
1268 | + $data['squawk'] = $line[17]; |
|
1269 | + $data['altitude'] = $line[11]; |
|
1270 | + $data['heading'] = $line[13]; |
|
1271 | + $data['ground'] = $line[21]; |
|
1272 | + $data['emergency'] = $line[19]; |
|
1273 | + $data['format_source'] = 'sbs'; |
|
1274 | 1274 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1275 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1276 | - $data['id_source'] = $id_source; |
|
1277 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1278 | - else $error = true; |
|
1279 | - unset($data); |
|
1280 | - } else $error = true; |
|
1281 | - if ($error) { |
|
1275 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1276 | + $data['id_source'] = $id_source; |
|
1277 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1278 | + else $error = true; |
|
1279 | + unset($data); |
|
1280 | + } else $error = true; |
|
1281 | + if ($error) { |
|
1282 | 1282 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1283 | 1283 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1284 | 1284 | } else { |
@@ -1294,13 +1294,13 @@ discard block |
||
1294 | 1294 | connect_all($sourceer); |
1295 | 1295 | $sourceer = array(); |
1296 | 1296 | } |
1297 | - } |
|
1297 | + } |
|
1298 | 1298 | } |
1299 | 1299 | // Sleep for xxx microseconds |
1300 | 1300 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1301 | - } else { |
|
1301 | + } else { |
|
1302 | 1302 | if ($format == 'flightgearmp') { |
1303 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1303 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1304 | 1304 | //@socket_close($r); |
1305 | 1305 | sleep($globalMinFetch); |
1306 | 1306 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1309,9 +1309,9 @@ discard block |
||
1309 | 1309 | break; |
1310 | 1310 | |
1311 | 1311 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1312 | - if (isset($tt[$format])) $tt[$format]++; |
|
1313 | - else $tt[$format] = 0; |
|
1314 | - if ($tt[$format] > 30) { |
|
1312 | + if (isset($tt[$format])) $tt[$format]++; |
|
1313 | + else $tt[$format] = 0; |
|
1314 | + if ($tt[$format] > 30) { |
|
1315 | 1315 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1316 | 1316 | //@socket_close($r); |
1317 | 1317 | sleep(2); |
@@ -1322,23 +1322,23 @@ discard block |
||
1322 | 1322 | //connect_all($globalSources); |
1323 | 1323 | $tt[$format]=0; |
1324 | 1324 | break; |
1325 | - } |
|
1325 | + } |
|
1326 | + } |
|
1326 | 1327 | } |
1327 | - } |
|
1328 | 1328 | } |
1329 | - } else { |
|
1329 | + } else { |
|
1330 | 1330 | $error = socket_strerror(socket_last_error()); |
1331 | 1331 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1332 | 1332 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1333 | 1333 | if (isset($globalDebug)) echo "Restarting...\n"; |
1334 | 1334 | // Restart the script if possible |
1335 | 1335 | if (is_array($sockets)) { |
1336 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1336 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1337 | 1337 | |
1338 | - foreach ($sockets as $sock) { |
|
1338 | + foreach ($sockets as $sock) { |
|
1339 | 1339 | @socket_shutdown($sock,2); |
1340 | 1340 | @socket_close($sock); |
1341 | - } |
|
1341 | + } |
|
1342 | 1342 | |
1343 | 1343 | } |
1344 | 1344 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1349,13 +1349,13 @@ discard block |
||
1349 | 1349 | if ($reset > 40) exit('Too many attempts...'); |
1350 | 1350 | connect_all($globalSources); |
1351 | 1351 | } |
1352 | - } |
|
1352 | + } |
|
1353 | 1353 | } |
1354 | 1354 | if ($globalDaemon === false) { |
1355 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1356 | - $SI->checkAll(); |
|
1355 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1356 | + $SI->checkAll(); |
|
1357 | + } |
|
1357 | 1358 | } |
1358 | - } |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | ?> |
@@ -13,13 +13,17 @@ discard block |
||
13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
16 | +if (isset($globalTracker) && $globalTracker) { |
|
17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | +} |
|
17 | 19 | if (isset($globalMarine) && $globalMarine) { |
18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
20 | 22 | } |
21 | 23 | |
22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
24 | +if (!isset($globalDebug)) { |
|
25 | + $globalDebug = FALSE; |
|
26 | +} |
|
23 | 27 | |
24 | 28 | // Check if schema is at latest version |
25 | 29 | $Connection = new Connection(); |
@@ -59,22 +63,39 @@ discard block |
||
59 | 63 | $globalSources = array(); |
60 | 64 | $globalSources[] = array('host' => $options['source']); |
61 | 65 | } |
62 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
63 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
64 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
65 | -if (isset($options['server'])) $globalServer = TRUE; |
|
66 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
67 | -else $id_source = 1; |
|
66 | +if (isset($options['aprsserverssid'])) { |
|
67 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
68 | +} |
|
69 | +if (isset($options['aprsserverpass'])) { |
|
70 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
71 | +} |
|
72 | +if (isset($options['nodaemon'])) { |
|
73 | + $globalDaemon = FALSE; |
|
74 | +} |
|
75 | +if (isset($options['server'])) { |
|
76 | + $globalServer = TRUE; |
|
77 | +} |
|
78 | +if (isset($options['idsource'])) { |
|
79 | + $id_source = $options['idsource']; |
|
80 | +} else { |
|
81 | + $id_source = 1; |
|
82 | +} |
|
68 | 83 | if (isset($globalServer) && $globalServer) { |
69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
84 | + if ($globalDebug) { |
|
85 | + echo "Using Server Mode\n"; |
|
86 | + } |
|
70 | 87 | $SI=new SpotterServer(); |
71 | 88 | /* |
72 | 89 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 90 | $SI = new adsb2aprs(); |
74 | 91 | $SI->connect(); |
75 | 92 | */ |
76 | -} else $SI=new SpotterImport($Connection->db); |
|
77 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
93 | +} else { |
|
94 | + $SI=new SpotterImport($Connection->db); |
|
95 | +} |
|
96 | +if (isset($globalTracker) && $globalTracker) { |
|
97 | + $TI = new TrackerImport($Connection->db); |
|
98 | +} |
|
78 | 99 | if (isset($globalMarine) && $globalMarine) { |
79 | 100 | $AIS = new AIS(); |
80 | 101 | $MI = new MarineImport($Connection->db); |
@@ -96,7 +117,9 @@ discard block |
||
96 | 117 | } |
97 | 118 | |
98 | 119 | // let's try and connect |
99 | -if ($globalDebug) echo "Connecting...\n"; |
|
120 | +if ($globalDebug) { |
|
121 | + echo "Connecting...\n"; |
|
122 | +} |
|
100 | 123 | $use_aprs = false; |
101 | 124 | $aprs_full = false; |
102 | 125 | $reset = 0; |
@@ -105,7 +128,9 @@ discard block |
||
105 | 128 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
106 | 129 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
107 | 130 | $reset++; |
108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo 'Connect to all...'."\n"; |
|
133 | + } |
|
109 | 134 | foreach ($hosts as $id => $value) { |
110 | 135 | $host = $value['host']; |
111 | 136 | $globalSources[$id]['last_exec'] = 0; |
@@ -115,27 +140,37 @@ discard block |
||
115 | 140 | //$formats[$id] = 'deltadbtxt'; |
116 | 141 | $globalSources[$id]['format'] = 'deltadbtxt'; |
117 | 142 | //$last_exec['deltadbtxt'] = 0; |
118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
145 | + } |
|
119 | 146 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
120 | 147 | //$formats[$id] = 'vatsimtxt'; |
121 | 148 | $globalSources[$id]['format'] = 'vatsimtxt'; |
122 | 149 | //$last_exec['vatsimtxt'] = 0; |
123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
152 | + } |
|
124 | 153 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
125 | 154 | //$formats[$id] = 'aircraftlistjson'; |
126 | 155 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
127 | 156 | //$last_exec['aircraftlistjson'] = 0; |
128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
157 | + if ($globalDebug) { |
|
158 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
159 | + } |
|
129 | 160 | } else if (preg_match('/opensky/i',$host)) { |
130 | 161 | //$formats[$id] = 'aircraftlistjson'; |
131 | 162 | $globalSources[$id]['format'] = 'opensky'; |
132 | 163 | //$last_exec['aircraftlistjson'] = 0; |
133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
164 | + if ($globalDebug) { |
|
165 | + echo "Connect to opensky source (".$host.")...\n"; |
|
166 | + } |
|
134 | 167 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
135 | 168 | //$formats[$id] = 'radarvirtueljson'; |
136 | 169 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
137 | 170 | //$last_exec['radarvirtueljson'] = 0; |
138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
171 | + if ($globalDebug) { |
|
172 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
173 | + } |
|
139 | 174 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
140 | 175 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
141 | 176 | exit(0); |
@@ -144,7 +179,9 @@ discard block |
||
144 | 179 | //$formats[$id] = 'planeupdatefaa'; |
145 | 180 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
146 | 181 | //$last_exec['planeupdatefaa'] = 0; |
147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
182 | + if ($globalDebug) { |
|
183 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
184 | + } |
|
148 | 185 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
149 | 186 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
150 | 187 | exit(0); |
@@ -153,26 +190,36 @@ discard block |
||
153 | 190 | //$formats[$id] = 'phpvmacars'; |
154 | 191 | $globalSources[$id]['format'] = 'phpvmacars'; |
155 | 192 | //$last_exec['phpvmacars'] = 0; |
156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
195 | + } |
|
157 | 196 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
158 | 197 | //$formats[$id] = 'phpvmacars'; |
159 | 198 | $globalSources[$id]['format'] = 'vam'; |
160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo "Connect to Vam source (".$host.")...\n"; |
|
201 | + } |
|
161 | 202 | } else if (preg_match('/whazzup/i',$host)) { |
162 | 203 | //$formats[$id] = 'whazzup'; |
163 | 204 | $globalSources[$id]['format'] = 'whazzup'; |
164 | 205 | //$last_exec['whazzup'] = 0; |
165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
206 | + if ($globalDebug) { |
|
207 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
208 | + } |
|
166 | 209 | } else if (preg_match('/recentpireps/i',$host)) { |
167 | 210 | //$formats[$id] = 'pirepsjson'; |
168 | 211 | $globalSources[$id]['format'] = 'pirepsjson'; |
169 | 212 | //$last_exec['pirepsjson'] = 0; |
170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
213 | + if ($globalDebug) { |
|
214 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
215 | + } |
|
171 | 216 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
172 | 217 | //$formats[$id] = 'fr24json'; |
173 | 218 | $globalSources[$id]['format'] = 'fr24json'; |
174 | 219 | //$last_exec['fr24json'] = 0; |
175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
222 | + } |
|
176 | 223 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
177 | 224 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
178 | 225 | exit(0); |
@@ -181,7 +228,9 @@ discard block |
||
181 | 228 | //$formats[$id] = 'fr24json'; |
182 | 229 | $globalSources[$id]['format'] = 'myshiptracking'; |
183 | 230 | //$last_exec['fr24json'] = 0; |
184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
231 | + if ($globalDebug) { |
|
232 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
233 | + } |
|
185 | 234 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
186 | 235 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
187 | 236 | exit(0); |
@@ -190,17 +239,24 @@ discard block |
||
190 | 239 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
191 | 240 | //$formats[$id] = 'tsv'; |
192 | 241 | $globalSources[$id]['format'] = 'tsv'; |
193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to tsv source (".$host.")...\n"; |
|
244 | + } |
|
194 | 245 | } |
195 | 246 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
196 | 247 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
197 | 248 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
198 | 249 | if ($idf !== false) { |
199 | 250 | $httpfeeds[$id] = $idf; |
200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
251 | + if ($globalDebug) { |
|
252 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
253 | + } |
|
254 | + } elseif ($globalDebug) { |
|
255 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
201 | 256 | } |
202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | + } elseif ($globalDebug) { |
|
258 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
259 | + } |
|
204 | 260 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
205 | 261 | $hostport = explode(':',$host); |
206 | 262 | if (isset($hostport[1])) { |
@@ -240,17 +296,25 @@ discard block |
||
240 | 296 | //$formats[$id] = 'beast'; |
241 | 297 | $globalSources[$id]['format'] = 'beast'; |
242 | 298 | //} else $formats[$id] = 'sbs'; |
243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
299 | + } else { |
|
300 | + $globalSources[$id]['format'] = 'sbs'; |
|
301 | + } |
|
244 | 302 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
245 | 303 | } |
246 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
304 | + if ($globalDebug) { |
|
305 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
306 | + } |
|
247 | 307 | } else { |
248 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
308 | + if ($globalDebug) { |
|
309 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
310 | + } |
|
249 | 311 | } |
250 | 312 | } |
251 | 313 | } |
252 | 314 | } |
253 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
315 | +if (!isset($globalMinFetch)) { |
|
316 | + $globalMinFetch = 15; |
|
317 | +} |
|
254 | 318 | |
255 | 319 | // Initialize all |
256 | 320 | $status = array(); |
@@ -259,13 +323,19 @@ discard block |
||
259 | 323 | $formats = array(); |
260 | 324 | $last_exec = array(); |
261 | 325 | $time = time(); |
262 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
263 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
264 | -else $timeout = 20; |
|
326 | +if (isset($globalSourcesTimeout)) { |
|
327 | + $timeout = $globalSourcesTimeOut; |
|
328 | +} else if (isset($globalSBS1TimeOut)) { |
|
329 | + $timeout = $globalSBS1TimeOut; |
|
330 | +} else { |
|
331 | + $timeout = 20; |
|
332 | +} |
|
265 | 333 | $errno = ''; |
266 | 334 | $errstr=''; |
267 | 335 | |
268 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
336 | +if (!isset($globalDaemon)) { |
|
337 | + $globalDaemon = TRUE; |
|
338 | +} |
|
269 | 339 | /* Initiate connections to all the hosts simultaneously */ |
270 | 340 | //connect_all($hosts); |
271 | 341 | //connect_all($globalSources); |
@@ -291,7 +361,9 @@ discard block |
||
291 | 361 | if (isset($source['format']) && $source['format'] == 'aprs') { |
292 | 362 | $aprs_connect = 0; |
293 | 363 | $use_aprs = true; |
294 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
364 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
365 | + $aprs_full = true; |
|
366 | + } |
|
295 | 367 | break; |
296 | 368 | } |
297 | 369 | } |
@@ -302,26 +374,49 @@ discard block |
||
302 | 374 | $aprs_connect = 0; |
303 | 375 | $aprs_keep = 120; |
304 | 376 | $aprs_last_tx = time(); |
305 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
307 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
309 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
311 | - if ($aprs_full) $aprs_filter = ''; |
|
312 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
313 | - else $aprs_pass = '-1'; |
|
377 | + if (isset($globalAPRSversion)) { |
|
378 | + $aprs_version = $globalAPRSversion; |
|
379 | + } else { |
|
380 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
381 | + } |
|
382 | + if (isset($globalAPRSssid)) { |
|
383 | + $aprs_ssid = $globalAPRSssid; |
|
384 | + } else { |
|
385 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
386 | + } |
|
387 | + if (isset($globalAPRSfilter)) { |
|
388 | + $aprs_filter = $globalAPRSfilter; |
|
389 | + } else { |
|
390 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
391 | + } |
|
392 | + if ($aprs_full) { |
|
393 | + $aprs_filter = ''; |
|
394 | + } |
|
395 | + if (isset($globalAPRSpass)) { |
|
396 | + $aprs_pass = $globalAPRSpass; |
|
397 | + } else { |
|
398 | + $aprs_pass = '-1'; |
|
399 | + } |
|
314 | 400 | |
315 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
316 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
401 | + if ($aprs_filter != '') { |
|
402 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
403 | + } else { |
|
404 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
405 | + } |
|
317 | 406 | echo $aprs_login."\n"; |
318 | 407 | } |
319 | 408 | |
320 | 409 | // connected - lets do some work |
321 | -if ($globalDebug) echo "Connected!\n"; |
|
410 | +if ($globalDebug) { |
|
411 | + echo "Connected!\n"; |
|
412 | +} |
|
322 | 413 | sleep(1); |
323 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
324 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
414 | +if ($globalDebug) { |
|
415 | + echo "SCAN MODE \n\n"; |
|
416 | +} |
|
417 | +if (!isset($globalCronEnd)) { |
|
418 | + $globalCronEnd = 60; |
|
419 | +} |
|
325 | 420 | $endtime = time()+$globalCronEnd; |
326 | 421 | $i = 1; |
327 | 422 | $tt = array(); |
@@ -335,10 +430,14 @@ discard block |
||
335 | 430 | |
336 | 431 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
337 | 432 | while ($i > 0) { |
338 | - if (!$globalDaemon) $i = $endtime-time(); |
|
433 | + if (!$globalDaemon) { |
|
434 | + $i = $endtime-time(); |
|
435 | + } |
|
339 | 436 | // Delete old ATC |
340 | 437 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
341 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
438 | + if ($globalDebug) { |
|
439 | + echo 'Delete old ATC...'."\n"; |
|
440 | + } |
|
342 | 441 | $ATC->deleteOldATC(); |
343 | 442 | } |
344 | 443 | |
@@ -346,10 +445,14 @@ discard block |
||
346 | 445 | if (count($last_exec) == count($globalSources)) { |
347 | 446 | $max = $globalMinFetch; |
348 | 447 | foreach ($last_exec as $last) { |
349 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
448 | + if ((time() - $last['last']) < $max) { |
|
449 | + $max = time() - $last['last']; |
|
450 | + } |
|
350 | 451 | } |
351 | 452 | if ($max != $globalMinFetch) { |
352 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
453 | + if ($globalDebug) { |
|
454 | + echo 'Sleeping...'."\n"; |
|
455 | + } |
|
353 | 456 | sleep($globalMinFetch-$max+2); |
354 | 457 | } |
355 | 458 | } |
@@ -358,11 +461,15 @@ discard block |
||
358 | 461 | //foreach ($formats as $id => $value) { |
359 | 462 | foreach ($globalSources as $id => $value) { |
360 | 463 | date_default_timezone_set('UTC'); |
361 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
464 | + if (!isset($last_exec[$id]['last'])) { |
|
465 | + $last_exec[$id]['last'] = 0; |
|
466 | + } |
|
362 | 467 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
363 | 468 | //$buffer = $Common->getData($hosts[$id]); |
364 | 469 | $buffer = $Common->getData($value['host']); |
365 | - if ($buffer != '') $reset = 0; |
|
470 | + if ($buffer != '') { |
|
471 | + $reset = 0; |
|
472 | + } |
|
366 | 473 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
367 | 474 | $buffer = explode('\n',$buffer); |
368 | 475 | foreach ($buffer as $line) { |
@@ -371,19 +478,38 @@ discard block |
||
371 | 478 | $data = array(); |
372 | 479 | $data['hex'] = $line[1]; // hex |
373 | 480 | $data['ident'] = $line[2]; // ident |
374 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
375 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
376 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
377 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
378 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
481 | + if (isset($line[3])) { |
|
482 | + $data['altitude'] = $line[3]; |
|
483 | + } |
|
484 | + // altitude |
|
485 | + if (isset($line[4])) { |
|
486 | + $data['speed'] = $line[4]; |
|
487 | + } |
|
488 | + // speed |
|
489 | + if (isset($line[5])) { |
|
490 | + $data['heading'] = $line[5]; |
|
491 | + } |
|
492 | + // heading |
|
493 | + if (isset($line[6])) { |
|
494 | + $data['latitude'] = $line[6]; |
|
495 | + } |
|
496 | + // lat |
|
497 | + if (isset($line[7])) { |
|
498 | + $data['longitude'] = $line[7]; |
|
499 | + } |
|
500 | + // long |
|
379 | 501 | $data['verticalrate'] = ''; // vertical rate |
380 | 502 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
381 | 503 | $data['emergency'] = ''; // emergency |
382 | 504 | $data['datetime'] = date('Y-m-d H:i:s'); |
383 | 505 | $data['format_source'] = 'deltadbtxt'; |
384 | 506 | $data['id_source'] = $id_source; |
385 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
386 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
507 | + if (isset($value['name']) && $value['name'] != '') { |
|
508 | + $data['source_name'] = $value['name']; |
|
509 | + } |
|
510 | + if (isset($value['sourcestats'])) { |
|
511 | + $data['sourcestats'] = $value['sourcestats']; |
|
512 | + } |
|
387 | 513 | $SI->add($data); |
388 | 514 | unset($data); |
389 | 515 | } |
@@ -393,7 +519,9 @@ discard block |
||
393 | 519 | date_default_timezone_set('CET'); |
394 | 520 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
395 | 521 | date_default_timezone_set('UTC'); |
396 | - if ($buffer != '') $reset = 0; |
|
522 | + if ($buffer != '') { |
|
523 | + $reset = 0; |
|
524 | + } |
|
397 | 525 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
398 | 526 | $buffer = explode('\n',$buffer); |
399 | 527 | foreach ($buffer as $line) { |
@@ -402,16 +530,36 @@ discard block |
||
402 | 530 | $add = false; |
403 | 531 | $ais_data = $AIS->parse_line(trim($line)); |
404 | 532 | $data = array(); |
405 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
406 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
407 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
408 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
409 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
410 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
411 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
412 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
413 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
414 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
533 | + if (isset($ais_data['ident'])) { |
|
534 | + $data['ident'] = $ais_data['ident']; |
|
535 | + } |
|
536 | + if (isset($ais_data['mmsi'])) { |
|
537 | + $data['mmsi'] = $ais_data['mmsi']; |
|
538 | + } |
|
539 | + if (isset($ais_data['speed'])) { |
|
540 | + $data['speed'] = $ais_data['speed']; |
|
541 | + } |
|
542 | + if (isset($ais_data['heading'])) { |
|
543 | + $data['heading'] = $ais_data['heading']; |
|
544 | + } |
|
545 | + if (isset($ais_data['latitude'])) { |
|
546 | + $data['latitude'] = $ais_data['latitude']; |
|
547 | + } |
|
548 | + if (isset($ais_data['longitude'])) { |
|
549 | + $data['longitude'] = $ais_data['longitude']; |
|
550 | + } |
|
551 | + if (isset($ais_data['status'])) { |
|
552 | + $data['status'] = $ais_data['status']; |
|
553 | + } |
|
554 | + if (isset($ais_data['type'])) { |
|
555 | + $data['type'] = $ais_data['type']; |
|
556 | + } |
|
557 | + if (isset($ais_data['imo'])) { |
|
558 | + $data['imo'] = $ais_data['imo']; |
|
559 | + } |
|
560 | + if (isset($ais_data['callsign'])) { |
|
561 | + $data['callsign'] = $ais_data['callsign']; |
|
562 | + } |
|
415 | 563 | if (isset($ais_data['timestamp'])) { |
416 | 564 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
417 | 565 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -426,7 +574,9 @@ discard block |
||
426 | 574 | $data['id_source'] = $id_source; |
427 | 575 | print_r($data); |
428 | 576 | echo 'Add...'."\n"; |
429 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
577 | + if ($add && $ais_data['mmsi_type'] == 'Ship') { |
|
578 | + $MI->add($data); |
|
579 | + } |
|
430 | 580 | unset($data); |
431 | 581 | } |
432 | 582 | } |
@@ -446,18 +596,42 @@ discard block |
||
446 | 596 | if ($line != '') { |
447 | 597 | $ais_data = $AIS->parse_line(trim($line)); |
448 | 598 | $data = array(); |
449 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
450 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
451 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
452 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
453 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
454 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
455 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
456 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
457 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
458 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
459 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
460 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
599 | + if (isset($ais_data['ident'])) { |
|
600 | + $data['ident'] = $ais_data['ident']; |
|
601 | + } |
|
602 | + if (isset($ais_data['mmsi'])) { |
|
603 | + $data['mmsi'] = $ais_data['mmsi']; |
|
604 | + } |
|
605 | + if (isset($ais_data['speed'])) { |
|
606 | + $data['speed'] = $ais_data['speed']; |
|
607 | + } |
|
608 | + if (isset($ais_data['heading'])) { |
|
609 | + $data['heading'] = $ais_data['heading']; |
|
610 | + } |
|
611 | + if (isset($ais_data['latitude'])) { |
|
612 | + $data['latitude'] = $ais_data['latitude']; |
|
613 | + } |
|
614 | + if (isset($ais_data['longitude'])) { |
|
615 | + $data['longitude'] = $ais_data['longitude']; |
|
616 | + } |
|
617 | + if (isset($ais_data['status'])) { |
|
618 | + $data['status'] = $ais_data['status']; |
|
619 | + } |
|
620 | + if (isset($ais_data['type'])) { |
|
621 | + $data['type'] = $ais_data['type']; |
|
622 | + } |
|
623 | + if (isset($ais_data['imo'])) { |
|
624 | + $data['imo'] = $ais_data['imo']; |
|
625 | + } |
|
626 | + if (isset($ais_data['callsign'])) { |
|
627 | + $data['callsign'] = $ais_data['callsign']; |
|
628 | + } |
|
629 | + if (isset($ais_data['destination'])) { |
|
630 | + $data['arrival_code'] = $ais_data['destination']; |
|
631 | + } |
|
632 | + if (isset($ais_data['eta_ts'])) { |
|
633 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
634 | + } |
|
461 | 635 | if (isset($ais_data['timestamp'])) { |
462 | 636 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
463 | 637 | } else { |
@@ -465,7 +639,9 @@ discard block |
||
465 | 639 | } |
466 | 640 | $data['format_source'] = 'aisnmeahttp'; |
467 | 641 | $data['id_source'] = $id_source; |
468 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
642 | + if ($ais_data['mmsi_type'] == 'Ship') { |
|
643 | + $MI->add($data); |
|
644 | + } |
|
469 | 645 | unset($data); |
470 | 646 | } |
471 | 647 | } |
@@ -514,7 +690,9 @@ discard block |
||
514 | 690 | $data['callsign'] = $line['callsign']; |
515 | 691 | $data['mmsi'] = $line['mmsi']; |
516 | 692 | $data['speed'] = $line['sog']; |
517 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
693 | + if ($line['heading'] != '511') { |
|
694 | + $data['heading'] = $line['heading']; |
|
695 | + } |
|
518 | 696 | $data['latitude'] = $line['latitude']; |
519 | 697 | $data['longitude'] = $line['longitude']; |
520 | 698 | $data['type_id'] = $line['shiptype']; |
@@ -534,7 +712,9 @@ discard block |
||
534 | 712 | echo 'download...'; |
535 | 713 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
536 | 714 | echo 'done !'."\n"; |
537 | - if ($buffer != '') $reset = 0; |
|
715 | + if ($buffer != '') { |
|
716 | + $reset = 0; |
|
717 | + } |
|
538 | 718 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
539 | 719 | $buffer = explode('\n',$buffer); |
540 | 720 | foreach ($buffer as $line) { |
@@ -578,16 +758,28 @@ discard block |
||
578 | 758 | $line = explode(':', $line); |
579 | 759 | if (count($line) > 30 && $line[0] != 'callsign') { |
580 | 760 | $data = array(); |
581 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
582 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
761 | + if (isset($line[37]) && $line[37] != '') { |
|
762 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
763 | + } else { |
|
764 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
765 | + } |
|
583 | 766 | $data['pilot_id'] = $line[1]; |
584 | 767 | $data['pilot_name'] = $line[2]; |
585 | 768 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
586 | 769 | $data['ident'] = $line[0]; // ident |
587 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
770 | + if ($line[7] != '' && $line[7] != 0) { |
|
771 | + $data['altitude'] = $line[7]; |
|
772 | + } |
|
773 | + // altitude |
|
588 | 774 | $data['speed'] = $line[8]; // speed |
589 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
590 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
775 | + if (isset($line[45])) { |
|
776 | + $data['heading'] = $line[45]; |
|
777 | + } |
|
778 | + // heading |
|
779 | + elseif (isset($line[38])) { |
|
780 | + $data['heading'] = $line[38]; |
|
781 | + } |
|
782 | + // heading |
|
591 | 783 | $data['latitude'] = $line[5]; // lat |
592 | 784 | $data['longitude'] = $line[6]; // long |
593 | 785 | $data['verticalrate'] = ''; // vertical rate |
@@ -603,7 +795,9 @@ discard block |
||
603 | 795 | $data['frequency'] = $line[4]; |
604 | 796 | $data['type'] = $line[18]; |
605 | 797 | $data['range'] = $line[19]; |
606 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
798 | + if (isset($line[35])) { |
|
799 | + $data['info'] = $line[35]; |
|
800 | + } |
|
607 | 801 | $data['id_source'] = $id_source; |
608 | 802 | //$data['arrival_airport_time'] = ; |
609 | 803 | if ($line[9] != '') { |
@@ -617,24 +811,41 @@ discard block |
||
617 | 811 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
618 | 812 | */ |
619 | 813 | $data['format_source'] = $value['format']; |
620 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
621 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
622 | - elseif ($line[3] == 'ATC') { |
|
814 | + if (isset($value['name']) && $value['name'] != '') { |
|
815 | + $data['source_name'] = $value['name']; |
|
816 | + } |
|
817 | + if ($line[3] == 'PILOT') { |
|
818 | + $SI->add($data); |
|
819 | + } elseif ($line[3] == 'ATC') { |
|
623 | 820 | //print_r($data); |
624 | 821 | $data['info'] = str_replace('^§','<br />',$data['info']); |
625 | 822 | $data['info'] = str_replace('&sect;','',$data['info']); |
626 | 823 | $typec = substr($data['ident'],-3); |
627 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
628 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
629 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
630 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
631 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
632 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
633 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
634 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
635 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
636 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
637 | - if (isset($ATC)) 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']); |
|
824 | + if ($typec == 'APP') { |
|
825 | + $data['type'] = 'Approach'; |
|
826 | + } elseif ($typec == 'TWR') { |
|
827 | + $data['type'] = 'Tower'; |
|
828 | + } elseif ($typec == 'OBS') { |
|
829 | + $data['type'] = 'Observer'; |
|
830 | + } elseif ($typec == 'GND') { |
|
831 | + $data['type'] = 'Ground'; |
|
832 | + } elseif ($typec == 'DEL') { |
|
833 | + $data['type'] = 'Delivery'; |
|
834 | + } elseif ($typec == 'DEP') { |
|
835 | + $data['type'] = 'Departure'; |
|
836 | + } elseif ($typec == 'FSS') { |
|
837 | + $data['type'] = 'Flight Service Station'; |
|
838 | + } elseif ($typec == 'CTR') { |
|
839 | + $data['type'] = 'Control Radar or Centre'; |
|
840 | + } elseif ($data['type'] == '') { |
|
841 | + $data['type'] = 'Observer'; |
|
842 | + } |
|
843 | + if (!isset($data['source_name'])) { |
|
844 | + $data['source_name'] = ''; |
|
845 | + } |
|
846 | + if (isset($ATC)) { |
|
847 | + 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']); |
|
848 | + } |
|
638 | 849 | } |
639 | 850 | unset($data); |
640 | 851 | } |
@@ -653,26 +864,55 @@ discard block |
||
653 | 864 | foreach ($all_data['acList'] as $line) { |
654 | 865 | $data = array(); |
655 | 866 | $data['hex'] = $line['Icao']; // hex |
656 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
657 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
658 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
659 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
660 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
661 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
867 | + if (isset($line['Call'])) { |
|
868 | + $data['ident'] = $line['Call']; |
|
869 | + } |
|
870 | + // ident |
|
871 | + if (isset($line['Alt'])) { |
|
872 | + $data['altitude'] = $line['Alt']; |
|
873 | + } |
|
874 | + // altitude |
|
875 | + if (isset($line['Spd'])) { |
|
876 | + $data['speed'] = $line['Spd']; |
|
877 | + } |
|
878 | + // speed |
|
879 | + if (isset($line['Trak'])) { |
|
880 | + $data['heading'] = $line['Trak']; |
|
881 | + } |
|
882 | + // heading |
|
883 | + if (isset($line['Lat'])) { |
|
884 | + $data['latitude'] = $line['Lat']; |
|
885 | + } |
|
886 | + // lat |
|
887 | + if (isset($line['Long'])) { |
|
888 | + $data['longitude'] = $line['Long']; |
|
889 | + } |
|
890 | + // long |
|
662 | 891 | //$data['verticalrate'] = $line['']; // verticale rate |
663 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
892 | + if (isset($line['Sqk'])) { |
|
893 | + $data['squawk'] = $line['Sqk']; |
|
894 | + } |
|
895 | + // squawk |
|
664 | 896 | $data['emergency'] = ''; // emergency |
665 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
897 | + if (isset($line['Reg'])) { |
|
898 | + $data['registration'] = $line['Reg']; |
|
899 | + } |
|
666 | 900 | /* |
667 | 901 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
668 | 902 | else $data['datetime'] = date('Y-m-d H:i:s'); |
669 | 903 | */ |
670 | 904 | $data['datetime'] = date('Y-m-d H:i:s'); |
671 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
905 | + if (isset($line['Type'])) { |
|
906 | + $data['aircraft_icao'] = $line['Type']; |
|
907 | + } |
|
672 | 908 | $data['format_source'] = 'aircraftlistjson'; |
673 | 909 | $data['id_source'] = $id_source; |
674 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
675 | - if (isset($data['latitude'])) $SI->add($data); |
|
910 | + if (isset($value['name']) && $value['name'] != '') { |
|
911 | + $data['source_name'] = $value['name']; |
|
912 | + } |
|
913 | + if (isset($data['latitude'])) { |
|
914 | + $SI->add($data); |
|
915 | + } |
|
676 | 916 | unset($data); |
677 | 917 | } |
678 | 918 | } elseif (is_array($all_data)) { |
@@ -692,7 +932,9 @@ discard block |
||
692 | 932 | $data['datetime'] = date('Y-m-d H:i:s'); |
693 | 933 | $data['format_source'] = 'aircraftlistjson'; |
694 | 934 | $data['id_source'] = $id_source; |
695 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
935 | + if (isset($value['name']) && $value['name'] != '') { |
|
936 | + $data['source_name'] = $value['name']; |
|
937 | + } |
|
696 | 938 | $SI->add($data); |
697 | 939 | unset($data); |
698 | 940 | } |
@@ -728,7 +970,9 @@ discard block |
||
728 | 970 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
729 | 971 | $data['format_source'] = 'planeupdatefaa'; |
730 | 972 | $data['id_source'] = $id_source; |
731 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
973 | + if (isset($value['name']) && $value['name'] != '') { |
|
974 | + $data['source_name'] = $value['name']; |
|
975 | + } |
|
732 | 976 | $SI->add($data); |
733 | 977 | unset($data); |
734 | 978 | } |
@@ -768,7 +1012,9 @@ discard block |
||
768 | 1012 | //$buffer = $Common->getData($hosts[$id]); |
769 | 1013 | $buffer = $Common->getData($value['host']); |
770 | 1014 | $all_data = json_decode($buffer,true); |
771 | - if (!empty($all_data)) $reset = 0; |
|
1015 | + if (!empty($all_data)) { |
|
1016 | + $reset = 0; |
|
1017 | + } |
|
772 | 1018 | foreach ($all_data as $key => $line) { |
773 | 1019 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
774 | 1020 | $data = array(); |
@@ -789,7 +1035,9 @@ discard block |
||
789 | 1035 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
790 | 1036 | $data['format_source'] = 'fr24json'; |
791 | 1037 | $data['id_source'] = $id_source; |
792 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1038 | + if (isset($value['name']) && $value['name'] != '') { |
|
1039 | + $data['source_name'] = $value['name']; |
|
1040 | + } |
|
793 | 1041 | $SI->add($data); |
794 | 1042 | unset($data); |
795 | 1043 | } |
@@ -813,23 +1061,39 @@ discard block |
||
813 | 1061 | if (isset($line['inf'])) { |
814 | 1062 | $data = array(); |
815 | 1063 | $data['hex'] = $line['inf']['ia']; |
816 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1064 | + if (isset($line['inf']['cs'])) { |
|
1065 | + $data['ident'] = $line['inf']['cs']; |
|
1066 | + } |
|
1067 | + //$line[13] |
|
817 | 1068 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
818 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
819 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1069 | + if (isset($line['inf']['gs'])) { |
|
1070 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1071 | + } |
|
1072 | + // speed |
|
1073 | + if (isset($line['inf']['tr'])) { |
|
1074 | + $data['heading'] = $line['inf']['tr']; |
|
1075 | + } |
|
1076 | + // heading |
|
820 | 1077 | $data['latitude'] = $line['pt'][0]; // lat |
821 | 1078 | $data['longitude'] = $line['pt'][1]; // long |
822 | 1079 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
823 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1080 | + if (isset($line['inf']['sq'])) { |
|
1081 | + $data['squawk'] = $line['inf']['sq']; |
|
1082 | + } |
|
1083 | + // squawk |
|
824 | 1084 | //$data['aircraft_icao'] = $line[8]; |
825 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1085 | + if (isset($line['inf']['rc'])) { |
|
1086 | + $data['registration'] = $line['inf']['rc']; |
|
1087 | + } |
|
826 | 1088 | //$data['departure_airport_iata'] = $line[11]; |
827 | 1089 | //$data['arrival_airport_iata'] = $line[12]; |
828 | 1090 | //$data['emergency'] = ''; // emergency |
829 | 1091 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
830 | 1092 | $data['format_source'] = 'radarvirtueljson'; |
831 | 1093 | $data['id_source'] = $id_source; |
832 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1094 | + if (isset($value['name']) && $value['name'] != '') { |
|
1095 | + $data['source_name'] = $value['name']; |
|
1096 | + } |
|
833 | 1097 | $SI->add($data); |
834 | 1098 | unset($data); |
835 | 1099 | } |
@@ -850,29 +1114,62 @@ discard block |
||
850 | 1114 | $data['id'] = $line['id']; |
851 | 1115 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
852 | 1116 | $data['ident'] = $line['callsign']; // ident |
853 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
854 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
855 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
856 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
857 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
858 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1117 | + if (isset($line['pilotid'])) { |
|
1118 | + $data['pilot_id'] = $line['pilotid']; |
|
1119 | + } |
|
1120 | + // pilot id |
|
1121 | + if (isset($line['name'])) { |
|
1122 | + $data['pilot_name'] = $line['name']; |
|
1123 | + } |
|
1124 | + // pilot name |
|
1125 | + if (isset($line['alt'])) { |
|
1126 | + $data['altitude'] = $line['alt']; |
|
1127 | + } |
|
1128 | + // altitude |
|
1129 | + if (isset($line['gs'])) { |
|
1130 | + $data['speed'] = $line['gs']; |
|
1131 | + } |
|
1132 | + // speed |
|
1133 | + if (isset($line['heading'])) { |
|
1134 | + $data['heading'] = $line['heading']; |
|
1135 | + } |
|
1136 | + // heading |
|
1137 | + if (isset($line['route'])) { |
|
1138 | + $data['waypoints'] = $line['route']; |
|
1139 | + } |
|
1140 | + // route |
|
859 | 1141 | $data['latitude'] = $line['lat']; // lat |
860 | 1142 | $data['longitude'] = $line['lon']; // long |
861 | 1143 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
862 | 1144 | //$data['squawk'] = $line['squawk']; // squawk |
863 | 1145 | //$data['emergency'] = ''; // emergency |
864 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
865 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
866 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1146 | + if (isset($line['depicao'])) { |
|
1147 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1148 | + } |
|
1149 | + if (isset($line['deptime'])) { |
|
1150 | + $data['departure_airport_time'] = $line['deptime']; |
|
1151 | + } |
|
1152 | + if (isset($line['arricao'])) { |
|
1153 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1154 | + } |
|
867 | 1155 | //$data['arrival_airport_time'] = $line['arrtime']; |
868 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
869 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
870 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
871 | - else $data['info'] = ''; |
|
1156 | + if (isset($line['aircraft'])) { |
|
1157 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1158 | + } |
|
1159 | + if (isset($line['transponder'])) { |
|
1160 | + $data['squawk'] = $line['transponder']; |
|
1161 | + } |
|
1162 | + if (isset($line['atis'])) { |
|
1163 | + $data['info'] = $line['atis']; |
|
1164 | + } else { |
|
1165 | + $data['info'] = ''; |
|
1166 | + } |
|
872 | 1167 | $data['format_source'] = 'pireps'; |
873 | 1168 | $data['id_source'] = $id_source; |
874 | 1169 | $data['datetime'] = date('Y-m-d H:i:s'); |
875 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1170 | + if (isset($value['name']) && $value['name'] != '') { |
|
1171 | + $data['source_name'] = $value['name']; |
|
1172 | + } |
|
876 | 1173 | if ($line['icon'] == 'plane') { |
877 | 1174 | $SI->add($data); |
878 | 1175 | // print_r($data); |
@@ -881,16 +1178,28 @@ discard block |
||
881 | 1178 | $data['info'] = str_replace('&sect;','',$data['info']); |
882 | 1179 | $typec = substr($data['ident'],-3); |
883 | 1180 | $data['type'] = ''; |
884 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
885 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
886 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
887 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
888 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
889 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
890 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
891 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
892 | - else $data['type'] = 'Observer'; |
|
893 | - 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']); |
|
1181 | + if ($typec == 'APP') { |
|
1182 | + $data['type'] = 'Approach'; |
|
1183 | + } elseif ($typec == 'TWR') { |
|
1184 | + $data['type'] = 'Tower'; |
|
1185 | + } elseif ($typec == 'OBS') { |
|
1186 | + $data['type'] = 'Observer'; |
|
1187 | + } elseif ($typec == 'GND') { |
|
1188 | + $data['type'] = 'Ground'; |
|
1189 | + } elseif ($typec == 'DEL') { |
|
1190 | + $data['type'] = 'Delivery'; |
|
1191 | + } elseif ($typec == 'DEP') { |
|
1192 | + $data['type'] = 'Departure'; |
|
1193 | + } elseif ($typec == 'FSS') { |
|
1194 | + $data['type'] = 'Flight Service Station'; |
|
1195 | + } elseif ($typec == 'CTR') { |
|
1196 | + $data['type'] = 'Control Radar or Centre'; |
|
1197 | + } else { |
|
1198 | + $data['type'] = 'Observer'; |
|
1199 | + } |
|
1200 | + if (isset($ATC)) { |
|
1201 | + 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']); |
|
1202 | + } |
|
894 | 1203 | } |
895 | 1204 | unset($data); |
896 | 1205 | } |
@@ -900,7 +1209,9 @@ discard block |
||
900 | 1209 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
901 | 1210 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
902 | 1211 | //$buffer = $Common->getData($hosts[$id]); |
903 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1212 | + if ($globalDebug) { |
|
1213 | + echo 'Get Data...'."\n"; |
|
1214 | + } |
|
904 | 1215 | $buffer = $Common->getData($value['host']); |
905 | 1216 | $all_data = json_decode($buffer,true); |
906 | 1217 | if ($buffer != '' && is_array($all_data)) { |
@@ -908,10 +1219,16 @@ discard block |
||
908 | 1219 | foreach ($all_data as $line) { |
909 | 1220 | $data = array(); |
910 | 1221 | //$data['id'] = $line['id']; // id not usable |
911 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1222 | + if (isset($line['pilotid'])) { |
|
1223 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1224 | + } |
|
912 | 1225 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
913 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
914 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1226 | + if (isset($line['pilotname'])) { |
|
1227 | + $data['pilot_name'] = $line['pilotname']; |
|
1228 | + } |
|
1229 | + if (isset($line['pilotid'])) { |
|
1230 | + $data['pilot_id'] = $line['pilotid']; |
|
1231 | + } |
|
915 | 1232 | $data['ident'] = $line['flightnum']; // ident |
916 | 1233 | $data['altitude'] = $line['alt']; // altitude |
917 | 1234 | $data['speed'] = $line['gs']; // speed |
@@ -929,27 +1246,41 @@ discard block |
||
929 | 1246 | $data['arrival_airport_icao'] = $line['arricao']; |
930 | 1247 | $data['arrival_airport_time'] = $line['arrtime']; |
931 | 1248 | $data['registration'] = $line['aircraft']; |
932 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1249 | + if (isset($line['route'])) { |
|
1250 | + $data['waypoints'] = $line['route']; |
|
1251 | + } |
|
1252 | + // route |
|
933 | 1253 | if (isset($line['aircraftname'])) { |
934 | 1254 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
935 | 1255 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
936 | 1256 | $aircraft_data = explode('-',$line['aircraftname']); |
937 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
938 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
939 | - else { |
|
1257 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
1258 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1259 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
1260 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1261 | + } else { |
|
940 | 1262 | $aircraft_data = explode(' ',$line['aircraftname']); |
941 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
942 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
1263 | + if (isset($aircraft_data[1])) { |
|
1264 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1265 | + } else { |
|
1266 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
1267 | + } |
|
943 | 1268 | } |
944 | 1269 | } |
945 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1270 | + if (isset($line['route'])) { |
|
1271 | + $data['waypoints'] = $line['route']; |
|
1272 | + } |
|
946 | 1273 | $data['id_source'] = $id_source; |
947 | 1274 | $data['format_source'] = 'phpvmacars'; |
948 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1275 | + if (isset($value['name']) && $value['name'] != '') { |
|
1276 | + $data['source_name'] = $value['name']; |
|
1277 | + } |
|
949 | 1278 | $SI->add($data); |
950 | 1279 | unset($data); |
951 | 1280 | } |
952 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1281 | + if ($globalDebug) { |
|
1282 | + echo 'No more data...'."\n"; |
|
1283 | + } |
|
953 | 1284 | unset($buffer); |
954 | 1285 | unset($all_data); |
955 | 1286 | } |
@@ -957,7 +1288,9 @@ discard block |
||
957 | 1288 | $last_exec[$id]['last'] = time(); |
958 | 1289 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
959 | 1290 | //$buffer = $Common->getData($hosts[$id]); |
960 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1291 | + if ($globalDebug) { |
|
1292 | + echo 'Get Data...'."\n"; |
|
1293 | + } |
|
961 | 1294 | $buffer = $Common->getData($value['host']); |
962 | 1295 | $all_data = json_decode($buffer,true); |
963 | 1296 | if ($buffer != '' && is_array($all_data)) { |
@@ -986,15 +1319,22 @@ discard block |
||
986 | 1319 | $data['arrival_airport_icao'] = $line['arrival']; |
987 | 1320 | //$data['arrival_airport_time'] = $line['arrival_time']; |
988 | 1321 | //$data['registration'] = $line['aircraft']; |
989 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1322 | + if (isset($line['route'])) { |
|
1323 | + $data['waypoints'] = $line['route']; |
|
1324 | + } |
|
1325 | + // route |
|
990 | 1326 | $data['aircraft_icao'] = $line['plane_type']; |
991 | 1327 | $data['id_source'] = $id_source; |
992 | 1328 | $data['format_source'] = 'vam'; |
993 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1329 | + if (isset($value['name']) && $value['name'] != '') { |
|
1330 | + $data['source_name'] = $value['name']; |
|
1331 | + } |
|
994 | 1332 | $SI->add($data); |
995 | 1333 | unset($data); |
996 | 1334 | } |
997 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1335 | + if ($globalDebug) { |
|
1336 | + echo 'No more data...'."\n"; |
|
1337 | + } |
|
998 | 1338 | unset($buffer); |
999 | 1339 | unset($all_data); |
1000 | 1340 | } |
@@ -1002,7 +1342,9 @@ discard block |
||
1002 | 1342 | $last_exec[$id]['last'] = time(); |
1003 | 1343 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1004 | 1344 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1005 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1345 | + if (function_exists('pcntl_fork')) { |
|
1346 | + pcntl_signal_dispatch(); |
|
1347 | + } |
|
1006 | 1348 | //$last_exec[$id]['last'] = time(); |
1007 | 1349 | |
1008 | 1350 | //$read = array( $sockets[$id] ); |
@@ -1010,7 +1352,9 @@ discard block |
||
1010 | 1352 | $write = NULL; |
1011 | 1353 | $e = NULL; |
1012 | 1354 | $n = socket_select($read, $write, $e, $timeout); |
1013 | - if ($e != NULL) var_dump($e); |
|
1355 | + if ($e != NULL) { |
|
1356 | + var_dump($e); |
|
1357 | + } |
|
1014 | 1358 | if ($n > 0) { |
1015 | 1359 | $reset = 0; |
1016 | 1360 | foreach ($read as $nb => $r) { |
@@ -1029,12 +1373,16 @@ discard block |
||
1029 | 1373 | //$SI::del(); |
1030 | 1374 | if ($format == 'vrstcp') { |
1031 | 1375 | $buffer = explode('},{',$buffer); |
1032 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1376 | + } else { |
|
1377 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1378 | + } |
|
1033 | 1379 | // SBS format is CSV format |
1034 | 1380 | if ($buffer != '') { |
1035 | 1381 | $tt[$format] = 0; |
1036 | 1382 | if ($format == 'acarssbs3') { |
1037 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1383 | + if ($globalDebug) { |
|
1384 | + echo 'ACARS : '.$buffer."\n"; |
|
1385 | + } |
|
1038 | 1386 | $ACARS->add(trim($buffer)); |
1039 | 1387 | $ACARS->deleteLiveAcarsData(); |
1040 | 1388 | } elseif ($format == 'raw') { |
@@ -1043,25 +1391,55 @@ discard block |
||
1043 | 1391 | if (is_array($data)) { |
1044 | 1392 | $data['datetime'] = date('Y-m-d H:i:s'); |
1045 | 1393 | $data['format_source'] = 'raw'; |
1046 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1047 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1048 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1394 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1395 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1396 | + } |
|
1397 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1398 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1399 | + } |
|
1400 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1401 | + $SI->add($data); |
|
1402 | + } |
|
1049 | 1403 | } |
1050 | 1404 | } elseif ($format == 'ais') { |
1051 | 1405 | $ais_data = $AIS->parse_line(trim($buffer)); |
1052 | 1406 | $data = array(); |
1053 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1054 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1055 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1056 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1057 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1058 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1059 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1060 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1061 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1062 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1063 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1064 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1407 | + if (isset($ais_data['ident'])) { |
|
1408 | + $data['ident'] = $ais_data['ident']; |
|
1409 | + } |
|
1410 | + if (isset($ais_data['mmsi'])) { |
|
1411 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1412 | + } |
|
1413 | + if (isset($ais_data['speed'])) { |
|
1414 | + $data['speed'] = $ais_data['speed']; |
|
1415 | + } |
|
1416 | + if (isset($ais_data['heading'])) { |
|
1417 | + $data['heading'] = $ais_data['heading']; |
|
1418 | + } |
|
1419 | + if (isset($ais_data['latitude'])) { |
|
1420 | + $data['latitude'] = $ais_data['latitude']; |
|
1421 | + } |
|
1422 | + if (isset($ais_data['longitude'])) { |
|
1423 | + $data['longitude'] = $ais_data['longitude']; |
|
1424 | + } |
|
1425 | + if (isset($ais_data['status'])) { |
|
1426 | + $data['status'] = $ais_data['status']; |
|
1427 | + } |
|
1428 | + if (isset($ais_data['type'])) { |
|
1429 | + $data['type'] = $ais_data['type']; |
|
1430 | + } |
|
1431 | + if (isset($ais_data['imo'])) { |
|
1432 | + $data['imo'] = $ais_data['imo']; |
|
1433 | + } |
|
1434 | + if (isset($ais_data['callsign'])) { |
|
1435 | + $data['callsign'] = $ais_data['callsign']; |
|
1436 | + } |
|
1437 | + if (isset($ais_data['destination'])) { |
|
1438 | + $data['arrival_code'] = $ais_data['destination']; |
|
1439 | + } |
|
1440 | + if (isset($ais_data['eta_ts'])) { |
|
1441 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1442 | + } |
|
1065 | 1443 | |
1066 | 1444 | if (isset($ais_data['timestamp'])) { |
1067 | 1445 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1070,7 +1448,9 @@ discard block |
||
1070 | 1448 | } |
1071 | 1449 | $data['format_source'] = 'aisnmea'; |
1072 | 1450 | $data['id_source'] = $id_source; |
1073 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1451 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1452 | + $MI->add($data); |
|
1453 | + } |
|
1074 | 1454 | unset($data); |
1075 | 1455 | } elseif ($format == 'flightgearsp') { |
1076 | 1456 | //echo $buffer."\n"; |
@@ -1088,11 +1468,15 @@ discard block |
||
1088 | 1468 | $data['speed'] = round($line[5]*1.94384); |
1089 | 1469 | $data['datetime'] = date('Y-m-d H:i:s'); |
1090 | 1470 | $data['format_source'] = 'flightgearsp'; |
1091 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1471 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1472 | + $SI->add($data); |
|
1473 | + } |
|
1092 | 1474 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1093 | 1475 | } |
1094 | 1476 | } elseif ($format == 'acars') { |
1095 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1477 | + if ($globalDebug) { |
|
1478 | + echo 'ACARS : '.$buffer."\n"; |
|
1479 | + } |
|
1096 | 1480 | $ACARS->add(trim($buffer)); |
1097 | 1481 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1098 | 1482 | $ACARS->deleteLiveAcarsData(); |
@@ -1113,7 +1497,9 @@ discard block |
||
1113 | 1497 | $aircraft_type = $line[10]; |
1114 | 1498 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1115 | 1499 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1116 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1500 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1501 | + $SI->add($data); |
|
1502 | + } |
|
1117 | 1503 | } |
1118 | 1504 | } |
1119 | 1505 | } elseif ($format == 'beast') { |
@@ -1123,27 +1509,59 @@ discard block |
||
1123 | 1509 | foreach($buffer as $all_data) { |
1124 | 1510 | $line = json_decode('{'.$all_data.'}',true); |
1125 | 1511 | $data = array(); |
1126 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1127 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1128 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1129 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1130 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1131 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1132 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1512 | + if (isset($line['Icao'])) { |
|
1513 | + $data['hex'] = $line['Icao']; |
|
1514 | + } |
|
1515 | + // hex |
|
1516 | + if (isset($line['Call'])) { |
|
1517 | + $data['ident'] = $line['Call']; |
|
1518 | + } |
|
1519 | + // ident |
|
1520 | + if (isset($line['Alt'])) { |
|
1521 | + $data['altitude'] = $line['Alt']; |
|
1522 | + } |
|
1523 | + // altitude |
|
1524 | + if (isset($line['Spd'])) { |
|
1525 | + $data['speed'] = $line['Spd']; |
|
1526 | + } |
|
1527 | + // speed |
|
1528 | + if (isset($line['Trak'])) { |
|
1529 | + $data['heading'] = $line['Trak']; |
|
1530 | + } |
|
1531 | + // heading |
|
1532 | + if (isset($line['Lat'])) { |
|
1533 | + $data['latitude'] = $line['Lat']; |
|
1534 | + } |
|
1535 | + // lat |
|
1536 | + if (isset($line['Long'])) { |
|
1537 | + $data['longitude'] = $line['Long']; |
|
1538 | + } |
|
1539 | + // long |
|
1133 | 1540 | //$data['verticalrate'] = $line['']; // verticale rate |
1134 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1541 | + if (isset($line['Sqk'])) { |
|
1542 | + $data['squawk'] = $line['Sqk']; |
|
1543 | + } |
|
1544 | + // squawk |
|
1135 | 1545 | $data['emergency'] = ''; // emergency |
1136 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1546 | + if (isset($line['Reg'])) { |
|
1547 | + $data['registration'] = $line['Reg']; |
|
1548 | + } |
|
1137 | 1549 | /* |
1138 | 1550 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1139 | 1551 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1140 | 1552 | */ |
1141 | 1553 | $data['datetime'] = date('Y-m-d H:i:s'); |
1142 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1554 | + if (isset($line['Type'])) { |
|
1555 | + $data['aircraft_icao'] = $line['Type']; |
|
1556 | + } |
|
1143 | 1557 | $data['format_source'] = 'vrstcp'; |
1144 | 1558 | $data['id_source'] = $id_source; |
1145 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1146 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1559 | + if (isset($value['name']) && $value['name'] != '') { |
|
1560 | + $data['source_name'] = $value['name']; |
|
1561 | + } |
|
1562 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1563 | + $SI->add($data); |
|
1564 | + } |
|
1147 | 1565 | unset($data); |
1148 | 1566 | } |
1149 | 1567 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1156,21 +1574,43 @@ discard block |
||
1156 | 1574 | $data['hex'] = $lined['hexid']; |
1157 | 1575 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1158 | 1576 | $data['datetime'] = date('Y-m-d H:i:s');; |
1159 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1160 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1161 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1162 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1163 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1164 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1165 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1577 | + if (isset($lined['ident'])) { |
|
1578 | + $data['ident'] = $lined['ident']; |
|
1579 | + } |
|
1580 | + if (isset($lined['lat'])) { |
|
1581 | + $data['latitude'] = $lined['lat']; |
|
1582 | + } |
|
1583 | + if (isset($lined['lon'])) { |
|
1584 | + $data['longitude'] = $lined['lon']; |
|
1585 | + } |
|
1586 | + if (isset($lined['speed'])) { |
|
1587 | + $data['speed'] = $lined['speed']; |
|
1588 | + } |
|
1589 | + if (isset($lined['squawk'])) { |
|
1590 | + $data['squawk'] = $lined['squawk']; |
|
1591 | + } |
|
1592 | + if (isset($lined['alt'])) { |
|
1593 | + $data['altitude'] = $lined['alt']; |
|
1594 | + } |
|
1595 | + if (isset($lined['heading'])) { |
|
1596 | + $data['heading'] = $lined['heading']; |
|
1597 | + } |
|
1166 | 1598 | $data['id_source'] = $id_source; |
1167 | 1599 | $data['format_source'] = 'tsv'; |
1168 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1169 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1170 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1600 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1601 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1602 | + } |
|
1603 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1604 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1605 | + } |
|
1606 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1607 | + $SI->add($data); |
|
1608 | + } |
|
1171 | 1609 | unset($lined); |
1172 | 1610 | unset($data); |
1173 | - } else $error = true; |
|
1611 | + } else { |
|
1612 | + $error = true; |
|
1613 | + } |
|
1174 | 1614 | } elseif ($format == 'aprs' && $use_aprs) { |
1175 | 1615 | if ($aprs_connect == 0) { |
1176 | 1616 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1196,49 +1636,82 @@ discard block |
||
1196 | 1636 | $aprs_last_tx = time(); |
1197 | 1637 | $data = array(); |
1198 | 1638 | //print_r($line); |
1199 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1200 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1201 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1639 | + if (isset($line['address'])) { |
|
1640 | + $data['hex'] = $line['address']; |
|
1641 | + } |
|
1642 | + if (isset($line['timestamp'])) { |
|
1643 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1644 | + } else { |
|
1645 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1646 | + } |
|
1202 | 1647 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1203 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1648 | + if (isset($line['ident'])) { |
|
1649 | + $data['ident'] = $line['ident']; |
|
1650 | + } |
|
1204 | 1651 | $data['latitude'] = $line['latitude']; |
1205 | 1652 | $data['longitude'] = $line['longitude']; |
1206 | 1653 | //$data['verticalrate'] = $line[16]; |
1207 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1208 | - else $data['speed'] = 0; |
|
1209 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1210 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1211 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1212 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1654 | + if (isset($line['speed'])) { |
|
1655 | + $data['speed'] = $line['speed']; |
|
1656 | + } else { |
|
1657 | + $data['speed'] = 0; |
|
1658 | + } |
|
1659 | + if (isset($line['altitude'])) { |
|
1660 | + $data['altitude'] = $line['altitude']; |
|
1661 | + } |
|
1662 | + if (isset($line['comment'])) { |
|
1663 | + $data['comment'] = $line['comment']; |
|
1664 | + } |
|
1665 | + if (isset($line['symbol'])) { |
|
1666 | + $data['type'] = $line['symbol']; |
|
1667 | + } |
|
1668 | + if (isset($line['heading'])) { |
|
1669 | + $data['heading'] = $line['heading']; |
|
1670 | + } |
|
1213 | 1671 | //else $data['heading'] = 0; |
1214 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1215 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1672 | + if (isset($line['stealth'])) { |
|
1673 | + $data['aircraft_type'] = $line['stealth']; |
|
1674 | + } |
|
1675 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
1676 | + $data['noarchive'] = true; |
|
1677 | + } |
|
1216 | 1678 | $data['id_source'] = $id_source; |
1217 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1218 | - else $data['format_source'] = 'aprs'; |
|
1679 | + if (isset($line['format_source'])) { |
|
1680 | + $data['format_source'] = $line['format_source']; |
|
1681 | + } else { |
|
1682 | + $data['format_source'] = 'aprs'; |
|
1683 | + } |
|
1219 | 1684 | $data['source_name'] = $line['source']; |
1220 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1221 | - else $data['source_type'] = 'flarm'; |
|
1222 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1685 | + if (isset($line['source_type'])) { |
|
1686 | + $data['source_type'] = $line['source_type']; |
|
1687 | + } else { |
|
1688 | + $data['source_type'] = 'flarm'; |
|
1689 | + } |
|
1690 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1691 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1692 | + } |
|
1223 | 1693 | $currentdate = date('Y-m-d H:i:s'); |
1224 | 1694 | $aprsdate = strtotime($data['datetime']); |
1225 | 1695 | // Accept data if time <= system time + 20s |
1226 | 1696 | 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'])))) { |
1227 | 1697 | $send = $SI->add($data); |
1228 | 1698 | } elseif (isset($line['stealth'])) { |
1229 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1230 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1699 | + if ($line['stealth'] != 0) { |
|
1700 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1701 | + } else { |
|
1702 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1703 | + } |
|
1231 | 1704 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1232 | 1705 | } 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') { |
1233 | 1706 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1234 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
1707 | + if (isset($globalTracker) && $globalTracker) { |
|
1708 | + $send = $TI->add($data); |
|
1709 | + } |
|
1235 | 1710 | } |
1236 | 1711 | unset($data); |
1237 | - } |
|
1238 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1712 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1239 | 1713 | echo '!! Weather Station not yet supported'."\n"; |
1240 | - } |
|
1241 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1714 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1242 | 1715 | echo '!! Car & Trucks not yet supported'."\n"; |
1243 | 1716 | } |
1244 | 1717 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1271,25 +1744,42 @@ discard block |
||
1271 | 1744 | $data['ground'] = $line[21]; |
1272 | 1745 | $data['emergency'] = $line[19]; |
1273 | 1746 | $data['format_source'] = 'sbs'; |
1274 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1275 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1747 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1748 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1749 | + } |
|
1750 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1751 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1752 | + } |
|
1276 | 1753 | $data['id_source'] = $id_source; |
1277 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1278 | - else $error = true; |
|
1754 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1755 | + $send = $SI->add($data); |
|
1756 | + } else { |
|
1757 | + $error = true; |
|
1758 | + } |
|
1279 | 1759 | unset($data); |
1280 | - } else $error = true; |
|
1760 | + } else { |
|
1761 | + $error = true; |
|
1762 | + } |
|
1281 | 1763 | if ($error) { |
1282 | 1764 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1283 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1765 | + if ($globalDebug) { |
|
1766 | + echo "Not a message. Ignoring... \n"; |
|
1767 | + } |
|
1284 | 1768 | } else { |
1285 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1769 | + if ($globalDebug) { |
|
1770 | + echo "Wrong line format. Ignoring... \n"; |
|
1771 | + } |
|
1286 | 1772 | if ($globalDebug) { |
1287 | 1773 | echo $buffer; |
1288 | 1774 | print_r($line); |
1289 | 1775 | } |
1290 | 1776 | //socket_close($r); |
1291 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1292 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1777 | + if ($globalDebug) { |
|
1778 | + echo "Reconnect after an error...\n"; |
|
1779 | + } |
|
1780 | + if ($format == 'aprs') { |
|
1781 | + $aprs_connect = 0; |
|
1782 | + } |
|
1293 | 1783 | $sourceer[$nb] = $globalSources[$nb]; |
1294 | 1784 | connect_all($sourceer); |
1295 | 1785 | $sourceer = array(); |
@@ -1297,10 +1787,14 @@ discard block |
||
1297 | 1787 | } |
1298 | 1788 | } |
1299 | 1789 | // Sleep for xxx microseconds |
1300 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1790 | + if (isset($globalSBSSleep)) { |
|
1791 | + usleep($globalSBSSleep); |
|
1792 | + } |
|
1301 | 1793 | } else { |
1302 | 1794 | if ($format == 'flightgearmp') { |
1303 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1795 | + if ($globalDebug) { |
|
1796 | + echo "Reconnect FlightGear MP..."; |
|
1797 | + } |
|
1304 | 1798 | //@socket_close($r); |
1305 | 1799 | sleep($globalMinFetch); |
1306 | 1800 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1309,10 +1803,15 @@ discard block |
||
1309 | 1803 | break; |
1310 | 1804 | |
1311 | 1805 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1312 | - if (isset($tt[$format])) $tt[$format]++; |
|
1313 | - else $tt[$format] = 0; |
|
1806 | + if (isset($tt[$format])) { |
|
1807 | + $tt[$format]++; |
|
1808 | + } else { |
|
1809 | + $tt[$format] = 0; |
|
1810 | + } |
|
1314 | 1811 | if ($tt[$format] > 30) { |
1315 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1812 | + if ($globalDebug) { |
|
1813 | + echo "ERROR : Reconnect ".$format."..."; |
|
1814 | + } |
|
1316 | 1815 | //@socket_close($r); |
1317 | 1816 | sleep(2); |
1318 | 1817 | $aprs_connect = 0; |
@@ -1329,11 +1828,17 @@ discard block |
||
1329 | 1828 | } else { |
1330 | 1829 | $error = socket_strerror(socket_last_error()); |
1331 | 1830 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1332 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1333 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1831 | + if ($globalDebug) { |
|
1832 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1833 | + } |
|
1834 | + if (isset($globalDebug)) { |
|
1835 | + echo "Restarting...\n"; |
|
1836 | + } |
|
1334 | 1837 | // Restart the script if possible |
1335 | 1838 | if (is_array($sockets)) { |
1336 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1839 | + if ($globalDebug) { |
|
1840 | + echo "Shutdown all sockets..."; |
|
1841 | + } |
|
1337 | 1842 | |
1338 | 1843 | foreach ($sockets as $sock) { |
1339 | 1844 | @socket_shutdown($sock,2); |
@@ -1341,18 +1846,24 @@ discard block |
||
1341 | 1846 | } |
1342 | 1847 | |
1343 | 1848 | } |
1344 | - if ($globalDebug) echo "Restart all connections..."; |
|
1849 | + if ($globalDebug) { |
|
1850 | + echo "Restart all connections..."; |
|
1851 | + } |
|
1345 | 1852 | sleep(2); |
1346 | 1853 | $time = time(); |
1347 | 1854 | //connect_all($hosts); |
1348 | 1855 | $aprs_connect = 0; |
1349 | - if ($reset > 40) exit('Too many attempts...'); |
|
1856 | + if ($reset > 40) { |
|
1857 | + exit('Too many attempts...'); |
|
1858 | + } |
|
1350 | 1859 | connect_all($globalSources); |
1351 | 1860 | } |
1352 | 1861 | } |
1353 | 1862 | } |
1354 | 1863 | if ($globalDaemon === false) { |
1355 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1864 | + if ($globalDebug) { |
|
1865 | + echo 'Check all...'."\n"; |
|
1866 | + } |
|
1356 | 1867 | $SI->checkAll(); |
1357 | 1868 | } |
1358 | 1869 | } |