@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
77 | 95 | if (isset($options['enable-aircraft'])) { |
78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo 'Enable Aircraft mode'."\n"; |
|
98 | + } |
|
79 | 99 | $globalAircraft = TRUE; |
80 | 100 | } |
81 | 101 | if (isset($options['disable-aircraft'])) { |
82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo 'Disable Aircraft mode'."\n"; |
|
104 | + } |
|
83 | 105 | $globalAircraft = FALSE; |
84 | 106 | } |
85 | 107 | if (isset($options['enable-tracker'])) { |
86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
108 | + if ($globalDebug) { |
|
109 | + echo 'Enable Tracker mode'."\n"; |
|
110 | + } |
|
87 | 111 | $globalTracker = TRUE; |
88 | 112 | } |
89 | 113 | if (isset($options['disable-tracker'])) { |
90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
114 | + if ($globalDebug) { |
|
115 | + echo 'Disable Tracker mode'."\n"; |
|
116 | + } |
|
91 | 117 | $globalTracker = FALSE; |
92 | 118 | } |
93 | 119 | if (isset($options['enable-marine'])) { |
94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo 'Enable Marine mode'."\n"; |
|
122 | + } |
|
95 | 123 | $globalMarine = TRUE; |
96 | 124 | } |
97 | 125 | if (isset($options['disable-marine'])) { |
98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
126 | + if ($globalDebug) { |
|
127 | + echo 'Disable Marine mode'."\n"; |
|
128 | + } |
|
99 | 129 | $globalMarine = FALSE; |
100 | 130 | } |
101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
104 | -else $id_source = 1; |
|
131 | +if (isset($options['nodaemon'])) { |
|
132 | + $globalDaemon = FALSE; |
|
133 | +} |
|
134 | +if (isset($options['server'])) { |
|
135 | + $globalServer = TRUE; |
|
136 | +} |
|
137 | +if (isset($options['idsource'])) { |
|
138 | + $id_source = $options['idsource']; |
|
139 | +} else { |
|
140 | + $id_source = 1; |
|
141 | +} |
|
105 | 142 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Using Server Mode\n"; |
|
145 | + } |
|
107 | 146 | $SI=new SpotterServer(); |
108 | 147 | /* |
109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 149 | $SI = new adsb2aprs(); |
111 | 150 | $SI->connect(); |
112 | 151 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
152 | +} else { |
|
153 | + $SI=new SpotterImport($Connection->db); |
|
154 | +} |
|
114 | 155 | |
115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
156 | +if (isset($globalTracker) && $globalTracker) { |
|
157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
158 | +} |
|
116 | 159 | if (isset($globalMarine) && $globalMarine) { |
117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
119 | 162 | } |
120 | 163 | |
121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
164 | +if (isset($globalTracker) && $globalTracker) { |
|
165 | + $TI = new TrackerImport($Connection->db); |
|
166 | +} |
|
122 | 167 | if (isset($globalMarine) && $globalMarine) { |
123 | 168 | $AIS = new AIS(); |
124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
143 | 188 | } |
144 | 189 | |
145 | 190 | // let's try and connect |
146 | -if ($globalDebug) echo "Connecting...\n"; |
|
191 | +if ($globalDebug) { |
|
192 | + echo "Connecting...\n"; |
|
193 | +} |
|
147 | 194 | $use_aprs = false; |
148 | 195 | $aprs_full = false; |
149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
154 | 201 | $reset++; |
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Connect to all...'."\n"; |
|
204 | + } |
|
156 | 205 | foreach ($hosts as $id => $value) { |
157 | 206 | $host = $value['host']; |
158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,22 +211,30 @@ discard block |
||
162 | 211 | //$formats[$id] = 'deltadbtxt'; |
163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 213 | //$last_exec['deltadbtxt'] = 0; |
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
216 | + } |
|
166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
167 | 218 | //$formats[$id] = 'vatsimtxt'; |
168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 220 | //$last_exec['vatsimtxt'] = 0; |
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
223 | + } |
|
171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
230 | + } |
|
176 | 231 | } else if (preg_match('/opensky/i',$host)) { |
177 | 232 | //$formats[$id] = 'aircraftlistjson'; |
178 | 233 | $globalSources[$id]['format'] = 'opensky'; |
179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to opensky source (".$host.")...\n"; |
|
237 | + } |
|
181 | 238 | /* |
182 | 239 | // Disabled for now, site change source format |
183 | 240 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -194,7 +251,9 @@ discard block |
||
194 | 251 | //$formats[$id] = 'planeupdatefaa'; |
195 | 252 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
196 | 253 | //$last_exec['planeupdatefaa'] = 0; |
197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
254 | + if ($globalDebug) { |
|
255 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
256 | + } |
|
198 | 257 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
199 | 258 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
200 | 259 | exit(0); |
@@ -203,32 +262,46 @@ discard block |
||
203 | 262 | //$formats[$id] = 'phpvmacars'; |
204 | 263 | $globalSources[$id]['format'] = 'phpvmacars'; |
205 | 264 | //$last_exec['phpvmacars'] = 0; |
206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
265 | + if ($globalDebug) { |
|
266 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
267 | + } |
|
207 | 268 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
208 | 269 | //$formats[$id] = 'phpvmacars'; |
209 | 270 | $globalSources[$id]['format'] = 'vam'; |
210 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
271 | + if ($globalDebug) { |
|
272 | + echo "Connect to Vam source (".$host.")...\n"; |
|
273 | + } |
|
211 | 274 | } else if (preg_match('/whazzup/i',$host)) { |
212 | 275 | //$formats[$id] = 'whazzup'; |
213 | 276 | $globalSources[$id]['format'] = 'whazzup'; |
214 | 277 | //$last_exec['whazzup'] = 0; |
215 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
278 | + if ($globalDebug) { |
|
279 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
280 | + } |
|
216 | 281 | } else if (preg_match('/blitzortung/i',$host)) { |
217 | 282 | $globalSources[$id]['format'] = 'blitzortung'; |
218 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
283 | + if ($globalDebug) { |
|
284 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
285 | + } |
|
219 | 286 | } else if (preg_match('/airwhere/i',$host)) { |
220 | 287 | $globalSources[$id]['format'] = 'airwhere'; |
221 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
288 | + if ($globalDebug) { |
|
289 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
290 | + } |
|
222 | 291 | } else if (preg_match('/recentpireps/i',$host)) { |
223 | 292 | //$formats[$id] = 'pirepsjson'; |
224 | 293 | $globalSources[$id]['format'] = 'pirepsjson'; |
225 | 294 | //$last_exec['pirepsjson'] = 0; |
226 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
295 | + if ($globalDebug) { |
|
296 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
297 | + } |
|
227 | 298 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
228 | 299 | //$formats[$id] = 'fr24json'; |
229 | 300 | $globalSources[$id]['format'] = 'fr24json'; |
230 | 301 | //$last_exec['fr24json'] = 0; |
231 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
302 | + if ($globalDebug) { |
|
303 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
304 | + } |
|
232 | 305 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
233 | 306 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
234 | 307 | exit(0); |
@@ -237,7 +310,9 @@ discard block |
||
237 | 310 | //$formats[$id] = 'fr24json'; |
238 | 311 | $globalSources[$id]['format'] = 'myshiptracking'; |
239 | 312 | //$last_exec['fr24json'] = 0; |
240 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
313 | + if ($globalDebug) { |
|
314 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
315 | + } |
|
241 | 316 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
242 | 317 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
243 | 318 | exit(0); |
@@ -246,16 +321,24 @@ discard block |
||
246 | 321 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
247 | 322 | //$formats[$id] = 'tsv'; |
248 | 323 | $globalSources[$id]['format'] = 'tsv'; |
249 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
324 | + if ($globalDebug) { |
|
325 | + echo "Connect to tsv source (".$host.")...\n"; |
|
326 | + } |
|
250 | 327 | } |
251 | 328 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
252 | 329 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
253 | 330 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
254 | 331 | if ($idf !== false) { |
255 | 332 | $httpfeeds[$id] = $idf; |
256 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
258 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
333 | + if ($globalDebug) { |
|
334 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
335 | + } |
|
336 | + } elseif ($globalDebug) { |
|
337 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
338 | + } |
|
339 | + } elseif ($globalDebug) { |
|
340 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
341 | + } |
|
259 | 342 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
260 | 343 | $hostport = explode(':',$host); |
261 | 344 | if (isset($hostport[1])) { |
@@ -295,17 +378,25 @@ discard block |
||
295 | 378 | //$formats[$id] = 'beast'; |
296 | 379 | $globalSources[$id]['format'] = 'beast'; |
297 | 380 | //} else $formats[$id] = 'sbs'; |
298 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
381 | + } else { |
|
382 | + $globalSources[$id]['format'] = 'sbs'; |
|
383 | + } |
|
299 | 384 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
300 | 385 | } |
301 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
386 | + if ($globalDebug) { |
|
387 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
388 | + } |
|
302 | 389 | } else { |
303 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
390 | + if ($globalDebug) { |
|
391 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
392 | + } |
|
304 | 393 | } |
305 | 394 | } |
306 | 395 | } |
307 | 396 | } |
308 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
397 | +if (!isset($globalMinFetch)) { |
|
398 | + $globalMinFetch = 15; |
|
399 | +} |
|
309 | 400 | |
310 | 401 | // Initialize all |
311 | 402 | $status = array(); |
@@ -314,13 +405,19 @@ discard block |
||
314 | 405 | $formats = array(); |
315 | 406 | $last_exec = array(); |
316 | 407 | $time = time(); |
317 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
318 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
319 | -else $timeout = 20; |
|
408 | +if (isset($globalSourcesTimeout)) { |
|
409 | + $timeout = $globalSourcesTimeOut; |
|
410 | +} else if (isset($globalSBS1TimeOut)) { |
|
411 | + $timeout = $globalSBS1TimeOut; |
|
412 | +} else { |
|
413 | + $timeout = 20; |
|
414 | +} |
|
320 | 415 | $errno = ''; |
321 | 416 | $errstr=''; |
322 | 417 | |
323 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
418 | +if (!isset($globalDaemon)) { |
|
419 | + $globalDaemon = TRUE; |
|
420 | +} |
|
324 | 421 | /* Initiate connections to all the hosts simultaneously */ |
325 | 422 | //connect_all($hosts); |
326 | 423 | //connect_all($globalSources); |
@@ -349,7 +446,9 @@ discard block |
||
349 | 446 | if (isset($source['format']) && $source['format'] == 'aprs') { |
350 | 447 | $aprs_connect = 0; |
351 | 448 | $use_aprs = true; |
352 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
449 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
450 | + $aprs_full = true; |
|
451 | + } |
|
353 | 452 | break; |
354 | 453 | } |
355 | 454 | } |
@@ -360,25 +459,46 @@ discard block |
||
360 | 459 | $aprs_connect = 0; |
361 | 460 | $aprs_keep = 120; |
362 | 461 | $aprs_last_tx = time(); |
363 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
364 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
365 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
366 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
367 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
368 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
369 | - if ($aprs_full) $aprs_filter = ''; |
|
370 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
371 | - else $aprs_pass = '-1'; |
|
462 | + if (isset($globalAPRSversion)) { |
|
463 | + $aprs_version = $globalAPRSversion; |
|
464 | + } else { |
|
465 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
466 | + } |
|
467 | + if (isset($globalAPRSssid)) { |
|
468 | + $aprs_ssid = $globalAPRSssid; |
|
469 | + } else { |
|
470 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
471 | + } |
|
472 | + if (isset($globalAPRSfilter)) { |
|
473 | + $aprs_filter = $globalAPRSfilter; |
|
474 | + } else { |
|
475 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
476 | + } |
|
477 | + if ($aprs_full) { |
|
478 | + $aprs_filter = ''; |
|
479 | + } |
|
480 | + if (isset($globalAPRSpass)) { |
|
481 | + $aprs_pass = $globalAPRSpass; |
|
482 | + } else { |
|
483 | + $aprs_pass = '-1'; |
|
484 | + } |
|
372 | 485 | |
373 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
374 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
375 | -} |
|
486 | + if ($aprs_filter != '') { |
|
487 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
488 | + } else { |
|
489 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
490 | + } |
|
491 | + } |
|
376 | 492 | |
377 | 493 | // connected - lets do some work |
378 | 494 | //if ($globalDebug) echo "Connected!\n"; |
379 | 495 | sleep(1); |
380 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
381 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
496 | +if ($globalDebug) { |
|
497 | + echo "SCAN MODE \n\n"; |
|
498 | +} |
|
499 | +if (!isset($globalCronEnd)) { |
|
500 | + $globalCronEnd = 60; |
|
501 | +} |
|
382 | 502 | $endtime = time()+$globalCronEnd; |
383 | 503 | $i = 1; |
384 | 504 | $tt = array(); |
@@ -392,20 +512,28 @@ discard block |
||
392 | 512 | |
393 | 513 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
394 | 514 | while ($i > 0) { |
395 | - if (!$globalDaemon) $i = $endtime-time(); |
|
515 | + if (!$globalDaemon) { |
|
516 | + $i = $endtime-time(); |
|
517 | + } |
|
396 | 518 | // Delete old ATC |
397 | 519 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
398 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
520 | + if ($globalDebug) { |
|
521 | + echo 'Delete old ATC...'."\n"; |
|
522 | + } |
|
399 | 523 | $ATC->deleteOldATC(); |
400 | 524 | } |
401 | 525 | |
402 | 526 | if (count($last_exec) == count($globalSources)) { |
403 | 527 | $max = $globalMinFetch; |
404 | 528 | foreach ($last_exec as $last) { |
405 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
529 | + if ((time() - $last['last']) < $max) { |
|
530 | + $max = time() - $last['last']; |
|
531 | + } |
|
406 | 532 | } |
407 | 533 | if ($max != $globalMinFetch) { |
408 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
534 | + if ($globalDebug) { |
|
535 | + echo 'Sleeping...'."\n"; |
|
536 | + } |
|
409 | 537 | sleep($globalMinFetch-$max+2); |
410 | 538 | } |
411 | 539 | } |
@@ -415,7 +543,9 @@ discard block |
||
415 | 543 | foreach ($globalSources as $id => $value) { |
416 | 544 | date_default_timezone_set('UTC'); |
417 | 545 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
418 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
546 | + if (!isset($last_exec[$id]['last'])) { |
|
547 | + $last_exec[$id]['last'] = 0; |
|
548 | + } |
|
419 | 549 | if ($value['format'] == 'deltadbtxt' && |
420 | 550 | ( |
421 | 551 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -424,7 +554,9 @@ discard block |
||
424 | 554 | ) { |
425 | 555 | //$buffer = $Common->getData($hosts[$id]); |
426 | 556 | $buffer = $Common->getData($value['host']); |
427 | - if ($buffer != '') $reset = 0; |
|
557 | + if ($buffer != '') { |
|
558 | + $reset = 0; |
|
559 | + } |
|
428 | 560 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
429 | 561 | $buffer = explode('\n',$buffer); |
430 | 562 | foreach ($buffer as $line) { |
@@ -433,20 +565,41 @@ discard block |
||
433 | 565 | $data = array(); |
434 | 566 | $data['hex'] = $line[1]; // hex |
435 | 567 | $data['ident'] = $line[2]; // ident |
436 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
437 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
438 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
439 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
440 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
568 | + if (isset($line[3])) { |
|
569 | + $data['altitude'] = $line[3]; |
|
570 | + } |
|
571 | + // altitude |
|
572 | + if (isset($line[4])) { |
|
573 | + $data['speed'] = $line[4]; |
|
574 | + } |
|
575 | + // speed |
|
576 | + if (isset($line[5])) { |
|
577 | + $data['heading'] = $line[5]; |
|
578 | + } |
|
579 | + // heading |
|
580 | + if (isset($line[6])) { |
|
581 | + $data['latitude'] = $line[6]; |
|
582 | + } |
|
583 | + // lat |
|
584 | + if (isset($line[7])) { |
|
585 | + $data['longitude'] = $line[7]; |
|
586 | + } |
|
587 | + // long |
|
441 | 588 | $data['verticalrate'] = ''; // vertical rate |
442 | 589 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
443 | 590 | $data['emergency'] = ''; // emergency |
444 | 591 | $data['datetime'] = date('Y-m-d H:i:s'); |
445 | 592 | $data['format_source'] = 'deltadbtxt'; |
446 | 593 | $data['id_source'] = $id_source; |
447 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
448 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
449 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
594 | + if (isset($value['name']) && $value['name'] != '') { |
|
595 | + $data['source_name'] = $value['name']; |
|
596 | + } |
|
597 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
598 | + $data['noarchive'] = true; |
|
599 | + } |
|
600 | + if (isset($value['sourcestats'])) { |
|
601 | + $data['sourcestats'] = $value['sourcestats']; |
|
602 | + } |
|
450 | 603 | $SI->add($data); |
451 | 604 | unset($data); |
452 | 605 | } |
@@ -461,7 +614,9 @@ discard block |
||
461 | 614 | date_default_timezone_set('CET'); |
462 | 615 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
463 | 616 | date_default_timezone_set('UTC'); |
464 | - if ($buffer != '') $reset = 0; |
|
617 | + if ($buffer != '') { |
|
618 | + $reset = 0; |
|
619 | + } |
|
465 | 620 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
466 | 621 | $buffer = explode('\n',$buffer); |
467 | 622 | foreach ($buffer as $line) { |
@@ -470,16 +625,36 @@ discard block |
||
470 | 625 | $add = false; |
471 | 626 | $ais_data = $AIS->parse_line(trim($line)); |
472 | 627 | $data = array(); |
473 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
474 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
475 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
476 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
477 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
478 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
479 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
480 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
481 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
482 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
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['type'])) { |
|
650 | + $data['type'] = $ais_data['type']; |
|
651 | + } |
|
652 | + if (isset($ais_data['imo'])) { |
|
653 | + $data['imo'] = $ais_data['imo']; |
|
654 | + } |
|
655 | + if (isset($ais_data['callsign'])) { |
|
656 | + $data['callsign'] = $ais_data['callsign']; |
|
657 | + } |
|
483 | 658 | if (isset($ais_data['timestamp'])) { |
484 | 659 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
485 | 660 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -493,8 +668,12 @@ discard block |
||
493 | 668 | $data['format_source'] = 'aisnmeatxt'; |
494 | 669 | $data['id_source'] = $id_source; |
495 | 670 | //print_r($data); |
496 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
497 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
671 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
672 | + $data['noarchive'] = true; |
|
673 | + } |
|
674 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
675 | + $MI->add($data); |
|
676 | + } |
|
498 | 677 | unset($data); |
499 | 678 | } |
500 | 679 | } |
@@ -517,20 +696,48 @@ discard block |
||
517 | 696 | if ($line != '') { |
518 | 697 | $ais_data = $AIS->parse_line(trim($line)); |
519 | 698 | $data = array(); |
520 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
521 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
522 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
523 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
524 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
525 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
526 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
527 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
528 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
529 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
530 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
531 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
532 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
533 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
699 | + if (isset($ais_data['ident'])) { |
|
700 | + $data['ident'] = $ais_data['ident']; |
|
701 | + } |
|
702 | + if (isset($ais_data['mmsi'])) { |
|
703 | + $data['mmsi'] = $ais_data['mmsi']; |
|
704 | + } |
|
705 | + if (isset($ais_data['speed'])) { |
|
706 | + $data['speed'] = $ais_data['speed']; |
|
707 | + } |
|
708 | + if (isset($ais_data['heading'])) { |
|
709 | + $data['heading'] = $ais_data['heading']; |
|
710 | + } |
|
711 | + if (isset($ais_data['latitude'])) { |
|
712 | + $data['latitude'] = $ais_data['latitude']; |
|
713 | + } |
|
714 | + if (isset($ais_data['longitude'])) { |
|
715 | + $data['longitude'] = $ais_data['longitude']; |
|
716 | + } |
|
717 | + if (isset($ais_data['status'])) { |
|
718 | + $data['status'] = $ais_data['status']; |
|
719 | + } |
|
720 | + if (isset($ais_data['statusid'])) { |
|
721 | + $data['status_id'] = $ais_data['statusid']; |
|
722 | + } |
|
723 | + if (isset($ais_data['type'])) { |
|
724 | + $data['type'] = $ais_data['type']; |
|
725 | + } |
|
726 | + if (isset($ais_data['typeid'])) { |
|
727 | + $data['type_id'] = $ais_data['typeid']; |
|
728 | + } |
|
729 | + if (isset($ais_data['imo'])) { |
|
730 | + $data['imo'] = $ais_data['imo']; |
|
731 | + } |
|
732 | + if (isset($ais_data['callsign'])) { |
|
733 | + $data['callsign'] = $ais_data['callsign']; |
|
734 | + } |
|
735 | + if (isset($ais_data['destination'])) { |
|
736 | + $data['arrival_code'] = $ais_data['destination']; |
|
737 | + } |
|
738 | + if (isset($ais_data['eta_ts'])) { |
|
739 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
740 | + } |
|
534 | 741 | if (isset($ais_data['timestamp'])) { |
535 | 742 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
536 | 743 | } else { |
@@ -538,18 +745,27 @@ discard block |
||
538 | 745 | } |
539 | 746 | $data['format_source'] = 'aisnmeahttp'; |
540 | 747 | $data['id_source'] = $id_source; |
541 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
542 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
748 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
749 | + $data['noarchive'] = true; |
|
750 | + } |
|
751 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
752 | + $MI->add($data); |
|
753 | + } |
|
543 | 754 | unset($data); |
544 | 755 | } |
545 | 756 | } |
546 | 757 | } |
547 | 758 | } else { |
548 | 759 | $format = $value['format']; |
549 | - if (isset($tt[$format])) $tt[$format]++; |
|
550 | - else $tt[$format] = 0; |
|
760 | + if (isset($tt[$format])) { |
|
761 | + $tt[$format]++; |
|
762 | + } else { |
|
763 | + $tt[$format] = 0; |
|
764 | + } |
|
551 | 765 | if ($tt[$format] > 30) { |
552 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
766 | + if ($globalDebug) { |
|
767 | + echo 'Reconnect...'."\n"; |
|
768 | + } |
|
553 | 769 | sleep(2); |
554 | 770 | //$sourceeen[] = $value; |
555 | 771 | //connect_all($sourceeen); |
@@ -588,7 +804,9 @@ discard block |
||
588 | 804 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
589 | 805 | $data['format_source'] = 'myshiptracking'; |
590 | 806 | $data['id_source'] = $id_source; |
591 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
807 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
808 | + $data['noarchive'] = true; |
|
809 | + } |
|
592 | 810 | $MI->add($data); |
593 | 811 | unset($data); |
594 | 812 | } |
@@ -613,7 +831,9 @@ discard block |
||
613 | 831 | $data['callsign'] = $line['callsign']; |
614 | 832 | $data['mmsi'] = $line['mmsi']; |
615 | 833 | $data['speed'] = $line['sog']; |
616 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
834 | + if ($line['heading'] != '511') { |
|
835 | + $data['heading'] = $line['heading']; |
|
836 | + } |
|
617 | 837 | $data['latitude'] = $line['latitude']; |
618 | 838 | $data['longitude'] = $line['longitude']; |
619 | 839 | $data['type_id'] = $line['shiptype']; |
@@ -621,7 +841,9 @@ discard block |
||
621 | 841 | $data['datetime'] = $line['time']; |
622 | 842 | $data['format_source'] = 'boatbeaconapp'; |
623 | 843 | $data['id_source'] = $id_source; |
624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
844 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
845 | + $data['noarchive'] = true; |
|
846 | + } |
|
625 | 847 | $MI->add($data); |
626 | 848 | unset($data); |
627 | 849 | } |
@@ -642,22 +864,44 @@ discard block |
||
642 | 864 | if (isset($all_data['features'][0]['id'])) { |
643 | 865 | foreach ($all_data['features'] as $line) { |
644 | 866 | $data = array(); |
645 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
646 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
647 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
648 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
649 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
650 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
867 | + if (isset($line['properties']['name'])) { |
|
868 | + $data['ident'] = $line['properties']['name']; |
|
869 | + } |
|
870 | + if (isset($line['properties']['callsign'])) { |
|
871 | + $data['callsign'] = $line['properties']['callsign']; |
|
872 | + } |
|
873 | + if (isset($line['properties']['mmsi'])) { |
|
874 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
875 | + } |
|
876 | + if (isset($line['properties']['imo'])) { |
|
877 | + $data['mmsi'] = $line['properties']['imo']; |
|
878 | + } |
|
879 | + if (isset($line['properties']['speed'])) { |
|
880 | + $data['speed'] = $line['properties']['speed']; |
|
881 | + } |
|
882 | + if (isset($line['properties']['heading'])) { |
|
883 | + $data['heading'] = $line['properties']['heading']; |
|
884 | + } |
|
651 | 885 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
652 | 886 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
653 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
654 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
655 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
887 | + if (isset($line['properties']['vesselType'])) { |
|
888 | + $data['type'] = $line['properties']['vesselType']; |
|
889 | + } |
|
890 | + if (isset($line['properties']['destination'])) { |
|
891 | + $data['arrival_code'] = $line['properties']['destination']; |
|
892 | + } |
|
893 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
894 | + $data['arrival_date'] = $line['properties']['eta']; |
|
895 | + } |
|
656 | 896 | $data['format_source'] = 'boatnerd'; |
657 | 897 | $data['id_source'] = $id_source; |
658 | 898 | $data['datetime'] = date('Y-m-d H:i:s'); |
659 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
660 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
899 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
900 | + $data['noarchive'] = true; |
|
901 | + } |
|
902 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
903 | + $MI->add($data); |
|
904 | + } |
|
661 | 905 | unset($data); |
662 | 906 | } |
663 | 907 | } |
@@ -673,7 +917,9 @@ discard block |
||
673 | 917 | echo 'download...'; |
674 | 918 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
675 | 919 | echo 'done !'."\n"; |
676 | - if ($buffer != '') $reset = 0; |
|
920 | + if ($buffer != '') { |
|
921 | + $reset = 0; |
|
922 | + } |
|
677 | 923 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
678 | 924 | $buffer = explode('\n',$buffer); |
679 | 925 | foreach ($buffer as $line) { |
@@ -698,7 +944,9 @@ discard block |
||
698 | 944 | //$data['etaTime'] = substr($line,135,5); |
699 | 945 | $data['format_source'] = 'shipplotter'; |
700 | 946 | $data['id_source'] = $id_source; |
701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
947 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
948 | + $data['noarchive'] = true; |
|
949 | + } |
|
702 | 950 | //print_r($data); |
703 | 951 | echo 'Add...'."\n"; |
704 | 952 | $MI->add($data); |
@@ -732,16 +980,28 @@ discard block |
||
732 | 980 | $line = explode(':', $line); |
733 | 981 | if (count($line) > 30 && $line[0] != 'callsign') { |
734 | 982 | $data = array(); |
735 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
736 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
983 | + if (isset($line[37]) && $line[37] != '') { |
|
984 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
985 | + } else { |
|
986 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
987 | + } |
|
737 | 988 | $data['pilot_id'] = $line[1]; |
738 | 989 | $data['pilot_name'] = $line[2]; |
739 | 990 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
740 | 991 | $data['ident'] = $line[0]; // ident |
741 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
992 | + if ($line[7] != '' && $line[7] != 0) { |
|
993 | + $data['altitude'] = $line[7]; |
|
994 | + } |
|
995 | + // altitude |
|
742 | 996 | $data['speed'] = $line[8]; // speed |
743 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
744 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
997 | + if (isset($line[45])) { |
|
998 | + $data['heading'] = $line[45]; |
|
999 | + } |
|
1000 | + // heading |
|
1001 | + elseif (isset($line[38])) { |
|
1002 | + $data['heading'] = $line[38]; |
|
1003 | + } |
|
1004 | + // heading |
|
745 | 1005 | $data['latitude'] = $line[5]; // lat |
746 | 1006 | $data['longitude'] = $line[6]; // long |
747 | 1007 | $data['verticalrate'] = ''; // vertical rate |
@@ -757,7 +1017,9 @@ discard block |
||
757 | 1017 | $data['frequency'] = $line[4]; |
758 | 1018 | $data['type'] = $line[18]; |
759 | 1019 | $data['range'] = $line[19]; |
760 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1020 | + if (isset($line[35])) { |
|
1021 | + $data['info'] = $line[35]; |
|
1022 | + } |
|
761 | 1023 | $data['id_source'] = $id_source; |
762 | 1024 | //$data['arrival_airport_time'] = ; |
763 | 1025 | if ($line[9] != '') { |
@@ -771,27 +1033,47 @@ discard block |
||
771 | 1033 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
772 | 1034 | */ |
773 | 1035 | $data['format_source'] = $value['format']; |
774 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
775 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
776 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
777 | - elseif ($line[3] == 'ATC') { |
|
1036 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1037 | + $data['noarchive'] = true; |
|
1038 | + } |
|
1039 | + if (isset($value['name']) && $value['name'] != '') { |
|
1040 | + $data['source_name'] = $value['name']; |
|
1041 | + } |
|
1042 | + if ($line[3] == 'PILOT') { |
|
1043 | + $SI->add($data); |
|
1044 | + } elseif ($line[3] == 'ATC') { |
|
778 | 1045 | //print_r($data); |
779 | 1046 | $data['info'] = str_replace('^§','<br />',$data['info']); |
780 | 1047 | $data['info'] = str_replace('&sect;','',$data['info']); |
781 | 1048 | $typec = substr($data['ident'],-3); |
782 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
783 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
784 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
785 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
786 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
787 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
788 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
789 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
790 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
791 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1049 | + if ($typec == 'APP') { |
|
1050 | + $data['type'] = 'Approach'; |
|
1051 | + } elseif ($typec == 'TWR') { |
|
1052 | + $data['type'] = 'Tower'; |
|
1053 | + } elseif ($typec == 'OBS') { |
|
1054 | + $data['type'] = 'Observer'; |
|
1055 | + } elseif ($typec == 'GND') { |
|
1056 | + $data['type'] = 'Ground'; |
|
1057 | + } elseif ($typec == 'DEL') { |
|
1058 | + $data['type'] = 'Delivery'; |
|
1059 | + } elseif ($typec == 'DEP') { |
|
1060 | + $data['type'] = 'Departure'; |
|
1061 | + } elseif ($typec == 'FSS') { |
|
1062 | + $data['type'] = 'Flight Service Station'; |
|
1063 | + } elseif ($typec == 'CTR') { |
|
1064 | + $data['type'] = 'Control Radar or Centre'; |
|
1065 | + } elseif ($data['type'] == '') { |
|
1066 | + $data['type'] = 'Observer'; |
|
1067 | + } |
|
1068 | + if (!isset($data['source_name'])) { |
|
1069 | + $data['source_name'] = ''; |
|
1070 | + } |
|
792 | 1071 | if (isset($ATC)) { |
793 | - 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']); |
|
794 | - 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']); |
|
1072 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1073 | + 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']); |
|
1074 | + } else { |
|
1075 | + 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']); |
|
1076 | + } |
|
795 | 1077 | } |
796 | 1078 | } |
797 | 1079 | unset($data); |
@@ -818,14 +1100,20 @@ discard block |
||
818 | 1100 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
819 | 1101 | $data['latitude'] = (float)$line['pktLatitude']; |
820 | 1102 | $data['longitude'] = (float)$line['pktLongitude']; |
821 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
822 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1103 | + if ((float)$line['pktTrack'] != 0) { |
|
1104 | + $data['heading'] = (float)$line['pktTrack']; |
|
1105 | + } |
|
1106 | + if ((int)$line['pktSpeed'] != 0) { |
|
1107 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1108 | + } |
|
823 | 1109 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
824 | 1110 | $data['altitude_relative'] = 'AMSL'; |
825 | 1111 | $data['pilot_id'] = (int)$line['pktPilotID']; |
826 | 1112 | $data['aircraft_icao'] = 'PARAGLIDER'; |
827 | 1113 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
828 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1114 | + if (isset($pilot_data[4])) { |
|
1115 | + $data['pilot_name'] = $pilot_data[4]; |
|
1116 | + } |
|
829 | 1117 | $data['format_source'] = $value['format']; |
830 | 1118 | $SI->add($data); |
831 | 1119 | unset($data); |
@@ -873,25 +1161,59 @@ discard block |
||
873 | 1161 | foreach ($all_data['acList'] as $line) { |
874 | 1162 | $data = array(); |
875 | 1163 | $data['hex'] = $line['Icao']; // hex |
876 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
877 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
878 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
879 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
880 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
881 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1164 | + if (isset($line['Call'])) { |
|
1165 | + $data['ident'] = $line['Call']; |
|
1166 | + } |
|
1167 | + // ident |
|
1168 | + if (isset($line['Alt'])) { |
|
1169 | + $data['altitude'] = $line['Alt']; |
|
1170 | + } |
|
1171 | + // altitude |
|
1172 | + if (isset($line['Spd'])) { |
|
1173 | + $data['speed'] = $line['Spd']; |
|
1174 | + } |
|
1175 | + // speed |
|
1176 | + if (isset($line['Trak'])) { |
|
1177 | + $data['heading'] = $line['Trak']; |
|
1178 | + } |
|
1179 | + // heading |
|
1180 | + if (isset($line['Lat'])) { |
|
1181 | + $data['latitude'] = $line['Lat']; |
|
1182 | + } |
|
1183 | + // lat |
|
1184 | + if (isset($line['Long'])) { |
|
1185 | + $data['longitude'] = $line['Long']; |
|
1186 | + } |
|
1187 | + // long |
|
882 | 1188 | //$data['verticalrate'] = $line['']; // verticale rate |
883 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1189 | + if (isset($line['Sqk'])) { |
|
1190 | + $data['squawk'] = $line['Sqk']; |
|
1191 | + } |
|
1192 | + // squawk |
|
884 | 1193 | $data['emergency'] = ''; // emergency |
885 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
886 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
887 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1194 | + if (isset($line['Reg'])) { |
|
1195 | + $data['registration'] = $line['Reg']; |
|
1196 | + } |
|
1197 | + if (isset($line['PosTime'])) { |
|
1198 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1199 | + } else { |
|
1200 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1201 | + } |
|
888 | 1202 | //$data['datetime'] = date('Y-m-d H:i:s'); |
889 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1203 | + if (isset($line['Type'])) { |
|
1204 | + $data['aircraft_icao'] = $line['Type']; |
|
1205 | + } |
|
890 | 1206 | $data['format_source'] = 'aircraftlistjson'; |
891 | 1207 | $data['id_source'] = $id_source; |
892 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
893 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
894 | - if (isset($data['latitude'])) $SI->add($data); |
|
1208 | + if (isset($value['name']) && $value['name'] != '') { |
|
1209 | + $data['source_name'] = $value['name']; |
|
1210 | + } |
|
1211 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1212 | + $data['noarchive'] = true; |
|
1213 | + } |
|
1214 | + if (isset($data['latitude'])) { |
|
1215 | + $SI->add($data); |
|
1216 | + } |
|
895 | 1217 | unset($data); |
896 | 1218 | } |
897 | 1219 | } elseif (is_array($all_data)) { |
@@ -908,17 +1230,26 @@ discard block |
||
908 | 1230 | $data['verticalrate'] = $line['vrt']; // verticale rate |
909 | 1231 | $data['squawk'] = $line['squawk']; // squawk |
910 | 1232 | $data['emergency'] = ''; // emergency |
911 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
912 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1233 | + if (isset($line['PosTime'])) { |
|
1234 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1235 | + } else { |
|
1236 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1237 | + } |
|
913 | 1238 | $data['format_source'] = 'aircraftlistjson'; |
914 | 1239 | $data['id_source'] = $id_source; |
915 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
916 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1240 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1241 | + $data['noarchive'] = true; |
|
1242 | + } |
|
1243 | + if (isset($value['name']) && $value['name'] != '') { |
|
1244 | + $data['source_name'] = $value['name']; |
|
1245 | + } |
|
917 | 1246 | $SI->add($data); |
918 | 1247 | unset($data); |
919 | 1248 | } |
920 | 1249 | } |
921 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1250 | + } elseif ($globalDebug) { |
|
1251 | + echo 'No data'."\n"; |
|
1252 | + } |
|
922 | 1253 | //$last_exec['aircraftlistjson'] = time(); |
923 | 1254 | $last_exec[$id]['last'] = time(); |
924 | 1255 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -954,8 +1285,12 @@ discard block |
||
954 | 1285 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
955 | 1286 | $data['format_source'] = 'planeupdatefaa'; |
956 | 1287 | $data['id_source'] = $id_source; |
957 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
958 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1288 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1289 | + $data['noarchive'] = true; |
|
1290 | + } |
|
1291 | + if (isset($value['name']) && $value['name'] != '') { |
|
1292 | + $data['source_name'] = $value['name']; |
|
1293 | + } |
|
959 | 1294 | $SI->add($data); |
960 | 1295 | unset($data); |
961 | 1296 | } |
@@ -989,7 +1324,9 @@ discard block |
||
989 | 1324 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
990 | 1325 | $data['format_source'] = 'opensky'; |
991 | 1326 | $data['id_source'] = $id_source; |
992 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1327 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1328 | + $data['noarchive'] = true; |
|
1329 | + } |
|
993 | 1330 | $SI->add($data); |
994 | 1331 | unset($data); |
995 | 1332 | } |
@@ -1006,7 +1343,9 @@ discard block |
||
1006 | 1343 | //$buffer = $Common->getData($hosts[$id]); |
1007 | 1344 | $buffer = $Common->getData($value['host']); |
1008 | 1345 | $all_data = json_decode($buffer,true); |
1009 | - if (!empty($all_data)) $reset = 0; |
|
1346 | + if (!empty($all_data)) { |
|
1347 | + $reset = 0; |
|
1348 | + } |
|
1010 | 1349 | foreach ($all_data as $key => $line) { |
1011 | 1350 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1012 | 1351 | $data = array(); |
@@ -1027,8 +1366,12 @@ discard block |
||
1027 | 1366 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1028 | 1367 | $data['format_source'] = 'fr24json'; |
1029 | 1368 | $data['id_source'] = $id_source; |
1030 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1031 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1369 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1370 | + $data['noarchive'] = true; |
|
1371 | + } |
|
1372 | + if (isset($value['name']) && $value['name'] != '') { |
|
1373 | + $data['source_name'] = $value['name']; |
|
1374 | + } |
|
1032 | 1375 | $SI->add($data); |
1033 | 1376 | unset($data); |
1034 | 1377 | } |
@@ -1057,24 +1400,42 @@ discard block |
||
1057 | 1400 | if (isset($line['inf'])) { |
1058 | 1401 | $data = array(); |
1059 | 1402 | $data['hex'] = $line['inf']['ia']; |
1060 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1403 | + if (isset($line['inf']['cs'])) { |
|
1404 | + $data['ident'] = $line['inf']['cs']; |
|
1405 | + } |
|
1406 | + //$line[13] |
|
1061 | 1407 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1062 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1063 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1408 | + if (isset($line['inf']['gs'])) { |
|
1409 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1410 | + } |
|
1411 | + // speed |
|
1412 | + if (isset($line['inf']['tr'])) { |
|
1413 | + $data['heading'] = $line['inf']['tr']; |
|
1414 | + } |
|
1415 | + // heading |
|
1064 | 1416 | $data['latitude'] = $line['pt'][0]; // lat |
1065 | 1417 | $data['longitude'] = $line['pt'][1]; // long |
1066 | 1418 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1067 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1419 | + if (isset($line['inf']['sq'])) { |
|
1420 | + $data['squawk'] = $line['inf']['sq']; |
|
1421 | + } |
|
1422 | + // squawk |
|
1068 | 1423 | //$data['aircraft_icao'] = $line[8]; |
1069 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1424 | + if (isset($line['inf']['rc'])) { |
|
1425 | + $data['registration'] = $line['inf']['rc']; |
|
1426 | + } |
|
1070 | 1427 | //$data['departure_airport_iata'] = $line[11]; |
1071 | 1428 | //$data['arrival_airport_iata'] = $line[12]; |
1072 | 1429 | //$data['emergency'] = ''; // emergency |
1073 | 1430 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1074 | 1431 | $data['format_source'] = 'radarvirtueljson'; |
1075 | 1432 | $data['id_source'] = $id_source; |
1076 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1077 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1433 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1434 | + $data['noarchive'] = true; |
|
1435 | + } |
|
1436 | + if (isset($value['name']) && $value['name'] != '') { |
|
1437 | + $data['source_name'] = $value['name']; |
|
1438 | + } |
|
1078 | 1439 | $SI->add($data); |
1079 | 1440 | unset($data); |
1080 | 1441 | } |
@@ -1100,30 +1461,65 @@ discard block |
||
1100 | 1461 | $data['id'] = $line['id']; |
1101 | 1462 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1102 | 1463 | $data['ident'] = $line['callsign']; // ident |
1103 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1104 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1105 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1106 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1107 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1108 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1464 | + if (isset($line['pilotid'])) { |
|
1465 | + $data['pilot_id'] = $line['pilotid']; |
|
1466 | + } |
|
1467 | + // pilot id |
|
1468 | + if (isset($line['name'])) { |
|
1469 | + $data['pilot_name'] = $line['name']; |
|
1470 | + } |
|
1471 | + // pilot name |
|
1472 | + if (isset($line['alt'])) { |
|
1473 | + $data['altitude'] = $line['alt']; |
|
1474 | + } |
|
1475 | + // altitude |
|
1476 | + if (isset($line['gs'])) { |
|
1477 | + $data['speed'] = $line['gs']; |
|
1478 | + } |
|
1479 | + // speed |
|
1480 | + if (isset($line['heading'])) { |
|
1481 | + $data['heading'] = $line['heading']; |
|
1482 | + } |
|
1483 | + // heading |
|
1484 | + if (isset($line['route'])) { |
|
1485 | + $data['waypoints'] = $line['route']; |
|
1486 | + } |
|
1487 | + // route |
|
1109 | 1488 | $data['latitude'] = $line['lat']; // lat |
1110 | 1489 | $data['longitude'] = $line['lon']; // long |
1111 | 1490 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1112 | 1491 | //$data['squawk'] = $line['squawk']; // squawk |
1113 | 1492 | //$data['emergency'] = ''; // emergency |
1114 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1115 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1116 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1493 | + if (isset($line['depicao'])) { |
|
1494 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1495 | + } |
|
1496 | + if (isset($line['deptime'])) { |
|
1497 | + $data['departure_airport_time'] = $line['deptime']; |
|
1498 | + } |
|
1499 | + if (isset($line['arricao'])) { |
|
1500 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1501 | + } |
|
1117 | 1502 | //$data['arrival_airport_time'] = $line['arrtime']; |
1118 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1119 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1120 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1121 | - else $data['info'] = ''; |
|
1503 | + if (isset($line['aircraft'])) { |
|
1504 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1505 | + } |
|
1506 | + if (isset($line['transponder'])) { |
|
1507 | + $data['squawk'] = $line['transponder']; |
|
1508 | + } |
|
1509 | + if (isset($line['atis'])) { |
|
1510 | + $data['info'] = $line['atis']; |
|
1511 | + } else { |
|
1512 | + $data['info'] = ''; |
|
1513 | + } |
|
1122 | 1514 | $data['format_source'] = 'pireps'; |
1123 | 1515 | $data['id_source'] = $id_source; |
1124 | 1516 | $data['datetime'] = date('Y-m-d H:i:s'); |
1125 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1126 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1517 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1518 | + $data['noarchive'] = true; |
|
1519 | + } |
|
1520 | + if (isset($value['name']) && $value['name'] != '') { |
|
1521 | + $data['source_name'] = $value['name']; |
|
1522 | + } |
|
1127 | 1523 | if ($line['icon'] == 'plane') { |
1128 | 1524 | $SI->add($data); |
1129 | 1525 | // print_r($data); |
@@ -1132,16 +1528,28 @@ discard block |
||
1132 | 1528 | $data['info'] = str_replace('&sect;','',$data['info']); |
1133 | 1529 | $typec = substr($data['ident'],-3); |
1134 | 1530 | $data['type'] = ''; |
1135 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
1136 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
1137 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
1138 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
1139 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
1140 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
1141 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
1142 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1143 | - else $data['type'] = 'Observer'; |
|
1144 | - 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']); |
|
1531 | + if ($typec == 'APP') { |
|
1532 | + $data['type'] = 'Approach'; |
|
1533 | + } elseif ($typec == 'TWR') { |
|
1534 | + $data['type'] = 'Tower'; |
|
1535 | + } elseif ($typec == 'OBS') { |
|
1536 | + $data['type'] = 'Observer'; |
|
1537 | + } elseif ($typec == 'GND') { |
|
1538 | + $data['type'] = 'Ground'; |
|
1539 | + } elseif ($typec == 'DEL') { |
|
1540 | + $data['type'] = 'Delivery'; |
|
1541 | + } elseif ($typec == 'DEP') { |
|
1542 | + $data['type'] = 'Departure'; |
|
1543 | + } elseif ($typec == 'FSS') { |
|
1544 | + $data['type'] = 'Flight Service Station'; |
|
1545 | + } elseif ($typec == 'CTR') { |
|
1546 | + $data['type'] = 'Control Radar or Centre'; |
|
1547 | + } else { |
|
1548 | + $data['type'] = 'Observer'; |
|
1549 | + } |
|
1550 | + if (isset($ATC)) { |
|
1551 | + 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']); |
|
1552 | + } |
|
1145 | 1553 | } |
1146 | 1554 | unset($data); |
1147 | 1555 | } |
@@ -1156,7 +1564,9 @@ discard block |
||
1156 | 1564 | ) |
1157 | 1565 | ) { |
1158 | 1566 | //$buffer = $Common->getData($hosts[$id]); |
1159 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1567 | + if ($globalDebug) { |
|
1568 | + echo 'Get Data...'."\n"; |
|
1569 | + } |
|
1160 | 1570 | $buffer = $Common->getData($value['host']); |
1161 | 1571 | $all_data = json_decode($buffer,true); |
1162 | 1572 | if ($buffer != '' && is_array($all_data)) { |
@@ -1164,10 +1574,16 @@ discard block |
||
1164 | 1574 | foreach ($all_data as $line) { |
1165 | 1575 | $data = array(); |
1166 | 1576 | //$data['id'] = $line['id']; // id not usable |
1167 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1577 | + if (isset($line['pilotid'])) { |
|
1578 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1579 | + } |
|
1168 | 1580 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1169 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1170 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1581 | + if (isset($line['pilotname'])) { |
|
1582 | + $data['pilot_name'] = $line['pilotname']; |
|
1583 | + } |
|
1584 | + if (isset($line['pilotid'])) { |
|
1585 | + $data['pilot_id'] = $line['pilotid']; |
|
1586 | + } |
|
1171 | 1587 | $data['ident'] = $line['flightnum']; // ident |
1172 | 1588 | $data['altitude'] = $line['alt']; // altitude |
1173 | 1589 | $data['speed'] = $line['gs']; // speed |
@@ -1183,34 +1599,52 @@ discard block |
||
1183 | 1599 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1184 | 1600 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1185 | 1601 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1186 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1602 | + } else { |
|
1603 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1604 | + } |
|
1187 | 1605 | $data['departure_airport_icao'] = $line['depicao']; |
1188 | 1606 | $data['departure_airport_time'] = $line['deptime']; |
1189 | 1607 | $data['arrival_airport_icao'] = $line['arricao']; |
1190 | 1608 | $data['arrival_airport_time'] = $line['arrtime']; |
1191 | 1609 | $data['registration'] = $line['aircraft']; |
1192 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1193 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1610 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1611 | + $data['noarchive'] = true; |
|
1612 | + } |
|
1613 | + if (isset($line['route'])) { |
|
1614 | + $data['waypoints'] = $line['route']; |
|
1615 | + } |
|
1616 | + // route |
|
1194 | 1617 | if (isset($line['aircraftname'])) { |
1195 | 1618 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1196 | 1619 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1197 | 1620 | $aircraft_data = explode('-',$line['aircraftname']); |
1198 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1199 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1200 | - else { |
|
1621 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1622 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1623 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1624 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1625 | + } else { |
|
1201 | 1626 | $aircraft_data = explode(' ',$line['aircraftname']); |
1202 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1203 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1627 | + if (isset($aircraft_data[1])) { |
|
1628 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1629 | + } else { |
|
1630 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1631 | + } |
|
1204 | 1632 | } |
1205 | 1633 | } |
1206 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1634 | + if (isset($line['route'])) { |
|
1635 | + $data['waypoints'] = $line['route']; |
|
1636 | + } |
|
1207 | 1637 | $data['id_source'] = $id_source; |
1208 | 1638 | $data['format_source'] = 'phpvmacars'; |
1209 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1639 | + if (isset($value['name']) && $value['name'] != '') { |
|
1640 | + $data['source_name'] = $value['name']; |
|
1641 | + } |
|
1210 | 1642 | $SI->add($data); |
1211 | 1643 | unset($data); |
1212 | 1644 | } |
1213 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1645 | + if ($globalDebug) { |
|
1646 | + echo 'No more data...'."\n"; |
|
1647 | + } |
|
1214 | 1648 | unset($buffer); |
1215 | 1649 | unset($all_data); |
1216 | 1650 | } |
@@ -1223,7 +1657,9 @@ discard block |
||
1223 | 1657 | ) |
1224 | 1658 | ) { |
1225 | 1659 | //$buffer = $Common->getData($hosts[$id]); |
1226 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1660 | + if ($globalDebug) { |
|
1661 | + echo 'Get Data...'."\n"; |
|
1662 | + } |
|
1227 | 1663 | $buffer = $Common->getData($value['host']); |
1228 | 1664 | $all_data = json_decode($buffer,true); |
1229 | 1665 | if ($buffer != '' && is_array($all_data)) { |
@@ -1252,16 +1688,25 @@ discard block |
||
1252 | 1688 | $data['arrival_airport_icao'] = $line['arrival']; |
1253 | 1689 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1254 | 1690 | //$data['registration'] = $line['aircraft']; |
1255 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1691 | + if (isset($line['route'])) { |
|
1692 | + $data['waypoints'] = $line['route']; |
|
1693 | + } |
|
1694 | + // route |
|
1256 | 1695 | $data['aircraft_icao'] = $line['plane_type']; |
1257 | 1696 | $data['id_source'] = $id_source; |
1258 | 1697 | $data['format_source'] = 'vam'; |
1259 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1260 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1698 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1699 | + $data['noarchive'] = true; |
|
1700 | + } |
|
1701 | + if (isset($value['name']) && $value['name'] != '') { |
|
1702 | + $data['source_name'] = $value['name']; |
|
1703 | + } |
|
1261 | 1704 | $SI->add($data); |
1262 | 1705 | unset($data); |
1263 | 1706 | } |
1264 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1707 | + if ($globalDebug) { |
|
1708 | + echo 'No more data...'."\n"; |
|
1709 | + } |
|
1265 | 1710 | unset($buffer); |
1266 | 1711 | unset($all_data); |
1267 | 1712 | } |
@@ -1274,7 +1719,9 @@ discard block |
||
1274 | 1719 | ) |
1275 | 1720 | ) { |
1276 | 1721 | //$buffer = $Common->getData($hosts[$id]); |
1277 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1722 | + if ($globalDebug) { |
|
1723 | + echo 'Get Data...'."\n"; |
|
1724 | + } |
|
1278 | 1725 | $buffer = $Common->getData($value['host']); |
1279 | 1726 | $all_data = json_decode($buffer,true); |
1280 | 1727 | if ($buffer != '') { |
@@ -1292,18 +1739,24 @@ discard block |
||
1292 | 1739 | $data['id_source'] = $id_source; |
1293 | 1740 | $data['format_source'] = 'blitzortung'; |
1294 | 1741 | $SI->add($data); |
1295 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1742 | + if ($globalDebug) { |
|
1743 | + echo '☈ Lightning added'."\n"; |
|
1744 | + } |
|
1296 | 1745 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1297 | 1746 | unset($data); |
1298 | 1747 | } |
1299 | 1748 | } |
1300 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1749 | + if ($globalDebug) { |
|
1750 | + echo 'No more data...'."\n"; |
|
1751 | + } |
|
1301 | 1752 | unset($buffer); |
1302 | 1753 | } |
1303 | 1754 | $last_exec[$id]['last'] = time(); |
1304 | 1755 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1305 | 1756 | } 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') { |
1306 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1757 | + if (function_exists('pcntl_fork')) { |
|
1758 | + pcntl_signal_dispatch(); |
|
1759 | + } |
|
1307 | 1760 | //$last_exec[$id]['last'] = time(); |
1308 | 1761 | |
1309 | 1762 | //$read = array( $sockets[$id] ); |
@@ -1311,7 +1764,9 @@ discard block |
||
1311 | 1764 | $write = NULL; |
1312 | 1765 | $e = NULL; |
1313 | 1766 | $n = socket_select($read, $write, $e, $timeout); |
1314 | - if ($e != NULL) var_dump($e); |
|
1767 | + if ($e != NULL) { |
|
1768 | + var_dump($e); |
|
1769 | + } |
|
1315 | 1770 | if ($n > 0) { |
1316 | 1771 | $reset = 0; |
1317 | 1772 | foreach ($read as $nb => $r) { |
@@ -1333,13 +1788,17 @@ discard block |
||
1333 | 1788 | if ($buffer !== FALSE) { |
1334 | 1789 | if ($format == 'vrstcp') { |
1335 | 1790 | $buffer = explode('},{',$buffer); |
1336 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1791 | + } else { |
|
1792 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1793 | + } |
|
1337 | 1794 | } |
1338 | 1795 | // SBS format is CSV format |
1339 | 1796 | if ($buffer !== FALSE && $buffer !== '') { |
1340 | 1797 | $tt[$format] = 0; |
1341 | 1798 | if ($format == 'acarssbs3') { |
1342 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1799 | + if ($globalDebug) { |
|
1800 | + echo 'ACARS : '.$buffer."\n"; |
|
1801 | + } |
|
1343 | 1802 | $ACARS->add(trim($buffer)); |
1344 | 1803 | $ACARS->deleteLiveAcarsData(); |
1345 | 1804 | } elseif ($format == 'raw') { |
@@ -1348,30 +1807,70 @@ discard block |
||
1348 | 1807 | if (is_array($data)) { |
1349 | 1808 | $data['datetime'] = date('Y-m-d H:i:s'); |
1350 | 1809 | $data['format_source'] = 'raw'; |
1351 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1352 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1353 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1354 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1810 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1811 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1812 | + } |
|
1813 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1814 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1815 | + } |
|
1816 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1817 | + $data['noarchive'] = true; |
|
1818 | + } |
|
1819 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1820 | + $SI->add($data); |
|
1821 | + } |
|
1355 | 1822 | } |
1356 | 1823 | } elseif ($format == 'ais') { |
1357 | 1824 | $ais_data = $AIS->parse_line(trim($buffer)); |
1358 | 1825 | $data = array(); |
1359 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1360 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1361 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1362 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1363 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1364 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1365 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1366 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1367 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1368 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1369 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1370 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1371 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1372 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1373 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1374 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1826 | + if (isset($ais_data['ident'])) { |
|
1827 | + $data['ident'] = $ais_data['ident']; |
|
1828 | + } |
|
1829 | + if (isset($ais_data['mmsi'])) { |
|
1830 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1831 | + } |
|
1832 | + if (isset($ais_data['speed'])) { |
|
1833 | + $data['speed'] = $ais_data['speed']; |
|
1834 | + } |
|
1835 | + if (isset($ais_data['heading'])) { |
|
1836 | + $data['heading'] = $ais_data['heading']; |
|
1837 | + } |
|
1838 | + if (isset($ais_data['latitude'])) { |
|
1839 | + $data['latitude'] = $ais_data['latitude']; |
|
1840 | + } |
|
1841 | + if (isset($ais_data['longitude'])) { |
|
1842 | + $data['longitude'] = $ais_data['longitude']; |
|
1843 | + } |
|
1844 | + if (isset($ais_data['status'])) { |
|
1845 | + $data['status'] = $ais_data['status']; |
|
1846 | + } |
|
1847 | + if (isset($ais_data['statusid'])) { |
|
1848 | + $data['status_id'] = $ais_data['statusid']; |
|
1849 | + } |
|
1850 | + if (isset($ais_data['type'])) { |
|
1851 | + $data['type'] = $ais_data['type']; |
|
1852 | + } |
|
1853 | + if (isset($ais_data['imo'])) { |
|
1854 | + $data['imo'] = $ais_data['imo']; |
|
1855 | + } |
|
1856 | + if (isset($ais_data['callsign'])) { |
|
1857 | + $data['callsign'] = $ais_data['callsign']; |
|
1858 | + } |
|
1859 | + if (isset($ais_data['destination'])) { |
|
1860 | + $data['arrival_code'] = $ais_data['destination']; |
|
1861 | + } |
|
1862 | + if (isset($ais_data['eta_ts'])) { |
|
1863 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1864 | + } |
|
1865 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1866 | + $data['noarchive'] = true; |
|
1867 | + } |
|
1868 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1869 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1870 | + } |
|
1871 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1872 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1873 | + } |
|
1375 | 1874 | |
1376 | 1875 | if (isset($ais_data['timestamp'])) { |
1377 | 1876 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1380,7 +1879,9 @@ discard block |
||
1380 | 1879 | } |
1381 | 1880 | $data['format_source'] = 'aisnmea'; |
1382 | 1881 | $data['id_source'] = $id_source; |
1383 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1882 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1883 | + $MI->add($data); |
|
1884 | + } |
|
1384 | 1885 | unset($data); |
1385 | 1886 | } elseif ($format == 'flightgearsp') { |
1386 | 1887 | //echo $buffer."\n"; |
@@ -1398,12 +1899,18 @@ discard block |
||
1398 | 1899 | $data['speed'] = round($line[5]*1.94384); |
1399 | 1900 | $data['datetime'] = date('Y-m-d H:i:s'); |
1400 | 1901 | $data['format_source'] = 'flightgearsp'; |
1401 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1402 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1902 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1903 | + $data['noarchive'] = true; |
|
1904 | + } |
|
1905 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1906 | + $SI->add($data); |
|
1907 | + } |
|
1403 | 1908 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1404 | 1909 | } |
1405 | 1910 | } elseif ($format == 'acars') { |
1406 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1911 | + if ($globalDebug) { |
|
1912 | + echo 'ACARS : '.$buffer."\n"; |
|
1913 | + } |
|
1407 | 1914 | $ACARS->add(trim($buffer)); |
1408 | 1915 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1409 | 1916 | $ACARS->deleteLiveAcarsData(); |
@@ -1424,8 +1931,12 @@ discard block |
||
1424 | 1931 | $aircraft_type = $line[10]; |
1425 | 1932 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1426 | 1933 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1427 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1428 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1934 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1935 | + $data['noarchive'] = true; |
|
1936 | + } |
|
1937 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1938 | + $SI->add($data); |
|
1939 | + } |
|
1429 | 1940 | } |
1430 | 1941 | } |
1431 | 1942 | } elseif ($format == 'beast') { |
@@ -1435,28 +1946,62 @@ discard block |
||
1435 | 1946 | foreach($buffer as $all_data) { |
1436 | 1947 | $line = json_decode('{'.$all_data.'}',true); |
1437 | 1948 | $data = array(); |
1438 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1439 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1440 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1441 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1442 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1443 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1444 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1949 | + if (isset($line['Icao'])) { |
|
1950 | + $data['hex'] = $line['Icao']; |
|
1951 | + } |
|
1952 | + // hex |
|
1953 | + if (isset($line['Call'])) { |
|
1954 | + $data['ident'] = $line['Call']; |
|
1955 | + } |
|
1956 | + // ident |
|
1957 | + if (isset($line['Alt'])) { |
|
1958 | + $data['altitude'] = $line['Alt']; |
|
1959 | + } |
|
1960 | + // altitude |
|
1961 | + if (isset($line['Spd'])) { |
|
1962 | + $data['speed'] = $line['Spd']; |
|
1963 | + } |
|
1964 | + // speed |
|
1965 | + if (isset($line['Trak'])) { |
|
1966 | + $data['heading'] = $line['Trak']; |
|
1967 | + } |
|
1968 | + // heading |
|
1969 | + if (isset($line['Lat'])) { |
|
1970 | + $data['latitude'] = $line['Lat']; |
|
1971 | + } |
|
1972 | + // lat |
|
1973 | + if (isset($line['Long'])) { |
|
1974 | + $data['longitude'] = $line['Long']; |
|
1975 | + } |
|
1976 | + // long |
|
1445 | 1977 | //$data['verticalrate'] = $line['']; // verticale rate |
1446 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1978 | + if (isset($line['Sqk'])) { |
|
1979 | + $data['squawk'] = $line['Sqk']; |
|
1980 | + } |
|
1981 | + // squawk |
|
1447 | 1982 | $data['emergency'] = ''; // emergency |
1448 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1983 | + if (isset($line['Reg'])) { |
|
1984 | + $data['registration'] = $line['Reg']; |
|
1985 | + } |
|
1449 | 1986 | /* |
1450 | 1987 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1451 | 1988 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1452 | 1989 | */ |
1453 | 1990 | $data['datetime'] = date('Y-m-d H:i:s'); |
1454 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1991 | + if (isset($line['Type'])) { |
|
1992 | + $data['aircraft_icao'] = $line['Type']; |
|
1993 | + } |
|
1455 | 1994 | $data['format_source'] = 'vrstcp'; |
1456 | 1995 | $data['id_source'] = $id_source; |
1457 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1458 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1459 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1996 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1997 | + $data['noarchive'] = true; |
|
1998 | + } |
|
1999 | + if (isset($value['name']) && $value['name'] != '') { |
|
2000 | + $data['source_name'] = $value['name']; |
|
2001 | + } |
|
2002 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2003 | + $SI->add($data); |
|
2004 | + } |
|
1460 | 2005 | unset($data); |
1461 | 2006 | } |
1462 | 2007 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1469,22 +2014,46 @@ discard block |
||
1469 | 2014 | $data['hex'] = $lined['hexid']; |
1470 | 2015 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1471 | 2016 | $data['datetime'] = date('Y-m-d H:i:s');; |
1472 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1473 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1474 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1475 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1476 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1477 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1478 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2017 | + if (isset($lined['ident'])) { |
|
2018 | + $data['ident'] = $lined['ident']; |
|
2019 | + } |
|
2020 | + if (isset($lined['lat'])) { |
|
2021 | + $data['latitude'] = $lined['lat']; |
|
2022 | + } |
|
2023 | + if (isset($lined['lon'])) { |
|
2024 | + $data['longitude'] = $lined['lon']; |
|
2025 | + } |
|
2026 | + if (isset($lined['speed'])) { |
|
2027 | + $data['speed'] = $lined['speed']; |
|
2028 | + } |
|
2029 | + if (isset($lined['squawk'])) { |
|
2030 | + $data['squawk'] = $lined['squawk']; |
|
2031 | + } |
|
2032 | + if (isset($lined['alt'])) { |
|
2033 | + $data['altitude'] = $lined['alt']; |
|
2034 | + } |
|
2035 | + if (isset($lined['heading'])) { |
|
2036 | + $data['heading'] = $lined['heading']; |
|
2037 | + } |
|
1479 | 2038 | $data['id_source'] = $id_source; |
1480 | 2039 | $data['format_source'] = 'tsv'; |
1481 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1482 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1483 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1484 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2040 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2041 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2042 | + } |
|
2043 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2044 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2045 | + } |
|
2046 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2047 | + $data['noarchive'] = true; |
|
2048 | + } |
|
2049 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2050 | + $SI->add($data); |
|
2051 | + } |
|
1485 | 2052 | unset($lined); |
1486 | 2053 | unset($data); |
1487 | - } else $error = true; |
|
2054 | + } else { |
|
2055 | + $error = true; |
|
2056 | + } |
|
1488 | 2057 | } elseif ($format == 'aprs' && $use_aprs) { |
1489 | 2058 | if ($aprs_connect == 0) { |
1490 | 2059 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1510,63 +2079,121 @@ discard block |
||
1510 | 2079 | $aprs_last_tx = time(); |
1511 | 2080 | $data = array(); |
1512 | 2081 | //print_r($line); |
1513 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1514 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1515 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1516 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1517 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1518 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1519 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1520 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1521 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1522 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2082 | + if (isset($line['address'])) { |
|
2083 | + $data['hex'] = $line['address']; |
|
2084 | + } |
|
2085 | + if (isset($line['mmsi'])) { |
|
2086 | + $data['mmsi'] = $line['mmsi']; |
|
2087 | + } |
|
2088 | + if (isset($line['imo'])) { |
|
2089 | + $data['imo'] = $line['imo']; |
|
2090 | + } |
|
2091 | + if (isset($line['squawk'])) { |
|
2092 | + $data['squawk'] = $line['squawk']; |
|
2093 | + } |
|
2094 | + if (isset($line['arrival_code'])) { |
|
2095 | + $data['arrical_code'] = $line['arrival_code']; |
|
2096 | + } |
|
2097 | + if (isset($line['arrival_date'])) { |
|
2098 | + $data['arrical_date'] = $line['arrival_date']; |
|
2099 | + } |
|
2100 | + if (isset($line['type_id'])) { |
|
2101 | + $data['type_id'] = $line['typeid']; |
|
2102 | + } |
|
2103 | + if (isset($line['status_id'])) { |
|
2104 | + $data['status_id'] = $line['statusid']; |
|
2105 | + } |
|
2106 | + if (isset($line['timestamp'])) { |
|
2107 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2108 | + } else { |
|
2109 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2110 | + } |
|
1523 | 2111 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1524 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2112 | + if (isset($line['ident'])) { |
|
2113 | + $data['ident'] = $line['ident']; |
|
2114 | + } |
|
1525 | 2115 | $data['latitude'] = $line['latitude']; |
1526 | 2116 | $data['longitude'] = $line['longitude']; |
1527 | 2117 | //$data['verticalrate'] = $line[16]; |
1528 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2118 | + if (isset($line['speed'])) { |
|
2119 | + $data['speed'] = $line['speed']; |
|
2120 | + } |
|
1529 | 2121 | //else $data['speed'] = 0; |
1530 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1531 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1532 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2122 | + if (isset($line['altitude'])) { |
|
2123 | + $data['altitude'] = $line['altitude']; |
|
2124 | + } |
|
2125 | + if (isset($line['comment'])) { |
|
2126 | + $data['comment'] = $line['comment']; |
|
2127 | + } |
|
2128 | + if (isset($line['symbol'])) { |
|
2129 | + $data['type'] = $line['symbol']; |
|
2130 | + } |
|
1533 | 2131 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1534 | 2132 | |
1535 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2133 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2134 | + $data['heading'] = $line['heading']; |
|
2135 | + } |
|
1536 | 2136 | //else echo 'No heading...'."\n"; |
1537 | 2137 | //else $data['heading'] = 0; |
1538 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2138 | + if (isset($line['stealth'])) { |
|
2139 | + $data['aircraft_type'] = $line['stealth']; |
|
2140 | + } |
|
1539 | 2141 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1540 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1541 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1542 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1543 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2142 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2143 | + $data['noarchive'] = true; |
|
2144 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2145 | + $data['noarchive'] = false; |
|
2146 | + } |
|
2147 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2148 | + $data['noarchive'] = true; |
|
2149 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2150 | + $data['noarchive'] = false; |
|
2151 | + } |
|
1544 | 2152 | $data['id_source'] = $id_source; |
1545 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1546 | - else $data['format_source'] = 'aprs'; |
|
2153 | + if (isset($line['format_source'])) { |
|
2154 | + $data['format_source'] = $line['format_source']; |
|
2155 | + } else { |
|
2156 | + $data['format_source'] = 'aprs'; |
|
2157 | + } |
|
1547 | 2158 | $data['source_name'] = $line['source']; |
1548 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1549 | - else $data['source_type'] = 'flarm'; |
|
1550 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2159 | + if (isset($line['source_type'])) { |
|
2160 | + $data['source_type'] = $line['source_type']; |
|
2161 | + } else { |
|
2162 | + $data['source_type'] = 'flarm'; |
|
2163 | + } |
|
2164 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2165 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2166 | + } |
|
1551 | 2167 | $currentdate = date('Y-m-d H:i:s'); |
1552 | 2168 | $aprsdate = strtotime($data['datetime']); |
1553 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2169 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2170 | + $data['altitude_relative'] = 'AMSL'; |
|
2171 | + } |
|
1554 | 2172 | // Accept data if time <= system time + 20s |
1555 | 2173 | //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'])))) { |
1556 | 2174 | 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'])))) { |
1557 | 2175 | $send = $SI->add($data); |
1558 | 2176 | } elseif ($data['source_type'] == 'ais') { |
1559 | 2177 | $data['type'] = ''; |
1560 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2178 | + if (isset($globalMarine) && $globalMarine) { |
|
2179 | + $send = $MI->add($data); |
|
2180 | + } |
|
1561 | 2181 | } elseif (isset($line['stealth'])) { |
1562 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1563 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2182 | + if ($line['stealth'] != 0) { |
|
2183 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2184 | + } else { |
|
2185 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2186 | + } |
|
1564 | 2187 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1565 | 2188 | //$line['symbol'] == 'Balloon' || |
1566 | 2189 | $line['symbol'] == 'Glider' || |
1567 | 2190 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1568 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1569 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2191 | + if ($line['symbol'] == 'Ballon') { |
|
2192 | + $data['aircraft_icao'] = 'BALL'; |
|
2193 | + } |
|
2194 | + if ($line['symbol'] == 'Glider') { |
|
2195 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2196 | + } |
|
1570 | 2197 | $send = $SI->add($data); |
1571 | 2198 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1572 | 2199 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1597,9 +2224,13 @@ discard block |
||
1597 | 2224 | //} 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') { |
1598 | 2225 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1599 | 2226 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1600 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2227 | + if (isset($globalTracker) && $globalTracker) { |
|
2228 | + $send = $TI->add($data); |
|
2229 | + } |
|
1601 | 2230 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1602 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2231 | + if (!isset($data['altitude'])) { |
|
2232 | + $data['altitude'] = 0; |
|
2233 | + } |
|
1603 | 2234 | $Source->deleteOldLocationByType('gs'); |
1604 | 2235 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1605 | 2236 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1608,7 +2239,9 @@ discard block |
||
1608 | 2239 | } |
1609 | 2240 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1610 | 2241 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1611 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2242 | + if ($globalDebug) { |
|
2243 | + echo '# Weather Station added'."\n"; |
|
2244 | + } |
|
1612 | 2245 | $Source->deleteOldLocationByType('wx'); |
1613 | 2246 | $weather_data = json_encode($line); |
1614 | 2247 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1618,7 +2251,9 @@ discard block |
||
1618 | 2251 | } |
1619 | 2252 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
1620 | 2253 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1621 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2254 | + if ($globalDebug) { |
|
2255 | + echo '☈ Lightning added'."\n"; |
|
2256 | + } |
|
1622 | 2257 | $Source->deleteOldLocationByType('lightning'); |
1623 | 2258 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1624 | 2259 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1630,8 +2265,7 @@ discard block |
||
1630 | 2265 | print_r($line); |
1631 | 2266 | } |
1632 | 2267 | unset($data); |
1633 | - } |
|
1634 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2268 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1635 | 2269 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1636 | 2270 | } |
1637 | 2271 | /* |
@@ -1640,7 +2274,9 @@ discard block |
||
1640 | 2274 | } |
1641 | 2275 | */ |
1642 | 2276 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1643 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2277 | + elseif ($line == true && $globalDebug) { |
|
2278 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2279 | + } |
|
1644 | 2280 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1645 | 2281 | $Source->deleteOldLocationByType('lightning'); |
1646 | 2282 | $Source->deleteOldLocationByType('wx'); |
@@ -1676,26 +2312,45 @@ discard block |
||
1676 | 2312 | $data['ground'] = $line[21]; |
1677 | 2313 | $data['emergency'] = $line[19]; |
1678 | 2314 | $data['format_source'] = 'sbs'; |
1679 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1680 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1681 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2315 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2316 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2317 | + } |
|
2318 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2319 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2320 | + } |
|
2321 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2322 | + $data['noarchive'] = true; |
|
2323 | + } |
|
1682 | 2324 | $data['id_source'] = $id_source; |
1683 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1684 | - else $error = true; |
|
2325 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2326 | + $send = $SI->add($data); |
|
2327 | + } else { |
|
2328 | + $error = true; |
|
2329 | + } |
|
1685 | 2330 | unset($data); |
1686 | - } else $error = true; |
|
2331 | + } else { |
|
2332 | + $error = true; |
|
2333 | + } |
|
1687 | 2334 | if ($error) { |
1688 | 2335 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1689 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2336 | + if ($globalDebug) { |
|
2337 | + echo "Not a message. Ignoring... \n"; |
|
2338 | + } |
|
1690 | 2339 | } else { |
1691 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2340 | + if ($globalDebug) { |
|
2341 | + echo "Wrong line format. Ignoring... \n"; |
|
2342 | + } |
|
1692 | 2343 | if ($globalDebug) { |
1693 | 2344 | echo $buffer; |
1694 | 2345 | //print_r($line); |
1695 | 2346 | } |
1696 | 2347 | //socket_close($r); |
1697 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1698 | - if ($format == 'aprs') $aprs_connect = 0; |
|
2348 | + if ($globalDebug) { |
|
2349 | + echo "Reconnect after an error...\n"; |
|
2350 | + } |
|
2351 | + if ($format == 'aprs') { |
|
2352 | + $aprs_connect = 0; |
|
2353 | + } |
|
1699 | 2354 | $sourceer[$nb] = $globalSources[$nb]; |
1700 | 2355 | connect_all($sourceer); |
1701 | 2356 | $sourceer = array(); |
@@ -1703,10 +2358,14 @@ discard block |
||
1703 | 2358 | } |
1704 | 2359 | } |
1705 | 2360 | // Sleep for xxx microseconds |
1706 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2361 | + if (isset($globalSBSSleep)) { |
|
2362 | + usleep($globalSBSSleep); |
|
2363 | + } |
|
1707 | 2364 | } else { |
1708 | 2365 | if ($format == 'flightgearmp') { |
1709 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2366 | + if ($globalDebug) { |
|
2367 | + echo "Reconnect FlightGear MP..."; |
|
2368 | + } |
|
1710 | 2369 | //@socket_close($r); |
1711 | 2370 | sleep($globalMinFetch); |
1712 | 2371 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1715,10 +2374,15 @@ discard block |
||
1715 | 2374 | break; |
1716 | 2375 | |
1717 | 2376 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1718 | - if (isset($tt[$format])) $tt[$format]++; |
|
1719 | - else $tt[$format] = 0; |
|
2377 | + if (isset($tt[$format])) { |
|
2378 | + $tt[$format]++; |
|
2379 | + } else { |
|
2380 | + $tt[$format] = 0; |
|
2381 | + } |
|
1720 | 2382 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1721 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2383 | + if ($globalDebug) { |
|
2384 | + echo "ERROR : Reconnect ".$format."..."; |
|
2385 | + } |
|
1722 | 2386 | //@socket_close($r); |
1723 | 2387 | sleep(2); |
1724 | 2388 | $aprs_connect = 0; |
@@ -1736,11 +2400,17 @@ discard block |
||
1736 | 2400 | } else { |
1737 | 2401 | $error = socket_strerror(socket_last_error()); |
1738 | 2402 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1739 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1740 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2403 | + if ($globalDebug) { |
|
2404 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2405 | + } |
|
2406 | + if (isset($globalDebug)) { |
|
2407 | + echo "Restarting...\n"; |
|
2408 | + } |
|
1741 | 2409 | // Restart the script if possible |
1742 | 2410 | if (is_array($sockets)) { |
1743 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2411 | + if ($globalDebug) { |
|
2412 | + echo "Shutdown all sockets..."; |
|
2413 | + } |
|
1744 | 2414 | |
1745 | 2415 | foreach ($sockets as $sock) { |
1746 | 2416 | @socket_shutdown($sock,2); |
@@ -1748,25 +2418,45 @@ discard block |
||
1748 | 2418 | } |
1749 | 2419 | |
1750 | 2420 | } |
1751 | - if ($globalDebug) echo "Waiting..."; |
|
2421 | + if ($globalDebug) { |
|
2422 | + echo "Waiting..."; |
|
2423 | + } |
|
1752 | 2424 | sleep(2); |
1753 | 2425 | $time = time(); |
1754 | 2426 | //connect_all($hosts); |
1755 | 2427 | $aprs_connect = 0; |
1756 | - if ($reset%5 == 0) sleep(20); |
|
1757 | - if ($reset%10 == 0) sleep(100); |
|
1758 | - if ($reset%20 == 0) sleep(200); |
|
1759 | - if ($reset > 100) exit('Too many attempts...'); |
|
1760 | - if ($globalDebug) echo "Restart all connections..."; |
|
2428 | + if ($reset%5 == 0) { |
|
2429 | + sleep(20); |
|
2430 | + } |
|
2431 | + if ($reset%10 == 0) { |
|
2432 | + sleep(100); |
|
2433 | + } |
|
2434 | + if ($reset%20 == 0) { |
|
2435 | + sleep(200); |
|
2436 | + } |
|
2437 | + if ($reset > 100) { |
|
2438 | + exit('Too many attempts...'); |
|
2439 | + } |
|
2440 | + if ($globalDebug) { |
|
2441 | + echo "Restart all connections..."; |
|
2442 | + } |
|
1761 | 2443 | connect_all($globalSources); |
1762 | 2444 | } |
1763 | 2445 | } |
1764 | 2446 | } |
1765 | 2447 | if ($globalDaemon === false) { |
1766 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1767 | - if (isset($SI)) $SI->checkAll(); |
|
1768 | - if (isset($TI)) $TI->checkAll(); |
|
1769 | - if (isset($MI)) $MI->checkAll(); |
|
2448 | + if ($globalDebug) { |
|
2449 | + echo 'Check all...'."\n"; |
|
2450 | + } |
|
2451 | + if (isset($SI)) { |
|
2452 | + $SI->checkAll(); |
|
2453 | + } |
|
2454 | + if (isset($TI)) { |
|
2455 | + $TI->checkAll(); |
|
2456 | + } |
|
2457 | + if (isset($MI)) { |
|
2458 | + $MI->checkAll(); |
|
2459 | + } |
|
1770 | 2460 | } |
1771 | 2461 | } |
1772 | 2462 | } |
@@ -48,27 +48,52 @@ discard block |
||
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
51 | -if (!isset($globalJsonCompress)) $compress = true; |
|
52 | -else $compress = $globalJsonCompress; |
|
51 | +if (!isset($globalJsonCompress)) { |
|
52 | + $compress = true; |
|
53 | +} else { |
|
54 | + $compress = $globalJsonCompress; |
|
55 | +} |
|
53 | 56 | |
54 | 57 | $from_archive = false; |
55 | 58 | $min = true; |
56 | 59 | $allhistory = false; |
57 | 60 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
62 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
63 | +} |
|
64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
65 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
66 | +} |
|
67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
68 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
69 | +} |
|
70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
71 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
72 | +} |
|
73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
74 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
75 | +} |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
78 | +} |
|
79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
80 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
81 | +} |
|
82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
83 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
84 | +} |
|
85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
87 | +} |
|
88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
90 | +} |
|
68 | 91 | |
69 | 92 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 93 | $min = true; |
71 | -} else $min = false; |
|
94 | +} else { |
|
95 | + $min = false; |
|
96 | +} |
|
72 | 97 | |
73 | 98 | if (isset($_GET['ident'])) { |
74 | 99 | $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
@@ -162,24 +187,38 @@ discard block |
||
162 | 187 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
163 | 188 | } |
164 | 189 | } |
165 | - if ($flightcnt == '') $flightcnt = 0; |
|
166 | -} else $flightcnt = 0; |
|
190 | + if ($flightcnt == '') { |
|
191 | + $flightcnt = 0; |
|
192 | + } |
|
193 | + } else { |
|
194 | + $flightcnt = 0; |
|
195 | +} |
|
167 | 196 | |
168 | 197 | $sqltime = round(microtime(true)-$begintime,2); |
169 | 198 | |
170 | 199 | $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
171 | -if ($currenttime != '') $currenttime = round($currenttime/1000); |
|
200 | +if ($currenttime != '') { |
|
201 | + $currenttime = round($currenttime/1000); |
|
202 | +} |
|
172 | 203 | |
173 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
174 | -else $usenextlatlon = true; |
|
175 | -if ($usenextlatlon === false) $currenttime = ''; |
|
204 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
205 | + $usenextlatlon = false; |
|
206 | +} else { |
|
207 | + $usenextlatlon = true; |
|
208 | +} |
|
209 | +if ($usenextlatlon === false) { |
|
210 | + $currenttime = ''; |
|
211 | +} |
|
176 | 212 | $j = 0; |
177 | 213 | $prev_flightaware_id = ''; |
178 | 214 | $aircrafts_shadow = array(); |
179 | 215 | $output = '{'; |
180 | 216 | $output .= '"type": "FeatureCollection",'; |
181 | - if ($min) $output .= '"minimal": "true",'; |
|
182 | - else $output .= '"minimal": "false",'; |
|
217 | + if ($min) { |
|
218 | + $output .= '"minimal": "true",'; |
|
219 | + } else { |
|
220 | + $output .= '"minimal": "false",'; |
|
221 | + } |
|
183 | 222 | //$output .= '"fc": "'.$flightcnt.'",'; |
184 | 223 | $output .= '"sqt": "'.$sqltime.'",'; |
185 | 224 | |
@@ -223,18 +262,29 @@ discard block |
||
223 | 262 | } |
224 | 263 | $output .= '"properties": {'; |
225 | 264 | if (isset($spotter_item['flightaware_id'])) { |
226 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
227 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
265 | + if ($compress) { |
|
266 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
267 | + } else { |
|
268 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
269 | + } |
|
228 | 270 | } elseif (isset($spotter_item['famtrackid'])) { |
229 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
230 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
271 | + if ($compress) { |
|
272 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
273 | + } else { |
|
274 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
275 | + } |
|
231 | 276 | } elseif (isset($spotter_item['fammarine_id'])) { |
232 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
233 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
277 | + if ($compress) { |
|
278 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
279 | + } else { |
|
280 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
281 | + } |
|
234 | 282 | } |
235 | 283 | $output .= '"fc": "'.$flightcnt.'",'; |
236 | 284 | $output .= '"sqt": "'.$sqltime.'",'; |
237 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
285 | + if (isset($begindate)) { |
|
286 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
287 | + } |
|
238 | 288 | |
239 | 289 | /* |
240 | 290 | if ($min) $output .= '"minimal": "true",'; |
@@ -242,14 +292,22 @@ discard block |
||
242 | 292 | */ |
243 | 293 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
244 | 294 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
245 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
246 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
295 | + if ($compress) { |
|
296 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
297 | + } else { |
|
298 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
299 | + } |
|
247 | 300 | //" |
248 | 301 | } else { |
249 | - if ($compress) $output .= '"c": "NA",'; |
|
250 | - else $output .= '"callsign": "NA",'; |
|
302 | + if ($compress) { |
|
303 | + $output .= '"c": "NA",'; |
|
304 | + } else { |
|
305 | + $output .= '"callsign": "NA",'; |
|
306 | + } |
|
307 | + } |
|
308 | + if (isset($spotter_item['registration'])) { |
|
309 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
251 | 310 | } |
252 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
253 | 311 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
254 | 312 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
255 | 313 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -262,16 +320,23 @@ discard block |
||
262 | 320 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
263 | 321 | } |
264 | 322 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
265 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
266 | - else { |
|
323 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
324 | + $spotter_item['aircraft_shadow'] = ''; |
|
325 | + } else { |
|
267 | 326 | $aircraft_icao = $spotter_item['aircraft_icao']; |
268 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
269 | - else { |
|
327 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
328 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
329 | + } else { |
|
270 | 330 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
271 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
272 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
273 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
274 | - else $spotter_item['aircraft_shadow'] = ''; |
|
331 | + if (count($aircraft_info) > 0) { |
|
332 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
333 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
334 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
335 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
336 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
337 | + } else { |
|
338 | + $spotter_item['aircraft_shadow'] = ''; |
|
339 | + } |
|
275 | 340 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
276 | 341 | } |
277 | 342 | } |
@@ -279,73 +344,139 @@ discard block |
||
279 | 344 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
280 | 345 | if ($tracker) { |
281 | 346 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
282 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
283 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
347 | + if ($compress) { |
|
348 | + $output .= '"as": "ambulance.png",'; |
|
349 | + } else { |
|
350 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
351 | + } |
|
284 | 352 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
285 | - if ($compress) $output .= '"as": "police.png",'; |
|
286 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
353 | + if ($compress) { |
|
354 | + $output .= '"as": "police.png",'; |
|
355 | + } else { |
|
356 | + $output .= '"aircraft_shadow": "police.png",'; |
|
357 | + } |
|
287 | 358 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
288 | - if ($compress) $output .= '"as": "ship.png",'; |
|
289 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
359 | + if ($compress) { |
|
360 | + $output .= '"as": "ship.png",'; |
|
361 | + } else { |
|
362 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
363 | + } |
|
290 | 364 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
291 | - if ($compress) $output .= '"as": "ship.png",'; |
|
292 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
365 | + if ($compress) { |
|
366 | + $output .= '"as": "ship.png",'; |
|
367 | + } else { |
|
368 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
369 | + } |
|
293 | 370 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
294 | - if ($compress) $output .= '"as": "ship.png",'; |
|
295 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
371 | + if ($compress) { |
|
372 | + $output .= '"as": "ship.png",'; |
|
373 | + } else { |
|
374 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
375 | + } |
|
296 | 376 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
297 | - if ($compress) $output .= '"as": "truck.png",'; |
|
298 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
377 | + if ($compress) { |
|
378 | + $output .= '"as": "truck.png",'; |
|
379 | + } else { |
|
380 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
381 | + } |
|
299 | 382 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
300 | - if ($compress) $output .= '"as": "truck.png",'; |
|
301 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
383 | + if ($compress) { |
|
384 | + $output .= '"as": "truck.png",'; |
|
385 | + } else { |
|
386 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
387 | + } |
|
302 | 388 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
303 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
304 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
389 | + if ($compress) { |
|
390 | + $output .= '"as": "aircraft.png",'; |
|
391 | + } else { |
|
392 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
393 | + } |
|
305 | 394 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
306 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
307 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
395 | + if ($compress) { |
|
396 | + $output .= '"as": "aircraft.png",'; |
|
397 | + } else { |
|
398 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
399 | + } |
|
308 | 400 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
309 | - if ($compress) $output .= '"as": "helico.png",'; |
|
310 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
401 | + if ($compress) { |
|
402 | + $output .= '"as": "helico.png",'; |
|
403 | + } else { |
|
404 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
405 | + } |
|
311 | 406 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
312 | - if ($compress) $output .= '"as": "rail.png",'; |
|
313 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
407 | + if ($compress) { |
|
408 | + $output .= '"as": "rail.png",'; |
|
409 | + } else { |
|
410 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
411 | + } |
|
314 | 412 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
315 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
316 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
413 | + if ($compress) { |
|
414 | + $output .= '"as": "firetruck.png",'; |
|
415 | + } else { |
|
416 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
417 | + } |
|
317 | 418 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
318 | - if ($compress) $output .= '"as": "bus.png",'; |
|
319 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
419 | + if ($compress) { |
|
420 | + $output .= '"as": "bus.png",'; |
|
421 | + } else { |
|
422 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
423 | + } |
|
320 | 424 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
321 | - if ($compress) $output .= '"as": "phone.png",'; |
|
322 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
425 | + if ($compress) { |
|
426 | + $output .= '"as": "phone.png",'; |
|
427 | + } else { |
|
428 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
429 | + } |
|
323 | 430 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
324 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
325 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
431 | + if ($compress) { |
|
432 | + $output .= '"as": "jogger.png",'; |
|
433 | + } else { |
|
434 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
435 | + } |
|
326 | 436 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
327 | - if ($compress) $output .= '"as": "bike.png",'; |
|
328 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
437 | + if ($compress) { |
|
438 | + $output .= '"as": "bike.png",'; |
|
439 | + } else { |
|
440 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
441 | + } |
|
329 | 442 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
330 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
331 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
443 | + if ($compress) { |
|
444 | + $output .= '"as": "motorcycle.png",'; |
|
445 | + } else { |
|
446 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
447 | + } |
|
332 | 448 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
333 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
334 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
449 | + if ($compress) { |
|
450 | + $output .= '"as": "balloon.png",'; |
|
451 | + } else { |
|
452 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
453 | + } |
|
335 | 454 | } else { |
336 | - if ($compress) $output .= '"as": "car.png",'; |
|
337 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
455 | + if ($compress) { |
|
456 | + $output .= '"as": "car.png",'; |
|
457 | + } else { |
|
458 | + $output .= '"aircraft_shadow": "car.png",'; |
|
459 | + } |
|
338 | 460 | } |
339 | 461 | } elseif ($marine) { |
340 | - if ($compress) $output .= '"as": "ship.png",'; |
|
341 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
462 | + if ($compress) { |
|
463 | + $output .= '"as": "ship.png",'; |
|
464 | + } else { |
|
465 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
466 | + } |
|
342 | 467 | } else { |
343 | - if ($compress) $output .= '"as": "default.png",'; |
|
344 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
468 | + if ($compress) { |
|
469 | + $output .= '"as": "default.png",'; |
|
470 | + } else { |
|
471 | + $output .= '"aircraft_shadow": "default.png",'; |
|
472 | + } |
|
345 | 473 | } |
346 | 474 | } else { |
347 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
348 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
475 | + if ($compress) { |
|
476 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
477 | + } else { |
|
478 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
479 | + } |
|
349 | 480 | } |
350 | 481 | if (isset($spotter_item['airline_name'])) { |
351 | 482 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -353,8 +484,11 @@ discard block |
||
353 | 484 | $output .= '"airline_name": "NA",'; |
354 | 485 | } |
355 | 486 | if (isset($spotter_item['departure_airport'])) { |
356 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
357 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
487 | + if ($compress) { |
|
488 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
489 | + } else { |
|
490 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
491 | + } |
|
358 | 492 | } |
359 | 493 | if (isset($spotter_item['departure_airport_city'])) { |
360 | 494 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -366,8 +500,11 @@ discard block |
||
366 | 500 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
367 | 501 | } |
368 | 502 | if (isset($spotter_item['arrival_airport'])) { |
369 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
370 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
503 | + if ($compress) { |
|
504 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
505 | + } else { |
|
506 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
507 | + } |
|
371 | 508 | } |
372 | 509 | if (isset($spotter_item['arrival_airport_city'])) { |
373 | 510 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -386,11 +523,17 @@ discard block |
||
386 | 523 | } |
387 | 524 | |
388 | 525 | if (isset($spotter_item['altitude'])) { |
389 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
390 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
526 | + if ($compress) { |
|
527 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
528 | + } else { |
|
529 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
530 | + } |
|
531 | + } |
|
532 | + if ($compress) { |
|
533 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
534 | + } else { |
|
535 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
391 | 536 | } |
392 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
393 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
394 | 537 | |
395 | 538 | if ($currenttime != '') { |
396 | 539 | if (strtotime($spotter_item['date']) < $currenttime) { |
@@ -412,7 +555,9 @@ discard block |
||
412 | 555 | } |
413 | 556 | } |
414 | 557 | |
415 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
558 | + if (!$min) { |
|
559 | + $output .= '"image": "'.$image.'",'; |
|
560 | + } |
|
416 | 561 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
417 | 562 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
418 | 563 | } |
@@ -420,8 +565,11 @@ discard block |
||
420 | 565 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
421 | 566 | } |
422 | 567 | if (isset($spotter_item['squawk'])) { |
423 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
424 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
568 | + if ($compress) { |
|
569 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
570 | + } else { |
|
571 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
572 | + } |
|
425 | 573 | } |
426 | 574 | if (isset($spotter_item['squawk_usage'])) { |
427 | 575 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -440,14 +588,23 @@ discard block |
||
440 | 588 | } |
441 | 589 | // type when not aircraft ? |
442 | 590 | if (isset($spotter_item['type'])) { |
443 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
444 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
591 | + if ($compress) { |
|
592 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
593 | + } else { |
|
594 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
595 | + } |
|
445 | 596 | } elseif ($marine) { |
446 | - if ($compress) $output .= '"t": "ship"'; |
|
447 | - else $output .= '"type": "ship"'; |
|
597 | + if ($compress) { |
|
598 | + $output .= '"t": "ship"'; |
|
599 | + } else { |
|
600 | + $output .= '"type": "ship"'; |
|
601 | + } |
|
448 | 602 | } else { |
449 | - if ($compress) $output .= '"t": "aircraft"'; |
|
450 | - else $output .= '"type": "aircraft"'; |
|
603 | + if ($compress) { |
|
604 | + $output .= '"t": "aircraft"'; |
|
605 | + } else { |
|
606 | + $output .= '"type": "aircraft"'; |
|
607 | + } |
|
451 | 608 | } |
452 | 609 | $output .= '},'; |
453 | 610 | $output .= '"geometry": {'; |
@@ -455,7 +612,9 @@ discard block |
||
455 | 612 | $output .= '"coordinates": ['; |
456 | 613 | if ($currenttime != '') { |
457 | 614 | if (strtotime($spotter_item['date']) < $currenttime) { |
458 | - if (!isset($archivespeed)) $archivespeed = 1; |
|
615 | + if (!isset($archivespeed)) { |
|
616 | + $archivespeed = 1; |
|
617 | + } |
|
459 | 618 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed,$currenttime-strtotime($spotter_item['date'])); |
460 | 619 | $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
461 | 620 | } else { |
@@ -526,7 +685,9 @@ discard block |
||
526 | 685 | } |
527 | 686 | */ |
528 | 687 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
529 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
688 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
689 | + $history = $_COOKIE['history']; |
|
690 | + } |
|
530 | 691 | |
531 | 692 | if ( |
532 | 693 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -570,8 +731,11 @@ discard block |
||
570 | 731 | $output_history .= ']}},'; |
571 | 732 | $output .= $output_history; |
572 | 733 | } |
573 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
574 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
734 | + if ($compress) { |
|
735 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
736 | + } else { |
|
737 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
738 | + } |
|
575 | 739 | } |
576 | 740 | $output_history .= '['; |
577 | 741 | $output_history .= $spotter_history['longitude'].', '; |
@@ -590,9 +754,14 @@ discard block |
||
590 | 754 | $prev_alt = $alt; |
591 | 755 | } else { |
592 | 756 | if ($d == false) { |
593 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
594 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
595 | - } else $d = true; |
|
757 | + if ($compress) { |
|
758 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
759 | + } else { |
|
760 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
761 | + } |
|
762 | + } else { |
|
763 | + $d = true; |
|
764 | + } |
|
596 | 765 | $output_history .= '['; |
597 | 766 | $output_history .= $spotter_history['longitude'].', '; |
598 | 767 | $output_history .= $spotter_history['latitude']; |
@@ -613,7 +782,9 @@ discard block |
||
613 | 782 | $output_historyd = '['; |
614 | 783 | $output_historyd .= $spotter_item['longitude'].', '; |
615 | 784 | $output_historyd .= $spotter_item['latitude']; |
616 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
785 | + if (isset($spotter_history['altitude'])) { |
|
786 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
787 | + } |
|
617 | 788 | $output_historyd .= '],'; |
618 | 789 | //$output_history = $output_historyd.$output_history; |
619 | 790 | $output_history = $output_history.$output_historyd; |
@@ -635,8 +806,11 @@ discard block |
||
635 | 806 | && $spotter_item['arrival_airport'] != 'NA' |
636 | 807 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
637 | 808 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
638 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
639 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
809 | + if ($compress) { |
|
810 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
811 | + } else { |
|
812 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
813 | + } |
|
640 | 814 | if (isset($spotter_item['departure_airport_latitude'])) { |
641 | 815 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
642 | 816 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -669,8 +843,11 @@ discard block |
||
669 | 843 | || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
670 | 844 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
671 | 845 | $havedata = false; |
672 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
673 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
846 | + if ($compress) { |
|
847 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
848 | + } else { |
|
849 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
850 | + } |
|
674 | 851 | $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
675 | 852 | |
676 | 853 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -685,7 +862,9 @@ discard block |
||
685 | 862 | } |
686 | 863 | //$output_dest = substr($output_dest, 0, -1); |
687 | 864 | $output_dest .= ']}},'; |
688 | - if ($havedata) $output .= $output_dest; |
|
865 | + if ($havedata) { |
|
866 | + $output .= $output_dest; |
|
867 | + } |
|
689 | 868 | unset($output_dest); |
690 | 869 | } |
691 | 870 | } |
@@ -693,7 +872,9 @@ discard block |
||
693 | 872 | $output .= ']'; |
694 | 873 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
695 | 874 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
696 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
875 | + if (isset($begindate)) { |
|
876 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
877 | + } |
|
697 | 878 | $output .= '"fc": "'.$j.'"'; |
698 | 879 | } else { |
699 | 880 | $output .= '"features": '; |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
25 | + if (empty($all_manufacturers)) { |
|
26 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
27 | + } |
|
26 | 28 | foreach($all_manufacturers as $all_manufacturer) |
27 | 29 | { |
28 | 30 | if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer'])) |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
25 | + if (empty($all_manufacturers)) { |
|
26 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
27 | + } |
|
26 | 28 | foreach($all_manufacturers as $all_manufacturer) |
27 | 29 | { |
28 | 30 | if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer'])) |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | public function __construct($dbc = null) { |
10 | 10 | $Connection = new Connection($dbc); |
11 | 11 | $this->db = $Connection->db(); |
12 | - if ($this->db === null) die('Error: No DB connection. (Image)'); |
|
12 | + if ($this->db === null) { |
|
13 | + die('Error: No DB connection. (Image)'); |
|
14 | + } |
|
13 | 15 | } |
14 | 16 | |
15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
26 | 28 | $reg = $registration; |
27 | - if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
29 | + if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') { |
|
30 | + $reg = $aircraft_icao.$airline_icao; |
|
31 | + } |
|
28 | 32 | $reg = trim($reg); |
29 | 33 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
32 | 36 | $sth = $this->db->prepare($query); |
33 | 37 | $sth->execute(array(':registration' => $reg)); |
34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | - if (!empty($result)) return $result; |
|
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
37 | - else return array(); |
|
39 | + if (!empty($result)) { |
|
40 | + return $result; |
|
41 | + } elseif ($registration != '') { |
|
42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
43 | + } else { |
|
44 | + return array(); |
|
45 | + } |
|
38 | 46 | } |
39 | 47 | |
40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
77 | 85 | public function getExifCopyright($url) { |
78 | 86 | $exif = exif_read_data($url); |
79 | 87 | $copyright = ''; |
80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
90 | + } elseif (isset($exif['copyright'])) { |
|
91 | + $copyright = $exif['copyright']; |
|
92 | + } |
|
82 | 93 | if ($copyright != '') { |
83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
97 | 108 | { |
98 | 109 | global $globalDebug,$globalAircraftImageFetch; |
99 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
110 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
111 | + return ''; |
|
112 | + } |
|
100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
101 | 114 | $registration = trim($registration); |
102 | 115 | //getting the aircraft image |
103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
116 | + if ($globalDebug && $registration != '') { |
|
117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
122 | + } |
|
106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
124 | + if ($registration == '' && $aircraft_icao != '') { |
|
125 | + $registration = $aircraft_icao.$airline_icao; |
|
126 | + } |
|
108 | 127 | if ($image_url['original'] != '') { |
109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
128 | + if ($globalDebug) { |
|
129 | + echo 'Found !'."\n"; |
|
130 | + } |
|
110 | 131 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
111 | 132 | try { |
112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
115 | 136 | echo $e->getMessage()."\n"; |
116 | 137 | return "error"; |
117 | 138 | } |
118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
139 | + } elseif ($globalDebug) { |
|
140 | + echo "Not found :'(\n"; |
|
141 | + } |
|
119 | 142 | return "success"; |
120 | 143 | } |
121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
129 | 152 | { |
130 | 153 | global $globalDebug,$globalMarineImageFetch; |
131 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
154 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
155 | + return ''; |
|
156 | + } |
|
132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
138 | 163 | $identity = $Marine->getIdentity($mmsi); |
139 | 164 | if (isset($identity[0]['mmsi'])) { |
140 | 165 | $imo = $identity[0]['imo']; |
141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
166 | + if ($identity[0]['ship_name'] != '') { |
|
167 | + $name = $identity[0]['ship_name']; |
|
168 | + } |
|
142 | 169 | } |
143 | 170 | } |
144 | 171 | unset($Marine); |
145 | 172 | |
146 | 173 | //getting the aircraft image |
147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
174 | + if ($globalDebug && $name != '') { |
|
175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
176 | + } |
|
148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
149 | 178 | if ($image_url['original'] != '') { |
150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo 'Found !'."\n"; |
|
181 | + } |
|
151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
152 | 183 | try { |
153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
156 | 187 | echo $e->getMessage()."\n"; |
157 | 188 | return "error"; |
158 | 189 | } |
159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
190 | + } elseif ($globalDebug) { |
|
191 | + echo "Not found :'(\n"; |
|
192 | + } |
|
160 | 193 | return "success"; |
161 | 194 | } |
162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
171 | 204 | { |
172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 206 | $Spotter = new Spotter($this->db); |
174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
207 | + if (!isset($globalIVAO)) { |
|
208 | + $globalIVAO = FALSE; |
|
209 | + } |
|
175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
176 | 211 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
214 | + } |
|
178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
181 | - else $aircraft_name = ''; |
|
182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
183 | - else $aircraft_icao = ''; |
|
184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
185 | - else $airline_icao = ''; |
|
217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
219 | + } else { |
|
220 | + $aircraft_name = ''; |
|
221 | + } |
|
222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
224 | + } else { |
|
225 | + $aircraft_icao = ''; |
|
226 | + } |
|
227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
229 | + } else { |
|
230 | + $airline_icao = ''; |
|
231 | + } |
|
186 | 232 | } elseif ($aircraft_icao != '') { |
187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
189 | - else $aircraft_name = ''; |
|
234 | + if (isset($aircraft_info[0]['type'])) { |
|
235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
236 | + } else { |
|
237 | + $aircraft_name = ''; |
|
238 | + } |
|
190 | 239 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
240 | + } else { |
|
241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
242 | + } |
|
192 | 243 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
244 | + if (!isset($globalAircraftImageSources)) { |
|
245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
246 | + } |
|
194 | 247 | foreach ($globalAircraftImageSources as $source) { |
195 | 248 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
207 | - } |
|
208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
251 | + } |
|
252 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
254 | + } |
|
255 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
257 | + } |
|
258 | + if ($source == 'bing') { |
|
259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
260 | + } |
|
261 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
263 | + } |
|
264 | + if ($source == 'wikimedia') { |
|
265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
266 | + } |
|
267 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
269 | + } |
|
270 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
272 | + } |
|
273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
275 | + } |
|
276 | + if ($source == 'customsources') { |
|
277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
278 | + } |
|
279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
280 | + return $images_array; |
|
281 | + } |
|
282 | + } |
|
283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
284 | + return $this->findAircraftImage($aircraft_icao); |
|
285 | + } |
|
209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
210 | 287 | } |
211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
227 | 304 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
305 | + if (strlen($name) < 4) { |
|
306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
307 | + } |
|
229 | 308 | /* |
230 | 309 | $Marine = new Marine($this->db); |
231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
237 | 316 | } |
238 | 317 | unset($Marine); |
239 | 318 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
319 | + if (!isset($globalMarineImageSources)) { |
|
320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
321 | + } |
|
241 | 322 | foreach ($globalMarineImageSources as $source) { |
242 | 323 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
324 | + if ($source == 'flickr') { |
|
325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
326 | + } |
|
327 | + if ($source == 'bing') { |
|
328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
329 | + } |
|
330 | + if ($source == 'deviantart') { |
|
331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
332 | + } |
|
333 | + if ($source == 'wikimedia') { |
|
334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
335 | + } |
|
336 | + if ($source == 'customsources') { |
|
337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
338 | + } |
|
339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
340 | + return $images_array; |
|
341 | + } |
|
249 | 342 | } |
250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
251 | 344 | } |
@@ -268,7 +361,9 @@ discard block |
||
268 | 361 | $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
269 | 362 | } |
270 | 363 | $data = $Common->getData($url); |
271 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
364 | + if (substr($data, 0, 5) != "<?xml") { |
|
365 | + return false; |
|
366 | + } |
|
272 | 367 | if ($xml = simplexml_load_string($data)) { |
273 | 368 | if (isset($xml->channel->item)) { |
274 | 369 | $image_url = array(); |
@@ -307,7 +402,9 @@ discard block |
||
307 | 402 | $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
308 | 403 | } |
309 | 404 | $data = $Common->getData($url); |
310 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
405 | + if (substr($data, 0, 5) != "<?xml") { |
|
406 | + return false; |
|
407 | + } |
|
311 | 408 | if ($xml = simplexml_load_string($data)) { |
312 | 409 | if (isset($xml->channel->item->link)) { |
313 | 410 | $image_url = array(); |
@@ -411,14 +508,22 @@ discard block |
||
411 | 508 | public function fromFlickr($type,$registration,$name='') { |
412 | 509 | $Common = new Common(); |
413 | 510 | if ($type == 'aircraft') { |
414 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
415 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
511 | + if ($name != '') { |
|
512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
513 | + } else { |
|
514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
515 | + } |
|
416 | 516 | } elseif ($type == 'marine') { |
417 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
418 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
517 | + if ($name != '') { |
|
518 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
519 | + } else { |
|
520 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
521 | + } |
|
419 | 522 | } |
420 | 523 | $data = $Common->getData($url); |
421 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
524 | + if (substr($data, 0, 5) != "<?xml") { |
|
525 | + return false; |
|
526 | + } |
|
422 | 527 | if ($xml = simplexml_load_string($data)) { |
423 | 528 | if (isset($xml->channel->item)) { |
424 | 529 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
@@ -461,13 +566,21 @@ discard block |
||
461 | 566 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
462 | 567 | global $globalImageBingKey; |
463 | 568 | $Common = new Common(); |
464 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
569 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
570 | + return false; |
|
571 | + } |
|
465 | 572 | if ($type == 'aircraft') { |
466 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
467 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
573 | + if ($aircraft_name != '') { |
|
574 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
575 | + } else { |
|
576 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
577 | + } |
|
468 | 578 | } elseif ($type == 'marine') { |
469 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
470 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
579 | + if ($aircraft_name != '') { |
|
580 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
581 | + } else { |
|
582 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
583 | + } |
|
471 | 584 | } |
472 | 585 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
473 | 586 | $data = $Common->getData($url,'get','',$headers); |
@@ -523,17 +636,25 @@ discard block |
||
523 | 636 | public function fromWikimedia($type,$registration,$name='') { |
524 | 637 | $Common = new Common(); |
525 | 638 | if ($type == 'aircraft') { |
526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
527 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
639 | + if ($name != '') { |
|
640 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
641 | + } else { |
|
642 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
643 | + } |
|
528 | 644 | } elseif ($type == 'marine') { |
529 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
530 | - else return false; |
|
645 | + if ($name != '') { |
|
646 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
647 | + } else { |
|
648 | + return false; |
|
649 | + } |
|
531 | 650 | } |
532 | 651 | $data = $Common->getData($url); |
533 | 652 | $result = json_decode($data); |
534 | 653 | if (isset($result->query->search[0]->title)) { |
535 | 654 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
655 | + if (substr($fileo,-3) == 'pdf') { |
|
656 | + return false; |
|
657 | + } |
|
537 | 658 | $file = urlencode($fileo); |
538 | 659 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 660 | $data2 = $Common->getData($url2); |
@@ -604,18 +725,27 @@ discard block |
||
604 | 725 | $image_url = array(); |
605 | 726 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 727 | $image_url['original'] = $url; |
607 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
608 | - else $exifCopyright = ''; |
|
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
611 | - else $image_url['copyright'] = $source['source_website']; |
|
728 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
729 | + $exifCopyright = $this->getExifCopyright($url); |
|
730 | + } else { |
|
731 | + $exifCopyright = ''; |
|
732 | + } |
|
733 | + if ($exifCopyright != '') { |
|
734 | + $image_url['copyright'] = $exifCopyright; |
|
735 | + } elseif (isset($source['copyright'])) { |
|
736 | + $image_url['copyright'] = $source['copyright']; |
|
737 | + } else { |
|
738 | + $image_url['copyright'] = $source['source_website']; |
|
739 | + } |
|
612 | 740 | $image_url['source_website'] = $source['source_website']; |
613 | 741 | $image_url['source'] = $source['source']; |
614 | 742 | return $image_url; |
615 | 743 | } |
616 | 744 | } |
617 | 745 | return false; |
618 | - } else return false; |
|
746 | + } else { |
|
747 | + return false; |
|
748 | + } |
|
619 | 749 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
620 | 750 | $customsources = array(); |
621 | 751 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -640,18 +770,27 @@ discard block |
||
640 | 770 | $image_url = array(); |
641 | 771 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 772 | $image_url['original'] = $url; |
643 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
644 | - else $exifCopyright = ''; |
|
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
647 | - else $image_url['copyright'] = $source['source_website']; |
|
773 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
774 | + $exifCopyright = $this->getExifCopyright($url); |
|
775 | + } else { |
|
776 | + $exifCopyright = ''; |
|
777 | + } |
|
778 | + if ($exifCopyright != '') { |
|
779 | + $image_url['copyright'] = $exifCopyright; |
|
780 | + } elseif (isset($source['copyright'])) { |
|
781 | + $image_url['copyright'] = $source['copyright']; |
|
782 | + } else { |
|
783 | + $image_url['copyright'] = $source['source_website']; |
|
784 | + } |
|
648 | 785 | $image_url['source_website'] = $source['source_website']; |
649 | 786 | $image_url['source'] = $source['source']; |
650 | 787 | return $image_url; |
651 | 788 | } |
652 | 789 | } |
653 | 790 | return false; |
654 | - } else return false; |
|
791 | + } else { |
|
792 | + return false; |
|
793 | + } |
|
655 | 794 | } |
656 | 795 | } |
657 | 796 |
@@ -1,13 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) { |
|
5 | + $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
6 | +} |
|
7 | +if (isset($_GET['ident'])) { |
|
8 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
9 | +} |
|
6 | 10 | if ($ident != '') |
7 | 11 | { |
8 | - if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
9 | - else header('Location: '.$globalURL.'/ident/'.$ident); |
|
10 | -} else { |
|
12 | + if (isset($_GET['marine'])) { |
|
13 | + header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
14 | + } else { |
|
15 | + header('Location: '.$globalURL.'/ident/'.$ident); |
|
16 | + } |
|
17 | + } else { |
|
11 | 18 | if ($globalURL == '') { |
12 | 19 | header('Location: /'); |
13 | 20 | } else { |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
27 | 27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
28 | 28 | curl_setopt($ch, CURLOPT_TIMEOUT, 20); |
29 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
29 | + if ($referer != '') { |
|
30 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
31 | + } |
|
30 | 32 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
31 | 33 | curl_setopt($ch, CURLOPT_FILE, $fp); |
32 | 34 | curl_exec($ch); |
@@ -37,12 +39,16 @@ discard block |
||
37 | 39 | public static function gunzip($in_file,$out_file_name = '') { |
38 | 40 | //echo $in_file.' -> '.$out_file_name."\n"; |
39 | 41 | $buffer_size = 4096; // read 4kb at a time |
40 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
42 | + if ($out_file_name == '') { |
|
43 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
44 | + } |
|
41 | 45 | if ($in_file != '' && file_exists($in_file)) { |
42 | 46 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
45 | - else { |
|
47 | + if (function_exists('gzopen')) { |
|
48 | + $file = gzopen($in_file,'rb'); |
|
49 | + } elseif (function_exists('gzopen64')) { |
|
50 | + $file = gzopen64($in_file,'rb'); |
|
51 | + } else { |
|
46 | 52 | echo 'gzopen not available'; |
47 | 53 | die; |
48 | 54 | } |
@@ -63,8 +69,12 @@ discard block |
||
63 | 69 | if ($res === TRUE) { |
64 | 70 | $zip->extractTo($path); |
65 | 71 | $zip->close(); |
66 | - } else return false; |
|
67 | - } else return false; |
|
72 | + } else { |
|
73 | + return false; |
|
74 | + } |
|
75 | + } else { |
|
76 | + return false; |
|
77 | + } |
|
68 | 78 | } |
69 | 79 | |
70 | 80 | public static function connect_sqlite($database) { |
@@ -79,7 +89,9 @@ discard block |
||
79 | 89 | public static function retrieve_route_sqlite_to_dest($database_file) { |
80 | 90 | global $globalDebug, $globalTransaction; |
81 | 91 | //$query = 'TRUNCATE TABLE routes'; |
82 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
92 | + if ($globalDebug) { |
|
93 | + echo " - Delete previous routes from DB -"; |
|
94 | + } |
|
83 | 95 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
84 | 96 | $Connection = new Connection(); |
85 | 97 | try { |
@@ -90,7 +102,9 @@ discard block |
||
90 | 102 | return "error : ".$e->getMessage(); |
91 | 103 | } |
92 | 104 | |
93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
105 | + if ($globalDebug) { |
|
106 | + echo " - Add routes to DB -"; |
|
107 | + } |
|
94 | 108 | update_db::connect_sqlite($database_file); |
95 | 109 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
96 | 110 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -105,15 +119,21 @@ discard block |
||
105 | 119 | $Connection = new Connection(); |
106 | 120 | $sth_dest = $Connection->db->prepare($query_dest); |
107 | 121 | try { |
108 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
122 | + if ($globalTransaction) { |
|
123 | + $Connection->db->beginTransaction(); |
|
124 | + } |
|
109 | 125 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
110 | 126 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
111 | 127 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
112 | 128 | $sth_dest->execute($query_dest_values); |
113 | 129 | } |
114 | - if ($globalTransaction) $Connection->db->commit(); |
|
130 | + if ($globalTransaction) { |
|
131 | + $Connection->db->commit(); |
|
132 | + } |
|
115 | 133 | } catch(PDOException $e) { |
116 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
134 | + if ($globalTransaction) { |
|
135 | + $Connection->db->rollBack(); |
|
136 | + } |
|
117 | 137 | return "error : ".$e->getMessage(); |
118 | 138 | } |
119 | 139 | return ''; |
@@ -121,7 +141,9 @@ discard block |
||
121 | 141 | public static function retrieve_route_oneworld($database_file) { |
122 | 142 | global $globalDebug, $globalTransaction; |
123 | 143 | //$query = 'TRUNCATE TABLE routes'; |
124 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
144 | + if ($globalDebug) { |
|
145 | + echo " - Delete previous routes from DB -"; |
|
146 | + } |
|
125 | 147 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
126 | 148 | $Connection = new Connection(); |
127 | 149 | try { |
@@ -132,14 +154,18 @@ discard block |
||
132 | 154 | return "error : ".$e->getMessage(); |
133 | 155 | } |
134 | 156 | |
135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
157 | + if ($globalDebug) { |
|
158 | + echo " - Add routes to DB -"; |
|
159 | + } |
|
136 | 160 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
137 | 161 | $Spotter = new Spotter(); |
138 | 162 | if ($fh = fopen($database_file,"r")) { |
139 | 163 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
140 | 164 | $Connection = new Connection(); |
141 | 165 | $sth_dest = $Connection->db->prepare($query_dest); |
142 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
166 | + if ($globalTransaction) { |
|
167 | + $Connection->db->beginTransaction(); |
|
168 | + } |
|
143 | 169 | while (!feof($fh)) { |
144 | 170 | $line = fgetcsv($fh,9999,','); |
145 | 171 | if ($line[0] != '') { |
@@ -148,13 +174,17 @@ discard block |
||
148 | 174 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
149 | 175 | $sth_dest->execute($query_dest_values); |
150 | 176 | } catch(PDOException $e) { |
151 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
177 | + if ($globalTransaction) { |
|
178 | + $Connection->db->rollBack(); |
|
179 | + } |
|
152 | 180 | return "error : ".$e->getMessage(); |
153 | 181 | } |
154 | 182 | } |
155 | 183 | } |
156 | 184 | } |
157 | - if ($globalTransaction) $Connection->db->commit(); |
|
185 | + if ($globalTransaction) { |
|
186 | + $Connection->db->commit(); |
|
187 | + } |
|
158 | 188 | } |
159 | 189 | return ''; |
160 | 190 | } |
@@ -162,7 +192,9 @@ discard block |
||
162 | 192 | public static function retrieve_route_skyteam($database_file) { |
163 | 193 | global $globalDebug, $globalTransaction; |
164 | 194 | //$query = 'TRUNCATE TABLE routes'; |
165 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
195 | + if ($globalDebug) { |
|
196 | + echo " - Delete previous routes from DB -"; |
|
197 | + } |
|
166 | 198 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
167 | 199 | $Connection = new Connection(); |
168 | 200 | try { |
@@ -173,7 +205,9 @@ discard block |
||
173 | 205 | return "error : ".$e->getMessage(); |
174 | 206 | } |
175 | 207 | |
176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo " - Add routes to DB -"; |
|
210 | + } |
|
177 | 211 | |
178 | 212 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
179 | 213 | $Spotter = new Spotter(); |
@@ -182,7 +216,9 @@ discard block |
||
182 | 216 | $Connection = new Connection(); |
183 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
184 | 218 | try { |
185 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
219 | + if ($globalTransaction) { |
|
220 | + $Connection->db->beginTransaction(); |
|
221 | + } |
|
186 | 222 | while (!feof($fh)) { |
187 | 223 | $line = fgetcsv($fh,9999,','); |
188 | 224 | if ($line[0] != '') { |
@@ -193,9 +229,13 @@ discard block |
||
193 | 229 | } |
194 | 230 | } |
195 | 231 | } |
196 | - if ($globalTransaction) $Connection->db->commit(); |
|
232 | + if ($globalTransaction) { |
|
233 | + $Connection->db->commit(); |
|
234 | + } |
|
197 | 235 | } catch(PDOException $e) { |
198 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
236 | + if ($globalTransaction) { |
|
237 | + $Connection->db->rollBack(); |
|
238 | + } |
|
199 | 239 | return "error : ".$e->getMessage(); |
200 | 240 | } |
201 | 241 | } |
@@ -238,11 +278,16 @@ discard block |
||
238 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
239 | 279 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
240 | 280 | try { |
241 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
281 | + if ($globalTransaction) { |
|
282 | + $Connection->db->beginTransaction(); |
|
283 | + } |
|
242 | 284 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
243 | 285 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
244 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
245 | - else $type = null; |
|
286 | + if ($values['UserString4'] == 'M') { |
|
287 | + $type = 'military'; |
|
288 | + } else { |
|
289 | + $type = null; |
|
290 | + } |
|
246 | 291 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
247 | 292 | $sth_dest->execute($query_dest_values); |
248 | 293 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -250,7 +295,9 @@ discard block |
||
250 | 295 | $sth_dest_owner->execute($query_dest_owner_values); |
251 | 296 | } |
252 | 297 | } |
253 | - if ($globalTransaction) $Connection->db->commit(); |
|
298 | + if ($globalTransaction) { |
|
299 | + $Connection->db->commit(); |
|
300 | + } |
|
254 | 301 | } catch(PDOException $e) { |
255 | 302 | return "error : ".$e->getMessage(); |
256 | 303 | } |
@@ -287,7 +334,9 @@ discard block |
||
287 | 334 | $Connection = new Connection(); |
288 | 335 | $sth_dest = $Connection->db->prepare($query_dest); |
289 | 336 | try { |
290 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
337 | + if ($globalTransaction) { |
|
338 | + $Connection->db->beginTransaction(); |
|
339 | + } |
|
291 | 340 | while (!feof($fh)) { |
292 | 341 | $values = array(); |
293 | 342 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -298,7 +347,9 @@ discard block |
||
298 | 347 | // Check if we can find ICAO, else set it to GLID |
299 | 348 | $aircraft_name_split = explode(' ',$aircraft_name); |
300 | 349 | $search_more = ''; |
301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
350 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
351 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
352 | + } |
|
302 | 353 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
303 | 354 | $sth_search = $Connection->db->prepare($query_search); |
304 | 355 | try { |
@@ -311,7 +362,9 @@ discard block |
||
311 | 362 | } catch(PDOException $e) { |
312 | 363 | return "error : ".$e->getMessage(); |
313 | 364 | } |
314 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
365 | + if (!isset($values['ICAOTypeCode'])) { |
|
366 | + $values['ICAOTypeCode'] = 'GLID'; |
|
367 | + } |
|
315 | 368 | // Add data to db |
316 | 369 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
317 | 370 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -320,7 +373,9 @@ discard block |
||
320 | 373 | $sth_dest->execute($query_dest_values); |
321 | 374 | } |
322 | 375 | } |
323 | - if ($globalTransaction) $Connection->db->commit(); |
|
376 | + if ($globalTransaction) { |
|
377 | + $Connection->db->commit(); |
|
378 | + } |
|
324 | 379 | } catch(PDOException $e) { |
325 | 380 | return "error : ".$e->getMessage(); |
326 | 381 | } |
@@ -356,7 +411,9 @@ discard block |
||
356 | 411 | $Connection = new Connection(); |
357 | 412 | $sth_dest = $Connection->db->prepare($query_dest); |
358 | 413 | try { |
359 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
414 | + if ($globalTransaction) { |
|
415 | + $Connection->db->beginTransaction(); |
|
416 | + } |
|
360 | 417 | $tmp = fgetcsv($fh,9999,',',"'"); |
361 | 418 | while (!feof($fh)) { |
362 | 419 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -370,13 +427,17 @@ discard block |
||
370 | 427 | // Check if we can find ICAO, else set it to GLID |
371 | 428 | $aircraft_name_split = explode(' ',$aircraft_name); |
372 | 429 | $search_more = ''; |
373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
430 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
431 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
432 | + } |
|
374 | 433 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
375 | 434 | $sth_search = $Connection->db->prepare($query_search); |
376 | 435 | try { |
377 | 436 | $sth_search->execute(); |
378 | 437 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
438 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
439 | + $values['ICAOTypeCode'] = $result['icao']; |
|
440 | + } |
|
380 | 441 | } catch(PDOException $e) { |
381 | 442 | return "error : ".$e->getMessage(); |
382 | 443 | } |
@@ -389,7 +450,9 @@ discard block |
||
389 | 450 | $sth_dest->execute($query_dest_values); |
390 | 451 | } |
391 | 452 | } |
392 | - if ($globalTransaction) $Connection->db->commit(); |
|
453 | + if ($globalTransaction) { |
|
454 | + $Connection->db->commit(); |
|
455 | + } |
|
393 | 456 | } catch(PDOException $e) { |
394 | 457 | return "error : ".$e->getMessage(); |
395 | 458 | } |
@@ -428,7 +491,9 @@ discard block |
||
428 | 491 | $sth_dest = $Connection->db->prepare($query_dest); |
429 | 492 | $sth_modes = $Connection->db->prepare($query_modes); |
430 | 493 | try { |
431 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
494 | + if ($globalTransaction) { |
|
495 | + $Connection->db->beginTransaction(); |
|
496 | + } |
|
432 | 497 | $tmp = fgetcsv($fh,9999,',','"'); |
433 | 498 | while (!feof($fh)) { |
434 | 499 | $line = fgetcsv($fh,9999,',','"'); |
@@ -438,16 +503,22 @@ discard block |
||
438 | 503 | $values['registration'] = $line[0]; |
439 | 504 | $values['base'] = $line[4]; |
440 | 505 | $values['owner'] = $line[5]; |
441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | + if ($line[6] == '') { |
|
507 | + $values['date_first_reg'] = null; |
|
508 | + } else { |
|
509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
510 | + } |
|
443 | 511 | $values['cancel'] = $line[7]; |
444 | 512 | } elseif ($country == 'EI') { |
445 | 513 | // TODO : add modeS & reg to aircraft_modes |
446 | 514 | $values['registration'] = $line[0]; |
447 | 515 | $values['base'] = $line[3]; |
448 | 516 | $values['owner'] = $line[2]; |
449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
517 | + if ($line[1] == '') { |
|
518 | + $values['date_first_reg'] = null; |
|
519 | + } else { |
|
520 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
521 | + } |
|
451 | 522 | $values['cancel'] = ''; |
452 | 523 | $values['modes'] = $line[7]; |
453 | 524 | $values['icao'] = $line[8]; |
@@ -466,16 +537,22 @@ discard block |
||
466 | 537 | $values['registration'] = $line[3]; |
467 | 538 | $values['base'] = null; |
468 | 539 | $values['owner'] = $line[5]; |
469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
540 | + if ($line[18] == '') { |
|
541 | + $values['date_first_reg'] = null; |
|
542 | + } else { |
|
543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
544 | + } |
|
471 | 545 | $values['cancel'] = ''; |
472 | 546 | } elseif ($country == 'VH') { |
473 | 547 | // TODO : add modeS & reg to aircraft_modes |
474 | 548 | $values['registration'] = $line[0]; |
475 | 549 | $values['base'] = null; |
476 | 550 | $values['owner'] = $line[12]; |
477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
551 | + if ($line[28] == '') { |
|
552 | + $values['date_first_reg'] = null; |
|
553 | + } else { |
|
554 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
555 | + } |
|
479 | 556 | |
480 | 557 | $values['cancel'] = $line[39]; |
481 | 558 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -494,29 +571,41 @@ discard block |
||
494 | 571 | $values['registration'] = $line[0]; |
495 | 572 | $values['base'] = null; |
496 | 573 | $values['owner'] = $line[8]; |
497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
574 | + if ($line[7] == '') { |
|
575 | + $values['date_first_reg'] = null; |
|
576 | + } else { |
|
577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
578 | + } |
|
499 | 579 | $values['cancel'] = ''; |
500 | 580 | } elseif ($country == 'PP') { |
501 | 581 | $values['registration'] = $line[0]; |
502 | 582 | $values['base'] = null; |
503 | 583 | $values['owner'] = $line[4]; |
504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
584 | + if ($line[6] == '') { |
|
585 | + $values['date_first_reg'] = null; |
|
586 | + } else { |
|
587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
588 | + } |
|
506 | 589 | $values['cancel'] = $line[7]; |
507 | 590 | } elseif ($country == 'E7') { |
508 | 591 | $values['registration'] = $line[0]; |
509 | 592 | $values['base'] = null; |
510 | 593 | $values['owner'] = $line[4]; |
511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
594 | + if ($line[5] == '') { |
|
595 | + $values['date_first_reg'] = null; |
|
596 | + } else { |
|
597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
598 | + } |
|
513 | 599 | $values['cancel'] = ''; |
514 | 600 | } elseif ($country == '8Q') { |
515 | 601 | $values['registration'] = $line[0]; |
516 | 602 | $values['base'] = null; |
517 | 603 | $values['owner'] = $line[3]; |
518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
604 | + if ($line[7] == '') { |
|
605 | + $values['date_first_reg'] = null; |
|
606 | + } else { |
|
607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
608 | + } |
|
520 | 609 | $values['cancel'] = ''; |
521 | 610 | } elseif ($country == 'ZK') { |
522 | 611 | $values['registration'] = $line[0]; |
@@ -561,7 +650,9 @@ discard block |
||
561 | 650 | $sth_modes->execute($query_modes_values); |
562 | 651 | } |
563 | 652 | } |
564 | - if ($globalTransaction) $Connection->db->commit(); |
|
653 | + if ($globalTransaction) { |
|
654 | + $Connection->db->commit(); |
|
655 | + } |
|
565 | 656 | } catch(PDOException $e) { |
566 | 657 | return "error : ".$e->getMessage(); |
567 | 658 | } |
@@ -697,25 +788,45 @@ discard block |
||
697 | 788 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
698 | 789 | $Connection = new Connection(); |
699 | 790 | $sth_dest = $Connection->db->prepare($query_dest); |
700 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
791 | + if ($globalTransaction) { |
|
792 | + $Connection->db->beginTransaction(); |
|
793 | + } |
|
701 | 794 | |
702 | 795 | $i = 0; |
703 | 796 | while($row = sparql_fetch_array($result)) |
704 | 797 | { |
705 | 798 | if ($i >= 1) { |
706 | 799 | //print_r($row); |
707 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
708 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
709 | - if (!isset($row['type'])) $row['type'] = ''; |
|
710 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
800 | + if (!isset($row['iata'])) { |
|
801 | + $row['iata'] = ''; |
|
802 | + } |
|
803 | + if (!isset($row['icao'])) { |
|
804 | + $row['icao'] = ''; |
|
805 | + } |
|
806 | + if (!isset($row['type'])) { |
|
807 | + $row['type'] = ''; |
|
808 | + } |
|
809 | + if (!isset($row['altitude'])) { |
|
810 | + $row['altitude'] = ''; |
|
811 | + } |
|
711 | 812 | if (isset($row['city_bis'])) { |
712 | 813 | $row['city'] = $row['city_bis']; |
713 | 814 | } |
714 | - if (!isset($row['city'])) $row['city'] = ''; |
|
715 | - if (!isset($row['country'])) $row['country'] = ''; |
|
716 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
717 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
718 | - if (!isset($row['name'])) continue; |
|
815 | + if (!isset($row['city'])) { |
|
816 | + $row['city'] = ''; |
|
817 | + } |
|
818 | + if (!isset($row['country'])) { |
|
819 | + $row['country'] = ''; |
|
820 | + } |
|
821 | + if (!isset($row['homepage'])) { |
|
822 | + $row['homepage'] = ''; |
|
823 | + } |
|
824 | + if (!isset($row['wikipedia_page'])) { |
|
825 | + $row['wikipedia_page'] = ''; |
|
826 | + } |
|
827 | + if (!isset($row['name'])) { |
|
828 | + continue; |
|
829 | + } |
|
719 | 830 | if (!isset($row['image'])) { |
720 | 831 | $row['image'] = ''; |
721 | 832 | $row['image_thumb'] = ''; |
@@ -771,7 +882,9 @@ discard block |
||
771 | 882 | |
772 | 883 | $i++; |
773 | 884 | } |
774 | - if ($globalTransaction) $Connection->db->commit(); |
|
885 | + if ($globalTransaction) { |
|
886 | + $Connection->db->commit(); |
|
887 | + } |
|
775 | 888 | /* |
776 | 889 | echo "Delete duplicate rows...\n"; |
777 | 890 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -814,7 +927,9 @@ discard block |
||
814 | 927 | $delimiter = ','; |
815 | 928 | $out_file = $tmp_dir.'airports.csv'; |
816 | 929 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
817 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
930 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
931 | + return FALSE; |
|
932 | + } |
|
818 | 933 | echo "Add data from ourairports.com...\n"; |
819 | 934 | |
820 | 935 | $header = NULL; |
@@ -824,8 +939,9 @@ discard block |
||
824 | 939 | //$Connection->db->beginTransaction(); |
825 | 940 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
826 | 941 | { |
827 | - if(!$header) $header = $row; |
|
828 | - else { |
|
942 | + if(!$header) { |
|
943 | + $header = $row; |
|
944 | + } else { |
|
829 | 945 | $data = array(); |
830 | 946 | $data = array_combine($header, $row); |
831 | 947 | try { |
@@ -866,7 +982,9 @@ discard block |
||
866 | 982 | echo "Download data from another free database...\n"; |
867 | 983 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
868 | 984 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
869 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
985 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
986 | + return FALSE; |
|
987 | + } |
|
870 | 988 | update_db::unzip($out_file); |
871 | 989 | $header = NULL; |
872 | 990 | echo "Add data from another free database...\n"; |
@@ -877,8 +995,9 @@ discard block |
||
877 | 995 | //$Connection->db->beginTransaction(); |
878 | 996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
879 | 997 | { |
880 | - if(!$header) $header = $row; |
|
881 | - else { |
|
998 | + if(!$header) { |
|
999 | + $header = $row; |
|
1000 | + } else { |
|
882 | 1001 | $data = $row; |
883 | 1002 | |
884 | 1003 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1047,7 +1166,9 @@ discard block |
||
1047 | 1166 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1048 | 1167 | { |
1049 | 1168 | $i = 0; |
1050 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1169 | + if ($globalTransaction) { |
|
1170 | + $Connection->db->beginTransaction(); |
|
1171 | + } |
|
1051 | 1172 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1052 | 1173 | { |
1053 | 1174 | if ($i > 0) { |
@@ -1060,7 +1181,9 @@ discard block |
||
1060 | 1181 | } |
1061 | 1182 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1062 | 1183 | if (!empty($result_search)) { |
1063 | - if ($globalDebug) echo '.'; |
|
1184 | + if ($globalDebug) { |
|
1185 | + echo '.'; |
|
1186 | + } |
|
1064 | 1187 | //if ($globalDBdriver == 'mysql') { |
1065 | 1188 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1066 | 1189 | //} else { |
@@ -1082,8 +1205,12 @@ discard block |
||
1082 | 1205 | } |
1083 | 1206 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1084 | 1207 | if (!empty($result_search_mfr)) { |
1085 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1086 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1208 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1209 | + $data[16] = $data[23]; |
|
1210 | + } |
|
1211 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1212 | + $data[16] = $data[15]; |
|
1213 | + } |
|
1087 | 1214 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1088 | 1215 | try { |
1089 | 1216 | $sthf = $Connection->db->prepare($queryf); |
@@ -1094,7 +1221,9 @@ discard block |
||
1094 | 1221 | } |
1095 | 1222 | } |
1096 | 1223 | if (strtotime($data[29]) > time()) { |
1097 | - if ($globalDebug) echo 'i'; |
|
1224 | + if ($globalDebug) { |
|
1225 | + echo 'i'; |
|
1226 | + } |
|
1098 | 1227 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1099 | 1228 | try { |
1100 | 1229 | $sth = $Connection->db->prepare($query); |
@@ -1105,13 +1234,19 @@ discard block |
||
1105 | 1234 | } |
1106 | 1235 | } |
1107 | 1236 | if ($i % 90 == 0) { |
1108 | - if ($globalTransaction) $Connection->db->commit(); |
|
1109 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1237 | + if ($globalTransaction) { |
|
1238 | + $Connection->db->commit(); |
|
1239 | + } |
|
1240 | + if ($globalTransaction) { |
|
1241 | + $Connection->db->beginTransaction(); |
|
1242 | + } |
|
1110 | 1243 | } |
1111 | 1244 | $i++; |
1112 | 1245 | } |
1113 | 1246 | fclose($handle); |
1114 | - if ($globalTransaction) $Connection->db->commit(); |
|
1247 | + if ($globalTransaction) { |
|
1248 | + $Connection->db->commit(); |
|
1249 | + } |
|
1115 | 1250 | } |
1116 | 1251 | return ''; |
1117 | 1252 | } |
@@ -1131,11 +1266,15 @@ discard block |
||
1131 | 1266 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
1132 | 1267 | { |
1133 | 1268 | $i = 0; |
1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1269 | + if ($globalTransaction) { |
|
1270 | + $Connection->db->beginTransaction(); |
|
1271 | + } |
|
1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1136 | 1273 | { |
1137 | 1274 | if ($i > 0) { |
1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1275 | + if ($data[1] == 'NULL') { |
|
1276 | + $data[1] = $data[0]; |
|
1277 | + } |
|
1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1279 | try { |
1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
1147 | 1286 | $i++; |
1148 | 1287 | } |
1149 | 1288 | fclose($handle); |
1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->commit(); |
|
1291 | + } |
|
1151 | 1292 | } |
1152 | 1293 | return ''; |
1153 | 1294 | } |
@@ -1179,11 +1320,15 @@ discard block |
||
1179 | 1320 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
1180 | 1321 | { |
1181 | 1322 | $i = 0; |
1182 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1323 | + if ($globalTransaction) { |
|
1324 | + $Connection->db->beginTransaction(); |
|
1325 | + } |
|
1183 | 1326 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1184 | 1327 | { |
1185 | 1328 | if ($i > 0) { |
1186 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1329 | + if ($data[1] == 'NULL') { |
|
1330 | + $data[1] = $data[0]; |
|
1331 | + } |
|
1187 | 1332 | $query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
1188 | 1333 | try { |
1189 | 1334 | $sth = $Connection->db->prepare($query); |
@@ -1195,7 +1340,9 @@ discard block |
||
1195 | 1340 | $i++; |
1196 | 1341 | } |
1197 | 1342 | fclose($handle); |
1198 | - if ($globalTransaction) $Connection->db->commit(); |
|
1343 | + if ($globalTransaction) { |
|
1344 | + $Connection->db->commit(); |
|
1345 | + } |
|
1199 | 1346 | } |
1200 | 1347 | /* |
1201 | 1348 | $query = "UNLOCK TABLES"; |
@@ -1225,7 +1372,9 @@ discard block |
||
1225 | 1372 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1226 | 1373 | { |
1227 | 1374 | $i = 0; |
1228 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1375 | + if ($globalTransaction) { |
|
1376 | + $Connection->db->beginTransaction(); |
|
1377 | + } |
|
1229 | 1378 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1230 | 1379 | { |
1231 | 1380 | if ($i > 0) { |
@@ -1241,7 +1390,9 @@ discard block |
||
1241 | 1390 | $i++; |
1242 | 1391 | } |
1243 | 1392 | fclose($handle); |
1244 | - if ($globalTransaction) $Connection->db->commit(); |
|
1393 | + if ($globalTransaction) { |
|
1394 | + $Connection->db->commit(); |
|
1395 | + } |
|
1245 | 1396 | } |
1246 | 1397 | return ''; |
1247 | 1398 | } |
@@ -1261,7 +1412,9 @@ discard block |
||
1261 | 1412 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
1262 | 1413 | { |
1263 | 1414 | $i = 0; |
1264 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1415 | + if ($globalTransaction) { |
|
1416 | + $Connection->db->beginTransaction(); |
|
1417 | + } |
|
1265 | 1418 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1266 | 1419 | { |
1267 | 1420 | if ($i > 0) { |
@@ -1270,13 +1423,17 @@ discard block |
||
1270 | 1423 | $sth = $Connection->db->prepare($query); |
1271 | 1424 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
1272 | 1425 | } catch(PDOException $e) { |
1273 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1426 | + if ($globalDebug) { |
|
1427 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1428 | + } |
|
1274 | 1429 | } |
1275 | 1430 | } |
1276 | 1431 | $i++; |
1277 | 1432 | } |
1278 | 1433 | fclose($handle); |
1279 | - if ($globalTransaction) $Connection->db->commit(); |
|
1434 | + if ($globalTransaction) { |
|
1435 | + $Connection->db->commit(); |
|
1436 | + } |
|
1280 | 1437 | } |
1281 | 1438 | return ''; |
1282 | 1439 | } |
@@ -1301,7 +1458,9 @@ discard block |
||
1301 | 1458 | $i = 0; |
1302 | 1459 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1303 | 1460 | //$Connection->db->beginTransaction(); |
1304 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1461 | + if ($globalTransaction) { |
|
1462 | + $Connection->db->beginTransaction(); |
|
1463 | + } |
|
1305 | 1464 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1306 | 1465 | { |
1307 | 1466 | if ($i > 0) { |
@@ -1317,7 +1476,9 @@ discard block |
||
1317 | 1476 | $i++; |
1318 | 1477 | } |
1319 | 1478 | fclose($handle); |
1320 | - if ($globalTransaction) $Connection->db->commit(); |
|
1479 | + if ($globalTransaction) { |
|
1480 | + $Connection->db->commit(); |
|
1481 | + } |
|
1321 | 1482 | } |
1322 | 1483 | return ''; |
1323 | 1484 | } |
@@ -1337,7 +1498,9 @@ discard block |
||
1337 | 1498 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
1338 | 1499 | { |
1339 | 1500 | $i = 0; |
1340 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1501 | + if ($globalTransaction) { |
|
1502 | + $Connection->db->beginTransaction(); |
|
1503 | + } |
|
1341 | 1504 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1342 | 1505 | { |
1343 | 1506 | if ($i > 0) { |
@@ -1354,7 +1517,9 @@ discard block |
||
1354 | 1517 | $i++; |
1355 | 1518 | } |
1356 | 1519 | fclose($handle); |
1357 | - if ($globalTransaction) $Connection->db->commit(); |
|
1520 | + if ($globalTransaction) { |
|
1521 | + $Connection->db->commit(); |
|
1522 | + } |
|
1358 | 1523 | } |
1359 | 1524 | return ''; |
1360 | 1525 | } |
@@ -1373,7 +1538,9 @@ discard block |
||
1373 | 1538 | $Connection = new Connection(); |
1374 | 1539 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1375 | 1540 | { |
1376 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1541 | + if ($globalTransaction) { |
|
1542 | + $Connection->db->beginTransaction(); |
|
1543 | + } |
|
1377 | 1544 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1378 | 1545 | { |
1379 | 1546 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1388,7 +1555,9 @@ discard block |
||
1388 | 1555 | } |
1389 | 1556 | } |
1390 | 1557 | fclose($handle); |
1391 | - if ($globalTransaction) $Connection->db->commit(); |
|
1558 | + if ($globalTransaction) { |
|
1559 | + $Connection->db->commit(); |
|
1560 | + } |
|
1392 | 1561 | } |
1393 | 1562 | return ''; |
1394 | 1563 | } |
@@ -1464,9 +1633,14 @@ discard block |
||
1464 | 1633 | if ($i > 0 && $data[0] != '') { |
1465 | 1634 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1466 | 1635 | $period = str_replace(',','',$data[14]); |
1467 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1468 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1469 | - else $launch_date = NULL; |
|
1636 | + if (!empty($period) && strpos($period,'days')) { |
|
1637 | + $period = str_replace(' days','',$period)*24*60; |
|
1638 | + } |
|
1639 | + if ($data[18] != '') { |
|
1640 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1641 | + } else { |
|
1642 | + $launch_date = NULL; |
|
1643 | + } |
|
1470 | 1644 | $data = array_map(function($value) { |
1471 | 1645 | return trim($value) === '' ? null : $value; |
1472 | 1646 | }, $data); |
@@ -1829,7 +2003,9 @@ discard block |
||
1829 | 2003 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1830 | 2004 | { |
1831 | 2005 | $i = 0; |
1832 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2006 | + if ($globalTransaction) { |
|
2007 | + $Connection->db->beginTransaction(); |
|
2008 | + } |
|
1833 | 2009 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1834 | 2010 | { |
1835 | 2011 | $i++; |
@@ -1857,7 +2033,9 @@ discard block |
||
1857 | 2033 | } |
1858 | 2034 | } |
1859 | 2035 | fclose($handle); |
1860 | - if ($globalTransaction) $Connection->db->commit(); |
|
2036 | + if ($globalTransaction) { |
|
2037 | + $Connection->db->commit(); |
|
2038 | + } |
|
1861 | 2039 | } |
1862 | 2040 | return ''; |
1863 | 2041 | } |
@@ -1900,7 +2078,9 @@ discard block |
||
1900 | 2078 | $Connection = new Connection(); |
1901 | 2079 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1902 | 2080 | { |
1903 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2081 | + if ($globalTransaction) { |
|
2082 | + $Connection->db->beginTransaction(); |
|
2083 | + } |
|
1904 | 2084 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1905 | 2085 | { |
1906 | 2086 | if(count($row) > 1) { |
@@ -1914,7 +2094,9 @@ discard block |
||
1914 | 2094 | } |
1915 | 2095 | } |
1916 | 2096 | fclose($handle); |
1917 | - if ($globalTransaction) $Connection->db->commit(); |
|
2097 | + if ($globalTransaction) { |
|
2098 | + $Connection->db->commit(); |
|
2099 | + } |
|
1918 | 2100 | } |
1919 | 2101 | return ''; |
1920 | 2102 | } |
@@ -1934,8 +2116,9 @@ discard block |
||
1934 | 2116 | } |
1935 | 2117 | |
1936 | 2118 | |
1937 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1938 | - else { |
|
2119 | + if ($globalDBdriver == 'mysql') { |
|
2120 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2121 | + } else { |
|
1939 | 2122 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1940 | 2123 | $query = "CREATE EXTENSION postgis"; |
1941 | 2124 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1954,7 +2137,9 @@ discard block |
||
1954 | 2137 | global $tmp_dir, $globalDebug; |
1955 | 2138 | include_once('class.create_db.php'); |
1956 | 2139 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1957 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
2140 | + if ($globalDebug) { |
|
2141 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
2142 | + } |
|
1958 | 2143 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
1959 | 2144 | $error = ''; |
1960 | 2145 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -1964,20 +2149,34 @@ discard block |
||
1964 | 2149 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1965 | 2150 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1966 | 2151 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
1967 | - if ($globalDebug) echo "Gunzip..."; |
|
2152 | + if ($globalDebug) { |
|
2153 | + echo "Gunzip..."; |
|
2154 | + } |
|
1968 | 2155 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1969 | - if ($globalDebug) echo "Add to DB..."; |
|
2156 | + if ($globalDebug) { |
|
2157 | + echo "Add to DB..."; |
|
2158 | + } |
|
1970 | 2159 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1971 | 2160 | $NOTAM = new NOTAM(); |
1972 | 2161 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1973 | 2162 | update_db::insert_notam_version($notam_md5); |
1974 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
1975 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1976 | - } elseif ($globalDebug) echo "No new version."; |
|
1977 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2163 | + } else { |
|
2164 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2165 | + } |
|
2166 | + } else { |
|
2167 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2168 | + } |
|
2169 | + } elseif ($globalDebug) { |
|
2170 | + echo "No new version."; |
|
2171 | + } |
|
2172 | + } else { |
|
2173 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2174 | + } |
|
1978 | 2175 | if ($error != '') { |
1979 | 2176 | return $error; |
1980 | - } elseif ($globalDebug) echo "Done\n"; |
|
2177 | + } elseif ($globalDebug) { |
|
2178 | + echo "Done\n"; |
|
2179 | + } |
|
1981 | 2180 | return ''; |
1982 | 2181 | } |
1983 | 2182 | |
@@ -2032,68 +2231,114 @@ discard block |
||
2032 | 2231 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
2033 | 2232 | if (extension_loaded('zip')) { |
2034 | 2233 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
2035 | - if ($globalDebug) echo "Unzip..."; |
|
2234 | + if ($globalDebug) { |
|
2235 | + echo "Unzip..."; |
|
2236 | + } |
|
2036 | 2237 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
2037 | - if ($globalDebug) echo "Add to DB..."; |
|
2238 | + if ($globalDebug) { |
|
2239 | + echo "Add to DB..."; |
|
2240 | + } |
|
2038 | 2241 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2039 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
2242 | + if ($globalDebug) { |
|
2243 | + echo "Copy airlines logos to airlines images directory..."; |
|
2244 | + } |
|
2040 | 2245 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2041 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2042 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2043 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2044 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
2246 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
2247 | + $error = "Failed to copy airlines logo."; |
|
2248 | + } |
|
2249 | + } else { |
|
2250 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2251 | + } |
|
2252 | + } else { |
|
2253 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2254 | + } |
|
2255 | + } else { |
|
2256 | + $error = "ZIP module not loaded but required for IVAO."; |
|
2257 | + } |
|
2045 | 2258 | if ($error != '') { |
2046 | 2259 | return $error; |
2047 | - } elseif ($globalDebug) echo "Done\n"; |
|
2260 | + } elseif ($globalDebug) { |
|
2261 | + echo "Done\n"; |
|
2262 | + } |
|
2048 | 2263 | return ''; |
2049 | 2264 | } |
2050 | 2265 | |
2051 | 2266 | public static function update_routes() { |
2052 | 2267 | global $tmp_dir, $globalDebug; |
2053 | 2268 | $error = ''; |
2054 | - if ($globalDebug) echo "Routes : Download..."; |
|
2269 | + if ($globalDebug) { |
|
2270 | + echo "Routes : Download..."; |
|
2271 | + } |
|
2055 | 2272 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
2056 | 2273 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2057 | - if ($globalDebug) echo "Gunzip..."; |
|
2274 | + if ($globalDebug) { |
|
2275 | + echo "Gunzip..."; |
|
2276 | + } |
|
2058 | 2277 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
2059 | - if ($globalDebug) echo "Add to DB..."; |
|
2278 | + if ($globalDebug) { |
|
2279 | + echo "Add to DB..."; |
|
2280 | + } |
|
2060 | 2281 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
2061 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2282 | + } else { |
|
2283 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2284 | + } |
|
2062 | 2285 | if ($error != '') { |
2063 | 2286 | return $error; |
2064 | - } elseif ($globalDebug) echo "Done\n"; |
|
2287 | + } elseif ($globalDebug) { |
|
2288 | + echo "Done\n"; |
|
2289 | + } |
|
2065 | 2290 | return ''; |
2066 | 2291 | } |
2067 | 2292 | public static function update_oneworld() { |
2068 | 2293 | global $tmp_dir, $globalDebug; |
2069 | 2294 | $error = ''; |
2070 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
2295 | + if ($globalDebug) { |
|
2296 | + echo "Schedules Oneworld : Download..."; |
|
2297 | + } |
|
2071 | 2298 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
2072 | 2299 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2073 | - if ($globalDebug) echo "Gunzip..."; |
|
2300 | + if ($globalDebug) { |
|
2301 | + echo "Gunzip..."; |
|
2302 | + } |
|
2074 | 2303 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
2075 | - if ($globalDebug) echo "Add to DB..."; |
|
2304 | + if ($globalDebug) { |
|
2305 | + echo "Add to DB..."; |
|
2306 | + } |
|
2076 | 2307 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
2077 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2308 | + } else { |
|
2309 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2310 | + } |
|
2078 | 2311 | if ($error != '') { |
2079 | 2312 | return $error; |
2080 | - } elseif ($globalDebug) echo "Done\n"; |
|
2313 | + } elseif ($globalDebug) { |
|
2314 | + echo "Done\n"; |
|
2315 | + } |
|
2081 | 2316 | return ''; |
2082 | 2317 | } |
2083 | 2318 | public static function update_skyteam() { |
2084 | 2319 | global $tmp_dir, $globalDebug; |
2085 | 2320 | $error = ''; |
2086 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
2321 | + if ($globalDebug) { |
|
2322 | + echo "Schedules Skyteam : Download..."; |
|
2323 | + } |
|
2087 | 2324 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
2088 | 2325 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2089 | - if ($globalDebug) echo "Gunzip..."; |
|
2326 | + if ($globalDebug) { |
|
2327 | + echo "Gunzip..."; |
|
2328 | + } |
|
2090 | 2329 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
2091 | - if ($globalDebug) echo "Add to DB..."; |
|
2330 | + if ($globalDebug) { |
|
2331 | + echo "Add to DB..."; |
|
2332 | + } |
|
2092 | 2333 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
2093 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2334 | + } else { |
|
2335 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2336 | + } |
|
2094 | 2337 | if ($error != '') { |
2095 | 2338 | return $error; |
2096 | - } elseif ($globalDebug) echo "Done\n"; |
|
2339 | + } elseif ($globalDebug) { |
|
2340 | + echo "Done\n"; |
|
2341 | + } |
|
2097 | 2342 | return ''; |
2098 | 2343 | } |
2099 | 2344 | public static function update_ModeS() { |
@@ -2110,340 +2355,590 @@ discard block |
||
2110 | 2355 | exit; |
2111 | 2356 | } elseif ($globalDebug) echo "Done\n"; |
2112 | 2357 | */ |
2113 | - if ($globalDebug) echo "Modes : Download..."; |
|
2114 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2358 | + if ($globalDebug) { |
|
2359 | + echo "Modes : Download..."; |
|
2360 | + } |
|
2361 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2115 | 2362 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
2116 | 2363 | |
2117 | 2364 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2118 | 2365 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
2119 | - if ($globalDebug) echo "Unzip..."; |
|
2120 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2366 | + if ($globalDebug) { |
|
2367 | + echo "Unzip..."; |
|
2368 | + } |
|
2369 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2121 | 2370 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
2122 | - if ($globalDebug) echo "Add to DB..."; |
|
2371 | + if ($globalDebug) { |
|
2372 | + echo "Add to DB..."; |
|
2373 | + } |
|
2123 | 2374 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
2124 | 2375 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
2125 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2376 | + } else { |
|
2377 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2378 | + } |
|
2126 | 2379 | if ($error != '') { |
2127 | 2380 | return $error; |
2128 | - } elseif ($globalDebug) echo "Done\n"; |
|
2381 | + } elseif ($globalDebug) { |
|
2382 | + echo "Done\n"; |
|
2383 | + } |
|
2129 | 2384 | return ''; |
2130 | 2385 | } |
2131 | 2386 | |
2132 | 2387 | public static function update_ModeS_faa() { |
2133 | 2388 | global $tmp_dir, $globalDebug; |
2134 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
2389 | + if ($globalDebug) { |
|
2390 | + echo "Modes FAA: Download..."; |
|
2391 | + } |
|
2135 | 2392 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
2136 | 2393 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2137 | - if ($globalDebug) echo "Unzip..."; |
|
2394 | + if ($globalDebug) { |
|
2395 | + echo "Unzip..."; |
|
2396 | + } |
|
2138 | 2397 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
2139 | - if ($globalDebug) echo "Add to DB..."; |
|
2398 | + if ($globalDebug) { |
|
2399 | + echo "Add to DB..."; |
|
2400 | + } |
|
2140 | 2401 | $error = update_db::modes_faa(); |
2141 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2402 | + } else { |
|
2403 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2404 | + } |
|
2142 | 2405 | if ($error != '') { |
2143 | 2406 | return $error; |
2144 | - } elseif ($globalDebug) echo "Done\n"; |
|
2407 | + } elseif ($globalDebug) { |
|
2408 | + echo "Done\n"; |
|
2409 | + } |
|
2145 | 2410 | return ''; |
2146 | 2411 | } |
2147 | 2412 | |
2148 | 2413 | public static function update_ModeS_flarm() { |
2149 | 2414 | global $tmp_dir, $globalDebug; |
2150 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
2415 | + if ($globalDebug) { |
|
2416 | + echo "Modes Flarmnet: Download..."; |
|
2417 | + } |
|
2151 | 2418 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
2152 | 2419 | if (file_exists($tmp_dir.'data.fln')) { |
2153 | - if ($globalDebug) echo "Add to DB..."; |
|
2420 | + if ($globalDebug) { |
|
2421 | + echo "Add to DB..."; |
|
2422 | + } |
|
2154 | 2423 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
2155 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2424 | + } else { |
|
2425 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2426 | + } |
|
2156 | 2427 | if ($error != '') { |
2157 | 2428 | return $error; |
2158 | - } elseif ($globalDebug) echo "Done\n"; |
|
2429 | + } elseif ($globalDebug) { |
|
2430 | + echo "Done\n"; |
|
2431 | + } |
|
2159 | 2432 | return ''; |
2160 | 2433 | } |
2161 | 2434 | |
2162 | 2435 | public static function update_ModeS_ogn() { |
2163 | 2436 | global $tmp_dir, $globalDebug; |
2164 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2437 | + if ($globalDebug) { |
|
2438 | + echo "Modes OGN: Download..."; |
|
2439 | + } |
|
2165 | 2440 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
2166 | 2441 | if (file_exists($tmp_dir.'ogn.csv')) { |
2167 | - if ($globalDebug) echo "Add to DB..."; |
|
2442 | + if ($globalDebug) { |
|
2443 | + echo "Add to DB..."; |
|
2444 | + } |
|
2168 | 2445 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
2169 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2446 | + } else { |
|
2447 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2448 | + } |
|
2170 | 2449 | if ($error != '') { |
2171 | 2450 | return $error; |
2172 | - } elseif ($globalDebug) echo "Done\n"; |
|
2451 | + } elseif ($globalDebug) { |
|
2452 | + echo "Done\n"; |
|
2453 | + } |
|
2173 | 2454 | return ''; |
2174 | 2455 | } |
2175 | 2456 | |
2176 | 2457 | public static function update_owner() { |
2177 | 2458 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2178 | 2459 | |
2179 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2460 | + if ($globalDebug) { |
|
2461 | + echo "Owner France: Download..."; |
|
2462 | + } |
|
2180 | 2463 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
2181 | 2464 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2182 | - if ($globalDebug) echo "Add to DB..."; |
|
2465 | + if ($globalDebug) { |
|
2466 | + echo "Add to DB..."; |
|
2467 | + } |
|
2183 | 2468 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
2184 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2469 | + } else { |
|
2470 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2471 | + } |
|
2185 | 2472 | if ($error != '') { |
2186 | 2473 | return $error; |
2187 | - } elseif ($globalDebug) echo "Done\n"; |
|
2474 | + } elseif ($globalDebug) { |
|
2475 | + echo "Done\n"; |
|
2476 | + } |
|
2188 | 2477 | |
2189 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2478 | + if ($globalDebug) { |
|
2479 | + echo "Owner Ireland: Download..."; |
|
2480 | + } |
|
2190 | 2481 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
2191 | 2482 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2192 | - if ($globalDebug) echo "Add to DB..."; |
|
2483 | + if ($globalDebug) { |
|
2484 | + echo "Add to DB..."; |
|
2485 | + } |
|
2193 | 2486 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
2194 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2487 | + } else { |
|
2488 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2489 | + } |
|
2195 | 2490 | if ($error != '') { |
2196 | 2491 | return $error; |
2197 | - } elseif ($globalDebug) echo "Done\n"; |
|
2198 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2492 | + } elseif ($globalDebug) { |
|
2493 | + echo "Done\n"; |
|
2494 | + } |
|
2495 | + if ($globalDebug) { |
|
2496 | + echo "Owner Switzerland: Download..."; |
|
2497 | + } |
|
2199 | 2498 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
2200 | 2499 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2201 | - if ($globalDebug) echo "Add to DB..."; |
|
2500 | + if ($globalDebug) { |
|
2501 | + echo "Add to DB..."; |
|
2502 | + } |
|
2202 | 2503 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
2203 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2504 | + } else { |
|
2505 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2506 | + } |
|
2204 | 2507 | if ($error != '') { |
2205 | 2508 | return $error; |
2206 | - } elseif ($globalDebug) echo "Done\n"; |
|
2207 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2509 | + } elseif ($globalDebug) { |
|
2510 | + echo "Done\n"; |
|
2511 | + } |
|
2512 | + if ($globalDebug) { |
|
2513 | + echo "Owner Czech Republic: Download..."; |
|
2514 | + } |
|
2208 | 2515 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
2209 | 2516 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2210 | - if ($globalDebug) echo "Add to DB..."; |
|
2517 | + if ($globalDebug) { |
|
2518 | + echo "Add to DB..."; |
|
2519 | + } |
|
2211 | 2520 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
2212 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2521 | + } else { |
|
2522 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2523 | + } |
|
2213 | 2524 | if ($error != '') { |
2214 | 2525 | return $error; |
2215 | - } elseif ($globalDebug) echo "Done\n"; |
|
2216 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2526 | + } elseif ($globalDebug) { |
|
2527 | + echo "Done\n"; |
|
2528 | + } |
|
2529 | + if ($globalDebug) { |
|
2530 | + echo "Owner Australia: Download..."; |
|
2531 | + } |
|
2217 | 2532 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
2218 | 2533 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2219 | - if ($globalDebug) echo "Add to DB..."; |
|
2534 | + if ($globalDebug) { |
|
2535 | + echo "Add to DB..."; |
|
2536 | + } |
|
2220 | 2537 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
2221 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2538 | + } else { |
|
2539 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2540 | + } |
|
2222 | 2541 | if ($error != '') { |
2223 | 2542 | return $error; |
2224 | - } elseif ($globalDebug) echo "Done\n"; |
|
2225 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2543 | + } elseif ($globalDebug) { |
|
2544 | + echo "Done\n"; |
|
2545 | + } |
|
2546 | + if ($globalDebug) { |
|
2547 | + echo "Owner Austria: Download..."; |
|
2548 | + } |
|
2226 | 2549 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
2227 | 2550 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2228 | - if ($globalDebug) echo "Add to DB..."; |
|
2551 | + if ($globalDebug) { |
|
2552 | + echo "Add to DB..."; |
|
2553 | + } |
|
2229 | 2554 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
2230 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2555 | + } else { |
|
2556 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2557 | + } |
|
2231 | 2558 | if ($error != '') { |
2232 | 2559 | return $error; |
2233 | - } elseif ($globalDebug) echo "Done\n"; |
|
2234 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2560 | + } elseif ($globalDebug) { |
|
2561 | + echo "Done\n"; |
|
2562 | + } |
|
2563 | + if ($globalDebug) { |
|
2564 | + echo "Owner Chile: Download..."; |
|
2565 | + } |
|
2235 | 2566 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
2236 | 2567 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2237 | - if ($globalDebug) echo "Add to DB..."; |
|
2568 | + if ($globalDebug) { |
|
2569 | + echo "Add to DB..."; |
|
2570 | + } |
|
2238 | 2571 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
2239 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2572 | + } else { |
|
2573 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2574 | + } |
|
2240 | 2575 | if ($error != '') { |
2241 | 2576 | return $error; |
2242 | - } elseif ($globalDebug) echo "Done\n"; |
|
2243 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2577 | + } elseif ($globalDebug) { |
|
2578 | + echo "Done\n"; |
|
2579 | + } |
|
2580 | + if ($globalDebug) { |
|
2581 | + echo "Owner Colombia: Download..."; |
|
2582 | + } |
|
2244 | 2583 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
2245 | 2584 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2246 | - if ($globalDebug) echo "Add to DB..."; |
|
2585 | + if ($globalDebug) { |
|
2586 | + echo "Add to DB..."; |
|
2587 | + } |
|
2247 | 2588 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
2248 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2589 | + } else { |
|
2590 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2591 | + } |
|
2249 | 2592 | if ($error != '') { |
2250 | 2593 | return $error; |
2251 | - } elseif ($globalDebug) echo "Done\n"; |
|
2252 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2594 | + } elseif ($globalDebug) { |
|
2595 | + echo "Done\n"; |
|
2596 | + } |
|
2597 | + if ($globalDebug) { |
|
2598 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2599 | + } |
|
2253 | 2600 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
2254 | 2601 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2255 | - if ($globalDebug) echo "Add to DB..."; |
|
2602 | + if ($globalDebug) { |
|
2603 | + echo "Add to DB..."; |
|
2604 | + } |
|
2256 | 2605 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
2257 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2606 | + } else { |
|
2607 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2608 | + } |
|
2258 | 2609 | if ($error != '') { |
2259 | 2610 | return $error; |
2260 | - } elseif ($globalDebug) echo "Done\n"; |
|
2261 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2611 | + } elseif ($globalDebug) { |
|
2612 | + echo "Done\n"; |
|
2613 | + } |
|
2614 | + if ($globalDebug) { |
|
2615 | + echo "Owner Brazil: Download..."; |
|
2616 | + } |
|
2262 | 2617 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
2263 | 2618 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2264 | - if ($globalDebug) echo "Add to DB..."; |
|
2619 | + if ($globalDebug) { |
|
2620 | + echo "Add to DB..."; |
|
2621 | + } |
|
2265 | 2622 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
2266 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2623 | + } else { |
|
2624 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2625 | + } |
|
2267 | 2626 | if ($error != '') { |
2268 | 2627 | return $error; |
2269 | - } elseif ($globalDebug) echo "Done\n"; |
|
2270 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2628 | + } elseif ($globalDebug) { |
|
2629 | + echo "Done\n"; |
|
2630 | + } |
|
2631 | + if ($globalDebug) { |
|
2632 | + echo "Owner Cayman Islands: Download..."; |
|
2633 | + } |
|
2271 | 2634 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
2272 | 2635 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2273 | - if ($globalDebug) echo "Add to DB..."; |
|
2636 | + if ($globalDebug) { |
|
2637 | + echo "Add to DB..."; |
|
2638 | + } |
|
2274 | 2639 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
2275 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2640 | + } else { |
|
2641 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2642 | + } |
|
2276 | 2643 | if ($error != '') { |
2277 | 2644 | return $error; |
2278 | - } elseif ($globalDebug) echo "Done\n"; |
|
2279 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2645 | + } elseif ($globalDebug) { |
|
2646 | + echo "Done\n"; |
|
2647 | + } |
|
2648 | + if ($globalDebug) { |
|
2649 | + echo "Owner Croatia: Download..."; |
|
2650 | + } |
|
2280 | 2651 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
2281 | 2652 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2282 | - if ($globalDebug) echo "Add to DB..."; |
|
2653 | + if ($globalDebug) { |
|
2654 | + echo "Add to DB..."; |
|
2655 | + } |
|
2283 | 2656 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
2284 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2657 | + } else { |
|
2658 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2659 | + } |
|
2285 | 2660 | if ($error != '') { |
2286 | 2661 | return $error; |
2287 | - } elseif ($globalDebug) echo "Done\n"; |
|
2288 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2662 | + } elseif ($globalDebug) { |
|
2663 | + echo "Done\n"; |
|
2664 | + } |
|
2665 | + if ($globalDebug) { |
|
2666 | + echo "Owner Luxembourg: Download..."; |
|
2667 | + } |
|
2289 | 2668 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
2290 | 2669 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2291 | - if ($globalDebug) echo "Add to DB..."; |
|
2670 | + if ($globalDebug) { |
|
2671 | + echo "Add to DB..."; |
|
2672 | + } |
|
2292 | 2673 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
2293 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2674 | + } else { |
|
2675 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2676 | + } |
|
2294 | 2677 | if ($error != '') { |
2295 | 2678 | return $error; |
2296 | - } elseif ($globalDebug) echo "Done\n"; |
|
2297 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2679 | + } elseif ($globalDebug) { |
|
2680 | + echo "Done\n"; |
|
2681 | + } |
|
2682 | + if ($globalDebug) { |
|
2683 | + echo "Owner Maldives: Download..."; |
|
2684 | + } |
|
2298 | 2685 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
2299 | 2686 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2300 | - if ($globalDebug) echo "Add to DB..."; |
|
2687 | + if ($globalDebug) { |
|
2688 | + echo "Add to DB..."; |
|
2689 | + } |
|
2301 | 2690 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
2302 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2691 | + } else { |
|
2692 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2693 | + } |
|
2303 | 2694 | if ($error != '') { |
2304 | 2695 | return $error; |
2305 | - } elseif ($globalDebug) echo "Done\n"; |
|
2306 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2696 | + } elseif ($globalDebug) { |
|
2697 | + echo "Done\n"; |
|
2698 | + } |
|
2699 | + if ($globalDebug) { |
|
2700 | + echo "Owner New Zealand: Download..."; |
|
2701 | + } |
|
2307 | 2702 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
2308 | 2703 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2309 | - if ($globalDebug) echo "Add to DB..."; |
|
2704 | + if ($globalDebug) { |
|
2705 | + echo "Add to DB..."; |
|
2706 | + } |
|
2310 | 2707 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
2311 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2708 | + } else { |
|
2709 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2710 | + } |
|
2312 | 2711 | if ($error != '') { |
2313 | 2712 | return $error; |
2314 | - } elseif ($globalDebug) echo "Done\n"; |
|
2315 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2713 | + } elseif ($globalDebug) { |
|
2714 | + echo "Done\n"; |
|
2715 | + } |
|
2716 | + if ($globalDebug) { |
|
2717 | + echo "Owner Papua New Guinea: Download..."; |
|
2718 | + } |
|
2316 | 2719 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
2317 | 2720 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2318 | - if ($globalDebug) echo "Add to DB..."; |
|
2721 | + if ($globalDebug) { |
|
2722 | + echo "Add to DB..."; |
|
2723 | + } |
|
2319 | 2724 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
2320 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2725 | + } else { |
|
2726 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2727 | + } |
|
2321 | 2728 | if ($error != '') { |
2322 | 2729 | return $error; |
2323 | - } elseif ($globalDebug) echo "Done\n"; |
|
2324 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2730 | + } elseif ($globalDebug) { |
|
2731 | + echo "Done\n"; |
|
2732 | + } |
|
2733 | + if ($globalDebug) { |
|
2734 | + echo "Owner Slovakia: Download..."; |
|
2735 | + } |
|
2325 | 2736 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
2326 | 2737 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2327 | - if ($globalDebug) echo "Add to DB..."; |
|
2738 | + if ($globalDebug) { |
|
2739 | + echo "Add to DB..."; |
|
2740 | + } |
|
2328 | 2741 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
2329 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2742 | + } else { |
|
2743 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2744 | + } |
|
2330 | 2745 | if ($error != '') { |
2331 | 2746 | return $error; |
2332 | - } elseif ($globalDebug) echo "Done\n"; |
|
2333 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2747 | + } elseif ($globalDebug) { |
|
2748 | + echo "Done\n"; |
|
2749 | + } |
|
2750 | + if ($globalDebug) { |
|
2751 | + echo "Owner Ecuador: Download..."; |
|
2752 | + } |
|
2334 | 2753 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
2335 | 2754 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2336 | - if ($globalDebug) echo "Add to DB..."; |
|
2755 | + if ($globalDebug) { |
|
2756 | + echo "Add to DB..."; |
|
2757 | + } |
|
2337 | 2758 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
2338 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2759 | + } else { |
|
2760 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2761 | + } |
|
2339 | 2762 | if ($error != '') { |
2340 | 2763 | return $error; |
2341 | - } elseif ($globalDebug) echo "Done\n"; |
|
2342 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2764 | + } elseif ($globalDebug) { |
|
2765 | + echo "Done\n"; |
|
2766 | + } |
|
2767 | + if ($globalDebug) { |
|
2768 | + echo "Owner Iceland: Download..."; |
|
2769 | + } |
|
2343 | 2770 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
2344 | 2771 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2345 | - if ($globalDebug) echo "Add to DB..."; |
|
2772 | + if ($globalDebug) { |
|
2773 | + echo "Add to DB..."; |
|
2774 | + } |
|
2346 | 2775 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
2347 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2776 | + } else { |
|
2777 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2778 | + } |
|
2348 | 2779 | if ($error != '') { |
2349 | 2780 | return $error; |
2350 | - } elseif ($globalDebug) echo "Done\n"; |
|
2351 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2781 | + } elseif ($globalDebug) { |
|
2782 | + echo "Done\n"; |
|
2783 | + } |
|
2784 | + if ($globalDebug) { |
|
2785 | + echo "Owner Isle of Man: Download..."; |
|
2786 | + } |
|
2352 | 2787 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
2353 | 2788 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2354 | - if ($globalDebug) echo "Add to DB..."; |
|
2789 | + if ($globalDebug) { |
|
2790 | + echo "Add to DB..."; |
|
2791 | + } |
|
2355 | 2792 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
2356 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2793 | + } else { |
|
2794 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2795 | + } |
|
2357 | 2796 | if ($error != '') { |
2358 | 2797 | return $error; |
2359 | - } elseif ($globalDebug) echo "Done\n"; |
|
2798 | + } elseif ($globalDebug) { |
|
2799 | + echo "Done\n"; |
|
2800 | + } |
|
2360 | 2801 | if ($globalMasterSource) { |
2361 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2802 | + if ($globalDebug) { |
|
2803 | + echo "ModeS Netherlands: Download..."; |
|
2804 | + } |
|
2362 | 2805 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
2363 | 2806 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2364 | - if ($globalDebug) echo "Add to DB..."; |
|
2807 | + if ($globalDebug) { |
|
2808 | + echo "Add to DB..."; |
|
2809 | + } |
|
2365 | 2810 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
2366 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2811 | + } else { |
|
2812 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2813 | + } |
|
2367 | 2814 | if ($error != '') { |
2368 | 2815 | return $error; |
2369 | - } elseif ($globalDebug) echo "Done\n"; |
|
2370 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2816 | + } elseif ($globalDebug) { |
|
2817 | + echo "Done\n"; |
|
2818 | + } |
|
2819 | + if ($globalDebug) { |
|
2820 | + echo "ModeS Denmark: Download..."; |
|
2821 | + } |
|
2371 | 2822 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
2372 | 2823 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2373 | - if ($globalDebug) echo "Add to DB..."; |
|
2824 | + if ($globalDebug) { |
|
2825 | + echo "Add to DB..."; |
|
2826 | + } |
|
2374 | 2827 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
2375 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2828 | + } else { |
|
2829 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2830 | + } |
|
2376 | 2831 | if ($error != '') { |
2377 | 2832 | return $error; |
2378 | - } elseif ($globalDebug) echo "Done\n"; |
|
2379 | - } elseif ($globalDebug) echo "Done\n"; |
|
2833 | + } elseif ($globalDebug) { |
|
2834 | + echo "Done\n"; |
|
2835 | + } |
|
2836 | + } elseif ($globalDebug) { |
|
2837 | + echo "Done\n"; |
|
2838 | + } |
|
2380 | 2839 | return ''; |
2381 | 2840 | } |
2382 | 2841 | |
2383 | 2842 | public static function update_translation() { |
2384 | 2843 | global $tmp_dir, $globalDebug; |
2385 | 2844 | $error = ''; |
2386 | - if ($globalDebug) echo "Translation : Download..."; |
|
2845 | + if ($globalDebug) { |
|
2846 | + echo "Translation : Download..."; |
|
2847 | + } |
|
2387 | 2848 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
2388 | 2849 | if (file_exists($tmp_dir.'translation.zip')) { |
2389 | - if ($globalDebug) echo "Unzip..."; |
|
2850 | + if ($globalDebug) { |
|
2851 | + echo "Unzip..."; |
|
2852 | + } |
|
2390 | 2853 | update_db::unzip($tmp_dir.'translation.zip'); |
2391 | - if ($globalDebug) echo "Add to DB..."; |
|
2854 | + if ($globalDebug) { |
|
2855 | + echo "Add to DB..."; |
|
2856 | + } |
|
2392 | 2857 | $error = update_db::translation(); |
2393 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2858 | + } else { |
|
2859 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2860 | + } |
|
2394 | 2861 | if ($error != '') { |
2395 | 2862 | return $error; |
2396 | - } elseif ($globalDebug) echo "Done\n"; |
|
2863 | + } elseif ($globalDebug) { |
|
2864 | + echo "Done\n"; |
|
2865 | + } |
|
2397 | 2866 | return ''; |
2398 | 2867 | } |
2399 | 2868 | |
2400 | 2869 | public static function update_translation_fam() { |
2401 | 2870 | global $tmp_dir, $globalDebug; |
2402 | 2871 | $error = ''; |
2403 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2872 | + if ($globalDebug) { |
|
2873 | + echo "Translation from FlightAirMap website : Download..."; |
|
2874 | + } |
|
2404 | 2875 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
2405 | 2876 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
2406 | 2877 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2407 | 2878 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
2408 | 2879 | $translation_md5 = $translation_md5_file[0]; |
2409 | 2880 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2410 | - if ($globalDebug) echo "Gunzip..."; |
|
2881 | + if ($globalDebug) { |
|
2882 | + echo "Gunzip..."; |
|
2883 | + } |
|
2411 | 2884 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
2412 | - if ($globalDebug) echo "Add to DB..."; |
|
2885 | + if ($globalDebug) { |
|
2886 | + echo "Add to DB..."; |
|
2887 | + } |
|
2413 | 2888 | $error = update_db::translation_fam(); |
2414 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2415 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2889 | + } else { |
|
2890 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2891 | + } |
|
2892 | + } else { |
|
2893 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2894 | + } |
|
2416 | 2895 | if ($error != '') { |
2417 | 2896 | return $error; |
2418 | - } elseif ($globalDebug) echo "Done\n"; |
|
2897 | + } elseif ($globalDebug) { |
|
2898 | + echo "Done\n"; |
|
2899 | + } |
|
2419 | 2900 | return ''; |
2420 | 2901 | } |
2421 | 2902 | public static function update_ModeS_fam() { |
2422 | 2903 | global $tmp_dir, $globalDebug; |
2423 | 2904 | $error = ''; |
2424 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2905 | + if ($globalDebug) { |
|
2906 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2907 | + } |
|
2425 | 2908 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2426 | 2909 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
2427 | 2910 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2428 | 2911 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
2429 | 2912 | $modes_md5 = $modes_md5_file[0]; |
2430 | 2913 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2431 | - if ($globalDebug) echo "Gunzip..."; |
|
2914 | + if ($globalDebug) { |
|
2915 | + echo "Gunzip..."; |
|
2916 | + } |
|
2432 | 2917 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2433 | - if ($globalDebug) echo "Add to DB..."; |
|
2918 | + if ($globalDebug) { |
|
2919 | + echo "Add to DB..."; |
|
2920 | + } |
|
2434 | 2921 | $error = update_db::modes_fam(); |
2435 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2436 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2922 | + } else { |
|
2923 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2924 | + } |
|
2925 | + } else { |
|
2926 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2927 | + } |
|
2437 | 2928 | if ($error != '') { |
2438 | 2929 | return $error; |
2439 | - } elseif ($globalDebug) echo "Done\n"; |
|
2930 | + } elseif ($globalDebug) { |
|
2931 | + echo "Done\n"; |
|
2932 | + } |
|
2440 | 2933 | return ''; |
2441 | 2934 | } |
2442 | 2935 | |
2443 | 2936 | public static function update_airlines_fam() { |
2444 | 2937 | global $tmp_dir, $globalDebug; |
2445 | 2938 | $error = ''; |
2446 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
2939 | + if ($globalDebug) { |
|
2940 | + echo "Airlines from FlightAirMap website : Download..."; |
|
2941 | + } |
|
2447 | 2942 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
2448 | 2943 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2449 | 2944 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2452,26 +2947,42 @@ discard block |
||
2452 | 2947 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
2453 | 2948 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2454 | 2949 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2455 | - if ($globalDebug) echo "Gunzip..."; |
|
2950 | + if ($globalDebug) { |
|
2951 | + echo "Gunzip..."; |
|
2952 | + } |
|
2456 | 2953 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
2457 | - if ($globalDebug) echo "Add to DB..."; |
|
2954 | + if ($globalDebug) { |
|
2955 | + echo "Add to DB..."; |
|
2956 | + } |
|
2458 | 2957 | $error = update_db::airlines_fam(); |
2459 | 2958 | update_db::insert_airlines_version($airlines_md5); |
2460 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2461 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2462 | - } elseif ($globalDebug) echo "No update."; |
|
2463 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
2959 | + } else { |
|
2960 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2961 | + } |
|
2962 | + } else { |
|
2963 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2964 | + } |
|
2965 | + } elseif ($globalDebug) { |
|
2966 | + echo "No update."; |
|
2967 | + } |
|
2968 | + } else { |
|
2969 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
2970 | + } |
|
2464 | 2971 | if ($error != '') { |
2465 | 2972 | return $error; |
2466 | 2973 | } else { |
2467 | - if ($globalDebug) echo "Done\n"; |
|
2974 | + if ($globalDebug) { |
|
2975 | + echo "Done\n"; |
|
2976 | + } |
|
2468 | 2977 | } |
2469 | 2978 | return ''; |
2470 | 2979 | } |
2471 | 2980 | |
2472 | 2981 | public static function update_owner_fam() { |
2473 | 2982 | global $tmp_dir, $globalDebug, $globalOwner; |
2474 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2983 | + if ($globalDebug) { |
|
2984 | + echo "owner from FlightAirMap website : Download..."; |
|
2985 | + } |
|
2475 | 2986 | $error = ''; |
2476 | 2987 | if ($globalOwner === TRUE) { |
2477 | 2988 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2484,35 +2995,57 @@ discard block |
||
2484 | 2995 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
2485 | 2996 | $owners_md5 = $owners_md5_file[0]; |
2486 | 2997 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2487 | - if ($globalDebug) echo "Gunzip..."; |
|
2998 | + if ($globalDebug) { |
|
2999 | + echo "Gunzip..."; |
|
3000 | + } |
|
2488 | 3001 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2489 | - if ($globalDebug) echo "Add to DB..."; |
|
3002 | + if ($globalDebug) { |
|
3003 | + echo "Add to DB..."; |
|
3004 | + } |
|
2490 | 3005 | $error = update_db::owner_fam(); |
2491 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
2492 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3006 | + } else { |
|
3007 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
3008 | + } |
|
3009 | + } else { |
|
3010 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3011 | + } |
|
2493 | 3012 | if ($error != '') { |
2494 | 3013 | return $error; |
2495 | - } elseif ($globalDebug) echo "Done\n"; |
|
3014 | + } elseif ($globalDebug) { |
|
3015 | + echo "Done\n"; |
|
3016 | + } |
|
2496 | 3017 | return ''; |
2497 | 3018 | } |
2498 | 3019 | public static function update_routes_fam() { |
2499 | 3020 | global $tmp_dir, $globalDebug; |
2500 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
3021 | + if ($globalDebug) { |
|
3022 | + echo "Routes from FlightAirMap website : Download..."; |
|
3023 | + } |
|
2501 | 3024 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2502 | 3025 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
2503 | 3026 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2504 | 3027 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
2505 | 3028 | $routes_md5 = $routes_md5_file[0]; |
2506 | 3029 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2507 | - if ($globalDebug) echo "Gunzip..."; |
|
3030 | + if ($globalDebug) { |
|
3031 | + echo "Gunzip..."; |
|
3032 | + } |
|
2508 | 3033 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2509 | - if ($globalDebug) echo "Add to DB..."; |
|
3034 | + if ($globalDebug) { |
|
3035 | + echo "Add to DB..."; |
|
3036 | + } |
|
2510 | 3037 | $error = update_db::routes_fam(); |
2511 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
2512 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3038 | + } else { |
|
3039 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
3040 | + } |
|
3041 | + } else { |
|
3042 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3043 | + } |
|
2513 | 3044 | if ($error != '') { |
2514 | 3045 | return $error; |
2515 | - } elseif ($globalDebug) echo "Done\n"; |
|
3046 | + } elseif ($globalDebug) { |
|
3047 | + echo "Done\n"; |
|
3048 | + } |
|
2516 | 3049 | return ''; |
2517 | 3050 | } |
2518 | 3051 | public static function update_marine_identity_fam() { |
@@ -2522,21 +3055,33 @@ discard block |
||
2522 | 3055 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2523 | 3056 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2524 | 3057 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2525 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
3058 | + if ($globalDebug) { |
|
3059 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
3060 | + } |
|
2526 | 3061 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2527 | 3062 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2528 | 3063 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2529 | - if ($globalDebug) echo "Gunzip..."; |
|
3064 | + if ($globalDebug) { |
|
3065 | + echo "Gunzip..."; |
|
3066 | + } |
|
2530 | 3067 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2531 | - if ($globalDebug) echo "Add to DB..."; |
|
3068 | + if ($globalDebug) { |
|
3069 | + echo "Add to DB..."; |
|
3070 | + } |
|
2532 | 3071 | $error = update_db::marine_identity_fam(); |
2533 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
2534 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3072 | + } else { |
|
3073 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
3074 | + } |
|
3075 | + } else { |
|
3076 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3077 | + } |
|
2535 | 3078 | if ($error != '') { |
2536 | 3079 | return $error; |
2537 | 3080 | } else { |
2538 | 3081 | update_db::insert_marine_identity_version($marine_identity_md5); |
2539 | - if ($globalDebug) echo "Done\n"; |
|
3082 | + if ($globalDebug) { |
|
3083 | + echo "Done\n"; |
|
3084 | + } |
|
2540 | 3085 | } |
2541 | 3086 | } |
2542 | 3087 | } |
@@ -2550,21 +3095,33 @@ discard block |
||
2550 | 3095 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
2551 | 3096 | $satellite_md5 = $satellite_md5_file[0]; |
2552 | 3097 | if (!update_db::check_satellite_version($satellite_md5)) { |
2553 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
3098 | + if ($globalDebug) { |
|
3099 | + echo "Satellite from FlightAirMap website : Download..."; |
|
3100 | + } |
|
2554 | 3101 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
2555 | 3102 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2556 | 3103 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2557 | - if ($globalDebug) echo "Gunzip..."; |
|
3104 | + if ($globalDebug) { |
|
3105 | + echo "Gunzip..."; |
|
3106 | + } |
|
2558 | 3107 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
2559 | - if ($globalDebug) echo "Add to DB..."; |
|
3108 | + if ($globalDebug) { |
|
3109 | + echo "Add to DB..."; |
|
3110 | + } |
|
2560 | 3111 | $error = update_db::satellite_fam(); |
2561 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
2562 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3112 | + } else { |
|
3113 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
3114 | + } |
|
3115 | + } else { |
|
3116 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3117 | + } |
|
2563 | 3118 | if ($error != '') { |
2564 | 3119 | return $error; |
2565 | 3120 | } else { |
2566 | 3121 | update_db::insert_satellite_version($satellite_md5); |
2567 | - if ($globalDebug) echo "Done\n"; |
|
3122 | + if ($globalDebug) { |
|
3123 | + echo "Done\n"; |
|
3124 | + } |
|
2568 | 3125 | } |
2569 | 3126 | } |
2570 | 3127 | } |
@@ -2572,17 +3129,25 @@ discard block |
||
2572 | 3129 | } |
2573 | 3130 | public static function update_banned_fam() { |
2574 | 3131 | global $tmp_dir, $globalDebug; |
2575 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3132 | + if ($globalDebug) { |
|
3133 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3134 | + } |
|
2576 | 3135 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2577 | 3136 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2578 | 3137 | //if ($globalDebug) echo "Gunzip..."; |
2579 | 3138 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2580 | - if ($globalDebug) echo "Add to DB..."; |
|
3139 | + if ($globalDebug) { |
|
3140 | + echo "Add to DB..."; |
|
3141 | + } |
|
2581 | 3142 | $error = update_db::banned_fam(); |
2582 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3143 | + } else { |
|
3144 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3145 | + } |
|
2583 | 3146 | if ($error != '') { |
2584 | 3147 | return $error; |
2585 | - } elseif ($globalDebug) echo "Done\n"; |
|
3148 | + } elseif ($globalDebug) { |
|
3149 | + echo "Done\n"; |
|
3150 | + } |
|
2586 | 3151 | return ''; |
2587 | 3152 | } |
2588 | 3153 | |
@@ -2590,7 +3155,9 @@ discard block |
||
2590 | 3155 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2591 | 3156 | include_once('class.create_db.php'); |
2592 | 3157 | $error = ''; |
2593 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
3158 | + if ($globalDebug) { |
|
3159 | + echo "Airspace from FlightAirMap website : Download..."; |
|
3160 | + } |
|
2594 | 3161 | if ($globalDBdriver == 'mysql') { |
2595 | 3162 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2596 | 3163 | } else { |
@@ -2607,9 +3174,13 @@ discard block |
||
2607 | 3174 | } |
2608 | 3175 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2609 | 3176 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
2610 | - if ($globalDebug) echo "Gunzip..."; |
|
3177 | + if ($globalDebug) { |
|
3178 | + echo "Gunzip..."; |
|
3179 | + } |
|
2611 | 3180 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2612 | - if ($globalDebug) echo "Add to DB..."; |
|
3181 | + if ($globalDebug) { |
|
3182 | + echo "Add to DB..."; |
|
3183 | + } |
|
2613 | 3184 | $Connection = new Connection(); |
2614 | 3185 | if ($Connection->tableExists('airspace')) { |
2615 | 3186 | $query = 'DROP TABLE airspace'; |
@@ -2622,20 +3193,30 @@ discard block |
||
2622 | 3193 | } |
2623 | 3194 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2624 | 3195 | update_db::insert_airspace_version($airspace_md5); |
2625 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
2626 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3196 | + } else { |
|
3197 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
3198 | + } |
|
3199 | + } else { |
|
3200 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3201 | + } |
|
2627 | 3202 | } |
2628 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3203 | + } else { |
|
3204 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3205 | + } |
|
2629 | 3206 | if ($error != '') { |
2630 | 3207 | return $error; |
2631 | - } elseif ($globalDebug) echo "Done\n"; |
|
3208 | + } elseif ($globalDebug) { |
|
3209 | + echo "Done\n"; |
|
3210 | + } |
|
2632 | 3211 | return ''; |
2633 | 3212 | } |
2634 | 3213 | |
2635 | 3214 | public static function update_geoid_fam() { |
2636 | 3215 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2637 | 3216 | $error = ''; |
2638 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
3217 | + if ($globalDebug) { |
|
3218 | + echo "Geoid from FlightAirMap website : Download..."; |
|
3219 | + } |
|
2639 | 3220 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2640 | 3221 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2641 | 3222 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2644,76 +3225,116 @@ discard block |
||
2644 | 3225 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2645 | 3226 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2646 | 3227 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2647 | - if ($globalDebug) echo "Gunzip..."; |
|
3228 | + if ($globalDebug) { |
|
3229 | + echo "Gunzip..."; |
|
3230 | + } |
|
2648 | 3231 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2649 | 3232 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2650 | 3233 | update_db::insert_geoid_version($geoid_md5); |
2651 | 3234 | } |
2652 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
2653 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3235 | + } else { |
|
3236 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
3237 | + } |
|
3238 | + } else { |
|
3239 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3240 | + } |
|
2654 | 3241 | } |
2655 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3242 | + } else { |
|
3243 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3244 | + } |
|
2656 | 3245 | if ($error != '') { |
2657 | 3246 | return $error; |
2658 | - } elseif ($globalDebug) echo "Done\n"; |
|
3247 | + } elseif ($globalDebug) { |
|
3248 | + echo "Done\n"; |
|
3249 | + } |
|
2659 | 3250 | return ''; |
2660 | 3251 | } |
2661 | 3252 | |
2662 | 3253 | public static function update_tle() { |
2663 | 3254 | global $tmp_dir, $globalDebug; |
2664 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
3255 | + if ($globalDebug) { |
|
3256 | + echo "Download TLE : Download..."; |
|
3257 | + } |
|
2665 | 3258 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
2666 | 3259 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
2667 | 3260 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
2668 | 3261 | foreach ($alltle as $filename) { |
2669 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
3262 | + if ($globalDebug) { |
|
3263 | + echo "downloading ".$filename.'...'; |
|
3264 | + } |
|
2670 | 3265 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2671 | 3266 | if (file_exists($tmp_dir.$filename)) { |
2672 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
3267 | + if ($globalDebug) { |
|
3268 | + echo "Add to DB ".$filename."..."; |
|
3269 | + } |
|
2673 | 3270 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2674 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3271 | + } else { |
|
3272 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3273 | + } |
|
2675 | 3274 | if ($error != '') { |
2676 | 3275 | echo $error."\n"; |
2677 | - } elseif ($globalDebug) echo "Done\n"; |
|
3276 | + } elseif ($globalDebug) { |
|
3277 | + echo "Done\n"; |
|
3278 | + } |
|
2678 | 3279 | } |
2679 | 3280 | return ''; |
2680 | 3281 | } |
2681 | 3282 | |
2682 | 3283 | public static function update_ucsdb() { |
2683 | 3284 | global $tmp_dir, $globalDebug; |
2684 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
3285 | + if ($globalDebug) { |
|
3286 | + echo "Download UCS DB : Download..."; |
|
3287 | + } |
|
2685 | 3288 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2686 | 3289 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
2687 | - if ($globalDebug) echo "Add to DB..."; |
|
3290 | + if ($globalDebug) { |
|
3291 | + echo "Add to DB..."; |
|
3292 | + } |
|
2688 | 3293 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2689 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3294 | + } else { |
|
3295 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3296 | + } |
|
2690 | 3297 | if ($error != '') { |
2691 | 3298 | echo $error."\n"; |
2692 | - } elseif ($globalDebug) echo "Done\n"; |
|
3299 | + } elseif ($globalDebug) { |
|
3300 | + echo "Done\n"; |
|
3301 | + } |
|
2693 | 3302 | return ''; |
2694 | 3303 | } |
2695 | 3304 | |
2696 | 3305 | public static function update_celestrak() { |
2697 | 3306 | global $tmp_dir, $globalDebug; |
2698 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
3307 | + if ($globalDebug) { |
|
3308 | + echo "Download Celestrak DB : Download..."; |
|
3309 | + } |
|
2699 | 3310 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
2700 | 3311 | if (file_exists($tmp_dir.'satcat.txt')) { |
2701 | - if ($globalDebug) echo "Add to DB..."; |
|
3312 | + if ($globalDebug) { |
|
3313 | + echo "Add to DB..."; |
|
3314 | + } |
|
2702 | 3315 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
2703 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3316 | + } else { |
|
3317 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3318 | + } |
|
2704 | 3319 | if ($error != '') { |
2705 | 3320 | echo $error."\n"; |
2706 | - } elseif ($globalDebug) echo "Done\n"; |
|
3321 | + } elseif ($globalDebug) { |
|
3322 | + echo "Done\n"; |
|
3323 | + } |
|
2707 | 3324 | return ''; |
2708 | 3325 | } |
2709 | 3326 | |
2710 | 3327 | public static function update_models() { |
2711 | 3328 | global $tmp_dir, $globalDebug; |
2712 | 3329 | $error = ''; |
2713 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3330 | + if ($globalDebug) { |
|
3331 | + echo "Models from FlightAirMap website : Download..."; |
|
3332 | + } |
|
2714 | 3333 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2715 | 3334 | if (file_exists($tmp_dir.'models.md5sum')) { |
2716 | - if ($globalDebug) echo "Check files...\n"; |
|
3335 | + if ($globalDebug) { |
|
3336 | + echo "Check files...\n"; |
|
3337 | + } |
|
2717 | 3338 | $newmodelsdb = array(); |
2718 | 3339 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2719 | 3340 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2732,19 +3353,29 @@ discard block |
||
2732 | 3353 | } |
2733 | 3354 | $diff = array_diff($newmodelsdb,$modelsdb); |
2734 | 3355 | foreach ($diff as $key => $value) { |
2735 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3356 | + if ($globalDebug) { |
|
3357 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3358 | + } |
|
2736 | 3359 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2737 | 3360 | |
2738 | 3361 | } |
2739 | 3362 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2740 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3363 | + } else { |
|
3364 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3365 | + } |
|
2741 | 3366 | if ($error != '') { |
2742 | 3367 | return $error; |
2743 | - } elseif ($globalDebug) echo "Done\n"; |
|
2744 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3368 | + } elseif ($globalDebug) { |
|
3369 | + echo "Done\n"; |
|
3370 | + } |
|
3371 | + if ($globalDebug) { |
|
3372 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3373 | + } |
|
2745 | 3374 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
2746 | 3375 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2747 | - if ($globalDebug) echo "Check files...\n"; |
|
3376 | + if ($globalDebug) { |
|
3377 | + echo "Check files...\n"; |
|
3378 | + } |
|
2748 | 3379 | $newmodelsdb = array(); |
2749 | 3380 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
2750 | 3381 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2763,25 +3394,35 @@ discard block |
||
2763 | 3394 | } |
2764 | 3395 | $diff = array_diff($newmodelsdb,$modelsdb); |
2765 | 3396 | foreach ($diff as $key => $value) { |
2766 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3397 | + if ($globalDebug) { |
|
3398 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3399 | + } |
|
2767 | 3400 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
2768 | 3401 | |
2769 | 3402 | } |
2770 | 3403 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
2771 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3404 | + } else { |
|
3405 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3406 | + } |
|
2772 | 3407 | if ($error != '') { |
2773 | 3408 | return $error; |
2774 | - } elseif ($globalDebug) echo "Done\n"; |
|
3409 | + } elseif ($globalDebug) { |
|
3410 | + echo "Done\n"; |
|
3411 | + } |
|
2775 | 3412 | return ''; |
2776 | 3413 | } |
2777 | 3414 | |
2778 | 3415 | public static function update_liveries() { |
2779 | 3416 | global $tmp_dir, $globalDebug; |
2780 | 3417 | $error = ''; |
2781 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
3418 | + if ($globalDebug) { |
|
3419 | + echo "Liveries from FlightAirMap website : Download..."; |
|
3420 | + } |
|
2782 | 3421 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
2783 | 3422 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2784 | - if ($globalDebug) echo "Check files...\n"; |
|
3423 | + if ($globalDebug) { |
|
3424 | + echo "Check files...\n"; |
|
3425 | + } |
|
2785 | 3426 | $newmodelsdb = array(); |
2786 | 3427 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
2787 | 3428 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2800,25 +3441,35 @@ discard block |
||
2800 | 3441 | } |
2801 | 3442 | $diff = array_diff($newmodelsdb,$modelsdb); |
2802 | 3443 | foreach ($diff as $key => $value) { |
2803 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3444 | + if ($globalDebug) { |
|
3445 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3446 | + } |
|
2804 | 3447 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
2805 | 3448 | |
2806 | 3449 | } |
2807 | 3450 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
2808 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3451 | + } else { |
|
3452 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3453 | + } |
|
2809 | 3454 | if ($error != '') { |
2810 | 3455 | return $error; |
2811 | - } elseif ($globalDebug) echo "Done\n"; |
|
3456 | + } elseif ($globalDebug) { |
|
3457 | + echo "Done\n"; |
|
3458 | + } |
|
2812 | 3459 | return ''; |
2813 | 3460 | } |
2814 | 3461 | |
2815 | 3462 | public static function update_space_models() { |
2816 | 3463 | global $tmp_dir, $globalDebug; |
2817 | 3464 | $error = ''; |
2818 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
3465 | + if ($globalDebug) { |
|
3466 | + echo "Space models from FlightAirMap website : Download..."; |
|
3467 | + } |
|
2819 | 3468 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2820 | 3469 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2821 | - if ($globalDebug) echo "Check files...\n"; |
|
3470 | + if ($globalDebug) { |
|
3471 | + echo "Check files...\n"; |
|
3472 | + } |
|
2822 | 3473 | $newmodelsdb = array(); |
2823 | 3474 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2824 | 3475 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2837,25 +3488,35 @@ discard block |
||
2837 | 3488 | } |
2838 | 3489 | $diff = array_diff($newmodelsdb,$modelsdb); |
2839 | 3490 | foreach ($diff as $key => $value) { |
2840 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
3491 | + if ($globalDebug) { |
|
3492 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
3493 | + } |
|
2841 | 3494 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2842 | 3495 | |
2843 | 3496 | } |
2844 | 3497 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2845 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3498 | + } else { |
|
3499 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3500 | + } |
|
2846 | 3501 | if ($error != '') { |
2847 | 3502 | return $error; |
2848 | - } elseif ($globalDebug) echo "Done\n"; |
|
3503 | + } elseif ($globalDebug) { |
|
3504 | + echo "Done\n"; |
|
3505 | + } |
|
2849 | 3506 | return ''; |
2850 | 3507 | } |
2851 | 3508 | |
2852 | 3509 | public static function update_vehicules_models() { |
2853 | 3510 | global $tmp_dir, $globalDebug; |
2854 | 3511 | $error = ''; |
2855 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
3512 | + if ($globalDebug) { |
|
3513 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
3514 | + } |
|
2856 | 3515 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2857 | 3516 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2858 | - if ($globalDebug) echo "Check files...\n"; |
|
3517 | + if ($globalDebug) { |
|
3518 | + echo "Check files...\n"; |
|
3519 | + } |
|
2859 | 3520 | $newmodelsdb = array(); |
2860 | 3521 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2861 | 3522 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2874,15 +3535,21 @@ discard block |
||
2874 | 3535 | } |
2875 | 3536 | $diff = array_diff($newmodelsdb,$modelsdb); |
2876 | 3537 | foreach ($diff as $key => $value) { |
2877 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3538 | + if ($globalDebug) { |
|
3539 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3540 | + } |
|
2878 | 3541 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2879 | 3542 | |
2880 | 3543 | } |
2881 | 3544 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2882 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3545 | + } else { |
|
3546 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3547 | + } |
|
2883 | 3548 | if ($error != '') { |
2884 | 3549 | return $error; |
2885 | - } elseif ($globalDebug) echo "Done\n"; |
|
3550 | + } elseif ($globalDebug) { |
|
3551 | + echo "Done\n"; |
|
3552 | + } |
|
2886 | 3553 | return ''; |
2887 | 3554 | } |
2888 | 3555 | |
@@ -2925,7 +3592,9 @@ discard block |
||
2925 | 3592 | } |
2926 | 3593 | |
2927 | 3594 | $error = ''; |
2928 | - if ($globalDebug) echo "Notam : Download..."; |
|
3595 | + if ($globalDebug) { |
|
3596 | + echo "Notam : Download..."; |
|
3597 | + } |
|
2929 | 3598 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2930 | 3599 | if (file_exists($tmp_dir.'notam.rss')) { |
2931 | 3600 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2940,14 +3609,30 @@ discard block |
||
2940 | 3609 | $data['fir'] = $q[0]; |
2941 | 3610 | $data['code'] = $q[1]; |
2942 | 3611 | $ifrvfr = $q[2]; |
2943 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2944 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2945 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2946 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2947 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2948 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2949 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2950 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
3612 | + if ($ifrvfr == 'IV') { |
|
3613 | + $data['rules'] = 'IFR/VFR'; |
|
3614 | + } |
|
3615 | + if ($ifrvfr == 'I') { |
|
3616 | + $data['rules'] = 'IFR'; |
|
3617 | + } |
|
3618 | + if ($ifrvfr == 'V') { |
|
3619 | + $data['rules'] = 'VFR'; |
|
3620 | + } |
|
3621 | + if ($q[4] == 'A') { |
|
3622 | + $data['scope'] = 'Airport warning'; |
|
3623 | + } |
|
3624 | + if ($q[4] == 'E') { |
|
3625 | + $data['scope'] = 'Enroute warning'; |
|
3626 | + } |
|
3627 | + if ($q[4] == 'W') { |
|
3628 | + $data['scope'] = 'Navigation warning'; |
|
3629 | + } |
|
3630 | + if ($q[4] == 'AE') { |
|
3631 | + $data['scope'] = 'Airport/Enroute warning'; |
|
3632 | + } |
|
3633 | + if ($q[4] == 'AW') { |
|
3634 | + $data['scope'] = 'Airport/Navigation warning'; |
|
3635 | + } |
|
2951 | 3636 | //$data['scope'] = $q[4]; |
2952 | 3637 | $data['lower_limit'] = $q[5]; |
2953 | 3638 | $data['upper_limit'] = $q[6]; |
@@ -2955,8 +3640,12 @@ discard block |
||
2955 | 3640 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2956 | 3641 | $latitude = $Common->convertDec($las,'latitude'); |
2957 | 3642 | $longitude = $Common->convertDec($lns,'longitude'); |
2958 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2959 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
3643 | + if ($lac == 'S') { |
|
3644 | + $latitude = '-'.$latitude; |
|
3645 | + } |
|
3646 | + if ($lnc == 'W') { |
|
3647 | + $longitude = '-'.$longitude; |
|
3648 | + } |
|
2960 | 3649 | $data['center_latitude'] = $latitude; |
2961 | 3650 | $data['center_longitude'] = $longitude; |
2962 | 3651 | $data['radius'] = intval($radius); |
@@ -2986,10 +3675,14 @@ discard block |
||
2986 | 3675 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
2987 | 3676 | unset($data); |
2988 | 3677 | } |
2989 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3678 | + } else { |
|
3679 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3680 | + } |
|
2990 | 3681 | if ($error != '') { |
2991 | 3682 | return $error; |
2992 | - } elseif ($globalDebug) echo "Done\n"; |
|
3683 | + } elseif ($globalDebug) { |
|
3684 | + echo "Done\n"; |
|
3685 | + } |
|
2993 | 3686 | return ''; |
2994 | 3687 | } |
2995 | 3688 | |
@@ -3014,7 +3707,9 @@ discard block |
||
3014 | 3707 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3015 | 3708 | $airspace_json = json_decode($airspace_lst,true); |
3016 | 3709 | foreach ($airspace_json['records'] as $airspace) { |
3017 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3710 | + if ($globalDebug) { |
|
3711 | + echo $airspace['name']."...\n"; |
|
3712 | + } |
|
3018 | 3713 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
3019 | 3714 | if (file_exists($tmp_dir.$airspace['name'])) { |
3020 | 3715 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3058,8 +3753,11 @@ discard block |
||
3058 | 3753 | return "error : ".$e->getMessage(); |
3059 | 3754 | } |
3060 | 3755 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3061 | - if ($row['nb'] > 0) return false; |
|
3062 | - else return true; |
|
3756 | + if ($row['nb'] > 0) { |
|
3757 | + return false; |
|
3758 | + } else { |
|
3759 | + return true; |
|
3760 | + } |
|
3063 | 3761 | } |
3064 | 3762 | |
3065 | 3763 | public static function insert_last_update() { |
@@ -3084,8 +3782,11 @@ discard block |
||
3084 | 3782 | return "error : ".$e->getMessage(); |
3085 | 3783 | } |
3086 | 3784 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3087 | - if ($row['nb'] > 0) return true; |
|
3088 | - else return false; |
|
3785 | + if ($row['nb'] > 0) { |
|
3786 | + return true; |
|
3787 | + } else { |
|
3788 | + return false; |
|
3789 | + } |
|
3089 | 3790 | } |
3090 | 3791 | |
3091 | 3792 | public static function check_geoid_version($version) { |
@@ -3098,8 +3799,11 @@ discard block |
||
3098 | 3799 | return "error : ".$e->getMessage(); |
3099 | 3800 | } |
3100 | 3801 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3101 | - if ($row['nb'] > 0) return true; |
|
3102 | - else return false; |
|
3802 | + if ($row['nb'] > 0) { |
|
3803 | + return true; |
|
3804 | + } else { |
|
3805 | + return false; |
|
3806 | + } |
|
3103 | 3807 | } |
3104 | 3808 | |
3105 | 3809 | public static function check_marine_identity_version($version) { |
@@ -3112,8 +3816,11 @@ discard block |
||
3112 | 3816 | return "error : ".$e->getMessage(); |
3113 | 3817 | } |
3114 | 3818 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3115 | - if ($row['nb'] > 0) return true; |
|
3116 | - else return false; |
|
3819 | + if ($row['nb'] > 0) { |
|
3820 | + return true; |
|
3821 | + } else { |
|
3822 | + return false; |
|
3823 | + } |
|
3117 | 3824 | } |
3118 | 3825 | |
3119 | 3826 | public static function check_satellite_version($version) { |
@@ -3126,8 +3833,11 @@ discard block |
||
3126 | 3833 | return "error : ".$e->getMessage(); |
3127 | 3834 | } |
3128 | 3835 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3129 | - if ($row['nb'] > 0) return true; |
|
3130 | - else return false; |
|
3836 | + if ($row['nb'] > 0) { |
|
3837 | + return true; |
|
3838 | + } else { |
|
3839 | + return false; |
|
3840 | + } |
|
3131 | 3841 | } |
3132 | 3842 | |
3133 | 3843 | public static function check_airlines_version($version) { |
@@ -3140,8 +3850,11 @@ discard block |
||
3140 | 3850 | return "error : ".$e->getMessage(); |
3141 | 3851 | } |
3142 | 3852 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3143 | - if ($row['nb'] > 0) return true; |
|
3144 | - else return false; |
|
3853 | + if ($row['nb'] > 0) { |
|
3854 | + return true; |
|
3855 | + } else { |
|
3856 | + return false; |
|
3857 | + } |
|
3145 | 3858 | } |
3146 | 3859 | |
3147 | 3860 | public static function check_notam_version($version) { |
@@ -3154,8 +3867,11 @@ discard block |
||
3154 | 3867 | return "error : ".$e->getMessage(); |
3155 | 3868 | } |
3156 | 3869 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3157 | - if ($row['nb'] > 0) return true; |
|
3158 | - else return false; |
|
3870 | + if ($row['nb'] > 0) { |
|
3871 | + return true; |
|
3872 | + } else { |
|
3873 | + return false; |
|
3874 | + } |
|
3159 | 3875 | } |
3160 | 3876 | |
3161 | 3877 | public static function insert_airlines_version($version) { |
@@ -3245,8 +3961,11 @@ discard block |
||
3245 | 3961 | return "error : ".$e->getMessage(); |
3246 | 3962 | } |
3247 | 3963 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3248 | - if ($row['nb'] > 0) return false; |
|
3249 | - else return true; |
|
3964 | + if ($row['nb'] > 0) { |
|
3965 | + return false; |
|
3966 | + } else { |
|
3967 | + return true; |
|
3968 | + } |
|
3250 | 3969 | } |
3251 | 3970 | |
3252 | 3971 | public static function insert_last_notam_update() { |
@@ -3276,8 +3995,11 @@ discard block |
||
3276 | 3995 | return "error : ".$e->getMessage(); |
3277 | 3996 | } |
3278 | 3997 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3279 | - if ($row['nb'] > 0) return false; |
|
3280 | - else return true; |
|
3998 | + if ($row['nb'] > 0) { |
|
3999 | + return false; |
|
4000 | + } else { |
|
4001 | + return true; |
|
4002 | + } |
|
3281 | 4003 | } |
3282 | 4004 | |
3283 | 4005 | public static function insert_last_airspace_update() { |
@@ -3307,8 +4029,11 @@ discard block |
||
3307 | 4029 | return "error : ".$e->getMessage(); |
3308 | 4030 | } |
3309 | 4031 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3310 | - if ($row['nb'] > 0) return false; |
|
3311 | - else return true; |
|
4032 | + if ($row['nb'] > 0) { |
|
4033 | + return false; |
|
4034 | + } else { |
|
4035 | + return true; |
|
4036 | + } |
|
3312 | 4037 | } |
3313 | 4038 | |
3314 | 4039 | public static function insert_last_geoid_update() { |
@@ -3338,8 +4063,11 @@ discard block |
||
3338 | 4063 | return "error : ".$e->getMessage(); |
3339 | 4064 | } |
3340 | 4065 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3341 | - if ($row['nb'] > 0) return false; |
|
3342 | - else return true; |
|
4066 | + if ($row['nb'] > 0) { |
|
4067 | + return false; |
|
4068 | + } else { |
|
4069 | + return true; |
|
4070 | + } |
|
3343 | 4071 | } |
3344 | 4072 | |
3345 | 4073 | public static function insert_last_owner_update() { |
@@ -3369,8 +4097,11 @@ discard block |
||
3369 | 4097 | return "error : ".$e->getMessage(); |
3370 | 4098 | } |
3371 | 4099 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3372 | - if ($row['nb'] > 0) return false; |
|
3373 | - else return true; |
|
4100 | + if ($row['nb'] > 0) { |
|
4101 | + return false; |
|
4102 | + } else { |
|
4103 | + return true; |
|
4104 | + } |
|
3374 | 4105 | } |
3375 | 4106 | |
3376 | 4107 | public static function insert_last_fires_update() { |
@@ -3400,8 +4131,11 @@ discard block |
||
3400 | 4131 | return "error : ".$e->getMessage(); |
3401 | 4132 | } |
3402 | 4133 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3403 | - if ($row['nb'] > 0) return false; |
|
3404 | - else return true; |
|
4134 | + if ($row['nb'] > 0) { |
|
4135 | + return false; |
|
4136 | + } else { |
|
4137 | + return true; |
|
4138 | + } |
|
3405 | 4139 | } |
3406 | 4140 | |
3407 | 4141 | public static function insert_last_airlines_update() { |
@@ -3431,8 +4165,11 @@ discard block |
||
3431 | 4165 | return "error : ".$e->getMessage(); |
3432 | 4166 | } |
3433 | 4167 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3434 | - if ($row['nb'] > 0) return false; |
|
3435 | - else return true; |
|
4168 | + if ($row['nb'] > 0) { |
|
4169 | + return false; |
|
4170 | + } else { |
|
4171 | + return true; |
|
4172 | + } |
|
3436 | 4173 | } |
3437 | 4174 | |
3438 | 4175 | public static function insert_last_schedules_update() { |
@@ -3462,8 +4199,11 @@ discard block |
||
3462 | 4199 | return "error : ".$e->getMessage(); |
3463 | 4200 | } |
3464 | 4201 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3465 | - if ($row['nb'] > 0) return false; |
|
3466 | - else return true; |
|
4202 | + if ($row['nb'] > 0) { |
|
4203 | + return false; |
|
4204 | + } else { |
|
4205 | + return true; |
|
4206 | + } |
|
3467 | 4207 | } |
3468 | 4208 | |
3469 | 4209 | public static function insert_last_tle_update() { |
@@ -3493,8 +4233,11 @@ discard block |
||
3493 | 4233 | return "error : ".$e->getMessage(); |
3494 | 4234 | } |
3495 | 4235 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3496 | - if ($row['nb'] > 0) return false; |
|
3497 | - else return true; |
|
4236 | + if ($row['nb'] > 0) { |
|
4237 | + return false; |
|
4238 | + } else { |
|
4239 | + return true; |
|
4240 | + } |
|
3498 | 4241 | } |
3499 | 4242 | |
3500 | 4243 | public static function insert_last_ucsdb_update() { |
@@ -3524,8 +4267,11 @@ discard block |
||
3524 | 4267 | return "error : ".$e->getMessage(); |
3525 | 4268 | } |
3526 | 4269 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3527 | - if ($row['nb'] > 0) return false; |
|
3528 | - else return true; |
|
4270 | + if ($row['nb'] > 0) { |
|
4271 | + return false; |
|
4272 | + } else { |
|
4273 | + return true; |
|
4274 | + } |
|
3529 | 4275 | } |
3530 | 4276 | |
3531 | 4277 | public static function insert_last_celestrak_update() { |
@@ -3555,8 +4301,11 @@ discard block |
||
3555 | 4301 | return "error : ".$e->getMessage(); |
3556 | 4302 | } |
3557 | 4303 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3558 | - if ($row['nb'] > 0) return false; |
|
3559 | - else return true; |
|
4304 | + if ($row['nb'] > 0) { |
|
4305 | + return false; |
|
4306 | + } else { |
|
4307 | + return true; |
|
4308 | + } |
|
3560 | 4309 | } |
3561 | 4310 | |
3562 | 4311 | public static function check_last_satellite_update() { |
@@ -3574,8 +4323,11 @@ discard block |
||
3574 | 4323 | return "error : ".$e->getMessage(); |
3575 | 4324 | } |
3576 | 4325 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3577 | - if ($row['nb'] > 0) return false; |
|
3578 | - else return true; |
|
4326 | + if ($row['nb'] > 0) { |
|
4327 | + return false; |
|
4328 | + } else { |
|
4329 | + return true; |
|
4330 | + } |
|
3579 | 4331 | } |
3580 | 4332 | |
3581 | 4333 | public static function insert_last_marine_identity_update() { |
@@ -8,8 +8,12 @@ discard block |
||
8 | 8 | } |
9 | 9 | $tracker = false; |
10 | 10 | $marine = false; |
11 | -if (isset($_GET['tracker'])) $tracker = true; |
|
12 | -if (isset($_GET['marine'])) $marine = true; |
|
11 | +if (isset($_GET['tracker'])) { |
|
12 | + $tracker = true; |
|
13 | +} |
|
14 | +if (isset($_GET['marine'])) { |
|
15 | + $marine = true; |
|
16 | +} |
|
13 | 17 | if ($tracker) { |
14 | 18 | require_once('require/class.Tracker.php'); |
15 | 19 | require_once('require/class.TrackerLive.php'); |
@@ -66,23 +70,46 @@ discard block |
||
66 | 70 | } |
67 | 71 | header('Content-Type: text/javascript'); |
68 | 72 | |
69 | -if (!isset($globalJsonCompress)) $compress = true; |
|
70 | -else $compress = $globalJsonCompress; |
|
73 | +if (!isset($globalJsonCompress)) { |
|
74 | + $compress = true; |
|
75 | +} else { |
|
76 | + $compress = $globalJsonCompress; |
|
77 | +} |
|
71 | 78 | |
72 | 79 | $from_archive = false; |
73 | 80 | $min = false; |
74 | 81 | $allhistory = false; |
75 | 82 | $filter['source'] = array(); |
76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
83 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
84 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
85 | +} |
|
86 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
87 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
88 | +} |
|
89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
90 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
91 | +} |
|
92 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
93 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
94 | +} |
|
95 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
96 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
97 | +} |
|
98 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
99 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
100 | +} |
|
101 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
102 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
103 | +} |
|
104 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
105 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
106 | +} |
|
107 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
108 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
109 | +} |
|
110 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
111 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
112 | +} |
|
86 | 113 | /* |
87 | 114 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
88 | 115 | $min = true; |
@@ -179,8 +206,12 @@ discard block |
||
179 | 206 | } else { |
180 | 207 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
181 | 208 | } |
182 | - if ($flightcnt == '') $flightcnt = 0; |
|
183 | -} else $flightcnt = 0; |
|
209 | + if ($flightcnt == '') { |
|
210 | + $flightcnt = 0; |
|
211 | + } |
|
212 | + } else { |
|
213 | + $flightcnt = 0; |
|
214 | +} |
|
184 | 215 | |
185 | 216 | $sqltime = round(microtime(true)-$begintime,2); |
186 | 217 | $minitime = time(); |
@@ -216,7 +247,9 @@ discard block |
||
216 | 247 | $prev_flightaware_id = ''; |
217 | 248 | $speed = 1; |
218 | 249 | $gltf2 = false; |
219 | -if (isset($archivespeed)) $speed = $archivespeed; |
|
250 | +if (isset($archivespeed)) { |
|
251 | + $speed = $archivespeed; |
|
252 | +} |
|
220 | 253 | $output = '['; |
221 | 254 | if ($tracker) { |
222 | 255 | $output .= '{"id" : "document", "name" : "tracker","version" : "1.0"'; |
@@ -252,9 +285,13 @@ discard block |
||
252 | 285 | $image = "images/placeholder_thumb.png"; |
253 | 286 | } |
254 | 287 | |
255 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
256 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
257 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
288 | + if (isset($spotter_item['flightaware_id'])) { |
|
289 | + $id = $spotter_item['flightaware_id']; |
|
290 | + } elseif (isset($spotter_item['famtrackid'])) { |
|
291 | + $id = $spotter_item['famtrackid']; |
|
292 | + } elseif (isset($spotter_item['fammarine_id'])) { |
|
293 | + $id = $spotter_item['fammarine_id']; |
|
294 | + } |
|
258 | 295 | if ($prev_flightaware_id != $id) { |
259 | 296 | if ($prev_flightaware_id != '') { |
260 | 297 | /* |
@@ -302,7 +339,9 @@ discard block |
||
302 | 339 | } |
303 | 340 | } |
304 | 341 | } |
305 | - if ($ident != '') $output.= '"ident": "'.$ident.'",'; |
|
342 | + if ($ident != '') { |
|
343 | + $output.= '"ident": "'.$ident.'",'; |
|
344 | + } |
|
306 | 345 | } |
307 | 346 | $output.= '"gltf2": %gltf2%,'; |
308 | 347 | $output.= '"type": "flight"'; |
@@ -334,7 +373,9 @@ discard block |
||
334 | 373 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
335 | 374 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
336 | 375 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
337 | - } else $aircraft_shadow = ''; |
|
376 | + } else { |
|
377 | + $aircraft_shadow = ''; |
|
378 | + } |
|
338 | 379 | $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
339 | 380 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) { |
340 | 381 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
@@ -342,7 +383,9 @@ discard block |
||
342 | 383 | } |
343 | 384 | $output .= '},'; |
344 | 385 | } |
345 | - } else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
386 | + } else { |
|
387 | + $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
388 | + } |
|
346 | 389 | } elseif ($one3dmodel) { |
347 | 390 | if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') { |
348 | 391 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -382,7 +425,9 @@ discard block |
||
382 | 425 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
383 | 426 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
384 | 427 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
385 | - } else $aircraft_shadow = ''; |
|
428 | + } else { |
|
429 | + $aircraft_shadow = ''; |
|
430 | + } |
|
386 | 431 | if ($aircraft_shadow != '') { |
387 | 432 | if (isset($modelsdb[$aircraft_shadow])) { |
388 | 433 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -519,7 +564,9 @@ discard block |
||
519 | 564 | } |
520 | 565 | $output .= '},'; |
521 | 566 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
522 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
567 | + if ($spotter_item['aircraft_icao'] != '') { |
|
568 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
569 | + } |
|
523 | 570 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
524 | 571 | } |
525 | 572 | } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
@@ -541,7 +588,9 @@ discard block |
||
541 | 588 | } |
542 | 589 | $output .= '},'; |
543 | 590 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
544 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
591 | + if ($spotter_item['aircraft_icao'] != '') { |
|
592 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
593 | + } |
|
545 | 594 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
546 | 595 | } |
547 | 596 | } else { |
@@ -554,7 +603,9 @@ discard block |
||
554 | 603 | } |
555 | 604 | $output .= '},'; |
556 | 605 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
557 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
606 | + if ($spotter_item['aircraft_icao'] != '') { |
|
607 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
608 | + } |
|
558 | 609 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
559 | 610 | } |
560 | 611 | } elseif ($tracker && isset($spotter_item['type'])) { |
@@ -658,8 +709,11 @@ discard block |
||
658 | 709 | $output .= '},'; |
659 | 710 | } |
660 | 711 | } |
661 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
662 | - else $output = str_replace('%onground%','false',$output); |
|
712 | + if (isset($onground) && $onground) { |
|
713 | + $output = str_replace('%onground%','true',$output); |
|
714 | + } else { |
|
715 | + $output = str_replace('%onground%','false',$output); |
|
716 | + } |
|
663 | 717 | |
664 | 718 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
665 | 719 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -672,8 +726,12 @@ discard block |
||
672 | 726 | // $output .= '"interpolationDegree" : 5,'; |
673 | 727 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
674 | 728 | $output .= '"cartographicDegrees": ['; |
675 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
676 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
729 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
730 | + $minitime = strtotime($spotter_item['date']); |
|
731 | + } |
|
732 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
733 | + $maxitime = strtotime($spotter_item['date']); |
|
734 | + } |
|
677 | 735 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
678 | 736 | $output .= $spotter_item['longitude'].', '; |
679 | 737 | $output .= $spotter_item['latitude']; |
@@ -696,7 +754,9 @@ discard block |
||
696 | 754 | $output .= ', '.round($spotter_item['altitude']*30.48); |
697 | 755 | $prevalt = round($spotter_item['altitude']*30.48); |
698 | 756 | } |
699 | - } else $output .= ', 0'; |
|
757 | + } else { |
|
758 | + $output .= ', 0'; |
|
759 | + } |
|
700 | 760 | //$orientation = '"orientation" : { '; |
701 | 761 | //$orientation .= '"unitQuaternion": ['; |
702 | 762 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
@@ -704,13 +764,18 @@ discard block |
||
704 | 764 | } else { |
705 | 765 | $nblatlong = $nblatlong+1; |
706 | 766 | $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
707 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
767 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
768 | + $maxitime = strtotime($spotter_item['date']); |
|
769 | + } |
|
708 | 770 | if ($spotter_item['ground_speed'] == 0) { |
709 | 771 | $output .= $prevlong.', '; |
710 | 772 | $output .= $prevlat; |
711 | 773 | //if (!$marine && (!isset($onground) || !$onground)) $output .= ', '.$prevalt; |
712 | - if (!$marine) $output .= ', '.$prevalt; |
|
713 | - else $output .= ', 0'; |
|
774 | + if (!$marine) { |
|
775 | + $output .= ', '.$prevalt; |
|
776 | + } else { |
|
777 | + $output .= ', 0'; |
|
778 | + } |
|
714 | 779 | } else { |
715 | 780 | $output .= $spotter_item['longitude'].', '; |
716 | 781 | $output .= $spotter_item['latitude']; |
@@ -723,14 +788,17 @@ discard block |
||
723 | 788 | $output .= ', 0'; |
724 | 789 | } |
725 | 790 | } else { |
726 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
727 | - elseif ($tracker) { |
|
791 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
792 | + $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
793 | + } elseif ($tracker) { |
|
728 | 794 | $output .= ', '.round($spotter_item['altitude']*0.3048); |
729 | 795 | } else { |
730 | 796 | $output .= ', '.round($spotter_item['altitude']*30.48); |
731 | 797 | } |
732 | 798 | } |
733 | - } else $output .= ', 0'; |
|
799 | + } else { |
|
800 | + $output .= ', 0'; |
|
801 | + } |
|
734 | 802 | } |
735 | 803 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
736 | 804 | //$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
@@ -749,11 +817,17 @@ discard block |
||
749 | 817 | } else { |
750 | 818 | $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
751 | 819 | } |
820 | + } else { |
|
821 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
752 | 822 | } |
753 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
754 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
823 | + } else { |
|
824 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
825 | +} |
|
755 | 826 | $output = str_replace('%maxitime%',date("c",$maxitime),$output); |
756 | -if ($gltf2) $output = str_replace('%gltf2%','true',$output); |
|
757 | -else $output = str_replace('%gltf2%','false',$output); |
|
827 | +if ($gltf2) { |
|
828 | + $output = str_replace('%gltf2%','true',$output); |
|
829 | +} else { |
|
830 | + $output = str_replace('%gltf2%','false',$output); |
|
831 | +} |
|
758 | 832 | print $output; |
759 | 833 | ?> |
@@ -37,8 +37,12 @@ discard block |
||
37 | 37 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
38 | 38 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
39 | 39 | $filter = array(); |
40 | - if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
41 | - if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
40 | + if ($year != '') { |
|
41 | + $filter = array_merge($filter,array('year' => $year)); |
|
42 | + } |
|
43 | + if ($month != '') { |
|
44 | + $filter = array_merge($filter,array('month' => $month)); |
|
45 | + } |
|
42 | 46 | if ($sort != '') |
43 | 47 | { |
44 | 48 | $spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter); |
@@ -56,8 +60,12 @@ discard block |
||
56 | 60 | { |
57 | 61 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']); |
58 | 62 | $ident = $spotter_array[0]['ident']; |
59 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
60 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
63 | + if (isset($spotter_array[0]['latitude'])) { |
|
64 | + $latitude = $spotter_array[0]['latitude']; |
|
65 | + } |
|
66 | + if (isset($spotter_array[0]['longitude'])) { |
|
67 | + $longitude = $spotter_array[0]['longitude']; |
|
68 | + } |
|
61 | 69 | require_once('header.php'); |
62 | 70 | /* |
63 | 71 | if (isset($globalArchive) && $globalArchive) { |
@@ -110,12 +118,18 @@ discard block |
||
110 | 118 | */ |
111 | 119 | print '<div class="info column">'; |
112 | 120 | print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>'; |
113 | - if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>'; |
|
121 | + if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') { |
|
122 | + print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>'; |
|
123 | + } |
|
114 | 124 | if ($year == '' && $month == '') { |
115 | 125 | $Stats = new Stats(); |
116 | 126 | $flights = $Stats->getStatsPilot($pilot); |
117 | - } else $flights = 0; |
|
118 | - if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter); |
|
127 | + } else { |
|
128 | + $flights = 0; |
|
129 | + } |
|
130 | + if ($flights == 0) { |
|
131 | + $flights = $Spotter->countFlightsByPilot($pilot,$filter); |
|
132 | + } |
|
119 | 133 | print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>'; |
120 | 134 | $aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter)); |
121 | 135 | print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>'; |
@@ -126,7 +140,9 @@ discard block |
||
126 | 140 | $airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter)); |
127 | 141 | print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>'; |
128 | 142 | $duration = $Spotter->getFlightDurationByPilot($pilot,$filter); |
129 | - if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>'; |
|
143 | + if ($duration != '0') { |
|
144 | + print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>'; |
|
145 | + } |
|
130 | 146 | print '</div>'; |
131 | 147 | |
132 | 148 | include('pilot-sub-menu.php'); |