@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,42 +25,42 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->latest() === false) { |
28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | - exit(); |
|
28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if (PHP_SAPI != 'cli') { |
32 | - echo "This script MUST be called from console, not a web browser."; |
|
32 | + echo "This script MUST be called from console, not a web browser."; |
|
33 | 33 | // exit(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | // This is to be compatible with old version of settings.php |
37 | 37 | if (!isset($globalSources)) { |
38 | - if (isset($globalSBS1Hosts)) { |
|
39 | - //$hosts = $globalSBS1Hosts; |
|
40 | - foreach ($globalSBS1Hosts as $host) { |
|
41 | - $globalSources[] = array('host' => $host); |
|
42 | - } |
|
43 | - } else { |
|
44 | - if (!isset($globalSBS1Host)) { |
|
45 | - echo '$globalSources MUST be defined !'; |
|
46 | - die; |
|
38 | + if (isset($globalSBS1Hosts)) { |
|
39 | + //$hosts = $globalSBS1Hosts; |
|
40 | + foreach ($globalSBS1Hosts as $host) { |
|
41 | + $globalSources[] = array('host' => $host); |
|
42 | + } |
|
43 | + } else { |
|
44 | + if (!isset($globalSBS1Host)) { |
|
45 | + echo '$globalSources MUST be defined !'; |
|
46 | + die; |
|
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | - $globalSources = array(); |
|
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
57 | + $globalSources = array(); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | + else $globalSources[] = array('host' => $options['s']); |
|
60 | 60 | } elseif (isset($options['source'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['source']); |
|
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | - $SI=new SpotterServer(); |
|
78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | + $SI=new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } else $SI=new SpotterImport($Connection->db); |
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | - $AIS = new AIS(); |
|
89 | - $MI = new MarineImport($Connection->db); |
|
88 | + $AIS = new AIS(); |
|
89 | + $MI = new MarineImport($Connection->db); |
|
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
101 | - global $sockets; |
|
102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | - die("Bye!\n"); |
|
104 | - }); |
|
105 | - pcntl_signal_dispatch(); |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | + global $sockets; |
|
102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | + die("Bye!\n"); |
|
104 | + }); |
|
105 | + pcntl_signal_dispatch(); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
112 | 112 | $reset = 0; |
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | - $reset++; |
|
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | - foreach ($hosts as $id => $value) { |
|
115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | + $reset++; |
|
118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | + foreach ($hosts as $id => $value) { |
|
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | - //$formats[$id] = 'deltadbtxt'; |
|
126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | - //$last_exec['deltadbtxt'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | - //$formats[$id] = 'vatsimtxt'; |
|
131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | - //$last_exec['vatsimtxt'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'aircraftlistjson'; |
|
136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | - //$last_exec['aircraftlistjson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
140 | - //$formats[$id] = 'aircraftlistjson'; |
|
141 | - $globalSources[$id]['format'] = 'opensky'; |
|
142 | - //$last_exec['aircraftlistjson'] = 0; |
|
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | - /* |
|
124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | + //$formats[$id] = 'deltadbtxt'; |
|
126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | + //$last_exec['deltadbtxt'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | + //$formats[$id] = 'vatsimtxt'; |
|
131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | + //$last_exec['vatsimtxt'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'aircraftlistjson'; |
|
136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | + //$last_exec['aircraftlistjson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | + } else if (preg_match('/opensky/i',$host)) { |
|
140 | + //$formats[$id] = 'aircraftlistjson'; |
|
141 | + $globalSources[$id]['format'] = 'opensky'; |
|
142 | + //$last_exec['aircraftlistjson'] = 0; |
|
143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | + /* |
|
145 | 145 | // Disabled for now, site change source format |
146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,118 +153,118 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | - //$formats[$id] = 'planeupdatefaa'; |
|
158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | - //$last_exec['planeupdatefaa'] = 0; |
|
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | - exit(0); |
|
164 | - } |
|
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | - //$last_exec['phpvmacars'] = 0; |
|
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | - //$formats[$id] = 'phpvmacars'; |
|
172 | - $globalSources[$id]['format'] = 'vam'; |
|
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
175 | - //$formats[$id] = 'whazzup'; |
|
176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
177 | - //$last_exec['whazzup'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
180 | - $globalSources[$id]['format'] = 'airwhere'; |
|
181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
183 | - //$formats[$id] = 'pirepsjson'; |
|
184 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
185 | - //$last_exec['pirepsjson'] = 0; |
|
186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
188 | - //$formats[$id] = 'fr24json'; |
|
189 | - $globalSources[$id]['format'] = 'fr24json'; |
|
190 | - //$last_exec['fr24json'] = 0; |
|
191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
192 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
193 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
194 | - exit(0); |
|
195 | - } |
|
196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
197 | - //$formats[$id] = 'fr24json'; |
|
198 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
199 | - //$last_exec['fr24json'] = 0; |
|
200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
201 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
202 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
203 | - exit(0); |
|
204 | - } |
|
205 | - //} else if (preg_match('/10001/',$host)) { |
|
206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | - //$formats[$id] = 'tsv'; |
|
208 | - $globalSources[$id]['format'] = 'tsv'; |
|
209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
210 | - } |
|
211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
212 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
214 | - if ($idf !== false) { |
|
215 | - $httpfeeds[$id] = $idf; |
|
216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
217 | - } |
|
218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | - $hostport = explode(':',$host); |
|
222 | - if (isset($hostport[1])) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | + //$formats[$id] = 'planeupdatefaa'; |
|
158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | + //$last_exec['planeupdatefaa'] = 0; |
|
160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | + exit(0); |
|
164 | + } |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | + //$last_exec['phpvmacars'] = 0; |
|
169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | + //$formats[$id] = 'phpvmacars'; |
|
172 | + $globalSources[$id]['format'] = 'vam'; |
|
173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
175 | + //$formats[$id] = 'whazzup'; |
|
176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
177 | + //$last_exec['whazzup'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | + } else if (preg_match('/airwhere/i',$host)) { |
|
180 | + $globalSources[$id]['format'] = 'airwhere'; |
|
181 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
182 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
183 | + //$formats[$id] = 'pirepsjson'; |
|
184 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
185 | + //$last_exec['pirepsjson'] = 0; |
|
186 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
188 | + //$formats[$id] = 'fr24json'; |
|
189 | + $globalSources[$id]['format'] = 'fr24json'; |
|
190 | + //$last_exec['fr24json'] = 0; |
|
191 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
192 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
193 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
194 | + exit(0); |
|
195 | + } |
|
196 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
197 | + //$formats[$id] = 'fr24json'; |
|
198 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
199 | + //$last_exec['fr24json'] = 0; |
|
200 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
201 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
202 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
203 | + exit(0); |
|
204 | + } |
|
205 | + //} else if (preg_match('/10001/',$host)) { |
|
206 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | + //$formats[$id] = 'tsv'; |
|
208 | + $globalSources[$id]['format'] = 'tsv'; |
|
209 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
210 | + } |
|
211 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
212 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
213 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
214 | + if ($idf !== false) { |
|
215 | + $httpfeeds[$id] = $idf; |
|
216 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
217 | + } |
|
218 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
219 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | + $hostport = explode(':',$host); |
|
222 | + if (isset($hostport[1])) { |
|
223 | 223 | $port = $hostport[1]; |
224 | 224 | $hostn = $hostport[0]; |
225 | - } else { |
|
225 | + } else { |
|
226 | 226 | $port = $globalSources[$id]['port']; |
227 | 227 | $hostn = $globalSources[$id]['host']; |
228 | - } |
|
229 | - $Common = new Common(); |
|
230 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
232 | - } else { |
|
233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
234 | - } |
|
235 | - if ($s) { |
|
236 | - $sockets[$id] = $s; |
|
237 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
228 | + } |
|
229 | + $Common = new Common(); |
|
230 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
231 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
232 | + } else { |
|
233 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
234 | + } |
|
235 | + if ($s) { |
|
236 | + $sockets[$id] = $s; |
|
237 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
238 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
239 | 239 | //$formats[$id] = 'aprs'; |
240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
241 | 241 | //$aprs_connect = 0; |
242 | 242 | //$use_aprs = true; |
243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
243 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
245 | - } elseif ($port == '10001') { |
|
246 | - //$formats[$id] = 'tsv'; |
|
247 | - $globalSources[$id]['format'] = 'tsv'; |
|
248 | - } elseif ($port == '30002') { |
|
249 | - //$formats[$id] = 'raw'; |
|
250 | - $globalSources[$id]['format'] = 'raw'; |
|
251 | - } elseif ($port == '5001') { |
|
252 | - //$formats[$id] = 'raw'; |
|
253 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
254 | - } elseif ($port == '30005') { |
|
245 | + } elseif ($port == '10001') { |
|
246 | + //$formats[$id] = 'tsv'; |
|
247 | + $globalSources[$id]['format'] = 'tsv'; |
|
248 | + } elseif ($port == '30002') { |
|
249 | + //$formats[$id] = 'raw'; |
|
250 | + $globalSources[$id]['format'] = 'raw'; |
|
251 | + } elseif ($port == '5001') { |
|
252 | + //$formats[$id] = 'raw'; |
|
253 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
254 | + } elseif ($port == '30005') { |
|
255 | 255 | // Not yet supported |
256 | - //$formats[$id] = 'beast'; |
|
257 | - $globalSources[$id]['format'] = 'beast'; |
|
258 | - //} else $formats[$id] = 'sbs'; |
|
259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
260 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
256 | + //$formats[$id] = 'beast'; |
|
257 | + $globalSources[$id]['format'] = 'beast'; |
|
258 | + //} else $formats[$id] = 'sbs'; |
|
259 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
260 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
261 | 261 | } |
262 | 262 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
263 | - } else { |
|
263 | + } else { |
|
264 | 264 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
265 | - } |
|
266 | - } |
|
267 | - } |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
270 | 270 | |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | //connect_all($globalSources); |
288 | 288 | |
289 | 289 | if (isset($globalProxy) && $globalProxy) { |
290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
291 | 291 | } else { |
292 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
292 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // APRS Configuration |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | die; |
299 | 299 | } |
300 | 300 | foreach ($globalSources as $key => $source) { |
301 | - if (!isset($source['format'])) { |
|
302 | - $globalSources[$key]['format'] = 'auto'; |
|
303 | - } |
|
301 | + if (!isset($source['format'])) { |
|
302 | + $globalSources[$key]['format'] = 'auto'; |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | connect_all($globalSources); |
306 | 306 | foreach ($globalSources as $key => $source) { |
307 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
307 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
308 | 308 | $aprs_connect = 0; |
309 | 309 | $use_aprs = true; |
310 | 310 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
311 | 311 | break; |
312 | - } |
|
312 | + } |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($use_aprs) { |
@@ -350,115 +350,115 @@ discard block |
||
350 | 350 | |
351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
352 | 352 | while ($i > 0) { |
353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
354 | - // Delete old ATC |
|
355 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
353 | + if (!$globalDaemon) $i = $endtime-time(); |
|
354 | + // Delete old ATC |
|
355 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
357 | - $ATC->deleteOldATC(); |
|
358 | - } |
|
357 | + $ATC->deleteOldATC(); |
|
358 | + } |
|
359 | 359 | |
360 | - if (count($last_exec) == count($globalSources)) { |
|
360 | + if (count($last_exec) == count($globalSources)) { |
|
361 | 361 | $max = $globalMinFetch; |
362 | 362 | foreach ($last_exec as $last) { |
363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
363 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
364 | 364 | } |
365 | 365 | if ($max != $globalMinFetch) { |
366 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
367 | - sleep($globalMinFetch-$max+2); |
|
366 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
367 | + sleep($globalMinFetch-$max+2); |
|
368 | + } |
|
368 | 369 | } |
369 | - } |
|
370 | 370 | |
371 | 371 | |
372 | - //foreach ($formats as $id => $value) { |
|
373 | - foreach ($globalSources as $id => $value) { |
|
372 | + //foreach ($formats as $id => $value) { |
|
373 | + foreach ($globalSources as $id => $value) { |
|
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
376 | 376 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
377 | - //$buffer = $Common->getData($hosts[$id]); |
|
378 | - $buffer = $Common->getData($value['host']); |
|
379 | - if ($buffer != '') $reset = 0; |
|
380 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | - $buffer = explode('\n',$buffer); |
|
382 | - foreach ($buffer as $line) { |
|
383 | - if ($line != '' && count($line) > 7) { |
|
384 | - $line = explode(',', $line); |
|
385 | - $data = array(); |
|
386 | - $data['hex'] = $line[1]; // hex |
|
387 | - $data['ident'] = $line[2]; // ident |
|
388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
393 | - $data['verticalrate'] = ''; // vertical rate |
|
394 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
395 | - $data['emergency'] = ''; // emergency |
|
396 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
397 | - $data['format_source'] = 'deltadbtxt'; |
|
398 | - $data['id_source'] = $id_source; |
|
399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
402 | - $SI->add($data); |
|
403 | - unset($data); |
|
404 | - } |
|
405 | - } |
|
406 | - $last_exec[$id]['last'] = time(); |
|
377 | + //$buffer = $Common->getData($hosts[$id]); |
|
378 | + $buffer = $Common->getData($value['host']); |
|
379 | + if ($buffer != '') $reset = 0; |
|
380 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | + $buffer = explode('\n',$buffer); |
|
382 | + foreach ($buffer as $line) { |
|
383 | + if ($line != '' && count($line) > 7) { |
|
384 | + $line = explode(',', $line); |
|
385 | + $data = array(); |
|
386 | + $data['hex'] = $line[1]; // hex |
|
387 | + $data['ident'] = $line[2]; // ident |
|
388 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
389 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
390 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
391 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
392 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
393 | + $data['verticalrate'] = ''; // vertical rate |
|
394 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
395 | + $data['emergency'] = ''; // emergency |
|
396 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
397 | + $data['format_source'] = 'deltadbtxt'; |
|
398 | + $data['id_source'] = $id_source; |
|
399 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
400 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
401 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
402 | + $SI->add($data); |
|
403 | + unset($data); |
|
404 | + } |
|
405 | + } |
|
406 | + $last_exec[$id]['last'] = time(); |
|
407 | 407 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
408 | - date_default_timezone_set('CET'); |
|
409 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
410 | - date_default_timezone_set('UTC'); |
|
411 | - if ($buffer != '') $reset = 0; |
|
412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | - $buffer = explode('\n',$buffer); |
|
414 | - foreach ($buffer as $line) { |
|
408 | + date_default_timezone_set('CET'); |
|
409 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
410 | + date_default_timezone_set('UTC'); |
|
411 | + if ($buffer != '') $reset = 0; |
|
412 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | + $buffer = explode('\n',$buffer); |
|
414 | + foreach ($buffer as $line) { |
|
415 | 415 | if ($line != '') { |
416 | - echo "'".$line."'\n"; |
|
417 | - $add = false; |
|
418 | - $ais_data = $AIS->parse_line(trim($line)); |
|
419 | - $data = array(); |
|
420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
430 | - if (isset($ais_data['timestamp'])) { |
|
416 | + echo "'".$line."'\n"; |
|
417 | + $add = false; |
|
418 | + $ais_data = $AIS->parse_line(trim($line)); |
|
419 | + $data = array(); |
|
420 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
421 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
422 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
423 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
424 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
425 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
426 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
427 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
428 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
429 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
430 | + if (isset($ais_data['timestamp'])) { |
|
431 | 431 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
432 | 432 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
433 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
434 | - $add = true; |
|
433 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
434 | + $add = true; |
|
435 | 435 | } |
436 | - } else { |
|
436 | + } else { |
|
437 | 437 | $data['datetime'] = date('Y-m-d H:i:s'); |
438 | 438 | $add = true; |
439 | - } |
|
440 | - $data['format_source'] = 'aisnmeatxt'; |
|
441 | - $data['id_source'] = $id_source; |
|
442 | - //print_r($data); |
|
443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
445 | - unset($data); |
|
439 | + } |
|
440 | + $data['format_source'] = 'aisnmeatxt'; |
|
441 | + $data['id_source'] = $id_source; |
|
442 | + //print_r($data); |
|
443 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
444 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
445 | + unset($data); |
|
446 | 446 | } |
447 | - } |
|
448 | - $last_exec[$id]['last'] = time(); |
|
447 | + } |
|
448 | + $last_exec[$id]['last'] = time(); |
|
449 | 449 | } elseif ($value['format'] == 'aisnmeahttp') { |
450 | - $arr = $httpfeeds; |
|
451 | - $w = $e = null; |
|
450 | + $arr = $httpfeeds; |
|
451 | + $w = $e = null; |
|
452 | 452 | |
453 | - if (isset($arr[$id])) { |
|
453 | + if (isset($arr[$id])) { |
|
454 | 454 | $nn = stream_select($arr,$w,$e,$timeout); |
455 | 455 | if ($nn > 0) { |
456 | - foreach ($httpfeeds as $feed) { |
|
456 | + foreach ($httpfeeds as $feed) { |
|
457 | 457 | $buffer = stream_get_line($feed,2000,"\n"); |
458 | 458 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
459 | 459 | $buffer = explode('\n',$buffer); |
460 | 460 | foreach ($buffer as $line) { |
461 | - if ($line != '') { |
|
461 | + if ($line != '') { |
|
462 | 462 | $ais_data = $AIS->parse_line(trim($line)); |
463 | 463 | $data = array(); |
464 | 464 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -476,96 +476,96 @@ discard block |
||
476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
477 | 477 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
478 | 478 | if (isset($ais_data['timestamp'])) { |
479 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
479 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
480 | 480 | } else { |
481 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
481 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
482 | 482 | } |
483 | 483 | $data['format_source'] = 'aisnmeahttp'; |
484 | 484 | $data['id_source'] = $id_source; |
485 | 485 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
486 | 486 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
487 | 487 | unset($data); |
488 | - } |
|
488 | + } |
|
489 | + } |
|
489 | 490 | } |
490 | - } |
|
491 | 491 | } else { |
492 | - $format = $value['format']; |
|
493 | - if (isset($tt[$format])) $tt[$format]++; |
|
494 | - else $tt[$format] = 0; |
|
495 | - if ($tt[$format] > 30) { |
|
492 | + $format = $value['format']; |
|
493 | + if (isset($tt[$format])) $tt[$format]++; |
|
494 | + else $tt[$format] = 0; |
|
495 | + if ($tt[$format] > 30) { |
|
496 | 496 | if ($globalDebug) echo 'Reconnect...'."\n"; |
497 | 497 | sleep(2); |
498 | 498 | $sourceeen[] = $value; |
499 | 499 | connect_all($sourceeen); |
500 | 500 | $sourceeen = array(); |
501 | - } |
|
501 | + } |
|
502 | + } |
|
502 | 503 | } |
503 | - } |
|
504 | 504 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
506 | - if ($buffer != '') { |
|
505 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
506 | + if ($buffer != '') { |
|
507 | 507 | //echo $buffer; |
508 | 508 | $all_data = json_decode($buffer,true); |
509 | 509 | //print_r($all_data); |
510 | 510 | if (isset($all_data[0]['DATA'])) { |
511 | - foreach ($all_data[0]['DATA'] as $line) { |
|
511 | + foreach ($all_data[0]['DATA'] as $line) { |
|
512 | 512 | if ($line != '') { |
513 | - $data = array(); |
|
514 | - $data['ident'] = $line['NAME']; |
|
515 | - $data['mmsi'] = $line['MMSI']; |
|
516 | - $data['speed'] = $line['SOG']; |
|
517 | - $data['heading'] = $line['COG']; |
|
518 | - $data['latitude'] = $line['LAT']; |
|
519 | - $data['longitude'] = $line['LNG']; |
|
520 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
521 | - $data['imo'] = $line['IMO']; |
|
522 | - //$data['arrival_code'] = $ais_data['destination']; |
|
523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
524 | - $data['format_source'] = 'myshiptracking'; |
|
525 | - $data['id_source'] = $id_source; |
|
526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
527 | - $MI->add($data); |
|
528 | - unset($data); |
|
513 | + $data = array(); |
|
514 | + $data['ident'] = $line['NAME']; |
|
515 | + $data['mmsi'] = $line['MMSI']; |
|
516 | + $data['speed'] = $line['SOG']; |
|
517 | + $data['heading'] = $line['COG']; |
|
518 | + $data['latitude'] = $line['LAT']; |
|
519 | + $data['longitude'] = $line['LNG']; |
|
520 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
521 | + $data['imo'] = $line['IMO']; |
|
522 | + //$data['arrival_code'] = $ais_data['destination']; |
|
523 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
524 | + $data['format_source'] = 'myshiptracking'; |
|
525 | + $data['id_source'] = $id_source; |
|
526 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
527 | + $MI->add($data); |
|
528 | + unset($data); |
|
529 | + } |
|
529 | 530 | } |
530 | - } |
|
531 | 531 | } |
532 | - } |
|
533 | - $last_exec[$id]['last'] = time(); |
|
532 | + } |
|
533 | + $last_exec[$id]['last'] = time(); |
|
534 | 534 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
535 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
536 | - if ($buffer != '') { |
|
535 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
536 | + if ($buffer != '') { |
|
537 | 537 | $all_data = json_decode($buffer,true); |
538 | 538 | if (isset($all_data[0]['mmsi'])) { |
539 | - foreach ($all_data as $line) { |
|
539 | + foreach ($all_data as $line) { |
|
540 | 540 | if ($line != '') { |
541 | - $data = array(); |
|
542 | - $data['ident'] = $line['shipname']; |
|
543 | - $data['callsign'] = $line['callsign']; |
|
544 | - $data['mmsi'] = $line['mmsi']; |
|
545 | - $data['speed'] = $line['sog']; |
|
546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
547 | - $data['latitude'] = $line['latitude']; |
|
548 | - $data['longitude'] = $line['longitude']; |
|
549 | - $data['type_id'] = $line['shiptype']; |
|
550 | - $data['arrival_code'] = $line['destination']; |
|
551 | - $data['datetime'] = $line['time']; |
|
552 | - $data['format_source'] = 'boatbeaconapp'; |
|
553 | - $data['id_source'] = $id_source; |
|
554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
555 | - $MI->add($data); |
|
556 | - unset($data); |
|
541 | + $data = array(); |
|
542 | + $data['ident'] = $line['shipname']; |
|
543 | + $data['callsign'] = $line['callsign']; |
|
544 | + $data['mmsi'] = $line['mmsi']; |
|
545 | + $data['speed'] = $line['sog']; |
|
546 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
547 | + $data['latitude'] = $line['latitude']; |
|
548 | + $data['longitude'] = $line['longitude']; |
|
549 | + $data['type_id'] = $line['shiptype']; |
|
550 | + $data['arrival_code'] = $line['destination']; |
|
551 | + $data['datetime'] = $line['time']; |
|
552 | + $data['format_source'] = 'boatbeaconapp'; |
|
553 | + $data['id_source'] = $id_source; |
|
554 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
555 | + $MI->add($data); |
|
556 | + unset($data); |
|
557 | + } |
|
557 | 558 | } |
558 | - } |
|
559 | 559 | } |
560 | 560 | |
561 | - } |
|
562 | - $last_exec[$id]['last'] = time(); |
|
561 | + } |
|
562 | + $last_exec[$id]['last'] = time(); |
|
563 | 563 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
564 | - $buffer = $Common->getData($value['host']); |
|
565 | - if ($buffer != '') { |
|
564 | + $buffer = $Common->getData($value['host']); |
|
565 | + if ($buffer != '') { |
|
566 | 566 | $all_data = json_decode($buffer,true); |
567 | 567 | if (isset($all_data['features'][0]['id'])) { |
568 | - foreach ($all_data['features'] as $line) { |
|
568 | + foreach ($all_data['features'] as $line) { |
|
569 | 569 | $data = array(); |
570 | 570 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
571 | 571 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -584,59 +584,59 @@ discard block |
||
584 | 584 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
585 | 585 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
586 | 586 | unset($data); |
587 | - } |
|
587 | + } |
|
588 | 588 | } |
589 | 589 | |
590 | - } |
|
591 | - $last_exec[$id]['last'] = time(); |
|
590 | + } |
|
591 | + $last_exec[$id]['last'] = time(); |
|
592 | 592 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
593 | - echo 'download...'; |
|
594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
595 | - echo 'done !'."\n"; |
|
596 | - if ($buffer != '') $reset = 0; |
|
597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | - $buffer = explode('\n',$buffer); |
|
599 | - foreach ($buffer as $line) { |
|
593 | + echo 'download...'; |
|
594 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
595 | + echo 'done !'."\n"; |
|
596 | + if ($buffer != '') $reset = 0; |
|
597 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | + $buffer = explode('\n',$buffer); |
|
599 | + foreach ($buffer as $line) { |
|
600 | 600 | if ($line != '') { |
601 | - $data = array(); |
|
602 | - $data['mmsi'] = (int)substr($line,0,9); |
|
603 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
604 | - //$data['status'] = substr($line,21,2); |
|
605 | - //$data['type'] = substr($line,24,3); |
|
606 | - $data['latitude'] = substr($line,29,9); |
|
607 | - $data['longitude'] = substr($line,41,9); |
|
608 | - $data['speed'] = round(substr($line,51,5)); |
|
609 | - //$data['course'] = substr($line,57,5); |
|
610 | - $data['heading'] = round(substr($line,63,3)); |
|
611 | - //$data['draft'] = substr($line,67,4); |
|
612 | - //$data['length'] = substr($line,72,3); |
|
613 | - //$data['beam'] = substr($line,76,2); |
|
614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
615 | - //$data['callsign'] = trim(substr($line,100,7); |
|
616 | - //$data['dest'] = substr($line,108,20); |
|
617 | - //$data['etaDate'] = substr($line,129,5); |
|
618 | - //$data['etaTime'] = substr($line,135,5); |
|
619 | - $data['format_source'] = 'shipplotter'; |
|
620 | - $data['id_source'] = $id_source; |
|
621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
622 | - //print_r($data); |
|
623 | - echo 'Add...'."\n"; |
|
624 | - $MI->add($data); |
|
625 | - unset($data); |
|
601 | + $data = array(); |
|
602 | + $data['mmsi'] = (int)substr($line,0,9); |
|
603 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
604 | + //$data['status'] = substr($line,21,2); |
|
605 | + //$data['type'] = substr($line,24,3); |
|
606 | + $data['latitude'] = substr($line,29,9); |
|
607 | + $data['longitude'] = substr($line,41,9); |
|
608 | + $data['speed'] = round(substr($line,51,5)); |
|
609 | + //$data['course'] = substr($line,57,5); |
|
610 | + $data['heading'] = round(substr($line,63,3)); |
|
611 | + //$data['draft'] = substr($line,67,4); |
|
612 | + //$data['length'] = substr($line,72,3); |
|
613 | + //$data['beam'] = substr($line,76,2); |
|
614 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
615 | + //$data['callsign'] = trim(substr($line,100,7); |
|
616 | + //$data['dest'] = substr($line,108,20); |
|
617 | + //$data['etaDate'] = substr($line,129,5); |
|
618 | + //$data['etaTime'] = substr($line,135,5); |
|
619 | + $data['format_source'] = 'shipplotter'; |
|
620 | + $data['id_source'] = $id_source; |
|
621 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
622 | + //print_r($data); |
|
623 | + echo 'Add...'."\n"; |
|
624 | + $MI->add($data); |
|
625 | + unset($data); |
|
626 | 626 | } |
627 | - } |
|
628 | - $last_exec[$id]['last'] = time(); |
|
627 | + } |
|
628 | + $last_exec[$id]['last'] = time(); |
|
629 | 629 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
630 | 630 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
631 | - //$buffer = $Common->getData($hosts[$id]); |
|
632 | - $buffer = $Common->getData($value['host']); |
|
633 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | - $buffer = explode('\n',$buffer); |
|
635 | - $reset = 0; |
|
636 | - foreach ($buffer as $line) { |
|
637 | - if ($line != '') { |
|
638 | - $line = explode(':', $line); |
|
639 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
631 | + //$buffer = $Common->getData($hosts[$id]); |
|
632 | + $buffer = $Common->getData($value['host']); |
|
633 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | + $buffer = explode('\n',$buffer); |
|
635 | + $reset = 0; |
|
636 | + foreach ($buffer as $line) { |
|
637 | + if ($line != '') { |
|
638 | + $line = explode(':', $line); |
|
639 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
640 | 640 | $data = array(); |
641 | 641 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -649,37 +649,37 @@ discard block |
||
649 | 649 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
650 | 650 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
651 | 651 | $data['latitude'] = $line[5]; // lat |
652 | - $data['longitude'] = $line[6]; // long |
|
653 | - $data['verticalrate'] = ''; // vertical rate |
|
654 | - $data['squawk'] = ''; // squawk |
|
655 | - $data['emergency'] = ''; // emergency |
|
656 | - $data['waypoints'] = $line[30]; |
|
652 | + $data['longitude'] = $line[6]; // long |
|
653 | + $data['verticalrate'] = ''; // vertical rate |
|
654 | + $data['squawk'] = ''; // squawk |
|
655 | + $data['emergency'] = ''; // emergency |
|
656 | + $data['waypoints'] = $line[30]; |
|
657 | 657 | $data['datetime'] = date('Y-m-d H:i:s'); |
658 | 658 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
660 | - $data['departure_airport_icao'] = $line[11]; |
|
661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
662 | - $data['arrival_airport_icao'] = $line[13]; |
|
660 | + $data['departure_airport_icao'] = $line[11]; |
|
661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
662 | + $data['arrival_airport_icao'] = $line[13]; |
|
663 | 663 | $data['frequency'] = $line[4]; |
664 | 664 | $data['type'] = $line[18]; |
665 | 665 | $data['range'] = $line[19]; |
666 | 666 | if (isset($line[35])) $data['info'] = $line[35]; |
667 | - $data['id_source'] = $id_source; |
|
668 | - //$data['arrival_airport_time'] = ; |
|
669 | - if ($line[9] != '') { |
|
670 | - $aircraft_data = explode('/',$line[9]); |
|
671 | - if (isset($aircraft_data[1])) { |
|
672 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
673 | - } |
|
674 | - } |
|
675 | - /* |
|
667 | + $data['id_source'] = $id_source; |
|
668 | + //$data['arrival_airport_time'] = ; |
|
669 | + if ($line[9] != '') { |
|
670 | + $aircraft_data = explode('/',$line[9]); |
|
671 | + if (isset($aircraft_data[1])) { |
|
672 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
673 | + } |
|
674 | + } |
|
675 | + /* |
|
676 | 676 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
677 | 677 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
678 | 678 | */ |
679 | - $data['format_source'] = $value['format']; |
|
679 | + $data['format_source'] = $value['format']; |
|
680 | 680 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
681 | 681 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
682 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
682 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
683 | 683 | elseif ($line[3] == 'ATC') { |
684 | 684 | //print_r($data); |
685 | 685 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -700,16 +700,16 @@ discard block |
||
700 | 700 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
701 | 701 | } |
702 | 702 | } |
703 | - unset($data); |
|
704 | - } |
|
705 | - } |
|
706 | - } |
|
707 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
708 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
709 | - $last_exec[$id]['last'] = time(); |
|
710 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
711 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
712 | - if ($buffer != '') { |
|
703 | + unset($data); |
|
704 | + } |
|
705 | + } |
|
706 | + } |
|
707 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
708 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
709 | + $last_exec[$id]['last'] = time(); |
|
710 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
711 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
712 | + if ($buffer != '') { |
|
713 | 713 | $all_data = simplexml_load_string($buffer); |
714 | 714 | foreach($all_data->children() as $childdata) { |
715 | 715 | $data = array(); |
@@ -730,10 +730,10 @@ discard block |
||
730 | 730 | $SI->add($data); |
731 | 731 | unset($data); |
732 | 732 | } |
733 | - } |
|
734 | - $Source->deleteOldLocationByType('gs'); |
|
735 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
736 | - if ($buffer != '') { |
|
733 | + } |
|
734 | + $Source->deleteOldLocationByType('gs'); |
|
735 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
736 | + if ($buffer != '') { |
|
737 | 737 | $all_data = simplexml_load_string($buffer); |
738 | 738 | foreach($all_data->children() as $childdata) { |
739 | 739 | $data = array(); |
@@ -750,249 +750,249 @@ discard block |
||
750 | 750 | } |
751 | 751 | unset($data); |
752 | 752 | } |
753 | - } |
|
754 | - $last_exec[$id]['last'] = time(); |
|
753 | + } |
|
754 | + $last_exec[$id]['last'] = time(); |
|
755 | 755 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
756 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
757 | - if ($buffer != '') { |
|
758 | - $all_data = json_decode($buffer,true); |
|
759 | - if (isset($all_data['acList'])) { |
|
756 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
757 | + if ($buffer != '') { |
|
758 | + $all_data = json_decode($buffer,true); |
|
759 | + if (isset($all_data['acList'])) { |
|
760 | 760 | $reset = 0; |
761 | 761 | foreach ($all_data['acList'] as $line) { |
762 | - $data = array(); |
|
763 | - $data['hex'] = $line['Icao']; // hex |
|
764 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
765 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
766 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
767 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
768 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
769 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
770 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
771 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
772 | - $data['emergency'] = ''; // emergency |
|
773 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
762 | + $data = array(); |
|
763 | + $data['hex'] = $line['Icao']; // hex |
|
764 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
765 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
766 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
767 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
768 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
769 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
770 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
771 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
772 | + $data['emergency'] = ''; // emergency |
|
773 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
774 | 774 | |
775 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
776 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
775 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
776 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
777 | 777 | |
778 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
779 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
780 | - $data['format_source'] = 'aircraftlistjson'; |
|
781 | - $data['id_source'] = $id_source; |
|
782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
783 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
784 | - if (isset($data['latitude'])) $SI->add($data); |
|
785 | - unset($data); |
|
778 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
779 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
780 | + $data['format_source'] = 'aircraftlistjson'; |
|
781 | + $data['id_source'] = $id_source; |
|
782 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
783 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
784 | + if (isset($data['latitude'])) $SI->add($data); |
|
785 | + unset($data); |
|
786 | 786 | } |
787 | - } elseif (is_array($all_data)) { |
|
787 | + } elseif (is_array($all_data)) { |
|
788 | 788 | $reset = 0; |
789 | 789 | foreach ($all_data as $line) { |
790 | - $data = array(); |
|
791 | - $data['hex'] = $line['hex']; // hex |
|
792 | - $data['ident'] = $line['flight']; // ident |
|
793 | - $data['altitude'] = $line['altitude']; // altitude |
|
794 | - $data['speed'] = $line['speed']; // speed |
|
795 | - $data['heading'] = $line['track']; // heading |
|
796 | - $data['latitude'] = $line['lat']; // lat |
|
797 | - $data['longitude'] = $line['lon']; // long |
|
798 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
799 | - $data['squawk'] = $line['squawk']; // squawk |
|
800 | - $data['emergency'] = ''; // emergency |
|
801 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
802 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
803 | - $data['format_source'] = 'aircraftlistjson'; |
|
804 | - $data['id_source'] = $id_source; |
|
805 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
806 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
807 | - $SI->add($data); |
|
808 | - unset($data); |
|
790 | + $data = array(); |
|
791 | + $data['hex'] = $line['hex']; // hex |
|
792 | + $data['ident'] = $line['flight']; // ident |
|
793 | + $data['altitude'] = $line['altitude']; // altitude |
|
794 | + $data['speed'] = $line['speed']; // speed |
|
795 | + $data['heading'] = $line['track']; // heading |
|
796 | + $data['latitude'] = $line['lat']; // lat |
|
797 | + $data['longitude'] = $line['lon']; // long |
|
798 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
799 | + $data['squawk'] = $line['squawk']; // squawk |
|
800 | + $data['emergency'] = ''; // emergency |
|
801 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
802 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
803 | + $data['format_source'] = 'aircraftlistjson'; |
|
804 | + $data['id_source'] = $id_source; |
|
805 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
806 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
807 | + $SI->add($data); |
|
808 | + unset($data); |
|
809 | + } |
|
809 | 810 | } |
810 | - } |
|
811 | - } |
|
812 | - //$last_exec['aircraftlistjson'] = time(); |
|
813 | - $last_exec[$id]['last'] = time(); |
|
814 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
815 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
816 | - $buffer = $Common->getData($value['host']); |
|
817 | - $all_data = json_decode($buffer,true); |
|
818 | - if (isset($all_data['planes'])) { |
|
811 | + } |
|
812 | + //$last_exec['aircraftlistjson'] = time(); |
|
813 | + $last_exec[$id]['last'] = time(); |
|
814 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
815 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
816 | + $buffer = $Common->getData($value['host']); |
|
817 | + $all_data = json_decode($buffer,true); |
|
818 | + if (isset($all_data['planes'])) { |
|
819 | 819 | $reset = 0; |
820 | 820 | foreach ($all_data['planes'] as $key => $line) { |
821 | - $data = array(); |
|
822 | - $data['hex'] = $key; // hex |
|
823 | - $data['ident'] = $line[3]; // ident |
|
824 | - $data['altitude'] = $line[6]; // altitude |
|
825 | - $data['speed'] = $line[8]; // speed |
|
826 | - $data['heading'] = $line[7]; // heading |
|
827 | - $data['latitude'] = $line[4]; // lat |
|
828 | - $data['longitude'] = $line[5]; // long |
|
829 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
830 | - $data['squawk'] = $line[10]; // squawk |
|
831 | - $data['emergency'] = ''; // emergency |
|
832 | - $data['registration'] = $line[2]; |
|
833 | - $data['aircraft_icao'] = $line[0]; |
|
834 | - $deparr = explode('-',$line[1]); |
|
835 | - if (count($deparr) == 2) { |
|
821 | + $data = array(); |
|
822 | + $data['hex'] = $key; // hex |
|
823 | + $data['ident'] = $line[3]; // ident |
|
824 | + $data['altitude'] = $line[6]; // altitude |
|
825 | + $data['speed'] = $line[8]; // speed |
|
826 | + $data['heading'] = $line[7]; // heading |
|
827 | + $data['latitude'] = $line[4]; // lat |
|
828 | + $data['longitude'] = $line[5]; // long |
|
829 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
830 | + $data['squawk'] = $line[10]; // squawk |
|
831 | + $data['emergency'] = ''; // emergency |
|
832 | + $data['registration'] = $line[2]; |
|
833 | + $data['aircraft_icao'] = $line[0]; |
|
834 | + $deparr = explode('-',$line[1]); |
|
835 | + if (count($deparr) == 2) { |
|
836 | 836 | $data['departure_airport_icao'] = $deparr[0]; |
837 | 837 | $data['arrival_airport_icao'] = $deparr[1]; |
838 | - } |
|
839 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
840 | - $data['format_source'] = 'planeupdatefaa'; |
|
841 | - $data['id_source'] = $id_source; |
|
842 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
843 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
844 | - $SI->add($data); |
|
845 | - unset($data); |
|
838 | + } |
|
839 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
840 | + $data['format_source'] = 'planeupdatefaa'; |
|
841 | + $data['id_source'] = $id_source; |
|
842 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
843 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
844 | + $SI->add($data); |
|
845 | + unset($data); |
|
846 | 846 | } |
847 | - } |
|
848 | - //$last_exec['planeupdatefaa'] = time(); |
|
849 | - $last_exec[$id]['last'] = time(); |
|
850 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
851 | - $buffer = $Common->getData($value['host']); |
|
852 | - $all_data = json_decode($buffer,true); |
|
853 | - if (isset($all_data['states'])) { |
|
847 | + } |
|
848 | + //$last_exec['planeupdatefaa'] = time(); |
|
849 | + $last_exec[$id]['last'] = time(); |
|
850 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
851 | + $buffer = $Common->getData($value['host']); |
|
852 | + $all_data = json_decode($buffer,true); |
|
853 | + if (isset($all_data['states'])) { |
|
854 | 854 | $reset = 0; |
855 | 855 | foreach ($all_data['states'] as $key => $line) { |
856 | - $data = array(); |
|
857 | - $data['hex'] = $line[0]; // hex |
|
858 | - $data['ident'] = trim($line[1]); // ident |
|
859 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
860 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
861 | - $data['heading'] = round($line[10]); // heading |
|
862 | - $data['latitude'] = $line[6]; // lat |
|
863 | - $data['longitude'] = $line[5]; // long |
|
864 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
865 | - //$data['squawk'] = $line[10]; // squawk |
|
866 | - //$data['emergency'] = ''; // emergency |
|
867 | - //$data['registration'] = $line[2]; |
|
868 | - //$data['aircraft_icao'] = $line[0]; |
|
869 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
870 | - $data['format_source'] = 'opensky'; |
|
871 | - $data['id_source'] = $id_source; |
|
872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
873 | - $SI->add($data); |
|
874 | - unset($data); |
|
856 | + $data = array(); |
|
857 | + $data['hex'] = $line[0]; // hex |
|
858 | + $data['ident'] = trim($line[1]); // ident |
|
859 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
860 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
861 | + $data['heading'] = round($line[10]); // heading |
|
862 | + $data['latitude'] = $line[6]; // lat |
|
863 | + $data['longitude'] = $line[5]; // long |
|
864 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
865 | + //$data['squawk'] = $line[10]; // squawk |
|
866 | + //$data['emergency'] = ''; // emergency |
|
867 | + //$data['registration'] = $line[2]; |
|
868 | + //$data['aircraft_icao'] = $line[0]; |
|
869 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
870 | + $data['format_source'] = 'opensky'; |
|
871 | + $data['id_source'] = $id_source; |
|
872 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
873 | + $SI->add($data); |
|
874 | + unset($data); |
|
875 | + } |
|
875 | 876 | } |
876 | - } |
|
877 | - //$last_exec['planeupdatefaa'] = time(); |
|
878 | - $last_exec[$id]['last'] = time(); |
|
879 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
880 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
881 | - //$buffer = $Common->getData($hosts[$id]); |
|
882 | - $buffer = $Common->getData($value['host']); |
|
883 | - $all_data = json_decode($buffer,true); |
|
884 | - if (!empty($all_data)) $reset = 0; |
|
885 | - foreach ($all_data as $key => $line) { |
|
877 | + //$last_exec['planeupdatefaa'] = time(); |
|
878 | + $last_exec[$id]['last'] = time(); |
|
879 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
880 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
881 | + //$buffer = $Common->getData($hosts[$id]); |
|
882 | + $buffer = $Common->getData($value['host']); |
|
883 | + $all_data = json_decode($buffer,true); |
|
884 | + if (!empty($all_data)) $reset = 0; |
|
885 | + foreach ($all_data as $key => $line) { |
|
886 | 886 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
887 | - $data = array(); |
|
888 | - $data['hex'] = $line[0]; |
|
889 | - $data['ident'] = $line[16]; //$line[13] |
|
890 | - $data['altitude'] = $line[4]; // altitude |
|
891 | - $data['speed'] = $line[5]; // speed |
|
892 | - $data['heading'] = $line[3]; // heading |
|
893 | - $data['latitude'] = $line[1]; // lat |
|
894 | - $data['longitude'] = $line[2]; // long |
|
895 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
896 | - $data['squawk'] = $line[6]; // squawk |
|
897 | - $data['aircraft_icao'] = $line[8]; |
|
898 | - $data['registration'] = $line[9]; |
|
899 | - $data['departure_airport_iata'] = $line[11]; |
|
900 | - $data['arrival_airport_iata'] = $line[12]; |
|
901 | - $data['emergency'] = ''; // emergency |
|
902 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
903 | - $data['format_source'] = 'fr24json'; |
|
904 | - $data['id_source'] = $id_source; |
|
905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
907 | - $SI->add($data); |
|
908 | - unset($data); |
|
887 | + $data = array(); |
|
888 | + $data['hex'] = $line[0]; |
|
889 | + $data['ident'] = $line[16]; //$line[13] |
|
890 | + $data['altitude'] = $line[4]; // altitude |
|
891 | + $data['speed'] = $line[5]; // speed |
|
892 | + $data['heading'] = $line[3]; // heading |
|
893 | + $data['latitude'] = $line[1]; // lat |
|
894 | + $data['longitude'] = $line[2]; // long |
|
895 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
896 | + $data['squawk'] = $line[6]; // squawk |
|
897 | + $data['aircraft_icao'] = $line[8]; |
|
898 | + $data['registration'] = $line[9]; |
|
899 | + $data['departure_airport_iata'] = $line[11]; |
|
900 | + $data['arrival_airport_iata'] = $line[12]; |
|
901 | + $data['emergency'] = ''; // emergency |
|
902 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
903 | + $data['format_source'] = 'fr24json'; |
|
904 | + $data['id_source'] = $id_source; |
|
905 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
906 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
907 | + $SI->add($data); |
|
908 | + unset($data); |
|
909 | 909 | } |
910 | - } |
|
911 | - //$last_exec['fr24json'] = time(); |
|
912 | - $last_exec[$id]['last'] = time(); |
|
913 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
914 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
915 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
916 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
917 | - //echo $buffer; |
|
918 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
919 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
920 | - $all_data = json_decode($buffer,true); |
|
921 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
910 | + } |
|
911 | + //$last_exec['fr24json'] = time(); |
|
912 | + $last_exec[$id]['last'] = time(); |
|
913 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
914 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
915 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
916 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
917 | + //echo $buffer; |
|
918 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
919 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
920 | + $all_data = json_decode($buffer,true); |
|
921 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
922 | 922 | die(json_last_error_msg()); |
923 | - } |
|
924 | - if (isset($all_data['mrkrs'])) { |
|
923 | + } |
|
924 | + if (isset($all_data['mrkrs'])) { |
|
925 | 925 | $reset = 0; |
926 | 926 | foreach ($all_data['mrkrs'] as $key => $line) { |
927 | - if (isset($line['inf'])) { |
|
927 | + if (isset($line['inf'])) { |
|
928 | 928 | $data = array(); |
929 | 929 | $data['hex'] = $line['inf']['ia']; |
930 | 930 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
931 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
932 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
933 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
934 | - $data['latitude'] = $line['pt'][0]; // lat |
|
935 | - $data['longitude'] = $line['pt'][1]; // long |
|
936 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
937 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
938 | - //$data['aircraft_icao'] = $line[8]; |
|
939 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
931 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
932 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
933 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
934 | + $data['latitude'] = $line['pt'][0]; // lat |
|
935 | + $data['longitude'] = $line['pt'][1]; // long |
|
936 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
937 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
938 | + //$data['aircraft_icao'] = $line[8]; |
|
939 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
940 | 940 | //$data['departure_airport_iata'] = $line[11]; |
941 | 941 | //$data['arrival_airport_iata'] = $line[12]; |
942 | - //$data['emergency'] = ''; // emergency |
|
942 | + //$data['emergency'] = ''; // emergency |
|
943 | 943 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
944 | - $data['format_source'] = 'radarvirtueljson'; |
|
945 | - $data['id_source'] = $id_source; |
|
944 | + $data['format_source'] = 'radarvirtueljson'; |
|
945 | + $data['id_source'] = $id_source; |
|
946 | 946 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
947 | 947 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
948 | 948 | $SI->add($data); |
949 | 949 | unset($data); |
950 | - } |
|
950 | + } |
|
951 | + } |
|
951 | 952 | } |
952 | - } |
|
953 | - //$last_exec['radarvirtueljson'] = time(); |
|
954 | - $last_exec[$id]['last'] = time(); |
|
955 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
956 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
957 | - //$buffer = $Common->getData($hosts[$id]); |
|
958 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
959 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
953 | + //$last_exec['radarvirtueljson'] = time(); |
|
954 | + $last_exec[$id]['last'] = time(); |
|
955 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
956 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
957 | + //$buffer = $Common->getData($hosts[$id]); |
|
958 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
959 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
960 | 960 | |
961 | - if (isset($all_data['pireps'])) { |
|
961 | + if (isset($all_data['pireps'])) { |
|
962 | 962 | $reset = 0; |
963 | - foreach ($all_data['pireps'] as $line) { |
|
964 | - $data = array(); |
|
965 | - $data['id'] = $line['id']; |
|
966 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
967 | - $data['ident'] = $line['callsign']; // ident |
|
968 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
969 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
970 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
971 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
972 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
973 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
974 | - $data['latitude'] = $line['lat']; // lat |
|
975 | - $data['longitude'] = $line['lon']; // long |
|
976 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
977 | - //$data['squawk'] = $line['squawk']; // squawk |
|
978 | - //$data['emergency'] = ''; // emergency |
|
979 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
980 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
981 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
982 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
983 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
984 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
985 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
986 | - else $data['info'] = ''; |
|
987 | - $data['format_source'] = 'pireps'; |
|
988 | - $data['id_source'] = $id_source; |
|
989 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
990 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
991 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
992 | - if ($line['icon'] == 'plane') { |
|
963 | + foreach ($all_data['pireps'] as $line) { |
|
964 | + $data = array(); |
|
965 | + $data['id'] = $line['id']; |
|
966 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
967 | + $data['ident'] = $line['callsign']; // ident |
|
968 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
969 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
970 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
971 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
972 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
973 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
974 | + $data['latitude'] = $line['lat']; // lat |
|
975 | + $data['longitude'] = $line['lon']; // long |
|
976 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
977 | + //$data['squawk'] = $line['squawk']; // squawk |
|
978 | + //$data['emergency'] = ''; // emergency |
|
979 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
980 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
981 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
982 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
983 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
984 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
985 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
986 | + else $data['info'] = ''; |
|
987 | + $data['format_source'] = 'pireps'; |
|
988 | + $data['id_source'] = $id_source; |
|
989 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
990 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
991 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
992 | + if ($line['icon'] == 'plane') { |
|
993 | 993 | $SI->add($data); |
994 | - // print_r($data); |
|
995 | - } elseif ($line['icon'] == 'ct') { |
|
994 | + // print_r($data); |
|
995 | + } elseif ($line['icon'] == 'ct') { |
|
996 | 996 | $data['info'] = str_replace('^§','<br />',$data['info']); |
997 | 997 | $data['info'] = str_replace('&sect;','',$data['info']); |
998 | 998 | $typec = substr($data['ident'],-3); |
@@ -1007,203 +1007,203 @@ discard block |
||
1007 | 1007 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1008 | 1008 | else $data['type'] = 'Observer'; |
1009 | 1009 | 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']); |
1010 | - } |
|
1011 | - unset($data); |
|
1010 | + } |
|
1011 | + unset($data); |
|
1012 | + } |
|
1012 | 1013 | } |
1013 | - } |
|
1014 | - //$last_exec['pirepsjson'] = time(); |
|
1015 | - $last_exec[$id]['last'] = time(); |
|
1016 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1017 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1018 | - //$buffer = $Common->getData($hosts[$id]); |
|
1019 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1020 | - $buffer = $Common->getData($value['host']); |
|
1021 | - $all_data = json_decode($buffer,true); |
|
1022 | - if ($buffer != '' && is_array($all_data)) { |
|
1014 | + //$last_exec['pirepsjson'] = time(); |
|
1015 | + $last_exec[$id]['last'] = time(); |
|
1016 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1017 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1018 | + //$buffer = $Common->getData($hosts[$id]); |
|
1019 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1020 | + $buffer = $Common->getData($value['host']); |
|
1021 | + $all_data = json_decode($buffer,true); |
|
1022 | + if ($buffer != '' && is_array($all_data)) { |
|
1023 | 1023 | $reset = 0; |
1024 | 1024 | foreach ($all_data as $line) { |
1025 | - $data = array(); |
|
1026 | - //$data['id'] = $line['id']; // id not usable |
|
1027 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1028 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1029 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1030 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1031 | - $data['ident'] = $line['flightnum']; // ident |
|
1032 | - $data['altitude'] = $line['alt']; // altitude |
|
1033 | - $data['speed'] = $line['gs']; // speed |
|
1034 | - $data['heading'] = $line['heading']; // heading |
|
1035 | - $data['latitude'] = $line['lat']; // lat |
|
1036 | - $data['longitude'] = $line['lng']; // long |
|
1037 | - $data['verticalrate'] = ''; // verticale rate |
|
1038 | - $data['squawk'] = ''; // squawk |
|
1039 | - $data['emergency'] = ''; // emergency |
|
1040 | - //$data['datetime'] = $line['lastupdate']; |
|
1041 | - //$data['last_update'] = $line['lastupdate']; |
|
1042 | - if (isset($value['timezone'])) { |
|
1043 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1044 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1045 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1046 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1047 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1048 | - $data['departure_airport_time'] = $line['deptime']; |
|
1049 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1050 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1051 | - $data['registration'] = $line['aircraft']; |
|
1052 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1053 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1054 | - if (isset($line['aircraftname'])) { |
|
1025 | + $data = array(); |
|
1026 | + //$data['id'] = $line['id']; // id not usable |
|
1027 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1028 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1029 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1030 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1031 | + $data['ident'] = $line['flightnum']; // ident |
|
1032 | + $data['altitude'] = $line['alt']; // altitude |
|
1033 | + $data['speed'] = $line['gs']; // speed |
|
1034 | + $data['heading'] = $line['heading']; // heading |
|
1035 | + $data['latitude'] = $line['lat']; // lat |
|
1036 | + $data['longitude'] = $line['lng']; // long |
|
1037 | + $data['verticalrate'] = ''; // verticale rate |
|
1038 | + $data['squawk'] = ''; // squawk |
|
1039 | + $data['emergency'] = ''; // emergency |
|
1040 | + //$data['datetime'] = $line['lastupdate']; |
|
1041 | + //$data['last_update'] = $line['lastupdate']; |
|
1042 | + if (isset($value['timezone'])) { |
|
1043 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1044 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1045 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1046 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1047 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1048 | + $data['departure_airport_time'] = $line['deptime']; |
|
1049 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1050 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1051 | + $data['registration'] = $line['aircraft']; |
|
1052 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1053 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1054 | + if (isset($line['aircraftname'])) { |
|
1055 | 1055 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1056 | 1056 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1057 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1058 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1059 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1060 | - else { |
|
1061 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1062 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1063 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1064 | - } |
|
1065 | - } |
|
1066 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1067 | - $data['id_source'] = $id_source; |
|
1068 | - $data['format_source'] = 'phpvmacars'; |
|
1069 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1070 | - $SI->add($data); |
|
1071 | - unset($data); |
|
1057 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1058 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1059 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1060 | + else { |
|
1061 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1062 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1063 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1064 | + } |
|
1065 | + } |
|
1066 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1067 | + $data['id_source'] = $id_source; |
|
1068 | + $data['format_source'] = 'phpvmacars'; |
|
1069 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1070 | + $SI->add($data); |
|
1071 | + unset($data); |
|
1072 | 1072 | } |
1073 | 1073 | if ($globalDebug) echo 'No more data...'."\n"; |
1074 | 1074 | unset($buffer); |
1075 | 1075 | unset($all_data); |
1076 | - } |
|
1077 | - //$last_exec['phpvmacars'] = time(); |
|
1078 | - $last_exec[$id]['last'] = time(); |
|
1079 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1080 | - //$buffer = $Common->getData($hosts[$id]); |
|
1081 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1082 | - $buffer = $Common->getData($value['host']); |
|
1083 | - $all_data = json_decode($buffer,true); |
|
1084 | - if ($buffer != '' && is_array($all_data)) { |
|
1076 | + } |
|
1077 | + //$last_exec['phpvmacars'] = time(); |
|
1078 | + $last_exec[$id]['last'] = time(); |
|
1079 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1080 | + //$buffer = $Common->getData($hosts[$id]); |
|
1081 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1082 | + $buffer = $Common->getData($value['host']); |
|
1083 | + $all_data = json_decode($buffer,true); |
|
1084 | + if ($buffer != '' && is_array($all_data)) { |
|
1085 | 1085 | $reset = 0; |
1086 | 1086 | foreach ($all_data as $line) { |
1087 | - $data = array(); |
|
1088 | - //$data['id'] = $line['id']; // id not usable |
|
1089 | - $data['id'] = trim($line['flight_id']); |
|
1090 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1091 | - $data['pilot_name'] = $line['pilot_name']; |
|
1092 | - $data['pilot_id'] = $line['pilot_id']; |
|
1093 | - $data['ident'] = trim($line['callsign']); // ident |
|
1094 | - $data['altitude'] = $line['altitude']; // altitude |
|
1095 | - $data['speed'] = $line['gs']; // speed |
|
1096 | - $data['heading'] = $line['heading']; // heading |
|
1097 | - $data['latitude'] = $line['latitude']; // lat |
|
1098 | - $data['longitude'] = $line['longitude']; // long |
|
1099 | - $data['verticalrate'] = ''; // verticale rate |
|
1100 | - $data['squawk'] = ''; // squawk |
|
1101 | - $data['emergency'] = ''; // emergency |
|
1102 | - //$data['datetime'] = $line['lastupdate']; |
|
1103 | - $data['last_update'] = $line['last_update']; |
|
1104 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1105 | - $data['departure_airport_icao'] = $line['departure']; |
|
1106 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1107 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1108 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1109 | - //$data['registration'] = $line['aircraft']; |
|
1110 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1111 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1112 | - $data['id_source'] = $id_source; |
|
1113 | - $data['format_source'] = 'vam'; |
|
1114 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1115 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1116 | - $SI->add($data); |
|
1117 | - unset($data); |
|
1087 | + $data = array(); |
|
1088 | + //$data['id'] = $line['id']; // id not usable |
|
1089 | + $data['id'] = trim($line['flight_id']); |
|
1090 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1091 | + $data['pilot_name'] = $line['pilot_name']; |
|
1092 | + $data['pilot_id'] = $line['pilot_id']; |
|
1093 | + $data['ident'] = trim($line['callsign']); // ident |
|
1094 | + $data['altitude'] = $line['altitude']; // altitude |
|
1095 | + $data['speed'] = $line['gs']; // speed |
|
1096 | + $data['heading'] = $line['heading']; // heading |
|
1097 | + $data['latitude'] = $line['latitude']; // lat |
|
1098 | + $data['longitude'] = $line['longitude']; // long |
|
1099 | + $data['verticalrate'] = ''; // verticale rate |
|
1100 | + $data['squawk'] = ''; // squawk |
|
1101 | + $data['emergency'] = ''; // emergency |
|
1102 | + //$data['datetime'] = $line['lastupdate']; |
|
1103 | + $data['last_update'] = $line['last_update']; |
|
1104 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1105 | + $data['departure_airport_icao'] = $line['departure']; |
|
1106 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1107 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1108 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1109 | + //$data['registration'] = $line['aircraft']; |
|
1110 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1111 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1112 | + $data['id_source'] = $id_source; |
|
1113 | + $data['format_source'] = 'vam'; |
|
1114 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1115 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1116 | + $SI->add($data); |
|
1117 | + unset($data); |
|
1118 | 1118 | } |
1119 | 1119 | if ($globalDebug) echo 'No more data...'."\n"; |
1120 | 1120 | unset($buffer); |
1121 | 1121 | unset($all_data); |
1122 | - } |
|
1123 | - //$last_exec['phpvmacars'] = time(); |
|
1124 | - $last_exec[$id]['last'] = time(); |
|
1122 | + } |
|
1123 | + //$last_exec['phpvmacars'] = time(); |
|
1124 | + $last_exec[$id]['last'] = time(); |
|
1125 | 1125 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1126 | 1126 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1127 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1128 | - //$last_exec[$id]['last'] = time(); |
|
1127 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1128 | + //$last_exec[$id]['last'] = time(); |
|
1129 | 1129 | |
1130 | - //$read = array( $sockets[$id] ); |
|
1131 | - $read = $sockets; |
|
1132 | - $write = NULL; |
|
1133 | - $e = NULL; |
|
1134 | - $n = socket_select($read, $write, $e, $timeout); |
|
1135 | - if ($e != NULL) var_dump($e); |
|
1136 | - if ($n > 0) { |
|
1130 | + //$read = array( $sockets[$id] ); |
|
1131 | + $read = $sockets; |
|
1132 | + $write = NULL; |
|
1133 | + $e = NULL; |
|
1134 | + $n = socket_select($read, $write, $e, $timeout); |
|
1135 | + if ($e != NULL) var_dump($e); |
|
1136 | + if ($n > 0) { |
|
1137 | 1137 | $reset = 0; |
1138 | 1138 | foreach ($read as $nb => $r) { |
1139 | - //$value = $formats[$nb]; |
|
1140 | - $format = $globalSources[$nb]['format']; |
|
1141 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1139 | + //$value = $formats[$nb]; |
|
1140 | + $format = $globalSources[$nb]['format']; |
|
1141 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1142 | 1142 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1143 | - } elseif ($format == 'vrstcp') { |
|
1143 | + } elseif ($format == 'vrstcp') { |
|
1144 | 1144 | $buffer = @socket_read($r, 6000); |
1145 | - } else { |
|
1145 | + } else { |
|
1146 | 1146 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1147 | - } |
|
1148 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1149 | - //echo $buffer."\n"; |
|
1150 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1151 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1152 | - $error = false; |
|
1153 | - //$SI::del(); |
|
1154 | - if ($format == 'vrstcp') { |
|
1147 | + } |
|
1148 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1149 | + //echo $buffer."\n"; |
|
1150 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1151 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1152 | + $error = false; |
|
1153 | + //$SI::del(); |
|
1154 | + if ($format == 'vrstcp') { |
|
1155 | 1155 | $buffer = explode('},{',$buffer); |
1156 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1157 | - // SBS format is CSV format |
|
1158 | - if ($buffer !== FALSE && $buffer != '') { |
|
1156 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1157 | + // SBS format is CSV format |
|
1158 | + if ($buffer !== FALSE && $buffer != '') { |
|
1159 | 1159 | $tt[$format] = 0; |
1160 | 1160 | if ($format == 'acarssbs3') { |
1161 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1162 | - $ACARS->add(trim($buffer)); |
|
1163 | - $ACARS->deleteLiveAcarsData(); |
|
1161 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1162 | + $ACARS->add(trim($buffer)); |
|
1163 | + $ACARS->deleteLiveAcarsData(); |
|
1164 | 1164 | } elseif ($format == 'raw') { |
1165 | - // AVR format |
|
1166 | - $data = $SBS->parse($buffer); |
|
1167 | - if (is_array($data)) { |
|
1165 | + // AVR format |
|
1166 | + $data = $SBS->parse($buffer); |
|
1167 | + if (is_array($data)) { |
|
1168 | 1168 | $data['datetime'] = date('Y-m-d H:i:s'); |
1169 | 1169 | $data['format_source'] = 'raw'; |
1170 | 1170 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1171 | 1171 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1172 | 1172 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1173 | 1173 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1174 | - } |
|
1174 | + } |
|
1175 | 1175 | } elseif ($format == 'ais') { |
1176 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1177 | - $data = array(); |
|
1178 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1179 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1180 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1181 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1182 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1183 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1184 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1185 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1186 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1187 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1188 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1189 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1190 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1191 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1192 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1193 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1176 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1177 | + $data = array(); |
|
1178 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1179 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1180 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1181 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1182 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1183 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1184 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1185 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1186 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1187 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1188 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1189 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1190 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1191 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1192 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1193 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1194 | 1194 | |
1195 | - if (isset($ais_data['timestamp'])) { |
|
1195 | + if (isset($ais_data['timestamp'])) { |
|
1196 | 1196 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1197 | - } else { |
|
1197 | + } else { |
|
1198 | 1198 | $data['datetime'] = date('Y-m-d H:i:s'); |
1199 | - } |
|
1200 | - $data['format_source'] = 'aisnmea'; |
|
1201 | - $data['id_source'] = $id_source; |
|
1202 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1203 | - unset($data); |
|
1204 | - } elseif ($format == 'flightgearsp') { |
|
1205 | - //echo $buffer."\n"; |
|
1206 | - if (strlen($buffer) > 5) { |
|
1199 | + } |
|
1200 | + $data['format_source'] = 'aisnmea'; |
|
1201 | + $data['id_source'] = $id_source; |
|
1202 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1203 | + unset($data); |
|
1204 | + } elseif ($format == 'flightgearsp') { |
|
1205 | + //echo $buffer."\n"; |
|
1206 | + if (strlen($buffer) > 5) { |
|
1207 | 1207 | $line = explode(',',$buffer); |
1208 | 1208 | $data = array(); |
1209 | 1209 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1220,38 +1220,38 @@ discard block |
||
1220 | 1220 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1221 | 1221 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1222 | 1222 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1223 | - } |
|
1224 | - } elseif ($format == 'acars') { |
|
1225 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1226 | - $ACARS->add(trim($buffer)); |
|
1227 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1228 | - $ACARS->deleteLiveAcarsData(); |
|
1223 | + } |
|
1224 | + } elseif ($format == 'acars') { |
|
1225 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1226 | + $ACARS->add(trim($buffer)); |
|
1227 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1228 | + $ACARS->deleteLiveAcarsData(); |
|
1229 | 1229 | } elseif ($format == 'flightgearmp') { |
1230 | - if (substr($buffer,0,1) != '#') { |
|
1230 | + if (substr($buffer,0,1) != '#') { |
|
1231 | 1231 | $data = array(); |
1232 | 1232 | //echo $buffer."\n"; |
1233 | 1233 | $line = explode(' ',$buffer); |
1234 | 1234 | if (count($line) == 11) { |
1235 | - $userserver = explode('@',$line[0]); |
|
1236 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1237 | - $data['ident'] = $userserver[0]; |
|
1238 | - $data['registration'] = $userserver[0]; |
|
1239 | - $data['latitude'] = $line[4]; |
|
1240 | - $data['longitude'] = $line[5]; |
|
1241 | - $data['altitude'] = $line[6]; |
|
1242 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1243 | - $aircraft_type = $line[10]; |
|
1244 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1245 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1246 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1247 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1235 | + $userserver = explode('@',$line[0]); |
|
1236 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1237 | + $data['ident'] = $userserver[0]; |
|
1238 | + $data['registration'] = $userserver[0]; |
|
1239 | + $data['latitude'] = $line[4]; |
|
1240 | + $data['longitude'] = $line[5]; |
|
1241 | + $data['altitude'] = $line[6]; |
|
1242 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1243 | + $aircraft_type = $line[10]; |
|
1244 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1245 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1246 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1247 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1248 | + } |
|
1248 | 1249 | } |
1249 | - } |
|
1250 | 1250 | } elseif ($format == 'beast') { |
1251 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1252 | - die; |
|
1251 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1252 | + die; |
|
1253 | 1253 | } elseif ($format == 'vrstcp') { |
1254 | - foreach($buffer as $all_data) { |
|
1254 | + foreach($buffer as $all_data) { |
|
1255 | 1255 | $line = json_decode('{'.$all_data.'}',true); |
1256 | 1256 | $data = array(); |
1257 | 1257 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1271,114 +1271,114 @@ discard block |
||
1271 | 1271 | */ |
1272 | 1272 | $data['datetime'] = date('Y-m-d H:i:s'); |
1273 | 1273 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1274 | - $data['format_source'] = 'vrstcp'; |
|
1274 | + $data['format_source'] = 'vrstcp'; |
|
1275 | 1275 | $data['id_source'] = $id_source; |
1276 | 1276 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1277 | 1277 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1278 | 1278 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1279 | 1279 | unset($data); |
1280 | - } |
|
1280 | + } |
|
1281 | 1281 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1282 | - $line = explode("\t", $buffer); |
|
1283 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1282 | + $line = explode("\t", $buffer); |
|
1283 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1284 | 1284 | $key = $line[$k]; |
1285 | - $lined[$key] = $line[$k+1]; |
|
1286 | - } |
|
1287 | - if (count($lined) > 3) { |
|
1288 | - $data['hex'] = $lined['hexid']; |
|
1289 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1290 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1291 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1292 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1293 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1294 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1295 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1296 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1297 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1298 | - $data['id_source'] = $id_source; |
|
1299 | - $data['format_source'] = 'tsv'; |
|
1300 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1301 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1285 | + $lined[$key] = $line[$k+1]; |
|
1286 | + } |
|
1287 | + if (count($lined) > 3) { |
|
1288 | + $data['hex'] = $lined['hexid']; |
|
1289 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1290 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1291 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1292 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1293 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1294 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1295 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1296 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1297 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1298 | + $data['id_source'] = $id_source; |
|
1299 | + $data['format_source'] = 'tsv'; |
|
1300 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1301 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1302 | 1302 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1303 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1304 | - unset($lined); |
|
1305 | - unset($data); |
|
1306 | - } else $error = true; |
|
1303 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1304 | + unset($lined); |
|
1305 | + unset($data); |
|
1306 | + } else $error = true; |
|
1307 | 1307 | } elseif ($format == 'aprs' && $use_aprs) { |
1308 | - if ($aprs_connect == 0) { |
|
1308 | + if ($aprs_connect == 0) { |
|
1309 | 1309 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1310 | 1310 | $aprs_connect = 1; |
1311 | - } |
|
1311 | + } |
|
1312 | 1312 | |
1313 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1313 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1314 | 1314 | $aprs_last_tx = time(); |
1315 | 1315 | $data_aprs = "# Keep alive"; |
1316 | 1316 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1317 | - } |
|
1317 | + } |
|
1318 | 1318 | |
1319 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1320 | - //echo 'APRS data : '.$buffer."\n"; |
|
1321 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1322 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1323 | - //echo $buffer."\n"; |
|
1324 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1319 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1320 | + //echo 'APRS data : '.$buffer."\n"; |
|
1321 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1322 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1323 | + //echo $buffer."\n"; |
|
1324 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1325 | 1325 | $line = $APRS->parse($buffer); |
1326 | 1326 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1327 | 1327 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1328 | - $aprs_last_tx = time(); |
|
1329 | - $data = array(); |
|
1330 | - //print_r($line); |
|
1331 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1332 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1333 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1334 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1335 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1336 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1337 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1338 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1339 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1340 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1341 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1342 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1343 | - $data['latitude'] = $line['latitude']; |
|
1344 | - $data['longitude'] = $line['longitude']; |
|
1345 | - //$data['verticalrate'] = $line[16]; |
|
1346 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1347 | - //else $data['speed'] = 0; |
|
1348 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1349 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1350 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1351 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1352 | - //else $data['heading'] = 0; |
|
1353 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1354 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1355 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1356 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1357 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1358 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1359 | - $data['id_source'] = $id_source; |
|
1360 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1361 | - else $data['format_source'] = 'aprs'; |
|
1362 | - $data['source_name'] = $line['source']; |
|
1363 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1364 | - else $data['source_type'] = 'flarm'; |
|
1365 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1366 | - $currentdate = date('Y-m-d H:i:s'); |
|
1367 | - $aprsdate = strtotime($data['datetime']); |
|
1368 | - // Accept data if time <= system time + 20s |
|
1369 | - //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'])))) { |
|
1370 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1328 | + $aprs_last_tx = time(); |
|
1329 | + $data = array(); |
|
1330 | + //print_r($line); |
|
1331 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1332 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1333 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1334 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1335 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1336 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1337 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1338 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1339 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1340 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1341 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1342 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1343 | + $data['latitude'] = $line['latitude']; |
|
1344 | + $data['longitude'] = $line['longitude']; |
|
1345 | + //$data['verticalrate'] = $line[16]; |
|
1346 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1347 | + //else $data['speed'] = 0; |
|
1348 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1349 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1350 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1351 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1352 | + //else $data['heading'] = 0; |
|
1353 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1354 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1355 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1356 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1357 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1358 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1359 | + $data['id_source'] = $id_source; |
|
1360 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1361 | + else $data['format_source'] = 'aprs'; |
|
1362 | + $data['source_name'] = $line['source']; |
|
1363 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1364 | + else $data['source_type'] = 'flarm'; |
|
1365 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1366 | + $currentdate = date('Y-m-d H:i:s'); |
|
1367 | + $aprsdate = strtotime($data['datetime']); |
|
1368 | + // Accept data if time <= system time + 20s |
|
1369 | + //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'])))) { |
|
1370 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1371 | 1371 | $send = $SI->add($data); |
1372 | - } elseif ($data['source_type'] == 'ais') { |
|
1372 | + } elseif ($data['source_type'] == 'ais') { |
|
1373 | 1373 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1374 | - } elseif (isset($line['stealth'])) { |
|
1374 | + } elseif (isset($line['stealth'])) { |
|
1375 | 1375 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1376 | 1376 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1377 | - //} 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')) { |
|
1378 | - } 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') { |
|
1377 | + //} 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')) { |
|
1378 | + } 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') { |
|
1379 | 1379 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1380 | 1380 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1381 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1381 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1382 | 1382 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1383 | 1383 | $Source->deleteOldLocationByType('gs'); |
1384 | 1384 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
@@ -1386,11 +1386,11 @@ discard block |
||
1386 | 1386 | } else { |
1387 | 1387 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1388 | 1388 | } |
1389 | - } else { |
|
1390 | - echo '/!\ Not added'."\n"; |
|
1391 | - print_r($line); |
|
1392 | - } |
|
1393 | - unset($data); |
|
1389 | + } else { |
|
1390 | + echo '/!\ Not added'."\n"; |
|
1391 | + print_r($line); |
|
1392 | + } |
|
1393 | + unset($data); |
|
1394 | 1394 | } |
1395 | 1395 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1396 | 1396 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1406,12 +1406,12 @@ discard block |
||
1406 | 1406 | */ |
1407 | 1407 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1408 | 1408 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1409 | - } |
|
1409 | + } |
|
1410 | 1410 | } else { |
1411 | - $line = explode(',', $buffer); |
|
1412 | - if (count($line) > 20) { |
|
1413 | - $data['hex'] = $line[4]; |
|
1414 | - /* |
|
1411 | + $line = explode(',', $buffer); |
|
1412 | + if (count($line) > 20) { |
|
1413 | + $data['hex'] = $line[4]; |
|
1414 | + /* |
|
1415 | 1415 | $data['datetime'] = $line[6].' '.$line[7]; |
1416 | 1416 | date_default_timezone_set($globalTimezone); |
1417 | 1417 | $datetime = new DateTime($data['datetime']); |
@@ -1419,30 +1419,30 @@ discard block |
||
1419 | 1419 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1420 | 1420 | date_default_timezone_set('UTC'); |
1421 | 1421 | */ |
1422 | - // Force datetime to current UTC datetime |
|
1423 | - date_default_timezone_set('UTC'); |
|
1424 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1425 | - $data['ident'] = trim($line[10]); |
|
1426 | - $data['latitude'] = $line[14]; |
|
1427 | - $data['longitude'] = $line[15]; |
|
1428 | - $data['verticalrate'] = $line[16]; |
|
1429 | - $data['emergency'] = $line[20]; |
|
1430 | - $data['speed'] = $line[12]; |
|
1431 | - $data['squawk'] = $line[17]; |
|
1432 | - $data['altitude'] = $line[11]; |
|
1433 | - $data['heading'] = $line[13]; |
|
1434 | - $data['ground'] = $line[21]; |
|
1435 | - $data['emergency'] = $line[19]; |
|
1436 | - $data['format_source'] = 'sbs'; |
|
1422 | + // Force datetime to current UTC datetime |
|
1423 | + date_default_timezone_set('UTC'); |
|
1424 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1425 | + $data['ident'] = trim($line[10]); |
|
1426 | + $data['latitude'] = $line[14]; |
|
1427 | + $data['longitude'] = $line[15]; |
|
1428 | + $data['verticalrate'] = $line[16]; |
|
1429 | + $data['emergency'] = $line[20]; |
|
1430 | + $data['speed'] = $line[12]; |
|
1431 | + $data['squawk'] = $line[17]; |
|
1432 | + $data['altitude'] = $line[11]; |
|
1433 | + $data['heading'] = $line[13]; |
|
1434 | + $data['ground'] = $line[21]; |
|
1435 | + $data['emergency'] = $line[19]; |
|
1436 | + $data['format_source'] = 'sbs'; |
|
1437 | 1437 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1438 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1438 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1439 | 1439 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1440 | - $data['id_source'] = $id_source; |
|
1441 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1442 | - else $error = true; |
|
1443 | - unset($data); |
|
1444 | - } else $error = true; |
|
1445 | - if ($error) { |
|
1440 | + $data['id_source'] = $id_source; |
|
1441 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1442 | + else $error = true; |
|
1443 | + unset($data); |
|
1444 | + } else $error = true; |
|
1445 | + if ($error) { |
|
1446 | 1446 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1447 | 1447 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1448 | 1448 | } else { |
@@ -1458,13 +1458,13 @@ discard block |
||
1458 | 1458 | connect_all($sourceer); |
1459 | 1459 | $sourceer = array(); |
1460 | 1460 | } |
1461 | - } |
|
1461 | + } |
|
1462 | 1462 | } |
1463 | 1463 | // Sleep for xxx microseconds |
1464 | 1464 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1465 | - } else { |
|
1465 | + } else { |
|
1466 | 1466 | if ($format == 'flightgearmp') { |
1467 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1467 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1468 | 1468 | //@socket_close($r); |
1469 | 1469 | sleep($globalMinFetch); |
1470 | 1470 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1473,9 +1473,9 @@ discard block |
||
1473 | 1473 | break; |
1474 | 1474 | |
1475 | 1475 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1476 | - if (isset($tt[$format])) $tt[$format]++; |
|
1477 | - else $tt[$format] = 0; |
|
1478 | - if ($tt[$format] > 30) { |
|
1476 | + if (isset($tt[$format])) $tt[$format]++; |
|
1477 | + else $tt[$format] = 0; |
|
1478 | + if ($tt[$format] > 30) { |
|
1479 | 1479 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1480 | 1480 | //@socket_close($r); |
1481 | 1481 | sleep(2); |
@@ -1486,23 +1486,23 @@ discard block |
||
1486 | 1486 | //connect_all($globalSources); |
1487 | 1487 | $tt[$format]=0; |
1488 | 1488 | break; |
1489 | - } |
|
1489 | + } |
|
1490 | + } |
|
1490 | 1491 | } |
1491 | - } |
|
1492 | 1492 | } |
1493 | - } else { |
|
1493 | + } else { |
|
1494 | 1494 | $error = socket_strerror(socket_last_error()); |
1495 | 1495 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1496 | 1496 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1497 | 1497 | if (isset($globalDebug)) echo "Restarting...\n"; |
1498 | 1498 | // Restart the script if possible |
1499 | 1499 | if (is_array($sockets)) { |
1500 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1500 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1501 | 1501 | |
1502 | - foreach ($sockets as $sock) { |
|
1502 | + foreach ($sockets as $sock) { |
|
1503 | 1503 | @socket_shutdown($sock,2); |
1504 | 1504 | @socket_close($sock); |
1505 | - } |
|
1505 | + } |
|
1506 | 1506 | |
1507 | 1507 | } |
1508 | 1508 | if ($globalDebug) echo "Waiting..."; |
@@ -1517,13 +1517,13 @@ discard block |
||
1517 | 1517 | if ($globalDebug) echo "Restart all connections..."; |
1518 | 1518 | connect_all($globalSources); |
1519 | 1519 | } |
1520 | - } |
|
1520 | + } |
|
1521 | 1521 | } |
1522 | 1522 | if ($globalDaemon === false) { |
1523 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1524 | - $SI->checkAll(); |
|
1523 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1524 | + $SI->checkAll(); |
|
1525 | + } |
|
1525 | 1526 | } |
1526 | - } |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | ?> |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | die; |
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
49 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | 57 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
59 | 59 | else $globalSources[] = array('host' => $options['s']); |
60 | 60 | } elseif (isset($options['source'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['source']); |
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; |
79 | - $SI=new SpotterServer(); |
|
79 | + $SI = new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
83 | 83 | $SI->connect(); |
84 | 84 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | +} else $SI = new SpotterImport($Connection->db); |
|
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | 88 | $AIS = new AIS(); |
89 | 89 | $MI = new MarineImport($Connection->db); |
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | -$SBS=new SBS(); |
|
93 | -$ACARS=new ACARS($Connection->db); |
|
94 | -$Source=new Source($Connection->db); |
|
95 | -$Common=new Common(); |
|
92 | +$SBS = new SBS(); |
|
93 | +$ACARS = new ACARS($Connection->db); |
|
94 | +$Source = new Source($Connection->db); |
|
95 | +$Common = new Common(); |
|
96 | 96 | date_default_timezone_set('UTC'); |
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | 101 | global $sockets; |
102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
103 | 103 | die("Bye!\n"); |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
117 | 117 | $reset++; |
118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
119 | 119 | foreach ($hosts as $id => $value) { |
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'deltadbtxt'; |
126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 127 | //$last_exec['deltadbtxt'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'vatsimtxt'; |
131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 132 | //$last_exec['vatsimtxt'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
139 | + } else if (preg_match('/opensky/i', $host)) { |
|
140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
157 | 157 | //$formats[$id] = 'planeupdatefaa'; |
158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 159 | //$last_exec['planeupdatefaa'] = 0; |
@@ -162,29 +162,29 @@ discard block |
||
162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 163 | exit(0); |
164 | 164 | } |
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'phpvmacars'; |
167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 168 | //$last_exec['phpvmacars'] = 0; |
169 | 169 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
170 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'phpvmacars'; |
172 | 172 | $globalSources[$id]['format'] = 'vam'; |
173 | 173 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
174 | + } else if (preg_match('/whazzup/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'whazzup'; |
176 | 176 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 177 | //$last_exec['whazzup'] = 0; |
178 | 178 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
179 | + } else if (preg_match('/airwhere/i', $host)) { |
|
180 | 180 | $globalSources[$id]['format'] = 'airwhere'; |
181 | 181 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
182 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
183 | 183 | //$formats[$id] = 'pirepsjson'; |
184 | 184 | $globalSources[$id]['format'] = 'pirepsjson'; |
185 | 185 | //$last_exec['pirepsjson'] = 0; |
186 | 186 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
188 | 188 | //$formats[$id] = 'fr24json'; |
189 | 189 | $globalSources[$id]['format'] = 'fr24json'; |
190 | 190 | //$last_exec['fr24json'] = 0; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
194 | 194 | exit(0); |
195 | 195 | } |
196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
196 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
197 | 197 | //$formats[$id] = 'fr24json'; |
198 | 198 | $globalSources[$id]['format'] = 'myshiptracking'; |
199 | 199 | //$last_exec['fr24json'] = 0; |
@@ -203,22 +203,22 @@ discard block |
||
203 | 203 | exit(0); |
204 | 204 | } |
205 | 205 | //} else if (preg_match('/10001/',$host)) { |
206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
206 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | 207 | //$formats[$id] = 'tsv'; |
208 | 208 | $globalSources[$id]['format'] = 'tsv'; |
209 | 209 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
210 | 210 | } |
211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
211 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
212 | 212 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
213 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
214 | 214 | if ($idf !== false) { |
215 | 215 | $httpfeeds[$id] = $idf; |
216 | 216 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
217 | 217 | } |
218 | 218 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
219 | 219 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | - $hostport = explode(':',$host); |
|
220 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
221 | + $hostport = explode(':', $host); |
|
222 | 222 | if (isset($hostport[1])) { |
223 | 223 | $port = $hostport[1]; |
224 | 224 | $hostn = $hostport[0]; |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | } |
229 | 229 | $Common = new Common(); |
230 | 230 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
231 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
232 | 232 | } else { |
233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
233 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
234 | 234 | } |
235 | 235 | if ($s) { |
236 | 236 | $sockets[$id] = $s; |
237 | 237 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
238 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
239 | 239 | //$formats[$id] = 'aprs'; |
240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
241 | 241 | //$aprs_connect = 0; |
242 | 242 | //$use_aprs = true; |
243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
243 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
245 | 245 | } elseif ($port == '10001') { |
246 | 246 | //$formats[$id] = 'tsv'; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
280 | 280 | else $timeout = 20; |
281 | 281 | $errno = ''; |
282 | -$errstr=''; |
|
282 | +$errstr = ''; |
|
283 | 283 | |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | /* Initiate connections to all the hosts simultaneously */ |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | //connect_all($globalSources); |
288 | 288 | |
289 | 289 | if (isset($globalProxy) && $globalProxy) { |
290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
291 | 291 | } else { |
292 | 292 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
293 | 293 | } |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | |
315 | 315 | if ($use_aprs) { |
316 | 316 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
317 | - $APRS=new APRS(); |
|
317 | + $APRS = new APRS(); |
|
318 | 318 | $aprs_connect = 0; |
319 | 319 | $aprs_keep = 120; |
320 | 320 | $aprs_last_tx = time(); |
321 | 321 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
322 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
322 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
323 | 323 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
324 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
324 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
325 | 325 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
326 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
327 | 327 | if ($aprs_full) $aprs_filter = ''; |
328 | 328 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
329 | 329 | else $aprs_pass = '-1'; |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | sleep(1); |
338 | 338 | if ($globalDebug) echo "SCAN MODE \n\n"; |
339 | 339 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
340 | -$endtime = time()+$globalCronEnd; |
|
340 | +$endtime = time() + $globalCronEnd; |
|
341 | 341 | $i = 1; |
342 | 342 | $tt = array(); |
343 | 343 | // Delete all ATC |
344 | 344 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
345 | - $ATC=new ATC($Connection->db); |
|
345 | + $ATC = new ATC($Connection->db); |
|
346 | 346 | } |
347 | 347 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
348 | 348 | $ATC->deleteAll(); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
352 | 352 | while ($i > 0) { |
353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
353 | + if (!$globalDaemon) $i = $endtime - time(); |
|
354 | 354 | // Delete old ATC |
355 | 355 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | } |
365 | 365 | if ($max != $globalMinFetch) { |
366 | 366 | if ($globalDebug) echo 'Sleeping...'."\n"; |
367 | - sleep($globalMinFetch-$max+2); |
|
367 | + sleep($globalMinFetch - $max + 2); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | //$buffer = $Common->getData($hosts[$id]); |
378 | 378 | $buffer = $Common->getData($value['host']); |
379 | 379 | if ($buffer != '') $reset = 0; |
380 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | - $buffer = explode('\n',$buffer); |
|
380 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
381 | + $buffer = explode('\n', $buffer); |
|
382 | 382 | foreach ($buffer as $line) { |
383 | 383 | if ($line != '' && count($line) > 7) { |
384 | 384 | $line = explode(',', $line); |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | $last_exec[$id]['last'] = time(); |
407 | 407 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
408 | 408 | date_default_timezone_set('CET'); |
409 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
409 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | if ($buffer != '') $reset = 0; |
412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | - $buffer = explode('\n',$buffer); |
|
412 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
413 | + $buffer = explode('\n', $buffer); |
|
414 | 414 | foreach ($buffer as $line) { |
415 | 415 | if ($line != '') { |
416 | 416 | echo "'".$line."'\n"; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
429 | 429 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
430 | 430 | if (isset($ais_data['timestamp'])) { |
431 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
431 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
432 | 432 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
433 | 433 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
434 | 434 | $add = true; |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | $w = $e = null; |
452 | 452 | |
453 | 453 | if (isset($arr[$id])) { |
454 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
454 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
455 | 455 | if ($nn > 0) { |
456 | 456 | foreach ($httpfeeds as $feed) { |
457 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
458 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
459 | - $buffer = explode('\n',$buffer); |
|
457 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
458 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
459 | + $buffer = explode('\n', $buffer); |
|
460 | 460 | foreach ($buffer as $line) { |
461 | 461 | if ($line != '') { |
462 | 462 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
475 | 475 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
477 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
477 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
478 | 478 | if (isset($ais_data['timestamp'])) { |
479 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
479 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
480 | 480 | } else { |
481 | 481 | $data['datetime'] = date('Y-m-d H:i:s'); |
482 | 482 | } |
@@ -502,10 +502,10 @@ discard block |
||
502 | 502 | } |
503 | 503 | } |
504 | 504 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
505 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
506 | 506 | if ($buffer != '') { |
507 | 507 | //echo $buffer; |
508 | - $all_data = json_decode($buffer,true); |
|
508 | + $all_data = json_decode($buffer, true); |
|
509 | 509 | //print_r($all_data); |
510 | 510 | if (isset($all_data[0]['DATA'])) { |
511 | 511 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
521 | 521 | $data['imo'] = $line['IMO']; |
522 | 522 | //$data['arrival_code'] = $ais_data['destination']; |
523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
523 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
524 | 524 | $data['format_source'] = 'myshiptracking'; |
525 | 525 | $data['id_source'] = $id_source; |
526 | 526 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | } |
533 | 533 | $last_exec[$id]['last'] = time(); |
534 | 534 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
535 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
535 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
536 | 536 | if ($buffer != '') { |
537 | - $all_data = json_decode($buffer,true); |
|
537 | + $all_data = json_decode($buffer, true); |
|
538 | 538 | if (isset($all_data[0]['mmsi'])) { |
539 | 539 | foreach ($all_data as $line) { |
540 | 540 | if ($line != '') { |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
564 | 564 | $buffer = $Common->getData($value['host']); |
565 | 565 | if ($buffer != '') { |
566 | - $all_data = json_decode($buffer,true); |
|
566 | + $all_data = json_decode($buffer, true); |
|
567 | 567 | if (isset($all_data['features'][0]['id'])) { |
568 | 568 | foreach ($all_data['features'] as $line) { |
569 | 569 | $data = array(); |
@@ -591,27 +591,27 @@ discard block |
||
591 | 591 | $last_exec[$id]['last'] = time(); |
592 | 592 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
593 | 593 | echo 'download...'; |
594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
594 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
595 | 595 | echo 'done !'."\n"; |
596 | 596 | if ($buffer != '') $reset = 0; |
597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | - $buffer = explode('\n',$buffer); |
|
597 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
598 | + $buffer = explode('\n', $buffer); |
|
599 | 599 | foreach ($buffer as $line) { |
600 | 600 | if ($line != '') { |
601 | 601 | $data = array(); |
602 | - $data['mmsi'] = (int)substr($line,0,9); |
|
603 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
602 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
603 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
604 | 604 | //$data['status'] = substr($line,21,2); |
605 | 605 | //$data['type'] = substr($line,24,3); |
606 | - $data['latitude'] = substr($line,29,9); |
|
607 | - $data['longitude'] = substr($line,41,9); |
|
608 | - $data['speed'] = round(substr($line,51,5)); |
|
606 | + $data['latitude'] = substr($line, 29, 9); |
|
607 | + $data['longitude'] = substr($line, 41, 9); |
|
608 | + $data['speed'] = round(substr($line, 51, 5)); |
|
609 | 609 | //$data['course'] = substr($line,57,5); |
610 | - $data['heading'] = round(substr($line,63,3)); |
|
610 | + $data['heading'] = round(substr($line, 63, 3)); |
|
611 | 611 | //$data['draft'] = substr($line,67,4); |
612 | 612 | //$data['length'] = substr($line,72,3); |
613 | 613 | //$data['beam'] = substr($line,76,2); |
614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
614 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
615 | 615 | //$data['callsign'] = trim(substr($line,100,7); |
616 | 616 | //$data['dest'] = substr($line,108,20); |
617 | 617 | //$data['etaDate'] = substr($line,129,5); |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
631 | 631 | //$buffer = $Common->getData($hosts[$id]); |
632 | 632 | $buffer = $Common->getData($value['host']); |
633 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | - $buffer = explode('\n',$buffer); |
|
633 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
634 | + $buffer = explode('\n', $buffer); |
|
635 | 635 | $reset = 0; |
636 | 636 | foreach ($buffer as $line) { |
637 | 637 | if ($line != '') { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
643 | 643 | $data['pilot_id'] = $line[1]; |
644 | 644 | $data['pilot_name'] = $line[2]; |
645 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
645 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
646 | 646 | $data['ident'] = $line[0]; // ident |
647 | 647 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
648 | 648 | $data['speed'] = $line[8]; // speed |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
660 | 660 | $data['departure_airport_icao'] = $line[11]; |
661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
662 | 662 | $data['arrival_airport_icao'] = $line[13]; |
663 | 663 | $data['frequency'] = $line[4]; |
664 | 664 | $data['type'] = $line[18]; |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $data['id_source'] = $id_source; |
668 | 668 | //$data['arrival_airport_time'] = ; |
669 | 669 | if ($line[9] != '') { |
670 | - $aircraft_data = explode('/',$line[9]); |
|
670 | + $aircraft_data = explode('/', $line[9]); |
|
671 | 671 | if (isset($aircraft_data[1])) { |
672 | 672 | $data['aircraft_icao'] = $aircraft_data[1]; |
673 | 673 | } |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | if ($line[3] == 'PILOT') $SI->add($data); |
683 | 683 | elseif ($line[3] == 'ATC') { |
684 | 684 | //print_r($data); |
685 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
686 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
687 | - $typec = substr($data['ident'],-3); |
|
685 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
686 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
687 | + $typec = substr($data['ident'], -3); |
|
688 | 688 | if ($typec == 'APP') $data['type'] = 'Approach'; |
689 | 689 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
690 | 690 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
697 | 697 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
698 | 698 | if (isset($ATC)) { |
699 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
700 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
699 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
700 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | unset($data); |
@@ -708,23 +708,23 @@ discard block |
||
708 | 708 | //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
709 | 709 | $last_exec[$id]['last'] = time(); |
710 | 710 | } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
711 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
711 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
712 | 712 | if ($buffer != '') { |
713 | 713 | $all_data = simplexml_load_string($buffer); |
714 | - foreach($all_data->children() as $childdata) { |
|
714 | + foreach ($all_data->children() as $childdata) { |
|
715 | 715 | $data = array(); |
716 | 716 | $line = $childdata; |
717 | 717 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
718 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
719 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
720 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
721 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
724 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
725 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
718 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
719 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
720 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
721 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
722 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
723 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
724 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
725 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
726 | 726 | $data['aircraft_icao'] = 'PARAGLIDER'; |
727 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
727 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
728 | 728 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
729 | 729 | $data['format_source'] = $value['format']; |
730 | 730 | $SI->add($data); |
@@ -732,30 +732,30 @@ discard block |
||
732 | 732 | } |
733 | 733 | } |
734 | 734 | $Source->deleteOldLocationByType('gs'); |
735 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
735 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
736 | 736 | if ($buffer != '') { |
737 | 737 | $all_data = simplexml_load_string($buffer); |
738 | - foreach($all_data->children() as $childdata) { |
|
738 | + foreach ($all_data->children() as $childdata) { |
|
739 | 739 | $data = array(); |
740 | 740 | $line = $childdata; |
741 | - $data['id'] = (int)$line['gsID']; |
|
742 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
743 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
744 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
745 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
741 | + $data['id'] = (int) $line['gsID']; |
|
742 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
743 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
744 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
745 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
746 | 746 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
747 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
747 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
748 | 748 | } else { |
749 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
749 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
750 | 750 | } |
751 | 751 | unset($data); |
752 | 752 | } |
753 | 753 | } |
754 | 754 | $last_exec[$id]['last'] = time(); |
755 | 755 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
756 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
756 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
757 | 757 | if ($buffer != '') { |
758 | - $all_data = json_decode($buffer,true); |
|
758 | + $all_data = json_decode($buffer, true); |
|
759 | 759 | if (isset($all_data['acList'])) { |
760 | 760 | $reset = 0; |
761 | 761 | foreach ($all_data['acList'] as $line) { |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | $data['emergency'] = ''; // emergency |
773 | 773 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
774 | 774 | |
775 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
775 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
776 | 776 | else $data['datetime'] = date('Y-m-d H:i:s'); |
777 | 777 | |
778 | 778 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | $data['verticalrate'] = $line['vrt']; // verticale rate |
799 | 799 | $data['squawk'] = $line['squawk']; // squawk |
800 | 800 | $data['emergency'] = ''; // emergency |
801 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
801 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
802 | 802 | else $data['datetime'] = date('Y-m-d H:i:s'); |
803 | 803 | $data['format_source'] = 'aircraftlistjson'; |
804 | 804 | $data['id_source'] = $id_source; |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
815 | 815 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
816 | 816 | $buffer = $Common->getData($value['host']); |
817 | - $all_data = json_decode($buffer,true); |
|
817 | + $all_data = json_decode($buffer, true); |
|
818 | 818 | if (isset($all_data['planes'])) { |
819 | 819 | $reset = 0; |
820 | 820 | foreach ($all_data['planes'] as $key => $line) { |
@@ -831,12 +831,12 @@ discard block |
||
831 | 831 | $data['emergency'] = ''; // emergency |
832 | 832 | $data['registration'] = $line[2]; |
833 | 833 | $data['aircraft_icao'] = $line[0]; |
834 | - $deparr = explode('-',$line[1]); |
|
834 | + $deparr = explode('-', $line[1]); |
|
835 | 835 | if (count($deparr) == 2) { |
836 | 836 | $data['departure_airport_icao'] = $deparr[0]; |
837 | 837 | $data['arrival_airport_icao'] = $deparr[1]; |
838 | 838 | } |
839 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
839 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
840 | 840 | $data['format_source'] = 'planeupdatefaa'; |
841 | 841 | $data['id_source'] = $id_source; |
842 | 842 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | $last_exec[$id]['last'] = time(); |
850 | 850 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
851 | 851 | $buffer = $Common->getData($value['host']); |
852 | - $all_data = json_decode($buffer,true); |
|
852 | + $all_data = json_decode($buffer, true); |
|
853 | 853 | if (isset($all_data['states'])) { |
854 | 854 | $reset = 0; |
855 | 855 | foreach ($all_data['states'] as $key => $line) { |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | //$data['emergency'] = ''; // emergency |
867 | 867 | //$data['registration'] = $line[2]; |
868 | 868 | //$data['aircraft_icao'] = $line[0]; |
869 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
869 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
870 | 870 | $data['format_source'] = 'opensky'; |
871 | 871 | $data['id_source'] = $id_source; |
872 | 872 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
881 | 881 | //$buffer = $Common->getData($hosts[$id]); |
882 | 882 | $buffer = $Common->getData($value['host']); |
883 | - $all_data = json_decode($buffer,true); |
|
883 | + $all_data = json_decode($buffer, true); |
|
884 | 884 | if (!empty($all_data)) $reset = 0; |
885 | 885 | foreach ($all_data as $key => $line) { |
886 | 886 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -913,11 +913,11 @@ discard block |
||
913 | 913 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
914 | 914 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
915 | 915 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
916 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
916 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
917 | 917 | //echo $buffer; |
918 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
919 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
920 | - $all_data = json_decode($buffer,true); |
|
918 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
919 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
920 | + $all_data = json_decode($buffer, true); |
|
921 | 921 | if (json_last_error() != JSON_ERROR_NONE) { |
922 | 922 | die(json_last_error_msg()); |
923 | 923 | } |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | //$data['departure_airport_iata'] = $line[11]; |
941 | 941 | //$data['arrival_airport_iata'] = $line[12]; |
942 | 942 | //$data['emergency'] = ''; // emergency |
943 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
943 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
944 | 944 | $data['format_source'] = 'radarvirtueljson'; |
945 | 945 | $data['id_source'] = $id_source; |
946 | 946 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -956,14 +956,14 @@ discard block |
||
956 | 956 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
957 | 957 | //$buffer = $Common->getData($hosts[$id]); |
958 | 958 | $buffer = $Common->getData($value['host'].'?'.time()); |
959 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
959 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
960 | 960 | |
961 | 961 | if (isset($all_data['pireps'])) { |
962 | 962 | $reset = 0; |
963 | 963 | foreach ($all_data['pireps'] as $line) { |
964 | 964 | $data = array(); |
965 | 965 | $data['id'] = $line['id']; |
966 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
966 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
967 | 967 | $data['ident'] = $line['callsign']; // ident |
968 | 968 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
969 | 969 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -993,9 +993,9 @@ discard block |
||
993 | 993 | $SI->add($data); |
994 | 994 | // print_r($data); |
995 | 995 | } elseif ($line['icon'] == 'ct') { |
996 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
997 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
998 | - $typec = substr($data['ident'],-3); |
|
996 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
997 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
998 | + $typec = substr($data['ident'], -3); |
|
999 | 999 | $data['type'] = ''; |
1000 | 1000 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1001 | 1001 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1007 | 1007 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1008 | 1008 | else $data['type'] = 'Observer'; |
1009 | - 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']); |
|
1009 | + 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']); |
|
1010 | 1010 | } |
1011 | 1011 | unset($data); |
1012 | 1012 | } |
@@ -1018,14 +1018,14 @@ discard block |
||
1018 | 1018 | //$buffer = $Common->getData($hosts[$id]); |
1019 | 1019 | if ($globalDebug) echo 'Get Data...'."\n"; |
1020 | 1020 | $buffer = $Common->getData($value['host']); |
1021 | - $all_data = json_decode($buffer,true); |
|
1021 | + $all_data = json_decode($buffer, true); |
|
1022 | 1022 | if ($buffer != '' && is_array($all_data)) { |
1023 | 1023 | $reset = 0; |
1024 | 1024 | foreach ($all_data as $line) { |
1025 | 1025 | $data = array(); |
1026 | 1026 | //$data['id'] = $line['id']; // id not usable |
1027 | 1027 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1028 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1028 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1029 | 1029 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1030 | 1030 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1031 | 1031 | $data['ident'] = $line['flightnum']; // ident |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | //$data['datetime'] = $line['lastupdate']; |
1041 | 1041 | //$data['last_update'] = $line['lastupdate']; |
1042 | 1042 | if (isset($value['timezone'])) { |
1043 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1043 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1044 | 1044 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1045 | 1045 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1046 | 1046 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1053,14 +1053,14 @@ discard block |
||
1053 | 1053 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1054 | 1054 | if (isset($line['aircraftname'])) { |
1055 | 1055 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1056 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1057 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1056 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1057 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1058 | 1058 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1059 | 1059 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1060 | 1060 | else { |
1061 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1062 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1063 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1061 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1062 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1063 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1064 | 1064 | } |
1065 | 1065 | } |
1066 | 1066 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | //$buffer = $Common->getData($hosts[$id]); |
1081 | 1081 | if ($globalDebug) echo 'Get Data...'."\n"; |
1082 | 1082 | $buffer = $Common->getData($value['host']); |
1083 | - $all_data = json_decode($buffer,true); |
|
1083 | + $all_data = json_decode($buffer, true); |
|
1084 | 1084 | if ($buffer != '' && is_array($all_data)) { |
1085 | 1085 | $reset = 0; |
1086 | 1086 | foreach ($all_data as $line) { |
1087 | 1087 | $data = array(); |
1088 | 1088 | //$data['id'] = $line['id']; // id not usable |
1089 | 1089 | $data['id'] = trim($line['flight_id']); |
1090 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1090 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1091 | 1091 | $data['pilot_name'] = $line['pilot_name']; |
1092 | 1092 | $data['pilot_id'] = $line['pilot_id']; |
1093 | 1093 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1139,11 +1139,11 @@ discard block |
||
1139 | 1139 | //$value = $formats[$nb]; |
1140 | 1140 | $format = $globalSources[$nb]['format']; |
1141 | 1141 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1142 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1142 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1143 | 1143 | } elseif ($format == 'vrstcp') { |
1144 | 1144 | $buffer = @socket_read($r, 6000); |
1145 | 1145 | } else { |
1146 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1146 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1147 | 1147 | } |
1148 | 1148 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1149 | 1149 | //echo $buffer."\n"; |
@@ -1152,8 +1152,8 @@ discard block |
||
1152 | 1152 | $error = false; |
1153 | 1153 | //$SI::del(); |
1154 | 1154 | if ($format == 'vrstcp') { |
1155 | - $buffer = explode('},{',$buffer); |
|
1156 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1155 | + $buffer = explode('},{', $buffer); |
|
1156 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1157 | 1157 | // SBS format is CSV format |
1158 | 1158 | if ($buffer !== FALSE && $buffer != '') { |
1159 | 1159 | $tt[$format] = 0; |
@@ -1187,13 +1187,13 @@ discard block |
||
1187 | 1187 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1188 | 1188 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1189 | 1189 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1190 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1190 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1191 | 1191 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1192 | 1192 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1193 | 1193 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1194 | 1194 | |
1195 | 1195 | if (isset($ais_data['timestamp'])) { |
1196 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1196 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1197 | 1197 | } else { |
1198 | 1198 | $data['datetime'] = date('Y-m-d H:i:s'); |
1199 | 1199 | } |
@@ -1204,10 +1204,10 @@ discard block |
||
1204 | 1204 | } elseif ($format == 'flightgearsp') { |
1205 | 1205 | //echo $buffer."\n"; |
1206 | 1206 | if (strlen($buffer) > 5) { |
1207 | - $line = explode(',',$buffer); |
|
1207 | + $line = explode(',', $buffer); |
|
1208 | 1208 | $data = array(); |
1209 | 1209 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1210 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1210 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1211 | 1211 | $data['ident'] = $line[6]; |
1212 | 1212 | $data['aircraft_name'] = $line[7]; |
1213 | 1213 | $data['longitude'] = $line[1]; |
@@ -1224,16 +1224,16 @@ discard block |
||
1224 | 1224 | } elseif ($format == 'acars') { |
1225 | 1225 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1226 | 1226 | $ACARS->add(trim($buffer)); |
1227 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1227 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1228 | 1228 | $ACARS->deleteLiveAcarsData(); |
1229 | 1229 | } elseif ($format == 'flightgearmp') { |
1230 | - if (substr($buffer,0,1) != '#') { |
|
1230 | + if (substr($buffer, 0, 1) != '#') { |
|
1231 | 1231 | $data = array(); |
1232 | 1232 | //echo $buffer."\n"; |
1233 | - $line = explode(' ',$buffer); |
|
1233 | + $line = explode(' ', $buffer); |
|
1234 | 1234 | if (count($line) == 11) { |
1235 | - $userserver = explode('@',$line[0]); |
|
1236 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1235 | + $userserver = explode('@', $line[0]); |
|
1236 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1237 | 1237 | $data['ident'] = $userserver[0]; |
1238 | 1238 | $data['registration'] = $userserver[0]; |
1239 | 1239 | $data['latitude'] = $line[4]; |
@@ -1241,8 +1241,8 @@ discard block |
||
1241 | 1241 | $data['altitude'] = $line[6]; |
1242 | 1242 | $data['datetime'] = date('Y-m-d H:i:s'); |
1243 | 1243 | $aircraft_type = $line[10]; |
1244 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1245 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1244 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1245 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1246 | 1246 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1247 | 1247 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1248 | 1248 | } |
@@ -1251,8 +1251,8 @@ discard block |
||
1251 | 1251 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1252 | 1252 | die; |
1253 | 1253 | } elseif ($format == 'vrstcp') { |
1254 | - foreach($buffer as $all_data) { |
|
1255 | - $line = json_decode('{'.$all_data.'}',true); |
|
1254 | + foreach ($buffer as $all_data) { |
|
1255 | + $line = json_decode('{'.$all_data.'}', true); |
|
1256 | 1256 | $data = array(); |
1257 | 1257 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1258 | 1258 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1278,16 +1278,16 @@ discard block |
||
1278 | 1278 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1279 | 1279 | unset($data); |
1280 | 1280 | } |
1281 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1281 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1282 | 1282 | $line = explode("\t", $buffer); |
1283 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1283 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1284 | 1284 | $key = $line[$k]; |
1285 | - $lined[$key] = $line[$k+1]; |
|
1285 | + $lined[$key] = $line[$k + 1]; |
|
1286 | 1286 | } |
1287 | 1287 | if (count($lined) > 3) { |
1288 | 1288 | $data['hex'] = $lined['hexid']; |
1289 | 1289 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1290 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1290 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1291 | 1291 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1292 | 1292 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1293 | 1293 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1306,22 +1306,22 @@ discard block |
||
1306 | 1306 | } else $error = true; |
1307 | 1307 | } elseif ($format == 'aprs' && $use_aprs) { |
1308 | 1308 | if ($aprs_connect == 0) { |
1309 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1309 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1310 | 1310 | $aprs_connect = 1; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1313 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1314 | 1314 | $aprs_last_tx = time(); |
1315 | 1315 | $data_aprs = "# Keep alive"; |
1316 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1316 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1320 | 1320 | //echo 'APRS data : '.$buffer."\n"; |
1321 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1322 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1321 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1322 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1323 | 1323 | //echo $buffer."\n"; |
1324 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1324 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1325 | 1325 | $line = $APRS->parse($buffer); |
1326 | 1326 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1327 | 1327 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1337 | 1337 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1338 | 1338 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1339 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1339 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1340 | 1340 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1341 | 1341 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1342 | 1342 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1382,9 +1382,9 @@ discard block |
||
1382 | 1382 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1383 | 1383 | $Source->deleteOldLocationByType('gs'); |
1384 | 1384 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
1385 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1385 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1386 | 1386 | } else { |
1387 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1387 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1388 | 1388 | } |
1389 | 1389 | } else { |
1390 | 1390 | echo '/!\ Not added'."\n"; |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1400 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1400 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1401 | 1401 | } |
1402 | 1402 | /* |
1403 | 1403 | 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')) { |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | connect_all($sourceee); |
1485 | 1485 | $sourceee = array(); |
1486 | 1486 | //connect_all($globalSources); |
1487 | - $tt[$format]=0; |
|
1487 | + $tt[$format] = 0; |
|
1488 | 1488 | break; |
1489 | 1489 | } |
1490 | 1490 | } |
@@ -1493,14 +1493,14 @@ discard block |
||
1493 | 1493 | } else { |
1494 | 1494 | $error = socket_strerror(socket_last_error()); |
1495 | 1495 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1496 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1496 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1497 | 1497 | if (isset($globalDebug)) echo "Restarting...\n"; |
1498 | 1498 | // Restart the script if possible |
1499 | 1499 | if (is_array($sockets)) { |
1500 | 1500 | if ($globalDebug) echo "Shutdown all sockets..."; |
1501 | 1501 | |
1502 | 1502 | foreach ($sockets as $sock) { |
1503 | - @socket_shutdown($sock,2); |
|
1503 | + @socket_shutdown($sock, 2); |
|
1504 | 1504 | @socket_close($sock); |
1505 | 1505 | } |
1506 | 1506 |
@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -55,35 +59,62 @@ discard block |
||
55 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 60 | if (isset($options['s'])) { |
57 | 61 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
60 | -} elseif (isset($options['source'])) { |
|
62 | + if (isset($options['format'])) { |
|
63 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
64 | + } else { |
|
65 | + $globalSources[] = array('host' => $options['s']); |
|
66 | + } |
|
67 | + } elseif (isset($options['source'])) { |
|
61 | 68 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
64 | -} |
|
69 | + if (isset($options['format'])) { |
|
70 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
71 | + } else { |
|
72 | + $globalSources[] = array('host' => $options['source']); |
|
73 | + } |
|
74 | + } |
|
65 | 75 | if (isset($options['aprsserverhost'])) { |
66 | 76 | $globalServerAPRS = TRUE; |
67 | 77 | $globalServerAPRShost = $options['aprsserverhost']; |
68 | 78 | } |
69 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
70 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
71 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
72 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
73 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
74 | -if (isset($options['server'])) $globalServer = TRUE; |
|
75 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
76 | -else $id_source = 1; |
|
79 | +if (isset($options['aprsserverport'])) { |
|
80 | + $globalServerAPRSport = $options['aprsserverport']; |
|
81 | +} |
|
82 | +if (isset($options['aprsserverssid'])) { |
|
83 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
84 | +} |
|
85 | +if (isset($options['aprsserverpass'])) { |
|
86 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
87 | +} |
|
88 | +if (isset($options['noaprsserver'])) { |
|
89 | + $globalServerAPRS = FALSE; |
|
90 | +} |
|
91 | +if (isset($options['nodaemon'])) { |
|
92 | + $globalDaemon = FALSE; |
|
93 | +} |
|
94 | +if (isset($options['server'])) { |
|
95 | + $globalServer = TRUE; |
|
96 | +} |
|
97 | +if (isset($options['idsource'])) { |
|
98 | + $id_source = $options['idsource']; |
|
99 | +} else { |
|
100 | + $id_source = 1; |
|
101 | +} |
|
77 | 102 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
103 | + if ($globalDebug) { |
|
104 | + echo "Using Server Mode\n"; |
|
105 | + } |
|
79 | 106 | $SI=new SpotterServer(); |
80 | 107 | /* |
81 | 108 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 109 | $SI = new adsb2aprs(); |
83 | 110 | $SI->connect(); |
84 | 111 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
86 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
112 | +} else { |
|
113 | + $SI=new SpotterImport($Connection->db); |
|
114 | +} |
|
115 | +if (isset($globalTracker) && $globalTracker) { |
|
116 | + $TI = new TrackerImport($Connection->db); |
|
117 | +} |
|
87 | 118 | if (isset($globalMarine) && $globalMarine) { |
88 | 119 | $AIS = new AIS(); |
89 | 120 | $MI = new MarineImport($Connection->db); |
@@ -106,7 +137,9 @@ discard block |
||
106 | 137 | } |
107 | 138 | |
108 | 139 | // let's try and connect |
109 | -if ($globalDebug) echo "Connecting...\n"; |
|
140 | +if ($globalDebug) { |
|
141 | + echo "Connecting...\n"; |
|
142 | +} |
|
110 | 143 | $use_aprs = false; |
111 | 144 | $aprs_full = false; |
112 | 145 | $reset = 0; |
@@ -115,7 +148,9 @@ discard block |
||
115 | 148 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | 149 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
117 | 150 | $reset++; |
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo 'Connect to all...'."\n"; |
|
153 | + } |
|
119 | 154 | foreach ($hosts as $id => $value) { |
120 | 155 | $host = $value['host']; |
121 | 156 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,22 +160,30 @@ discard block |
||
125 | 160 | //$formats[$id] = 'deltadbtxt'; |
126 | 161 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 162 | //$last_exec['deltadbtxt'] = 0; |
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
163 | + if ($globalDebug) { |
|
164 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
165 | + } |
|
129 | 166 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
130 | 167 | //$formats[$id] = 'vatsimtxt'; |
131 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 169 | //$last_exec['vatsimtxt'] = 0; |
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
172 | + } |
|
134 | 173 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
135 | 174 | //$formats[$id] = 'aircraftlistjson'; |
136 | 175 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 176 | //$last_exec['aircraftlistjson'] = 0; |
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
177 | + if ($globalDebug) { |
|
178 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
179 | + } |
|
139 | 180 | } else if (preg_match('/opensky/i',$host)) { |
140 | 181 | //$formats[$id] = 'aircraftlistjson'; |
141 | 182 | $globalSources[$id]['format'] = 'opensky'; |
142 | 183 | //$last_exec['aircraftlistjson'] = 0; |
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "Connect to opensky source (".$host.")...\n"; |
|
186 | + } |
|
144 | 187 | /* |
145 | 188 | // Disabled for now, site change source format |
146 | 189 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -157,7 +200,9 @@ discard block |
||
157 | 200 | //$formats[$id] = 'planeupdatefaa'; |
158 | 201 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 202 | //$last_exec['planeupdatefaa'] = 0; |
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
205 | + } |
|
161 | 206 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
162 | 207 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 208 | exit(0); |
@@ -166,29 +211,41 @@ discard block |
||
166 | 211 | //$formats[$id] = 'phpvmacars'; |
167 | 212 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 213 | //$last_exec['phpvmacars'] = 0; |
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
216 | + } |
|
170 | 217 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
171 | 218 | //$formats[$id] = 'phpvmacars'; |
172 | 219 | $globalSources[$id]['format'] = 'vam'; |
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo "Connect to Vam source (".$host.")...\n"; |
|
222 | + } |
|
174 | 223 | } else if (preg_match('/whazzup/i',$host)) { |
175 | 224 | //$formats[$id] = 'whazzup'; |
176 | 225 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 226 | //$last_exec['whazzup'] = 0; |
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
227 | + if ($globalDebug) { |
|
228 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
229 | + } |
|
179 | 230 | } else if (preg_match('/airwhere/i',$host)) { |
180 | 231 | $globalSources[$id]['format'] = 'airwhere'; |
181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | + if ($globalDebug) { |
|
233 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
234 | + } |
|
182 | 235 | } else if (preg_match('/recentpireps/i',$host)) { |
183 | 236 | //$formats[$id] = 'pirepsjson'; |
184 | 237 | $globalSources[$id]['format'] = 'pirepsjson'; |
185 | 238 | //$last_exec['pirepsjson'] = 0; |
186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
239 | + if ($globalDebug) { |
|
240 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
241 | + } |
|
187 | 242 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
188 | 243 | //$formats[$id] = 'fr24json'; |
189 | 244 | $globalSources[$id]['format'] = 'fr24json'; |
190 | 245 | //$last_exec['fr24json'] = 0; |
191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
246 | + if ($globalDebug) { |
|
247 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
248 | + } |
|
192 | 249 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
193 | 250 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
194 | 251 | exit(0); |
@@ -197,7 +254,9 @@ discard block |
||
197 | 254 | //$formats[$id] = 'fr24json'; |
198 | 255 | $globalSources[$id]['format'] = 'myshiptracking'; |
199 | 256 | //$last_exec['fr24json'] = 0; |
200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
257 | + if ($globalDebug) { |
|
258 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
259 | + } |
|
201 | 260 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
202 | 261 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
203 | 262 | exit(0); |
@@ -206,17 +265,24 @@ discard block |
||
206 | 265 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
207 | 266 | //$formats[$id] = 'tsv'; |
208 | 267 | $globalSources[$id]['format'] = 'tsv'; |
209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
268 | + if ($globalDebug) { |
|
269 | + echo "Connect to tsv source (".$host.")...\n"; |
|
270 | + } |
|
210 | 271 | } |
211 | 272 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
212 | 273 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
213 | 274 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
214 | 275 | if ($idf !== false) { |
215 | 276 | $httpfeeds[$id] = $idf; |
216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
277 | + if ($globalDebug) { |
|
278 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
279 | + } |
|
280 | + } elseif ($globalDebug) { |
|
281 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
217 | 282 | } |
218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
283 | + } elseif ($globalDebug) { |
|
284 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
285 | + } |
|
220 | 286 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
221 | 287 | $hostport = explode(':',$host); |
222 | 288 | if (isset($hostport[1])) { |
@@ -256,17 +322,25 @@ discard block |
||
256 | 322 | //$formats[$id] = 'beast'; |
257 | 323 | $globalSources[$id]['format'] = 'beast'; |
258 | 324 | //} else $formats[$id] = 'sbs'; |
259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
325 | + } else { |
|
326 | + $globalSources[$id]['format'] = 'sbs'; |
|
327 | + } |
|
260 | 328 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
261 | 329 | } |
262 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
330 | + if ($globalDebug) { |
|
331 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
332 | + } |
|
263 | 333 | } else { |
264 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
336 | + } |
|
265 | 337 | } |
266 | 338 | } |
267 | 339 | } |
268 | 340 | } |
269 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
341 | +if (!isset($globalMinFetch)) { |
|
342 | + $globalMinFetch = 15; |
|
343 | +} |
|
270 | 344 | |
271 | 345 | // Initialize all |
272 | 346 | $status = array(); |
@@ -275,13 +349,19 @@ discard block |
||
275 | 349 | $formats = array(); |
276 | 350 | $last_exec = array(); |
277 | 351 | $time = time(); |
278 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
279 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
280 | -else $timeout = 20; |
|
352 | +if (isset($globalSourcesTimeout)) { |
|
353 | + $timeout = $globalSourcesTimeOut; |
|
354 | +} else if (isset($globalSBS1TimeOut)) { |
|
355 | + $timeout = $globalSBS1TimeOut; |
|
356 | +} else { |
|
357 | + $timeout = 20; |
|
358 | +} |
|
281 | 359 | $errno = ''; |
282 | 360 | $errstr=''; |
283 | 361 | |
284 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
362 | +if (!isset($globalDaemon)) { |
|
363 | + $globalDaemon = TRUE; |
|
364 | +} |
|
285 | 365 | /* Initiate connections to all the hosts simultaneously */ |
286 | 366 | //connect_all($hosts); |
287 | 367 | //connect_all($globalSources); |
@@ -307,7 +387,9 @@ discard block |
||
307 | 387 | if (isset($source['format']) && $source['format'] == 'aprs') { |
308 | 388 | $aprs_connect = 0; |
309 | 389 | $use_aprs = true; |
310 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
390 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
391 | + $aprs_full = true; |
|
392 | + } |
|
311 | 393 | break; |
312 | 394 | } |
313 | 395 | } |
@@ -318,25 +400,48 @@ discard block |
||
318 | 400 | $aprs_connect = 0; |
319 | 401 | $aprs_keep = 120; |
320 | 402 | $aprs_last_tx = time(); |
321 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
322 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
323 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
324 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
325 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
327 | - if ($aprs_full) $aprs_filter = ''; |
|
328 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
329 | - else $aprs_pass = '-1'; |
|
403 | + if (isset($globalAPRSversion)) { |
|
404 | + $aprs_version = $globalAPRSversion; |
|
405 | + } else { |
|
406 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
407 | + } |
|
408 | + if (isset($globalAPRSssid)) { |
|
409 | + $aprs_ssid = $globalAPRSssid; |
|
410 | + } else { |
|
411 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
412 | + } |
|
413 | + if (isset($globalAPRSfilter)) { |
|
414 | + $aprs_filter = $globalAPRSfilter; |
|
415 | + } else { |
|
416 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
417 | + } |
|
418 | + if ($aprs_full) { |
|
419 | + $aprs_filter = ''; |
|
420 | + } |
|
421 | + if (isset($globalAPRSpass)) { |
|
422 | + $aprs_pass = $globalAPRSpass; |
|
423 | + } else { |
|
424 | + $aprs_pass = '-1'; |
|
425 | + } |
|
330 | 426 | |
331 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
332 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
333 | -} |
|
427 | + if ($aprs_filter != '') { |
|
428 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
429 | + } else { |
|
430 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
431 | + } |
|
432 | + } |
|
334 | 433 | |
335 | 434 | // connected - lets do some work |
336 | -if ($globalDebug) echo "Connected!\n"; |
|
435 | +if ($globalDebug) { |
|
436 | + echo "Connected!\n"; |
|
437 | +} |
|
337 | 438 | sleep(1); |
338 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
339 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
439 | +if ($globalDebug) { |
|
440 | + echo "SCAN MODE \n\n"; |
|
441 | +} |
|
442 | +if (!isset($globalCronEnd)) { |
|
443 | + $globalCronEnd = 60; |
|
444 | +} |
|
340 | 445 | $endtime = time()+$globalCronEnd; |
341 | 446 | $i = 1; |
342 | 447 | $tt = array(); |
@@ -350,20 +455,28 @@ discard block |
||
350 | 455 | |
351 | 456 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
352 | 457 | while ($i > 0) { |
353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
458 | + if (!$globalDaemon) { |
|
459 | + $i = $endtime-time(); |
|
460 | + } |
|
354 | 461 | // Delete old ATC |
355 | 462 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
356 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
463 | + if ($globalDebug) { |
|
464 | + echo 'Delete old ATC...'."\n"; |
|
465 | + } |
|
357 | 466 | $ATC->deleteOldATC(); |
358 | 467 | } |
359 | 468 | |
360 | 469 | if (count($last_exec) == count($globalSources)) { |
361 | 470 | $max = $globalMinFetch; |
362 | 471 | foreach ($last_exec as $last) { |
363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
472 | + if ((time() - $last['last']) < $max) { |
|
473 | + $max = time() - $last['last']; |
|
474 | + } |
|
364 | 475 | } |
365 | 476 | if ($max != $globalMinFetch) { |
366 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
477 | + if ($globalDebug) { |
|
478 | + echo 'Sleeping...'."\n"; |
|
479 | + } |
|
367 | 480 | sleep($globalMinFetch-$max+2); |
368 | 481 | } |
369 | 482 | } |
@@ -372,11 +485,15 @@ discard block |
||
372 | 485 | //foreach ($formats as $id => $value) { |
373 | 486 | foreach ($globalSources as $id => $value) { |
374 | 487 | date_default_timezone_set('UTC'); |
375 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
488 | + if (!isset($last_exec[$id]['last'])) { |
|
489 | + $last_exec[$id]['last'] = 0; |
|
490 | + } |
|
376 | 491 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
377 | 492 | //$buffer = $Common->getData($hosts[$id]); |
378 | 493 | $buffer = $Common->getData($value['host']); |
379 | - if ($buffer != '') $reset = 0; |
|
494 | + if ($buffer != '') { |
|
495 | + $reset = 0; |
|
496 | + } |
|
380 | 497 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
381 | 498 | $buffer = explode('\n',$buffer); |
382 | 499 | foreach ($buffer as $line) { |
@@ -385,20 +502,41 @@ discard block |
||
385 | 502 | $data = array(); |
386 | 503 | $data['hex'] = $line[1]; // hex |
387 | 504 | $data['ident'] = $line[2]; // ident |
388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
505 | + if (isset($line[3])) { |
|
506 | + $data['altitude'] = $line[3]; |
|
507 | + } |
|
508 | + // altitude |
|
509 | + if (isset($line[4])) { |
|
510 | + $data['speed'] = $line[4]; |
|
511 | + } |
|
512 | + // speed |
|
513 | + if (isset($line[5])) { |
|
514 | + $data['heading'] = $line[5]; |
|
515 | + } |
|
516 | + // heading |
|
517 | + if (isset($line[6])) { |
|
518 | + $data['latitude'] = $line[6]; |
|
519 | + } |
|
520 | + // lat |
|
521 | + if (isset($line[7])) { |
|
522 | + $data['longitude'] = $line[7]; |
|
523 | + } |
|
524 | + // long |
|
393 | 525 | $data['verticalrate'] = ''; // vertical rate |
394 | 526 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
395 | 527 | $data['emergency'] = ''; // emergency |
396 | 528 | $data['datetime'] = date('Y-m-d H:i:s'); |
397 | 529 | $data['format_source'] = 'deltadbtxt'; |
398 | 530 | $data['id_source'] = $id_source; |
399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
531 | + if (isset($value['name']) && $value['name'] != '') { |
|
532 | + $data['source_name'] = $value['name']; |
|
533 | + } |
|
534 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
535 | + $data['noarchive'] = true; |
|
536 | + } |
|
537 | + if (isset($value['sourcestats'])) { |
|
538 | + $data['sourcestats'] = $value['sourcestats']; |
|
539 | + } |
|
402 | 540 | $SI->add($data); |
403 | 541 | unset($data); |
404 | 542 | } |
@@ -408,7 +546,9 @@ discard block |
||
408 | 546 | date_default_timezone_set('CET'); |
409 | 547 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
410 | 548 | date_default_timezone_set('UTC'); |
411 | - if ($buffer != '') $reset = 0; |
|
549 | + if ($buffer != '') { |
|
550 | + $reset = 0; |
|
551 | + } |
|
412 | 552 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
413 | 553 | $buffer = explode('\n',$buffer); |
414 | 554 | foreach ($buffer as $line) { |
@@ -417,16 +557,36 @@ discard block |
||
417 | 557 | $add = false; |
418 | 558 | $ais_data = $AIS->parse_line(trim($line)); |
419 | 559 | $data = array(); |
420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
560 | + if (isset($ais_data['ident'])) { |
|
561 | + $data['ident'] = $ais_data['ident']; |
|
562 | + } |
|
563 | + if (isset($ais_data['mmsi'])) { |
|
564 | + $data['mmsi'] = $ais_data['mmsi']; |
|
565 | + } |
|
566 | + if (isset($ais_data['speed'])) { |
|
567 | + $data['speed'] = $ais_data['speed']; |
|
568 | + } |
|
569 | + if (isset($ais_data['heading'])) { |
|
570 | + $data['heading'] = $ais_data['heading']; |
|
571 | + } |
|
572 | + if (isset($ais_data['latitude'])) { |
|
573 | + $data['latitude'] = $ais_data['latitude']; |
|
574 | + } |
|
575 | + if (isset($ais_data['longitude'])) { |
|
576 | + $data['longitude'] = $ais_data['longitude']; |
|
577 | + } |
|
578 | + if (isset($ais_data['status'])) { |
|
579 | + $data['status'] = $ais_data['status']; |
|
580 | + } |
|
581 | + if (isset($ais_data['type'])) { |
|
582 | + $data['type'] = $ais_data['type']; |
|
583 | + } |
|
584 | + if (isset($ais_data['imo'])) { |
|
585 | + $data['imo'] = $ais_data['imo']; |
|
586 | + } |
|
587 | + if (isset($ais_data['callsign'])) { |
|
588 | + $data['callsign'] = $ais_data['callsign']; |
|
589 | + } |
|
430 | 590 | if (isset($ais_data['timestamp'])) { |
431 | 591 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
432 | 592 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -440,8 +600,12 @@ discard block |
||
440 | 600 | $data['format_source'] = 'aisnmeatxt'; |
441 | 601 | $data['id_source'] = $id_source; |
442 | 602 | //print_r($data); |
443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
603 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
604 | + $data['noarchive'] = true; |
|
605 | + } |
|
606 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
607 | + $MI->add($data); |
|
608 | + } |
|
445 | 609 | unset($data); |
446 | 610 | } |
447 | 611 | } |
@@ -461,20 +625,48 @@ discard block |
||
461 | 625 | if ($line != '') { |
462 | 626 | $ais_data = $AIS->parse_line(trim($line)); |
463 | 627 | $data = array(); |
464 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
465 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
466 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
467 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
468 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
469 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
470 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
471 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
472 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
473 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
474 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
475 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
476 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
477 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
628 | + if (isset($ais_data['ident'])) { |
|
629 | + $data['ident'] = $ais_data['ident']; |
|
630 | + } |
|
631 | + if (isset($ais_data['mmsi'])) { |
|
632 | + $data['mmsi'] = $ais_data['mmsi']; |
|
633 | + } |
|
634 | + if (isset($ais_data['speed'])) { |
|
635 | + $data['speed'] = $ais_data['speed']; |
|
636 | + } |
|
637 | + if (isset($ais_data['heading'])) { |
|
638 | + $data['heading'] = $ais_data['heading']; |
|
639 | + } |
|
640 | + if (isset($ais_data['latitude'])) { |
|
641 | + $data['latitude'] = $ais_data['latitude']; |
|
642 | + } |
|
643 | + if (isset($ais_data['longitude'])) { |
|
644 | + $data['longitude'] = $ais_data['longitude']; |
|
645 | + } |
|
646 | + if (isset($ais_data['status'])) { |
|
647 | + $data['status'] = $ais_data['status']; |
|
648 | + } |
|
649 | + if (isset($ais_data['statusid'])) { |
|
650 | + $data['status_id'] = $ais_data['statusid']; |
|
651 | + } |
|
652 | + if (isset($ais_data['type'])) { |
|
653 | + $data['type'] = $ais_data['type']; |
|
654 | + } |
|
655 | + if (isset($ais_data['typeid'])) { |
|
656 | + $data['type_id'] = $ais_data['typeid']; |
|
657 | + } |
|
658 | + if (isset($ais_data['imo'])) { |
|
659 | + $data['imo'] = $ais_data['imo']; |
|
660 | + } |
|
661 | + if (isset($ais_data['callsign'])) { |
|
662 | + $data['callsign'] = $ais_data['callsign']; |
|
663 | + } |
|
664 | + if (isset($ais_data['destination'])) { |
|
665 | + $data['arrival_code'] = $ais_data['destination']; |
|
666 | + } |
|
667 | + if (isset($ais_data['eta_ts'])) { |
|
668 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
669 | + } |
|
478 | 670 | if (isset($ais_data['timestamp'])) { |
479 | 671 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
480 | 672 | } else { |
@@ -482,18 +674,27 @@ discard block |
||
482 | 674 | } |
483 | 675 | $data['format_source'] = 'aisnmeahttp'; |
484 | 676 | $data['id_source'] = $id_source; |
485 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
486 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
677 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
678 | + $data['noarchive'] = true; |
|
679 | + } |
|
680 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
681 | + $MI->add($data); |
|
682 | + } |
|
487 | 683 | unset($data); |
488 | 684 | } |
489 | 685 | } |
490 | 686 | } |
491 | 687 | } else { |
492 | 688 | $format = $value['format']; |
493 | - if (isset($tt[$format])) $tt[$format]++; |
|
494 | - else $tt[$format] = 0; |
|
689 | + if (isset($tt[$format])) { |
|
690 | + $tt[$format]++; |
|
691 | + } else { |
|
692 | + $tt[$format] = 0; |
|
693 | + } |
|
495 | 694 | if ($tt[$format] > 30) { |
496 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
695 | + if ($globalDebug) { |
|
696 | + echo 'Reconnect...'."\n"; |
|
697 | + } |
|
497 | 698 | sleep(2); |
498 | 699 | $sourceeen[] = $value; |
499 | 700 | connect_all($sourceeen); |
@@ -523,7 +724,9 @@ discard block |
||
523 | 724 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
524 | 725 | $data['format_source'] = 'myshiptracking'; |
525 | 726 | $data['id_source'] = $id_source; |
526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
727 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
728 | + $data['noarchive'] = true; |
|
729 | + } |
|
527 | 730 | $MI->add($data); |
528 | 731 | unset($data); |
529 | 732 | } |
@@ -543,7 +746,9 @@ discard block |
||
543 | 746 | $data['callsign'] = $line['callsign']; |
544 | 747 | $data['mmsi'] = $line['mmsi']; |
545 | 748 | $data['speed'] = $line['sog']; |
546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
749 | + if ($line['heading'] != '511') { |
|
750 | + $data['heading'] = $line['heading']; |
|
751 | + } |
|
547 | 752 | $data['latitude'] = $line['latitude']; |
548 | 753 | $data['longitude'] = $line['longitude']; |
549 | 754 | $data['type_id'] = $line['shiptype']; |
@@ -551,7 +756,9 @@ discard block |
||
551 | 756 | $data['datetime'] = $line['time']; |
552 | 757 | $data['format_source'] = 'boatbeaconapp'; |
553 | 758 | $data['id_source'] = $id_source; |
554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
759 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
760 | + $data['noarchive'] = true; |
|
761 | + } |
|
555 | 762 | $MI->add($data); |
556 | 763 | unset($data); |
557 | 764 | } |
@@ -567,22 +774,44 @@ discard block |
||
567 | 774 | if (isset($all_data['features'][0]['id'])) { |
568 | 775 | foreach ($all_data['features'] as $line) { |
569 | 776 | $data = array(); |
570 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
571 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
572 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
573 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
574 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
575 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
777 | + if (isset($line['properties']['name'])) { |
|
778 | + $data['ident'] = $line['properties']['name']; |
|
779 | + } |
|
780 | + if (isset($line['properties']['callsign'])) { |
|
781 | + $data['callsign'] = $line['properties']['callsign']; |
|
782 | + } |
|
783 | + if (isset($line['properties']['mmsi'])) { |
|
784 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
785 | + } |
|
786 | + if (isset($line['properties']['imo'])) { |
|
787 | + $data['mmsi'] = $line['properties']['imo']; |
|
788 | + } |
|
789 | + if (isset($line['properties']['speed'])) { |
|
790 | + $data['speed'] = $line['properties']['speed']; |
|
791 | + } |
|
792 | + if (isset($line['properties']['heading'])) { |
|
793 | + $data['heading'] = $line['properties']['heading']; |
|
794 | + } |
|
576 | 795 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
577 | 796 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
578 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
579 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
580 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
797 | + if (isset($line['properties']['vesselType'])) { |
|
798 | + $data['type'] = $line['properties']['vesselType']; |
|
799 | + } |
|
800 | + if (isset($line['properties']['destination'])) { |
|
801 | + $data['arrival_code'] = $line['properties']['destination']; |
|
802 | + } |
|
803 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
804 | + $data['arrival_date'] = $line['properties']['eta']; |
|
805 | + } |
|
581 | 806 | $data['format_source'] = 'boatnerd'; |
582 | 807 | $data['id_source'] = $id_source; |
583 | 808 | $data['datetime'] = date('Y-m-d H:i:s'); |
584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
585 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
809 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
810 | + $data['noarchive'] = true; |
|
811 | + } |
|
812 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
813 | + $MI->add($data); |
|
814 | + } |
|
586 | 815 | unset($data); |
587 | 816 | } |
588 | 817 | } |
@@ -593,7 +822,9 @@ discard block |
||
593 | 822 | echo 'download...'; |
594 | 823 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
595 | 824 | echo 'done !'."\n"; |
596 | - if ($buffer != '') $reset = 0; |
|
825 | + if ($buffer != '') { |
|
826 | + $reset = 0; |
|
827 | + } |
|
597 | 828 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
598 | 829 | $buffer = explode('\n',$buffer); |
599 | 830 | foreach ($buffer as $line) { |
@@ -618,7 +849,9 @@ discard block |
||
618 | 849 | //$data['etaTime'] = substr($line,135,5); |
619 | 850 | $data['format_source'] = 'shipplotter'; |
620 | 851 | $data['id_source'] = $id_source; |
621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
852 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
853 | + $data['noarchive'] = true; |
|
854 | + } |
|
622 | 855 | //print_r($data); |
623 | 856 | echo 'Add...'."\n"; |
624 | 857 | $MI->add($data); |
@@ -638,16 +871,28 @@ discard block |
||
638 | 871 | $line = explode(':', $line); |
639 | 872 | if (count($line) > 30 && $line[0] != 'callsign') { |
640 | 873 | $data = array(); |
641 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
642 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
874 | + if (isset($line[37]) && $line[37] != '') { |
|
875 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
876 | + } else { |
|
877 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
878 | + } |
|
643 | 879 | $data['pilot_id'] = $line[1]; |
644 | 880 | $data['pilot_name'] = $line[2]; |
645 | 881 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
646 | 882 | $data['ident'] = $line[0]; // ident |
647 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
883 | + if ($line[7] != '' && $line[7] != 0) { |
|
884 | + $data['altitude'] = $line[7]; |
|
885 | + } |
|
886 | + // altitude |
|
648 | 887 | $data['speed'] = $line[8]; // speed |
649 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
650 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
888 | + if (isset($line[45])) { |
|
889 | + $data['heading'] = $line[45]; |
|
890 | + } |
|
891 | + // heading |
|
892 | + elseif (isset($line[38])) { |
|
893 | + $data['heading'] = $line[38]; |
|
894 | + } |
|
895 | + // heading |
|
651 | 896 | $data['latitude'] = $line[5]; // lat |
652 | 897 | $data['longitude'] = $line[6]; // long |
653 | 898 | $data['verticalrate'] = ''; // vertical rate |
@@ -663,7 +908,9 @@ discard block |
||
663 | 908 | $data['frequency'] = $line[4]; |
664 | 909 | $data['type'] = $line[18]; |
665 | 910 | $data['range'] = $line[19]; |
666 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
911 | + if (isset($line[35])) { |
|
912 | + $data['info'] = $line[35]; |
|
913 | + } |
|
667 | 914 | $data['id_source'] = $id_source; |
668 | 915 | //$data['arrival_airport_time'] = ; |
669 | 916 | if ($line[9] != '') { |
@@ -677,27 +924,47 @@ discard block |
||
677 | 924 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
678 | 925 | */ |
679 | 926 | $data['format_source'] = $value['format']; |
680 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
681 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
682 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
683 | - elseif ($line[3] == 'ATC') { |
|
927 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
928 | + $data['noarchive'] = true; |
|
929 | + } |
|
930 | + if (isset($value['name']) && $value['name'] != '') { |
|
931 | + $data['source_name'] = $value['name']; |
|
932 | + } |
|
933 | + if ($line[3] == 'PILOT') { |
|
934 | + $SI->add($data); |
|
935 | + } elseif ($line[3] == 'ATC') { |
|
684 | 936 | //print_r($data); |
685 | 937 | $data['info'] = str_replace('^§','<br />',$data['info']); |
686 | 938 | $data['info'] = str_replace('&sect;','',$data['info']); |
687 | 939 | $typec = substr($data['ident'],-3); |
688 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
689 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
690 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
691 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
692 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
693 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
694 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
695 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
696 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
697 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
940 | + if ($typec == 'APP') { |
|
941 | + $data['type'] = 'Approach'; |
|
942 | + } elseif ($typec == 'TWR') { |
|
943 | + $data['type'] = 'Tower'; |
|
944 | + } elseif ($typec == 'OBS') { |
|
945 | + $data['type'] = 'Observer'; |
|
946 | + } elseif ($typec == 'GND') { |
|
947 | + $data['type'] = 'Ground'; |
|
948 | + } elseif ($typec == 'DEL') { |
|
949 | + $data['type'] = 'Delivery'; |
|
950 | + } elseif ($typec == 'DEP') { |
|
951 | + $data['type'] = 'Departure'; |
|
952 | + } elseif ($typec == 'FSS') { |
|
953 | + $data['type'] = 'Flight Service Station'; |
|
954 | + } elseif ($typec == 'CTR') { |
|
955 | + $data['type'] = 'Control Radar or Centre'; |
|
956 | + } elseif ($data['type'] == '') { |
|
957 | + $data['type'] = 'Observer'; |
|
958 | + } |
|
959 | + if (!isset($data['source_name'])) { |
|
960 | + $data['source_name'] = ''; |
|
961 | + } |
|
698 | 962 | if (isset($ATC)) { |
699 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
700 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
963 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
964 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
965 | + } else { |
|
966 | + 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']); |
|
967 | + } |
|
701 | 968 | } |
702 | 969 | } |
703 | 970 | unset($data); |
@@ -719,13 +986,19 @@ discard block |
||
719 | 986 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
720 | 987 | $data['latitude'] = (float)$line['pktLatitude']; |
721 | 988 | $data['longitude'] = (float)$line['pktLongitude']; |
722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
989 | + if ((float)$line['pktTrack'] != 0) { |
|
990 | + $data['heading'] = (float)$line['pktTrack']; |
|
991 | + } |
|
992 | + if ((int)$line['pktSpeed'] != 0) { |
|
993 | + $data['speed'] = (int)$line['pktSpeed']; |
|
994 | + } |
|
724 | 995 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
725 | 996 | $data['pilot_id'] = (int)$line['pktPilotID']; |
726 | 997 | $data['aircraft_icao'] = 'PARAGLIDER'; |
727 | 998 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
728 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
999 | + if (isset($pilot_data[4])) { |
|
1000 | + $data['pilot_name'] = $pilot_data[4]; |
|
1001 | + } |
|
729 | 1002 | $data['format_source'] = $value['format']; |
730 | 1003 | $SI->add($data); |
731 | 1004 | unset($data); |
@@ -761,27 +1034,61 @@ discard block |
||
761 | 1034 | foreach ($all_data['acList'] as $line) { |
762 | 1035 | $data = array(); |
763 | 1036 | $data['hex'] = $line['Icao']; // hex |
764 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
765 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
766 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
767 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
768 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
769 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1037 | + if (isset($line['Call'])) { |
|
1038 | + $data['ident'] = $line['Call']; |
|
1039 | + } |
|
1040 | + // ident |
|
1041 | + if (isset($line['Alt'])) { |
|
1042 | + $data['altitude'] = $line['Alt']; |
|
1043 | + } |
|
1044 | + // altitude |
|
1045 | + if (isset($line['Spd'])) { |
|
1046 | + $data['speed'] = $line['Spd']; |
|
1047 | + } |
|
1048 | + // speed |
|
1049 | + if (isset($line['Trak'])) { |
|
1050 | + $data['heading'] = $line['Trak']; |
|
1051 | + } |
|
1052 | + // heading |
|
1053 | + if (isset($line['Lat'])) { |
|
1054 | + $data['latitude'] = $line['Lat']; |
|
1055 | + } |
|
1056 | + // lat |
|
1057 | + if (isset($line['Long'])) { |
|
1058 | + $data['longitude'] = $line['Long']; |
|
1059 | + } |
|
1060 | + // long |
|
770 | 1061 | //$data['verticalrate'] = $line['']; // verticale rate |
771 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1062 | + if (isset($line['Sqk'])) { |
|
1063 | + $data['squawk'] = $line['Sqk']; |
|
1064 | + } |
|
1065 | + // squawk |
|
772 | 1066 | $data['emergency'] = ''; // emergency |
773 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1067 | + if (isset($line['Reg'])) { |
|
1068 | + $data['registration'] = $line['Reg']; |
|
1069 | + } |
|
774 | 1070 | |
775 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
776 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1071 | + if (isset($line['PosTime'])) { |
|
1072 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1073 | + } else { |
|
1074 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1075 | + } |
|
777 | 1076 | |
778 | 1077 | //$data['datetime'] = date('Y-m-d H:i:s'); |
779 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1078 | + if (isset($line['Type'])) { |
|
1079 | + $data['aircraft_icao'] = $line['Type']; |
|
1080 | + } |
|
780 | 1081 | $data['format_source'] = 'aircraftlistjson'; |
781 | 1082 | $data['id_source'] = $id_source; |
782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
783 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
784 | - if (isset($data['latitude'])) $SI->add($data); |
|
1083 | + if (isset($value['name']) && $value['name'] != '') { |
|
1084 | + $data['source_name'] = $value['name']; |
|
1085 | + } |
|
1086 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1087 | + $data['noarchive'] = true; |
|
1088 | + } |
|
1089 | + if (isset($data['latitude'])) { |
|
1090 | + $SI->add($data); |
|
1091 | + } |
|
785 | 1092 | unset($data); |
786 | 1093 | } |
787 | 1094 | } elseif (is_array($all_data)) { |
@@ -798,12 +1105,19 @@ discard block |
||
798 | 1105 | $data['verticalrate'] = $line['vrt']; // verticale rate |
799 | 1106 | $data['squawk'] = $line['squawk']; // squawk |
800 | 1107 | $data['emergency'] = ''; // emergency |
801 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
802 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1108 | + if (isset($line['PosTime'])) { |
|
1109 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1110 | + } else { |
|
1111 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1112 | + } |
|
803 | 1113 | $data['format_source'] = 'aircraftlistjson'; |
804 | 1114 | $data['id_source'] = $id_source; |
805 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
806 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1115 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1116 | + $data['noarchive'] = true; |
|
1117 | + } |
|
1118 | + if (isset($value['name']) && $value['name'] != '') { |
|
1119 | + $data['source_name'] = $value['name']; |
|
1120 | + } |
|
807 | 1121 | $SI->add($data); |
808 | 1122 | unset($data); |
809 | 1123 | } |
@@ -839,8 +1153,12 @@ discard block |
||
839 | 1153 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
840 | 1154 | $data['format_source'] = 'planeupdatefaa'; |
841 | 1155 | $data['id_source'] = $id_source; |
842 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
843 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1156 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1157 | + $data['noarchive'] = true; |
|
1158 | + } |
|
1159 | + if (isset($value['name']) && $value['name'] != '') { |
|
1160 | + $data['source_name'] = $value['name']; |
|
1161 | + } |
|
844 | 1162 | $SI->add($data); |
845 | 1163 | unset($data); |
846 | 1164 | } |
@@ -869,7 +1187,9 @@ discard block |
||
869 | 1187 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
870 | 1188 | $data['format_source'] = 'opensky'; |
871 | 1189 | $data['id_source'] = $id_source; |
872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1190 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1191 | + $data['noarchive'] = true; |
|
1192 | + } |
|
873 | 1193 | $SI->add($data); |
874 | 1194 | unset($data); |
875 | 1195 | } |
@@ -881,7 +1201,9 @@ discard block |
||
881 | 1201 | //$buffer = $Common->getData($hosts[$id]); |
882 | 1202 | $buffer = $Common->getData($value['host']); |
883 | 1203 | $all_data = json_decode($buffer,true); |
884 | - if (!empty($all_data)) $reset = 0; |
|
1204 | + if (!empty($all_data)) { |
|
1205 | + $reset = 0; |
|
1206 | + } |
|
885 | 1207 | foreach ($all_data as $key => $line) { |
886 | 1208 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
887 | 1209 | $data = array(); |
@@ -902,8 +1224,12 @@ discard block |
||
902 | 1224 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
903 | 1225 | $data['format_source'] = 'fr24json'; |
904 | 1226 | $data['id_source'] = $id_source; |
905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1227 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1228 | + $data['noarchive'] = true; |
|
1229 | + } |
|
1230 | + if (isset($value['name']) && $value['name'] != '') { |
|
1231 | + $data['source_name'] = $value['name']; |
|
1232 | + } |
|
907 | 1233 | $SI->add($data); |
908 | 1234 | unset($data); |
909 | 1235 | } |
@@ -927,24 +1253,42 @@ discard block |
||
927 | 1253 | if (isset($line['inf'])) { |
928 | 1254 | $data = array(); |
929 | 1255 | $data['hex'] = $line['inf']['ia']; |
930 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1256 | + if (isset($line['inf']['cs'])) { |
|
1257 | + $data['ident'] = $line['inf']['cs']; |
|
1258 | + } |
|
1259 | + //$line[13] |
|
931 | 1260 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
932 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
933 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1261 | + if (isset($line['inf']['gs'])) { |
|
1262 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1263 | + } |
|
1264 | + // speed |
|
1265 | + if (isset($line['inf']['tr'])) { |
|
1266 | + $data['heading'] = $line['inf']['tr']; |
|
1267 | + } |
|
1268 | + // heading |
|
934 | 1269 | $data['latitude'] = $line['pt'][0]; // lat |
935 | 1270 | $data['longitude'] = $line['pt'][1]; // long |
936 | 1271 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
937 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1272 | + if (isset($line['inf']['sq'])) { |
|
1273 | + $data['squawk'] = $line['inf']['sq']; |
|
1274 | + } |
|
1275 | + // squawk |
|
938 | 1276 | //$data['aircraft_icao'] = $line[8]; |
939 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1277 | + if (isset($line['inf']['rc'])) { |
|
1278 | + $data['registration'] = $line['inf']['rc']; |
|
1279 | + } |
|
940 | 1280 | //$data['departure_airport_iata'] = $line[11]; |
941 | 1281 | //$data['arrival_airport_iata'] = $line[12]; |
942 | 1282 | //$data['emergency'] = ''; // emergency |
943 | 1283 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
944 | 1284 | $data['format_source'] = 'radarvirtueljson'; |
945 | 1285 | $data['id_source'] = $id_source; |
946 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1286 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1287 | + $data['noarchive'] = true; |
|
1288 | + } |
|
1289 | + if (isset($value['name']) && $value['name'] != '') { |
|
1290 | + $data['source_name'] = $value['name']; |
|
1291 | + } |
|
948 | 1292 | $SI->add($data); |
949 | 1293 | unset($data); |
950 | 1294 | } |
@@ -965,30 +1309,65 @@ discard block |
||
965 | 1309 | $data['id'] = $line['id']; |
966 | 1310 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
967 | 1311 | $data['ident'] = $line['callsign']; // ident |
968 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
969 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
970 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
971 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
972 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
973 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1312 | + if (isset($line['pilotid'])) { |
|
1313 | + $data['pilot_id'] = $line['pilotid']; |
|
1314 | + } |
|
1315 | + // pilot id |
|
1316 | + if (isset($line['name'])) { |
|
1317 | + $data['pilot_name'] = $line['name']; |
|
1318 | + } |
|
1319 | + // pilot name |
|
1320 | + if (isset($line['alt'])) { |
|
1321 | + $data['altitude'] = $line['alt']; |
|
1322 | + } |
|
1323 | + // altitude |
|
1324 | + if (isset($line['gs'])) { |
|
1325 | + $data['speed'] = $line['gs']; |
|
1326 | + } |
|
1327 | + // speed |
|
1328 | + if (isset($line['heading'])) { |
|
1329 | + $data['heading'] = $line['heading']; |
|
1330 | + } |
|
1331 | + // heading |
|
1332 | + if (isset($line['route'])) { |
|
1333 | + $data['waypoints'] = $line['route']; |
|
1334 | + } |
|
1335 | + // route |
|
974 | 1336 | $data['latitude'] = $line['lat']; // lat |
975 | 1337 | $data['longitude'] = $line['lon']; // long |
976 | 1338 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
977 | 1339 | //$data['squawk'] = $line['squawk']; // squawk |
978 | 1340 | //$data['emergency'] = ''; // emergency |
979 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
980 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
981 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1341 | + if (isset($line['depicao'])) { |
|
1342 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1343 | + } |
|
1344 | + if (isset($line['deptime'])) { |
|
1345 | + $data['departure_airport_time'] = $line['deptime']; |
|
1346 | + } |
|
1347 | + if (isset($line['arricao'])) { |
|
1348 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1349 | + } |
|
982 | 1350 | //$data['arrival_airport_time'] = $line['arrtime']; |
983 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
984 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
985 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
986 | - else $data['info'] = ''; |
|
1351 | + if (isset($line['aircraft'])) { |
|
1352 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1353 | + } |
|
1354 | + if (isset($line['transponder'])) { |
|
1355 | + $data['squawk'] = $line['transponder']; |
|
1356 | + } |
|
1357 | + if (isset($line['atis'])) { |
|
1358 | + $data['info'] = $line['atis']; |
|
1359 | + } else { |
|
1360 | + $data['info'] = ''; |
|
1361 | + } |
|
987 | 1362 | $data['format_source'] = 'pireps'; |
988 | 1363 | $data['id_source'] = $id_source; |
989 | 1364 | $data['datetime'] = date('Y-m-d H:i:s'); |
990 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
991 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1365 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1366 | + $data['noarchive'] = true; |
|
1367 | + } |
|
1368 | + if (isset($value['name']) && $value['name'] != '') { |
|
1369 | + $data['source_name'] = $value['name']; |
|
1370 | + } |
|
992 | 1371 | if ($line['icon'] == 'plane') { |
993 | 1372 | $SI->add($data); |
994 | 1373 | // print_r($data); |
@@ -997,16 +1376,28 @@ discard block |
||
997 | 1376 | $data['info'] = str_replace('&sect;','',$data['info']); |
998 | 1377 | $typec = substr($data['ident'],-3); |
999 | 1378 | $data['type'] = ''; |
1000 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
1001 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
1002 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
1003 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
1004 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
1005 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
1006 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
1007 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1008 | - else $data['type'] = 'Observer'; |
|
1009 | - 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']); |
|
1379 | + if ($typec == 'APP') { |
|
1380 | + $data['type'] = 'Approach'; |
|
1381 | + } elseif ($typec == 'TWR') { |
|
1382 | + $data['type'] = 'Tower'; |
|
1383 | + } elseif ($typec == 'OBS') { |
|
1384 | + $data['type'] = 'Observer'; |
|
1385 | + } elseif ($typec == 'GND') { |
|
1386 | + $data['type'] = 'Ground'; |
|
1387 | + } elseif ($typec == 'DEL') { |
|
1388 | + $data['type'] = 'Delivery'; |
|
1389 | + } elseif ($typec == 'DEP') { |
|
1390 | + $data['type'] = 'Departure'; |
|
1391 | + } elseif ($typec == 'FSS') { |
|
1392 | + $data['type'] = 'Flight Service Station'; |
|
1393 | + } elseif ($typec == 'CTR') { |
|
1394 | + $data['type'] = 'Control Radar or Centre'; |
|
1395 | + } else { |
|
1396 | + $data['type'] = 'Observer'; |
|
1397 | + } |
|
1398 | + if (isset($ATC)) { |
|
1399 | + 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']); |
|
1400 | + } |
|
1010 | 1401 | } |
1011 | 1402 | unset($data); |
1012 | 1403 | } |
@@ -1016,7 +1407,9 @@ discard block |
||
1016 | 1407 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1017 | 1408 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
1018 | 1409 | //$buffer = $Common->getData($hosts[$id]); |
1019 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1410 | + if ($globalDebug) { |
|
1411 | + echo 'Get Data...'."\n"; |
|
1412 | + } |
|
1020 | 1413 | $buffer = $Common->getData($value['host']); |
1021 | 1414 | $all_data = json_decode($buffer,true); |
1022 | 1415 | if ($buffer != '' && is_array($all_data)) { |
@@ -1024,10 +1417,16 @@ discard block |
||
1024 | 1417 | foreach ($all_data as $line) { |
1025 | 1418 | $data = array(); |
1026 | 1419 | //$data['id'] = $line['id']; // id not usable |
1027 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1420 | + if (isset($line['pilotid'])) { |
|
1421 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1422 | + } |
|
1028 | 1423 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1029 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1030 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1424 | + if (isset($line['pilotname'])) { |
|
1425 | + $data['pilot_name'] = $line['pilotname']; |
|
1426 | + } |
|
1427 | + if (isset($line['pilotid'])) { |
|
1428 | + $data['pilot_id'] = $line['pilotid']; |
|
1429 | + } |
|
1031 | 1430 | $data['ident'] = $line['flightnum']; // ident |
1032 | 1431 | $data['altitude'] = $line['alt']; // altitude |
1033 | 1432 | $data['speed'] = $line['gs']; // speed |
@@ -1043,34 +1442,52 @@ discard block |
||
1043 | 1442 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1044 | 1443 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1045 | 1444 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1046 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1445 | + } else { |
|
1446 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1447 | + } |
|
1047 | 1448 | $data['departure_airport_icao'] = $line['depicao']; |
1048 | 1449 | $data['departure_airport_time'] = $line['deptime']; |
1049 | 1450 | $data['arrival_airport_icao'] = $line['arricao']; |
1050 | 1451 | $data['arrival_airport_time'] = $line['arrtime']; |
1051 | 1452 | $data['registration'] = $line['aircraft']; |
1052 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1053 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1453 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1454 | + $data['noarchive'] = true; |
|
1455 | + } |
|
1456 | + if (isset($line['route'])) { |
|
1457 | + $data['waypoints'] = $line['route']; |
|
1458 | + } |
|
1459 | + // route |
|
1054 | 1460 | if (isset($line['aircraftname'])) { |
1055 | 1461 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1056 | 1462 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1057 | 1463 | $aircraft_data = explode('-',$line['aircraftname']); |
1058 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1059 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1060 | - else { |
|
1464 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1465 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1466 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1467 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1468 | + } else { |
|
1061 | 1469 | $aircraft_data = explode(' ',$line['aircraftname']); |
1062 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1063 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1470 | + if (isset($aircraft_data[1])) { |
|
1471 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1472 | + } else { |
|
1473 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1474 | + } |
|
1064 | 1475 | } |
1065 | 1476 | } |
1066 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1477 | + if (isset($line['route'])) { |
|
1478 | + $data['waypoints'] = $line['route']; |
|
1479 | + } |
|
1067 | 1480 | $data['id_source'] = $id_source; |
1068 | 1481 | $data['format_source'] = 'phpvmacars'; |
1069 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1482 | + if (isset($value['name']) && $value['name'] != '') { |
|
1483 | + $data['source_name'] = $value['name']; |
|
1484 | + } |
|
1070 | 1485 | $SI->add($data); |
1071 | 1486 | unset($data); |
1072 | 1487 | } |
1073 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1488 | + if ($globalDebug) { |
|
1489 | + echo 'No more data...'."\n"; |
|
1490 | + } |
|
1074 | 1491 | unset($buffer); |
1075 | 1492 | unset($all_data); |
1076 | 1493 | } |
@@ -1078,7 +1495,9 @@ discard block |
||
1078 | 1495 | $last_exec[$id]['last'] = time(); |
1079 | 1496 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
1080 | 1497 | //$buffer = $Common->getData($hosts[$id]); |
1081 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1498 | + if ($globalDebug) { |
|
1499 | + echo 'Get Data...'."\n"; |
|
1500 | + } |
|
1082 | 1501 | $buffer = $Common->getData($value['host']); |
1083 | 1502 | $all_data = json_decode($buffer,true); |
1084 | 1503 | if ($buffer != '' && is_array($all_data)) { |
@@ -1107,16 +1526,25 @@ discard block |
||
1107 | 1526 | $data['arrival_airport_icao'] = $line['arrival']; |
1108 | 1527 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1109 | 1528 | //$data['registration'] = $line['aircraft']; |
1110 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1529 | + if (isset($line['route'])) { |
|
1530 | + $data['waypoints'] = $line['route']; |
|
1531 | + } |
|
1532 | + // route |
|
1111 | 1533 | $data['aircraft_icao'] = $line['plane_type']; |
1112 | 1534 | $data['id_source'] = $id_source; |
1113 | 1535 | $data['format_source'] = 'vam'; |
1114 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1115 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1536 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1537 | + $data['noarchive'] = true; |
|
1538 | + } |
|
1539 | + if (isset($value['name']) && $value['name'] != '') { |
|
1540 | + $data['source_name'] = $value['name']; |
|
1541 | + } |
|
1116 | 1542 | $SI->add($data); |
1117 | 1543 | unset($data); |
1118 | 1544 | } |
1119 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1545 | + if ($globalDebug) { |
|
1546 | + echo 'No more data...'."\n"; |
|
1547 | + } |
|
1120 | 1548 | unset($buffer); |
1121 | 1549 | unset($all_data); |
1122 | 1550 | } |
@@ -1124,7 +1552,9 @@ discard block |
||
1124 | 1552 | $last_exec[$id]['last'] = time(); |
1125 | 1553 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1126 | 1554 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1127 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1555 | + if (function_exists('pcntl_fork')) { |
|
1556 | + pcntl_signal_dispatch(); |
|
1557 | + } |
|
1128 | 1558 | //$last_exec[$id]['last'] = time(); |
1129 | 1559 | |
1130 | 1560 | //$read = array( $sockets[$id] ); |
@@ -1132,7 +1562,9 @@ discard block |
||
1132 | 1562 | $write = NULL; |
1133 | 1563 | $e = NULL; |
1134 | 1564 | $n = socket_select($read, $write, $e, $timeout); |
1135 | - if ($e != NULL) var_dump($e); |
|
1565 | + if ($e != NULL) { |
|
1566 | + var_dump($e); |
|
1567 | + } |
|
1136 | 1568 | if ($n > 0) { |
1137 | 1569 | $reset = 0; |
1138 | 1570 | foreach ($read as $nb => $r) { |
@@ -1153,12 +1585,16 @@ discard block |
||
1153 | 1585 | //$SI::del(); |
1154 | 1586 | if ($format == 'vrstcp') { |
1155 | 1587 | $buffer = explode('},{',$buffer); |
1156 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1588 | + } else { |
|
1589 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1590 | + } |
|
1157 | 1591 | // SBS format is CSV format |
1158 | 1592 | if ($buffer !== FALSE && $buffer != '') { |
1159 | 1593 | $tt[$format] = 0; |
1160 | 1594 | if ($format == 'acarssbs3') { |
1161 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1595 | + if ($globalDebug) { |
|
1596 | + echo 'ACARS : '.$buffer."\n"; |
|
1597 | + } |
|
1162 | 1598 | $ACARS->add(trim($buffer)); |
1163 | 1599 | $ACARS->deleteLiveAcarsData(); |
1164 | 1600 | } elseif ($format == 'raw') { |
@@ -1167,30 +1603,70 @@ discard block |
||
1167 | 1603 | if (is_array($data)) { |
1168 | 1604 | $data['datetime'] = date('Y-m-d H:i:s'); |
1169 | 1605 | $data['format_source'] = 'raw'; |
1170 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1171 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1172 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1173 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1606 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1607 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1608 | + } |
|
1609 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1610 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1611 | + } |
|
1612 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1613 | + $data['noarchive'] = true; |
|
1614 | + } |
|
1615 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1616 | + $SI->add($data); |
|
1617 | + } |
|
1174 | 1618 | } |
1175 | 1619 | } elseif ($format == 'ais') { |
1176 | 1620 | $ais_data = $AIS->parse_line(trim($buffer)); |
1177 | 1621 | $data = array(); |
1178 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1179 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1180 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1181 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1182 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1183 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1184 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1185 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1186 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1187 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1188 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1189 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1190 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1191 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1192 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1193 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1622 | + if (isset($ais_data['ident'])) { |
|
1623 | + $data['ident'] = $ais_data['ident']; |
|
1624 | + } |
|
1625 | + if (isset($ais_data['mmsi'])) { |
|
1626 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1627 | + } |
|
1628 | + if (isset($ais_data['speed'])) { |
|
1629 | + $data['speed'] = $ais_data['speed']; |
|
1630 | + } |
|
1631 | + if (isset($ais_data['heading'])) { |
|
1632 | + $data['heading'] = $ais_data['heading']; |
|
1633 | + } |
|
1634 | + if (isset($ais_data['latitude'])) { |
|
1635 | + $data['latitude'] = $ais_data['latitude']; |
|
1636 | + } |
|
1637 | + if (isset($ais_data['longitude'])) { |
|
1638 | + $data['longitude'] = $ais_data['longitude']; |
|
1639 | + } |
|
1640 | + if (isset($ais_data['status'])) { |
|
1641 | + $data['status'] = $ais_data['status']; |
|
1642 | + } |
|
1643 | + if (isset($ais_data['statusid'])) { |
|
1644 | + $data['status_id'] = $ais_data['statusid']; |
|
1645 | + } |
|
1646 | + if (isset($ais_data['type'])) { |
|
1647 | + $data['type'] = $ais_data['type']; |
|
1648 | + } |
|
1649 | + if (isset($ais_data['imo'])) { |
|
1650 | + $data['imo'] = $ais_data['imo']; |
|
1651 | + } |
|
1652 | + if (isset($ais_data['callsign'])) { |
|
1653 | + $data['callsign'] = $ais_data['callsign']; |
|
1654 | + } |
|
1655 | + if (isset($ais_data['destination'])) { |
|
1656 | + $data['arrival_code'] = $ais_data['destination']; |
|
1657 | + } |
|
1658 | + if (isset($ais_data['eta_ts'])) { |
|
1659 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1660 | + } |
|
1661 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1662 | + $data['noarchive'] = true; |
|
1663 | + } |
|
1664 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1665 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1666 | + } |
|
1667 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1668 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1669 | + } |
|
1194 | 1670 | |
1195 | 1671 | if (isset($ais_data['timestamp'])) { |
1196 | 1672 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1199,7 +1675,9 @@ discard block |
||
1199 | 1675 | } |
1200 | 1676 | $data['format_source'] = 'aisnmea'; |
1201 | 1677 | $data['id_source'] = $id_source; |
1202 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1678 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1679 | + $MI->add($data); |
|
1680 | + } |
|
1203 | 1681 | unset($data); |
1204 | 1682 | } elseif ($format == 'flightgearsp') { |
1205 | 1683 | //echo $buffer."\n"; |
@@ -1217,12 +1695,18 @@ discard block |
||
1217 | 1695 | $data['speed'] = round($line[5]*1.94384); |
1218 | 1696 | $data['datetime'] = date('Y-m-d H:i:s'); |
1219 | 1697 | $data['format_source'] = 'flightgearsp'; |
1220 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1698 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1699 | + $data['noarchive'] = true; |
|
1700 | + } |
|
1701 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1702 | + $SI->add($data); |
|
1703 | + } |
|
1222 | 1704 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1223 | 1705 | } |
1224 | 1706 | } elseif ($format == 'acars') { |
1225 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1707 | + if ($globalDebug) { |
|
1708 | + echo 'ACARS : '.$buffer."\n"; |
|
1709 | + } |
|
1226 | 1710 | $ACARS->add(trim($buffer)); |
1227 | 1711 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1228 | 1712 | $ACARS->deleteLiveAcarsData(); |
@@ -1243,8 +1727,12 @@ discard block |
||
1243 | 1727 | $aircraft_type = $line[10]; |
1244 | 1728 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1245 | 1729 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1246 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1247 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1730 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1731 | + $data['noarchive'] = true; |
|
1732 | + } |
|
1733 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1734 | + $SI->add($data); |
|
1735 | + } |
|
1248 | 1736 | } |
1249 | 1737 | } |
1250 | 1738 | } elseif ($format == 'beast') { |
@@ -1254,28 +1742,62 @@ discard block |
||
1254 | 1742 | foreach($buffer as $all_data) { |
1255 | 1743 | $line = json_decode('{'.$all_data.'}',true); |
1256 | 1744 | $data = array(); |
1257 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1258 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1259 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1260 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1261 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1262 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1263 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1745 | + if (isset($line['Icao'])) { |
|
1746 | + $data['hex'] = $line['Icao']; |
|
1747 | + } |
|
1748 | + // hex |
|
1749 | + if (isset($line['Call'])) { |
|
1750 | + $data['ident'] = $line['Call']; |
|
1751 | + } |
|
1752 | + // ident |
|
1753 | + if (isset($line['Alt'])) { |
|
1754 | + $data['altitude'] = $line['Alt']; |
|
1755 | + } |
|
1756 | + // altitude |
|
1757 | + if (isset($line['Spd'])) { |
|
1758 | + $data['speed'] = $line['Spd']; |
|
1759 | + } |
|
1760 | + // speed |
|
1761 | + if (isset($line['Trak'])) { |
|
1762 | + $data['heading'] = $line['Trak']; |
|
1763 | + } |
|
1764 | + // heading |
|
1765 | + if (isset($line['Lat'])) { |
|
1766 | + $data['latitude'] = $line['Lat']; |
|
1767 | + } |
|
1768 | + // lat |
|
1769 | + if (isset($line['Long'])) { |
|
1770 | + $data['longitude'] = $line['Long']; |
|
1771 | + } |
|
1772 | + // long |
|
1264 | 1773 | //$data['verticalrate'] = $line['']; // verticale rate |
1265 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1774 | + if (isset($line['Sqk'])) { |
|
1775 | + $data['squawk'] = $line['Sqk']; |
|
1776 | + } |
|
1777 | + // squawk |
|
1266 | 1778 | $data['emergency'] = ''; // emergency |
1267 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1779 | + if (isset($line['Reg'])) { |
|
1780 | + $data['registration'] = $line['Reg']; |
|
1781 | + } |
|
1268 | 1782 | /* |
1269 | 1783 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1270 | 1784 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1271 | 1785 | */ |
1272 | 1786 | $data['datetime'] = date('Y-m-d H:i:s'); |
1273 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1787 | + if (isset($line['Type'])) { |
|
1788 | + $data['aircraft_icao'] = $line['Type']; |
|
1789 | + } |
|
1274 | 1790 | $data['format_source'] = 'vrstcp'; |
1275 | 1791 | $data['id_source'] = $id_source; |
1276 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1277 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1278 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1792 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1793 | + $data['noarchive'] = true; |
|
1794 | + } |
|
1795 | + if (isset($value['name']) && $value['name'] != '') { |
|
1796 | + $data['source_name'] = $value['name']; |
|
1797 | + } |
|
1798 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1799 | + $SI->add($data); |
|
1800 | + } |
|
1279 | 1801 | unset($data); |
1280 | 1802 | } |
1281 | 1803 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1288,22 +1810,46 @@ discard block |
||
1288 | 1810 | $data['hex'] = $lined['hexid']; |
1289 | 1811 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1290 | 1812 | $data['datetime'] = date('Y-m-d H:i:s');; |
1291 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1292 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1293 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1294 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1295 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1296 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1297 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1813 | + if (isset($lined['ident'])) { |
|
1814 | + $data['ident'] = $lined['ident']; |
|
1815 | + } |
|
1816 | + if (isset($lined['lat'])) { |
|
1817 | + $data['latitude'] = $lined['lat']; |
|
1818 | + } |
|
1819 | + if (isset($lined['lon'])) { |
|
1820 | + $data['longitude'] = $lined['lon']; |
|
1821 | + } |
|
1822 | + if (isset($lined['speed'])) { |
|
1823 | + $data['speed'] = $lined['speed']; |
|
1824 | + } |
|
1825 | + if (isset($lined['squawk'])) { |
|
1826 | + $data['squawk'] = $lined['squawk']; |
|
1827 | + } |
|
1828 | + if (isset($lined['alt'])) { |
|
1829 | + $data['altitude'] = $lined['alt']; |
|
1830 | + } |
|
1831 | + if (isset($lined['heading'])) { |
|
1832 | + $data['heading'] = $lined['heading']; |
|
1833 | + } |
|
1298 | 1834 | $data['id_source'] = $id_source; |
1299 | 1835 | $data['format_source'] = 'tsv'; |
1300 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1301 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1302 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1303 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1836 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1837 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1838 | + } |
|
1839 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1840 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1841 | + } |
|
1842 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1843 | + $data['noarchive'] = true; |
|
1844 | + } |
|
1845 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1846 | + $SI->add($data); |
|
1847 | + } |
|
1304 | 1848 | unset($lined); |
1305 | 1849 | unset($data); |
1306 | - } else $error = true; |
|
1850 | + } else { |
|
1851 | + $error = true; |
|
1852 | + } |
|
1307 | 1853 | } elseif ($format == 'aprs' && $use_aprs) { |
1308 | 1854 | if ($aprs_connect == 0) { |
1309 | 1855 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1328,41 +1874,88 @@ discard block |
||
1328 | 1874 | $aprs_last_tx = time(); |
1329 | 1875 | $data = array(); |
1330 | 1876 | //print_r($line); |
1331 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1332 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1333 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1334 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1335 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1336 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1337 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1338 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1339 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1340 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1877 | + if (isset($line['address'])) { |
|
1878 | + $data['hex'] = $line['address']; |
|
1879 | + } |
|
1880 | + if (isset($line['mmsi'])) { |
|
1881 | + $data['mmsi'] = $line['mmsi']; |
|
1882 | + } |
|
1883 | + if (isset($line['imo'])) { |
|
1884 | + $data['imo'] = $line['imo']; |
|
1885 | + } |
|
1886 | + if (isset($line['squawk'])) { |
|
1887 | + $data['squawk'] = $line['squawk']; |
|
1888 | + } |
|
1889 | + if (isset($line['arrival_code'])) { |
|
1890 | + $data['arrical_code'] = $line['arrival_code']; |
|
1891 | + } |
|
1892 | + if (isset($line['arrival_date'])) { |
|
1893 | + $data['arrical_date'] = $line['arrival_date']; |
|
1894 | + } |
|
1895 | + if (isset($line['type_id'])) { |
|
1896 | + $data['type_id'] = $line['typeid']; |
|
1897 | + } |
|
1898 | + if (isset($line['status_id'])) { |
|
1899 | + $data['status_id'] = $line['statusid']; |
|
1900 | + } |
|
1901 | + if (isset($line['timestamp'])) { |
|
1902 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1903 | + } else { |
|
1904 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1905 | + } |
|
1341 | 1906 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1342 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1907 | + if (isset($line['ident'])) { |
|
1908 | + $data['ident'] = $line['ident']; |
|
1909 | + } |
|
1343 | 1910 | $data['latitude'] = $line['latitude']; |
1344 | 1911 | $data['longitude'] = $line['longitude']; |
1345 | 1912 | //$data['verticalrate'] = $line[16]; |
1346 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1913 | + if (isset($line['speed'])) { |
|
1914 | + $data['speed'] = $line['speed']; |
|
1915 | + } |
|
1347 | 1916 | //else $data['speed'] = 0; |
1348 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1349 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1350 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1351 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1917 | + if (isset($line['altitude'])) { |
|
1918 | + $data['altitude'] = $line['altitude']; |
|
1919 | + } |
|
1920 | + if (isset($line['comment'])) { |
|
1921 | + $data['comment'] = $line['comment']; |
|
1922 | + } |
|
1923 | + if (isset($line['symbol'])) { |
|
1924 | + $data['type'] = $line['symbol']; |
|
1925 | + } |
|
1926 | + if (isset($line['heading'])) { |
|
1927 | + $data['heading'] = $line['heading']; |
|
1928 | + } |
|
1352 | 1929 | //else $data['heading'] = 0; |
1353 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1930 | + if (isset($line['stealth'])) { |
|
1931 | + $data['aircraft_type'] = $line['stealth']; |
|
1932 | + } |
|
1354 | 1933 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1355 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1356 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1357 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1358 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1934 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
1935 | + $data['noarchive'] = true; |
|
1936 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
1937 | + $data['noarchive'] = false; |
|
1938 | + } |
|
1939 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1940 | + $data['noarchive'] = true; |
|
1941 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
1942 | + $data['noarchive'] = false; |
|
1943 | + } |
|
1359 | 1944 | $data['id_source'] = $id_source; |
1360 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1361 | - else $data['format_source'] = 'aprs'; |
|
1945 | + if (isset($line['format_source'])) { |
|
1946 | + $data['format_source'] = $line['format_source']; |
|
1947 | + } else { |
|
1948 | + $data['format_source'] = 'aprs'; |
|
1949 | + } |
|
1362 | 1950 | $data['source_name'] = $line['source']; |
1363 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1364 | - else $data['source_type'] = 'flarm'; |
|
1365 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1951 | + if (isset($line['source_type'])) { |
|
1952 | + $data['source_type'] = $line['source_type']; |
|
1953 | + } else { |
|
1954 | + $data['source_type'] = 'flarm'; |
|
1955 | + } |
|
1956 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1957 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1958 | + } |
|
1366 | 1959 | $currentdate = date('Y-m-d H:i:s'); |
1367 | 1960 | $aprsdate = strtotime($data['datetime']); |
1368 | 1961 | // Accept data if time <= system time + 20s |
@@ -1370,16 +1963,25 @@ discard block |
||
1370 | 1963 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1371 | 1964 | $send = $SI->add($data); |
1372 | 1965 | } elseif ($data['source_type'] == 'ais') { |
1373 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
1966 | + if (isset($globalMarine) && $globalMarine) { |
|
1967 | + $send = $MI->add($data); |
|
1968 | + } |
|
1374 | 1969 | } elseif (isset($line['stealth'])) { |
1375 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1376 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1970 | + if ($line['stealth'] != 0) { |
|
1971 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1972 | + } else { |
|
1973 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1974 | + } |
|
1377 | 1975 | //} 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')) { |
1378 | 1976 | } 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') { |
1379 | 1977 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1380 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
1978 | + if (isset($globalTracker) && $globalTracker) { |
|
1979 | + $send = $TI->add($data); |
|
1980 | + } |
|
1381 | 1981 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1382 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
1982 | + if (!isset($data['altitude'])) { |
|
1983 | + $data['altitude'] = 0; |
|
1984 | + } |
|
1383 | 1985 | $Source->deleteOldLocationByType('gs'); |
1384 | 1986 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
1385 | 1987 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1391,12 +1993,9 @@ discard block |
||
1391 | 1993 | print_r($line); |
1392 | 1994 | } |
1393 | 1995 | unset($data); |
1394 | - } |
|
1395 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1996 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1396 | 1997 | echo '!! Weather Station not yet supported'."\n"; |
1397 | - } |
|
1398 | - |
|
1399 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1998 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1400 | 1999 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1401 | 2000 | } |
1402 | 2001 | /* |
@@ -1405,7 +2004,9 @@ discard block |
||
1405 | 2004 | } |
1406 | 2005 | */ |
1407 | 2006 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1408 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2007 | + elseif ($line == true && $globalDebug) { |
|
2008 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2009 | + } |
|
1409 | 2010 | } |
1410 | 2011 | } else { |
1411 | 2012 | $line = explode(',', $buffer); |
@@ -1434,26 +2035,45 @@ discard block |
||
1434 | 2035 | $data['ground'] = $line[21]; |
1435 | 2036 | $data['emergency'] = $line[19]; |
1436 | 2037 | $data['format_source'] = 'sbs'; |
1437 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1438 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1439 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2038 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2039 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2040 | + } |
|
2041 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2042 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2043 | + } |
|
2044 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2045 | + $data['noarchive'] = true; |
|
2046 | + } |
|
1440 | 2047 | $data['id_source'] = $id_source; |
1441 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1442 | - else $error = true; |
|
2048 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2049 | + $send = $SI->add($data); |
|
2050 | + } else { |
|
2051 | + $error = true; |
|
2052 | + } |
|
1443 | 2053 | unset($data); |
1444 | - } else $error = true; |
|
2054 | + } else { |
|
2055 | + $error = true; |
|
2056 | + } |
|
1445 | 2057 | if ($error) { |
1446 | 2058 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1447 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2059 | + if ($globalDebug) { |
|
2060 | + echo "Not a message. Ignoring... \n"; |
|
2061 | + } |
|
1448 | 2062 | } else { |
1449 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2063 | + if ($globalDebug) { |
|
2064 | + echo "Wrong line format. Ignoring... \n"; |
|
2065 | + } |
|
1450 | 2066 | if ($globalDebug) { |
1451 | 2067 | echo $buffer; |
1452 | 2068 | //print_r($line); |
1453 | 2069 | } |
1454 | 2070 | //socket_close($r); |
1455 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1456 | - if ($format == 'aprs') $aprs_connect = 0; |
|
2071 | + if ($globalDebug) { |
|
2072 | + echo "Reconnect after an error...\n"; |
|
2073 | + } |
|
2074 | + if ($format == 'aprs') { |
|
2075 | + $aprs_connect = 0; |
|
2076 | + } |
|
1457 | 2077 | $sourceer[$nb] = $globalSources[$nb]; |
1458 | 2078 | connect_all($sourceer); |
1459 | 2079 | $sourceer = array(); |
@@ -1461,10 +2081,14 @@ discard block |
||
1461 | 2081 | } |
1462 | 2082 | } |
1463 | 2083 | // Sleep for xxx microseconds |
1464 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2084 | + if (isset($globalSBSSleep)) { |
|
2085 | + usleep($globalSBSSleep); |
|
2086 | + } |
|
1465 | 2087 | } else { |
1466 | 2088 | if ($format == 'flightgearmp') { |
1467 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2089 | + if ($globalDebug) { |
|
2090 | + echo "Reconnect FlightGear MP..."; |
|
2091 | + } |
|
1468 | 2092 | //@socket_close($r); |
1469 | 2093 | sleep($globalMinFetch); |
1470 | 2094 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1473,10 +2097,15 @@ discard block |
||
1473 | 2097 | break; |
1474 | 2098 | |
1475 | 2099 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1476 | - if (isset($tt[$format])) $tt[$format]++; |
|
1477 | - else $tt[$format] = 0; |
|
2100 | + if (isset($tt[$format])) { |
|
2101 | + $tt[$format]++; |
|
2102 | + } else { |
|
2103 | + $tt[$format] = 0; |
|
2104 | + } |
|
1478 | 2105 | if ($tt[$format] > 30) { |
1479 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2106 | + if ($globalDebug) { |
|
2107 | + echo "ERROR : Reconnect ".$format."..."; |
|
2108 | + } |
|
1480 | 2109 | //@socket_close($r); |
1481 | 2110 | sleep(2); |
1482 | 2111 | $aprs_connect = 0; |
@@ -1493,11 +2122,17 @@ discard block |
||
1493 | 2122 | } else { |
1494 | 2123 | $error = socket_strerror(socket_last_error()); |
1495 | 2124 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1496 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1497 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2125 | + if ($globalDebug) { |
|
2126 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2127 | + } |
|
2128 | + if (isset($globalDebug)) { |
|
2129 | + echo "Restarting...\n"; |
|
2130 | + } |
|
1498 | 2131 | // Restart the script if possible |
1499 | 2132 | if (is_array($sockets)) { |
1500 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2133 | + if ($globalDebug) { |
|
2134 | + echo "Shutdown all sockets..."; |
|
2135 | + } |
|
1501 | 2136 | |
1502 | 2137 | foreach ($sockets as $sock) { |
1503 | 2138 | @socket_shutdown($sock,2); |
@@ -1505,22 +2140,36 @@ discard block |
||
1505 | 2140 | } |
1506 | 2141 | |
1507 | 2142 | } |
1508 | - if ($globalDebug) echo "Waiting..."; |
|
2143 | + if ($globalDebug) { |
|
2144 | + echo "Waiting..."; |
|
2145 | + } |
|
1509 | 2146 | sleep(2); |
1510 | 2147 | $time = time(); |
1511 | 2148 | //connect_all($hosts); |
1512 | 2149 | $aprs_connect = 0; |
1513 | - if ($reset%5 == 0) sleep(20); |
|
1514 | - if ($reset%10 == 0) sleep(100); |
|
1515 | - if ($reset%20 == 0) sleep(200); |
|
1516 | - if ($reset > 100) exit('Too many attempts...'); |
|
1517 | - if ($globalDebug) echo "Restart all connections..."; |
|
2150 | + if ($reset%5 == 0) { |
|
2151 | + sleep(20); |
|
2152 | + } |
|
2153 | + if ($reset%10 == 0) { |
|
2154 | + sleep(100); |
|
2155 | + } |
|
2156 | + if ($reset%20 == 0) { |
|
2157 | + sleep(200); |
|
2158 | + } |
|
2159 | + if ($reset > 100) { |
|
2160 | + exit('Too many attempts...'); |
|
2161 | + } |
|
2162 | + if ($globalDebug) { |
|
2163 | + echo "Restart all connections..."; |
|
2164 | + } |
|
1518 | 2165 | connect_all($globalSources); |
1519 | 2166 | } |
1520 | 2167 | } |
1521 | 2168 | } |
1522 | 2169 | if ($globalDaemon === false) { |
1523 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2170 | + if ($globalDebug) { |
|
2171 | + echo 'Check all...'."\n"; |
|
2172 | + } |
|
1524 | 2173 | $SI->checkAll(); |
1525 | 2174 | } |
1526 | 2175 | } |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | </tr> |
318 | 318 | <!-- |
319 | 319 | <?php |
320 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | - $Connection = new Connection(); |
|
320 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | + $Connection = new Connection(); |
|
322 | 322 | ?> |
323 | 323 | --> |
324 | 324 | <?php |
325 | - if ($Connection->db != NULL) { |
|
325 | + if ($Connection->db != NULL) { |
|
326 | 326 | if ($Connection->tableExists('source_location')) { |
327 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | - $Source = new Source(); |
|
329 | - //$alllocations = $Source->getAllLocationInfo(); |
|
330 | - $alllocations = $Source->getLocationInfobyType(''); |
|
331 | - foreach ($alllocations as $location) { |
|
327 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | + $Source = new Source(); |
|
329 | + //$alllocations = $Source->getAllLocationInfo(); |
|
330 | + $alllocations = $Source->getLocationInfobyType(''); |
|
331 | + foreach ($alllocations as $location) { |
|
332 | 332 | ?> |
333 | 333 | <tr> |
334 | 334 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | </tr> |
343 | 343 | |
344 | 344 | <?php |
345 | - } |
|
345 | + } |
|
346 | + } |
|
346 | 347 | } |
347 | - } |
|
348 | 348 | ?> |
349 | 349 | |
350 | 350 | <tr> |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | ?> |
453 | 453 | <tr> |
454 | 454 | <?php |
455 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
455 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
456 | 456 | ?> |
457 | 457 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | 458 | <td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
459 | 459 | <?php |
460 | - } else { |
|
460 | + } else { |
|
461 | 461 | $hostport = explode(':',$source['host']); |
462 | 462 | if (isset($hostport[1])) { |
463 | 463 | $host = $hostport[0]; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
471 | 471 | <td><input type="number" name="port[]" id="port" class="col-xs-2" value="<?php print $port; ?>" /></td> |
472 | 472 | <?php |
473 | - } |
|
473 | + } |
|
474 | 474 | ?> |
475 | 475 | <td> |
476 | 476 | <select name="format[]" id="format"> |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | <br /> |
864 | 864 | <p> |
865 | 865 | <?php |
866 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
866 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
867 | 867 | ?> |
868 | 868 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
869 | 869 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -873,11 +873,11 @@ discard block |
||
873 | 873 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
874 | 874 | <?php |
875 | 875 | } |
876 | - } else { |
|
876 | + } else { |
|
877 | 877 | ?> |
878 | 878 | <b>PHP GD is not installed, you can t change color of aircraft icon on map</b> |
879 | 879 | <?php |
880 | - } |
|
880 | + } |
|
881 | 881 | ?> |
882 | 882 | </p> |
883 | 883 | <br /> |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | </p> |
902 | 902 | <?php |
903 | 903 | require('../footer.php'); |
904 | - exit; |
|
904 | + exit; |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | $settings = array(); |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | |
993 | 993 | $sources = array(); |
994 | 994 | foreach ($source_name as $keys => $name) { |
995 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
996 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
995 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
996 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
997 | 997 | } |
998 | 998 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
999 | 999 | |
@@ -1362,14 +1362,14 @@ discard block |
||
1362 | 1362 | |
1363 | 1363 | // Set some defaults values... |
1364 | 1364 | if (!isset($globalAircraftImageSources)) { |
1365 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1366 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1365 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1366 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | if (!isset($globalSchedulesSources)) { |
1370 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1371 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1372 | - } |
|
1370 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1371 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1372 | + } |
|
1373 | 1373 | |
1374 | 1374 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1375 | 1375 | |
@@ -1421,21 +1421,21 @@ discard block |
||
1421 | 1421 | $popi = false; |
1422 | 1422 | $popw = false; |
1423 | 1423 | foreach ($_SESSION['done'] as $done) { |
1424 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1425 | - if ($done == 'Create database') $pop = true; |
|
1426 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1427 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1428 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1424 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1425 | + if ($done == 'Create database') $pop = true; |
|
1426 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1427 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1428 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1429 | 1429 | } |
1430 | 1430 | if ($pop) { |
1431 | - sleep(5); |
|
1432 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1431 | + sleep(5); |
|
1432 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1433 | 1433 | } else if ($popi) { |
1434 | - sleep(5); |
|
1435 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1434 | + sleep(5); |
|
1435 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1436 | 1436 | } else if ($popw) { |
1437 | - sleep(5); |
|
1438 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1437 | + sleep(5); |
|
1438 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1439 | 1439 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1440 | 1440 | print '</div></ul>'; |
1441 | 1441 | print '<div id="error"></div>'; |
@@ -1498,7 +1498,7 @@ discard block |
||
1498 | 1498 | unset($_COOKIE['install']); |
1499 | 1499 | print '<div class="info column"><ul>'; |
1500 | 1500 | foreach ($_SESSION['done'] as $done) { |
1501 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1501 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1502 | 1502 | } |
1503 | 1503 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1504 | 1504 | print '</ul></div>'; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | require_once(dirname(__FILE__).'/class.create_db.php'); |
11 | 11 | require_once(dirname(__FILE__).'/class.update_schema.php'); |
12 | 12 | require_once(dirname(__FILE__).'/class.settings.php'); |
13 | -$title="Install"; |
|
13 | +$title = "Install"; |
|
14 | 14 | require(dirname(__FILE__).'/../require/settings.php'); |
15 | 15 | require(dirname(__FILE__).'/header.php'); |
16 | 16 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | if (!extension_loaded('curl')) { |
70 | 70 | $error[] = "Curl is not loaded."; |
71 | 71 | } |
72 | -if(function_exists('apache_get_modules') ){ |
|
73 | - if(!in_array('mod_rewrite',apache_get_modules())) { |
|
72 | +if (function_exists('apache_get_modules')) { |
|
73 | + if (!in_array('mod_rewrite', apache_get_modules())) { |
|
74 | 74 | $error[] = "mod_rewrite is not available."; |
75 | 75 | } |
76 | 76 | /* |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>'; |
87 | 87 | if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) { |
88 | 88 | if (function_exists('get_headers')) { |
89 | - $check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"]))); |
|
90 | - if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) { |
|
89 | + $check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"]))); |
|
90 | + if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) { |
|
91 | 91 | print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>'; |
92 | 92 | } |
93 | 93 | } |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | ?> |
453 | 453 | <tr> |
454 | 454 | <?php |
455 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
455 | + if (filter_var($source['host'], FILTER_VALIDATE_URL)) { |
|
456 | 456 | ?> |
457 | 457 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | 458 | <td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
459 | 459 | <?php |
460 | 460 | } else { |
461 | - $hostport = explode(':',$source['host']); |
|
461 | + $hostport = explode(':', $source['host']); |
|
462 | 462 | if (isset($hostport[1])) { |
463 | 463 | $host = $hostport[0]; |
464 | 464 | $port = $hostport[1]; |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | <td> |
503 | 503 | <select name="timezone[]" id="timezone"> |
504 | 504 | <?php |
505 | - foreach(timezone_abbreviations_list() as $abbr => $timezone){ |
|
506 | - foreach($timezone as $val){ |
|
507 | - if(isset($val['timezone_id'])){ |
|
505 | + foreach (timezone_abbreviations_list() as $abbr => $timezone) { |
|
506 | + foreach ($timezone as $val) { |
|
507 | + if (isset($val['timezone_id'])) { |
|
508 | 508 | if (isset($source['timezone']) && $source['timezone'] == $val['timezone_id']) { |
509 | 509 | print '<option selected>'.$val['timezone_id'].'</option>'; |
510 | 510 | } elseif (!isset($source['timezone']) && $val['timezone_id'] == 'UTC') { |
@@ -555,9 +555,9 @@ discard block |
||
555 | 555 | <td> |
556 | 556 | <select name="timezone[]" id="timezone"> |
557 | 557 | <?php |
558 | - foreach(timezone_abbreviations_list() as $abbr => $timezone){ |
|
559 | - foreach($timezone as $val){ |
|
560 | - if(isset($val['timezone_id'])){ |
|
558 | + foreach (timezone_abbreviations_list() as $abbr => $timezone) { |
|
559 | + foreach ($timezone as $val) { |
|
560 | + if (isset($val['timezone_id'])) { |
|
561 | 561 | if ($val['timezone_id'] == 'UTC') { |
562 | 562 | print '<option selected>'.$val['timezone_id'].'</option>'; |
563 | 563 | } else print '<option>'.$val['timezone_id'].'</option>'; |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | <br /> |
854 | 854 | <p> |
855 | 855 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
856 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
856 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" /> |
|
857 | 857 | </p> |
858 | 858 | <br /> |
859 | 859 | <p> |
@@ -909,14 +909,14 @@ discard block |
||
909 | 909 | $error = ''; |
910 | 910 | |
911 | 911 | if (isset($_POST['dbtype'])) { |
912 | - $dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING); |
|
913 | - $dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING); |
|
914 | - $dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING); |
|
915 | - $dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING); |
|
916 | - $dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING); |
|
917 | - $dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING); |
|
918 | - $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
|
919 | - $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
|
912 | + $dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING); |
|
913 | + $dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING); |
|
914 | + $dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING); |
|
915 | + $dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING); |
|
916 | + $dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING); |
|
917 | + $dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING); |
|
918 | + $dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING); |
|
919 | + $dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING); |
|
920 | 920 | |
921 | 921 | if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
922 | 922 | if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
@@ -936,49 +936,49 @@ discard block |
||
936 | 936 | } else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
937 | 937 | */ |
938 | 938 | |
939 | - $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
|
939 | + $settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname)); |
|
940 | 940 | |
941 | - $sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING); |
|
942 | - $siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING); |
|
943 | - $timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING); |
|
944 | - $language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING); |
|
945 | - $settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language)); |
|
941 | + $sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING); |
|
942 | + $siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING); |
|
943 | + $timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING); |
|
944 | + $language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING); |
|
945 | + $settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language)); |
|
946 | 946 | |
947 | - $mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING); |
|
948 | - $mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING); |
|
949 | - $mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING); |
|
950 | - $googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING); |
|
951 | - $bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING); |
|
952 | - $openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING); |
|
953 | - $mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING); |
|
954 | - $hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING); |
|
955 | - $hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING); |
|
956 | - $settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey)); |
|
947 | + $mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING); |
|
948 | + $mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING); |
|
949 | + $mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING); |
|
950 | + $googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING); |
|
951 | + $bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING); |
|
952 | + $openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING); |
|
953 | + $mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING); |
|
954 | + $hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING); |
|
955 | + $hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING); |
|
956 | + $settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey)); |
|
957 | 957 | |
958 | - $latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING); |
|
959 | - $latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING); |
|
960 | - $longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING); |
|
961 | - $longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING); |
|
962 | - $livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT); |
|
963 | - $settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom)); |
|
958 | + $latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING); |
|
959 | + $latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING); |
|
960 | + $longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING); |
|
961 | + $longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING); |
|
962 | + $livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT); |
|
963 | + $settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom)); |
|
964 | 964 | |
965 | - $squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING); |
|
966 | - $settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country)); |
|
965 | + $squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING); |
|
966 | + $settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country)); |
|
967 | 967 | |
968 | - $latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING); |
|
969 | - $longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING); |
|
970 | - $settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter)); |
|
968 | + $latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING); |
|
969 | + $longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING); |
|
970 | + $settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter)); |
|
971 | 971 | |
972 | - $acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING); |
|
972 | + $acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING); |
|
973 | 973 | if ($acars == 'acars') { |
974 | - $settings = array_merge($settings,array('globalACARS' => 'TRUE')); |
|
974 | + $settings = array_merge($settings, array('globalACARS' => 'TRUE')); |
|
975 | 975 | } else { |
976 | - $settings = array_merge($settings,array('globalACARS' => 'FALSE')); |
|
976 | + $settings = array_merge($settings, array('globalACARS' => 'FALSE')); |
|
977 | 977 | } |
978 | 978 | |
979 | - $flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING); |
|
980 | - $flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING); |
|
981 | - $settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword)); |
|
979 | + $flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING); |
|
980 | + $flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING); |
|
981 | + $settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword)); |
|
982 | 982 | |
983 | 983 | $source_name = $_POST['source_name']; |
984 | 984 | $source_latitude = $_POST['source_latitude']; |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | |
993 | 993 | $sources = array(); |
994 | 994 | foreach ($source_name as $keys => $name) { |
995 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
996 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
995 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]); |
|
996 | + else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]); |
|
997 | 997 | } |
998 | 998 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
999 | 999 | |
@@ -1006,24 +1006,24 @@ discard block |
||
1006 | 1006 | $sbsurl = $_POST['sbsurl']; |
1007 | 1007 | */ |
1008 | 1008 | |
1009 | - $globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING); |
|
1010 | - $globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING); |
|
1011 | - $globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING); |
|
1012 | - $globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING); |
|
1013 | - $globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING); |
|
1014 | - $globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING); |
|
1015 | - $globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING); |
|
1016 | - $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
|
1009 | + $globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING); |
|
1010 | + $globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING); |
|
1011 | + $globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING); |
|
1012 | + $globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING); |
|
1013 | + $globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING); |
|
1014 | + $globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING); |
|
1015 | + $globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING); |
|
1016 | + $datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING); |
|
1017 | 1017 | |
1018 | - $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
|
1019 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1020 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1021 | - $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
|
1022 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1023 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1024 | - $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
|
1025 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1026 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1018 | + $globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING); |
|
1019 | + if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE')); |
|
1020 | + else $settings = array_merge($settings, array('globalAircraft' => 'FALSE')); |
|
1021 | + $globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING); |
|
1022 | + if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE')); |
|
1023 | + else $settings = array_merge($settings, array('globalTracker' => 'FALSE')); |
|
1024 | + $globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING); |
|
1025 | + if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE')); |
|
1026 | + else $settings = array_merge($settings, array('globalMarine' => 'FALSE')); |
|
1027 | 1027 | |
1028 | 1028 | /* |
1029 | 1029 | $globalSBS1Hosts = array(); |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | } |
1040 | 1040 | $settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts)); |
1041 | 1041 | */ |
1042 | - $settings_comment = array_merge($settings_comment,array('globalSBS1Hosts')); |
|
1042 | + $settings_comment = array_merge($settings_comment, array('globalSBS1Hosts')); |
|
1043 | 1043 | $host = $_POST['host']; |
1044 | 1044 | $port = $_POST['port']; |
1045 | 1045 | $name = $_POST['name']; |
@@ -1056,100 +1056,100 @@ discard block |
||
1056 | 1056 | else $cov = 'FALSE'; |
1057 | 1057 | if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
1058 | 1058 | else $arch = 'FALSE'; |
1059 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]); |
|
1059 | + if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezone[$key]); |
|
1060 | 1060 | if ($format[$key] == 'airwhere') $forcepilots = true; |
1061 | 1061 | } |
1062 | - $settings = array_merge($settings,array('globalSources' => $gSources)); |
|
1062 | + $settings = array_merge($settings, array('globalSources' => $gSources)); |
|
1063 | 1063 | |
1064 | 1064 | /* |
1065 | 1065 | $sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT); |
1066 | 1066 | $settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout)); |
1067 | 1067 | */ |
1068 | - $acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING); |
|
1069 | - $acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT); |
|
1070 | - $settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport)); |
|
1068 | + $acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING); |
|
1069 | + $acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT); |
|
1070 | + $settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport)); |
|
1071 | 1071 | |
1072 | - $bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING); |
|
1073 | - $settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly)); |
|
1072 | + $bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING); |
|
1073 | + $settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly)); |
|
1074 | 1074 | |
1075 | - $customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING); |
|
1076 | - $settings = array_merge($settings,array('globalCustomCSS' => $customcss)); |
|
1075 | + $customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING); |
|
1076 | + $settings = array_merge($settings, array('globalCustomCSS' => $customcss)); |
|
1077 | 1077 | |
1078 | - $notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING); |
|
1079 | - $settings = array_merge($settings,array('globalNOTAMSource' => $notamsource)); |
|
1080 | - $metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING); |
|
1081 | - $settings = array_merge($settings,array('globalMETARurl' => $metarsource)); |
|
1078 | + $notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING); |
|
1079 | + $settings = array_merge($settings, array('globalNOTAMSource' => $notamsource)); |
|
1080 | + $metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING); |
|
1081 | + $settings = array_merge($settings, array('globalMETARurl' => $metarsource)); |
|
1082 | 1082 | |
1083 | - $zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING); |
|
1084 | - $zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING); |
|
1085 | - $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING); |
|
1084 | + $zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING); |
|
1085 | + $zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT); |
|
1086 | 1086 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1087 | - $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
|
1088 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1087 | + $settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance))); |
|
1088 | + } else $settings = array_merge($settings, array('globalDistanceIgnore' => array())); |
|
1089 | 1089 | |
1090 | - $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
|
1091 | - $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
|
1092 | - $maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT); |
|
1093 | - $settings = array_merge($settings,array('globalMapRefresh' => $maprefresh)); |
|
1094 | - $mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT); |
|
1095 | - $settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle)); |
|
1096 | - $closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT); |
|
1097 | - $settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist)); |
|
1090 | + $refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT); |
|
1091 | + $settings = array_merge($settings, array('globalLiveInterval' => $refresh)); |
|
1092 | + $maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT); |
|
1093 | + $settings = array_merge($settings, array('globalMapRefresh' => $maprefresh)); |
|
1094 | + $mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT); |
|
1095 | + $settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle)); |
|
1096 | + $closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT); |
|
1097 | + $settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist)); |
|
1098 | 1098 | |
1099 | - $aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT); |
|
1100 | - $settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize)); |
|
1099 | + $aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT); |
|
1100 | + $settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize)); |
|
1101 | 1101 | |
1102 | - $archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT); |
|
1103 | - $settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths)); |
|
1102 | + $archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT); |
|
1103 | + $settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths)); |
|
1104 | 1104 | |
1105 | - $archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING); |
|
1105 | + $archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING); |
|
1106 | 1106 | if ($archiveyear == "archiveyear") { |
1107 | - $settings = array_merge($settings,array('globalArchiveYear' => 'TRUE')); |
|
1107 | + $settings = array_merge($settings, array('globalArchiveYear' => 'TRUE')); |
|
1108 | 1108 | } else { |
1109 | - $settings = array_merge($settings,array('globalArchiveYear' => 'FALSE')); |
|
1109 | + $settings = array_merge($settings, array('globalArchiveYear' => 'FALSE')); |
|
1110 | 1110 | } |
1111 | - $archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT); |
|
1112 | - $settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
1113 | - $archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT); |
|
1114 | - $settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
1111 | + $archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT); |
|
1112 | + $settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
1113 | + $archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT); |
|
1114 | + $settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
1115 | 1115 | |
1116 | - $britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING); |
|
1117 | - $settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways)); |
|
1118 | - $transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING); |
|
1119 | - $settings = array_merge($settings,array('globalTransaviaKey' => $transavia)); |
|
1116 | + $britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING); |
|
1117 | + $settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways)); |
|
1118 | + $transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING); |
|
1119 | + $settings = array_merge($settings, array('globalTransaviaKey' => $transavia)); |
|
1120 | 1120 | |
1121 | - $lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING); |
|
1122 | - $lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING); |
|
1123 | - $settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret))); |
|
1121 | + $lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING); |
|
1122 | + $lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING); |
|
1123 | + $settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret))); |
|
1124 | 1124 | |
1125 | 1125 | // Create in settings.php keys not yet configurable if not already here |
1126 | 1126 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1127 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1127 | + if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE')); |
|
1128 | 1128 | |
1129 | - $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
|
1129 | + $resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING); |
|
1130 | 1130 | if ($resetyearstats == 'resetyearstats') { |
1131 | - $settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE')); |
|
1131 | + $settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE')); |
|
1132 | 1132 | } else { |
1133 | - $settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE')); |
|
1133 | + $settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE')); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | - $archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING); |
|
1136 | + $archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING); |
|
1137 | 1137 | if ($archive == 'archive') { |
1138 | - $settings = array_merge($settings,array('globalArchive' => 'TRUE')); |
|
1138 | + $settings = array_merge($settings, array('globalArchive' => 'TRUE')); |
|
1139 | 1139 | } else { |
1140 | - $settings = array_merge($settings,array('globalArchive' => 'FALSE')); |
|
1140 | + $settings = array_merge($settings, array('globalArchive' => 'FALSE')); |
|
1141 | 1141 | } |
1142 | - $daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING); |
|
1142 | + $daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING); |
|
1143 | 1143 | if ($daemon == 'daemon') { |
1144 | - $settings = array_merge($settings,array('globalDaemon' => 'TRUE')); |
|
1144 | + $settings = array_merge($settings, array('globalDaemon' => 'TRUE')); |
|
1145 | 1145 | } else { |
1146 | - $settings = array_merge($settings,array('globalDaemon' => 'FALSE')); |
|
1146 | + $settings = array_merge($settings, array('globalDaemon' => 'FALSE')); |
|
1147 | 1147 | } |
1148 | - $schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING); |
|
1148 | + $schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING); |
|
1149 | 1149 | if ($schedules == 'schedules') { |
1150 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE')); |
|
1150 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE')); |
|
1151 | 1151 | } else { |
1152 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE')); |
|
1152 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE')); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | /* |
@@ -1160,218 +1160,218 @@ discard block |
||
1160 | 1160 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE')); |
1161 | 1161 | } |
1162 | 1162 | */ |
1163 | - $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
|
1164 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1165 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1166 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1167 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1163 | + $settings = array_merge($settings, array('globalFlightAware' => 'FALSE')); |
|
1164 | + if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE')); |
|
1165 | + else $settings = array_merge($settings, array('globalSBS1' => 'FALSE')); |
|
1166 | + if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE')); |
|
1167 | + else $settings = array_merge($settings, array('globalAPRS' => 'FALSE')); |
|
1168 | 1168 | $va = false; |
1169 | 1169 | if ($globalivao == 'ivao') { |
1170 | - $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
|
1170 | + $settings = array_merge($settings, array('globalIVAO' => 'TRUE')); |
|
1171 | 1171 | $va = true; |
1172 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1172 | + } else $settings = array_merge($settings, array('globalIVAO' => 'FALSE')); |
|
1173 | 1173 | if ($globalvatsim == 'vatsim') { |
1174 | - $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
|
1174 | + $settings = array_merge($settings, array('globalVATSIM' => 'TRUE')); |
|
1175 | 1175 | $va = true; |
1176 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1176 | + } else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE')); |
|
1177 | 1177 | if ($globalphpvms == 'phpvms') { |
1178 | - $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
|
1178 | + $settings = array_merge($settings, array('globalphpVMS' => 'TRUE')); |
|
1179 | 1179 | $va = true; |
1180 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1180 | + } else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE')); |
|
1181 | 1181 | if ($globalvam == 'vam') { |
1182 | - $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
|
1182 | + $settings = array_merge($settings, array('globalVAM' => 'TRUE')); |
|
1183 | 1183 | $va = true; |
1184 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1184 | + } else $settings = array_merge($settings, array('globalVAM' => 'FALSE')); |
|
1185 | 1185 | if ($va) { |
1186 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
|
1187 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1186 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE')); |
|
1187 | + } else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE')); |
|
1188 | 1188 | if ($globalva == 'va' || $va) { |
1189 | - $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
|
1190 | - $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1189 | + $settings = array_merge($settings, array('globalVA' => 'TRUE')); |
|
1190 | + $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE')); |
|
1191 | 1191 | } else { |
1192 | - $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
|
1193 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1194 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1192 | + $settings = array_merge($settings, array('globalVA' => 'FALSE')); |
|
1193 | + if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE')); |
|
1194 | + else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE')); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | |
1198 | 1198 | |
1199 | - $notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING); |
|
1199 | + $notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING); |
|
1200 | 1200 | if ($notam == 'notam') { |
1201 | - $settings = array_merge($settings,array('globalNOTAM' => 'TRUE')); |
|
1201 | + $settings = array_merge($settings, array('globalNOTAM' => 'TRUE')); |
|
1202 | 1202 | } else { |
1203 | - $settings = array_merge($settings,array('globalNOTAM' => 'FALSE')); |
|
1203 | + $settings = array_merge($settings, array('globalNOTAM' => 'FALSE')); |
|
1204 | 1204 | } |
1205 | - $owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING); |
|
1205 | + $owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING); |
|
1206 | 1206 | if ($owner == 'owner') { |
1207 | - $settings = array_merge($settings,array('globalOwner' => 'TRUE')); |
|
1207 | + $settings = array_merge($settings, array('globalOwner' => 'TRUE')); |
|
1208 | 1208 | } else { |
1209 | - $settings = array_merge($settings,array('globalOwner' => 'FALSE')); |
|
1209 | + $settings = array_merge($settings, array('globalOwner' => 'FALSE')); |
|
1210 | 1210 | } |
1211 | - $map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING); |
|
1211 | + $map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING); |
|
1212 | 1212 | if ($map3d == 'map3d') { |
1213 | - $settings = array_merge($settings,array('globalMap3D' => 'TRUE')); |
|
1213 | + $settings = array_merge($settings, array('globalMap3D' => 'TRUE')); |
|
1214 | 1214 | } else { |
1215 | - $settings = array_merge($settings,array('globalMap3D' => 'FALSE')); |
|
1215 | + $settings = array_merge($settings, array('globalMap3D' => 'FALSE')); |
|
1216 | 1216 | } |
1217 | - $crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING); |
|
1217 | + $crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING); |
|
1218 | 1218 | if ($crash == 'crash') { |
1219 | - $settings = array_merge($settings,array('globalAccidents' => 'TRUE')); |
|
1219 | + $settings = array_merge($settings, array('globalAccidents' => 'TRUE')); |
|
1220 | 1220 | } else { |
1221 | - $settings = array_merge($settings,array('globalAccidents' => 'FALSE')); |
|
1221 | + $settings = array_merge($settings, array('globalAccidents' => 'FALSE')); |
|
1222 | 1222 | } |
1223 | - $mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING); |
|
1223 | + $mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING); |
|
1224 | 1224 | if ($mapsatellites == 'mapsatellites') { |
1225 | - $settings = array_merge($settings,array('globalMapSatellites' => 'TRUE')); |
|
1225 | + $settings = array_merge($settings, array('globalMapSatellites' => 'TRUE')); |
|
1226 | 1226 | } else { |
1227 | - $settings = array_merge($settings,array('globalMapSatellites' => 'FALSE')); |
|
1227 | + $settings = array_merge($settings, array('globalMapSatellites' => 'FALSE')); |
|
1228 | 1228 | } |
1229 | - $map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING); |
|
1229 | + $map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING); |
|
1230 | 1230 | if ($map3ddefault == 'map3ddefault') { |
1231 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE')); |
|
1231 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE')); |
|
1232 | 1232 | } else { |
1233 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE')); |
|
1233 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE')); |
|
1234 | 1234 | } |
1235 | - $translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING); |
|
1235 | + $translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING); |
|
1236 | 1236 | if ($translate == 'translate') { |
1237 | - $settings = array_merge($settings,array('globalTranslate' => 'TRUE')); |
|
1237 | + $settings = array_merge($settings, array('globalTranslate' => 'TRUE')); |
|
1238 | 1238 | } else { |
1239 | - $settings = array_merge($settings,array('globalTranslate' => 'FALSE')); |
|
1239 | + $settings = array_merge($settings, array('globalTranslate' => 'FALSE')); |
|
1240 | 1240 | } |
1241 | - $realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING); |
|
1241 | + $realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING); |
|
1242 | 1242 | if ($realairlines == 'realairlines') { |
1243 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE')); |
|
1243 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE')); |
|
1244 | 1244 | } else { |
1245 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE')); |
|
1245 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE')); |
|
1246 | 1246 | } |
1247 | - $estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING); |
|
1247 | + $estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING); |
|
1248 | 1248 | if ($estimation == 'estimation') { |
1249 | - $settings = array_merge($settings,array('globalMapEstimation' => 'TRUE')); |
|
1249 | + $settings = array_merge($settings, array('globalMapEstimation' => 'TRUE')); |
|
1250 | 1250 | } else { |
1251 | - $settings = array_merge($settings,array('globalMapEstimation' => 'FALSE')); |
|
1251 | + $settings = array_merge($settings, array('globalMapEstimation' => 'FALSE')); |
|
1252 | 1252 | } |
1253 | - $metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING); |
|
1253 | + $metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING); |
|
1254 | 1254 | if ($metar == 'metar') { |
1255 | - $settings = array_merge($settings,array('globalMETAR' => 'TRUE')); |
|
1255 | + $settings = array_merge($settings, array('globalMETAR' => 'TRUE')); |
|
1256 | 1256 | } else { |
1257 | - $settings = array_merge($settings,array('globalMETAR' => 'FALSE')); |
|
1257 | + $settings = array_merge($settings, array('globalMETAR' => 'FALSE')); |
|
1258 | 1258 | } |
1259 | - $metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING); |
|
1259 | + $metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING); |
|
1260 | 1260 | if ($metarcycle == 'metarcycle') { |
1261 | - $settings = array_merge($settings,array('globalMETARcycle' => 'TRUE')); |
|
1261 | + $settings = array_merge($settings, array('globalMETARcycle' => 'TRUE')); |
|
1262 | 1262 | } else { |
1263 | - $settings = array_merge($settings,array('globalMETARcycle' => 'FALSE')); |
|
1263 | + $settings = array_merge($settings, array('globalMETARcycle' => 'FALSE')); |
|
1264 | 1264 | } |
1265 | - $fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING); |
|
1265 | + $fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING); |
|
1266 | 1266 | if ($fork == 'fork') { |
1267 | - $settings = array_merge($settings,array('globalFork' => 'TRUE')); |
|
1267 | + $settings = array_merge($settings, array('globalFork' => 'TRUE')); |
|
1268 | 1268 | } else { |
1269 | - $settings = array_merge($settings,array('globalFork' => 'FALSE')); |
|
1269 | + $settings = array_merge($settings, array('globalFork' => 'FALSE')); |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | - $colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING); |
|
1272 | + $colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING); |
|
1273 | 1273 | if ($colormap == 'colormap') { |
1274 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE')); |
|
1274 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE')); |
|
1275 | 1275 | } else { |
1276 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE')); |
|
1276 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE')); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | if (isset($_POST['aircrafticoncolor'])) { |
1280 | - $aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING); |
|
1281 | - $settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1))); |
|
1280 | + $aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING); |
|
1281 | + $settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1))); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | - $airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT); |
|
1285 | - $settings = array_merge($settings,array('globalAirportZoom' => $airportzoom)); |
|
1284 | + $airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT); |
|
1285 | + $settings = array_merge($settings, array('globalAirportZoom' => $airportzoom)); |
|
1286 | 1286 | |
1287 | - $unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING); |
|
1288 | - $settings = array_merge($settings,array('globalUnitDistance' => $unitdistance)); |
|
1289 | - $unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING); |
|
1290 | - $settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude)); |
|
1291 | - $unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING); |
|
1292 | - $settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed)); |
|
1287 | + $unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING); |
|
1288 | + $settings = array_merge($settings, array('globalUnitDistance' => $unitdistance)); |
|
1289 | + $unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING); |
|
1290 | + $settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude)); |
|
1291 | + $unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING); |
|
1292 | + $settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed)); |
|
1293 | 1293 | |
1294 | - $mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING); |
|
1294 | + $mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING); |
|
1295 | 1295 | if ($mappopup == 'mappopup') { |
1296 | - $settings = array_merge($settings,array('globalMapPopup' => 'TRUE')); |
|
1296 | + $settings = array_merge($settings, array('globalMapPopup' => 'TRUE')); |
|
1297 | 1297 | } else { |
1298 | - $settings = array_merge($settings,array('globalMapPopup' => 'FALSE')); |
|
1298 | + $settings = array_merge($settings, array('globalMapPopup' => 'FALSE')); |
|
1299 | 1299 | } |
1300 | - $airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING); |
|
1300 | + $airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING); |
|
1301 | 1301 | if ($airportpopup == 'airportpopup') { |
1302 | - $settings = array_merge($settings,array('globalAirportPopup' => 'TRUE')); |
|
1302 | + $settings = array_merge($settings, array('globalAirportPopup' => 'TRUE')); |
|
1303 | 1303 | } else { |
1304 | - $settings = array_merge($settings,array('globalAirportPopup' => 'FALSE')); |
|
1304 | + $settings = array_merge($settings, array('globalAirportPopup' => 'FALSE')); |
|
1305 | 1305 | } |
1306 | - $maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING); |
|
1306 | + $maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING); |
|
1307 | 1307 | if ($maphistory == 'maphistory') { |
1308 | - $settings = array_merge($settings,array('globalMapHistory' => 'TRUE')); |
|
1308 | + $settings = array_merge($settings, array('globalMapHistory' => 'TRUE')); |
|
1309 | 1309 | } else { |
1310 | - $settings = array_merge($settings,array('globalMapHistory' => 'FALSE')); |
|
1310 | + $settings = array_merge($settings, array('globalMapHistory' => 'FALSE')); |
|
1311 | 1311 | } |
1312 | - $maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING); |
|
1312 | + $maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING); |
|
1313 | 1313 | if ($maptooltip == 'maptooltip') { |
1314 | - $settings = array_merge($settings,array('globalMapTooltip' => 'TRUE')); |
|
1314 | + $settings = array_merge($settings, array('globalMapTooltip' => 'TRUE')); |
|
1315 | 1315 | } else { |
1316 | - $settings = array_merge($settings,array('globalMapTooltip' => 'FALSE')); |
|
1316 | + $settings = array_merge($settings, array('globalMapTooltip' => 'FALSE')); |
|
1317 | 1317 | } |
1318 | - $flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING); |
|
1318 | + $flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING); |
|
1319 | 1319 | if ($flightroute == 'flightroute') { |
1320 | - $settings = array_merge($settings,array('globalMapRoute' => 'TRUE')); |
|
1320 | + $settings = array_merge($settings, array('globalMapRoute' => 'TRUE')); |
|
1321 | 1321 | } else { |
1322 | - $settings = array_merge($settings,array('globalMapRoute' => 'FALSE')); |
|
1322 | + $settings = array_merge($settings, array('globalMapRoute' => 'FALSE')); |
|
1323 | 1323 | } |
1324 | - $flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING); |
|
1324 | + $flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING); |
|
1325 | 1325 | if ($flightremainingroute == 'flightremainingroute') { |
1326 | - $settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE')); |
|
1326 | + $settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE')); |
|
1327 | 1327 | } else { |
1328 | - $settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE')); |
|
1328 | + $settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE')); |
|
1329 | 1329 | } |
1330 | - $allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING); |
|
1330 | + $allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING); |
|
1331 | 1331 | if ($allflights == 'allflights') { |
1332 | - $settings = array_merge($settings,array('globalAllFlights' => 'TRUE')); |
|
1332 | + $settings = array_merge($settings, array('globalAllFlights' => 'TRUE')); |
|
1333 | 1333 | } else { |
1334 | - $settings = array_merge($settings,array('globalAllFlights' => 'FALSE')); |
|
1334 | + $settings = array_merge($settings, array('globalAllFlights' => 'FALSE')); |
|
1335 | 1335 | } |
1336 | - $bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING); |
|
1336 | + $bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING); |
|
1337 | 1337 | if ($bbox == 'bbox') { |
1338 | - $settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE')); |
|
1338 | + $settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE')); |
|
1339 | 1339 | } else { |
1340 | - $settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE')); |
|
1340 | + $settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE')); |
|
1341 | 1341 | } |
1342 | - $groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING); |
|
1342 | + $groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING); |
|
1343 | 1343 | if ($groundaltitude == 'groundaltitude') { |
1344 | - $settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE')); |
|
1344 | + $settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE')); |
|
1345 | 1345 | } else { |
1346 | - $settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE')); |
|
1346 | + $settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE')); |
|
1347 | 1347 | } |
1348 | - $waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING); |
|
1348 | + $waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING); |
|
1349 | 1349 | if ($waypoints == 'waypoints') { |
1350 | - $settings = array_merge($settings,array('globalWaypoints' => 'TRUE')); |
|
1350 | + $settings = array_merge($settings, array('globalWaypoints' => 'TRUE')); |
|
1351 | 1351 | } else { |
1352 | - $settings = array_merge($settings,array('globalWaypoints' => 'FALSE')); |
|
1352 | + $settings = array_merge($settings, array('globalWaypoints' => 'FALSE')); |
|
1353 | 1353 | } |
1354 | - $noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING); |
|
1354 | + $noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING); |
|
1355 | 1355 | if ($noairlines == 'noairlines') { |
1356 | - $settings = array_merge($settings,array('globalNoAirlines' => 'TRUE')); |
|
1356 | + $settings = array_merge($settings, array('globalNoAirlines' => 'TRUE')); |
|
1357 | 1357 | } else { |
1358 | - $settings = array_merge($settings,array('globalNoAirlines' => 'FALSE')); |
|
1358 | + $settings = array_merge($settings, array('globalNoAirlines' => 'FALSE')); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1361 | + if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE')); |
|
1362 | 1362 | |
1363 | 1363 | // Set some defaults values... |
1364 | 1364 | if (!isset($globalAircraftImageSources)) { |
1365 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1366 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1365 | + $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
1366 | + $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | if (!isset($globalSchedulesSources)) { |
1370 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1371 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1370 | + $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1371 | + $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | - $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
|
1374 | + $settings = array_merge($settings, array('globalInstalled' => 'TRUE')); |
|
1375 | 1375 | |
1376 | 1376 | if ($error == '') settings::modify_settings($settings); |
1377 | 1377 | if ($error == '') settings::comment_settings($settings_comment); |
@@ -131,45 +131,72 @@ discard block |
||
131 | 131 | </div> |
132 | 132 | <p> |
133 | 133 | <label for="dbhost">Database hostname</label> |
134 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
134 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
135 | + print $globalDBhost; |
|
136 | +} |
|
137 | +?>" /> |
|
135 | 138 | </p> |
136 | 139 | <p> |
137 | 140 | <label for="dbport">Database port</label> |
138 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
141 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
142 | + print $globalDBport; |
|
143 | +} |
|
144 | +?>" /> |
|
139 | 145 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
140 | 146 | </p> |
141 | 147 | <p> |
142 | 148 | <label for="dbname">Database name</label> |
143 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
149 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
150 | + print $globalDBname; |
|
151 | +} |
|
152 | +?>" /> |
|
144 | 153 | </p> |
145 | 154 | <p> |
146 | 155 | <label for="dbuser">Database user</label> |
147 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
156 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
157 | + print $globalDBuser; |
|
158 | +} |
|
159 | +?>" /> |
|
148 | 160 | </p> |
149 | 161 | <p> |
150 | 162 | <label for="dbuserpass">Database user password</label> |
151 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
163 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
164 | + print $globalDBpass; |
|
165 | +} |
|
166 | +?>" /> |
|
152 | 167 | </p> |
153 | 168 | </fieldset> |
154 | 169 | <fieldset id="site"> |
155 | 170 | <legend>Site configuration</legend> |
156 | 171 | <p> |
157 | 172 | <label for="sitename">Site name</label> |
158 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
173 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
174 | + print $globalName; |
|
175 | +} |
|
176 | +?>" /> |
|
159 | 177 | </p> |
160 | 178 | <p> |
161 | 179 | <label for="siteurl">Site directory</label> |
162 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
180 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
181 | + print $globalURL; |
|
182 | +} |
|
183 | +?>" /> |
|
163 | 184 | <p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
164 | 185 | </p> |
165 | 186 | <p> |
166 | 187 | <label for="timezone">Timezone</label> |
167 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
188 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
189 | + print $globalTimezone; |
|
190 | +} |
|
191 | +?>" /> |
|
168 | 192 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
169 | 193 | </p> |
170 | 194 | <p> |
171 | 195 | <label for="language">Language</label> |
172 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
196 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
197 | + print $globalLanguage; |
|
198 | +} |
|
199 | +?>" /> |
|
173 | 200 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
174 | 201 | </p> |
175 | 202 | </fieldset> |
@@ -190,11 +217,17 @@ discard block |
||
190 | 217 | <div id="mapbox_data"> |
191 | 218 | <p> |
192 | 219 | <label for="mapboxid">Mapbox id</label> |
193 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
220 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
221 | + print $globalMapboxId; |
|
222 | +} |
|
223 | +?>" /> |
|
194 | 224 | </p> |
195 | 225 | <p> |
196 | 226 | <label for="mapboxtoken">Mapbox token</label> |
197 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
227 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
228 | + print $globalMapboxToken; |
|
229 | +} |
|
230 | +?>" /> |
|
198 | 231 | </p> |
199 | 232 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
200 | 233 | </div> |
@@ -202,7 +235,10 @@ discard block |
||
202 | 235 | <div id="google_data"> |
203 | 236 | <p> |
204 | 237 | <label for="googlekey">Google API key</label> |
205 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
238 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
239 | + print $globalGoogleAPIKey; |
|
240 | +} |
|
241 | +?>" /> |
|
206 | 242 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
207 | 243 | </p> |
208 | 244 | </div> |
@@ -210,7 +246,10 @@ discard block |
||
210 | 246 | <div id="bing_data"> |
211 | 247 | <p> |
212 | 248 | <label for="bingkey">Bing Map key</label> |
213 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
249 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
250 | + print $globalBingMapKey; |
|
251 | +} |
|
252 | +?>" /> |
|
214 | 253 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
215 | 254 | </p> |
216 | 255 | </div> |
@@ -218,7 +257,10 @@ discard block |
||
218 | 257 | <div id="mapquest_data"> |
219 | 258 | <p> |
220 | 259 | <label for="mapquestkey">MapQuest key</label> |
221 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
260 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
261 | + print $globalMapQuestKey; |
|
262 | +} |
|
263 | +?>" /> |
|
222 | 264 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
223 | 265 | </p> |
224 | 266 | </div> |
@@ -226,11 +268,17 @@ discard block |
||
226 | 268 | <div id="here_data"> |
227 | 269 | <p> |
228 | 270 | <label for="hereappid">Here App_Id</label> |
229 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
271 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
272 | + print $globalHereappId; |
|
273 | +} |
|
274 | +?>" /> |
|
230 | 275 | </p> |
231 | 276 | <p> |
232 | 277 | <label for="hereappcode">Here App_Code</label> |
233 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
278 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
279 | + print $globalHereappCode; |
|
280 | +} |
|
281 | +?>" /> |
|
234 | 282 | </p> |
235 | 283 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
236 | 284 | </div> |
@@ -238,7 +286,10 @@ discard block |
||
238 | 286 | <div id="openweathermap_data"> |
239 | 287 | <p> |
240 | 288 | <label for="openweathermapkey">OpenWeatherMap key (weather layer)</label> |
241 | - <input type="text" name="oepnweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" /> |
|
289 | + <input type="text" name="oepnweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) { |
|
290 | + print $globalOpenWeatherMapKey; |
|
291 | +} |
|
292 | +?>" /> |
|
242 | 293 | <p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p> |
243 | 294 | </p> |
244 | 295 | </div> |
@@ -248,42 +299,86 @@ discard block |
||
248 | 299 | <legend>Coverage area</legend> |
249 | 300 | <p> |
250 | 301 | <label for="latitudemax">The maximum latitude (north)</label> |
251 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
302 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
303 | + print $globalLatitudeMax; |
|
304 | +} |
|
305 | +?>" /> |
|
252 | 306 | </p> |
253 | 307 | <p> |
254 | 308 | <label for="latitudemin">The minimum latitude (south)</label> |
255 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
309 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
310 | + print $globalLatitudeMin; |
|
311 | +} |
|
312 | +?>" /> |
|
256 | 313 | </p> |
257 | 314 | <p> |
258 | 315 | <label for="longitudemax">The maximum longitude (west)</label> |
259 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
316 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
317 | + print $globalLongitudeMax; |
|
318 | +} |
|
319 | +?>" /> |
|
260 | 320 | </p> |
261 | 321 | <p> |
262 | 322 | <label for="longitudemin">The minimum longitude (east)</label> |
263 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
323 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
324 | + print $globalLongitudeMin; |
|
325 | +} |
|
326 | +?>" /> |
|
264 | 327 | </p> |
265 | 328 | <p> |
266 | 329 | <label for="latitudecenter">The latitude center</label> |
267 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
330 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
331 | + print $globalCenterLatitude; |
|
332 | +} |
|
333 | +?>" /> |
|
268 | 334 | </p> |
269 | 335 | <p> |
270 | 336 | <label for="longitudecenter">The longitude center</label> |
271 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
337 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
338 | + print $globalCenterLongitude; |
|
339 | +} |
|
340 | +?>" /> |
|
272 | 341 | </p> |
273 | 342 | <p> |
274 | 343 | <label for="livezoom">Default Zoom on live map</label> |
275 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
344 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
345 | + print $globalLiveZoom; |
|
346 | +} else { |
|
347 | + print '9'; |
|
348 | +} |
|
349 | +?>" /> |
|
276 | 350 | </p> |
277 | 351 | <p> |
278 | 352 | <label for="squawk_country">Country for squawk usage</label> |
279 | 353 | <select name="squawk_country" id="squawk_country"> |
280 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
281 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
282 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
283 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
284 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
285 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
286 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
354 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
355 | + print ' selected '; |
|
356 | +} |
|
357 | +?>>UK</option> |
|
358 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
359 | + print ' selected '; |
|
360 | +} |
|
361 | +?>>NZ</option> |
|
362 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
363 | + print ' selected '; |
|
364 | +} |
|
365 | +?>>US</option> |
|
366 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
367 | + print ' selected '; |
|
368 | +} |
|
369 | +?>>AU</option> |
|
370 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
371 | + print ' selected '; |
|
372 | +} |
|
373 | +?>>NL</option> |
|
374 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
375 | + print ' selected '; |
|
376 | +} |
|
377 | +?>>FR</option> |
|
378 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
379 | + print ' selected '; |
|
380 | +} |
|
381 | +?>>TR</option> |
|
287 | 382 | </select> |
288 | 383 | </p> |
289 | 384 | </fieldset> |
@@ -292,15 +387,24 @@ discard block |
||
292 | 387 | <p><i>Only put in DB flights that are inside a circle</i></p> |
293 | 388 | <p> |
294 | 389 | <label for="latitude">Center latitude</label> |
295 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
390 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
391 | + echo $globalDistanceIgnore['latitude']; |
|
392 | +} |
|
393 | +?>" /> |
|
296 | 394 | </p> |
297 | 395 | <p> |
298 | 396 | <label for="longitude">Center longitude</label> |
299 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
397 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
398 | + echo $globalDistanceIgnore['longitude']; |
|
399 | +} |
|
400 | +?>" /> |
|
300 | 401 | </p> |
301 | 402 | <p> |
302 | 403 | <label for="Distance">Distance (in km)</label> |
303 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
404 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
405 | + echo $globalDistanceIgnore['distance']; |
|
406 | +} |
|
407 | +?>" /> |
|
304 | 408 | </p> |
305 | 409 | </fieldset> |
306 | 410 | <fieldset id="sourceloc"> |
@@ -409,11 +513,17 @@ discard block |
||
409 | 513 | <div id="flightaware_data"> |
410 | 514 | <p> |
411 | 515 | <label for="flightawareusername">FlightAware username</label> |
412 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
516 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
517 | + print $globalFlightAwareUsername; |
|
518 | +} |
|
519 | +?>" /> |
|
413 | 520 | </p> |
414 | 521 | <p> |
415 | 522 | <label for="flightawarepassword">FlightAware password/API key</label> |
416 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
523 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
524 | + print $globalFlightAwarePassword; |
|
525 | +} |
|
526 | +?>" /> |
|
417 | 527 | </p> |
418 | 528 | </div> |
419 | 529 | --> |
@@ -455,7 +565,10 @@ discard block |
||
455 | 565 | if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
456 | 566 | ?> |
457 | 567 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | - <td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
|
568 | + <td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) { |
|
569 | + print $source['port']; |
|
570 | +} |
|
571 | +?>" /></td> |
|
459 | 572 | <?php |
460 | 573 | } else { |
461 | 574 | $hostport = explode(':',$source['host']); |
@@ -474,31 +587,94 @@ discard block |
||
474 | 587 | ?> |
475 | 588 | <td> |
476 | 589 | <select name="format[]" id="format"> |
477 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
478 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
479 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
480 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
481 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
482 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
483 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
484 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option> |
|
485 | - <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option> |
|
486 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
487 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
488 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
489 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
490 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
491 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
492 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option> |
|
493 | - <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option> |
|
494 | - <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option> |
|
590 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
591 | + print 'selected'; |
|
592 | +} |
|
593 | +?>>Auto</option> |
|
594 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
595 | + print 'selected'; |
|
596 | +} |
|
597 | +?>>SBS</option> |
|
598 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
599 | + print 'selected'; |
|
600 | +} |
|
601 | +?>>TSV</option> |
|
602 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
603 | + print 'selected'; |
|
604 | +} |
|
605 | +?>>Raw</option> |
|
606 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
607 | + print 'selected'; |
|
608 | +} |
|
609 | +?>>APRS</option> |
|
610 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
611 | + print 'selected'; |
|
612 | +} |
|
613 | +?>>Radarcape deltadb.txt</option> |
|
614 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
615 | + print 'selected'; |
|
616 | +} |
|
617 | +?>>Vatsim</option> |
|
618 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
619 | + print 'selected'; |
|
620 | +} |
|
621 | +?>>Virtual Radar Server AircraftList.json</option> |
|
622 | + <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') { |
|
623 | + print 'selected'; |
|
624 | +} |
|
625 | +?>>Virtual Radar Server TCP</option> |
|
626 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
627 | + print 'selected'; |
|
628 | +} |
|
629 | +?>>phpVMS</option> |
|
630 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
631 | + print 'selected'; |
|
632 | +} |
|
633 | +?>>Virtual Airlines Manager</option> |
|
634 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
635 | + print 'selected'; |
|
636 | +} |
|
637 | +?>>IVAO</option> |
|
638 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
639 | + print 'selected'; |
|
640 | +} |
|
641 | +?>>FlightGear Multiplayer</option> |
|
642 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
643 | + print 'selected'; |
|
644 | +} |
|
645 | +?>>FlightGear Singleplayer</option> |
|
646 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
647 | + print 'selected'; |
|
648 | +} |
|
649 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
650 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
651 | + print 'selected'; |
|
652 | +} |
|
653 | +?>>ACARS SBS-3 over TCP</option> |
|
654 | + <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') { |
|
655 | + print 'selected'; |
|
656 | +} |
|
657 | +?>>NMEA AIS over TCP</option> |
|
658 | + <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') { |
|
659 | + print 'selected'; |
|
660 | +} |
|
661 | +?>>AirWhere website</option> |
|
495 | 662 | </select> |
496 | 663 | </td> |
497 | 664 | <td> |
498 | - <input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /> |
|
665 | + <input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) { |
|
666 | + print $source['name']; |
|
667 | +} |
|
668 | +?>" /> |
|
499 | 669 | </td> |
500 | - <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
501 | - <td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td> |
|
670 | + <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
671 | + print 'checked'; |
|
672 | +} |
|
673 | +?> /></td> |
|
674 | + <td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) { |
|
675 | + print 'checked'; |
|
676 | +} |
|
677 | +?> /></td> |
|
502 | 678 | <td> |
503 | 679 | <select name="timezone[]" id="timezone"> |
504 | 680 | <?php |
@@ -509,7 +685,9 @@ discard block |
||
509 | 685 | print '<option selected>'.$val['timezone_id'].'</option>'; |
510 | 686 | } elseif (!isset($source['timezone']) && $val['timezone_id'] == 'UTC') { |
511 | 687 | print '<option selected>'.$val['timezone_id'].'</option>'; |
512 | - } else print '<option>'.$val['timezone_id'].'</option>'; |
|
688 | + } else { |
|
689 | + print '<option>'.$val['timezone_id'].'</option>'; |
|
690 | + } |
|
513 | 691 | } |
514 | 692 | } |
515 | 693 | } |
@@ -560,7 +738,9 @@ discard block |
||
560 | 738 | if(isset($val['timezone_id'])){ |
561 | 739 | if ($val['timezone_id'] == 'UTC') { |
562 | 740 | print '<option selected>'.$val['timezone_id'].'</option>'; |
563 | - } else print '<option>'.$val['timezone_id'].'</option>'; |
|
741 | + } else { |
|
742 | + print '<option>'.$val['timezone_id'].'</option>'; |
|
743 | + } |
|
564 | 744 | } |
565 | 745 | } |
566 | 746 | } |
@@ -582,11 +762,17 @@ discard block |
||
582 | 762 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
583 | 763 | <p> |
584 | 764 | <label for="acarshost">ACARS UDP host</label> |
585 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
765 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
766 | + print $globalACARSHost; |
|
767 | +} |
|
768 | +?>" /> |
|
586 | 769 | </p> |
587 | 770 | <p> |
588 | 771 | <label for="acarsport">ACARS UDP port</label> |
589 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
772 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
773 | + print $globalACARSPort; |
|
774 | +} |
|
775 | +?>" /> |
|
590 | 776 | </p> |
591 | 777 | </fieldset> |
592 | 778 | </div> |
@@ -666,13 +852,19 @@ discard block |
||
666 | 852 | <div id="schedules_options"> |
667 | 853 | <p> |
668 | 854 | <label for="britishairways">British Airways API Key</label> |
669 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
855 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) { |
|
856 | + print $globalBritishAirwaysKey; |
|
857 | +} |
|
858 | +?>" /> |
|
670 | 859 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
671 | 860 | </p> |
672 | 861 | <!-- |
673 | 862 | <p> |
674 | 863 | <label for="transavia">Transavia Test API Consumer Key</label> |
675 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
864 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
865 | + print $globalTransaviaKey; |
|
866 | +} |
|
867 | +?>" /> |
|
676 | 868 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
677 | 869 | </p> |
678 | 870 | --> |
@@ -681,10 +873,16 @@ discard block |
||
681 | 873 | <b>Lufthansa API Key</b> |
682 | 874 | <p> |
683 | 875 | <label for="lufthansakey">Key</label> |
684 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
876 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
877 | + print $globalLufthansaKey['key']; |
|
878 | +} |
|
879 | +?>" /> |
|
685 | 880 | </p><p> |
686 | 881 | <label for="lufthansasecret">Secret</label> |
687 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
882 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
883 | + print $globalLufthansaKey['secret']; |
|
884 | +} |
|
885 | +?>" /> |
|
688 | 886 | </p> |
689 | 887 | </div> |
690 | 888 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -704,7 +902,10 @@ discard block |
||
704 | 902 | </p> |
705 | 903 | <p> |
706 | 904 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
707 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
905 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
906 | + print $globalNOTAMSource; |
|
907 | +} |
|
908 | +?>" /> |
|
708 | 909 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
709 | 910 | </p> |
710 | 911 | <br /> |
@@ -720,14 +921,20 @@ discard block |
||
720 | 921 | <div id="metarsrc"> |
721 | 922 | <p> |
722 | 923 | <label for="metarsource">URL of your METAR source</label> |
723 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
924 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
925 | + print $globalMETARurl; |
|
926 | +} |
|
927 | +?>" /> |
|
724 | 928 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
725 | 929 | </p> |
726 | 930 | </div> |
727 | 931 | <br /> |
728 | 932 | <p> |
729 | 933 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
730 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
934 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
935 | + print $globalBitlyAccessToken; |
|
936 | +} |
|
937 | +?>" /> |
|
731 | 938 | </p> |
732 | 939 | <br /> |
733 | 940 | <p> |
@@ -747,7 +954,12 @@ discard block |
||
747 | 954 | </p> |
748 | 955 | <p> |
749 | 956 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
750 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" /> |
|
957 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
958 | + print $globalArchiveMonths; |
|
959 | +} else { |
|
960 | + echo '0'; |
|
961 | +} |
|
962 | +?>" /> |
|
751 | 963 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
752 | 964 | </p> |
753 | 965 | <p> |
@@ -757,12 +969,22 @@ discard block |
||
757 | 969 | </p> |
758 | 970 | <p> |
759 | 971 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
760 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" /> |
|
972 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
973 | + print $globalArchiveKeepMonths; |
|
974 | +} else { |
|
975 | + echo '0'; |
|
976 | +} |
|
977 | +?>" /> |
|
761 | 978 | <p class="help-block">0 to disable</p> |
762 | 979 | </p> |
763 | 980 | <p> |
764 | 981 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
765 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" /> |
|
982 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
983 | + print $globalArchiveKeepTrackMonths; |
|
984 | +} else { |
|
985 | + echo '0'; |
|
986 | +} |
|
987 | +?>" /> |
|
766 | 988 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
767 | 989 | </p> |
768 | 990 | <br /> |
@@ -772,7 +994,12 @@ discard block |
||
772 | 994 | <p class="help-block">Uncheck if the script is running as cron job</p> |
773 | 995 | <div id="cronends"> |
774 | 996 | <label for="cronend">Run script for xx seconds</label> |
775 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
997 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
998 | + print $globalCronEnd; |
|
999 | +} else { |
|
1000 | + print '0'; |
|
1001 | +} |
|
1002 | +?>" /> |
|
776 | 1003 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
777 | 1004 | </div> |
778 | 1005 | </p> |
@@ -825,15 +1052,30 @@ discard block |
||
825 | 1052 | <br /> |
826 | 1053 | <p> |
827 | 1054 | <label for="refresh">Show flights detected since xxx seconds</label> |
828 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
1055 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
1056 | + echo $globalLiveInterval; |
|
1057 | +} else { |
|
1058 | + echo '200'; |
|
1059 | +} |
|
1060 | +?>" /> |
|
829 | 1061 | </p> |
830 | 1062 | <p> |
831 | 1063 | <label for="maprefresh">Live map refresh (in seconds)</label> |
832 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
1064 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
1065 | + echo $globalMapRefresh; |
|
1066 | +} else { |
|
1067 | + echo '30'; |
|
1068 | +} |
|
1069 | +?>" /> |
|
833 | 1070 | </p> |
834 | 1071 | <p> |
835 | 1072 | <label for="mapidle">Map idle timeout (in minutes)</label> |
836 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
1073 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
1074 | + echo $globalMapIdleTimeout; |
|
1075 | +} else { |
|
1076 | + echo '30'; |
|
1077 | +} |
|
1078 | +?>" /> |
|
837 | 1079 | <p class="help-block">0 to disable</p> |
838 | 1080 | </p> |
839 | 1081 | <p> |
@@ -848,12 +1090,20 @@ discard block |
||
848 | 1090 | <br /> |
849 | 1091 | <p> |
850 | 1092 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
851 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
1093 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
1094 | + echo $globalClosestMinDist; |
|
1095 | +} else { |
|
1096 | + echo '50'; |
|
1097 | +} |
|
1098 | +?>" /> |
|
852 | 1099 | </p> |
853 | 1100 | <br /> |
854 | 1101 | <p> |
855 | 1102 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
856 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
1103 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
1104 | + echo $globalAircraftSize; |
|
1105 | +} |
|
1106 | +?>" /> |
|
857 | 1107 | </p> |
858 | 1108 | <br /> |
859 | 1109 | <p> |
@@ -866,7 +1116,12 @@ discard block |
||
866 | 1116 | if (extension_loaded('gd') && function_exists('gd_info')) { |
867 | 1117 | ?> |
868 | 1118 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
869 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
1119 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
1120 | + echo $globalAircraftIconColor; |
|
1121 | +} else { |
|
1122 | + echo '1a3151'; |
|
1123 | +} |
|
1124 | +?>" /> |
|
870 | 1125 | <?php |
871 | 1126 | if (!is_writable('../cache')) { |
872 | 1127 | ?> |
@@ -884,14 +1139,27 @@ discard block |
||
884 | 1139 | <p> |
885 | 1140 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
886 | 1141 | <div class="range"> |
887 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
888 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
1142 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
1143 | + echo $globalAirportZoom; |
|
1144 | +} else { |
|
1145 | + echo '7'; |
|
1146 | +} |
|
1147 | +?>" /> |
|
1148 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
1149 | + echo $globalAirportZoom; |
|
1150 | +} else { |
|
1151 | + echo '7'; |
|
1152 | +} |
|
1153 | +?></output> |
|
889 | 1154 | </div> |
890 | 1155 | </p> |
891 | 1156 | <br /> |
892 | 1157 | <p> |
893 | 1158 | <label for="customcss">Custom CSS web path</label> |
894 | - <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" /> |
|
1159 | + <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) { |
|
1160 | + echo $globalCustomCSS; |
|
1161 | +} |
|
1162 | +?>" /> |
|
895 | 1163 | </p> |
896 | 1164 | </fieldset> |
897 | 1165 | <input type="submit" name="submit" value="Create/Update database & write setup" /> |
@@ -918,8 +1186,12 @@ discard block |
||
918 | 1186 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
919 | 1187 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
920 | 1188 | |
921 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
922 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1189 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
1190 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
1191 | + } |
|
1192 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
1193 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1194 | + } |
|
923 | 1195 | |
924 | 1196 | $_SESSION['database_root'] = $dbroot; |
925 | 1197 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -987,15 +1259,23 @@ discard block |
||
987 | 1259 | $source_city = $_POST['source_city']; |
988 | 1260 | $source_country = $_POST['source_country']; |
989 | 1261 | $source_ref = $_POST['source_ref']; |
990 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
991 | - else $source_id = array(); |
|
1262 | + if (isset($source_id)) { |
|
1263 | + $source_id = $_POST['source_id']; |
|
1264 | + } else { |
|
1265 | + $source_id = array(); |
|
1266 | + } |
|
992 | 1267 | |
993 | 1268 | $sources = array(); |
994 | 1269 | foreach ($source_name as $keys => $name) { |
995 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
996 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1270 | + if (isset($source_id[$keys])) { |
|
1271 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1272 | + } else { |
|
1273 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1274 | + } |
|
1275 | + } |
|
1276 | + if (count($sources) > 0) { |
|
1277 | + $_SESSION['sources'] = $sources; |
|
997 | 1278 | } |
998 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
999 | 1279 | |
1000 | 1280 | //$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING); |
1001 | 1281 | //$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT); |
@@ -1016,14 +1296,23 @@ discard block |
||
1016 | 1296 | $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
1017 | 1297 | |
1018 | 1298 | $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
1019 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1020 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1299 | + if ($globalaircraft == 'aircraft') { |
|
1300 | + $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1301 | + } else { |
|
1302 | + $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1303 | + } |
|
1021 | 1304 | $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
1022 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1023 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1305 | + if ($globaltracker == 'tracker') { |
|
1306 | + $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1307 | + } else { |
|
1308 | + $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1309 | + } |
|
1024 | 1310 | $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
1025 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1026 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1311 | + if ($globalmarine == 'marine') { |
|
1312 | + $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1313 | + } else { |
|
1314 | + $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1315 | + } |
|
1027 | 1316 | |
1028 | 1317 | /* |
1029 | 1318 | $globalSBS1Hosts = array(); |
@@ -1045,19 +1334,35 @@ discard block |
||
1045 | 1334 | $name = $_POST['name']; |
1046 | 1335 | $format = $_POST['format']; |
1047 | 1336 | $timezone = $_POST['timezone']; |
1048 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
1049 | - else $sourcestats = array(); |
|
1050 | - if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive']; |
|
1051 | - else $noarchive = array(); |
|
1337 | + if (isset($_POST['sourcestats'])) { |
|
1338 | + $sourcestats = $_POST['sourcestats']; |
|
1339 | + } else { |
|
1340 | + $sourcestats = array(); |
|
1341 | + } |
|
1342 | + if (isset($_POST['noarchive'])) { |
|
1343 | + $noarchive = $_POST['noarchive']; |
|
1344 | + } else { |
|
1345 | + $noarchive = array(); |
|
1346 | + } |
|
1052 | 1347 | $gSources = array(); |
1053 | 1348 | $forcepilots = false; |
1054 | 1349 | foreach ($host as $key => $h) { |
1055 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
1056 | - else $cov = 'FALSE'; |
|
1057 | - if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
|
1058 | - else $arch = 'FALSE'; |
|
1059 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]); |
|
1060 | - if ($format[$key] == 'airwhere') $forcepilots = true; |
|
1350 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
1351 | + $cov = 'TRUE'; |
|
1352 | + } else { |
|
1353 | + $cov = 'FALSE'; |
|
1354 | + } |
|
1355 | + if (isset($noarchive[$key]) && $noarchive[$key] == 1) { |
|
1356 | + $arch = 'TRUE'; |
|
1357 | + } else { |
|
1358 | + $arch = 'FALSE'; |
|
1359 | + } |
|
1360 | + if ($h != '') { |
|
1361 | + $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]); |
|
1362 | + } |
|
1363 | + if ($format[$key] == 'airwhere') { |
|
1364 | + $forcepilots = true; |
|
1365 | + } |
|
1061 | 1366 | } |
1062 | 1367 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
1063 | 1368 | |
@@ -1085,7 +1390,9 @@ discard block |
||
1085 | 1390 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
1086 | 1391 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1087 | 1392 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
1088 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1393 | + } else { |
|
1394 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1395 | + } |
|
1089 | 1396 | |
1090 | 1397 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
1091 | 1398 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -1124,7 +1431,9 @@ discard block |
||
1124 | 1431 | |
1125 | 1432 | // Create in settings.php keys not yet configurable if not already here |
1126 | 1433 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1127 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1434 | + if (!isset($globalDebug)) { |
|
1435 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1436 | + } |
|
1128 | 1437 | |
1129 | 1438 | $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
1130 | 1439 | if ($resetyearstats == 'resetyearstats') { |
@@ -1161,37 +1470,56 @@ discard block |
||
1161 | 1470 | } |
1162 | 1471 | */ |
1163 | 1472 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
1164 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1165 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1166 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1167 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1473 | + if ($globalsbs == 'sbs') { |
|
1474 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1475 | + } else { |
|
1476 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1477 | + } |
|
1478 | + if ($globalaprs == 'aprs') { |
|
1479 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1480 | + } else { |
|
1481 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1482 | + } |
|
1168 | 1483 | $va = false; |
1169 | 1484 | if ($globalivao == 'ivao') { |
1170 | 1485 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
1171 | 1486 | $va = true; |
1172 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1487 | + } else { |
|
1488 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1489 | + } |
|
1173 | 1490 | if ($globalvatsim == 'vatsim') { |
1174 | 1491 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
1175 | 1492 | $va = true; |
1176 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1493 | + } else { |
|
1494 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1495 | + } |
|
1177 | 1496 | if ($globalphpvms == 'phpvms') { |
1178 | 1497 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
1179 | 1498 | $va = true; |
1180 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1499 | + } else { |
|
1500 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1501 | + } |
|
1181 | 1502 | if ($globalvam == 'vam') { |
1182 | 1503 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
1183 | 1504 | $va = true; |
1184 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1505 | + } else { |
|
1506 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1507 | + } |
|
1185 | 1508 | if ($va) { |
1186 | 1509 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
1187 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1510 | + } else { |
|
1511 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1512 | + } |
|
1188 | 1513 | if ($globalva == 'va' || $va) { |
1189 | 1514 | $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
1190 | 1515 | $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
1191 | 1516 | } else { |
1192 | 1517 | $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
1193 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1194 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1518 | + if ($forcepilots) { |
|
1519 | + $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1520 | + } else { |
|
1521 | + $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1522 | + } |
|
1195 | 1523 | } |
1196 | 1524 | |
1197 | 1525 | |
@@ -1358,7 +1686,9 @@ discard block |
||
1358 | 1686 | $settings = array_merge($settings,array('globalNoAirlines' => 'FALSE')); |
1359 | 1687 | } |
1360 | 1688 | |
1361 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1689 | + if (!isset($globalTransaction)) { |
|
1690 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1691 | + } |
|
1362 | 1692 | |
1363 | 1693 | // Set some defaults values... |
1364 | 1694 | if (!isset($globalAircraftImageSources)) { |
@@ -1373,15 +1703,23 @@ discard block |
||
1373 | 1703 | |
1374 | 1704 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1375 | 1705 | |
1376 | - if ($error == '') settings::modify_settings($settings); |
|
1377 | - if ($error == '') settings::comment_settings($settings_comment); |
|
1706 | + if ($error == '') { |
|
1707 | + settings::modify_settings($settings); |
|
1708 | + } |
|
1709 | + if ($error == '') { |
|
1710 | + settings::comment_settings($settings_comment); |
|
1711 | + } |
|
1378 | 1712 | if ($error != '') { |
1379 | 1713 | print '<div class="info column">'.$error.'</div>'; |
1380 | 1714 | require('../footer.php'); |
1381 | 1715 | exit; |
1382 | 1716 | } else { |
1383 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
1384 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
1717 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
1718 | + $_SESSION['waypoints'] = 1; |
|
1719 | + } |
|
1720 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
1721 | + $_SESSION['owner'] = 1; |
|
1722 | + } |
|
1385 | 1723 | if (isset($_POST['createdb'])) { |
1386 | 1724 | $_SESSION['install'] = 'database_create'; |
1387 | 1725 | } else { |
@@ -1422,10 +1760,18 @@ discard block |
||
1422 | 1760 | $popw = false; |
1423 | 1761 | foreach ($_SESSION['done'] as $done) { |
1424 | 1762 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
1425 | - if ($done == 'Create database') $pop = true; |
|
1426 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1427 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1428 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1763 | + if ($done == 'Create database') { |
|
1764 | + $pop = true; |
|
1765 | + } |
|
1766 | + if ($_SESSION['install'] == 'database_create') { |
|
1767 | + $pop = true; |
|
1768 | + } |
|
1769 | + if ($_SESSION['install'] == 'database_import') { |
|
1770 | + $popi = true; |
|
1771 | + } |
|
1772 | + if ($_SESSION['install'] == 'waypoints') { |
|
1773 | + $popw = true; |
|
1774 | + } |
|
1429 | 1775 | } |
1430 | 1776 | if ($pop) { |
1431 | 1777 | sleep(5); |
@@ -1436,7 +1782,9 @@ discard block |
||
1436 | 1782 | } else if ($popw) { |
1437 | 1783 | sleep(5); |
1438 | 1784 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
1439 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
1785 | + } else { |
|
1786 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
1787 | + } |
|
1440 | 1788 | print '</div></ul>'; |
1441 | 1789 | print '<div id="error"></div>'; |
1442 | 1790 | /* foreach ($_SESSION['done'] as $done) { |