@@ -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,37 +262,53 @@ 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('/\/api\/v1\/acars\/data$/i',$host)) { |
208 | 269 | //$formats[$id] = 'phpvmacars'; |
209 | 270 | $globalSources[$id]['format'] = 'vaos'; |
210 | 271 | //$last_exec['phpvmacars'] = 0; |
211 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
272 | + if ($globalDebug) { |
|
273 | + echo "Connect to vaos source (".$host.")...\n"; |
|
274 | + } |
|
212 | 275 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
213 | 276 | //$formats[$id] = 'phpvmacars'; |
214 | 277 | $globalSources[$id]['format'] = 'vam'; |
215 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
278 | + if ($globalDebug) { |
|
279 | + echo "Connect to Vam source (".$host.")...\n"; |
|
280 | + } |
|
216 | 281 | } else if (preg_match('/whazzup/i',$host)) { |
217 | 282 | //$formats[$id] = 'whazzup'; |
218 | 283 | $globalSources[$id]['format'] = 'whazzup'; |
219 | 284 | //$last_exec['whazzup'] = 0; |
220 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
285 | + if ($globalDebug) { |
|
286 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
287 | + } |
|
221 | 288 | } else if (preg_match('/blitzortung/i',$host)) { |
222 | 289 | $globalSources[$id]['format'] = 'blitzortung'; |
223 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
290 | + if ($globalDebug) { |
|
291 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
292 | + } |
|
224 | 293 | } else if (preg_match('/airwhere/i',$host)) { |
225 | 294 | $globalSources[$id]['format'] = 'airwhere'; |
226 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
295 | + if ($globalDebug) { |
|
296 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
297 | + } |
|
227 | 298 | } else if (preg_match('/recentpireps/i',$host)) { |
228 | 299 | //$formats[$id] = 'pirepsjson'; |
229 | 300 | $globalSources[$id]['format'] = 'pirepsjson'; |
230 | 301 | //$last_exec['pirepsjson'] = 0; |
231 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
302 | + if ($globalDebug) { |
|
303 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
304 | + } |
|
232 | 305 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
233 | 306 | //$formats[$id] = 'fr24json'; |
234 | 307 | $globalSources[$id]['format'] = 'fr24json'; |
235 | 308 | //$last_exec['fr24json'] = 0; |
236 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
311 | + } |
|
237 | 312 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
238 | 313 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
239 | 314 | exit(0); |
@@ -242,7 +317,9 @@ discard block |
||
242 | 317 | //$formats[$id] = 'fr24json'; |
243 | 318 | $globalSources[$id]['format'] = 'myshiptracking'; |
244 | 319 | //$last_exec['fr24json'] = 0; |
245 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
320 | + if ($globalDebug) { |
|
321 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
322 | + } |
|
246 | 323 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
247 | 324 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
248 | 325 | exit(0); |
@@ -251,16 +328,24 @@ discard block |
||
251 | 328 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
252 | 329 | //$formats[$id] = 'tsv'; |
253 | 330 | $globalSources[$id]['format'] = 'tsv'; |
254 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
331 | + if ($globalDebug) { |
|
332 | + echo "Connect to tsv source (".$host.")...\n"; |
|
333 | + } |
|
255 | 334 | } |
256 | 335 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
257 | 336 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
258 | 337 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
259 | 338 | if ($idf !== false) { |
260 | 339 | $httpfeeds[$id] = $idf; |
261 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
262 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
263 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
340 | + if ($globalDebug) { |
|
341 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
342 | + } |
|
343 | + } elseif ($globalDebug) { |
|
344 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
345 | + } |
|
346 | + } elseif ($globalDebug) { |
|
347 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
348 | + } |
|
264 | 349 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
265 | 350 | $hostport = explode(':',$host); |
266 | 351 | if (isset($hostport[1])) { |
@@ -300,17 +385,25 @@ discard block |
||
300 | 385 | //$formats[$id] = 'beast'; |
301 | 386 | $globalSources[$id]['format'] = 'beast'; |
302 | 387 | //} else $formats[$id] = 'sbs'; |
303 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
388 | + } else { |
|
389 | + $globalSources[$id]['format'] = 'sbs'; |
|
390 | + } |
|
304 | 391 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
305 | 392 | } |
306 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
393 | + if ($globalDebug) { |
|
394 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
395 | + } |
|
307 | 396 | } else { |
308 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
397 | + if ($globalDebug) { |
|
398 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
399 | + } |
|
309 | 400 | } |
310 | 401 | } |
311 | 402 | } |
312 | 403 | } |
313 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
404 | +if (!isset($globalMinFetch)) { |
|
405 | + $globalMinFetch = 15; |
|
406 | +} |
|
314 | 407 | |
315 | 408 | // Initialize all |
316 | 409 | $status = array(); |
@@ -319,13 +412,19 @@ discard block |
||
319 | 412 | $formats = array(); |
320 | 413 | $last_exec = array(); |
321 | 414 | $time = time(); |
322 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
323 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
324 | -else $timeout = 20; |
|
415 | +if (isset($globalSourcesTimeout)) { |
|
416 | + $timeout = $globalSourcesTimeOut; |
|
417 | +} else if (isset($globalSBS1TimeOut)) { |
|
418 | + $timeout = $globalSBS1TimeOut; |
|
419 | +} else { |
|
420 | + $timeout = 20; |
|
421 | +} |
|
325 | 422 | $errno = ''; |
326 | 423 | $errstr=''; |
327 | 424 | |
328 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
425 | +if (!isset($globalDaemon)) { |
|
426 | + $globalDaemon = TRUE; |
|
427 | +} |
|
329 | 428 | /* Initiate connections to all the hosts simultaneously */ |
330 | 429 | //connect_all($hosts); |
331 | 430 | //connect_all($globalSources); |
@@ -354,7 +453,9 @@ discard block |
||
354 | 453 | if (isset($source['format']) && $source['format'] == 'aprs') { |
355 | 454 | $aprs_connect = 0; |
356 | 455 | $use_aprs = true; |
357 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
456 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
457 | + $aprs_full = true; |
|
458 | + } |
|
358 | 459 | break; |
359 | 460 | } |
360 | 461 | } |
@@ -365,25 +466,46 @@ discard block |
||
365 | 466 | $aprs_connect = 0; |
366 | 467 | $aprs_keep = 120; |
367 | 468 | $aprs_last_tx = time(); |
368 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
369 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
370 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
371 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
372 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
373 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
374 | - if ($aprs_full) $aprs_filter = ''; |
|
375 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
376 | - else $aprs_pass = '-1'; |
|
469 | + if (isset($globalAPRSversion)) { |
|
470 | + $aprs_version = $globalAPRSversion; |
|
471 | + } else { |
|
472 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
473 | + } |
|
474 | + if (isset($globalAPRSssid)) { |
|
475 | + $aprs_ssid = $globalAPRSssid; |
|
476 | + } else { |
|
477 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
478 | + } |
|
479 | + if (isset($globalAPRSfilter)) { |
|
480 | + $aprs_filter = $globalAPRSfilter; |
|
481 | + } else { |
|
482 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
483 | + } |
|
484 | + if ($aprs_full) { |
|
485 | + $aprs_filter = ''; |
|
486 | + } |
|
487 | + if (isset($globalAPRSpass)) { |
|
488 | + $aprs_pass = $globalAPRSpass; |
|
489 | + } else { |
|
490 | + $aprs_pass = '-1'; |
|
491 | + } |
|
377 | 492 | |
378 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
379 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
380 | -} |
|
493 | + if ($aprs_filter != '') { |
|
494 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
495 | + } else { |
|
496 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
497 | + } |
|
498 | + } |
|
381 | 499 | |
382 | 500 | // connected - lets do some work |
383 | 501 | //if ($globalDebug) echo "Connected!\n"; |
384 | 502 | sleep(1); |
385 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
386 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
503 | +if ($globalDebug) { |
|
504 | + echo "SCAN MODE \n\n"; |
|
505 | +} |
|
506 | +if (!isset($globalCronEnd)) { |
|
507 | + $globalCronEnd = 60; |
|
508 | +} |
|
387 | 509 | $endtime = time()+$globalCronEnd; |
388 | 510 | $i = 1; |
389 | 511 | $tt = array(); |
@@ -397,20 +519,28 @@ discard block |
||
397 | 519 | |
398 | 520 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
399 | 521 | while ($i > 0) { |
400 | - if (!$globalDaemon) $i = $endtime-time(); |
|
522 | + if (!$globalDaemon) { |
|
523 | + $i = $endtime-time(); |
|
524 | + } |
|
401 | 525 | // Delete old ATC |
402 | 526 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
403 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
527 | + if ($globalDebug) { |
|
528 | + echo 'Delete old ATC...'."\n"; |
|
529 | + } |
|
404 | 530 | $ATC->deleteOldATC(); |
405 | 531 | } |
406 | 532 | |
407 | 533 | if (count($last_exec) == count($globalSources)) { |
408 | 534 | $max = $globalMinFetch; |
409 | 535 | foreach ($last_exec as $last) { |
410 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
536 | + if ((time() - $last['last']) < $max) { |
|
537 | + $max = time() - $last['last']; |
|
538 | + } |
|
411 | 539 | } |
412 | 540 | if ($max != $globalMinFetch) { |
413 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
541 | + if ($globalDebug) { |
|
542 | + echo 'Sleeping...'."\n"; |
|
543 | + } |
|
414 | 544 | sleep($globalMinFetch-$max+2); |
415 | 545 | } |
416 | 546 | } |
@@ -420,7 +550,9 @@ discard block |
||
420 | 550 | foreach ($globalSources as $id => $value) { |
421 | 551 | date_default_timezone_set('UTC'); |
422 | 552 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
423 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
553 | + if (!isset($last_exec[$id]['last'])) { |
|
554 | + $last_exec[$id]['last'] = 0; |
|
555 | + } |
|
424 | 556 | if ($value['format'] == 'deltadbtxt' && |
425 | 557 | ( |
426 | 558 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -429,7 +561,9 @@ discard block |
||
429 | 561 | ) { |
430 | 562 | //$buffer = $Common->getData($hosts[$id]); |
431 | 563 | $buffer = $Common->getData($value['host']); |
432 | - if ($buffer != '') $reset = 0; |
|
564 | + if ($buffer != '') { |
|
565 | + $reset = 0; |
|
566 | + } |
|
433 | 567 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
434 | 568 | $buffer = explode('\n',$buffer); |
435 | 569 | foreach ($buffer as $line) { |
@@ -438,20 +572,41 @@ discard block |
||
438 | 572 | $data = array(); |
439 | 573 | $data['hex'] = $line[1]; // hex |
440 | 574 | $data['ident'] = $line[2]; // ident |
441 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
442 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
443 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
444 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
445 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
575 | + if (isset($line[3])) { |
|
576 | + $data['altitude'] = $line[3]; |
|
577 | + } |
|
578 | + // altitude |
|
579 | + if (isset($line[4])) { |
|
580 | + $data['speed'] = $line[4]; |
|
581 | + } |
|
582 | + // speed |
|
583 | + if (isset($line[5])) { |
|
584 | + $data['heading'] = $line[5]; |
|
585 | + } |
|
586 | + // heading |
|
587 | + if (isset($line[6])) { |
|
588 | + $data['latitude'] = $line[6]; |
|
589 | + } |
|
590 | + // lat |
|
591 | + if (isset($line[7])) { |
|
592 | + $data['longitude'] = $line[7]; |
|
593 | + } |
|
594 | + // long |
|
446 | 595 | $data['verticalrate'] = ''; // vertical rate |
447 | 596 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
448 | 597 | $data['emergency'] = ''; // emergency |
449 | 598 | $data['datetime'] = date('Y-m-d H:i:s'); |
450 | 599 | $data['format_source'] = 'deltadbtxt'; |
451 | 600 | $data['id_source'] = $id_source; |
452 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
453 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
454 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
601 | + if (isset($value['name']) && $value['name'] != '') { |
|
602 | + $data['source_name'] = $value['name']; |
|
603 | + } |
|
604 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
605 | + $data['noarchive'] = true; |
|
606 | + } |
|
607 | + if (isset($value['sourcestats'])) { |
|
608 | + $data['sourcestats'] = $value['sourcestats']; |
|
609 | + } |
|
455 | 610 | $SI->add($data); |
456 | 611 | unset($data); |
457 | 612 | } |
@@ -466,7 +621,9 @@ discard block |
||
466 | 621 | date_default_timezone_set('CET'); |
467 | 622 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
468 | 623 | date_default_timezone_set('UTC'); |
469 | - if ($buffer != '') $reset = 0; |
|
624 | + if ($buffer != '') { |
|
625 | + $reset = 0; |
|
626 | + } |
|
470 | 627 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
471 | 628 | $buffer = explode('\n',$buffer); |
472 | 629 | foreach ($buffer as $line) { |
@@ -475,18 +632,42 @@ discard block |
||
475 | 632 | $add = false; |
476 | 633 | $ais_data = $AIS->parse_line(trim($line)); |
477 | 634 | $data = array(); |
478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
485 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
486 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
487 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
488 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
489 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
635 | + if (isset($ais_data['ident'])) { |
|
636 | + $data['ident'] = $ais_data['ident']; |
|
637 | + } |
|
638 | + if (isset($ais_data['mmsi'])) { |
|
639 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
640 | + } |
|
641 | + if (isset($ais_data['speed'])) { |
|
642 | + $data['speed'] = $ais_data['speed']; |
|
643 | + } |
|
644 | + if (isset($ais_data['heading'])) { |
|
645 | + $data['heading'] = $ais_data['heading']; |
|
646 | + } |
|
647 | + if (isset($ais_data['latitude'])) { |
|
648 | + $data['latitude'] = $ais_data['latitude']; |
|
649 | + } |
|
650 | + if (isset($ais_data['longitude'])) { |
|
651 | + $data['longitude'] = $ais_data['longitude']; |
|
652 | + } |
|
653 | + if (isset($ais_data['status'])) { |
|
654 | + $data['status'] = $ais_data['status']; |
|
655 | + } |
|
656 | + if (isset($ais_data['statusid'])) { |
|
657 | + $data['status_id'] = $ais_data['statusid']; |
|
658 | + } |
|
659 | + if (isset($ais_data['type'])) { |
|
660 | + $data['type'] = $ais_data['type']; |
|
661 | + } |
|
662 | + if (isset($ais_data['typeid'])) { |
|
663 | + $data['type_id'] = $ais_data['typeid']; |
|
664 | + } |
|
665 | + if (isset($ais_data['imo'])) { |
|
666 | + $data['imo'] = $ais_data['imo']; |
|
667 | + } |
|
668 | + if (isset($ais_data['callsign'])) { |
|
669 | + $data['callsign'] = $ais_data['callsign']; |
|
670 | + } |
|
490 | 671 | if (isset($ais_data['timestamp'])) { |
491 | 672 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
492 | 673 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -500,8 +681,12 @@ discard block |
||
500 | 681 | $data['format_source'] = 'aisnmeatxt'; |
501 | 682 | $data['id_source'] = $id_source; |
502 | 683 | //print_r($data); |
503 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
504 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
684 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
685 | + $data['noarchive'] = true; |
|
686 | + } |
|
687 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
688 | + $MI->add($data); |
|
689 | + } |
|
505 | 690 | unset($data); |
506 | 691 | } |
507 | 692 | } |
@@ -524,20 +709,48 @@ discard block |
||
524 | 709 | if ($line != '') { |
525 | 710 | $ais_data = $AIS->parse_line(trim($line)); |
526 | 711 | $data = array(); |
527 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
528 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
529 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
530 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
531 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
532 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
533 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
534 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
535 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
536 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
537 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
538 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
539 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
540 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
712 | + if (isset($ais_data['ident'])) { |
|
713 | + $data['ident'] = $ais_data['ident']; |
|
714 | + } |
|
715 | + if (isset($ais_data['mmsi'])) { |
|
716 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
717 | + } |
|
718 | + if (isset($ais_data['speed'])) { |
|
719 | + $data['speed'] = $ais_data['speed']; |
|
720 | + } |
|
721 | + if (isset($ais_data['heading'])) { |
|
722 | + $data['heading'] = $ais_data['heading']; |
|
723 | + } |
|
724 | + if (isset($ais_data['latitude'])) { |
|
725 | + $data['latitude'] = $ais_data['latitude']; |
|
726 | + } |
|
727 | + if (isset($ais_data['longitude'])) { |
|
728 | + $data['longitude'] = $ais_data['longitude']; |
|
729 | + } |
|
730 | + if (isset($ais_data['status'])) { |
|
731 | + $data['status'] = $ais_data['status']; |
|
732 | + } |
|
733 | + if (isset($ais_data['statusid'])) { |
|
734 | + $data['status_id'] = $ais_data['statusid']; |
|
735 | + } |
|
736 | + if (isset($ais_data['type'])) { |
|
737 | + $data['type'] = $ais_data['type']; |
|
738 | + } |
|
739 | + if (isset($ais_data['typeid'])) { |
|
740 | + $data['type_id'] = $ais_data['typeid']; |
|
741 | + } |
|
742 | + if (isset($ais_data['imo'])) { |
|
743 | + $data['imo'] = $ais_data['imo']; |
|
744 | + } |
|
745 | + if (isset($ais_data['callsign'])) { |
|
746 | + $data['callsign'] = $ais_data['callsign']; |
|
747 | + } |
|
748 | + if (isset($ais_data['destination'])) { |
|
749 | + $data['arrival_code'] = $ais_data['destination']; |
|
750 | + } |
|
751 | + if (isset($ais_data['eta_ts'])) { |
|
752 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
753 | + } |
|
541 | 754 | if (isset($ais_data['timestamp'])) { |
542 | 755 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
543 | 756 | } else { |
@@ -545,18 +758,27 @@ discard block |
||
545 | 758 | } |
546 | 759 | $data['format_source'] = 'aisnmeahttp'; |
547 | 760 | $data['id_source'] = $id_source; |
548 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
549 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
761 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
762 | + $data['noarchive'] = true; |
|
763 | + } |
|
764 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
765 | + $MI->add($data); |
|
766 | + } |
|
550 | 767 | unset($data); |
551 | 768 | } |
552 | 769 | } |
553 | 770 | } |
554 | 771 | } else { |
555 | 772 | $format = $value['format']; |
556 | - if (isset($tt[$format])) $tt[$format]++; |
|
557 | - else $tt[$format] = 0; |
|
773 | + if (isset($tt[$format])) { |
|
774 | + $tt[$format]++; |
|
775 | + } else { |
|
776 | + $tt[$format] = 0; |
|
777 | + } |
|
558 | 778 | if ($tt[$format] > 30) { |
559 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
779 | + if ($globalDebug) { |
|
780 | + echo 'Reconnect...'."\n"; |
|
781 | + } |
|
560 | 782 | sleep(2); |
561 | 783 | //$sourceeen[] = $value; |
562 | 784 | //connect_all($sourceeen); |
@@ -592,12 +814,18 @@ discard block |
||
592 | 814 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
593 | 815 | //$data['type_id'] = $line['TYPE']; |
594 | 816 | $data['imo'] = $line['IMO']; |
595 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
596 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
817 | + if ($line['DEST'] != '') { |
|
818 | + $data['arrival_code'] = $line['DEST']; |
|
819 | + } |
|
820 | + if ($line['ARV'] != '') { |
|
821 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
822 | + } |
|
597 | 823 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
598 | 824 | $data['format_source'] = 'myshiptracking'; |
599 | 825 | $data['id_source'] = $id_source; |
600 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
826 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
827 | + $data['noarchive'] = true; |
|
828 | + } |
|
601 | 829 | $MI->add($data); |
602 | 830 | unset($data); |
603 | 831 | } |
@@ -622,7 +850,9 @@ discard block |
||
622 | 850 | $data['callsign'] = $line['callsign']; |
623 | 851 | $data['mmsi'] = substr($line['mmsi'],-9); |
624 | 852 | $data['speed'] = $line['sog']; |
625 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
853 | + if ($line['heading'] != '511') { |
|
854 | + $data['heading'] = $line['heading']; |
|
855 | + } |
|
626 | 856 | $data['latitude'] = $line['latitude']; |
627 | 857 | $data['longitude'] = $line['longitude']; |
628 | 858 | $data['type_id'] = $line['shiptype']; |
@@ -630,7 +860,9 @@ discard block |
||
630 | 860 | $data['datetime'] = $line['time']; |
631 | 861 | $data['format_source'] = 'boatbeaconapp'; |
632 | 862 | $data['id_source'] = $id_source; |
633 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
863 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
864 | + $data['noarchive'] = true; |
|
865 | + } |
|
634 | 866 | $MI->add($data); |
635 | 867 | unset($data); |
636 | 868 | } |
@@ -652,22 +884,44 @@ discard block |
||
652 | 884 | foreach ($all_data['features'] as $line) { |
653 | 885 | print_r($line); |
654 | 886 | $data = array(); |
655 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
656 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
657 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
658 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
659 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
660 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
887 | + if (isset($line['properties']['name'])) { |
|
888 | + $data['ident'] = $line['properties']['name']; |
|
889 | + } |
|
890 | + if (isset($line['properties']['callsign'])) { |
|
891 | + $data['callsign'] = $line['properties']['callsign']; |
|
892 | + } |
|
893 | + if (isset($line['properties']['mmsi'])) { |
|
894 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
895 | + } |
|
896 | + if (isset($line['properties']['imo'])) { |
|
897 | + $data['imo'] = $line['properties']['imo']; |
|
898 | + } |
|
899 | + if (isset($line['properties']['speed'])) { |
|
900 | + $data['speed'] = $line['properties']['speed']; |
|
901 | + } |
|
902 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
903 | + $data['heading'] = $line['properties']['heading']; |
|
904 | + } |
|
661 | 905 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
662 | 906 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
663 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
664 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
665 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
907 | + if (isset($line['properties']['vesselType'])) { |
|
908 | + $data['type'] = $line['properties']['vesselType']; |
|
909 | + } |
|
910 | + if (isset($line['properties']['destination'])) { |
|
911 | + $data['arrival_code'] = $line['properties']['destination']; |
|
912 | + } |
|
913 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
914 | + $data['arrival_date'] = $line['properties']['eta']; |
|
915 | + } |
|
666 | 916 | $data['format_source'] = 'boatnerd'; |
667 | 917 | $data['id_source'] = $id_source; |
668 | 918 | $data['datetime'] = date('Y-m-d H:i:s'); |
669 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
670 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
919 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
920 | + $data['noarchive'] = true; |
|
921 | + } |
|
922 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
923 | + $MI->add($data); |
|
924 | + } |
|
671 | 925 | unset($data); |
672 | 926 | } |
673 | 927 | } |
@@ -684,7 +938,9 @@ discard block |
||
684 | 938 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
685 | 939 | echo 'done !'."\n"; |
686 | 940 | // FIXME: Need more work |
687 | - if ($buffer != '') $reset = 0; |
|
941 | + if ($buffer != '') { |
|
942 | + $reset = 0; |
|
943 | + } |
|
688 | 944 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
689 | 945 | $buffer = explode('\n',$buffer); |
690 | 946 | foreach ($buffer as $line) { |
@@ -710,7 +966,9 @@ discard block |
||
710 | 966 | //$data['etaTime'] = substr($line,135,5); |
711 | 967 | $data['format_source'] = 'shipplotter'; |
712 | 968 | $data['id_source'] = $id_source; |
713 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
969 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
970 | + $data['noarchive'] = true; |
|
971 | + } |
|
714 | 972 | //print_r($data); |
715 | 973 | echo 'Add...'."\n"; |
716 | 974 | $MI->add($data); |
@@ -744,16 +1002,28 @@ discard block |
||
744 | 1002 | $line = explode(':', $line); |
745 | 1003 | if (count($line) > 30 && $line[0] != 'callsign') { |
746 | 1004 | $data = array(); |
747 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
748 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1005 | + if (isset($line[37]) && $line[37] != '') { |
|
1006 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1007 | + } else { |
|
1008 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1009 | + } |
|
749 | 1010 | $data['pilot_id'] = $line[1]; |
750 | 1011 | $data['pilot_name'] = $line[2]; |
751 | 1012 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
752 | 1013 | $data['ident'] = $line[0]; // ident |
753 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1014 | + if ($line[7] != '' && $line[7] != 0) { |
|
1015 | + $data['altitude'] = $line[7]; |
|
1016 | + } |
|
1017 | + // altitude |
|
754 | 1018 | $data['speed'] = $line[8]; // speed |
755 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
756 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1019 | + if (isset($line[45])) { |
|
1020 | + $data['heading'] = $line[45]; |
|
1021 | + } |
|
1022 | + // heading |
|
1023 | + elseif (isset($line[38])) { |
|
1024 | + $data['heading'] = $line[38]; |
|
1025 | + } |
|
1026 | + // heading |
|
757 | 1027 | $data['latitude'] = $line[5]; // lat |
758 | 1028 | $data['longitude'] = $line[6]; // long |
759 | 1029 | $data['verticalrate'] = ''; // vertical rate |
@@ -769,7 +1039,9 @@ discard block |
||
769 | 1039 | $data['frequency'] = $line[4]; |
770 | 1040 | $data['type'] = $line[18]; |
771 | 1041 | $data['range'] = $line[19]; |
772 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1042 | + if (isset($line[35])) { |
|
1043 | + $data['info'] = $line[35]; |
|
1044 | + } |
|
773 | 1045 | $data['id_source'] = $id_source; |
774 | 1046 | //$data['arrival_airport_time'] = ; |
775 | 1047 | if ($line[9] != '') { |
@@ -783,27 +1055,47 @@ discard block |
||
783 | 1055 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
784 | 1056 | */ |
785 | 1057 | $data['format_source'] = $value['format']; |
786 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
787 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
788 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
789 | - elseif ($line[3] == 'ATC') { |
|
1058 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1059 | + $data['noarchive'] = true; |
|
1060 | + } |
|
1061 | + if (isset($value['name']) && $value['name'] != '') { |
|
1062 | + $data['source_name'] = $value['name']; |
|
1063 | + } |
|
1064 | + if ($line[3] == 'PILOT') { |
|
1065 | + $SI->add($data); |
|
1066 | + } elseif ($line[3] == 'ATC') { |
|
790 | 1067 | //print_r($data); |
791 | 1068 | $data['info'] = str_replace('^§','<br />',$data['info']); |
792 | 1069 | $data['info'] = str_replace('&sect;','',$data['info']); |
793 | 1070 | $typec = substr($data['ident'],-3); |
794 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
795 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
796 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
797 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
798 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
799 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
800 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
801 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
802 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
803 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1071 | + if ($typec == 'APP') { |
|
1072 | + $data['type'] = 'Approach'; |
|
1073 | + } elseif ($typec == 'TWR') { |
|
1074 | + $data['type'] = 'Tower'; |
|
1075 | + } elseif ($typec == 'OBS') { |
|
1076 | + $data['type'] = 'Observer'; |
|
1077 | + } elseif ($typec == 'GND') { |
|
1078 | + $data['type'] = 'Ground'; |
|
1079 | + } elseif ($typec == 'DEL') { |
|
1080 | + $data['type'] = 'Delivery'; |
|
1081 | + } elseif ($typec == 'DEP') { |
|
1082 | + $data['type'] = 'Departure'; |
|
1083 | + } elseif ($typec == 'FSS') { |
|
1084 | + $data['type'] = 'Flight Service Station'; |
|
1085 | + } elseif ($typec == 'CTR') { |
|
1086 | + $data['type'] = 'Control Radar or Centre'; |
|
1087 | + } elseif ($data['type'] == '') { |
|
1088 | + $data['type'] = 'Observer'; |
|
1089 | + } |
|
1090 | + if (!isset($data['source_name'])) { |
|
1091 | + $data['source_name'] = ''; |
|
1092 | + } |
|
804 | 1093 | if (isset($ATC)) { |
805 | - 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']); |
|
806 | - 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']); |
|
1094 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1095 | + 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']); |
|
1096 | + } else { |
|
1097 | + 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']); |
|
1098 | + } |
|
807 | 1099 | } |
808 | 1100 | } |
809 | 1101 | unset($data); |
@@ -830,14 +1122,20 @@ discard block |
||
830 | 1122 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
831 | 1123 | $data['latitude'] = (float)$line['pktLatitude']; |
832 | 1124 | $data['longitude'] = (float)$line['pktLongitude']; |
833 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
834 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1125 | + if ((float)$line['pktTrack'] != 0) { |
|
1126 | + $data['heading'] = (float)$line['pktTrack']; |
|
1127 | + } |
|
1128 | + if ((int)$line['pktSpeed'] != 0) { |
|
1129 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1130 | + } |
|
835 | 1131 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
836 | 1132 | $data['altitude_relative'] = 'AMSL'; |
837 | 1133 | $data['pilot_id'] = (int)$line['pktPilotID']; |
838 | 1134 | $data['aircraft_icao'] = 'PARAGLIDER'; |
839 | 1135 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
840 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1136 | + if (isset($pilot_data[4])) { |
|
1137 | + $data['pilot_name'] = $pilot_data[4]; |
|
1138 | + } |
|
841 | 1139 | $data['format_source'] = $value['format']; |
842 | 1140 | $SI->add($data); |
843 | 1141 | unset($data); |
@@ -885,25 +1183,59 @@ discard block |
||
885 | 1183 | foreach ($all_data['acList'] as $line) { |
886 | 1184 | $data = array(); |
887 | 1185 | $data['hex'] = $line['Icao']; // hex |
888 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
889 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
890 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
891 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
892 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
893 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1186 | + if (isset($line['Call'])) { |
|
1187 | + $data['ident'] = $line['Call']; |
|
1188 | + } |
|
1189 | + // ident |
|
1190 | + if (isset($line['Alt'])) { |
|
1191 | + $data['altitude'] = $line['Alt']; |
|
1192 | + } |
|
1193 | + // altitude |
|
1194 | + if (isset($line['Spd'])) { |
|
1195 | + $data['speed'] = $line['Spd']; |
|
1196 | + } |
|
1197 | + // speed |
|
1198 | + if (isset($line['Trak'])) { |
|
1199 | + $data['heading'] = $line['Trak']; |
|
1200 | + } |
|
1201 | + // heading |
|
1202 | + if (isset($line['Lat'])) { |
|
1203 | + $data['latitude'] = $line['Lat']; |
|
1204 | + } |
|
1205 | + // lat |
|
1206 | + if (isset($line['Long'])) { |
|
1207 | + $data['longitude'] = $line['Long']; |
|
1208 | + } |
|
1209 | + // long |
|
894 | 1210 | //$data['verticalrate'] = $line['']; // verticale rate |
895 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1211 | + if (isset($line['Sqk'])) { |
|
1212 | + $data['squawk'] = $line['Sqk']; |
|
1213 | + } |
|
1214 | + // squawk |
|
896 | 1215 | $data['emergency'] = ''; // emergency |
897 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
898 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
899 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1216 | + if (isset($line['Reg'])) { |
|
1217 | + $data['registration'] = $line['Reg']; |
|
1218 | + } |
|
1219 | + if (isset($line['PosTime'])) { |
|
1220 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1221 | + } else { |
|
1222 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1223 | + } |
|
900 | 1224 | //$data['datetime'] = date('Y-m-d H:i:s'); |
901 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1225 | + if (isset($line['Type'])) { |
|
1226 | + $data['aircraft_icao'] = $line['Type']; |
|
1227 | + } |
|
902 | 1228 | $data['format_source'] = 'aircraftlistjson'; |
903 | 1229 | $data['id_source'] = $id_source; |
904 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
906 | - if (isset($data['latitude'])) $SI->add($data); |
|
1230 | + if (isset($value['name']) && $value['name'] != '') { |
|
1231 | + $data['source_name'] = $value['name']; |
|
1232 | + } |
|
1233 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1234 | + $data['noarchive'] = true; |
|
1235 | + } |
|
1236 | + if (isset($data['latitude'])) { |
|
1237 | + $SI->add($data); |
|
1238 | + } |
|
907 | 1239 | unset($data); |
908 | 1240 | } |
909 | 1241 | } elseif (is_array($all_data)) { |
@@ -920,17 +1252,26 @@ discard block |
||
920 | 1252 | $data['verticalrate'] = $line['vrt']; // verticale rate |
921 | 1253 | $data['squawk'] = $line['squawk']; // squawk |
922 | 1254 | $data['emergency'] = ''; // emergency |
923 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
924 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1255 | + if (isset($line['PosTime'])) { |
|
1256 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1257 | + } else { |
|
1258 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1259 | + } |
|
925 | 1260 | $data['format_source'] = 'aircraftlistjson'; |
926 | 1261 | $data['id_source'] = $id_source; |
927 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
928 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1262 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1263 | + $data['noarchive'] = true; |
|
1264 | + } |
|
1265 | + if (isset($value['name']) && $value['name'] != '') { |
|
1266 | + $data['source_name'] = $value['name']; |
|
1267 | + } |
|
929 | 1268 | $SI->add($data); |
930 | 1269 | unset($data); |
931 | 1270 | } |
932 | 1271 | } |
933 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1272 | + } elseif ($globalDebug) { |
|
1273 | + echo 'No data'."\n"; |
|
1274 | + } |
|
934 | 1275 | //$last_exec['aircraftlistjson'] = time(); |
935 | 1276 | $last_exec[$id]['last'] = time(); |
936 | 1277 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -966,8 +1307,12 @@ discard block |
||
966 | 1307 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
967 | 1308 | $data['format_source'] = 'planeupdatefaa'; |
968 | 1309 | $data['id_source'] = $id_source; |
969 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
970 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1310 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1311 | + $data['noarchive'] = true; |
|
1312 | + } |
|
1313 | + if (isset($value['name']) && $value['name'] != '') { |
|
1314 | + $data['source_name'] = $value['name']; |
|
1315 | + } |
|
971 | 1316 | $SI->add($data); |
972 | 1317 | unset($data); |
973 | 1318 | } |
@@ -1001,7 +1346,9 @@ discard block |
||
1001 | 1346 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1002 | 1347 | $data['format_source'] = 'opensky'; |
1003 | 1348 | $data['id_source'] = $id_source; |
1004 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1349 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1350 | + $data['noarchive'] = true; |
|
1351 | + } |
|
1005 | 1352 | $SI->add($data); |
1006 | 1353 | unset($data); |
1007 | 1354 | } |
@@ -1018,7 +1365,9 @@ discard block |
||
1018 | 1365 | //$buffer = $Common->getData($hosts[$id]); |
1019 | 1366 | $buffer = $Common->getData($value['host']); |
1020 | 1367 | $all_data = json_decode($buffer,true); |
1021 | - if (!empty($all_data)) $reset = 0; |
|
1368 | + if (!empty($all_data)) { |
|
1369 | + $reset = 0; |
|
1370 | + } |
|
1022 | 1371 | foreach ($all_data as $key => $line) { |
1023 | 1372 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1024 | 1373 | $data = array(); |
@@ -1039,8 +1388,12 @@ discard block |
||
1039 | 1388 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1040 | 1389 | $data['format_source'] = 'fr24json'; |
1041 | 1390 | $data['id_source'] = $id_source; |
1042 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1043 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1391 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1392 | + $data['noarchive'] = true; |
|
1393 | + } |
|
1394 | + if (isset($value['name']) && $value['name'] != '') { |
|
1395 | + $data['source_name'] = $value['name']; |
|
1396 | + } |
|
1044 | 1397 | $SI->add($data); |
1045 | 1398 | unset($data); |
1046 | 1399 | } |
@@ -1069,24 +1422,42 @@ discard block |
||
1069 | 1422 | if (isset($line['inf'])) { |
1070 | 1423 | $data = array(); |
1071 | 1424 | $data['hex'] = $line['inf']['ia']; |
1072 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1425 | + if (isset($line['inf']['cs'])) { |
|
1426 | + $data['ident'] = $line['inf']['cs']; |
|
1427 | + } |
|
1428 | + //$line[13] |
|
1073 | 1429 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1074 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1075 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1430 | + if (isset($line['inf']['gs'])) { |
|
1431 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1432 | + } |
|
1433 | + // speed |
|
1434 | + if (isset($line['inf']['tr'])) { |
|
1435 | + $data['heading'] = $line['inf']['tr']; |
|
1436 | + } |
|
1437 | + // heading |
|
1076 | 1438 | $data['latitude'] = $line['pt'][0]; // lat |
1077 | 1439 | $data['longitude'] = $line['pt'][1]; // long |
1078 | 1440 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1079 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1441 | + if (isset($line['inf']['sq'])) { |
|
1442 | + $data['squawk'] = $line['inf']['sq']; |
|
1443 | + } |
|
1444 | + // squawk |
|
1080 | 1445 | //$data['aircraft_icao'] = $line[8]; |
1081 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1446 | + if (isset($line['inf']['rc'])) { |
|
1447 | + $data['registration'] = $line['inf']['rc']; |
|
1448 | + } |
|
1082 | 1449 | //$data['departure_airport_iata'] = $line[11]; |
1083 | 1450 | //$data['arrival_airport_iata'] = $line[12]; |
1084 | 1451 | //$data['emergency'] = ''; // emergency |
1085 | 1452 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1086 | 1453 | $data['format_source'] = 'radarvirtueljson'; |
1087 | 1454 | $data['id_source'] = $id_source; |
1088 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1089 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1455 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1456 | + $data['noarchive'] = true; |
|
1457 | + } |
|
1458 | + if (isset($value['name']) && $value['name'] != '') { |
|
1459 | + $data['source_name'] = $value['name']; |
|
1460 | + } |
|
1090 | 1461 | $SI->add($data); |
1091 | 1462 | unset($data); |
1092 | 1463 | } |
@@ -1112,30 +1483,65 @@ discard block |
||
1112 | 1483 | $data['id'] = $line['id']; |
1113 | 1484 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1114 | 1485 | $data['ident'] = $line['callsign']; // ident |
1115 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1116 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1117 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1118 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1119 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1120 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1486 | + if (isset($line['pilotid'])) { |
|
1487 | + $data['pilot_id'] = $line['pilotid']; |
|
1488 | + } |
|
1489 | + // pilot id |
|
1490 | + if (isset($line['name'])) { |
|
1491 | + $data['pilot_name'] = $line['name']; |
|
1492 | + } |
|
1493 | + // pilot name |
|
1494 | + if (isset($line['alt'])) { |
|
1495 | + $data['altitude'] = $line['alt']; |
|
1496 | + } |
|
1497 | + // altitude |
|
1498 | + if (isset($line['gs'])) { |
|
1499 | + $data['speed'] = $line['gs']; |
|
1500 | + } |
|
1501 | + // speed |
|
1502 | + if (isset($line['heading'])) { |
|
1503 | + $data['heading'] = $line['heading']; |
|
1504 | + } |
|
1505 | + // heading |
|
1506 | + if (isset($line['route'])) { |
|
1507 | + $data['waypoints'] = $line['route']; |
|
1508 | + } |
|
1509 | + // route |
|
1121 | 1510 | $data['latitude'] = $line['lat']; // lat |
1122 | 1511 | $data['longitude'] = $line['lon']; // long |
1123 | 1512 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1124 | 1513 | //$data['squawk'] = $line['squawk']; // squawk |
1125 | 1514 | //$data['emergency'] = ''; // emergency |
1126 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1127 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1128 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1515 | + if (isset($line['depicao'])) { |
|
1516 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1517 | + } |
|
1518 | + if (isset($line['deptime'])) { |
|
1519 | + $data['departure_airport_time'] = $line['deptime']; |
|
1520 | + } |
|
1521 | + if (isset($line['arricao'])) { |
|
1522 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1523 | + } |
|
1129 | 1524 | //$data['arrival_airport_time'] = $line['arrtime']; |
1130 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1131 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1132 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1133 | - else $data['info'] = ''; |
|
1525 | + if (isset($line['aircraft'])) { |
|
1526 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1527 | + } |
|
1528 | + if (isset($line['transponder'])) { |
|
1529 | + $data['squawk'] = $line['transponder']; |
|
1530 | + } |
|
1531 | + if (isset($line['atis'])) { |
|
1532 | + $data['info'] = $line['atis']; |
|
1533 | + } else { |
|
1534 | + $data['info'] = ''; |
|
1535 | + } |
|
1134 | 1536 | $data['format_source'] = 'pireps'; |
1135 | 1537 | $data['id_source'] = $id_source; |
1136 | 1538 | $data['datetime'] = date('Y-m-d H:i:s'); |
1137 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1138 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1539 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1540 | + $data['noarchive'] = true; |
|
1541 | + } |
|
1542 | + if (isset($value['name']) && $value['name'] != '') { |
|
1543 | + $data['source_name'] = $value['name']; |
|
1544 | + } |
|
1139 | 1545 | if ($line['icon'] == 'plane') { |
1140 | 1546 | $SI->add($data); |
1141 | 1547 | // print_r($data); |
@@ -1144,16 +1550,28 @@ discard block |
||
1144 | 1550 | $data['info'] = str_replace('&sect;','',$data['info']); |
1145 | 1551 | $typec = substr($data['ident'],-3); |
1146 | 1552 | $data['type'] = ''; |
1147 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
1148 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
1149 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
1150 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
1151 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
1152 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
1153 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
1154 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1155 | - else $data['type'] = 'Observer'; |
|
1156 | - 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']); |
|
1553 | + if ($typec == 'APP') { |
|
1554 | + $data['type'] = 'Approach'; |
|
1555 | + } elseif ($typec == 'TWR') { |
|
1556 | + $data['type'] = 'Tower'; |
|
1557 | + } elseif ($typec == 'OBS') { |
|
1558 | + $data['type'] = 'Observer'; |
|
1559 | + } elseif ($typec == 'GND') { |
|
1560 | + $data['type'] = 'Ground'; |
|
1561 | + } elseif ($typec == 'DEL') { |
|
1562 | + $data['type'] = 'Delivery'; |
|
1563 | + } elseif ($typec == 'DEP') { |
|
1564 | + $data['type'] = 'Departure'; |
|
1565 | + } elseif ($typec == 'FSS') { |
|
1566 | + $data['type'] = 'Flight Service Station'; |
|
1567 | + } elseif ($typec == 'CTR') { |
|
1568 | + $data['type'] = 'Control Radar or Centre'; |
|
1569 | + } else { |
|
1570 | + $data['type'] = 'Observer'; |
|
1571 | + } |
|
1572 | + if (isset($ATC)) { |
|
1573 | + 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']); |
|
1574 | + } |
|
1157 | 1575 | } |
1158 | 1576 | unset($data); |
1159 | 1577 | } |
@@ -1168,7 +1586,9 @@ discard block |
||
1168 | 1586 | ) |
1169 | 1587 | ) { |
1170 | 1588 | //$buffer = $Common->getData($hosts[$id]); |
1171 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1589 | + if ($globalDebug) { |
|
1590 | + echo 'Get Data...'."\n"; |
|
1591 | + } |
|
1172 | 1592 | $buffer = $Common->getData($value['host']); |
1173 | 1593 | $all_data = json_decode($buffer,true); |
1174 | 1594 | if ($buffer != '' && is_array($all_data)) { |
@@ -1176,10 +1596,16 @@ discard block |
||
1176 | 1596 | foreach ($all_data as $line) { |
1177 | 1597 | $data = array(); |
1178 | 1598 | //$data['id'] = $line['id']; // id not usable |
1179 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1599 | + if (isset($line['pilotid'])) { |
|
1600 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1601 | + } |
|
1180 | 1602 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1181 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1182 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1603 | + if (isset($line['pilotname'])) { |
|
1604 | + $data['pilot_name'] = $line['pilotname']; |
|
1605 | + } |
|
1606 | + if (isset($line['pilotid'])) { |
|
1607 | + $data['pilot_id'] = $line['pilotid']; |
|
1608 | + } |
|
1183 | 1609 | $data['ident'] = $line['flightnum']; // ident |
1184 | 1610 | $data['altitude'] = $line['alt']; // altitude |
1185 | 1611 | $data['speed'] = $line['gs']; // speed |
@@ -1195,7 +1621,9 @@ discard block |
||
1195 | 1621 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1196 | 1622 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1197 | 1623 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1198 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1624 | + } else { |
|
1625 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1626 | + } |
|
1199 | 1627 | $data['departure_airport_icao'] = $line['depicao']; |
1200 | 1628 | $data['departure_airport_time'] = $line['deptime']; |
1201 | 1629 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1203,29 +1631,47 @@ discard block |
||
1203 | 1631 | if (isset($line['registration'])) { |
1204 | 1632 | $data['registration'] = $line['registration']; |
1205 | 1633 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1206 | - } else $data['registration'] = $line['aircraft']; |
|
1207 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1208 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1634 | + } else { |
|
1635 | + $data['registration'] = $line['aircraft']; |
|
1636 | + } |
|
1637 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1638 | + $data['noarchive'] = true; |
|
1639 | + } |
|
1640 | + if (isset($line['route'])) { |
|
1641 | + $data['waypoints'] = $line['route']; |
|
1642 | + } |
|
1643 | + // route |
|
1209 | 1644 | if (isset($line['aircraftname'])) { |
1210 | 1645 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1211 | 1646 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1212 | 1647 | $aircraft_data = explode('-',$line['aircraftname']); |
1213 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1214 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1215 | - else { |
|
1648 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1649 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1650 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1651 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1652 | + } else { |
|
1216 | 1653 | $aircraft_data = explode(' ',$line['aircraftname']); |
1217 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1218 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1654 | + if (isset($aircraft_data[1])) { |
|
1655 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1656 | + } else { |
|
1657 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1658 | + } |
|
1219 | 1659 | } |
1220 | 1660 | } |
1221 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1661 | + if (isset($line['route'])) { |
|
1662 | + $data['waypoints'] = $line['route']; |
|
1663 | + } |
|
1222 | 1664 | $data['id_source'] = $id_source; |
1223 | 1665 | $data['format_source'] = 'phpvmacars'; |
1224 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1666 | + if (isset($value['name']) && $value['name'] != '') { |
|
1667 | + $data['source_name'] = $value['name']; |
|
1668 | + } |
|
1225 | 1669 | $SI->add($data); |
1226 | 1670 | unset($data); |
1227 | 1671 | } |
1228 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1672 | + if ($globalDebug) { |
|
1673 | + echo 'No more data...'."\n"; |
|
1674 | + } |
|
1229 | 1675 | unset($buffer); |
1230 | 1676 | unset($all_data); |
1231 | 1677 | } |
@@ -1238,7 +1684,9 @@ discard block |
||
1238 | 1684 | ) |
1239 | 1685 | ) { |
1240 | 1686 | //$buffer = $Common->getData($hosts[$id]); |
1241 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1687 | + if ($globalDebug) { |
|
1688 | + echo 'Get Data...'."\n"; |
|
1689 | + } |
|
1242 | 1690 | $buffer = $Common->getData($value['host']); |
1243 | 1691 | $all_data = json_decode($buffer,true); |
1244 | 1692 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1249,10 +1697,16 @@ discard block |
||
1249 | 1697 | //$data['id'] = $line['id']; // id not usable |
1250 | 1698 | $data['id'] = $line['id']; |
1251 | 1699 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1252 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1253 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1700 | + if (isset($line['user']['username'])) { |
|
1701 | + $data['pilot_name'] = $line['user']['username']; |
|
1702 | + } |
|
1703 | + if (isset($line['user_id'])) { |
|
1704 | + $data['pilot_id'] = $line['user_id']; |
|
1705 | + } |
|
1254 | 1706 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1255 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1707 | + if (is_numeric($data['ident'])) { |
|
1708 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1709 | + } |
|
1256 | 1710 | $data['altitude'] = $line['altitude']; // altitude |
1257 | 1711 | $data['speed'] = $line['groundspeed']; // speed |
1258 | 1712 | $data['heading'] = $line['heading']; // heading |
@@ -1265,7 +1719,9 @@ discard block |
||
1265 | 1719 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1266 | 1720 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1267 | 1721 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1268 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1722 | + } else { |
|
1723 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1724 | + } |
|
1269 | 1725 | |
1270 | 1726 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1271 | 1727 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1273,17 +1729,26 @@ discard block |
||
1273 | 1729 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1274 | 1730 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1275 | 1731 | |
1276 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1277 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1732 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1733 | + $data['noarchive'] = true; |
|
1734 | + } |
|
1735 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
1736 | + $data['waypoints'] = $line['bid']['route']; |
|
1737 | + } |
|
1738 | + // route |
|
1278 | 1739 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1279 | 1740 | |
1280 | 1741 | $data['id_source'] = $id_source; |
1281 | 1742 | $data['format_source'] = 'vaos'; |
1282 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1743 | + if (isset($value['name']) && $value['name'] != '') { |
|
1744 | + $data['source_name'] = $value['name']; |
|
1745 | + } |
|
1283 | 1746 | $SI->add($data); |
1284 | 1747 | unset($data); |
1285 | 1748 | } |
1286 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1749 | + if ($globalDebug) { |
|
1750 | + echo 'No more data...'."\n"; |
|
1751 | + } |
|
1287 | 1752 | unset($buffer); |
1288 | 1753 | unset($all_data); |
1289 | 1754 | } |
@@ -1296,7 +1761,9 @@ discard block |
||
1296 | 1761 | ) |
1297 | 1762 | ) { |
1298 | 1763 | //$buffer = $Common->getData($hosts[$id]); |
1299 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1764 | + if ($globalDebug) { |
|
1765 | + echo 'Get Data...'."\n"; |
|
1766 | + } |
|
1300 | 1767 | $buffer = $Common->getData($value['host']); |
1301 | 1768 | $all_data = json_decode($buffer,true); |
1302 | 1769 | if ($buffer != '' && is_array($all_data)) { |
@@ -1325,16 +1792,25 @@ discard block |
||
1325 | 1792 | $data['arrival_airport_icao'] = $line['arrival']; |
1326 | 1793 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1327 | 1794 | //$data['registration'] = $line['aircraft']; |
1328 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1795 | + if (isset($line['route'])) { |
|
1796 | + $data['waypoints'] = $line['route']; |
|
1797 | + } |
|
1798 | + // route |
|
1329 | 1799 | $data['aircraft_icao'] = $line['plane_type']; |
1330 | 1800 | $data['id_source'] = $id_source; |
1331 | 1801 | $data['format_source'] = 'vam'; |
1332 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1333 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1802 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1803 | + $data['noarchive'] = true; |
|
1804 | + } |
|
1805 | + if (isset($value['name']) && $value['name'] != '') { |
|
1806 | + $data['source_name'] = $value['name']; |
|
1807 | + } |
|
1334 | 1808 | $SI->add($data); |
1335 | 1809 | unset($data); |
1336 | 1810 | } |
1337 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1811 | + if ($globalDebug) { |
|
1812 | + echo 'No more data...'."\n"; |
|
1813 | + } |
|
1338 | 1814 | unset($buffer); |
1339 | 1815 | unset($all_data); |
1340 | 1816 | } |
@@ -1347,7 +1823,9 @@ discard block |
||
1347 | 1823 | ) |
1348 | 1824 | ) { |
1349 | 1825 | //$buffer = $Common->getData($hosts[$id]); |
1350 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1826 | + if ($globalDebug) { |
|
1827 | + echo 'Get Data...'."\n"; |
|
1828 | + } |
|
1351 | 1829 | $buffer = $Common->getData($value['host']); |
1352 | 1830 | $all_data = json_decode($buffer,true); |
1353 | 1831 | if ($buffer != '') { |
@@ -1365,18 +1843,24 @@ discard block |
||
1365 | 1843 | $data['id_source'] = $id_source; |
1366 | 1844 | $data['format_source'] = 'blitzortung'; |
1367 | 1845 | $SI->add($data); |
1368 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1846 | + if ($globalDebug) { |
|
1847 | + echo '☈ Lightning added'."\n"; |
|
1848 | + } |
|
1369 | 1849 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1370 | 1850 | unset($data); |
1371 | 1851 | } |
1372 | 1852 | } |
1373 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1853 | + if ($globalDebug) { |
|
1854 | + echo 'No more data...'."\n"; |
|
1855 | + } |
|
1374 | 1856 | unset($buffer); |
1375 | 1857 | } |
1376 | 1858 | $last_exec[$id]['last'] = time(); |
1377 | 1859 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1378 | 1860 | } 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') { |
1379 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1861 | + if (function_exists('pcntl_fork')) { |
|
1862 | + pcntl_signal_dispatch(); |
|
1863 | + } |
|
1380 | 1864 | //$last_exec[$id]['last'] = time(); |
1381 | 1865 | |
1382 | 1866 | //$read = array( $sockets[$id] ); |
@@ -1384,7 +1868,9 @@ discard block |
||
1384 | 1868 | $write = NULL; |
1385 | 1869 | $e = NULL; |
1386 | 1870 | $n = socket_select($read, $write, $e, $timeout); |
1387 | - if ($e != NULL) var_dump($e); |
|
1871 | + if ($e != NULL) { |
|
1872 | + var_dump($e); |
|
1873 | + } |
|
1388 | 1874 | if ($n > 0) { |
1389 | 1875 | $reset = 0; |
1390 | 1876 | foreach ($read as $nb => $r) { |
@@ -1406,13 +1892,17 @@ discard block |
||
1406 | 1892 | if ($buffer !== FALSE) { |
1407 | 1893 | if ($format == 'vrstcp') { |
1408 | 1894 | $buffer = explode('},{',$buffer); |
1409 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1895 | + } else { |
|
1896 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1897 | + } |
|
1410 | 1898 | } |
1411 | 1899 | // SBS format is CSV format |
1412 | 1900 | if ($buffer !== FALSE && $buffer !== '') { |
1413 | 1901 | $tt[$format] = 0; |
1414 | 1902 | if ($format == 'acarssbs3') { |
1415 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1903 | + if ($globalDebug) { |
|
1904 | + echo 'ACARS : '.$buffer."\n"; |
|
1905 | + } |
|
1416 | 1906 | $ACARS->add(trim($buffer)); |
1417 | 1907 | $ACARS->deleteLiveAcarsData(); |
1418 | 1908 | } elseif ($format == 'raw') { |
@@ -1421,30 +1911,70 @@ discard block |
||
1421 | 1911 | if (is_array($data)) { |
1422 | 1912 | $data['datetime'] = date('Y-m-d H:i:s'); |
1423 | 1913 | $data['format_source'] = 'raw'; |
1424 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1425 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1426 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1427 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1914 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1915 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1916 | + } |
|
1917 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1918 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1919 | + } |
|
1920 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1921 | + $data['noarchive'] = true; |
|
1922 | + } |
|
1923 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1924 | + $SI->add($data); |
|
1925 | + } |
|
1428 | 1926 | } |
1429 | 1927 | } elseif ($format == 'ais') { |
1430 | 1928 | $ais_data = $AIS->parse_line(trim($buffer)); |
1431 | 1929 | $data = array(); |
1432 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1433 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1434 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1435 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1436 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1437 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1438 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1439 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1440 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1441 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1442 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1443 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1444 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1445 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1447 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1930 | + if (isset($ais_data['ident'])) { |
|
1931 | + $data['ident'] = $ais_data['ident']; |
|
1932 | + } |
|
1933 | + if (isset($ais_data['mmsi'])) { |
|
1934 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1935 | + } |
|
1936 | + if (isset($ais_data['speed'])) { |
|
1937 | + $data['speed'] = $ais_data['speed']; |
|
1938 | + } |
|
1939 | + if (isset($ais_data['heading'])) { |
|
1940 | + $data['heading'] = $ais_data['heading']; |
|
1941 | + } |
|
1942 | + if (isset($ais_data['latitude'])) { |
|
1943 | + $data['latitude'] = $ais_data['latitude']; |
|
1944 | + } |
|
1945 | + if (isset($ais_data['longitude'])) { |
|
1946 | + $data['longitude'] = $ais_data['longitude']; |
|
1947 | + } |
|
1948 | + if (isset($ais_data['status'])) { |
|
1949 | + $data['status'] = $ais_data['status']; |
|
1950 | + } |
|
1951 | + if (isset($ais_data['statusid'])) { |
|
1952 | + $data['status_id'] = $ais_data['statusid']; |
|
1953 | + } |
|
1954 | + if (isset($ais_data['type'])) { |
|
1955 | + $data['type'] = $ais_data['type']; |
|
1956 | + } |
|
1957 | + if (isset($ais_data['imo'])) { |
|
1958 | + $data['imo'] = $ais_data['imo']; |
|
1959 | + } |
|
1960 | + if (isset($ais_data['callsign'])) { |
|
1961 | + $data['callsign'] = $ais_data['callsign']; |
|
1962 | + } |
|
1963 | + if (isset($ais_data['destination'])) { |
|
1964 | + $data['arrival_code'] = $ais_data['destination']; |
|
1965 | + } |
|
1966 | + if (isset($ais_data['eta_ts'])) { |
|
1967 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1968 | + } |
|
1969 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1970 | + $data['noarchive'] = true; |
|
1971 | + } |
|
1972 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1973 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1974 | + } |
|
1975 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1976 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1977 | + } |
|
1448 | 1978 | |
1449 | 1979 | if (isset($ais_data['timestamp'])) { |
1450 | 1980 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1453,7 +1983,9 @@ discard block |
||
1453 | 1983 | } |
1454 | 1984 | $data['format_source'] = 'aisnmea'; |
1455 | 1985 | $data['id_source'] = $id_source; |
1456 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1986 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1987 | + $MI->add($data); |
|
1988 | + } |
|
1457 | 1989 | unset($data); |
1458 | 1990 | } elseif ($format == 'flightgearsp') { |
1459 | 1991 | //echo $buffer."\n"; |
@@ -1471,12 +2003,18 @@ discard block |
||
1471 | 2003 | $data['speed'] = round($line[5]*1.94384); |
1472 | 2004 | $data['datetime'] = date('Y-m-d H:i:s'); |
1473 | 2005 | $data['format_source'] = 'flightgearsp'; |
1474 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1475 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2006 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2007 | + $data['noarchive'] = true; |
|
2008 | + } |
|
2009 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2010 | + $SI->add($data); |
|
2011 | + } |
|
1476 | 2012 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1477 | 2013 | } |
1478 | 2014 | } elseif ($format == 'acars') { |
1479 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2015 | + if ($globalDebug) { |
|
2016 | + echo 'ACARS : '.$buffer."\n"; |
|
2017 | + } |
|
1480 | 2018 | $ACARS->add(trim($buffer)); |
1481 | 2019 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1482 | 2020 | $ACARS->deleteLiveAcarsData(); |
@@ -1497,8 +2035,12 @@ discard block |
||
1497 | 2035 | $aircraft_type = $line[10]; |
1498 | 2036 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1499 | 2037 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1500 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2038 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2039 | + $data['noarchive'] = true; |
|
2040 | + } |
|
2041 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2042 | + $SI->add($data); |
|
2043 | + } |
|
1502 | 2044 | } |
1503 | 2045 | } |
1504 | 2046 | } elseif ($format == 'beast') { |
@@ -1508,28 +2050,62 @@ discard block |
||
1508 | 2050 | foreach($buffer as $all_data) { |
1509 | 2051 | $line = json_decode('{'.$all_data.'}',true); |
1510 | 2052 | $data = array(); |
1511 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1512 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1513 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1514 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1515 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1516 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1517 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2053 | + if (isset($line['Icao'])) { |
|
2054 | + $data['hex'] = $line['Icao']; |
|
2055 | + } |
|
2056 | + // hex |
|
2057 | + if (isset($line['Call'])) { |
|
2058 | + $data['ident'] = $line['Call']; |
|
2059 | + } |
|
2060 | + // ident |
|
2061 | + if (isset($line['Alt'])) { |
|
2062 | + $data['altitude'] = $line['Alt']; |
|
2063 | + } |
|
2064 | + // altitude |
|
2065 | + if (isset($line['Spd'])) { |
|
2066 | + $data['speed'] = $line['Spd']; |
|
2067 | + } |
|
2068 | + // speed |
|
2069 | + if (isset($line['Trak'])) { |
|
2070 | + $data['heading'] = $line['Trak']; |
|
2071 | + } |
|
2072 | + // heading |
|
2073 | + if (isset($line['Lat'])) { |
|
2074 | + $data['latitude'] = $line['Lat']; |
|
2075 | + } |
|
2076 | + // lat |
|
2077 | + if (isset($line['Long'])) { |
|
2078 | + $data['longitude'] = $line['Long']; |
|
2079 | + } |
|
2080 | + // long |
|
1518 | 2081 | //$data['verticalrate'] = $line['']; // verticale rate |
1519 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2082 | + if (isset($line['Sqk'])) { |
|
2083 | + $data['squawk'] = $line['Sqk']; |
|
2084 | + } |
|
2085 | + // squawk |
|
1520 | 2086 | $data['emergency'] = ''; // emergency |
1521 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2087 | + if (isset($line['Reg'])) { |
|
2088 | + $data['registration'] = $line['Reg']; |
|
2089 | + } |
|
1522 | 2090 | /* |
1523 | 2091 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1524 | 2092 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1525 | 2093 | */ |
1526 | 2094 | $data['datetime'] = date('Y-m-d H:i:s'); |
1527 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2095 | + if (isset($line['Type'])) { |
|
2096 | + $data['aircraft_icao'] = $line['Type']; |
|
2097 | + } |
|
1528 | 2098 | $data['format_source'] = 'vrstcp'; |
1529 | 2099 | $data['id_source'] = $id_source; |
1530 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1531 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1532 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2100 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2101 | + $data['noarchive'] = true; |
|
2102 | + } |
|
2103 | + if (isset($value['name']) && $value['name'] != '') { |
|
2104 | + $data['source_name'] = $value['name']; |
|
2105 | + } |
|
2106 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2107 | + $SI->add($data); |
|
2108 | + } |
|
1533 | 2109 | unset($data); |
1534 | 2110 | } |
1535 | 2111 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1542,22 +2118,46 @@ discard block |
||
1542 | 2118 | $data['hex'] = $lined['hexid']; |
1543 | 2119 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1544 | 2120 | $data['datetime'] = date('Y-m-d H:i:s');; |
1545 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1546 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1547 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1548 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1549 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1550 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1551 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2121 | + if (isset($lined['ident'])) { |
|
2122 | + $data['ident'] = $lined['ident']; |
|
2123 | + } |
|
2124 | + if (isset($lined['lat'])) { |
|
2125 | + $data['latitude'] = $lined['lat']; |
|
2126 | + } |
|
2127 | + if (isset($lined['lon'])) { |
|
2128 | + $data['longitude'] = $lined['lon']; |
|
2129 | + } |
|
2130 | + if (isset($lined['speed'])) { |
|
2131 | + $data['speed'] = $lined['speed']; |
|
2132 | + } |
|
2133 | + if (isset($lined['squawk'])) { |
|
2134 | + $data['squawk'] = $lined['squawk']; |
|
2135 | + } |
|
2136 | + if (isset($lined['alt'])) { |
|
2137 | + $data['altitude'] = $lined['alt']; |
|
2138 | + } |
|
2139 | + if (isset($lined['heading'])) { |
|
2140 | + $data['heading'] = $lined['heading']; |
|
2141 | + } |
|
1552 | 2142 | $data['id_source'] = $id_source; |
1553 | 2143 | $data['format_source'] = 'tsv'; |
1554 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1555 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1556 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1557 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2144 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2145 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2146 | + } |
|
2147 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2148 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2149 | + } |
|
2150 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2151 | + $data['noarchive'] = true; |
|
2152 | + } |
|
2153 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2154 | + $SI->add($data); |
|
2155 | + } |
|
1558 | 2156 | unset($lined); |
1559 | 2157 | unset($data); |
1560 | - } else $error = true; |
|
2158 | + } else { |
|
2159 | + $error = true; |
|
2160 | + } |
|
1561 | 2161 | } elseif ($format == 'aprs' && $use_aprs) { |
1562 | 2162 | if ($aprs_connect == 0) { |
1563 | 2163 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1583,63 +2183,121 @@ discard block |
||
1583 | 2183 | $aprs_last_tx = time(); |
1584 | 2184 | $data = array(); |
1585 | 2185 | //print_r($line); |
1586 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1587 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1588 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1589 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1590 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1591 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1592 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1593 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1594 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1595 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2186 | + if (isset($line['address'])) { |
|
2187 | + $data['hex'] = $line['address']; |
|
2188 | + } |
|
2189 | + if (isset($line['mmsi'])) { |
|
2190 | + $data['mmsi'] = $line['mmsi']; |
|
2191 | + } |
|
2192 | + if (isset($line['imo'])) { |
|
2193 | + $data['imo'] = $line['imo']; |
|
2194 | + } |
|
2195 | + if (isset($line['squawk'])) { |
|
2196 | + $data['squawk'] = $line['squawk']; |
|
2197 | + } |
|
2198 | + if (isset($line['arrival_code'])) { |
|
2199 | + $data['arrival_code'] = $line['arrival_code']; |
|
2200 | + } |
|
2201 | + if (isset($line['arrival_date'])) { |
|
2202 | + $data['arrival_date'] = $line['arrival_date']; |
|
2203 | + } |
|
2204 | + if (isset($line['typeid'])) { |
|
2205 | + $data['type_id'] = $line['typeid']; |
|
2206 | + } |
|
2207 | + if (isset($line['statusid'])) { |
|
2208 | + $data['status_id'] = $line['statusid']; |
|
2209 | + } |
|
2210 | + if (isset($line['timestamp'])) { |
|
2211 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2212 | + } else { |
|
2213 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2214 | + } |
|
1596 | 2215 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1597 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2216 | + if (isset($line['ident'])) { |
|
2217 | + $data['ident'] = $line['ident']; |
|
2218 | + } |
|
1598 | 2219 | $data['latitude'] = $line['latitude']; |
1599 | 2220 | $data['longitude'] = $line['longitude']; |
1600 | 2221 | //$data['verticalrate'] = $line[16]; |
1601 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2222 | + if (isset($line['speed'])) { |
|
2223 | + $data['speed'] = $line['speed']; |
|
2224 | + } |
|
1602 | 2225 | //else $data['speed'] = 0; |
1603 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1604 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1605 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2226 | + if (isset($line['altitude'])) { |
|
2227 | + $data['altitude'] = $line['altitude']; |
|
2228 | + } |
|
2229 | + if (isset($line['comment'])) { |
|
2230 | + $data['comment'] = $line['comment']; |
|
2231 | + } |
|
2232 | + if (isset($line['symbol'])) { |
|
2233 | + $data['type'] = $line['symbol']; |
|
2234 | + } |
|
1606 | 2235 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1607 | 2236 | |
1608 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2237 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2238 | + $data['heading'] = $line['heading']; |
|
2239 | + } |
|
1609 | 2240 | //else echo 'No heading...'."\n"; |
1610 | 2241 | //else $data['heading'] = 0; |
1611 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2242 | + if (isset($line['stealth'])) { |
|
2243 | + $data['aircraft_type'] = $line['stealth']; |
|
2244 | + } |
|
1612 | 2245 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1613 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1614 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1615 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1616 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2246 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2247 | + $data['noarchive'] = true; |
|
2248 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2249 | + $data['noarchive'] = false; |
|
2250 | + } |
|
2251 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2252 | + $data['noarchive'] = true; |
|
2253 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2254 | + $data['noarchive'] = false; |
|
2255 | + } |
|
1617 | 2256 | $data['id_source'] = $id_source; |
1618 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1619 | - else $data['format_source'] = 'aprs'; |
|
2257 | + if (isset($line['format_source'])) { |
|
2258 | + $data['format_source'] = $line['format_source']; |
|
2259 | + } else { |
|
2260 | + $data['format_source'] = 'aprs'; |
|
2261 | + } |
|
1620 | 2262 | $data['source_name'] = $line['source']; |
1621 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1622 | - else $data['source_type'] = 'flarm'; |
|
1623 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2263 | + if (isset($line['source_type'])) { |
|
2264 | + $data['source_type'] = $line['source_type']; |
|
2265 | + } else { |
|
2266 | + $data['source_type'] = 'flarm'; |
|
2267 | + } |
|
2268 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2269 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2270 | + } |
|
1624 | 2271 | $currentdate = date('Y-m-d H:i:s'); |
1625 | 2272 | $aprsdate = strtotime($data['datetime']); |
1626 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2273 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2274 | + $data['altitude_relative'] = 'AMSL'; |
|
2275 | + } |
|
1627 | 2276 | // Accept data if time <= system time + 20s |
1628 | 2277 | //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'])))) { |
1629 | 2278 | 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'])))) { |
1630 | 2279 | $send = $SI->add($data); |
1631 | 2280 | } elseif ($data['source_type'] == 'ais') { |
1632 | 2281 | $data['type'] = ''; |
1633 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2282 | + if (isset($globalMarine) && $globalMarine) { |
|
2283 | + $send = $MI->add($data); |
|
2284 | + } |
|
1634 | 2285 | } elseif (isset($line['stealth'])) { |
1635 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1636 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2286 | + if ($line['stealth'] != 0) { |
|
2287 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2288 | + } else { |
|
2289 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2290 | + } |
|
1637 | 2291 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1638 | 2292 | //$line['symbol'] == 'Balloon' || |
1639 | 2293 | $line['symbol'] == 'Glider' || |
1640 | 2294 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1641 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1642 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2295 | + if ($line['symbol'] == 'Ballon') { |
|
2296 | + $data['aircraft_icao'] = 'BALL'; |
|
2297 | + } |
|
2298 | + if ($line['symbol'] == 'Glider') { |
|
2299 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2300 | + } |
|
1643 | 2301 | $send = $SI->add($data); |
1644 | 2302 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1645 | 2303 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1670,9 +2328,13 @@ discard block |
||
1670 | 2328 | //} 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') { |
1671 | 2329 | // } 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') { |
1672 | 2330 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1673 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2331 | + if (isset($globalTracker) && $globalTracker) { |
|
2332 | + $send = $TI->add($data); |
|
2333 | + } |
|
1674 | 2334 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1675 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2335 | + if (!isset($data['altitude'])) { |
|
2336 | + $data['altitude'] = 0; |
|
2337 | + } |
|
1676 | 2338 | $Source->deleteOldLocationByType('gs'); |
1677 | 2339 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1678 | 2340 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1681,7 +2343,9 @@ discard block |
||
1681 | 2343 | } |
1682 | 2344 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1683 | 2345 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1684 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2346 | + if ($globalDebug) { |
|
2347 | + echo '# Weather Station added'."\n"; |
|
2348 | + } |
|
1685 | 2349 | $Source->deleteOldLocationByType('wx'); |
1686 | 2350 | $weather_data = json_encode($line); |
1687 | 2351 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1691,7 +2355,9 @@ discard block |
||
1691 | 2355 | } |
1692 | 2356 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
1693 | 2357 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1694 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2358 | + if ($globalDebug) { |
|
2359 | + echo '☈ Lightning added'."\n"; |
|
2360 | + } |
|
1695 | 2361 | $Source->deleteOldLocationByType('lightning'); |
1696 | 2362 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1697 | 2363 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1703,8 +2369,7 @@ discard block |
||
1703 | 2369 | print_r($line); |
1704 | 2370 | } |
1705 | 2371 | unset($data); |
1706 | - } |
|
1707 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2372 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1708 | 2373 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1709 | 2374 | } |
1710 | 2375 | /* |
@@ -1713,7 +2378,9 @@ discard block |
||
1713 | 2378 | } |
1714 | 2379 | */ |
1715 | 2380 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1716 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2381 | + elseif ($line == true && $globalDebug) { |
|
2382 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2383 | + } |
|
1717 | 2384 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1718 | 2385 | $Source->deleteOldLocationByType('lightning'); |
1719 | 2386 | $Source->deleteOldLocationByType('wx'); |
@@ -1749,26 +2416,45 @@ discard block |
||
1749 | 2416 | $data['ground'] = $line[21]; |
1750 | 2417 | $data['emergency'] = $line[19]; |
1751 | 2418 | $data['format_source'] = 'sbs'; |
1752 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1753 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1754 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2419 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2420 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2421 | + } |
|
2422 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2423 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2424 | + } |
|
2425 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2426 | + $data['noarchive'] = true; |
|
2427 | + } |
|
1755 | 2428 | $data['id_source'] = $id_source; |
1756 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1757 | - else $error = true; |
|
2429 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2430 | + $send = $SI->add($data); |
|
2431 | + } else { |
|
2432 | + $error = true; |
|
2433 | + } |
|
1758 | 2434 | unset($data); |
1759 | - } else $error = true; |
|
2435 | + } else { |
|
2436 | + $error = true; |
|
2437 | + } |
|
1760 | 2438 | if ($error) { |
1761 | 2439 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1762 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2440 | + if ($globalDebug) { |
|
2441 | + echo "Not a message. Ignoring... \n"; |
|
2442 | + } |
|
1763 | 2443 | } else { |
1764 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2444 | + if ($globalDebug) { |
|
2445 | + echo "Wrong line format. Ignoring... \n"; |
|
2446 | + } |
|
1765 | 2447 | if ($globalDebug) { |
1766 | 2448 | echo $buffer; |
1767 | 2449 | //print_r($line); |
1768 | 2450 | } |
1769 | 2451 | //socket_close($r); |
1770 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1771 | - if ($format == 'aprs') $aprs_connect = 0; |
|
2452 | + if ($globalDebug) { |
|
2453 | + echo "Reconnect after an error...\n"; |
|
2454 | + } |
|
2455 | + if ($format == 'aprs') { |
|
2456 | + $aprs_connect = 0; |
|
2457 | + } |
|
1772 | 2458 | $sourceer[$nb] = $globalSources[$nb]; |
1773 | 2459 | connect_all($sourceer); |
1774 | 2460 | $sourceer = array(); |
@@ -1776,10 +2462,14 @@ discard block |
||
1776 | 2462 | } |
1777 | 2463 | } |
1778 | 2464 | // Sleep for xxx microseconds |
1779 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2465 | + if (isset($globalSBSSleep)) { |
|
2466 | + usleep($globalSBSSleep); |
|
2467 | + } |
|
1780 | 2468 | } else { |
1781 | 2469 | if ($format == 'flightgearmp') { |
1782 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2470 | + if ($globalDebug) { |
|
2471 | + echo "Reconnect FlightGear MP..."; |
|
2472 | + } |
|
1783 | 2473 | //@socket_close($r); |
1784 | 2474 | sleep($globalMinFetch); |
1785 | 2475 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1788,10 +2478,15 @@ discard block |
||
1788 | 2478 | break; |
1789 | 2479 | |
1790 | 2480 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1791 | - if (isset($tt[$format])) $tt[$format]++; |
|
1792 | - else $tt[$format] = 0; |
|
2481 | + if (isset($tt[$format])) { |
|
2482 | + $tt[$format]++; |
|
2483 | + } else { |
|
2484 | + $tt[$format] = 0; |
|
2485 | + } |
|
1793 | 2486 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1794 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2487 | + if ($globalDebug) { |
|
2488 | + echo "ERROR : Reconnect ".$format."..."; |
|
2489 | + } |
|
1795 | 2490 | //@socket_close($r); |
1796 | 2491 | sleep(2); |
1797 | 2492 | $aprs_connect = 0; |
@@ -1809,11 +2504,17 @@ discard block |
||
1809 | 2504 | } else { |
1810 | 2505 | $error = socket_strerror(socket_last_error()); |
1811 | 2506 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1812 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1813 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2507 | + if ($globalDebug) { |
|
2508 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2509 | + } |
|
2510 | + if (isset($globalDebug)) { |
|
2511 | + echo "Restarting...\n"; |
|
2512 | + } |
|
1814 | 2513 | // Restart the script if possible |
1815 | 2514 | if (is_array($sockets)) { |
1816 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2515 | + if ($globalDebug) { |
|
2516 | + echo "Shutdown all sockets..."; |
|
2517 | + } |
|
1817 | 2518 | |
1818 | 2519 | foreach ($sockets as $sock) { |
1819 | 2520 | @socket_shutdown($sock,2); |
@@ -1821,25 +2522,45 @@ discard block |
||
1821 | 2522 | } |
1822 | 2523 | |
1823 | 2524 | } |
1824 | - if ($globalDebug) echo "Waiting..."; |
|
2525 | + if ($globalDebug) { |
|
2526 | + echo "Waiting..."; |
|
2527 | + } |
|
1825 | 2528 | sleep(2); |
1826 | 2529 | $time = time(); |
1827 | 2530 | //connect_all($hosts); |
1828 | 2531 | $aprs_connect = 0; |
1829 | - if ($reset%5 == 0) sleep(20); |
|
1830 | - if ($reset%10 == 0) sleep(100); |
|
1831 | - if ($reset%20 == 0) sleep(200); |
|
1832 | - if ($reset > 100) exit('Too many attempts...'); |
|
1833 | - if ($globalDebug) echo "Restart all connections..."; |
|
2532 | + if ($reset%5 == 0) { |
|
2533 | + sleep(20); |
|
2534 | + } |
|
2535 | + if ($reset%10 == 0) { |
|
2536 | + sleep(100); |
|
2537 | + } |
|
2538 | + if ($reset%20 == 0) { |
|
2539 | + sleep(200); |
|
2540 | + } |
|
2541 | + if ($reset > 100) { |
|
2542 | + exit('Too many attempts...'); |
|
2543 | + } |
|
2544 | + if ($globalDebug) { |
|
2545 | + echo "Restart all connections..."; |
|
2546 | + } |
|
1834 | 2547 | connect_all($globalSources); |
1835 | 2548 | } |
1836 | 2549 | } |
1837 | 2550 | } |
1838 | 2551 | if ($globalDaemon === false) { |
1839 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1840 | - if (isset($SI)) $SI->checkAll(); |
|
1841 | - if (isset($TI)) $TI->checkAll(); |
|
1842 | - if (isset($MI)) $MI->checkAll(); |
|
2552 | + if ($globalDebug) { |
|
2553 | + echo 'Check all...'."\n"; |
|
2554 | + } |
|
2555 | + if (isset($SI)) { |
|
2556 | + $SI->checkAll(); |
|
2557 | + } |
|
2558 | + if (isset($TI)) { |
|
2559 | + $TI->checkAll(); |
|
2560 | + } |
|
2561 | + if (isset($MI)) { |
|
2562 | + $MI->checkAll(); |
|
2563 | + } |
|
1843 | 2564 | } |
1844 | 2565 | } |
1845 | 2566 | } |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -191,7 +217,9 @@ discard block |
||
191 | 217 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 218 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | 219 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
222 | + } |
|
195 | 223 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 224 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 225 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -204,7 +232,9 @@ discard block |
||
204 | 232 | } |
205 | 233 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
206 | 234 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
237 | + } |
|
208 | 238 | if (!isset($line['id'])) { |
209 | 239 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
210 | 240 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -213,7 +243,9 @@ discard block |
||
213 | 243 | } |
214 | 244 | } |
215 | 245 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
246 | + if (strtotime($line['arrival_date']) > time()) { |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | + } |
|
217 | 249 | } |
218 | 250 | |
219 | 251 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -234,34 +266,49 @@ discard block |
||
234 | 266 | $Marine = new Marine($this->db); |
235 | 267 | $fromsource = NULL; |
236 | 268 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
237 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
269 | + if ($globalDebug && $result != 'success') { |
|
270 | + echo '!!! ERROR : '.$result."\n"; |
|
271 | + } |
|
238 | 272 | $Marine->db = null; |
239 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
273 | + if ($globalDebugTimeElapsed) { |
|
274 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
275 | + } |
|
240 | 276 | } |
241 | 277 | } |
242 | 278 | } |
243 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
279 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
281 | + } |
|
244 | 282 | } |
245 | 283 | |
246 | 284 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
247 | 285 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
248 | 286 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
249 | 287 | } else { |
250 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
251 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
288 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
289 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
290 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
291 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
292 | + } |
|
252 | 293 | return ''; |
253 | 294 | } |
254 | 295 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
255 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
296 | + if ($globalDebug) { |
|
297 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
298 | + } |
|
256 | 299 | return ''; |
257 | 300 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
258 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
301 | + if ($globalDebug) { |
|
302 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
303 | + } |
|
259 | 304 | return ''; |
260 | 305 | } elseif (!isset($line['datetime'])) { |
261 | 306 | date_default_timezone_set('UTC'); |
262 | 307 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
263 | 308 | } else { |
264 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
311 | + } |
|
265 | 312 | return ''; |
266 | 313 | } |
267 | 314 | |
@@ -274,14 +321,21 @@ discard block |
||
274 | 321 | if ($distance > 1000 && $distance < 10000) { |
275 | 322 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
276 | 323 | $speed = $speed*3.6; |
277 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
278 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
324 | + if ($speed < 1000) { |
|
325 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
326 | + } |
|
327 | + if ($globalDebug) { |
|
328 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
329 | + } |
|
279 | 330 | } |
280 | 331 | } |
281 | 332 | |
282 | 333 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
283 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
284 | - else unset($timediff); |
|
334 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
335 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
336 | + } else { |
|
337 | + unset($timediff); |
|
338 | + } |
|
285 | 339 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
286 | 340 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
287 | 341 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -289,22 +343,32 @@ discard block |
||
289 | 343 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
290 | 344 | $this->all_tracked[$id]['putinarchive'] = true; |
291 | 345 | |
292 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
346 | + if ($globalDebug) { |
|
347 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
348 | + } |
|
293 | 349 | $timeelapsed = microtime(true); |
294 | 350 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
295 | 351 | $Marine = new Marine($this->db); |
296 | 352 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
297 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
353 | + if (!empty($all_country)) { |
|
354 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
355 | + } |
|
298 | 356 | $Marine->db = null; |
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
357 | + if ($globalDebugTimeElapsed) { |
|
358 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
359 | + } |
|
300 | 360 | } |
301 | 361 | $this->tmd = 0; |
302 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
362 | + if ($globalDebug) { |
|
363 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
364 | + } |
|
303 | 365 | } |
304 | 366 | } |
305 | 367 | |
306 | 368 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
307 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
369 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
370 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
371 | + } |
|
308 | 372 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
309 | 373 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
310 | 374 | $dataFound = true; |
@@ -313,8 +377,12 @@ discard block |
||
313 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
314 | 378 | } |
315 | 379 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
316 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
317 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
380 | + if ($line['longitude'] > 180) { |
|
381 | + $line['longitude'] = $line['longitude'] - 360; |
|
382 | + } |
|
383 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
384 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
385 | + } |
|
318 | 386 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
319 | 387 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
320 | 388 | $dataFound = true; |
@@ -332,7 +400,9 @@ discard block |
||
332 | 400 | } |
333 | 401 | } |
334 | 402 | if (isset($line['last_update']) && $line['last_update'] != '') { |
335 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
403 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
404 | + $dataFound = true; |
|
405 | + } |
|
336 | 406 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
337 | 407 | } |
338 | 408 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -346,15 +416,21 @@ discard block |
||
346 | 416 | } |
347 | 417 | |
348 | 418 | if (isset($line['heading']) && $line['heading'] != '') { |
349 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
419 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
420 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
421 | + } |
|
350 | 422 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
351 | 423 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
352 | 424 | //$dataFound = true; |
353 | 425 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
354 | 426 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
355 | 427 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
356 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
357 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
428 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
429 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
430 | + } |
|
431 | + if ($globalDebug) { |
|
432 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
433 | + } |
|
358 | 434 | } |
359 | 435 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
360 | 436 | |
@@ -366,23 +442,38 @@ discard block |
||
366 | 442 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
367 | 443 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
368 | 444 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
369 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
445 | + if ($globalDebug) { |
|
446 | + echo "Check if vessel is already in DB..."; |
|
447 | + } |
|
370 | 448 | $timeelapsed = microtime(true); |
371 | 449 | $MarineLive = new MarineLive($this->db); |
372 | 450 | if (isset($line['id'])) { |
373 | 451 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
374 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
452 | + if ($globalDebugTimeElapsed) { |
|
453 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
454 | + } |
|
375 | 455 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
376 | 456 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
377 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
457 | + if ($globalDebugTimeElapsed) { |
|
458 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | + } |
|
378 | 460 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
379 | 461 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
381 | - } else $recent_ident = ''; |
|
462 | + if ($globalDebugTimeElapsed) { |
|
463 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
464 | + } |
|
465 | + } else { |
|
466 | + $recent_ident = ''; |
|
467 | + } |
|
382 | 468 | $MarineLive->db=null; |
383 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
384 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
385 | - } else $recent_ident = ''; |
|
469 | + if ($globalDebug && $recent_ident == '') { |
|
470 | + echo " Not in DB.\n"; |
|
471 | + } elseif ($globalDebug && $recent_ident != '') { |
|
472 | + echo " Already in DB.\n"; |
|
473 | + } |
|
474 | + } else { |
|
475 | + $recent_ident = ''; |
|
476 | + } |
|
386 | 477 | } else { |
387 | 478 | $recent_ident = ''; |
388 | 479 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -390,30 +481,44 @@ discard block |
||
390 | 481 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
391 | 482 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
392 | 483 | { |
393 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
484 | + if ($globalDebug) { |
|
485 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
486 | + } |
|
394 | 487 | //adds the spotter data for the archive |
395 | 488 | $highlight = ''; |
396 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
489 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
490 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
491 | + } |
|
397 | 492 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
398 | 493 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
399 | 494 | $timeelapsed = microtime(true); |
400 | 495 | $Marine = new Marine($this->db); |
401 | 496 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
402 | 497 | $Marine->db = null; |
403 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
404 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
498 | + if ($globalDebug && isset($result)) { |
|
499 | + echo $result."\n"; |
|
500 | + } |
|
501 | + if ($globalDebugTimeElapsed) { |
|
502 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
503 | + } |
|
405 | 504 | } |
406 | 505 | } |
407 | 506 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
408 | 507 | // Add source stat in DB |
409 | 508 | $Stats = new Stats($this->db); |
410 | 509 | if (!empty($this->stats)) { |
411 | - if ($globalDebug) echo 'Add source stats : '; |
|
510 | + if ($globalDebug) { |
|
511 | + echo 'Add source stats : '; |
|
512 | + } |
|
412 | 513 | foreach($this->stats as $date => $data) { |
413 | 514 | foreach($data as $source => $sourced) { |
414 | 515 | //print_r($sourced); |
415 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
416 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
516 | + if (isset($sourced['polar'])) { |
|
517 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
518 | + } |
|
519 | + if (isset($sourced['hist'])) { |
|
520 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
521 | + } |
|
417 | 522 | if (isset($sourced['msg'])) { |
418 | 523 | if (time() - $sourced['msg']['date'] > 10) { |
419 | 524 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -426,7 +531,9 @@ discard block |
||
426 | 531 | unset($this->stats[$date]); |
427 | 532 | } |
428 | 533 | } |
429 | - if ($globalDebug) echo 'Done'."\n"; |
|
534 | + if ($globalDebug) { |
|
535 | + echo 'Done'."\n"; |
|
536 | + } |
|
430 | 537 | } |
431 | 538 | $Stats->db = null; |
432 | 539 | } |
@@ -436,13 +543,17 @@ discard block |
||
436 | 543 | $this->all_tracked[$id]['addedMarine'] = 1; |
437 | 544 | //print_r($this->all_tracked[$id]); |
438 | 545 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
439 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
546 | + if ($globalDebug) { |
|
547 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
548 | + } |
|
440 | 549 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
441 | 550 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 551 | $MarineLive = new MarineLive($this->db); |
443 | 552 | $MarineLive->deleteLiveMarineData(); |
444 | 553 | $MarineLive->db=null; |
445 | - if ($globalDebug) echo " Done\n"; |
|
554 | + if ($globalDebug) { |
|
555 | + echo " Done\n"; |
|
556 | + } |
|
446 | 557 | } |
447 | 558 | $this->last_delete = time(); |
448 | 559 | } |
@@ -468,15 +579,21 @@ discard block |
||
468 | 579 | |
469 | 580 | if (!$ignoreImport) { |
470 | 581 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
471 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
582 | + if ($globalDebug) { |
|
583 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
584 | + } |
|
472 | 585 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
473 | 586 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
474 | 587 | $timeelapsed = microtime(true); |
475 | 588 | $MarineLive = new MarineLive($this->db); |
476 | 589 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
477 | 590 | $MarineLive->db = null; |
478 | - if ($globalDebug) echo $result."\n"; |
|
479 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
591 | + if ($globalDebug) { |
|
592 | + echo $result."\n"; |
|
593 | + } |
|
594 | + if ($globalDebugTimeElapsed) { |
|
595 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | + } |
|
480 | 597 | } |
481 | 598 | } |
482 | 599 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -488,7 +605,9 @@ discard block |
||
488 | 605 | |
489 | 606 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
490 | 607 | $source = $this->all_tracked[$id]['source_name']; |
491 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
608 | + if ($source == '') { |
|
609 | + $source = $this->all_tracked[$id]['format_source']; |
|
610 | + } |
|
492 | 611 | if (!isset($this->source_location[$source])) { |
493 | 612 | $Location = new Source($this->db); |
494 | 613 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -509,7 +628,9 @@ discard block |
||
509 | 628 | $stats_heading = round($stats_heading/22.5); |
510 | 629 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
511 | 630 | $current_date = date('Y-m-d'); |
512 | - if ($stats_heading == 16) $stats_heading = 0; |
|
631 | + if ($stats_heading == 16) { |
|
632 | + $stats_heading = 0; |
|
633 | + } |
|
513 | 634 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
514 | 635 | for ($i=0;$i<=15;$i++) { |
515 | 636 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -527,7 +648,9 @@ discard block |
||
527 | 648 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
528 | 649 | end($this->stats[$current_date][$source]['hist']); |
529 | 650 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
530 | - } else $mini = 0; |
|
651 | + } else { |
|
652 | + $mini = 0; |
|
653 | + } |
|
531 | 654 | for ($i=$mini;$i<=$distance;$i+=10) { |
532 | 655 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
533 | 656 | } |
@@ -539,19 +662,27 @@ discard block |
||
539 | 662 | |
540 | 663 | |
541 | 664 | $this->all_tracked[$id]['lastupdate'] = time(); |
542 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
543 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
665 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
666 | + $send = true; |
|
667 | + } |
|
668 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
669 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
670 | + } |
|
544 | 671 | //$this->del(); |
545 | 672 | |
546 | 673 | |
547 | 674 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
548 | 675 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
549 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
676 | + if ($globalDebug) { |
|
677 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
678 | + } |
|
550 | 679 | $MarineLive = new MarineLive($this->db); |
551 | 680 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
552 | 681 | $MarineLive->db = null; |
553 | 682 | //MarineLive->deleteLiveMarineData(); |
554 | - if ($globalDebug) echo " Done\n"; |
|
683 | + if ($globalDebug) { |
|
684 | + echo " Done\n"; |
|
685 | + } |
|
555 | 686 | } |
556 | 687 | $this->last_delete_hourly = time(); |
557 | 688 | } |
@@ -560,7 +691,9 @@ discard block |
||
560 | 691 | //$ignoreImport = false; |
561 | 692 | } |
562 | 693 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
563 | - if ($send) return $this->all_tracked[$id]; |
|
694 | + if ($send) { |
|
695 | + return $this->all_tracked[$id]; |
|
696 | + } |
|
564 | 697 | } |
565 | 698 | } |
566 | 699 | } |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | $temp += 1; |
124 | 124 | $flat = (float)($temp / (60.0 * 10000.0)); |
125 | 125 | $flat *= -1.0; |
126 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
126 | + } else { |
|
127 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
128 | + } |
|
127 | 129 | return $flat; // float |
128 | 130 | } |
129 | 131 | |
@@ -135,7 +137,9 @@ discard block |
||
135 | 137 | $temp += 1; |
136 | 138 | $flon = (float)($temp / (60.0 * 10000.0)); |
137 | 139 | $flon *= -1.0; |
138 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
140 | + } else { |
|
141 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
142 | + } |
|
139 | 143 | return $flon; |
140 | 144 | } |
141 | 145 | |
@@ -158,10 +162,8 @@ discard block |
||
158 | 162 | */ |
159 | 163 | private function asciidec_2_8bit($ascii) { |
160 | 164 | //only process in the following range: 48-87, 96-119 |
161 | - if ($ascii < 48) { } |
|
162 | - else { |
|
163 | - if($ascii>119) { } |
|
164 | - else { |
|
165 | + if ($ascii < 48) { } else { |
|
166 | + if($ascii>119) { } else { |
|
165 | 167 | if ($ascii>87 && $ascii<96) ; |
166 | 168 | else { |
167 | 169 | $ascii=$ascii+40; |
@@ -263,7 +265,9 @@ discard block |
||
263 | 265 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
264 | 266 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
265 | 267 | $ro->heading = bindec(substr($_aisdata,124,9)); |
266 | - if ($ro->heading == 511) $ro->heading = ''; |
|
268 | + if ($ro->heading == 511) { |
|
269 | + $ro->heading = ''; |
|
270 | + } |
|
267 | 271 | $ro->cls = 2; // class B |
268 | 272 | } else if ($ro->id == 19) { |
269 | 273 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -273,7 +277,9 @@ discard block |
||
273 | 277 | $ro->name = $this->binchar($_aisdata,143,120); |
274 | 278 | $ro->cls = 2; // class B |
275 | 279 | $ro->heading = bindec(substr($_aisdata,124,9)); |
276 | - if ($ro->heading == 511) $ro->heading = ''; |
|
280 | + if ($ro->heading == 511) { |
|
281 | + $ro->heading = ''; |
|
282 | + } |
|
277 | 283 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
278 | 284 | $ro->type = $this->getShipType($ro->typeid); |
279 | 285 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -304,9 +310,13 @@ discard block |
||
304 | 310 | $ro->cls = 2; // class B |
305 | 311 | } else if ($ro->id == 27) { |
306 | 312 | $ro->cog = bindec(substr($_aisdata,85,9)); |
307 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
313 | + if ($ro->cog == 511) { |
|
314 | + $ro->cog = 0.0; |
|
315 | + } |
|
308 | 316 | $ro->sog = bindec(substr($_aisdata,79,6)); |
309 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
317 | + if ($ro->sog == 63) { |
|
318 | + $ro->sog = 0.0; |
|
319 | + } |
|
310 | 320 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
311 | 321 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
312 | 322 | $ro->cls = 1; // class A |
@@ -354,14 +364,20 @@ discard block |
||
354 | 364 | } |
355 | 365 | |
356 | 366 | public function getShipType($code) { |
357 | - if (isset($this->shiptype[$code])) return $this->shiptype[$code]; |
|
358 | - else return ''; |
|
367 | + if (isset($this->shiptype[$code])) { |
|
368 | + return $this->shiptype[$code]; |
|
369 | + } else { |
|
370 | + return ''; |
|
371 | + } |
|
359 | 372 | } |
360 | 373 | |
361 | 374 | public function getShipTypeID($type) { |
362 | 375 | $typeid = array_search($type,$this->shiptype); |
363 | - if ($typeid !== FALSE) return $typeid; |
|
364 | - else return ''; |
|
376 | + if ($typeid !== FALSE) { |
|
377 | + return $typeid; |
|
378 | + } else { |
|
379 | + return ''; |
|
380 | + } |
|
365 | 381 | } |
366 | 382 | |
367 | 383 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -398,11 +414,20 @@ discard block |
||
398 | 414 | // assume 1st ! is valid |
399 | 415 | // find * ensure that it is at correct position |
400 | 416 | $end = strrpos ( $rawdata , '*' ); |
401 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
417 | + if ($end === FALSE) { |
|
418 | + return -1; |
|
419 | + } |
|
420 | + // check for NULLS!!! |
|
402 | 421 | $cs = substr( $rawdata, $end + 1 ); |
403 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
422 | + if ( strlen($cs) != 2 ) { |
|
423 | + return -1; |
|
424 | + } |
|
425 | + // correct cs length |
|
404 | 426 | $dcs = (int)hexdec( $cs ); |
405 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
427 | + for ( $alias=1; $alias<$end; $alias++) { |
|
428 | + $chksum ^= ord( $rawdata[$alias] ); |
|
429 | + } |
|
430 | + // perform XOR for NMEA checksum |
|
406 | 431 | if ( $chksum == $dcs ) { // NMEA checksum pass |
407 | 432 | $pcs = explode(',', $rawdata); |
408 | 433 | // !AI??? identifier |
@@ -413,8 +438,14 @@ discard block |
||
413 | 438 | $num_seq = (int)$pcs[1]; // number of sequences |
414 | 439 | $seq = (int)$pcs[2]; // get sequence |
415 | 440 | // get msg sequence id |
416 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
417 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
441 | + if ($pcs[3] == '') { |
|
442 | + $msg_sid = -1; |
|
443 | + } |
|
444 | + // non-multipart message, set to -1 |
|
445 | + else { |
|
446 | + $msg_sid = (int)$pcs[3]; |
|
447 | + } |
|
448 | + // multipart message |
|
418 | 449 | $ais_ch = $pcs[4]; // get AIS channel |
419 | 450 | // message sequence checking |
420 | 451 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -477,10 +508,18 @@ discard block |
||
477 | 508 | //DEBUG echo "[$start $end $tst]\n"; |
478 | 509 | $result = $this->process_ais_raw( $tst, "" ); |
479 | 510 | $last_pos = $end + 1; |
480 | - } else break; |
|
511 | + } else { |
|
512 | + break; |
|
513 | + } |
|
514 | + } |
|
515 | + if ($last_pos > 0) { |
|
516 | + $cbuf = substr($cbuf, $last_pos); |
|
481 | 517 | } |
482 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
483 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
518 | + // move... |
|
519 | + if (strlen($cbuf) > 1024) { |
|
520 | + $cbuf = ""; |
|
521 | + } |
|
522 | + // prevent overflow simple mode... |
|
484 | 523 | return $result; |
485 | 524 | } |
486 | 525 | |
@@ -500,7 +539,9 @@ discard block |
||
500 | 539 | if ($lat<0.0) { |
501 | 540 | $lat = -$lat; |
502 | 541 | $neg=true; |
503 | - } else $neg=false; |
|
542 | + } else { |
|
543 | + $neg=false; |
|
544 | + } |
|
504 | 545 | $latd = 0x00000000; |
505 | 546 | $latd = intval ($lat * 600000.0); |
506 | 547 | if ($neg==true) { |
@@ -516,7 +557,9 @@ discard block |
||
516 | 557 | if ($lon<0.0) { |
517 | 558 | $lon = -$lon; |
518 | 559 | $neg=true; |
519 | - } else $neg=false; |
|
560 | + } else { |
|
561 | + $neg=false; |
|
562 | + } |
|
520 | 563 | $lond = 0x00000000; |
521 | 564 | $lond = intval ($lon * 600000.0); |
522 | 565 | if ($neg==true) { |
@@ -529,9 +572,14 @@ discard block |
||
529 | 572 | |
530 | 573 | private function char2bin($name, $max_len) { |
531 | 574 | $len = strlen($name); |
532 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
533 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
534 | - else $pad = ''; |
|
575 | + if ($len > $max_len) { |
|
576 | + $name = substr($name,0,$max_len); |
|
577 | + } |
|
578 | + if ($len < $max_len) { |
|
579 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
580 | + } else { |
|
581 | + $pad = ''; |
|
582 | + } |
|
535 | 583 | $rv = ''; |
536 | 584 | $ais_chars = array( |
537 | 585 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -544,9 +592,12 @@ discard block |
||
544 | 592 | ); |
545 | 593 | // " |
546 | 594 | $_a = str_split($name); |
547 | - if ($_a) foreach ($_a as $_1) { |
|
595 | + if ($_a) { |
|
596 | + foreach ($_a as $_1) { |
|
548 | 597 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
549 | - else $dec = 0; |
|
598 | + } else { |
|
599 | + $dec = 0; |
|
600 | + } |
|
550 | 601 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
551 | 602 | $rv .= $bin; |
552 | 603 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -558,7 +609,9 @@ discard block |
||
558 | 609 | $len_bit = strlen($_enc); |
559 | 610 | $rem6 = $len_bit % 6; |
560 | 611 | $pad6_len = 0; |
561 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
612 | + if ($rem6) { |
|
613 | + $pad6_len = 6 - $rem6; |
|
614 | + } |
|
562 | 615 | //echo $pad6_len.'<br>'; |
563 | 616 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
564 | 617 | $len_enc = strlen($_enc) / 6; |
@@ -567,8 +620,11 @@ discard block |
||
567 | 620 | for ($i=0; $i<$len_enc; $i++) { |
568 | 621 | $offset = $i * 6; |
569 | 622 | $dec = bindec(substr($_enc,$offset,6)); |
570 | - if ($dec < 40) $dec += 48; |
|
571 | - else $dec += 56; |
|
623 | + if ($dec < 40) { |
|
624 | + $dec += 48; |
|
625 | + } else { |
|
626 | + $dec += 56; |
|
627 | + } |
|
572 | 628 | //echo chr($dec)." $dec<br/>"; |
573 | 629 | $itu .= chr($dec); |
574 | 630 | } |
@@ -581,26 +637,42 @@ discard block |
||
581 | 637 | } |
582 | 638 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
583 | 639 | $lsb = $chksum & 0x0F; |
584 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
585 | - else $lsbc = '0'; |
|
640 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
641 | + $lsbc = $hex_arr[$lsb]; |
|
642 | + } else { |
|
643 | + $lsbc = '0'; |
|
644 | + } |
|
586 | 645 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
587 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
588 | - else $msbc = '0'; |
|
646 | + if ($msb >=0 && $msb <= 15 ) { |
|
647 | + $msbc = $hex_arr[$msb]; |
|
648 | + } else { |
|
649 | + $msbc = '0'; |
|
650 | + } |
|
589 | 651 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
590 | 652 | return $itu; |
591 | 653 | } |
592 | 654 | |
593 | 655 | public function parse($buffer) { |
594 | 656 | $data = $this->process_ais_buf($buffer); |
595 | - if (!is_object($data)) return array(); |
|
657 | + if (!is_object($data)) { |
|
658 | + return array(); |
|
659 | + } |
|
596 | 660 | $result = array(); |
597 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
598 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
661 | + if ($data->lon != 0) { |
|
662 | + $result['longitude'] = $data->lon; |
|
663 | + } |
|
664 | + if ($data->lat != 0) { |
|
665 | + $result['latitude'] = $data->lat; |
|
666 | + } |
|
599 | 667 | $result['ident'] = trim($data->name); |
600 | 668 | $result['timestamp'] = $data->ts; |
601 | 669 | $result['mmsi'] = $data->mmsi; |
602 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
603 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
670 | + if ($data->sog != -1.0) { |
|
671 | + $result['speed'] = $data->sog; |
|
672 | + } |
|
673 | + if ($data->cog != 0) { |
|
674 | + $result['heading'] = $data->cog; |
|
675 | + } |
|
604 | 676 | /* |
605 | 677 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
606 | 678 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -610,15 +682,25 @@ discard block |
||
610 | 682 | |
611 | 683 | public function mmsitype($mmsi) { |
612 | 684 | if (strlen($mmsi) == 9) { |
613 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
614 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
615 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
616 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
617 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
618 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
619 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
620 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
621 | - else return 'Ship'; |
|
685 | + if (substr($mmsi,0,3) == '974') { |
|
686 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
687 | + } elseif (substr($mmsi,0,3) == '972') { |
|
688 | + return 'MOB (Man Overboard) device'; |
|
689 | + } elseif (substr($mmsi,0,3) == '970') { |
|
690 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
691 | + } elseif (substr($mmsi,0,3) == '111') { |
|
692 | + return 'SAR (Search and Rescue) aircraft'; |
|
693 | + } elseif (substr($mmsi,0,2) == '98') { |
|
694 | + return 'Auxiliary craft associated with a parent ship'; |
|
695 | + } elseif (substr($mmsi,0,2) == '99') { |
|
696 | + return 'Aids to Navigation'; |
|
697 | + } elseif (substr($mmsi,0,2) == '00') { |
|
698 | + return 'Coastal stations'; |
|
699 | + } elseif (substr($mmsi,0,1) == '0') { |
|
700 | + return 'Group of ships'; |
|
701 | + } else { |
|
702 | + return 'Ship'; |
|
703 | + } |
|
622 | 704 | } |
623 | 705 | |
624 | 706 | |
@@ -634,32 +716,61 @@ discard block |
||
634 | 716 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
635 | 717 | return array(); |
636 | 718 | } |
637 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
638 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
719 | + if ($data->lon != 0) { |
|
720 | + $result['longitude'] = $data->lon; |
|
721 | + } |
|
722 | + if ($data->lat != 0) { |
|
723 | + $result['latitude'] = $data->lat; |
|
724 | + } |
|
639 | 725 | $result['ident'] = trim(str_replace('@','',$data->name)); |
640 | 726 | $result['timestamp'] = $data->ts; |
641 | 727 | $result['mmsi'] = $data->mmsi; |
642 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
728 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
729 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
730 | + } |
|
643 | 731 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
644 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
645 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
646 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
647 | - if ($data->status != '') $result['status'] = $data->status; |
|
648 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
649 | - if ($data->type !== '') $result['type'] = $data->type; |
|
650 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
651 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
652 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
732 | + if ($data->sog != -1.0) { |
|
733 | + $result['speed'] = $data->sog; |
|
734 | + } |
|
735 | + if ($data->heading !== '') { |
|
736 | + $result['heading'] = $data->heading; |
|
737 | + } elseif ($data->cog != 0) { |
|
738 | + $result['heading'] = $data->cog; |
|
739 | + } |
|
740 | + if ($data->status != '') { |
|
741 | + $result['status'] = $data->status; |
|
742 | + } |
|
743 | + if ($data->statusid !== '') { |
|
744 | + $result['statusid'] = $data->statusid; |
|
745 | + } |
|
746 | + if ($data->type !== '') { |
|
747 | + $result['type'] = $data->type; |
|
748 | + } |
|
749 | + if ($data->typeid !== '') { |
|
750 | + $result['typeid'] = $data->typeid; |
|
751 | + } |
|
752 | + if ($data->imo !== '') { |
|
753 | + $result['imo'] = $data->imo; |
|
754 | + } |
|
755 | + if ($data->callsign !== '') { |
|
756 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
757 | + } |
|
653 | 758 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
654 | 759 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
655 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
760 | + if ($eta_ts != '') { |
|
761 | + $result['eta_ts'] = $eta_ts; |
|
762 | + } |
|
656 | 763 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
657 | 764 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
658 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
765 | + if ($eta_ts != '') { |
|
766 | + $result['eta_ts'] = $eta_ts; |
|
767 | + } |
|
659 | 768 | } |
660 | 769 | if ($data->destination != '') { |
661 | 770 | $dest = trim(str_replace('@','',$data->destination)); |
662 | - if ($dest != '') $result['destination'] = $dest; |
|
771 | + if ($dest != '') { |
|
772 | + $result['destination'] = $dest; |
|
773 | + } |
|
663 | 774 | } |
664 | 775 | $result['all'] = (array) $data; |
665 | 776 | /* |
@@ -15,10 +15,14 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct($dbc = null) { |
17 | 17 | global $globalFilterName; |
18 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
18 | + if (isset($globalFilterName)) { |
|
19 | + $this->filter_name = $globalFilterName; |
|
20 | + } |
|
19 | 21 | $Connection = new Connection($dbc); |
20 | 22 | $this->db = $Connection->db(); |
21 | - if ($this->db === null) die('Error: No DB connection. (Stats)'); |
|
23 | + if ($this->db === null) { |
|
24 | + die('Error: No DB connection. (Stats)'); |
|
25 | + } |
|
22 | 26 | } |
23 | 27 | |
24 | 28 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -86,7 +90,9 @@ discard block |
||
86 | 90 | |
87 | 91 | public function getAllAirlineNames($filter_name = '') { |
88 | 92 | global $globalStatsFilters; |
89 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
93 | + if ($filter_name == '') { |
|
94 | + $filter_name = $this->filter_name; |
|
95 | + } |
|
90 | 96 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
91 | 97 | try { |
92 | 98 | $sth = $this->db->prepare($query); |
@@ -106,7 +112,9 @@ discard block |
||
106 | 112 | return $all; |
107 | 113 | } |
108 | 114 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
109 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
115 | + if ($filter_name == '') { |
|
116 | + $filter_name = $this->filter_name; |
|
117 | + } |
|
110 | 118 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
111 | 119 | try { |
112 | 120 | $sth = $this->db->prepare($query); |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | return $all; |
119 | 127 | } |
120 | 128 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
129 | + if ($filter_name == '') { |
|
130 | + $filter_name = $this->filter_name; |
|
131 | + } |
|
122 | 132 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
123 | 133 | try { |
124 | 134 | $sth = $this->db->prepare($query); |
@@ -130,7 +140,9 @@ discard block |
||
130 | 140 | return $all; |
131 | 141 | } |
132 | 142 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
133 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
143 | + if ($filter_name == '') { |
|
144 | + $filter_name = $this->filter_name; |
|
145 | + } |
|
134 | 146 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
135 | 147 | try { |
136 | 148 | $sth = $this->db->prepare($query); |
@@ -143,7 +155,9 @@ discard block |
||
143 | 155 | } |
144 | 156 | |
145 | 157 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | + if ($filter_name == '') { |
|
159 | + $filter_name = $this->filter_name; |
|
160 | + } |
|
147 | 161 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
148 | 162 | try { |
149 | 163 | $sth = $this->db->prepare($query); |
@@ -156,7 +170,9 @@ discard block |
||
156 | 170 | } |
157 | 171 | |
158 | 172 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
159 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
173 | + if ($filter_name == '') { |
|
174 | + $filter_name = $this->filter_name; |
|
175 | + } |
|
160 | 176 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
161 | 177 | try { |
162 | 178 | $sth = $this->db->prepare($query); |
@@ -171,7 +187,9 @@ discard block |
||
171 | 187 | |
172 | 188 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
173 | 189 | global $globalStatsFilters; |
174 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
190 | + if ($filter_name == '') { |
|
191 | + $filter_name = $this->filter_name; |
|
192 | + } |
|
175 | 193 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
176 | 194 | $Spotter = new Spotter($this->db); |
177 | 195 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -180,8 +198,11 @@ discard block |
||
180 | 198 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
181 | 199 | } |
182 | 200 | if ($year == '' && $month == '') { |
183 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
184 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
201 | + if ($limit) { |
|
202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
203 | + } else { |
|
204 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
205 | + } |
|
185 | 206 | try { |
186 | 207 | $sth = $this->db->prepare($query); |
187 | 208 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,11 +210,16 @@ discard block |
||
189 | 210 | echo "error : ".$e->getMessage(); |
190 | 211 | } |
191 | 212 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
192 | - } else $all = array(); |
|
213 | + } else { |
|
214 | + $all = array(); |
|
215 | + } |
|
193 | 216 | } else { |
194 | 217 | if ($year == '' && $month == '') { |
195 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
196 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
218 | + if ($limit) { |
|
219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
220 | + } else { |
|
221 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
222 | + } |
|
197 | 223 | try { |
198 | 224 | $sth = $this->db->prepare($query); |
199 | 225 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -201,7 +227,9 @@ discard block |
||
201 | 227 | echo "error : ".$e->getMessage(); |
202 | 228 | } |
203 | 229 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
204 | - } else $all = array(); |
|
230 | + } else { |
|
231 | + $all = array(); |
|
232 | + } |
|
205 | 233 | } |
206 | 234 | if (empty($all)) { |
207 | 235 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -220,10 +248,15 @@ discard block |
||
220 | 248 | } |
221 | 249 | public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
222 | 250 | global $globalStatsFilters; |
223 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
251 | + if ($filter_name == '') { |
|
252 | + $filter_name = $this->filter_name; |
|
253 | + } |
|
224 | 254 | if ($year == '' && $month == '') { |
225 | - if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
226 | - else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
255 | + if ($limit) { |
|
256 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
257 | + } else { |
|
258 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
259 | + } |
|
227 | 260 | try { |
228 | 261 | $sth = $this->db->prepare($query); |
229 | 262 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -231,7 +264,9 @@ discard block |
||
231 | 264 | echo "error : ".$e->getMessage(); |
232 | 265 | } |
233 | 266 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
234 | - } else $all = array(); |
|
267 | + } else { |
|
268 | + $all = array(); |
|
269 | + } |
|
235 | 270 | if (empty($all)) { |
236 | 271 | $filters = array('year' => $year,'month' => $month); |
237 | 272 | if ($filter_name != '') { |
@@ -245,10 +280,15 @@ discard block |
||
245 | 280 | } |
246 | 281 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
247 | 282 | global $globalStatsFilters; |
248 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
283 | + if ($filter_name == '') { |
|
284 | + $filter_name = $this->filter_name; |
|
285 | + } |
|
249 | 286 | if ($year == '' && $month == '') { |
250 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
251 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
287 | + if ($limit) { |
|
288 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
289 | + } else { |
|
290 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
291 | + } |
|
252 | 292 | try { |
253 | 293 | $sth = $this->db->prepare($query); |
254 | 294 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -256,7 +296,9 @@ discard block |
||
256 | 296 | echo "error : ".$e->getMessage(); |
257 | 297 | } |
258 | 298 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
259 | - } else $all = array(); |
|
299 | + } else { |
|
300 | + $all = array(); |
|
301 | + } |
|
260 | 302 | if (empty($all)) { |
261 | 303 | $Spotter = new Spotter($this->db); |
262 | 304 | $filters = array(); |
@@ -271,7 +313,9 @@ discard block |
||
271 | 313 | } |
272 | 314 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
273 | 315 | global $globalStatsFilters; |
274 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
316 | + if ($filter_name == '') { |
|
317 | + $filter_name = $this->filter_name; |
|
318 | + } |
|
275 | 319 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
276 | 320 | $Spotter = new Spotter($this->db); |
277 | 321 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -280,8 +324,11 @@ discard block |
||
280 | 324 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
281 | 325 | } |
282 | 326 | if ($year == '' && $month == '') { |
283 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
284 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
327 | + if ($limit) { |
|
328 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
329 | + } else { |
|
330 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
331 | + } |
|
285 | 332 | try { |
286 | 333 | $sth = $this->db->prepare($query); |
287 | 334 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -289,11 +336,16 @@ discard block |
||
289 | 336 | echo "error : ".$e->getMessage(); |
290 | 337 | } |
291 | 338 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
292 | - } else $all = array(); |
|
339 | + } else { |
|
340 | + $all = array(); |
|
341 | + } |
|
293 | 342 | } else { |
294 | 343 | if ($year == '' && $month == '') { |
295 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
296 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
344 | + if ($limit) { |
|
345 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
346 | + } else { |
|
347 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
348 | + } |
|
297 | 349 | try { |
298 | 350 | $sth = $this->db->prepare($query); |
299 | 351 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -301,7 +353,9 @@ discard block |
||
301 | 353 | echo "error : ".$e->getMessage(); |
302 | 354 | } |
303 | 355 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
304 | - } else $all = array(); |
|
356 | + } else { |
|
357 | + $all = array(); |
|
358 | + } |
|
305 | 359 | } |
306 | 360 | if (empty($all)) { |
307 | 361 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -321,7 +375,9 @@ discard block |
||
321 | 375 | |
322 | 376 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
323 | 377 | global $globalStatsFilters; |
324 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
378 | + if ($filter_name == '') { |
|
379 | + $filter_name = $this->filter_name; |
|
380 | + } |
|
325 | 381 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
326 | 382 | $Spotter = new Spotter($this->db); |
327 | 383 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -330,8 +386,11 @@ discard block |
||
330 | 386 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
331 | 387 | } |
332 | 388 | if ($year == '' && $month == '') { |
333 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
334 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
389 | + if ($limit) { |
|
390 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
391 | + } else { |
|
392 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
393 | + } |
|
335 | 394 | try { |
336 | 395 | $sth = $this->db->prepare($query); |
337 | 396 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -339,11 +398,16 @@ discard block |
||
339 | 398 | echo "error : ".$e->getMessage(); |
340 | 399 | } |
341 | 400 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
342 | - } else $all = array(); |
|
401 | + } else { |
|
402 | + $all = array(); |
|
403 | + } |
|
343 | 404 | } else { |
344 | 405 | if ($year == '' && $month == '') { |
345 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
346 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
406 | + if ($limit) { |
|
407 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
408 | + } else { |
|
409 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
410 | + } |
|
347 | 411 | try { |
348 | 412 | $sth = $this->db->prepare($query); |
349 | 413 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -351,7 +415,9 @@ discard block |
||
351 | 415 | echo "error : ".$e->getMessage(); |
352 | 416 | } |
353 | 417 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
354 | - } else $all = array(); |
|
418 | + } else { |
|
419 | + $all = array(); |
|
420 | + } |
|
355 | 421 | } |
356 | 422 | if (empty($all)) { |
357 | 423 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -370,7 +436,9 @@ discard block |
||
370 | 436 | } |
371 | 437 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
372 | 438 | global $globalStatsFilters; |
373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
439 | + if ($filter_name == '') { |
|
440 | + $filter_name = $this->filter_name; |
|
441 | + } |
|
374 | 442 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
375 | 443 | $Spotter = new Spotter($this->db); |
376 | 444 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -378,12 +446,18 @@ discard block |
||
378 | 446 | foreach ($airlines as $airline) { |
379 | 447 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
380 | 448 | } |
381 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
382 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
449 | + if ($limit) { |
|
450 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
451 | + } else { |
|
452 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
453 | + } |
|
383 | 454 | $query_values = array(':filter_name' => $filter_name); |
384 | 455 | } else { |
385 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
386 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
456 | + if ($limit) { |
|
457 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
458 | + } else { |
|
459 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
460 | + } |
|
387 | 461 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
388 | 462 | } |
389 | 463 | try { |
@@ -411,17 +485,29 @@ discard block |
||
411 | 485 | |
412 | 486 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
413 | 487 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
414 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
488 | + if ($filter_name == '') { |
|
489 | + $filter_name = $this->filter_name; |
|
490 | + } |
|
415 | 491 | if ($year == '' && $month == '') { |
416 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
417 | - if ($globalIVAO) $forsource = 'ivao'; |
|
492 | + if ($globalVATSIM) { |
|
493 | + $forsource = 'vatsim'; |
|
494 | + } |
|
495 | + if ($globalIVAO) { |
|
496 | + $forsource = 'ivao'; |
|
497 | + } |
|
418 | 498 | if (isset($forsource)) { |
419 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
420 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
499 | + if ($limit) { |
|
500 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
501 | + } else { |
|
502 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
503 | + } |
|
421 | 504 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
422 | 505 | } else { |
423 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
424 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
506 | + if ($limit) { |
|
507 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
508 | + } else { |
|
509 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
510 | + } |
|
425 | 511 | $query_values = array(':filter_name' => $filter_name); |
426 | 512 | } |
427 | 513 | try { |
@@ -431,7 +517,9 @@ discard block |
||
431 | 517 | echo "error : ".$e->getMessage(); |
432 | 518 | } |
433 | 519 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
434 | - } else $all = array(); |
|
520 | + } else { |
|
521 | + $all = array(); |
|
522 | + } |
|
435 | 523 | if (empty($all)) { |
436 | 524 | $Spotter = new Spotter($this->db); |
437 | 525 | $filters = array(); |
@@ -446,7 +534,9 @@ discard block |
||
446 | 534 | } |
447 | 535 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 536 | global $globalStatsFilters; |
449 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
537 | + if ($filter_name == '') { |
|
538 | + $filter_name = $this->filter_name; |
|
539 | + } |
|
450 | 540 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
451 | 541 | $Spotter = new Spotter($this->db); |
452 | 542 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -455,8 +545,11 @@ discard block |
||
455 | 545 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
456 | 546 | } |
457 | 547 | if ($year == '' && $month == '') { |
458 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
459 | - else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
548 | + if ($limit) { |
|
549 | + $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
550 | + } else { |
|
551 | + $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
552 | + } |
|
460 | 553 | try { |
461 | 554 | $sth = $this->db->prepare($query); |
462 | 555 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -464,11 +557,16 @@ discard block |
||
464 | 557 | echo "error : ".$e->getMessage(); |
465 | 558 | } |
466 | 559 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
467 | - } else $all = array(); |
|
560 | + } else { |
|
561 | + $all = array(); |
|
562 | + } |
|
468 | 563 | } else { |
469 | 564 | if ($year == '' && $month == '') { |
470 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
471 | - else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
565 | + if ($limit) { |
|
566 | + $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
567 | + } else { |
|
568 | + $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
569 | + } |
|
472 | 570 | try { |
473 | 571 | $sth = $this->db->prepare($query); |
474 | 572 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -476,7 +574,9 @@ discard block |
||
476 | 574 | echo "error : ".$e->getMessage(); |
477 | 575 | } |
478 | 576 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
479 | - } else $all = array(); |
|
577 | + } else { |
|
578 | + $all = array(); |
|
579 | + } |
|
480 | 580 | } |
481 | 581 | if (empty($all)) { |
482 | 582 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -495,7 +595,9 @@ discard block |
||
495 | 595 | } |
496 | 596 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
497 | 597 | global $globalStatsFilters; |
498 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
598 | + if ($filter_name == '') { |
|
599 | + $filter_name = $this->filter_name; |
|
600 | + } |
|
499 | 601 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
500 | 602 | $Spotter = new Spotter($this->db); |
501 | 603 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -504,8 +606,11 @@ discard block |
||
504 | 606 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
505 | 607 | } |
506 | 608 | if ($year == '' && $month == '') { |
507 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
508 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
609 | + if ($limit) { |
|
610 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
611 | + } else { |
|
612 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
613 | + } |
|
509 | 614 | try { |
510 | 615 | $sth = $this->db->prepare($query); |
511 | 616 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -513,11 +618,16 @@ discard block |
||
513 | 618 | echo "error : ".$e->getMessage(); |
514 | 619 | } |
515 | 620 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
516 | - } else $all = array(); |
|
621 | + } else { |
|
622 | + $all = array(); |
|
623 | + } |
|
517 | 624 | } else { |
518 | 625 | if ($year == '' && $month == '') { |
519 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
520 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
626 | + if ($limit) { |
|
627 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
628 | + } else { |
|
629 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
630 | + } |
|
521 | 631 | try { |
522 | 632 | $sth = $this->db->prepare($query); |
523 | 633 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -525,7 +635,9 @@ discard block |
||
525 | 635 | echo "error : ".$e->getMessage(); |
526 | 636 | } |
527 | 637 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
528 | - } else $all = array(); |
|
638 | + } else { |
|
639 | + $all = array(); |
|
640 | + } |
|
529 | 641 | } |
530 | 642 | if (empty($all)) { |
531 | 643 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -544,7 +656,9 @@ discard block |
||
544 | 656 | } |
545 | 657 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
546 | 658 | $Connection = new Connection($this->db); |
547 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
659 | + if ($filter_name == '') { |
|
660 | + $filter_name = $this->filter_name; |
|
661 | + } |
|
548 | 662 | if ($Connection->tableExists('countries')) { |
549 | 663 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
550 | 664 | $Spotter = new Spotter($this->db); |
@@ -554,8 +668,11 @@ discard block |
||
554 | 668 | foreach ($airlines as $airline) { |
555 | 669 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
556 | 670 | } |
557 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
558 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
671 | + if ($limit) { |
|
672 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
673 | + } else { |
|
674 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
675 | + } |
|
559 | 676 | try { |
560 | 677 | $sth = $this->db->prepare($query); |
561 | 678 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -564,11 +681,16 @@ discard block |
||
564 | 681 | } |
565 | 682 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
566 | 683 | return $all; |
567 | - } else return array(); |
|
684 | + } else { |
|
685 | + return array(); |
|
686 | + } |
|
568 | 687 | } else { |
569 | 688 | if ($year == '' && $month == '') { |
570 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
571 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
689 | + if ($limit) { |
|
690 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
691 | + } else { |
|
692 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
693 | + } |
|
572 | 694 | try { |
573 | 695 | $sth = $this->db->prepare($query); |
574 | 696 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -577,20 +699,29 @@ discard block |
||
577 | 699 | } |
578 | 700 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
579 | 701 | return $all; |
580 | - } else return array(); |
|
702 | + } else { |
|
703 | + return array(); |
|
704 | + } |
|
581 | 705 | } |
582 | 706 | $Spotter = new Spotter($this->db); |
583 | 707 | return $Spotter->countAllFlightOverCountries($limit); |
584 | - } else return array(); |
|
708 | + } else { |
|
709 | + return array(); |
|
710 | + } |
|
585 | 711 | } |
586 | 712 | public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
587 | 713 | $Connection = new Connection($this->db); |
588 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
714 | + if ($filter_name == '') { |
|
715 | + $filter_name = $this->filter_name; |
|
716 | + } |
|
589 | 717 | if ($Connection->tableExists('countries')) { |
590 | 718 | $all = array(); |
591 | 719 | if ($year == '' && $month == '') { |
592 | - if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
593 | - else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
720 | + if ($limit) { |
|
721 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
722 | + } else { |
|
723 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
724 | + } |
|
594 | 725 | try { |
595 | 726 | $sth = $this->db->prepare($query); |
596 | 727 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,17 +739,24 @@ discard block |
||
608 | 739 | $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
609 | 740 | } |
610 | 741 | return $all; |
611 | - } else return array(); |
|
742 | + } else { |
|
743 | + return array(); |
|
744 | + } |
|
612 | 745 | } |
613 | 746 | public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
614 | 747 | global $globalStatsFilters; |
615 | 748 | $Connection = new Connection($this->db); |
616 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
749 | + if ($filter_name == '') { |
|
750 | + $filter_name = $this->filter_name; |
|
751 | + } |
|
617 | 752 | if ($Connection->tableExists('countries')) { |
618 | 753 | $all = array(); |
619 | 754 | if ($year == '' && $month == '') { |
620 | - if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
621 | - else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
755 | + if ($limit) { |
|
756 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
757 | + } else { |
|
758 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
759 | + } |
|
622 | 760 | try { |
623 | 761 | $sth = $this->db->prepare($query); |
624 | 762 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -637,14 +775,21 @@ discard block |
||
637 | 775 | $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
638 | 776 | } |
639 | 777 | return $all; |
640 | - } else return array(); |
|
778 | + } else { |
|
779 | + return array(); |
|
780 | + } |
|
641 | 781 | } |
642 | 782 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
643 | 783 | global $globalStatsFilters; |
644 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
784 | + if ($filter_name == '') { |
|
785 | + $filter_name = $this->filter_name; |
|
786 | + } |
|
645 | 787 | if ($year == '' && $month == '') { |
646 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
647 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
788 | + if ($limit) { |
|
789 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
790 | + } else { |
|
791 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
792 | + } |
|
648 | 793 | try { |
649 | 794 | $sth = $this->db->prepare($query); |
650 | 795 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -652,7 +797,9 @@ discard block |
||
652 | 797 | echo "error : ".$e->getMessage(); |
653 | 798 | } |
654 | 799 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
655 | - } else $all = array(); |
|
800 | + } else { |
|
801 | + $all = array(); |
|
802 | + } |
|
656 | 803 | if (empty($all)) { |
657 | 804 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
658 | 805 | if ($filter_name != '') { |
@@ -667,7 +814,9 @@ discard block |
||
667 | 814 | |
668 | 815 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
669 | 816 | global $globalStatsFilters; |
670 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
817 | + if ($filter_name == '') { |
|
818 | + $filter_name = $this->filter_name; |
|
819 | + } |
|
671 | 820 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
672 | 821 | $Spotter = new Spotter($this->db); |
673 | 822 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -676,8 +825,11 @@ discard block |
||
676 | 825 | foreach ($airlines as $airline) { |
677 | 826 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
678 | 827 | } |
679 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
680 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
828 | + if ($limit) { |
|
829 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
830 | + } else { |
|
831 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
832 | + } |
|
681 | 833 | try { |
682 | 834 | $sth = $this->db->prepare($query); |
683 | 835 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -685,11 +837,16 @@ discard block |
||
685 | 837 | echo "error : ".$e->getMessage(); |
686 | 838 | } |
687 | 839 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
688 | - } else $all = array(); |
|
840 | + } else { |
|
841 | + $all = array(); |
|
842 | + } |
|
689 | 843 | } else { |
690 | 844 | if ($year == '' && $month == '') { |
691 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
692 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
845 | + if ($limit) { |
|
846 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
847 | + } else { |
|
848 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
849 | + } |
|
693 | 850 | try { |
694 | 851 | $sth = $this->db->prepare($query); |
695 | 852 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -697,7 +854,9 @@ discard block |
||
697 | 854 | echo "error : ".$e->getMessage(); |
698 | 855 | } |
699 | 856 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
700 | - } else $all = array(); |
|
857 | + } else { |
|
858 | + $all = array(); |
|
859 | + } |
|
701 | 860 | } |
702 | 861 | if (empty($all)) { |
703 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -716,7 +875,9 @@ discard block |
||
716 | 875 | } |
717 | 876 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
718 | 877 | global $globalStatsFilters; |
719 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
878 | + if ($filter_name == '') { |
|
879 | + $filter_name = $this->filter_name; |
|
880 | + } |
|
720 | 881 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
721 | 882 | $Spotter = new Spotter($this->db); |
722 | 883 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -725,8 +886,11 @@ discard block |
||
725 | 886 | foreach ($airlines as $airline) { |
726 | 887 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
727 | 888 | } |
728 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
729 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
889 | + if ($limit) { |
|
890 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
891 | + } else { |
|
892 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
893 | + } |
|
730 | 894 | try { |
731 | 895 | $sth = $this->db->prepare($query); |
732 | 896 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -734,11 +898,16 @@ discard block |
||
734 | 898 | echo "error : ".$e->getMessage(); |
735 | 899 | } |
736 | 900 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
737 | - } else $all = array(); |
|
901 | + } else { |
|
902 | + $all = array(); |
|
903 | + } |
|
738 | 904 | } else { |
739 | 905 | if ($year == '' && $month == '') { |
740 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
741 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
906 | + if ($limit) { |
|
907 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
908 | + } else { |
|
909 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
910 | + } |
|
742 | 911 | try { |
743 | 912 | $sth = $this->db->prepare($query); |
744 | 913 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -746,7 +915,9 @@ discard block |
||
746 | 915 | echo "error : ".$e->getMessage(); |
747 | 916 | } |
748 | 917 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
749 | - } else $all = array(); |
|
918 | + } else { |
|
919 | + $all = array(); |
|
920 | + } |
|
750 | 921 | } |
751 | 922 | if (empty($all)) { |
752 | 923 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -771,7 +942,9 @@ discard block |
||
771 | 942 | $icao = $value['airport_departure_icao']; |
772 | 943 | if (isset($all[$icao])) { |
773 | 944 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
774 | - } else $all[$icao] = $value; |
|
945 | + } else { |
|
946 | + $all[$icao] = $value; |
|
947 | + } |
|
775 | 948 | } |
776 | 949 | $count = array(); |
777 | 950 | foreach ($all as $key => $row) { |
@@ -783,7 +956,9 @@ discard block |
||
783 | 956 | } |
784 | 957 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
785 | 958 | global $globalStatsFilters; |
786 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
959 | + if ($filter_name == '') { |
|
960 | + $filter_name = $this->filter_name; |
|
961 | + } |
|
787 | 962 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
788 | 963 | $Spotter = new Spotter($this->db); |
789 | 964 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -792,8 +967,11 @@ discard block |
||
792 | 967 | foreach ($airlines as $airline) { |
793 | 968 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
794 | 969 | } |
795 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
796 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
970 | + if ($limit) { |
|
971 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
972 | + } else { |
|
973 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
974 | + } |
|
797 | 975 | try { |
798 | 976 | $sth = $this->db->prepare($query); |
799 | 977 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -801,11 +979,16 @@ discard block |
||
801 | 979 | echo "error : ".$e->getMessage(); |
802 | 980 | } |
803 | 981 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
804 | - } else $all = array(); |
|
982 | + } else { |
|
983 | + $all = array(); |
|
984 | + } |
|
805 | 985 | } else { |
806 | 986 | if ($year == '' && $month == '') { |
807 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
808 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
987 | + if ($limit) { |
|
988 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
989 | + } else { |
|
990 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
991 | + } |
|
809 | 992 | try { |
810 | 993 | $sth = $this->db->prepare($query); |
811 | 994 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -813,7 +996,9 @@ discard block |
||
813 | 996 | echo "error : ".$e->getMessage(); |
814 | 997 | } |
815 | 998 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
816 | - } else $all = array(); |
|
999 | + } else { |
|
1000 | + $all = array(); |
|
1001 | + } |
|
817 | 1002 | } |
818 | 1003 | if (empty($all)) { |
819 | 1004 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -838,7 +1023,9 @@ discard block |
||
838 | 1023 | $icao = $value['airport_arrival_icao']; |
839 | 1024 | if (isset($all[$icao])) { |
840 | 1025 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
841 | - } else $all[$icao] = $value; |
|
1026 | + } else { |
|
1027 | + $all[$icao] = $value; |
|
1028 | + } |
|
842 | 1029 | } |
843 | 1030 | $count = array(); |
844 | 1031 | foreach ($all as $key => $row) { |
@@ -850,7 +1037,9 @@ discard block |
||
850 | 1037 | } |
851 | 1038 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
852 | 1039 | global $globalDBdriver, $globalStatsFilters; |
853 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1040 | + if ($filter_name == '') { |
|
1041 | + $filter_name = $this->filter_name; |
|
1042 | + } |
|
854 | 1043 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
855 | 1044 | $Spotter = new Spotter($this->db); |
856 | 1045 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -859,20 +1048,32 @@ discard block |
||
859 | 1048 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
860 | 1049 | } |
861 | 1050 | if ($globalDBdriver == 'mysql') { |
862 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
863 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1051 | + if ($limit) { |
|
1052 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1053 | + } else { |
|
1054 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1055 | + } |
|
864 | 1056 | } else { |
865 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
866 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1057 | + if ($limit) { |
|
1058 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1059 | + } else { |
|
1060 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1061 | + } |
|
867 | 1062 | } |
868 | 1063 | $query_data = array(':filter_name' => $filter_name); |
869 | 1064 | } else { |
870 | 1065 | if ($globalDBdriver == 'mysql') { |
871 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
872 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1066 | + if ($limit) { |
|
1067 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1068 | + } else { |
|
1069 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1070 | + } |
|
873 | 1071 | } else { |
874 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
875 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1072 | + if ($limit) { |
|
1073 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1074 | + } else { |
|
1075 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1076 | + } |
|
876 | 1077 | } |
877 | 1078 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
878 | 1079 | } |
@@ -900,13 +1101,21 @@ discard block |
||
900 | 1101 | |
901 | 1102 | public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') { |
902 | 1103 | global $globalDBdriver, $globalStatsFilters; |
903 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1104 | + if ($filter_name == '') { |
|
1105 | + $filter_name = $this->filter_name; |
|
1106 | + } |
|
904 | 1107 | if ($globalDBdriver == 'mysql') { |
905 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
906 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1108 | + if ($limit) { |
|
1109 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
1110 | + } else { |
|
1111 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1112 | + } |
|
907 | 1113 | } else { |
908 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
909 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1114 | + if ($limit) { |
|
1115 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
1116 | + } else { |
|
1117 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1118 | + } |
|
910 | 1119 | } |
911 | 1120 | $query_data = array(':filter_name' => $filter_name); |
912 | 1121 | try { |
@@ -929,13 +1138,21 @@ discard block |
||
929 | 1138 | |
930 | 1139 | public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') { |
931 | 1140 | global $globalDBdriver, $globalStatsFilters; |
932 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1141 | + if ($filter_name == '') { |
|
1142 | + $filter_name = $this->filter_name; |
|
1143 | + } |
|
933 | 1144 | if ($globalDBdriver == 'mysql') { |
934 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
935 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1145 | + if ($limit) { |
|
1146 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
1147 | + } else { |
|
1148 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1149 | + } |
|
936 | 1150 | } else { |
937 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
938 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1151 | + if ($limit) { |
|
1152 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
1153 | + } else { |
|
1154 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name"; |
|
1155 | + } |
|
939 | 1156 | } |
940 | 1157 | $query_data = array(':filter_name' => $filter_name); |
941 | 1158 | try { |
@@ -958,7 +1175,9 @@ discard block |
||
958 | 1175 | |
959 | 1176 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
960 | 1177 | global $globalStatsFilters; |
961 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1178 | + if ($filter_name == '') { |
|
1179 | + $filter_name = $this->filter_name; |
|
1180 | + } |
|
962 | 1181 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
963 | 1182 | $Spotter = new Spotter($this->db); |
964 | 1183 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -995,7 +1214,9 @@ discard block |
||
995 | 1214 | } |
996 | 1215 | public function countAllMarineDatesLastMonth($filter_name = '') { |
997 | 1216 | global $globalStatsFilters; |
998 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1217 | + if ($filter_name == '') { |
|
1218 | + $filter_name = $this->filter_name; |
|
1219 | + } |
|
999 | 1220 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name"; |
1000 | 1221 | $query_data = array(':filter_name' => $filter_name); |
1001 | 1222 | try { |
@@ -1017,7 +1238,9 @@ discard block |
||
1017 | 1238 | } |
1018 | 1239 | public function countAllTrackerDatesLastMonth($filter_name = '') { |
1019 | 1240 | global $globalStatsFilters; |
1020 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1241 | + if ($filter_name == '') { |
|
1242 | + $filter_name = $this->filter_name; |
|
1243 | + } |
|
1021 | 1244 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name"; |
1022 | 1245 | $query_data = array(':filter_name' => $filter_name); |
1023 | 1246 | try { |
@@ -1039,7 +1262,9 @@ discard block |
||
1039 | 1262 | } |
1040 | 1263 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
1041 | 1264 | global $globalDBdriver, $globalStatsFilters; |
1042 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1265 | + if ($filter_name == '') { |
|
1266 | + $filter_name = $this->filter_name; |
|
1267 | + } |
|
1043 | 1268 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1044 | 1269 | $Spotter = new Spotter($this->db); |
1045 | 1270 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1084,7 +1309,9 @@ discard block |
||
1084 | 1309 | } |
1085 | 1310 | public function countAllMarineDatesLast7Days($filter_name = '') { |
1086 | 1311 | global $globalDBdriver, $globalStatsFilters; |
1087 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1312 | + if ($filter_name == '') { |
|
1313 | + $filter_name = $this->filter_name; |
|
1314 | + } |
|
1088 | 1315 | if ($globalDBdriver == 'mysql') { |
1089 | 1316 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
1090 | 1317 | } else { |
@@ -1110,7 +1337,9 @@ discard block |
||
1110 | 1337 | } |
1111 | 1338 | public function countAllTrackerDatesLast7Days($filter_name = '') { |
1112 | 1339 | global $globalDBdriver, $globalStatsFilters; |
1113 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1340 | + if ($filter_name == '') { |
|
1341 | + $filter_name = $this->filter_name; |
|
1342 | + } |
|
1114 | 1343 | if ($globalDBdriver == 'mysql') { |
1115 | 1344 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
1116 | 1345 | } else { |
@@ -1136,7 +1365,9 @@ discard block |
||
1136 | 1365 | } |
1137 | 1366 | public function countAllDates($stats_airline = '',$filter_name = '') { |
1138 | 1367 | global $globalStatsFilters; |
1139 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1368 | + if ($filter_name == '') { |
|
1369 | + $filter_name = $this->filter_name; |
|
1370 | + } |
|
1140 | 1371 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1141 | 1372 | $Spotter = new Spotter($this->db); |
1142 | 1373 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1173,7 +1404,9 @@ discard block |
||
1173 | 1404 | } |
1174 | 1405 | public function countAllDatesMarine($filter_name = '') { |
1175 | 1406 | global $globalStatsFilters; |
1176 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1407 | + if ($filter_name == '') { |
|
1408 | + $filter_name = $this->filter_name; |
|
1409 | + } |
|
1177 | 1410 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
1178 | 1411 | $query_data = array(':filter_name' => $filter_name); |
1179 | 1412 | try { |
@@ -1195,7 +1428,9 @@ discard block |
||
1195 | 1428 | } |
1196 | 1429 | public function countAllDatesTracker($filter_name = '') { |
1197 | 1430 | global $globalStatsFilters; |
1198 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1431 | + if ($filter_name == '') { |
|
1432 | + $filter_name = $this->filter_name; |
|
1433 | + } |
|
1199 | 1434 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
1200 | 1435 | $query_data = array(':filter_name' => $filter_name); |
1201 | 1436 | try { |
@@ -1217,7 +1452,9 @@ discard block |
||
1217 | 1452 | } |
1218 | 1453 | public function countAllDatesByAirlines($filter_name = '') { |
1219 | 1454 | global $globalStatsFilters; |
1220 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1455 | + if ($filter_name == '') { |
|
1456 | + $filter_name = $this->filter_name; |
|
1457 | + } |
|
1221 | 1458 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
1222 | 1459 | $query_data = array('filter_name' => $filter_name); |
1223 | 1460 | try { |
@@ -1239,7 +1476,9 @@ discard block |
||
1239 | 1476 | } |
1240 | 1477 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
1241 | 1478 | global $globalStatsFilters, $globalDBdriver; |
1242 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1479 | + if ($filter_name == '') { |
|
1480 | + $filter_name = $this->filter_name; |
|
1481 | + } |
|
1243 | 1482 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1244 | 1483 | $Spotter = new Spotter($this->db); |
1245 | 1484 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1324,7 +1563,9 @@ discard block |
||
1324 | 1563 | } |
1325 | 1564 | public function countAllMilitaryMonths($filter_name = '') { |
1326 | 1565 | global $globalStatsFilters; |
1327 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1566 | + if ($filter_name == '') { |
|
1567 | + $filter_name = $this->filter_name; |
|
1568 | + } |
|
1328 | 1569 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
1329 | 1570 | try { |
1330 | 1571 | $sth = $this->db->prepare($query); |
@@ -1345,7 +1586,9 @@ discard block |
||
1345 | 1586 | } |
1346 | 1587 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
1347 | 1588 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1348 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1589 | + if ($filter_name == '') { |
|
1590 | + $filter_name = $this->filter_name; |
|
1591 | + } |
|
1349 | 1592 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1350 | 1593 | $Spotter = new Spotter($this->db); |
1351 | 1594 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1353,12 +1596,18 @@ discard block |
||
1353 | 1596 | foreach ($airlines as $airline) { |
1354 | 1597 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
1355 | 1598 | } |
1356 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1357 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1599 | + if ($limit) { |
|
1600 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1601 | + } else { |
|
1602 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1603 | + } |
|
1358 | 1604 | $query_data = array(':filter_name' => $filter_name); |
1359 | 1605 | } else { |
1360 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1361 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1606 | + if ($limit) { |
|
1607 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1608 | + } else { |
|
1609 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
1610 | + } |
|
1362 | 1611 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
1363 | 1612 | } |
1364 | 1613 | if ($orderby == 'hour') { |
@@ -1368,7 +1617,9 @@ discard block |
||
1368 | 1617 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
1369 | 1618 | } |
1370 | 1619 | } |
1371 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1620 | + if ($orderby == 'count') { |
|
1621 | + $query .= " ORDER BY hour_count DESC"; |
|
1622 | + } |
|
1372 | 1623 | try { |
1373 | 1624 | $sth = $this->db->prepare($query); |
1374 | 1625 | $sth->execute($query_data); |
@@ -1392,9 +1643,14 @@ discard block |
||
1392 | 1643 | } |
1393 | 1644 | public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') { |
1394 | 1645 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1395 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1396 | - if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1397 | - else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1646 | + if ($filter_name == '') { |
|
1647 | + $filter_name = $this->filter_name; |
|
1648 | + } |
|
1649 | + if ($limit) { |
|
1650 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1651 | + } else { |
|
1652 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1653 | + } |
|
1398 | 1654 | $query_data = array(':filter_name' => $filter_name); |
1399 | 1655 | if ($orderby == 'hour') { |
1400 | 1656 | if ($globalDBdriver == 'mysql') { |
@@ -1403,7 +1659,9 @@ discard block |
||
1403 | 1659 | $query .= " ORDER BY CAST(marine_date AS integer) ASC"; |
1404 | 1660 | } |
1405 | 1661 | } |
1406 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1662 | + if ($orderby == 'count') { |
|
1663 | + $query .= " ORDER BY hour_count DESC"; |
|
1664 | + } |
|
1407 | 1665 | try { |
1408 | 1666 | $sth = $this->db->prepare($query); |
1409 | 1667 | $sth->execute($query_data); |
@@ -1423,9 +1681,14 @@ discard block |
||
1423 | 1681 | } |
1424 | 1682 | public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') { |
1425 | 1683 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1426 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1427 | - if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1428 | - else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1684 | + if ($filter_name == '') { |
|
1685 | + $filter_name = $this->filter_name; |
|
1686 | + } |
|
1687 | + if ($limit) { |
|
1688 | + $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1689 | + } else { |
|
1690 | + $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1691 | + } |
|
1429 | 1692 | $query_data = array(':filter_name' => $filter_name); |
1430 | 1693 | if ($orderby == 'hour') { |
1431 | 1694 | if ($globalDBdriver == 'mysql') { |
@@ -1434,7 +1697,9 @@ discard block |
||
1434 | 1697 | $query .= " ORDER BY CAST(tracker_date AS integer) ASC"; |
1435 | 1698 | } |
1436 | 1699 | } |
1437 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1700 | + if ($orderby == 'count') { |
|
1701 | + $query .= " ORDER BY hour_count DESC"; |
|
1702 | + } |
|
1438 | 1703 | try { |
1439 | 1704 | $sth = $this->db->prepare($query); |
1440 | 1705 | $sth->execute($query_data); |
@@ -1454,8 +1719,12 @@ discard block |
||
1454 | 1719 | } |
1455 | 1720 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
1456 | 1721 | global $globalStatsFilters; |
1457 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1458 | - if ($year == '') $year = date('Y'); |
|
1722 | + if ($filter_name == '') { |
|
1723 | + $filter_name = $this->filter_name; |
|
1724 | + } |
|
1725 | + if ($year == '') { |
|
1726 | + $year = date('Y'); |
|
1727 | + } |
|
1459 | 1728 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
1460 | 1729 | if (empty($all)) { |
1461 | 1730 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1474,8 +1743,12 @@ discard block |
||
1474 | 1743 | } |
1475 | 1744 | public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
1476 | 1745 | global $globalStatsFilters; |
1477 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1478 | - if ($year == '') $year = date('Y'); |
|
1746 | + if ($filter_name == '') { |
|
1747 | + $filter_name = $this->filter_name; |
|
1748 | + } |
|
1749 | + if ($year == '') { |
|
1750 | + $year = date('Y'); |
|
1751 | + } |
|
1479 | 1752 | $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
1480 | 1753 | if (empty($all)) { |
1481 | 1754 | $filters = array('year' => $year,'month' => $month); |
@@ -1490,8 +1763,12 @@ discard block |
||
1490 | 1763 | } |
1491 | 1764 | public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
1492 | 1765 | global $globalStatsFilters; |
1493 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1494 | - if ($year == '') $year = date('Y'); |
|
1766 | + if ($filter_name == '') { |
|
1767 | + $filter_name = $this->filter_name; |
|
1768 | + } |
|
1769 | + if ($year == '') { |
|
1770 | + $year = date('Y'); |
|
1771 | + } |
|
1495 | 1772 | $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
1496 | 1773 | if (empty($all)) { |
1497 | 1774 | $filters = array('year' => $year,'month' => $month); |
@@ -1506,8 +1783,12 @@ discard block |
||
1506 | 1783 | } |
1507 | 1784 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
1508 | 1785 | global $globalStatsFilters; |
1509 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1510 | - if ($year == '') $year = date('Y'); |
|
1786 | + if ($filter_name == '') { |
|
1787 | + $filter_name = $this->filter_name; |
|
1788 | + } |
|
1789 | + if ($year == '') { |
|
1790 | + $year = date('Y'); |
|
1791 | + } |
|
1511 | 1792 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
1512 | 1793 | if (empty($all)) { |
1513 | 1794 | $filters = array(); |
@@ -1523,8 +1804,12 @@ discard block |
||
1523 | 1804 | } |
1524 | 1805 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
1525 | 1806 | global $globalStatsFilters; |
1526 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1527 | - if ($year == '') $year = date('Y'); |
|
1807 | + if ($filter_name == '') { |
|
1808 | + $filter_name = $this->filter_name; |
|
1809 | + } |
|
1810 | + if ($year == '') { |
|
1811 | + $year = date('Y'); |
|
1812 | + } |
|
1528 | 1813 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
1529 | 1814 | if (empty($all)) { |
1530 | 1815 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1543,7 +1828,9 @@ discard block |
||
1543 | 1828 | } |
1544 | 1829 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1545 | 1830 | global $globalStatsFilters; |
1546 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1831 | + if ($filter_name == '') { |
|
1832 | + $filter_name = $this->filter_name; |
|
1833 | + } |
|
1547 | 1834 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1548 | 1835 | $Spotter = new Spotter($this->db); |
1549 | 1836 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1561,7 +1848,9 @@ discard block |
||
1561 | 1848 | } |
1562 | 1849 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1563 | 1850 | $all = $result[0]['nb']; |
1564 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1851 | + } else { |
|
1852 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1853 | + } |
|
1565 | 1854 | } else { |
1566 | 1855 | if ($year == '' && $month == '') { |
1567 | 1856 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1573,7 +1862,9 @@ discard block |
||
1573 | 1862 | } |
1574 | 1863 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1575 | 1864 | $all = $result[0]['nb']; |
1576 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1865 | + } else { |
|
1866 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1867 | + } |
|
1577 | 1868 | } |
1578 | 1869 | if (empty($all)) { |
1579 | 1870 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1592,7 +1883,9 @@ discard block |
||
1592 | 1883 | } |
1593 | 1884 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
1594 | 1885 | global $globalStatsFilters; |
1595 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1886 | + if ($filter_name == '') { |
|
1887 | + $filter_name = $this->filter_name; |
|
1888 | + } |
|
1596 | 1889 | if ($year == '' && $month == '') { |
1597 | 1890 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
1598 | 1891 | try { |
@@ -1603,7 +1896,9 @@ discard block |
||
1603 | 1896 | } |
1604 | 1897 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1605 | 1898 | $all = $result[0]['nb_airline']; |
1606 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1899 | + } else { |
|
1900 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1901 | + } |
|
1607 | 1902 | if (empty($all)) { |
1608 | 1903 | $filters = array(); |
1609 | 1904 | $filters = array('year' => $year,'month' => $month); |
@@ -1618,7 +1913,9 @@ discard block |
||
1618 | 1913 | } |
1619 | 1914 | public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
1620 | 1915 | global $globalStatsFilters; |
1621 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1916 | + if ($filter_name == '') { |
|
1917 | + $filter_name = $this->filter_name; |
|
1918 | + } |
|
1622 | 1919 | $all = array(); |
1623 | 1920 | if ($year == '' && $month == '') { |
1624 | 1921 | $query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name"; |
@@ -1645,7 +1942,9 @@ discard block |
||
1645 | 1942 | } |
1646 | 1943 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1647 | 1944 | global $globalStatsFilters; |
1648 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1945 | + if ($filter_name == '') { |
|
1946 | + $filter_name = $this->filter_name; |
|
1947 | + } |
|
1649 | 1948 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1650 | 1949 | $Spotter = new Spotter($this->db); |
1651 | 1950 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1700,7 +1999,9 @@ discard block |
||
1700 | 1999 | } |
1701 | 2000 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
1702 | 2001 | global $globalStatsFilters; |
1703 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2002 | + if ($filter_name == '') { |
|
2003 | + $filter_name = $this->filter_name; |
|
2004 | + } |
|
1704 | 2005 | //if ($year == '') $year = date('Y'); |
1705 | 2006 | if ($year == '' && $month == '') { |
1706 | 2007 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1729,7 +2030,9 @@ discard block |
||
1729 | 2030 | } |
1730 | 2031 | |
1731 | 2032 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
1732 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2033 | + if ($filter_name == '') { |
|
2034 | + $filter_name = $this->filter_name; |
|
2035 | + } |
|
1733 | 2036 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1734 | 2037 | $Spotter = new Spotter($this->db); |
1735 | 2038 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1753,7 +2056,9 @@ discard block |
||
1753 | 2056 | return $all; |
1754 | 2057 | } |
1755 | 2058 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
1756 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2059 | + if ($filter_name == '') { |
|
2060 | + $filter_name = $this->filter_name; |
|
2061 | + } |
|
1757 | 2062 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
1758 | 2063 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1759 | 2064 | try { |
@@ -1766,7 +2071,9 @@ discard block |
||
1766 | 2071 | return $all; |
1767 | 2072 | } |
1768 | 2073 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
1769 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2074 | + if ($filter_name == '') { |
|
2075 | + $filter_name = $this->filter_name; |
|
2076 | + } |
|
1770 | 2077 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1771 | 2078 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1772 | 2079 | try { |
@@ -1777,7 +2084,9 @@ discard block |
||
1777 | 2084 | } |
1778 | 2085 | } |
1779 | 2086 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
1780 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2087 | + if ($filter_name == '') { |
|
2088 | + $filter_name = $this->filter_name; |
|
2089 | + } |
|
1781 | 2090 | global $globalArchiveMonths, $globalDBdriver; |
1782 | 2091 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1783 | 2092 | $Spotter = new Spotter($this->db); |
@@ -1833,7 +2142,9 @@ discard block |
||
1833 | 2142 | } |
1834 | 2143 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1835 | 2144 | global $globalArchiveMonths, $globalDBdriver; |
1836 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2145 | + if ($filter_name == '') { |
|
2146 | + $filter_name = $this->filter_name; |
|
2147 | + } |
|
1837 | 2148 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1838 | 2149 | $Spotter = new Spotter($this->db); |
1839 | 2150 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1866,7 +2177,9 @@ discard block |
||
1866 | 2177 | } |
1867 | 2178 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1868 | 2179 | global $globalArchiveMonths, $globalDBdriver; |
1869 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2180 | + if ($filter_name == '') { |
|
2181 | + $filter_name = $this->filter_name; |
|
2182 | + } |
|
1870 | 2183 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1871 | 2184 | $Spotter = new Spotter($this->db); |
1872 | 2185 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1897,7 +2210,9 @@ discard block |
||
1897 | 2210 | } |
1898 | 2211 | public function getStatsAirlineTotal($filter_name = '') { |
1899 | 2212 | global $globalArchiveMonths, $globalDBdriver; |
1900 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2213 | + if ($filter_name == '') { |
|
2214 | + $filter_name = $this->filter_name; |
|
2215 | + } |
|
1901 | 2216 | if ($globalDBdriver == 'mysql') { |
1902 | 2217 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1903 | 2218 | } else { |
@@ -1914,7 +2229,9 @@ discard block |
||
1914 | 2229 | } |
1915 | 2230 | public function getStatsOwnerTotal($filter_name = '') { |
1916 | 2231 | global $globalArchiveMonths, $globalDBdriver; |
1917 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2232 | + if ($filter_name == '') { |
|
2233 | + $filter_name = $this->filter_name; |
|
2234 | + } |
|
1918 | 2235 | if ($globalDBdriver == 'mysql') { |
1919 | 2236 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1920 | 2237 | } else { |
@@ -1931,7 +2248,9 @@ discard block |
||
1931 | 2248 | } |
1932 | 2249 | public function getStatsOwner($owner_name,$filter_name = '') { |
1933 | 2250 | global $globalArchiveMonths, $globalDBdriver; |
1934 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2251 | + if ($filter_name == '') { |
|
2252 | + $filter_name = $this->filter_name; |
|
2253 | + } |
|
1935 | 2254 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1936 | 2255 | try { |
1937 | 2256 | $sth = $this->db->prepare($query); |
@@ -1940,12 +2259,17 @@ discard block |
||
1940 | 2259 | echo "error : ".$e->getMessage(); |
1941 | 2260 | } |
1942 | 2261 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1943 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1944 | - else return 0; |
|
2262 | + if (isset($all[0]['cnt'])) { |
|
2263 | + return $all[0]['cnt']; |
|
2264 | + } else { |
|
2265 | + return 0; |
|
2266 | + } |
|
1945 | 2267 | } |
1946 | 2268 | public function getStatsPilotTotal($filter_name = '') { |
1947 | 2269 | global $globalArchiveMonths, $globalDBdriver; |
1948 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2270 | + if ($filter_name == '') { |
|
2271 | + $filter_name = $this->filter_name; |
|
2272 | + } |
|
1949 | 2273 | if ($globalDBdriver == 'mysql') { |
1950 | 2274 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1951 | 2275 | } else { |
@@ -1962,7 +2286,9 @@ discard block |
||
1962 | 2286 | } |
1963 | 2287 | public function getStatsPilot($pilot,$filter_name = '') { |
1964 | 2288 | global $globalArchiveMonths, $globalDBdriver; |
1965 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2289 | + if ($filter_name == '') { |
|
2290 | + $filter_name = $this->filter_name; |
|
2291 | + } |
|
1966 | 2292 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1967 | 2293 | try { |
1968 | 2294 | $sth = $this->db->prepare($query); |
@@ -1971,13 +2297,18 @@ discard block |
||
1971 | 2297 | echo "error : ".$e->getMessage(); |
1972 | 2298 | } |
1973 | 2299 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1974 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1975 | - else return 0; |
|
2300 | + if (isset($all[0]['cnt'])) { |
|
2301 | + return $all[0]['cnt']; |
|
2302 | + } else { |
|
2303 | + return 0; |
|
2304 | + } |
|
1976 | 2305 | } |
1977 | 2306 | |
1978 | 2307 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1979 | 2308 | global $globalDBdriver; |
1980 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2309 | + if ($filter_name == '') { |
|
2310 | + $filter_name = $this->filter_name; |
|
2311 | + } |
|
1981 | 2312 | if ($globalDBdriver == 'mysql') { |
1982 | 2313 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
1983 | 2314 | } else { |
@@ -1993,7 +2324,9 @@ discard block |
||
1993 | 2324 | } |
1994 | 2325 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1995 | 2326 | global $globalDBdriver; |
1996 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2327 | + if ($filter_name == '') { |
|
2328 | + $filter_name = $this->filter_name; |
|
2329 | + } |
|
1997 | 2330 | if ($globalDBdriver == 'mysql') { |
1998 | 2331 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1999 | 2332 | } else { |
@@ -2512,27 +2845,37 @@ discard block |
||
2512 | 2845 | date_default_timezone_set('UTC'); |
2513 | 2846 | if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) { |
2514 | 2847 | $last_update = $this->getLastStatsUpdate('last_update_stats_marine'); |
2515 | - if ($globalDebug) echo '!!! Update Marine stats !!!'."\n"; |
|
2848 | + if ($globalDebug) { |
|
2849 | + echo '!!! Update Marine stats !!!'."\n"; |
|
2850 | + } |
|
2516 | 2851 | if (isset($last_update[0]['value'])) { |
2517 | 2852 | $last_update_day = $last_update[0]['value']; |
2518 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2853 | + } else { |
|
2854 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2855 | + } |
|
2519 | 2856 | $reset = false; |
2520 | 2857 | $Marine = new Marine($this->db); |
2521 | 2858 | $filtername = 'marine'; |
2522 | 2859 | if ($Connection->tableExists('countries')) { |
2523 | - if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
|
2860 | + if ($globalDebug) { |
|
2861 | + echo 'Count all vessels by countries...'."\n"; |
|
2862 | + } |
|
2524 | 2863 | $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
2525 | 2864 | foreach ($alldata as $number) { |
2526 | 2865 | echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
2527 | 2866 | } |
2528 | 2867 | } |
2529 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
2868 | + if ($globalDebug) { |
|
2869 | + echo 'Count all vessels by months...'."\n"; |
|
2870 | + } |
|
2530 | 2871 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2531 | 2872 | $filter_last_month = array('since_date' => $last_month); |
2532 | 2873 | $alldata = $Marine->countAllMonths($filter_last_month); |
2533 | 2874 | $lastyear = false; |
2534 | 2875 | foreach ($alldata as $number) { |
2535 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2876 | + if ($number['year_name'] != date('Y')) { |
|
2877 | + $lastyear = true; |
|
2878 | + } |
|
2536 | 2879 | $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2537 | 2880 | } |
2538 | 2881 | echo 'Marine data...'."\n"; |
@@ -2562,7 +2905,9 @@ discard block |
||
2562 | 2905 | foreach ($alldata as $number) { |
2563 | 2906 | $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
2564 | 2907 | } |
2565 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
2908 | + if ($globalDebug) { |
|
2909 | + echo 'Count all types...'."\n"; |
|
2910 | + } |
|
2566 | 2911 | $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
2567 | 2912 | foreach ($alldata as $number) { |
2568 | 2913 | $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
@@ -2574,26 +2919,36 @@ discard block |
||
2574 | 2919 | } |
2575 | 2920 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
2576 | 2921 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
2577 | - if ($globalDebug) echo '!!! Update tracker stats !!!'."\n"; |
|
2922 | + if ($globalDebug) { |
|
2923 | + echo '!!! Update tracker stats !!!'."\n"; |
|
2924 | + } |
|
2578 | 2925 | if (isset($last_update[0]['value'])) { |
2579 | 2926 | $last_update_day = $last_update[0]['value']; |
2580 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2927 | + } else { |
|
2928 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2929 | + } |
|
2581 | 2930 | $reset = false; |
2582 | 2931 | $Tracker = new Tracker($this->db); |
2583 | 2932 | if ($Connection->tableExists('countries')) { |
2584 | - if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
|
2933 | + if ($globalDebug) { |
|
2934 | + echo 'Count all trackers by countries...'."\n"; |
|
2935 | + } |
|
2585 | 2936 | $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
2586 | 2937 | foreach ($alldata as $number) { |
2587 | 2938 | $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
2588 | 2939 | } |
2589 | 2940 | } |
2590 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
2941 | + if ($globalDebug) { |
|
2942 | + echo 'Count all vessels by months...'."\n"; |
|
2943 | + } |
|
2591 | 2944 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2592 | 2945 | $filter_last_month = array('since_date' => $last_month); |
2593 | 2946 | $alldata = $Tracker->countAllMonths($filter_last_month); |
2594 | 2947 | $lastyear = false; |
2595 | 2948 | foreach ($alldata as $number) { |
2596 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2949 | + if ($number['year_name'] != date('Y')) { |
|
2950 | + $lastyear = true; |
|
2951 | + } |
|
2597 | 2952 | $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2598 | 2953 | } |
2599 | 2954 | echo 'Tracker data...'."\n"; |
@@ -2623,7 +2978,9 @@ discard block |
||
2623 | 2978 | foreach ($alldata as $number) { |
2624 | 2979 | $this->addStatTracker('hour',$number['hour_name'],$number['hour_count']); |
2625 | 2980 | } |
2626 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
2981 | + if ($globalDebug) { |
|
2982 | + echo 'Count all types...'."\n"; |
|
2983 | + } |
|
2627 | 2984 | $alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day); |
2628 | 2985 | foreach ($alldata as $number) { |
2629 | 2986 | $this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset); |
@@ -2635,10 +2992,14 @@ discard block |
||
2635 | 2992 | |
2636 | 2993 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
2637 | 2994 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2638 | - if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n"; |
|
2995 | + if ($globalDebug) { |
|
2996 | + echo '!!! Update aicraft stats !!!'."\n"; |
|
2997 | + } |
|
2639 | 2998 | if (isset($last_update[0]['value'])) { |
2640 | 2999 | $last_update_day = $last_update[0]['value']; |
2641 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
3000 | + } else { |
|
3001 | + $last_update_day = '2012-12-12 12:12:12'; |
|
3002 | + } |
|
2642 | 3003 | $reset = false; |
2643 | 3004 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
2644 | 3005 | if ($globalStatsResetYear) { |
@@ -2647,43 +3008,63 @@ discard block |
||
2647 | 3008 | } |
2648 | 3009 | $Spotter = new Spotter($this->db); |
2649 | 3010 | |
2650 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
3011 | + if ($globalDebug) { |
|
3012 | + echo 'Count all aircraft types...'."\n"; |
|
3013 | + } |
|
2651 | 3014 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
2652 | 3015 | foreach ($alldata as $number) { |
2653 | 3016 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
2654 | 3017 | } |
2655 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
3018 | + if ($globalDebug) { |
|
3019 | + echo 'Count all airlines...'."\n"; |
|
3020 | + } |
|
2656 | 3021 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
2657 | 3022 | foreach ($alldata as $number) { |
2658 | 3023 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
2659 | 3024 | } |
2660 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
3025 | + if ($globalDebug) { |
|
3026 | + echo 'Count all registrations...'."\n"; |
|
3027 | + } |
|
2661 | 3028 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
2662 | 3029 | foreach ($alldata as $number) { |
2663 | 3030 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
2664 | 3031 | } |
2665 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
3032 | + if ($globalDebug) { |
|
3033 | + echo 'Count all callsigns...'."\n"; |
|
3034 | + } |
|
2666 | 3035 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
2667 | 3036 | foreach ($alldata as $number) { |
2668 | 3037 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2669 | 3038 | } |
2670 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
3039 | + if ($globalDebug) { |
|
3040 | + echo 'Count all owners...'."\n"; |
|
3041 | + } |
|
2671 | 3042 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
2672 | 3043 | foreach ($alldata as $number) { |
2673 | 3044 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
2674 | 3045 | } |
2675 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
3046 | + if ($globalDebug) { |
|
3047 | + echo 'Count all pilots...'."\n"; |
|
3048 | + } |
|
2676 | 3049 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
2677 | 3050 | foreach ($alldata as $number) { |
2678 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
3051 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
3052 | + $number['pilot_id'] = $number['pilot_name']; |
|
3053 | + } |
|
2679 | 3054 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
2680 | 3055 | } |
2681 | 3056 | |
2682 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
3057 | + if ($globalDebug) { |
|
3058 | + echo 'Count all departure airports...'."\n"; |
|
3059 | + } |
|
2683 | 3060 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
2684 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
3061 | + if ($globalDebug) { |
|
3062 | + echo 'Count all detected departure airports...'."\n"; |
|
3063 | + } |
|
2685 | 3064 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
2686 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
3065 | + if ($globalDebug) { |
|
3066 | + echo 'Order departure airports...'."\n"; |
|
3067 | + } |
|
2687 | 3068 | $alldata = array(); |
2688 | 3069 | foreach ($pall as $value) { |
2689 | 3070 | $icao = $value['airport_departure_icao']; |
@@ -2693,7 +3074,9 @@ discard block |
||
2693 | 3074 | $icao = $value['airport_departure_icao']; |
2694 | 3075 | if (isset($alldata[$icao])) { |
2695 | 3076 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2696 | - } else $alldata[$icao] = $value; |
|
3077 | + } else { |
|
3078 | + $alldata[$icao] = $value; |
|
3079 | + } |
|
2697 | 3080 | } |
2698 | 3081 | $count = array(); |
2699 | 3082 | foreach ($alldata as $key => $row) { |
@@ -2703,11 +3086,17 @@ discard block |
||
2703 | 3086 | foreach ($alldata as $number) { |
2704 | 3087 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
2705 | 3088 | } |
2706 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
3089 | + if ($globalDebug) { |
|
3090 | + echo 'Count all arrival airports...'."\n"; |
|
3091 | + } |
|
2707 | 3092 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
2708 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
3093 | + if ($globalDebug) { |
|
3094 | + echo 'Count all detected arrival airports...'."\n"; |
|
3095 | + } |
|
2709 | 3096 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
2710 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
3097 | + if ($globalDebug) { |
|
3098 | + echo 'Order arrival airports...'."\n"; |
|
3099 | + } |
|
2711 | 3100 | $alldata = array(); |
2712 | 3101 | foreach ($pall as $value) { |
2713 | 3102 | $icao = $value['airport_arrival_icao']; |
@@ -2717,7 +3106,9 @@ discard block |
||
2717 | 3106 | $icao = $value['airport_arrival_icao']; |
2718 | 3107 | if (isset($alldata[$icao])) { |
2719 | 3108 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2720 | - } else $alldata[$icao] = $value; |
|
3109 | + } else { |
|
3110 | + $alldata[$icao] = $value; |
|
3111 | + } |
|
2721 | 3112 | } |
2722 | 3113 | $count = array(); |
2723 | 3114 | foreach ($alldata as $key => $row) { |
@@ -2728,7 +3119,9 @@ discard block |
||
2728 | 3119 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
2729 | 3120 | } |
2730 | 3121 | if ($Connection->tableExists('countries')) { |
2731 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
3122 | + if ($globalDebug) { |
|
3123 | + echo 'Count all flights by countries...'."\n"; |
|
3124 | + } |
|
2732 | 3125 | //$SpotterArchive = new SpotterArchive(); |
2733 | 3126 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
2734 | 3127 | $Spotter = new Spotter($this->db); |
@@ -2739,7 +3132,9 @@ discard block |
||
2739 | 3132 | } |
2740 | 3133 | |
2741 | 3134 | if (isset($globalAccidents) && $globalAccidents) { |
2742 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
3135 | + if ($globalDebug) { |
|
3136 | + echo 'Count fatalities stats...'."\n"; |
|
3137 | + } |
|
2743 | 3138 | $Accident = new Accident($this->db); |
2744 | 3139 | $this->deleteStatsByType('fatalities_byyear'); |
2745 | 3140 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2755,48 +3150,68 @@ discard block |
||
2755 | 3150 | |
2756 | 3151 | // Add by month using getstat if month finish... |
2757 | 3152 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
2758 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
3153 | + if ($globalDebug) { |
|
3154 | + echo 'Count all flights by months...'."\n"; |
|
3155 | + } |
|
2759 | 3156 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2760 | 3157 | $filter_last_month = array('since_date' => $last_month); |
2761 | 3158 | $Spotter = new Spotter($this->db); |
2762 | 3159 | $alldata = $Spotter->countAllMonths($filter_last_month); |
2763 | 3160 | $lastyear = false; |
2764 | 3161 | foreach ($alldata as $number) { |
2765 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3162 | + if ($number['year_name'] != date('Y')) { |
|
3163 | + $lastyear = true; |
|
3164 | + } |
|
2766 | 3165 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2767 | 3166 | } |
2768 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
3167 | + if ($globalDebug) { |
|
3168 | + echo 'Count all military flights by months...'."\n"; |
|
3169 | + } |
|
2769 | 3170 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
2770 | 3171 | foreach ($alldata as $number) { |
2771 | 3172 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2772 | 3173 | } |
2773 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
3174 | + if ($globalDebug) { |
|
3175 | + echo 'Count all owners by months...'."\n"; |
|
3176 | + } |
|
2774 | 3177 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
2775 | 3178 | foreach ($alldata as $number) { |
2776 | 3179 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2777 | 3180 | } |
2778 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
3181 | + if ($globalDebug) { |
|
3182 | + echo 'Count all pilots by months...'."\n"; |
|
3183 | + } |
|
2779 | 3184 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
2780 | 3185 | foreach ($alldata as $number) { |
2781 | 3186 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2782 | 3187 | } |
2783 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
3188 | + if ($globalDebug) { |
|
3189 | + echo 'Count all airlines by months...'."\n"; |
|
3190 | + } |
|
2784 | 3191 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
2785 | 3192 | foreach ($alldata as $number) { |
2786 | 3193 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2787 | 3194 | } |
2788 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
3195 | + if ($globalDebug) { |
|
3196 | + echo 'Count all aircrafts by months...'."\n"; |
|
3197 | + } |
|
2789 | 3198 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
2790 | 3199 | foreach ($alldata as $number) { |
2791 | 3200 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2792 | 3201 | } |
2793 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
3202 | + if ($globalDebug) { |
|
3203 | + echo 'Count all real arrivals by months...'."\n"; |
|
3204 | + } |
|
2794 | 3205 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
2795 | 3206 | foreach ($alldata as $number) { |
2796 | 3207 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2797 | 3208 | } |
2798 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
2799 | - if ($globalDebug) echo '...Departure'."\n"; |
|
3209 | + if ($globalDebug) { |
|
3210 | + echo 'Airports data...'."\n"; |
|
3211 | + } |
|
3212 | + if ($globalDebug) { |
|
3213 | + echo '...Departure'."\n"; |
|
3214 | + } |
|
2800 | 3215 | $this->deleteStatAirport('daily'); |
2801 | 3216 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
2802 | 3217 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2914,7 +3329,9 @@ discard block |
||
2914 | 3329 | // Count by airlines |
2915 | 3330 | echo '--- Stats by airlines ---'."\n"; |
2916 | 3331 | if ($Connection->tableExists('countries')) { |
2917 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
3332 | + if ($globalDebug) { |
|
3333 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
3334 | + } |
|
2918 | 3335 | $SpotterArchive = new SpotterArchive($this->db); |
2919 | 3336 | //$Spotter = new Spotter($this->db); |
2920 | 3337 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2923,37 +3340,53 @@ discard block |
||
2923 | 3340 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
2924 | 3341 | } |
2925 | 3342 | } |
2926 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
3343 | + if ($globalDebug) { |
|
3344 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
3345 | + } |
|
2927 | 3346 | $Spotter = new Spotter($this->db); |
2928 | 3347 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
2929 | 3348 | foreach ($alldata as $number) { |
2930 | 3349 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
2931 | 3350 | } |
2932 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
3351 | + if ($globalDebug) { |
|
3352 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
3353 | + } |
|
2933 | 3354 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
2934 | 3355 | foreach ($alldata as $number) { |
2935 | 3356 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
2936 | 3357 | } |
2937 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
3358 | + if ($globalDebug) { |
|
3359 | + echo 'Count all callsigns by airlines...'."\n"; |
|
3360 | + } |
|
2938 | 3361 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
2939 | 3362 | foreach ($alldata as $number) { |
2940 | 3363 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2941 | 3364 | } |
2942 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
3365 | + if ($globalDebug) { |
|
3366 | + echo 'Count all owners by airlines...'."\n"; |
|
3367 | + } |
|
2943 | 3368 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
2944 | 3369 | foreach ($alldata as $number) { |
2945 | 3370 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
2946 | 3371 | } |
2947 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
3372 | + if ($globalDebug) { |
|
3373 | + echo 'Count all pilots by airlines...'."\n"; |
|
3374 | + } |
|
2948 | 3375 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
2949 | 3376 | foreach ($alldata as $number) { |
2950 | 3377 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
2951 | 3378 | } |
2952 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
3379 | + if ($globalDebug) { |
|
3380 | + echo 'Count all departure airports by airlines...'."\n"; |
|
3381 | + } |
|
2953 | 3382 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
2954 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
3383 | + if ($globalDebug) { |
|
3384 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
3385 | + } |
|
2955 | 3386 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
2956 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
3387 | + if ($globalDebug) { |
|
3388 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
3389 | + } |
|
2957 | 3390 | //$alldata = array(); |
2958 | 3391 | foreach ($dall as $value) { |
2959 | 3392 | $icao = $value['airport_departure_icao']; |
@@ -2974,11 +3407,17 @@ discard block |
||
2974 | 3407 | foreach ($alldata as $number) { |
2975 | 3408 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
2976 | 3409 | } |
2977 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
3410 | + if ($globalDebug) { |
|
3411 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
3412 | + } |
|
2978 | 3413 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
2979 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
3414 | + if ($globalDebug) { |
|
3415 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
3416 | + } |
|
2980 | 3417 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
2981 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
3418 | + if ($globalDebug) { |
|
3419 | + echo 'Order arrival airports by airlines...'."\n"; |
|
3420 | + } |
|
2982 | 3421 | //$alldata = array(); |
2983 | 3422 | foreach ($dall as $value) { |
2984 | 3423 | $icao = $value['airport_arrival_icao']; |
@@ -2997,37 +3436,53 @@ discard block |
||
2997 | 3436 | } |
2998 | 3437 | $alldata = $pall; |
2999 | 3438 | foreach ($alldata as $number) { |
3000 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
3439 | + if ($number['airline_icao'] != '') { |
|
3440 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
3441 | + } |
|
3442 | + } |
|
3443 | + if ($globalDebug) { |
|
3444 | + echo 'Count all flights by months by airlines...'."\n"; |
|
3001 | 3445 | } |
3002 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
3003 | 3446 | $Spotter = new Spotter($this->db); |
3004 | 3447 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
3005 | 3448 | $lastyear = false; |
3006 | 3449 | foreach ($alldata as $number) { |
3007 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3450 | + if ($number['year_name'] != date('Y')) { |
|
3451 | + $lastyear = true; |
|
3452 | + } |
|
3008 | 3453 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3009 | 3454 | } |
3010 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
3455 | + if ($globalDebug) { |
|
3456 | + echo 'Count all owners by months by airlines...'."\n"; |
|
3457 | + } |
|
3011 | 3458 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
3012 | 3459 | foreach ($alldata as $number) { |
3013 | 3460 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3014 | 3461 | } |
3015 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
3462 | + if ($globalDebug) { |
|
3463 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
3464 | + } |
|
3016 | 3465 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
3017 | 3466 | foreach ($alldata as $number) { |
3018 | 3467 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3019 | 3468 | } |
3020 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
3469 | + if ($globalDebug) { |
|
3470 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
3471 | + } |
|
3021 | 3472 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
3022 | 3473 | foreach ($alldata as $number) { |
3023 | 3474 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3024 | 3475 | } |
3025 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
3476 | + if ($globalDebug) { |
|
3477 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
3478 | + } |
|
3026 | 3479 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
3027 | 3480 | foreach ($alldata as $number) { |
3028 | 3481 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
3029 | 3482 | } |
3030 | - if ($globalDebug) echo '...Departure'."\n"; |
|
3483 | + if ($globalDebug) { |
|
3484 | + echo '...Departure'."\n"; |
|
3485 | + } |
|
3031 | 3486 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
3032 | 3487 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
3033 | 3488 | foreach ($dall as $value) { |
@@ -3050,7 +3505,9 @@ discard block |
||
3050 | 3505 | foreach ($alldata as $number) { |
3051 | 3506 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
3052 | 3507 | } |
3053 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
3508 | + if ($globalDebug) { |
|
3509 | + echo '...Arrival'."\n"; |
|
3510 | + } |
|
3054 | 3511 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
3055 | 3512 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
3056 | 3513 | foreach ($dall as $value) { |
@@ -3074,13 +3531,19 @@ discard block |
||
3074 | 3531 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
3075 | 3532 | } |
3076 | 3533 | |
3077 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
3078 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
3534 | + if ($globalDebug) { |
|
3535 | + echo 'Flights data...'."\n"; |
|
3536 | + } |
|
3537 | + if ($globalDebug) { |
|
3538 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
3539 | + } |
|
3079 | 3540 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
3080 | 3541 | foreach ($alldata as $number) { |
3081 | 3542 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
3082 | 3543 | } |
3083 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
3544 | + if ($globalDebug) { |
|
3545 | + echo '-> countAllDates...'."\n"; |
|
3546 | + } |
|
3084 | 3547 | //$previousdata = $this->countAllDatesByAirlines(); |
3085 | 3548 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
3086 | 3549 | $values = array(); |
@@ -3093,14 +3556,18 @@ discard block |
||
3093 | 3556 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
3094 | 3557 | } |
3095 | 3558 | |
3096 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
3559 | + if ($globalDebug) { |
|
3560 | + echo '-> countAllHours...'."\n"; |
|
3561 | + } |
|
3097 | 3562 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
3098 | 3563 | foreach ($alldata as $number) { |
3099 | 3564 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
3100 | 3565 | } |
3101 | 3566 | |
3102 | 3567 | // Stats by filters |
3103 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
3568 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
3569 | + $globalStatsFilters = array(); |
|
3570 | + } |
|
3104 | 3571 | foreach ($globalStatsFilters as $name => $filter) { |
3105 | 3572 | if (!empty($filter)) { |
3106 | 3573 | //$filter_name = $filter['name']; |
@@ -3108,7 +3575,9 @@ discard block |
||
3108 | 3575 | $reset = false; |
3109 | 3576 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
3110 | 3577 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
3111 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
3578 | + if ($globalDebug) { |
|
3579 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
3580 | + } |
|
3112 | 3581 | $this->deleteOldStats($filter_name); |
3113 | 3582 | unset($last_update); |
3114 | 3583 | } |
@@ -3125,39 +3594,55 @@ discard block |
||
3125 | 3594 | $reset = true; |
3126 | 3595 | } |
3127 | 3596 | // Count by filter |
3128 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
3597 | + if ($globalDebug) { |
|
3598 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
3599 | + } |
|
3129 | 3600 | $Spotter = new Spotter($this->db); |
3130 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
3601 | + if ($globalDebug) { |
|
3602 | + echo 'Count all aircraft types...'."\n"; |
|
3603 | + } |
|
3131 | 3604 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
3132 | 3605 | foreach ($alldata as $number) { |
3133 | 3606 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
3134 | 3607 | } |
3135 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
3608 | + if ($globalDebug) { |
|
3609 | + echo 'Count all airlines...'."\n"; |
|
3610 | + } |
|
3136 | 3611 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
3137 | 3612 | foreach ($alldata as $number) { |
3138 | 3613 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
3139 | 3614 | } |
3140 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
3615 | + if ($globalDebug) { |
|
3616 | + echo 'Count all aircraft registrations...'."\n"; |
|
3617 | + } |
|
3141 | 3618 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
3142 | 3619 | foreach ($alldata as $number) { |
3143 | 3620 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
3144 | 3621 | } |
3145 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
3622 | + if ($globalDebug) { |
|
3623 | + echo 'Count all callsigns...'."\n"; |
|
3624 | + } |
|
3146 | 3625 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
3147 | 3626 | foreach ($alldata as $number) { |
3148 | 3627 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
3149 | 3628 | } |
3150 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
3629 | + if ($globalDebug) { |
|
3630 | + echo 'Count all owners...'."\n"; |
|
3631 | + } |
|
3151 | 3632 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
3152 | 3633 | foreach ($alldata as $number) { |
3153 | 3634 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
3154 | 3635 | } |
3155 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
3636 | + if ($globalDebug) { |
|
3637 | + echo 'Count all pilots...'."\n"; |
|
3638 | + } |
|
3156 | 3639 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
3157 | 3640 | foreach ($alldata as $number) { |
3158 | 3641 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
3159 | 3642 | } |
3160 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
3643 | + if ($globalDebug) { |
|
3644 | + echo 'Count departure airports...'."\n"; |
|
3645 | + } |
|
3161 | 3646 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
3162 | 3647 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
3163 | 3648 | $alldata = array(); |
@@ -3169,7 +3654,9 @@ discard block |
||
3169 | 3654 | $icao = $value['airport_departure_icao']; |
3170 | 3655 | if (isset($alldata[$icao])) { |
3171 | 3656 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
3172 | - } else $alldata[$icao] = $value; |
|
3657 | + } else { |
|
3658 | + $alldata[$icao] = $value; |
|
3659 | + } |
|
3173 | 3660 | } |
3174 | 3661 | $count = array(); |
3175 | 3662 | foreach ($alldata as $key => $row) { |
@@ -3179,7 +3666,9 @@ discard block |
||
3179 | 3666 | foreach ($alldata as $number) { |
3180 | 3667 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
3181 | 3668 | } |
3182 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
3669 | + if ($globalDebug) { |
|
3670 | + echo 'Count all arrival airports...'."\n"; |
|
3671 | + } |
|
3183 | 3672 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
3184 | 3673 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
3185 | 3674 | $alldata = array(); |
@@ -3191,7 +3680,9 @@ discard block |
||
3191 | 3680 | $icao = $value['airport_arrival_icao']; |
3192 | 3681 | if (isset($alldata[$icao])) { |
3193 | 3682 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
3194 | - } else $alldata[$icao] = $value; |
|
3683 | + } else { |
|
3684 | + $alldata[$icao] = $value; |
|
3685 | + } |
|
3195 | 3686 | } |
3196 | 3687 | $count = array(); |
3197 | 3688 | foreach ($alldata as $key => $row) { |
@@ -3201,35 +3692,49 @@ discard block |
||
3201 | 3692 | foreach ($alldata as $number) { |
3202 | 3693 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
3203 | 3694 | } |
3204 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
3695 | + if ($globalDebug) { |
|
3696 | + echo 'Count all months...'."\n"; |
|
3697 | + } |
|
3205 | 3698 | $Spotter = new Spotter($this->db); |
3206 | 3699 | $alldata = $Spotter->countAllMonths($filter); |
3207 | 3700 | $lastyear = false; |
3208 | 3701 | foreach ($alldata as $number) { |
3209 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3702 | + if ($number['year_name'] != date('Y')) { |
|
3703 | + $lastyear = true; |
|
3704 | + } |
|
3210 | 3705 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3211 | 3706 | } |
3212 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
3707 | + if ($globalDebug) { |
|
3708 | + echo 'Count all owners by months...'."\n"; |
|
3709 | + } |
|
3213 | 3710 | $alldata = $Spotter->countAllMonthsOwners($filter); |
3214 | 3711 | foreach ($alldata as $number) { |
3215 | 3712 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3216 | 3713 | } |
3217 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
3714 | + if ($globalDebug) { |
|
3715 | + echo 'Count all pilots by months...'."\n"; |
|
3716 | + } |
|
3218 | 3717 | $alldata = $Spotter->countAllMonthsPilots($filter); |
3219 | 3718 | foreach ($alldata as $number) { |
3220 | 3719 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3221 | 3720 | } |
3222 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
3721 | + if ($globalDebug) { |
|
3722 | + echo 'Count all military by months...'."\n"; |
|
3723 | + } |
|
3223 | 3724 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
3224 | 3725 | foreach ($alldata as $number) { |
3225 | 3726 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3226 | 3727 | } |
3227 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
3728 | + if ($globalDebug) { |
|
3729 | + echo 'Count all aircrafts by months...'."\n"; |
|
3730 | + } |
|
3228 | 3731 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
3229 | 3732 | foreach ($alldata as $number) { |
3230 | 3733 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3231 | 3734 | } |
3232 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
3735 | + if ($globalDebug) { |
|
3736 | + echo 'Count all real arrivals by months...'."\n"; |
|
3737 | + } |
|
3233 | 3738 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
3234 | 3739 | foreach ($alldata as $number) { |
3235 | 3740 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -803,12 +855,16 @@ discard block |
||
803 | 855 | if ($globalDBdriver == 'mysql') { |
804 | 856 | if (!$Connection->tableExists('tle')) { |
805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
806 | - if ($error != '') return $error; |
|
858 | + if ($error != '') { |
|
859 | + return $error; |
|
860 | + } |
|
807 | 861 | } |
808 | 862 | } else { |
809 | 863 | if (!$Connection->tableExists('tle')) { |
810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
811 | - if ($error != '') return $error; |
|
865 | + if ($error != '') { |
|
866 | + return $error; |
|
867 | + } |
|
812 | 868 | } |
813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
848 | 904 | } else { |
849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 906 | } |
851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
907 | + if ($error != '') { |
|
908 | + return 'Import airlines.sql : '.$error; |
|
909 | + } |
|
852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
853 | 911 | // Add forsource to airlines |
854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
1331 | 1389 | } |
1332 | 1390 | if ($globalDBdriver == 'mysql') { |
1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
1334 | - if ($error != '') return $error; |
|
1392 | + if ($error != '') { |
|
1393 | + return $error; |
|
1394 | + } |
|
1335 | 1395 | } else { |
1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1337 | - if ($error != '') return $error; |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } |
|
1338 | 1400 | } |
1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
1342 | 1404 | $error .= update_db::update_vatsim(); |
1343 | - if ($error != '') return $error; |
|
1405 | + if ($error != '') { |
|
1406 | + return $error; |
|
1407 | + } |
|
1344 | 1408 | } |
1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1346 | 1410 | $error .= update_db::update_IVAO(); |
1347 | - if ($error != '') return $error; |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } |
|
1348 | 1414 | } |
1349 | 1415 | } |
1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
1607 | 1673 | if ($globalDBdriver == 'mysql') { |
1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1610 | - if ($error != '') return $error; |
|
1676 | + if ($error != '') { |
|
1677 | + return $error; |
|
1678 | + } |
|
1611 | 1679 | } |
1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1614 | - if ($error != '') return $error; |
|
1682 | + if ($error != '') { |
|
1683 | + return $error; |
|
1684 | + } |
|
1615 | 1685 | } |
1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
1618 | - if ($error != '') return $error; |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } |
|
1619 | 1691 | } |
1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
1622 | - if ($error != '') return $error; |
|
1694 | + if ($error != '') { |
|
1695 | + return $error; |
|
1696 | + } |
|
1623 | 1697 | } |
1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1626 | - if ($error != '') return $error; |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } |
|
1627 | 1703 | } |
1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1630 | - if ($error != '') return $error; |
|
1706 | + if ($error != '') { |
|
1707 | + return $error; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } else { |
1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1634 | - if ($error != '') return $error; |
|
1712 | + if ($error != '') { |
|
1713 | + return $error; |
|
1714 | + } |
|
1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1636 | - if ($error != '') return $error; |
|
1716 | + if ($error != '') { |
|
1717 | + return $error; |
|
1718 | + } |
|
1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1638 | - if ($error != '') return $error; |
|
1720 | + if ($error != '') { |
|
1721 | + return $error; |
|
1722 | + } |
|
1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1640 | - if ($error != '') return $error; |
|
1724 | + if ($error != '') { |
|
1725 | + return $error; |
|
1726 | + } |
|
1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1642 | - if ($error != '') return $error; |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } |
|
1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1644 | - if ($error != '') return $error; |
|
1732 | + if ($error != '') { |
|
1733 | + return $error; |
|
1734 | + } |
|
1645 | 1735 | } |
1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
1660 | 1750 | if ($globalDBdriver == 'mysql') { |
1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
1663 | - if ($error != '') return $error; |
|
1753 | + if ($error != '') { |
|
1754 | + return $error; |
|
1755 | + } |
|
1664 | 1756 | } |
1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1667 | - if ($error != '') return $error; |
|
1759 | + if ($error != '') { |
|
1760 | + return $error; |
|
1761 | + } |
|
1668 | 1762 | } |
1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1671 | - if ($error != '') return $error; |
|
1765 | + if ($error != '') { |
|
1766 | + return $error; |
|
1767 | + } |
|
1672 | 1768 | } |
1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1675 | - if ($error != '') return $error; |
|
1771 | + if ($error != '') { |
|
1772 | + return $error; |
|
1773 | + } |
|
1676 | 1774 | } |
1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1679 | - if ($error != '') return $error; |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } |
|
1680 | 1780 | } |
1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1683 | - if ($error != '') return $error; |
|
1783 | + if ($error != '') { |
|
1784 | + return $error; |
|
1785 | + } |
|
1684 | 1786 | } |
1685 | 1787 | } else { |
1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1687 | - if ($error != '') return $error; |
|
1789 | + if ($error != '') { |
|
1790 | + return $error; |
|
1791 | + } |
|
1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1689 | - if ($error != '') return $error; |
|
1793 | + if ($error != '') { |
|
1794 | + return $error; |
|
1795 | + } |
|
1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1691 | - if ($error != '') return $error; |
|
1797 | + if ($error != '') { |
|
1798 | + return $error; |
|
1799 | + } |
|
1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1693 | - if ($error != '') return $error; |
|
1801 | + if ($error != '') { |
|
1802 | + return $error; |
|
1803 | + } |
|
1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1695 | - if ($error != '') return $error; |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } |
|
1696 | 1808 | } |
1697 | 1809 | if ($globalDBdriver == 'mysql') { |
1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
2063 | 2175 | if ($globalDBdriver == 'mysql') { |
2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
2066 | - if ($error != '') return $error; |
|
2178 | + if ($error != '') { |
|
2179 | + return $error; |
|
2180 | + } |
|
2067 | 2181 | } |
2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
2091 | 2205 | $error = ''; |
2092 | 2206 | if ($globalDBdriver == 'mysql') { |
2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
2094 | - if ($error != '') return $error; |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } |
|
2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
2096 | - if ($error != '') return $error; |
|
2212 | + if ($error != '') { |
|
2213 | + return $error; |
|
2214 | + } |
|
2097 | 2215 | } else { |
2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2099 | - if ($error != '') return $error; |
|
2217 | + if ($error != '') { |
|
2218 | + return $error; |
|
2219 | + } |
|
2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
2101 | - if ($error != '') return $error; |
|
2221 | + if ($error != '') { |
|
2222 | + return $error; |
|
2223 | + } |
|
2102 | 2224 | } |
2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
2115 | 2237 | $error .= update_db::update_vatsim(); |
2116 | 2238 | } |
2117 | 2239 | } |
2118 | - if ($error != '') return $error; |
|
2240 | + if ($error != '') { |
|
2241 | + return $error; |
|
2242 | + } |
|
2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
2120 | 2244 | try { |
2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
2134 | 2258 | if ($globalDBdriver == 'mysql') { |
2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
2136 | - if ($error != '') return $error; |
|
2260 | + if ($error != '') { |
|
2261 | + return $error; |
|
2262 | + } |
|
2137 | 2263 | } else { |
2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
2139 | - if ($error != '') return $error; |
|
2265 | + if ($error != '') { |
|
2266 | + return $error; |
|
2267 | + } |
|
2140 | 2268 | } |
2141 | 2269 | } |
2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2156,37 +2284,53 @@ discard block |
||
2156 | 2284 | if (!$Connection->tableExists('stats_marine')) { |
2157 | 2285 | if ($globalDBdriver == 'mysql') { |
2158 | 2286 | $error .= create_db::import_file('../db/stats_marine.sql'); |
2159 | - if ($error != '') return $error; |
|
2287 | + if ($error != '') { |
|
2288 | + return $error; |
|
2289 | + } |
|
2160 | 2290 | } else { |
2161 | 2291 | $error .= create_db::import_file('../db/pgsql/stats_marine.sql'); |
2162 | - if ($error != '') return $error; |
|
2292 | + if ($error != '') { |
|
2293 | + return $error; |
|
2294 | + } |
|
2163 | 2295 | } |
2164 | 2296 | } |
2165 | 2297 | if (!$Connection->tableExists('stats_marine_country')) { |
2166 | 2298 | if ($globalDBdriver == 'mysql') { |
2167 | 2299 | $error .= create_db::import_file('../db/stats_marine_country.sql'); |
2168 | - if ($error != '') return $error; |
|
2300 | + if ($error != '') { |
|
2301 | + return $error; |
|
2302 | + } |
|
2169 | 2303 | } else { |
2170 | 2304 | $error .= create_db::import_file('../db/pgsql/stats_marine_country.sql'); |
2171 | - if ($error != '') return $error; |
|
2305 | + if ($error != '') { |
|
2306 | + return $error; |
|
2307 | + } |
|
2172 | 2308 | } |
2173 | 2309 | } |
2174 | 2310 | if (!$Connection->tableExists('stats_tracker')) { |
2175 | 2311 | if ($globalDBdriver == 'mysql') { |
2176 | 2312 | $error .= create_db::import_file('../db/stats_tracker.sql'); |
2177 | - if ($error != '') return $error; |
|
2313 | + if ($error != '') { |
|
2314 | + return $error; |
|
2315 | + } |
|
2178 | 2316 | } else { |
2179 | 2317 | $error .= create_db::import_file('../db/pgsql/stats_tracker.sql'); |
2180 | - if ($error != '') return $error; |
|
2318 | + if ($error != '') { |
|
2319 | + return $error; |
|
2320 | + } |
|
2181 | 2321 | } |
2182 | 2322 | } |
2183 | 2323 | if (!$Connection->tableExists('stats_tracker_country')) { |
2184 | 2324 | if ($globalDBdriver == 'mysql') { |
2185 | 2325 | $error .= create_db::import_file('../db/stats_tracker_country.sql'); |
2186 | - if ($error != '') return $error; |
|
2326 | + if ($error != '') { |
|
2327 | + return $error; |
|
2328 | + } |
|
2187 | 2329 | } else { |
2188 | 2330 | $error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql'); |
2189 | - if ($error != '') return $error; |
|
2331 | + if ($error != '') { |
|
2332 | + return $error; |
|
2333 | + } |
|
2190 | 2334 | } |
2191 | 2335 | } |
2192 | 2336 | $query = "UPDATE config SET value = '47' WHERE name = 'schema_version'"; |
@@ -2206,10 +2350,14 @@ discard block |
||
2206 | 2350 | if (!$Connection->tableExists('stats_marine_type')) { |
2207 | 2351 | if ($globalDBdriver == 'mysql') { |
2208 | 2352 | $error .= create_db::import_file('../db/stats_marine_type.sql'); |
2209 | - if ($error != '') return $error; |
|
2353 | + if ($error != '') { |
|
2354 | + return $error; |
|
2355 | + } |
|
2210 | 2356 | } else { |
2211 | 2357 | $error .= create_db::import_file('../db/pgsql/stats_marine_type.sql'); |
2212 | - if ($error != '') return $error; |
|
2358 | + if ($error != '') { |
|
2359 | + return $error; |
|
2360 | + } |
|
2213 | 2361 | } |
2214 | 2362 | } |
2215 | 2363 | $query = "UPDATE config SET value = '48' WHERE name = 'schema_version'"; |
@@ -2229,10 +2377,14 @@ discard block |
||
2229 | 2377 | if (!$Connection->tableExists('stats_tracker_type')) { |
2230 | 2378 | if ($globalDBdriver == 'mysql') { |
2231 | 2379 | $error .= create_db::import_file('../db/stats_tracker_type.sql'); |
2232 | - if ($error != '') return $error; |
|
2380 | + if ($error != '') { |
|
2381 | + return $error; |
|
2382 | + } |
|
2233 | 2383 | } else { |
2234 | 2384 | $error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql'); |
2235 | - if ($error != '') return $error; |
|
2385 | + if ($error != '') { |
|
2386 | + return $error; |
|
2387 | + } |
|
2236 | 2388 | } |
2237 | 2389 | } |
2238 | 2390 | $query = "UPDATE config SET value = '49' WHERE name = 'schema_version'"; |
@@ -2255,8 +2407,11 @@ discard block |
||
2255 | 2407 | if ($Connection->tableExists('aircraft')) { |
2256 | 2408 | if (!$Connection->tableExists('config')) { |
2257 | 2409 | $version = '1'; |
2258 | - if ($update) return self::update_from_1(); |
|
2259 | - else return $version; |
|
2410 | + if ($update) { |
|
2411 | + return self::update_from_1(); |
|
2412 | + } else { |
|
2413 | + return $version; |
|
2414 | + } |
|
2260 | 2415 | } else { |
2261 | 2416 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2262 | 2417 | try { |
@@ -2269,199 +2424,347 @@ discard block |
||
2269 | 2424 | if ($update) { |
2270 | 2425 | if ($result['value'] == '2') { |
2271 | 2426 | $error = self::update_from_2(); |
2272 | - if ($error != '') return $error; |
|
2273 | - else return self::check_version(true); |
|
2427 | + if ($error != '') { |
|
2428 | + return $error; |
|
2429 | + } else { |
|
2430 | + return self::check_version(true); |
|
2431 | + } |
|
2274 | 2432 | } elseif ($result['value'] == '3') { |
2275 | 2433 | $error = self::update_from_3(); |
2276 | - if ($error != '') return $error; |
|
2277 | - else return self::check_version(true); |
|
2434 | + if ($error != '') { |
|
2435 | + return $error; |
|
2436 | + } else { |
|
2437 | + return self::check_version(true); |
|
2438 | + } |
|
2278 | 2439 | } elseif ($result['value'] == '4') { |
2279 | 2440 | $error = self::update_from_4(); |
2280 | - if ($error != '') return $error; |
|
2281 | - else return self::check_version(true); |
|
2441 | + if ($error != '') { |
|
2442 | + return $error; |
|
2443 | + } else { |
|
2444 | + return self::check_version(true); |
|
2445 | + } |
|
2282 | 2446 | } elseif ($result['value'] == '5') { |
2283 | 2447 | $error = self::update_from_5(); |
2284 | - if ($error != '') return $error; |
|
2285 | - else return self::check_version(true); |
|
2448 | + if ($error != '') { |
|
2449 | + return $error; |
|
2450 | + } else { |
|
2451 | + return self::check_version(true); |
|
2452 | + } |
|
2286 | 2453 | } elseif ($result['value'] == '6') { |
2287 | 2454 | $error = self::update_from_6(); |
2288 | - if ($error != '') return $error; |
|
2289 | - else return self::check_version(true); |
|
2455 | + if ($error != '') { |
|
2456 | + return $error; |
|
2457 | + } else { |
|
2458 | + return self::check_version(true); |
|
2459 | + } |
|
2290 | 2460 | } elseif ($result['value'] == '7') { |
2291 | 2461 | $error = self::update_from_7(); |
2292 | - if ($error != '') return $error; |
|
2293 | - else return self::check_version(true); |
|
2462 | + if ($error != '') { |
|
2463 | + return $error; |
|
2464 | + } else { |
|
2465 | + return self::check_version(true); |
|
2466 | + } |
|
2294 | 2467 | } elseif ($result['value'] == '8') { |
2295 | 2468 | $error = self::update_from_8(); |
2296 | - if ($error != '') return $error; |
|
2297 | - else return self::check_version(true); |
|
2469 | + if ($error != '') { |
|
2470 | + return $error; |
|
2471 | + } else { |
|
2472 | + return self::check_version(true); |
|
2473 | + } |
|
2298 | 2474 | } elseif ($result['value'] == '9') { |
2299 | 2475 | $error = self::update_from_9(); |
2300 | - if ($error != '') return $error; |
|
2301 | - else return self::check_version(true); |
|
2476 | + if ($error != '') { |
|
2477 | + return $error; |
|
2478 | + } else { |
|
2479 | + return self::check_version(true); |
|
2480 | + } |
|
2302 | 2481 | } elseif ($result['value'] == '10') { |
2303 | 2482 | $error = self::update_from_10(); |
2304 | - if ($error != '') return $error; |
|
2305 | - else return self::check_version(true); |
|
2483 | + if ($error != '') { |
|
2484 | + return $error; |
|
2485 | + } else { |
|
2486 | + return self::check_version(true); |
|
2487 | + } |
|
2306 | 2488 | } elseif ($result['value'] == '11') { |
2307 | 2489 | $error = self::update_from_11(); |
2308 | - if ($error != '') return $error; |
|
2309 | - else return self::check_version(true); |
|
2490 | + if ($error != '') { |
|
2491 | + return $error; |
|
2492 | + } else { |
|
2493 | + return self::check_version(true); |
|
2494 | + } |
|
2310 | 2495 | } elseif ($result['value'] == '12') { |
2311 | 2496 | $error = self::update_from_12(); |
2312 | - if ($error != '') return $error; |
|
2313 | - else return self::check_version(true); |
|
2497 | + if ($error != '') { |
|
2498 | + return $error; |
|
2499 | + } else { |
|
2500 | + return self::check_version(true); |
|
2501 | + } |
|
2314 | 2502 | } elseif ($result['value'] == '13') { |
2315 | 2503 | $error = self::update_from_13(); |
2316 | - if ($error != '') return $error; |
|
2317 | - else return self::check_version(true); |
|
2504 | + if ($error != '') { |
|
2505 | + return $error; |
|
2506 | + } else { |
|
2507 | + return self::check_version(true); |
|
2508 | + } |
|
2318 | 2509 | } elseif ($result['value'] == '14') { |
2319 | 2510 | $error = self::update_from_14(); |
2320 | - if ($error != '') return $error; |
|
2321 | - else return self::check_version(true); |
|
2511 | + if ($error != '') { |
|
2512 | + return $error; |
|
2513 | + } else { |
|
2514 | + return self::check_version(true); |
|
2515 | + } |
|
2322 | 2516 | } elseif ($result['value'] == '15') { |
2323 | 2517 | $error = self::update_from_15(); |
2324 | - if ($error != '') return $error; |
|
2325 | - else return self::check_version(true); |
|
2518 | + if ($error != '') { |
|
2519 | + return $error; |
|
2520 | + } else { |
|
2521 | + return self::check_version(true); |
|
2522 | + } |
|
2326 | 2523 | } elseif ($result['value'] == '16') { |
2327 | 2524 | $error = self::update_from_16(); |
2328 | - if ($error != '') return $error; |
|
2329 | - else return self::check_version(true); |
|
2525 | + if ($error != '') { |
|
2526 | + return $error; |
|
2527 | + } else { |
|
2528 | + return self::check_version(true); |
|
2529 | + } |
|
2330 | 2530 | } elseif ($result['value'] == '17') { |
2331 | 2531 | $error = self::update_from_17(); |
2332 | - if ($error != '') return $error; |
|
2333 | - else return self::check_version(true); |
|
2532 | + if ($error != '') { |
|
2533 | + return $error; |
|
2534 | + } else { |
|
2535 | + return self::check_version(true); |
|
2536 | + } |
|
2334 | 2537 | } elseif ($result['value'] == '18') { |
2335 | 2538 | $error = self::update_from_18(); |
2336 | - if ($error != '') return $error; |
|
2337 | - else return self::check_version(true); |
|
2539 | + if ($error != '') { |
|
2540 | + return $error; |
|
2541 | + } else { |
|
2542 | + return self::check_version(true); |
|
2543 | + } |
|
2338 | 2544 | } elseif ($result['value'] == '19') { |
2339 | 2545 | $error = self::update_from_19(); |
2340 | - if ($error != '') return $error; |
|
2341 | - else return self::check_version(true); |
|
2546 | + if ($error != '') { |
|
2547 | + return $error; |
|
2548 | + } else { |
|
2549 | + return self::check_version(true); |
|
2550 | + } |
|
2342 | 2551 | } elseif ($result['value'] == '20') { |
2343 | 2552 | $error = self::update_from_20(); |
2344 | - if ($error != '') return $error; |
|
2345 | - else return self::check_version(true); |
|
2553 | + if ($error != '') { |
|
2554 | + return $error; |
|
2555 | + } else { |
|
2556 | + return self::check_version(true); |
|
2557 | + } |
|
2346 | 2558 | } elseif ($result['value'] == '21') { |
2347 | 2559 | $error = self::update_from_21(); |
2348 | - if ($error != '') return $error; |
|
2349 | - else return self::check_version(true); |
|
2560 | + if ($error != '') { |
|
2561 | + return $error; |
|
2562 | + } else { |
|
2563 | + return self::check_version(true); |
|
2564 | + } |
|
2350 | 2565 | } elseif ($result['value'] == '22') { |
2351 | 2566 | $error = self::update_from_22(); |
2352 | - if ($error != '') return $error; |
|
2353 | - else return self::check_version(true); |
|
2567 | + if ($error != '') { |
|
2568 | + return $error; |
|
2569 | + } else { |
|
2570 | + return self::check_version(true); |
|
2571 | + } |
|
2354 | 2572 | } elseif ($result['value'] == '23') { |
2355 | 2573 | $error = self::update_from_23(); |
2356 | - if ($error != '') return $error; |
|
2357 | - else return self::check_version(true); |
|
2574 | + if ($error != '') { |
|
2575 | + return $error; |
|
2576 | + } else { |
|
2577 | + return self::check_version(true); |
|
2578 | + } |
|
2358 | 2579 | } elseif ($result['value'] == '24') { |
2359 | 2580 | $error = self::update_from_24(); |
2360 | - if ($error != '') return $error; |
|
2361 | - else return self::check_version(true); |
|
2581 | + if ($error != '') { |
|
2582 | + return $error; |
|
2583 | + } else { |
|
2584 | + return self::check_version(true); |
|
2585 | + } |
|
2362 | 2586 | } elseif ($result['value'] == '25') { |
2363 | 2587 | $error = self::update_from_25(); |
2364 | - if ($error != '') return $error; |
|
2365 | - else return self::check_version(true); |
|
2588 | + if ($error != '') { |
|
2589 | + return $error; |
|
2590 | + } else { |
|
2591 | + return self::check_version(true); |
|
2592 | + } |
|
2366 | 2593 | } elseif ($result['value'] == '26') { |
2367 | 2594 | $error = self::update_from_26(); |
2368 | - if ($error != '') return $error; |
|
2369 | - else return self::check_version(true); |
|
2595 | + if ($error != '') { |
|
2596 | + return $error; |
|
2597 | + } else { |
|
2598 | + return self::check_version(true); |
|
2599 | + } |
|
2370 | 2600 | } elseif ($result['value'] == '27') { |
2371 | 2601 | $error = self::update_from_27(); |
2372 | - if ($error != '') return $error; |
|
2373 | - else return self::check_version(true); |
|
2602 | + if ($error != '') { |
|
2603 | + return $error; |
|
2604 | + } else { |
|
2605 | + return self::check_version(true); |
|
2606 | + } |
|
2374 | 2607 | } elseif ($result['value'] == '28') { |
2375 | 2608 | $error = self::update_from_28(); |
2376 | - if ($error != '') return $error; |
|
2377 | - else return self::check_version(true); |
|
2609 | + if ($error != '') { |
|
2610 | + return $error; |
|
2611 | + } else { |
|
2612 | + return self::check_version(true); |
|
2613 | + } |
|
2378 | 2614 | } elseif ($result['value'] == '29') { |
2379 | 2615 | $error = self::update_from_29(); |
2380 | - if ($error != '') return $error; |
|
2381 | - else return self::check_version(true); |
|
2616 | + if ($error != '') { |
|
2617 | + return $error; |
|
2618 | + } else { |
|
2619 | + return self::check_version(true); |
|
2620 | + } |
|
2382 | 2621 | } elseif ($result['value'] == '30') { |
2383 | 2622 | $error = self::update_from_30(); |
2384 | - if ($error != '') return $error; |
|
2385 | - else return self::check_version(true); |
|
2623 | + if ($error != '') { |
|
2624 | + return $error; |
|
2625 | + } else { |
|
2626 | + return self::check_version(true); |
|
2627 | + } |
|
2386 | 2628 | } elseif ($result['value'] == '31') { |
2387 | 2629 | $error = self::update_from_31(); |
2388 | - if ($error != '') return $error; |
|
2389 | - else return self::check_version(true); |
|
2630 | + if ($error != '') { |
|
2631 | + return $error; |
|
2632 | + } else { |
|
2633 | + return self::check_version(true); |
|
2634 | + } |
|
2390 | 2635 | } elseif ($result['value'] == '32') { |
2391 | 2636 | $error = self::update_from_32(); |
2392 | - if ($error != '') return $error; |
|
2393 | - else return self::check_version(true); |
|
2637 | + if ($error != '') { |
|
2638 | + return $error; |
|
2639 | + } else { |
|
2640 | + return self::check_version(true); |
|
2641 | + } |
|
2394 | 2642 | } elseif ($result['value'] == '33') { |
2395 | 2643 | $error = self::update_from_33(); |
2396 | - if ($error != '') return $error; |
|
2397 | - else return self::check_version(true); |
|
2644 | + if ($error != '') { |
|
2645 | + return $error; |
|
2646 | + } else { |
|
2647 | + return self::check_version(true); |
|
2648 | + } |
|
2398 | 2649 | } elseif ($result['value'] == '34') { |
2399 | 2650 | $error = self::update_from_34(); |
2400 | - if ($error != '') return $error; |
|
2401 | - else return self::check_version(true); |
|
2651 | + if ($error != '') { |
|
2652 | + return $error; |
|
2653 | + } else { |
|
2654 | + return self::check_version(true); |
|
2655 | + } |
|
2402 | 2656 | } elseif ($result['value'] == '35') { |
2403 | 2657 | $error = self::update_from_35(); |
2404 | - if ($error != '') return $error; |
|
2405 | - else return self::check_version(true); |
|
2658 | + if ($error != '') { |
|
2659 | + return $error; |
|
2660 | + } else { |
|
2661 | + return self::check_version(true); |
|
2662 | + } |
|
2406 | 2663 | } elseif ($result['value'] == '36') { |
2407 | 2664 | $error = self::update_from_36(); |
2408 | - if ($error != '') return $error; |
|
2409 | - else return self::check_version(true); |
|
2665 | + if ($error != '') { |
|
2666 | + return $error; |
|
2667 | + } else { |
|
2668 | + return self::check_version(true); |
|
2669 | + } |
|
2410 | 2670 | } elseif ($result['value'] == '37') { |
2411 | 2671 | $error = self::update_from_37(); |
2412 | - if ($error != '') return $error; |
|
2413 | - else return self::check_version(true); |
|
2672 | + if ($error != '') { |
|
2673 | + return $error; |
|
2674 | + } else { |
|
2675 | + return self::check_version(true); |
|
2676 | + } |
|
2414 | 2677 | } elseif ($result['value'] == '38') { |
2415 | 2678 | $error = self::update_from_38(); |
2416 | - if ($error != '') return $error; |
|
2417 | - else return self::check_version(true); |
|
2679 | + if ($error != '') { |
|
2680 | + return $error; |
|
2681 | + } else { |
|
2682 | + return self::check_version(true); |
|
2683 | + } |
|
2418 | 2684 | } elseif ($result['value'] == '39') { |
2419 | 2685 | $error = self::update_from_39(); |
2420 | - if ($error != '') return $error; |
|
2421 | - else return self::check_version(true); |
|
2686 | + if ($error != '') { |
|
2687 | + return $error; |
|
2688 | + } else { |
|
2689 | + return self::check_version(true); |
|
2690 | + } |
|
2422 | 2691 | } elseif ($result['value'] == '40') { |
2423 | 2692 | $error = self::update_from_40(); |
2424 | - if ($error != '') return $error; |
|
2425 | - else return self::check_version(true); |
|
2693 | + if ($error != '') { |
|
2694 | + return $error; |
|
2695 | + } else { |
|
2696 | + return self::check_version(true); |
|
2697 | + } |
|
2426 | 2698 | } elseif ($result['value'] == '41') { |
2427 | 2699 | $error = self::update_from_41(); |
2428 | - if ($error != '') return $error; |
|
2429 | - else return self::check_version(true); |
|
2700 | + if ($error != '') { |
|
2701 | + return $error; |
|
2702 | + } else { |
|
2703 | + return self::check_version(true); |
|
2704 | + } |
|
2430 | 2705 | } elseif ($result['value'] == '42') { |
2431 | 2706 | $error = self::update_from_42(); |
2432 | - if ($error != '') return $error; |
|
2433 | - else return self::check_version(true); |
|
2707 | + if ($error != '') { |
|
2708 | + return $error; |
|
2709 | + } else { |
|
2710 | + return self::check_version(true); |
|
2711 | + } |
|
2434 | 2712 | } elseif ($result['value'] == '43') { |
2435 | 2713 | $error = self::update_from_43(); |
2436 | - if ($error != '') return $error; |
|
2437 | - else return self::check_version(true); |
|
2714 | + if ($error != '') { |
|
2715 | + return $error; |
|
2716 | + } else { |
|
2717 | + return self::check_version(true); |
|
2718 | + } |
|
2438 | 2719 | } elseif ($result['value'] == '44') { |
2439 | 2720 | $error = self::update_from_44(); |
2440 | - if ($error != '') return $error; |
|
2441 | - else return self::check_version(true); |
|
2721 | + if ($error != '') { |
|
2722 | + return $error; |
|
2723 | + } else { |
|
2724 | + return self::check_version(true); |
|
2725 | + } |
|
2442 | 2726 | } elseif ($result['value'] == '45') { |
2443 | 2727 | $error = self::update_from_45(); |
2444 | - if ($error != '') return $error; |
|
2445 | - else return self::check_version(true); |
|
2728 | + if ($error != '') { |
|
2729 | + return $error; |
|
2730 | + } else { |
|
2731 | + return self::check_version(true); |
|
2732 | + } |
|
2446 | 2733 | } elseif ($result['value'] == '46') { |
2447 | 2734 | $error = self::update_from_46(); |
2448 | - if ($error != '') return $error; |
|
2449 | - else return self::check_version(true); |
|
2735 | + if ($error != '') { |
|
2736 | + return $error; |
|
2737 | + } else { |
|
2738 | + return self::check_version(true); |
|
2739 | + } |
|
2450 | 2740 | } elseif ($result['value'] == '47') { |
2451 | 2741 | $error = self::update_from_47(); |
2452 | - if ($error != '') return $error; |
|
2453 | - else return self::check_version(true); |
|
2742 | + if ($error != '') { |
|
2743 | + return $error; |
|
2744 | + } else { |
|
2745 | + return self::check_version(true); |
|
2746 | + } |
|
2454 | 2747 | } elseif ($result['value'] == '48') { |
2455 | 2748 | $error = self::update_from_48(); |
2456 | - if ($error != '') return $error; |
|
2457 | - else return self::check_version(true); |
|
2458 | - } else return ''; |
|
2749 | + if ($error != '') { |
|
2750 | + return $error; |
|
2751 | + } else { |
|
2752 | + return self::check_version(true); |
|
2753 | + } |
|
2754 | + } else { |
|
2755 | + return ''; |
|
2756 | + } |
|
2459 | 2757 | } else { |
2460 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2461 | - else return 0; |
|
2758 | + if (isset($result['value']) && $result['value'] != '') { |
|
2759 | + return $result['value']; |
|
2760 | + } else { |
|
2761 | + return 0; |
|
2762 | + } |
|
2462 | 2763 | } |
2463 | 2764 | } |
2464 | - } else return $version; |
|
2765 | + } else { |
|
2766 | + return $version; |
|
2767 | + } |
|
2465 | 2768 | } |
2466 | 2769 | } |
2467 | 2770 | } |
@@ -22,11 +22,15 @@ discard block |
||
22 | 22 | require_once('require/class.Spotter.php'); |
23 | 23 | } |
24 | 24 | |
25 | -if (!isset($filter_name)) $filter_name = ''; |
|
25 | +if (!isset($filter_name)) { |
|
26 | + $filter_name = ''; |
|
27 | +} |
|
26 | 28 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
27 | 29 | if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) { |
28 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
29 | -} |
|
30 | + if (isset($globalFilter['airline'])) { |
|
31 | + $airline_icao = $globalFilter['airline'][0]; |
|
32 | + } |
|
33 | + } |
|
30 | 34 | if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') { |
31 | 35 | $Spotter = new Spotter(); |
32 | 36 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -61,7 +65,12 @@ discard block |
||
61 | 65 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
62 | 66 | <div class="column"> |
63 | 67 | <div class="info"> |
64 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
68 | + <h1><?php if (isset($airline_name)) { |
|
69 | + echo _("Statistics for ").$airline_name; |
|
70 | +} else { |
|
71 | + echo _("Statistics"); |
|
72 | +} |
|
73 | +?></h1> |
|
65 | 74 | <?php |
66 | 75 | if ($type == 'aircraft') { |
67 | 76 | $last_update = $Stats->getLastStatsUpdate(); |
@@ -73,7 +82,9 @@ discard block |
||
73 | 82 | if (isset($last_update[0]['value'])) { |
74 | 83 | date_default_timezone_set('UTC'); |
75 | 84 | $lastupdate = strtotime($last_update[0]['value']); |
76 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
85 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
86 | + date_default_timezone_set($globalTimezone); |
|
87 | + } |
|
77 | 88 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
78 | 89 | } |
79 | 90 | |
@@ -158,8 +169,11 @@ discard block |
||
158 | 169 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
159 | 170 | $aircraft_data = ''; |
160 | 171 | foreach($aircraft_array as $aircraft_item) { |
161 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
162 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
172 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
173 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
174 | + } else { |
|
175 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
176 | + } |
|
163 | 177 | } |
164 | 178 | $aircraft_data = substr($aircraft_data, 0, -1); |
165 | 179 | print 'var series = ['.$aircraft_data.'];'; |
@@ -176,11 +190,17 @@ discard block |
||
176 | 190 | <?php |
177 | 191 | if ($year != '' && $month != '') { |
178 | 192 | ?> |
179 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
193 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
194 | + echo '/'.$airline_icao; |
|
195 | +} |
|
196 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
180 | 197 | <?php |
181 | 198 | } else { |
182 | 199 | ?> |
183 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
200 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
201 | + echo '/'.$airline_icao; |
|
202 | +} |
|
203 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
184 | 204 | <?php |
185 | 205 | } |
186 | 206 | ?> |
@@ -209,11 +229,15 @@ discard block |
||
209 | 229 | print '</script>'; |
210 | 230 | if ($year != '' && $month != '') { |
211 | 231 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
212 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
232 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
233 | + echo '/'.$airline_icao; |
|
234 | + } |
|
213 | 235 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
214 | 236 | } else { |
215 | 237 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
216 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
238 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
239 | + echo '/'.$airline_icao; |
|
240 | + } |
|
217 | 241 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
218 | 242 | } |
219 | 243 | print '</div>'; |
@@ -233,8 +257,9 @@ discard block |
||
233 | 257 | <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2> |
234 | 258 | <?php |
235 | 259 | $marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month); |
236 | - if (count($marine_array) == 0) print _("No data available"); |
|
237 | - else { |
|
260 | + if (count($marine_array) == 0) { |
|
261 | + print _("No data available"); |
|
262 | + } else { |
|
238 | 263 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
239 | 264 | $marine_data = ''; |
240 | 265 | foreach($marine_array as $marine_item) { |
@@ -277,8 +302,9 @@ discard block |
||
277 | 302 | <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2> |
278 | 303 | <?php |
279 | 304 | $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
280 | - if (count($tracker_array) == 0) print _("No data available"); |
|
281 | - else { |
|
305 | + if (count($tracker_array) == 0) { |
|
306 | + print _("No data available"); |
|
307 | + } else { |
|
282 | 308 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
283 | 309 | $tracker_data = ''; |
284 | 310 | foreach($tracker_array as $tracker_item) { |
@@ -322,8 +348,9 @@ discard block |
||
322 | 348 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
323 | 349 | <?php |
324 | 350 | $owner_array = $Satellite->countAllOwners(true); |
325 | - if (count($owner_array) == 0) print _("No data available"); |
|
326 | - else { |
|
351 | + if (count($owner_array) == 0) { |
|
352 | + print _("No data available"); |
|
353 | + } else { |
|
327 | 354 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
328 | 355 | $owner_data = ''; |
329 | 356 | foreach($owner_array as $owner_item) { |
@@ -342,7 +369,10 @@ discard block |
||
342 | 369 | ?> |
343 | 370 | <!-- |
344 | 371 | <div class="more"> |
345 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
372 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
373 | + echo '/'.$airline_icao; |
|
374 | +} |
|
375 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
346 | 376 | </div> |
347 | 377 | --> |
348 | 378 | </div> |
@@ -351,8 +381,9 @@ discard block |
||
351 | 381 | <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2> |
352 | 382 | <?php |
353 | 383 | $countries_array = $Satellite->countAllCountriesOwners(true); |
354 | - if (count($countries_array) == 0) print _("No data available"); |
|
355 | - else { |
|
384 | + if (count($countries_array) == 0) { |
|
385 | + print _("No data available"); |
|
386 | + } else { |
|
356 | 387 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
357 | 388 | $owner_data = ''; |
358 | 389 | foreach($countries_array as $owner_item) { |
@@ -371,7 +402,10 @@ discard block |
||
371 | 402 | ?> |
372 | 403 | <!-- |
373 | 404 | <div class="more"> |
374 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
405 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
406 | + echo '/'.$airline_icao; |
|
407 | +} |
|
408 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
375 | 409 | </div> |
376 | 410 | --> |
377 | 411 | </div> |
@@ -383,8 +417,9 @@ discard block |
||
383 | 417 | <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2> |
384 | 418 | <?php |
385 | 419 | $launch_site_array = $Satellite->countAllLaunchSite(true); |
386 | - if (count($launch_site_array) == 0) print _("No data available"); |
|
387 | - else { |
|
420 | + if (count($launch_site_array) == 0) { |
|
421 | + print _("No data available"); |
|
422 | + } else { |
|
388 | 423 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
389 | 424 | $launch_site_data = ''; |
390 | 425 | foreach($launch_site_array as $launch_site_item) { |
@@ -403,7 +438,10 @@ discard block |
||
403 | 438 | ?> |
404 | 439 | <!-- |
405 | 440 | <div class="more"> |
406 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
441 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
442 | + echo '/'.$airline_icao; |
|
443 | +} |
|
444 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
407 | 445 | </div> |
408 | 446 | --> |
409 | 447 | </div> |
@@ -426,8 +464,9 @@ discard block |
||
426 | 464 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
427 | 465 | <?php |
428 | 466 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
429 | - if (count($pilot_array) == 0) print _("No data available"); |
|
430 | - else { |
|
467 | + if (count($pilot_array) == 0) { |
|
468 | + print _("No data available"); |
|
469 | + } else { |
|
431 | 470 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
432 | 471 | $pilot_data = ''; |
433 | 472 | foreach($pilot_array as $pilot_item) { |
@@ -445,7 +484,9 @@ discard block |
||
445 | 484 | } |
446 | 485 | print '<div class="more">'; |
447 | 486 | print '<a href="'.$globalURL.'/statistics/pilot'; |
448 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
487 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
488 | + echo '/'.$airline_icao; |
|
489 | + } |
|
449 | 490 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
450 | 491 | print '</div>'; |
451 | 492 | ?> |
@@ -461,8 +502,9 @@ discard block |
||
461 | 502 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
462 | 503 | <?php |
463 | 504 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
464 | - if (count($owner_array) == 0) print _("No data available"); |
|
465 | - else { |
|
505 | + if (count($owner_array) == 0) { |
|
506 | + print _("No data available"); |
|
507 | + } else { |
|
466 | 508 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
467 | 509 | $owner_data = ''; |
468 | 510 | foreach($owner_array as $owner_item) { |
@@ -480,7 +522,10 @@ discard block |
||
480 | 522 | } |
481 | 523 | ?> |
482 | 524 | <div class="more"> |
483 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
525 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
526 | + echo '/'.$airline_icao; |
|
527 | +} |
|
528 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
484 | 529 | </div> |
485 | 530 | </div> |
486 | 531 | |
@@ -493,8 +538,9 @@ discard block |
||
493 | 538 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
494 | 539 | <?php |
495 | 540 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
496 | - if (count($flightover_array) == 0) print _("No data available"); |
|
497 | - else { |
|
541 | + if (count($flightover_array) == 0) { |
|
542 | + print _("No data available"); |
|
543 | + } else { |
|
498 | 544 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
499 | 545 | print 'var series = ['; |
500 | 546 | $flightover_data = ''; |
@@ -536,7 +582,10 @@ discard block |
||
536 | 582 | } |
537 | 583 | ?> |
538 | 584 | <div class="more"> |
539 | - <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
585 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
586 | + echo '/'.$airline_icao; |
|
587 | +} |
|
588 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
540 | 589 | </div> |
541 | 590 | </div> |
542 | 591 | <?php |
@@ -554,8 +603,9 @@ discard block |
||
554 | 603 | <div class="col-md-6"> |
555 | 604 | <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2> |
556 | 605 | <?php |
557 | - if (count($flightover_array) == 0) print _("No data available"); |
|
558 | - else { |
|
606 | + if (count($flightover_array) == 0) { |
|
607 | + print _("No data available"); |
|
608 | + } else { |
|
559 | 609 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
560 | 610 | print 'var series = ['; |
561 | 611 | $flightover_data = ''; |
@@ -612,8 +662,9 @@ discard block |
||
612 | 662 | <div class="col-md-6"> |
613 | 663 | <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2> |
614 | 664 | <?php |
615 | - if (count($flightover_array) == 0) print _("No data available"); |
|
616 | - else { |
|
665 | + if (count($flightover_array) == 0) { |
|
666 | + print _("No data available"); |
|
667 | + } else { |
|
617 | 668 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
618 | 669 | print 'var series = ['; |
619 | 670 | $flightover_data = ''; |
@@ -719,7 +770,9 @@ discard block |
||
719 | 770 | });"; |
720 | 771 | print '</script>'; |
721 | 772 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
722 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
773 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
774 | + echo '/'.$airline_icao; |
|
775 | + } |
|
723 | 776 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
724 | 777 | } |
725 | 778 | ?> |
@@ -783,7 +836,9 @@ discard block |
||
783 | 836 | });"; |
784 | 837 | print '</script>'; |
785 | 838 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
786 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
839 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
840 | + echo '/'.$airline_icao; |
|
841 | + } |
|
787 | 842 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
788 | 843 | } |
789 | 844 | ?> |
@@ -802,8 +857,9 @@ discard block |
||
802 | 857 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
803 | 858 | <?php |
804 | 859 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
805 | - if (count($year_array) == 0) print _("No data available"); |
|
806 | - else { |
|
860 | + if (count($year_array) == 0) { |
|
861 | + print _("No data available"); |
|
862 | + } else { |
|
807 | 863 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
808 | 864 | $year_data = ''; |
809 | 865 | $year_cnt = ''; |
@@ -822,7 +878,10 @@ discard block |
||
822 | 878 | } |
823 | 879 | ?> |
824 | 880 | <div class="more"> |
825 | - <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
881 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
882 | + echo '/'.$airline_icao; |
|
883 | +} |
|
884 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
826 | 885 | </div> |
827 | 886 | </div> |
828 | 887 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -830,8 +889,9 @@ discard block |
||
830 | 889 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
831 | 890 | <?php |
832 | 891 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
833 | - if (count($month_array) == 0) print _("No data available"); |
|
834 | - else { |
|
892 | + if (count($month_array) == 0) { |
|
893 | + print _("No data available"); |
|
894 | + } else { |
|
835 | 895 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
836 | 896 | $month_data = ''; |
837 | 897 | $month_cnt = ''; |
@@ -850,7 +910,10 @@ discard block |
||
850 | 910 | } |
851 | 911 | ?> |
852 | 912 | <div class="more"> |
853 | - <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
913 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
914 | + echo '/'.$airline_icao; |
|
915 | +} |
|
916 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
854 | 917 | </div> |
855 | 918 | </div> |
856 | 919 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -859,8 +922,9 @@ discard block |
||
859 | 922 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
860 | 923 | <?php |
861 | 924 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
862 | - if (empty($date_array)) print _("No data available"); |
|
863 | - else { |
|
925 | + if (empty($date_array)) { |
|
926 | + print _("No data available"); |
|
927 | + } else { |
|
864 | 928 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
865 | 929 | $date_data = ''; |
866 | 930 | $date_cnt = ''; |
@@ -879,7 +943,10 @@ discard block |
||
879 | 943 | } |
880 | 944 | ?> |
881 | 945 | <div class="more"> |
882 | - <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
946 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
947 | + echo '/'.$airline_icao; |
|
948 | +} |
|
949 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
883 | 950 | </div> |
884 | 951 | </div> |
885 | 952 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -887,8 +954,9 @@ discard block |
||
887 | 954 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
888 | 955 | <?php |
889 | 956 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
890 | - if (empty($hour_array)) print _("No data available"); |
|
891 | - else { |
|
957 | + if (empty($hour_array)) { |
|
958 | + print _("No data available"); |
|
959 | + } else { |
|
892 | 960 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
893 | 961 | $hour_data = ''; |
894 | 962 | $hour_cnt = ''; |
@@ -907,7 +975,10 @@ discard block |
||
907 | 975 | } |
908 | 976 | ?> |
909 | 977 | <div class="more"> |
910 | - <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
978 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
979 | + echo '/'.$airline_icao; |
|
980 | +} |
|
981 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
911 | 982 | </div> |
912 | 983 | </div> |
913 | 984 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -927,8 +998,9 @@ discard block |
||
927 | 998 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
928 | 999 | <?php |
929 | 1000 | $year_array = $Stats->countAllMarineMonthsLastYear(true,$filter_name); |
930 | - if (count($year_array) == 0) print _("No data available"); |
|
931 | - else { |
|
1001 | + if (count($year_array) == 0) { |
|
1002 | + print _("No data available"); |
|
1003 | + } else { |
|
932 | 1004 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
933 | 1005 | $year_data = ''; |
934 | 1006 | $year_cnt = ''; |
@@ -956,8 +1028,9 @@ discard block |
||
956 | 1028 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
957 | 1029 | <?php |
958 | 1030 | $month_array = $Stats->countAllMarineDatesLastMonth($filter_name); |
959 | - if (count($month_array) == 0) print _("No data available"); |
|
960 | - else { |
|
1031 | + if (count($month_array) == 0) { |
|
1032 | + print _("No data available"); |
|
1033 | + } else { |
|
961 | 1034 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
962 | 1035 | $month_data = ''; |
963 | 1036 | $month_cnt = ''; |
@@ -985,8 +1058,9 @@ discard block |
||
985 | 1058 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
986 | 1059 | <?php |
987 | 1060 | $date_array = $Stats->countAllMarineDatesLast7Days($filter_name); |
988 | - if (empty($date_array)) print _("No data available"); |
|
989 | - else { |
|
1061 | + if (empty($date_array)) { |
|
1062 | + print _("No data available"); |
|
1063 | + } else { |
|
990 | 1064 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
991 | 1065 | $date_data = ''; |
992 | 1066 | $date_cnt = ''; |
@@ -1013,8 +1087,9 @@ discard block |
||
1013 | 1087 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1014 | 1088 | <?php |
1015 | 1089 | $hour_array = $Stats->countAllMarineHours('hour',true,$filter_name); |
1016 | - if (empty($hour_array)) print _("No data available"); |
|
1017 | - else { |
|
1090 | + if (empty($hour_array)) { |
|
1091 | + print _("No data available"); |
|
1092 | + } else { |
|
1018 | 1093 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1019 | 1094 | $hour_data = ''; |
1020 | 1095 | $hour_cnt = ''; |
@@ -1053,8 +1128,9 @@ discard block |
||
1053 | 1128 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
1054 | 1129 | <?php |
1055 | 1130 | $year_array = $Stats->countAllTrackerMonthsLastYear(true); |
1056 | - if (count($year_array) == 0) print _("No data available"); |
|
1057 | - else { |
|
1131 | + if (count($year_array) == 0) { |
|
1132 | + print _("No data available"); |
|
1133 | + } else { |
|
1058 | 1134 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
1059 | 1135 | $year_data = ''; |
1060 | 1136 | $year_cnt = ''; |
@@ -1082,8 +1158,9 @@ discard block |
||
1082 | 1158 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
1083 | 1159 | <?php |
1084 | 1160 | $month_array = $Stats->countAllTrackerDatesLastMonth(); |
1085 | - if (count($month_array) == 0) print _("No data available"); |
|
1086 | - else { |
|
1161 | + if (count($month_array) == 0) { |
|
1162 | + print _("No data available"); |
|
1163 | + } else { |
|
1087 | 1164 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
1088 | 1165 | $month_data = ''; |
1089 | 1166 | $month_cnt = ''; |
@@ -1111,8 +1188,9 @@ discard block |
||
1111 | 1188 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
1112 | 1189 | <?php |
1113 | 1190 | $date_array = $Stats->countAllTrackerDatesLast7Days(); |
1114 | - if (empty($date_array)) print _("No data available"); |
|
1115 | - else { |
|
1191 | + if (empty($date_array)) { |
|
1192 | + print _("No data available"); |
|
1193 | + } else { |
|
1116 | 1194 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
1117 | 1195 | $date_data = ''; |
1118 | 1196 | $date_cnt = ''; |
@@ -1139,8 +1217,9 @@ discard block |
||
1139 | 1217 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1140 | 1218 | <?php |
1141 | 1219 | $hour_array = $Stats->countAllTrackerHours('hour',true); |
1142 | - if (empty($hour_array)) print _("No data available"); |
|
1143 | - else { |
|
1220 | + if (empty($hour_array)) { |
|
1221 | + print _("No data available"); |
|
1222 | + } else { |
|
1144 | 1223 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1145 | 1224 | $hour_data = ''; |
1146 | 1225 | $hour_cnt = ''; |
@@ -1179,8 +1258,9 @@ discard block |
||
1179 | 1258 | <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2> |
1180 | 1259 | <?php |
1181 | 1260 | $year_array = $Satellite->countAllMonthsLastYear(); |
1182 | - if (count($year_array) == 0) print _("No data available"); |
|
1183 | - else { |
|
1261 | + if (count($year_array) == 0) { |
|
1262 | + print _("No data available"); |
|
1263 | + } else { |
|
1184 | 1264 | print '<div id="chart21" class="chart" width="100%"></div><script>'; |
1185 | 1265 | $year_data = ''; |
1186 | 1266 | $year_cnt = ''; |
@@ -1210,8 +1290,9 @@ discard block |
||
1210 | 1290 | <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2> |
1211 | 1291 | <?php |
1212 | 1292 | $year_array = $Satellite->countAllYears(); |
1213 | - if (count($year_array) == 0) print _("No data available"); |
|
1214 | - else { |
|
1293 | + if (count($year_array) == 0) { |
|
1294 | + print _("No data available"); |
|
1295 | + } else { |
|
1215 | 1296 | print '<div id="chart22" class="chart" width="100%"></div><script>'; |
1216 | 1297 | $year_data = ''; |
1217 | 1298 | $year_cnt = ''; |
@@ -1253,8 +1334,9 @@ discard block |
||
1253 | 1334 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
1254 | 1335 | <?php |
1255 | 1336 | $year_array = $Stats->countFatalitiesByYear(); |
1256 | - if (count($year_array) == 0) print _("No data available"); |
|
1257 | - else { |
|
1337 | + if (count($year_array) == 0) { |
|
1338 | + print _("No data available"); |
|
1339 | + } else { |
|
1258 | 1340 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
1259 | 1341 | $year_data = ''; |
1260 | 1342 | $year_cnt = ''; |
@@ -1283,8 +1365,9 @@ discard block |
||
1283 | 1365 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
1284 | 1366 | <?php |
1285 | 1367 | $year_array = $Stats->countFatalitiesLast12Months(); |
1286 | - if (count($year_array) == 0) print _("No data available"); |
|
1287 | - else { |
|
1368 | + if (count($year_array) == 0) { |
|
1369 | + print _("No data available"); |
|
1370 | + } else { |
|
1288 | 1371 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
1289 | 1372 | $year_data = ''; |
1290 | 1373 | $year_cnt = ''; |
@@ -1355,8 +1438,11 @@ discard block |
||
1355 | 1438 | $distance = $distance; |
1356 | 1439 | $unit = 'km'; |
1357 | 1440 | } |
1358 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1359 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1441 | + if (!isset($polar_data)) { |
|
1442 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1443 | + } else { |
|
1444 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1445 | + } |
|
1360 | 1446 | } |
1361 | 1447 | ?> |
1362 | 1448 | <div class="col-md-6"> |
@@ -1420,9 +1506,12 @@ discard block |
||
1420 | 1506 | foreach ($msg as $eachmsg) { |
1421 | 1507 | //$eachmsg = $msg[0]; |
1422 | 1508 | $data = $eachmsg['source_data']; |
1423 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
1424 | - else $max = 500; |
|
1425 | -?> |
|
1509 | + if ($data > 500) { |
|
1510 | + $max = (round(($data+100)/100))*100; |
|
1511 | + } else { |
|
1512 | + $max = 500; |
|
1513 | + } |
|
1514 | + ?> |
|
1426 | 1515 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
1427 | 1516 | <script> |
1428 | 1517 | var g = new JustGage({ |