@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | die; |
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
53 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
57 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['s']); |
64 | 64 | } elseif (isset($options['source'])) { |
65 | 65 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
67 | 67 | else $globalSources[] = array('host' => $options['source']); |
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | else $id_source = 1; |
81 | 81 | if (isset($globalServer) && $globalServer) { |
82 | 82 | if ($globalDebug) echo "Using Server Mode\n"; |
83 | - $SI=new SpotterServer(); |
|
83 | + $SI = new SpotterServer(); |
|
84 | 84 | /* |
85 | 85 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
86 | 86 | $SI = new adsb2aprs(); |
87 | 87 | $SI->connect(); |
88 | 88 | */ |
89 | -} else $SI=new SpotterImport($Connection->db); |
|
89 | +} else $SI = new SpotterImport($Connection->db); |
|
90 | 90 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
91 | 91 | if (isset($globalMarine) && $globalMarine) { |
92 | 92 | $AIS = new AIS(); |
93 | 93 | $MI = new MarineImport($Connection->db); |
94 | 94 | } |
95 | 95 | //$APRS=new APRS($Connection->db); |
96 | -$SBS=new SBS(); |
|
97 | -$ACARS=new ACARS($Connection->db,true); |
|
98 | -$Source=new Source($Connection->db); |
|
99 | -$Common=new Common(); |
|
96 | +$SBS = new SBS(); |
|
97 | +$ACARS = new ACARS($Connection->db, true); |
|
98 | +$Source = new Source($Connection->db); |
|
99 | +$Common = new Common(); |
|
100 | 100 | date_default_timezone_set('UTC'); |
101 | 101 | //$servertz = system('date +%Z'); |
102 | 102 | // signal handler - playing nice with sockets and dump1090 |
103 | 103 | if (function_exists('pcntl_fork')) { |
104 | - pcntl_signal(SIGINT, function() { |
|
104 | + pcntl_signal(SIGINT, function() { |
|
105 | 105 | global $sockets; |
106 | 106 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
107 | 107 | die("Bye!\n"); |
@@ -117,30 +117,30 @@ discard block |
||
117 | 117 | |
118 | 118 | function connect_all($hosts) { |
119 | 119 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
120 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
120 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
121 | 121 | $reset++; |
122 | 122 | if ($globalDebug) echo 'Connect to all...'."\n"; |
123 | 123 | foreach ($hosts as $id => $value) { |
124 | 124 | $host = $value['host']; |
125 | 125 | $globalSources[$id]['last_exec'] = 0; |
126 | 126 | // Here we check type of source(s) |
127 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
128 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
127 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
128 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
129 | 129 | //$formats[$id] = 'deltadbtxt'; |
130 | 130 | $globalSources[$id]['format'] = 'deltadbtxt'; |
131 | 131 | //$last_exec['deltadbtxt'] = 0; |
132 | 132 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
133 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
133 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
134 | 134 | //$formats[$id] = 'vatsimtxt'; |
135 | 135 | $globalSources[$id]['format'] = 'vatsimtxt'; |
136 | 136 | //$last_exec['vatsimtxt'] = 0; |
137 | 137 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
138 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
138 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
139 | 139 | //$formats[$id] = 'aircraftlistjson'; |
140 | 140 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
141 | 141 | //$last_exec['aircraftlistjson'] = 0; |
142 | 142 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
143 | - } else if (preg_match('/opensky/i',$host)) { |
|
143 | + } else if (preg_match('/opensky/i', $host)) { |
|
144 | 144 | //$formats[$id] = 'aircraftlistjson'; |
145 | 145 | $globalSources[$id]['format'] = 'opensky'; |
146 | 146 | //$last_exec['aircraftlistjson'] = 0; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | exit(0); |
158 | 158 | } |
159 | 159 | */ |
160 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
160 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
161 | 161 | //$formats[$id] = 'planeupdatefaa'; |
162 | 162 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
163 | 163 | //$last_exec['planeupdatefaa'] = 0; |
@@ -166,32 +166,32 @@ discard block |
||
166 | 166 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
167 | 167 | exit(0); |
168 | 168 | } |
169 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
169 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
170 | 170 | //$formats[$id] = 'phpvmacars'; |
171 | 171 | $globalSources[$id]['format'] = 'phpvmacars'; |
172 | 172 | //$last_exec['phpvmacars'] = 0; |
173 | 173 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
174 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
174 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'phpvmacars'; |
176 | 176 | $globalSources[$id]['format'] = 'vam'; |
177 | 177 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
178 | - } else if (preg_match('/whazzup/i',$host)) { |
|
178 | + } else if (preg_match('/whazzup/i', $host)) { |
|
179 | 179 | //$formats[$id] = 'whazzup'; |
180 | 180 | $globalSources[$id]['format'] = 'whazzup'; |
181 | 181 | //$last_exec['whazzup'] = 0; |
182 | 182 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
183 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
183 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
184 | 184 | $globalSources[$id]['format'] = 'blitzortung'; |
185 | 185 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
186 | - } else if (preg_match('/airwhere/i',$host)) { |
|
186 | + } else if (preg_match('/airwhere/i', $host)) { |
|
187 | 187 | $globalSources[$id]['format'] = 'airwhere'; |
188 | 188 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
189 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
189 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
190 | 190 | //$formats[$id] = 'pirepsjson'; |
191 | 191 | $globalSources[$id]['format'] = 'pirepsjson'; |
192 | 192 | //$last_exec['pirepsjson'] = 0; |
193 | 193 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
194 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
194 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
195 | 195 | //$formats[$id] = 'fr24json'; |
196 | 196 | $globalSources[$id]['format'] = 'fr24json'; |
197 | 197 | //$last_exec['fr24json'] = 0; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
201 | 201 | exit(0); |
202 | 202 | } |
203 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
203 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
204 | 204 | //$formats[$id] = 'fr24json'; |
205 | 205 | $globalSources[$id]['format'] = 'myshiptracking'; |
206 | 206 | //$last_exec['fr24json'] = 0; |
@@ -210,22 +210,22 @@ discard block |
||
210 | 210 | exit(0); |
211 | 211 | } |
212 | 212 | //} else if (preg_match('/10001/',$host)) { |
213 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
213 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
214 | 214 | //$formats[$id] = 'tsv'; |
215 | 215 | $globalSources[$id]['format'] = 'tsv'; |
216 | 216 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
217 | 217 | } |
218 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
218 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
219 | 219 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
220 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
220 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
221 | 221 | if ($idf !== false) { |
222 | 222 | $httpfeeds[$id] = $idf; |
223 | 223 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
224 | 224 | } |
225 | 225 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
226 | 226 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
227 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
228 | - $hostport = explode(':',$host); |
|
227 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
228 | + $hostport = explode(':', $host); |
|
229 | 229 | if (isset($hostport[1])) { |
230 | 230 | $port = $hostport[1]; |
231 | 231 | $hostn = $hostport[0]; |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | } |
236 | 236 | $Common = new Common(); |
237 | 237 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
238 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
238 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
239 | 239 | } else { |
240 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
240 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
241 | 241 | } |
242 | 242 | if ($s) { |
243 | 243 | $sockets[$id] = $s; |
244 | 244 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
245 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
245 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
246 | 246 | //$formats[$id] = 'aprs'; |
247 | 247 | $globalSources[$id]['format'] = 'aprs'; |
248 | 248 | //$aprs_connect = 0; |
249 | 249 | //$use_aprs = true; |
250 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
250 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
251 | 251 | $globalSources[$id]['format'] = 'vrstcp'; |
252 | 252 | } elseif ($port == '10001') { |
253 | 253 | //$formats[$id] = 'tsv'; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
287 | 287 | else $timeout = 20; |
288 | 288 | $errno = ''; |
289 | -$errstr=''; |
|
289 | +$errstr = ''; |
|
290 | 290 | |
291 | 291 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
292 | 292 | /* Initiate connections to all the hosts simultaneously */ |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | //connect_all($globalSources); |
295 | 295 | |
296 | 296 | if (isset($globalProxy) && $globalProxy) { |
297 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
297 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
298 | 298 | } else { |
299 | 299 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
300 | 300 | } |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | |
325 | 325 | if ($use_aprs) { |
326 | 326 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
327 | - $APRS=new APRS(); |
|
327 | + $APRS = new APRS(); |
|
328 | 328 | $aprs_connect = 0; |
329 | 329 | $aprs_keep = 120; |
330 | 330 | $aprs_last_tx = time(); |
331 | 331 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
332 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
332 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
333 | 333 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
334 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
334 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
335 | 335 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
336 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
336 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
337 | 337 | if ($aprs_full) $aprs_filter = ''; |
338 | 338 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
339 | 339 | else $aprs_pass = '-1'; |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | sleep(1); |
348 | 348 | if ($globalDebug) echo "SCAN MODE \n\n"; |
349 | 349 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
350 | -$endtime = time()+$globalCronEnd; |
|
350 | +$endtime = time() + $globalCronEnd; |
|
351 | 351 | $i = 1; |
352 | 352 | $tt = array(); |
353 | 353 | // Delete all ATC |
354 | 354 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
355 | - $ATC=new ATC($Connection->db); |
|
355 | + $ATC = new ATC($Connection->db); |
|
356 | 356 | } |
357 | 357 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
358 | 358 | $ATC->deleteAll(); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
362 | 362 | while ($i > 0) { |
363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
363 | + if (!$globalDaemon) $i = $endtime - time(); |
|
364 | 364 | // Delete old ATC |
365 | 365 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
366 | 366 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | } |
375 | 375 | if ($max != $globalMinFetch) { |
376 | 376 | if ($globalDebug) echo 'Sleeping...'."\n"; |
377 | - sleep($globalMinFetch-$max+2); |
|
377 | + sleep($globalMinFetch - $max + 2); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | //$buffer = $Common->getData($hosts[$id]); |
394 | 394 | $buffer = $Common->getData($value['host']); |
395 | 395 | if ($buffer != '') $reset = 0; |
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
396 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
397 | + $buffer = explode('\n', $buffer); |
|
398 | 398 | foreach ($buffer as $line) { |
399 | 399 | if ($line != '' && count($line) > 7) { |
400 | 400 | $line = explode(',', $line); |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | ) |
428 | 428 | ) { |
429 | 429 | date_default_timezone_set('CET'); |
430 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
430 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
431 | 431 | date_default_timezone_set('UTC'); |
432 | 432 | if ($buffer != '') $reset = 0; |
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
433 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
434 | + $buffer = explode('\n', $buffer); |
|
435 | 435 | foreach ($buffer as $line) { |
436 | 436 | if ($line != '') { |
437 | 437 | //echo "'".$line."'\n"; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
450 | 450 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
451 | 451 | if (isset($ais_data['timestamp'])) { |
452 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
452 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
453 | 453 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
454 | 454 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
455 | 455 | $add = true; |
@@ -472,12 +472,12 @@ discard block |
||
472 | 472 | $w = $e = null; |
473 | 473 | |
474 | 474 | if (isset($arr[$id])) { |
475 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
475 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
476 | 476 | if ($nn > 0) { |
477 | 477 | foreach ($httpfeeds as $feed) { |
478 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
479 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
480 | - $buffer = explode('\n',$buffer); |
|
478 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
479 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
480 | + $buffer = explode('\n', $buffer); |
|
481 | 481 | foreach ($buffer as $line) { |
482 | 482 | if ($line != '') { |
483 | 483 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
496 | 496 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
497 | 497 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
498 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
498 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
499 | 499 | if (isset($ais_data['timestamp'])) { |
500 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
500 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
501 | 501 | } else { |
502 | 502 | $data['datetime'] = date('Y-m-d H:i:s'); |
503 | 503 | } |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
529 | 529 | ) |
530 | 530 | ) { |
531 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
531 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
532 | 532 | if ($buffer != '') { |
533 | 533 | //echo $buffer; |
534 | - $all_data = json_decode($buffer,true); |
|
534 | + $all_data = json_decode($buffer, true); |
|
535 | 535 | //print_r($all_data); |
536 | 536 | if (isset($all_data[0]['DATA'])) { |
537 | 537 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
547 | 547 | $data['imo'] = $line['IMO']; |
548 | 548 | //$data['arrival_code'] = $ais_data['destination']; |
549 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
550 | 550 | $data['format_source'] = 'myshiptracking'; |
551 | 551 | $data['id_source'] = $id_source; |
552 | 552 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
564 | 564 | ) |
565 | 565 | ) { |
566 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
566 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
567 | 567 | if ($buffer != '') { |
568 | - $all_data = json_decode($buffer,true); |
|
568 | + $all_data = json_decode($buffer, true); |
|
569 | 569 | if (isset($all_data[0]['mmsi'])) { |
570 | 570 | foreach ($all_data as $line) { |
571 | 571 | if ($line != '') { |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | ) { |
600 | 600 | $buffer = $Common->getData($value['host']); |
601 | 601 | if ($buffer != '') { |
602 | - $all_data = json_decode($buffer,true); |
|
602 | + $all_data = json_decode($buffer, true); |
|
603 | 603 | if (isset($all_data['features'][0]['id'])) { |
604 | 604 | foreach ($all_data['features'] as $line) { |
605 | 605 | $data = array(); |
@@ -632,27 +632,27 @@ discard block |
||
632 | 632 | ) |
633 | 633 | ) { |
634 | 634 | echo 'download...'; |
635 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
635 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
636 | 636 | echo 'done !'."\n"; |
637 | 637 | if ($buffer != '') $reset = 0; |
638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
639 | - $buffer = explode('\n',$buffer); |
|
638 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
639 | + $buffer = explode('\n', $buffer); |
|
640 | 640 | foreach ($buffer as $line) { |
641 | 641 | if ($line != '') { |
642 | 642 | $data = array(); |
643 | - $data['mmsi'] = (int)substr($line,0,9); |
|
644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
643 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
644 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
645 | 645 | //$data['status'] = substr($line,21,2); |
646 | 646 | //$data['type'] = substr($line,24,3); |
647 | - $data['latitude'] = substr($line,29,9); |
|
648 | - $data['longitude'] = substr($line,41,9); |
|
649 | - $data['speed'] = round(substr($line,51,5)); |
|
647 | + $data['latitude'] = substr($line, 29, 9); |
|
648 | + $data['longitude'] = substr($line, 41, 9); |
|
649 | + $data['speed'] = round(substr($line, 51, 5)); |
|
650 | 650 | //$data['course'] = substr($line,57,5); |
651 | - $data['heading'] = round(substr($line,63,3)); |
|
651 | + $data['heading'] = round(substr($line, 63, 3)); |
|
652 | 652 | //$data['draft'] = substr($line,67,4); |
653 | 653 | //$data['length'] = substr($line,72,3); |
654 | 654 | //$data['beam'] = substr($line,76,2); |
655 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
655 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
656 | 656 | //$data['callsign'] = trim(substr($line,100,7); |
657 | 657 | //$data['dest'] = substr($line,108,20); |
658 | 658 | //$data['etaDate'] = substr($line,129,5); |
@@ -685,8 +685,8 @@ discard block |
||
685 | 685 | ) { |
686 | 686 | //$buffer = $Common->getData($hosts[$id]); |
687 | 687 | $buffer = $Common->getData($value['host']); |
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
688 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
689 | + $buffer = explode('\n', $buffer); |
|
690 | 690 | $reset = 0; |
691 | 691 | foreach ($buffer as $line) { |
692 | 692 | if ($line != '') { |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
698 | 698 | $data['pilot_id'] = $line[1]; |
699 | 699 | $data['pilot_name'] = $line[2]; |
700 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
700 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
701 | 701 | $data['ident'] = $line[0]; // ident |
702 | 702 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
703 | 703 | $data['speed'] = $line[8]; // speed |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
714 | 714 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
715 | 715 | $data['departure_airport_icao'] = $line[11]; |
716 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
716 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
717 | 717 | $data['arrival_airport_icao'] = $line[13]; |
718 | 718 | $data['frequency'] = $line[4]; |
719 | 719 | $data['type'] = $line[18]; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | $data['id_source'] = $id_source; |
723 | 723 | //$data['arrival_airport_time'] = ; |
724 | 724 | if ($line[9] != '') { |
725 | - $aircraft_data = explode('/',$line[9]); |
|
725 | + $aircraft_data = explode('/', $line[9]); |
|
726 | 726 | if (isset($aircraft_data[1])) { |
727 | 727 | $data['aircraft_icao'] = $aircraft_data[1]; |
728 | 728 | } |
@@ -737,9 +737,9 @@ discard block |
||
737 | 737 | if ($line[3] == 'PILOT') $SI->add($data); |
738 | 738 | elseif ($line[3] == 'ATC') { |
739 | 739 | //print_r($data); |
740 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
741 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
742 | - $typec = substr($data['ident'],-3); |
|
740 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
741 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
742 | + $typec = substr($data['ident'], -3); |
|
743 | 743 | if ($typec == 'APP') $data['type'] = 'Approach'; |
744 | 744 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
745 | 745 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -751,8 +751,8 @@ discard block |
||
751 | 751 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
752 | 752 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
753 | 753 | if (isset($ATC)) { |
754 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
755 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
754 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
755 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | unset($data); |
@@ -768,24 +768,24 @@ discard block |
||
768 | 768 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
769 | 769 | ) |
770 | 770 | ) { |
771 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
771 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
772 | 772 | if ($buffer != '') { |
773 | 773 | $all_data = simplexml_load_string($buffer); |
774 | - foreach($all_data->children() as $childdata) { |
|
774 | + foreach ($all_data->children() as $childdata) { |
|
775 | 775 | $data = array(); |
776 | 776 | $line = $childdata; |
777 | 777 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
778 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
779 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
780 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
781 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
782 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
783 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
784 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
778 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
779 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
780 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
781 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
782 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
783 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
784 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
785 | 785 | $data['altitude_relative'] = 'AMSL'; |
786 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
786 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
787 | 787 | $data['aircraft_icao'] = 'PARAGLIDER'; |
788 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
788 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
789 | 789 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
790 | 790 | $data['format_source'] = $value['format']; |
791 | 791 | $SI->add($data); |
@@ -793,22 +793,22 @@ discard block |
||
793 | 793 | } |
794 | 794 | } |
795 | 795 | $Source->deleteOldLocationByType('gs'); |
796 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
796 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
797 | 797 | if ($buffer != '') { |
798 | 798 | $all_data = simplexml_load_string($buffer); |
799 | - foreach($all_data->children() as $childdata) { |
|
799 | + foreach ($all_data->children() as $childdata) { |
|
800 | 800 | $data = array(); |
801 | 801 | $line = $childdata; |
802 | - $data['id'] = (int)$line['gsID']; |
|
803 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
804 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
805 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
802 | + $data['id'] = (int) $line['gsID']; |
|
803 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
804 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
805 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
806 | 806 | $data['altitude_relative'] = 'AMSL'; |
807 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
807 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
808 | 808 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
809 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
809 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
810 | 810 | } else { |
811 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
811 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
812 | 812 | } |
813 | 813 | unset($data); |
814 | 814 | } |
@@ -826,9 +826,9 @@ discard block |
||
826 | 826 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
827 | 827 | ) |
828 | 828 | ) { |
829 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
829 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
830 | 830 | if ($buffer != '') { |
831 | - $all_data = json_decode($buffer,true); |
|
831 | + $all_data = json_decode($buffer, true); |
|
832 | 832 | if (isset($all_data['acList'])) { |
833 | 833 | $reset = 0; |
834 | 834 | foreach ($all_data['acList'] as $line) { |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
845 | 845 | $data['emergency'] = ''; // emergency |
846 | 846 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
847 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
847 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
848 | 848 | else $data['datetime'] = date('Y-m-d H:i:s'); |
849 | 849 | //$data['datetime'] = date('Y-m-d H:i:s'); |
850 | 850 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | $data['verticalrate'] = $line['vrt']; // verticale rate |
870 | 870 | $data['squawk'] = $line['squawk']; // squawk |
871 | 871 | $data['emergency'] = ''; // emergency |
872 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
872 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
873 | 873 | else $data['datetime'] = date('Y-m-d H:i:s'); |
874 | 874 | $data['format_source'] = 'aircraftlistjson'; |
875 | 875 | $data['id_source'] = $id_source; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | ) |
891 | 891 | ) { |
892 | 892 | $buffer = $Common->getData($value['host']); |
893 | - $all_data = json_decode($buffer,true); |
|
893 | + $all_data = json_decode($buffer, true); |
|
894 | 894 | if (isset($all_data['planes'])) { |
895 | 895 | $reset = 0; |
896 | 896 | foreach ($all_data['planes'] as $key => $line) { |
@@ -907,12 +907,12 @@ discard block |
||
907 | 907 | $data['emergency'] = ''; // emergency |
908 | 908 | $data['registration'] = $line[2]; |
909 | 909 | $data['aircraft_icao'] = $line[0]; |
910 | - $deparr = explode('-',$line[1]); |
|
910 | + $deparr = explode('-', $line[1]); |
|
911 | 911 | if (count($deparr) == 2) { |
912 | 912 | $data['departure_airport_icao'] = $deparr[0]; |
913 | 913 | $data['arrival_airport_icao'] = $deparr[1]; |
914 | 914 | } |
915 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
915 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
916 | 916 | $data['format_source'] = 'planeupdatefaa'; |
917 | 917 | $data['id_source'] = $id_source; |
918 | 918 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | ) |
931 | 931 | ) { |
932 | 932 | $buffer = $Common->getData($value['host']); |
933 | - $all_data = json_decode($buffer,true); |
|
933 | + $all_data = json_decode($buffer, true); |
|
934 | 934 | if (isset($all_data['states'])) { |
935 | 935 | $reset = 0; |
936 | 936 | foreach ($all_data['states'] as $key => $line) { |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | //$data['emergency'] = ''; // emergency |
948 | 948 | //$data['registration'] = $line[2]; |
949 | 949 | //$data['aircraft_icao'] = $line[0]; |
950 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
950 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
951 | 951 | $data['format_source'] = 'opensky'; |
952 | 952 | $data['id_source'] = $id_source; |
953 | 953 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | ) { |
967 | 967 | //$buffer = $Common->getData($hosts[$id]); |
968 | 968 | $buffer = $Common->getData($value['host']); |
969 | - $all_data = json_decode($buffer,true); |
|
969 | + $all_data = json_decode($buffer, true); |
|
970 | 970 | if (!empty($all_data)) $reset = 0; |
971 | 971 | foreach ($all_data as $key => $line) { |
972 | 972 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1004,11 +1004,11 @@ discard block |
||
1004 | 1004 | ) |
1005 | 1005 | ) { |
1006 | 1006 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1007 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1007 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1008 | 1008 | //echo $buffer; |
1009 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1010 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1011 | - $all_data = json_decode($buffer,true); |
|
1009 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1010 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1011 | + $all_data = json_decode($buffer, true); |
|
1012 | 1012 | if (json_last_error() != JSON_ERROR_NONE) { |
1013 | 1013 | die(json_last_error_msg()); |
1014 | 1014 | } |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | //$data['departure_airport_iata'] = $line[11]; |
1032 | 1032 | //$data['arrival_airport_iata'] = $line[12]; |
1033 | 1033 | //$data['emergency'] = ''; // emergency |
1034 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1034 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1035 | 1035 | $data['format_source'] = 'radarvirtueljson'; |
1036 | 1036 | $data['id_source'] = $id_source; |
1037 | 1037 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1052,14 +1052,14 @@ discard block |
||
1052 | 1052 | ) { |
1053 | 1053 | //$buffer = $Common->getData($hosts[$id]); |
1054 | 1054 | $buffer = $Common->getData($value['host'].'?'.time()); |
1055 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1055 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1056 | 1056 | |
1057 | 1057 | if (isset($all_data['pireps'])) { |
1058 | 1058 | $reset = 0; |
1059 | 1059 | foreach ($all_data['pireps'] as $line) { |
1060 | 1060 | $data = array(); |
1061 | 1061 | $data['id'] = $line['id']; |
1062 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1062 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1063 | 1063 | $data['ident'] = $line['callsign']; // ident |
1064 | 1064 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1065 | 1065 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1089,9 +1089,9 @@ discard block |
||
1089 | 1089 | $SI->add($data); |
1090 | 1090 | // print_r($data); |
1091 | 1091 | } elseif ($line['icon'] == 'ct') { |
1092 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1093 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1094 | - $typec = substr($data['ident'],-3); |
|
1092 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1093 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1094 | + $typec = substr($data['ident'], -3); |
|
1095 | 1095 | $data['type'] = ''; |
1096 | 1096 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1097 | 1097 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1103 | 1103 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1104 | 1104 | else $data['type'] = 'Observer'; |
1105 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1105 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
1106 | 1106 | } |
1107 | 1107 | unset($data); |
1108 | 1108 | } |
@@ -1119,14 +1119,14 @@ discard block |
||
1119 | 1119 | //$buffer = $Common->getData($hosts[$id]); |
1120 | 1120 | if ($globalDebug) echo 'Get Data...'."\n"; |
1121 | 1121 | $buffer = $Common->getData($value['host']); |
1122 | - $all_data = json_decode($buffer,true); |
|
1122 | + $all_data = json_decode($buffer, true); |
|
1123 | 1123 | if ($buffer != '' && is_array($all_data)) { |
1124 | 1124 | $reset = 0; |
1125 | 1125 | foreach ($all_data as $line) { |
1126 | 1126 | $data = array(); |
1127 | 1127 | //$data['id'] = $line['id']; // id not usable |
1128 | 1128 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1129 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1129 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1130 | 1130 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1131 | 1131 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1132 | 1132 | $data['ident'] = $line['flightnum']; // ident |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | //$data['datetime'] = $line['lastupdate']; |
1142 | 1142 | //$data['last_update'] = $line['lastupdate']; |
1143 | 1143 | if (isset($value['timezone'])) { |
1144 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1144 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1145 | 1145 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1146 | 1146 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1147 | 1147 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1154,14 +1154,14 @@ discard block |
||
1154 | 1154 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1155 | 1155 | if (isset($line['aircraftname'])) { |
1156 | 1156 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1157 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1158 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1157 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1158 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1159 | 1159 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1160 | 1160 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1161 | 1161 | else { |
1162 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1162 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1163 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1164 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1165 | 1165 | } |
1166 | 1166 | } |
1167 | 1167 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1186,14 +1186,14 @@ discard block |
||
1186 | 1186 | //$buffer = $Common->getData($hosts[$id]); |
1187 | 1187 | if ($globalDebug) echo 'Get Data...'."\n"; |
1188 | 1188 | $buffer = $Common->getData($value['host']); |
1189 | - $all_data = json_decode($buffer,true); |
|
1189 | + $all_data = json_decode($buffer, true); |
|
1190 | 1190 | if ($buffer != '' && is_array($all_data)) { |
1191 | 1191 | $reset = 0; |
1192 | 1192 | foreach ($all_data as $line) { |
1193 | 1193 | $data = array(); |
1194 | 1194 | //$data['id'] = $line['id']; // id not usable |
1195 | 1195 | $data['id'] = trim($line['flight_id']); |
1196 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1196 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1197 | 1197 | $data['pilot_name'] = $line['pilot_name']; |
1198 | 1198 | $data['pilot_id'] = $line['pilot_id']; |
1199 | 1199 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1237,24 +1237,24 @@ discard block |
||
1237 | 1237 | //$buffer = $Common->getData($hosts[$id]); |
1238 | 1238 | if ($globalDebug) echo 'Get Data...'."\n"; |
1239 | 1239 | $buffer = $Common->getData($value['host']); |
1240 | - $all_data = json_decode($buffer,true); |
|
1240 | + $all_data = json_decode($buffer, true); |
|
1241 | 1241 | if ($buffer != '') { |
1242 | 1242 | $Source->deleteLocationBySource('blitzortung'); |
1243 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1244 | - $buffer = explode('\n',$buffer); |
|
1243 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1244 | + $buffer = explode('\n', $buffer); |
|
1245 | 1245 | foreach ($buffer as $buffer_line) { |
1246 | - $line = json_decode($buffer_line,true); |
|
1246 | + $line = json_decode($buffer_line, true); |
|
1247 | 1247 | if (isset($line['time'])) { |
1248 | 1248 | $data = array(); |
1249 | 1249 | $data['altitude'] = $line['alt']; // altitude |
1250 | 1250 | $data['latitude'] = $line['lat']; // lat |
1251 | 1251 | $data['longitude'] = $line['lon']; // long |
1252 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1252 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1253 | 1253 | $data['id_source'] = $id_source; |
1254 | 1254 | $data['format_source'] = 'blitzortung'; |
1255 | 1255 | $SI->add($data); |
1256 | 1256 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1257 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1257 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1258 | 1258 | unset($data); |
1259 | 1259 | } |
1260 | 1260 | } |
@@ -1279,11 +1279,11 @@ discard block |
||
1279 | 1279 | //$value = $formats[$nb]; |
1280 | 1280 | $format = $globalSources[$nb]['format']; |
1281 | 1281 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1282 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1282 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1283 | 1283 | } elseif ($format == 'vrstcp') { |
1284 | 1284 | $buffer = @socket_read($r, 6000); |
1285 | 1285 | } else { |
1286 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1286 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1287 | 1287 | } |
1288 | 1288 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1289 | 1289 | //echo $buffer."\n"; |
@@ -1292,8 +1292,8 @@ discard block |
||
1292 | 1292 | $error = false; |
1293 | 1293 | //$SI::del(); |
1294 | 1294 | if ($format == 'vrstcp') { |
1295 | - $buffer = explode('},{',$buffer); |
|
1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1295 | + $buffer = explode('},{', $buffer); |
|
1296 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1297 | 1297 | // SBS format is CSV format |
1298 | 1298 | if ($buffer !== FALSE && $buffer != '') { |
1299 | 1299 | $tt[$format] = 0; |
@@ -1327,13 +1327,13 @@ discard block |
||
1327 | 1327 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1328 | 1328 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1329 | 1329 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1330 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1331 | 1331 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1332 | 1332 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1333 | 1333 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1334 | 1334 | |
1335 | 1335 | if (isset($ais_data['timestamp'])) { |
1336 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1336 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1337 | 1337 | } else { |
1338 | 1338 | $data['datetime'] = date('Y-m-d H:i:s'); |
1339 | 1339 | } |
@@ -1344,10 +1344,10 @@ discard block |
||
1344 | 1344 | } elseif ($format == 'flightgearsp') { |
1345 | 1345 | //echo $buffer."\n"; |
1346 | 1346 | if (strlen($buffer) > 5) { |
1347 | - $line = explode(',',$buffer); |
|
1347 | + $line = explode(',', $buffer); |
|
1348 | 1348 | $data = array(); |
1349 | 1349 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1350 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1350 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1351 | 1351 | $data['ident'] = $line[6]; |
1352 | 1352 | $data['aircraft_name'] = $line[7]; |
1353 | 1353 | $data['longitude'] = $line[1]; |
@@ -1364,16 +1364,16 @@ discard block |
||
1364 | 1364 | } elseif ($format == 'acars') { |
1365 | 1365 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1366 | 1366 | $ACARS->add(trim($buffer)); |
1367 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1367 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1368 | 1368 | $ACARS->deleteLiveAcarsData(); |
1369 | 1369 | } elseif ($format == 'flightgearmp') { |
1370 | - if (substr($buffer,0,1) != '#') { |
|
1370 | + if (substr($buffer, 0, 1) != '#') { |
|
1371 | 1371 | $data = array(); |
1372 | 1372 | //echo $buffer."\n"; |
1373 | - $line = explode(' ',$buffer); |
|
1373 | + $line = explode(' ', $buffer); |
|
1374 | 1374 | if (count($line) == 11) { |
1375 | - $userserver = explode('@',$line[0]); |
|
1376 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1375 | + $userserver = explode('@', $line[0]); |
|
1376 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1377 | 1377 | $data['ident'] = $userserver[0]; |
1378 | 1378 | $data['registration'] = $userserver[0]; |
1379 | 1379 | $data['latitude'] = $line[4]; |
@@ -1381,8 +1381,8 @@ discard block |
||
1381 | 1381 | $data['altitude'] = $line[6]; |
1382 | 1382 | $data['datetime'] = date('Y-m-d H:i:s'); |
1383 | 1383 | $aircraft_type = $line[10]; |
1384 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1385 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1384 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1385 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1386 | 1386 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1387 | 1387 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1388 | 1388 | } |
@@ -1391,8 +1391,8 @@ discard block |
||
1391 | 1391 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1392 | 1392 | die; |
1393 | 1393 | } elseif ($format == 'vrstcp') { |
1394 | - foreach($buffer as $all_data) { |
|
1395 | - $line = json_decode('{'.$all_data.'}',true); |
|
1394 | + foreach ($buffer as $all_data) { |
|
1395 | + $line = json_decode('{'.$all_data.'}', true); |
|
1396 | 1396 | $data = array(); |
1397 | 1397 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1398 | 1398 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1418,16 +1418,16 @@ discard block |
||
1418 | 1418 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1419 | 1419 | unset($data); |
1420 | 1420 | } |
1421 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1421 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1422 | 1422 | $line = explode("\t", $buffer); |
1423 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1423 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1424 | 1424 | $key = $line[$k]; |
1425 | - $lined[$key] = $line[$k+1]; |
|
1425 | + $lined[$key] = $line[$k + 1]; |
|
1426 | 1426 | } |
1427 | 1427 | if (count($lined) > 3) { |
1428 | 1428 | $data['hex'] = $lined['hexid']; |
1429 | 1429 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1430 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1430 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1431 | 1431 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1432 | 1432 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1433 | 1433 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1446,22 +1446,22 @@ discard block |
||
1446 | 1446 | } else $error = true; |
1447 | 1447 | } elseif ($format == 'aprs' && $use_aprs) { |
1448 | 1448 | if ($aprs_connect == 0) { |
1449 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1449 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1450 | 1450 | $aprs_connect = 1; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1453 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1454 | 1454 | $aprs_last_tx = time(); |
1455 | 1455 | $data_aprs = "# Keep alive"; |
1456 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1456 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1460 | 1460 | //echo 'APRS data : '.$buffer."\n"; |
1461 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1462 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1461 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1462 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1463 | 1463 | //echo $buffer."\n"; |
1464 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1464 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1465 | 1465 | $line = $APRS->parse($buffer); |
1466 | 1466 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1467 | 1467 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1477 | 1477 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1478 | 1478 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1479 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1480 | 1480 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1481 | 1481 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1482 | 1482 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1555,29 +1555,29 @@ discard block |
||
1555 | 1555 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1556 | 1556 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1557 | 1557 | $Source->deleteOldLocationByType('gs'); |
1558 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1559 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1558 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1559 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1560 | 1560 | } else { |
1561 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1561 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1562 | 1562 | } |
1563 | 1563 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1564 | 1564 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1565 | 1565 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1566 | 1566 | $Source->deleteOldLocationByType('wx'); |
1567 | 1567 | $weather_data = json_encode($line); |
1568 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1569 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1568 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1569 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1570 | 1570 | } else { |
1571 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1571 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1572 | 1572 | } |
1573 | 1573 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
1574 | 1574 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1575 | 1575 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1576 | 1576 | $Source->deleteOldLocationByType('lightning'); |
1577 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1578 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1577 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1578 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1579 | 1579 | } else { |
1580 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1580 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1581 | 1581 | } |
1582 | 1582 | } elseif ($globalDebug) { |
1583 | 1583 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | unset($data); |
1587 | 1587 | } |
1588 | 1588 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1589 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1589 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1590 | 1590 | } |
1591 | 1591 | /* |
1592 | 1592 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
@@ -1595,7 +1595,7 @@ discard block |
||
1595 | 1595 | */ |
1596 | 1596 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1597 | 1597 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1598 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1598 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1599 | 1599 | $Source->deleteOldLocationByType('lightning'); |
1600 | 1600 | $Source->deleteOldLocationByType('wx'); |
1601 | 1601 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | connect_all($sourceee); |
1681 | 1681 | $sourceee = array(); |
1682 | 1682 | //connect_all($globalSources); |
1683 | - $tt[$format]=0; |
|
1683 | + $tt[$format] = 0; |
|
1684 | 1684 | break; |
1685 | 1685 | } |
1686 | 1686 | } |
@@ -1689,14 +1689,14 @@ discard block |
||
1689 | 1689 | } else { |
1690 | 1690 | $error = socket_strerror(socket_last_error()); |
1691 | 1691 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1692 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1692 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1693 | 1693 | if (isset($globalDebug)) echo "Restarting...\n"; |
1694 | 1694 | // Restart the script if possible |
1695 | 1695 | if (is_array($sockets)) { |
1696 | 1696 | if ($globalDebug) echo "Shutdown all sockets..."; |
1697 | 1697 | |
1698 | 1698 | foreach ($sockets as $sock) { |
1699 | - @socket_shutdown($sock,2); |
|
1699 | + @socket_shutdown($sock, 2); |
|
1700 | 1700 | @socket_close($sock); |
1701 | 1701 | } |
1702 | 1702 |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
37 | + foreach ($sourcestat as $srcst) { |
|
38 | 38 | $type = $srcst['stats_type']; |
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | 40 | $source = $srcst['source_name']; |
41 | 41 | $data = $srcst['source_data']; |
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | - } catch(Exception $e) { |
|
54 | + } catch (Exception $e) { |
|
55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id, $ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | 88 | // Should also check if route schedule = route from DB |
89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
107 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
108 | 108 | } |
109 | 109 | } else $scheduleexist = true; |
110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($scheduleexist) { |
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | 114 | $sch = $Schedule->getSchedule($operator); |
115 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116 | 116 | } |
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 140 | $Spotter = new Spotter($this->db); |
141 | 141 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $airport_time = ''; |
154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157 | 157 | if (isset($closestAirports[0])) { |
158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
183 | 183 | } |
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | 194 | if (isset($flight['lastupdate'])) { |
195 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
195 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
196 | 196 | $this->delKey($key); |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $real_arrival = $this->arrival($key); |
209 | 209 | $Spotter = new Spotter($this->db); |
210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
211 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
213 | 213 | } |
214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $send = false; |
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245 | 245 | //print_r($line); |
246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
247 | 247 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
279 | 279 | $this->all_flights[$id] = array(); |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283 | 283 | if (!isset($line['id'])) { |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
287 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,27 +304,27 @@ discard block |
||
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308 | 308 | } else { |
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 310 | } |
311 | 311 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
318 | 318 | } |
319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321 | 321 | } |
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | $Spotter = new Spotter($this->db); |
325 | 325 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
326 | 326 | $Spotter->db = null; |
327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
328 | 328 | } |
329 | 329 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
330 | 330 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $Spotter = new Spotter($this->db); |
333 | 333 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
334 | 334 | $Spotter->db = null; |
335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
335 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
341 | 341 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
342 | 342 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
343 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
344 | 344 | } |
345 | 345 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
346 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
346 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
347 | 347 | } |
348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
349 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
349 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
350 | 350 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
352 | 352 | } else { |
353 | 353 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
354 | 354 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -359,31 +359,31 @@ discard block |
||
359 | 359 | */ |
360 | 360 | return ''; |
361 | 361 | } |
362 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
362 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
364 | 364 | return ''; |
365 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
365 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
366 | 366 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
367 | 367 | return ''; |
368 | 368 | } elseif (!isset($line['datetime'])) { |
369 | 369 | date_default_timezone_set('UTC'); |
370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | 371 | } else { |
372 | 372 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
373 | 373 | return ''; |
374 | 374 | } |
375 | 375 | |
376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
378 | 378 | } |
379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
381 | 381 | } |
382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
384 | 384 | } |
385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
395 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
396 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
398 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
396 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
397 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
398 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
399 | 399 | } else { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
401 | 401 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
402 | 402 | $timeelapsed = microtime(true); |
403 | 403 | $Spotter = new Spotter($this->db); |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
412 | 412 | $Spotter->db = null; |
413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
413 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
414 | 414 | } |
415 | 415 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
417 | 417 | |
418 | 418 | /* |
419 | 419 | if (!isset($line['id'])) { |
@@ -423,25 +423,25 @@ discard block |
||
423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 425 | */ |
426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
426 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
427 | 427 | |
428 | 428 | //$putinarchive = true; |
429 | 429 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
430 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
431 | 431 | } |
432 | 432 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
433 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
433 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
434 | 434 | } |
435 | 435 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
437 | 437 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
438 | 438 | $timeelapsed = microtime(true); |
439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 440 | $Spotter = new Spotter($this->db); |
441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
445 | 445 | } |
446 | 446 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
447 | 447 | $timeelapsed = microtime(true); |
@@ -455,35 +455,35 @@ discard block |
||
455 | 455 | $Translation->db = null; |
456 | 456 | } |
457 | 457 | $Spotter->db = null; |
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
459 | 459 | } |
460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | 461 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
462 | 462 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
469 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
478 | 478 | //$dataFound = true; |
479 | 479 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
480 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
481 | 481 | if ($distance > 1000 && $distance < 10000) { |
482 | 482 | // use datetime |
483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
484 | 484 | $speed = $speed*3.6; |
485 | 485 | if ($speed < 1000) { |
486 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
486 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
487 | 487 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
488 | 488 | } else { |
489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
499 | 499 | return false; |
500 | 500 | } |
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
502 | 502 | else unset($timediff); |
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
504 | 504 | else unset($timediff_archive); |
505 | 505 | if ($this->tmd > 5 |
506 | 506 | || (isset($line['format_source']) |
@@ -524,14 +524,14 @@ discard block |
||
524 | 524 | || ($timediff > 30 |
525 | 525 | && isset($this->all_flights[$id]['latitude']) |
526 | 526 | && isset($this->all_flights[$id]['longitude']) |
527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
527 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
528 | 528 | ) |
529 | 529 | ) { |
530 | 530 | |
531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
532 | 532 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
534 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
534 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
536 | 536 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | $timeelapsed = microtime(true); |
542 | 542 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
543 | 543 | $Spotter = new Spotter($this->db); |
544 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
544 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
546 | 546 | else $this->all_flights[$id]['over_country'] = ''; |
547 | 547 | $Spotter->db = null; |
548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
548 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
550 | 550 | } |
551 | 551 | } |
@@ -571,13 +571,13 @@ discard block |
||
571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
572 | 572 | } |
573 | 573 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
574 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
574 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
575 | 575 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
576 | 576 | $dataFound = true; |
577 | 577 | $this->all_flights[$id]['time_last_coord'] = time(); |
578 | 578 | } |
579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
580 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
580 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
581 | 581 | /* |
582 | 582 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
583 | 583 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -599,13 +599,13 @@ discard block |
||
599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
600 | 600 | } |
601 | 601 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
602 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
602 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
603 | 603 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
604 | 604 | $dataFound = true; |
605 | 605 | $this->all_flights[$id]['time_last_coord'] = time(); |
606 | 606 | } |
607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
609 | 609 | /* |
610 | 610 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
611 | 611 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -623,46 +623,46 @@ discard block |
||
623 | 623 | } else if ($globalDebug && $timediff > 30) { |
624 | 624 | $this->tmd = $this->tmd + 1; |
625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
626 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
627 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
626 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
627 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
629 | 629 | } |
630 | 630 | } |
631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | 632 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
634 | 634 | } |
635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
637 | 637 | //$dataFound = true; |
638 | 638 | } |
639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
641 | 641 | } |
642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
647 | 647 | //$dataFound = true; |
648 | 648 | } |
649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
650 | 650 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
653 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
654 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
653 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
654 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
656 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
657 | 657 | } |
658 | 658 | if ($line['ground'] != 1) $line['ground'] = 0; |
659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
660 | 660 | //$dataFound = true; |
661 | 661 | } |
662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | 663 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
664 | 664 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
666 | 666 | $highlight = ''; |
667 | 667 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
668 | 668 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -671,66 +671,66 @@ discard block |
||
671 | 671 | $timeelapsed = microtime(true); |
672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | 673 | $Spotter = new Spotter($this->db); |
674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
675 | 675 | $Spotter->db = null; |
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
677 | 677 | } |
678 | 678 | //$putinarchive = true; |
679 | 679 | //$highlight = ''; |
680 | 680 | } |
681 | 681 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
683 | 683 | //$dataFound = true; |
684 | 684 | } |
685 | 685 | |
686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
687 | 687 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
688 | 688 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
689 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
689 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
690 | 690 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
691 | 691 | $line['altitude'] = $line['altitude'] - $geoid; |
692 | 692 | } |
693 | 693 | } |
694 | 694 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
695 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
698 | 698 | //$dataFound = true; |
699 | 699 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
700 | 700 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
703 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
705 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
707 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
703 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
705 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
706 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
707 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
708 | 708 | } |
709 | 709 | } |
710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
721 | 721 | //$dataFound = true; |
722 | 722 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
723 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
723 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
725 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | 726 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | 728 | // If not enough messages and ACARS set heading to 0 |
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
730 | 730 | } |
731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
731 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
734 | 734 | |
735 | 735 | // print_r($this->all_flights[$id]); |
736 | 736 | //gets the callsign from the last hour |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
742 | 742 | $this->all_flights[$id]['lastupdate'] = time(); |
743 | 743 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
744 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
744 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
745 | 745 | //print_r($this->all_flights); |
746 | 746 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
747 | 747 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -752,61 +752,61 @@ discard block |
||
752 | 752 | $SpotterLive = new SpotterLive($this->db); |
753 | 753 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
755 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
756 | 756 | } elseif (isset($line['id'])) { |
757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
758 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
759 | 759 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
761 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
762 | 762 | } else $recent_ident = ''; |
763 | - $SpotterLive->db=null; |
|
763 | + $SpotterLive->db = null; |
|
764 | 764 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
765 | 765 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
766 | 766 | } else $recent_ident = ''; |
767 | 767 | } else { |
768 | 768 | $recent_ident = ''; |
769 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
769 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
770 | 770 | } |
771 | 771 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
772 | - if($recent_ident == "") |
|
772 | + if ($recent_ident == "") |
|
773 | 773 | { |
774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 777 | //adds the spotter data for the archive |
778 | 778 | $ignoreImport = false; |
779 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
779 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
780 | 780 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
781 | 781 | $ignoreImport = true; |
782 | 782 | } |
783 | 783 | } |
784 | 784 | if (count($globalAirportAccept) > 0) { |
785 | 785 | $ignoreImport = true; |
786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
786 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
788 | 788 | $ignoreImport = false; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | } |
792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
794 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
793 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
794 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
795 | 795 | $ignoreImport = true; |
796 | 796 | } |
797 | 797 | } |
798 | 798 | } |
799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
800 | 800 | $ignoreImport = true; |
801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
801 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
802 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
803 | 803 | $ignoreImport = false; |
804 | 804 | } |
805 | 805 | } |
806 | 806 | } |
807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
808 | 808 | $ignoreImport = true; |
809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
809 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
811 | 811 | $ignoreImport = false; |
812 | 812 | } |
@@ -818,32 +818,32 @@ discard block |
||
818 | 818 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
819 | 819 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
820 | 820 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
821 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
822 | 822 | $timeelapsed = microtime(true); |
823 | 823 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | 825 | $Spotter = new Spotter($this->db); |
826 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
826 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
827 | 827 | $Spotter->db = null; |
828 | 828 | if ($globalDebug && isset($result)) echo $result."\n"; |
829 | 829 | } |
830 | 830 | } |
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
832 | 832 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
833 | 833 | |
834 | 834 | // Add source stat in DB |
835 | 835 | $Stats = new Stats($this->db); |
836 | 836 | if (!empty($this->stats)) { |
837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
838 | - foreach($this->stats as $date => $data) { |
|
839 | - foreach($data as $source => $sourced) { |
|
838 | + foreach ($this->stats as $date => $data) { |
|
839 | + foreach ($data as $source => $sourced) { |
|
840 | 840 | //print_r($sourced); |
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
843 | 843 | if (isset($sourced['msg'])) { |
844 | 844 | if (time() - $sourced['msg']['date'] > 10) { |
845 | 845 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
846 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
847 | 847 | unset($this->stats[$date][$source]['msg']); |
848 | 848 | } |
849 | 849 | } |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
882 | 882 | $SpotterLive = new SpotterLive($this->db); |
883 | 883 | $SpotterLive->deleteLiveSpotterData(); |
884 | - $SpotterLive->db=null; |
|
884 | + $SpotterLive->db = null; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | if ($globalDebug) echo " Done\n"; |
888 | 888 | $this->last_delete = time(); |
889 | 889 | } |
890 | 890 | } else { |
891 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
891 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
892 | 892 | $this->all_flights[$id]['id'] = $recent_ident; |
893 | 893 | $this->all_flights[$id]['addedSpotter'] = 1; |
894 | 894 | } |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
898 | 898 | $Spotter = new Spotter($this->db); |
899 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
899 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
900 | 900 | $Spotter->db = null; |
901 | 901 | } |
902 | 902 | } |
@@ -922,37 +922,37 @@ discard block |
||
922 | 922 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
923 | 923 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
924 | 924 | |
925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
925 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
926 | 926 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
927 | 927 | $ignoreImport = true; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | if (count($globalAirportAccept) > 0) { |
931 | 931 | $ignoreImport = true; |
932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
932 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
933 | 933 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
934 | 934 | $ignoreImport = false; |
935 | 935 | } |
936 | 936 | } |
937 | 937 | } |
938 | 938 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
939 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
940 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
939 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
940 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
941 | 941 | $ignoreImport = true; |
942 | 942 | } |
943 | 943 | } |
944 | 944 | } |
945 | 945 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
946 | 946 | $ignoreImport = true; |
947 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
948 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
947 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
948 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
949 | 949 | $ignoreImport = false; |
950 | 950 | } |
951 | 951 | } |
952 | 952 | } |
953 | 953 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
954 | 954 | $ignoreImport = true; |
955 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
955 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
956 | 956 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
957 | 957 | $ignoreImport = false; |
958 | 958 | } |
@@ -960,23 +960,23 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | if (!$ignoreImport) { |
963 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
964 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
963 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
964 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
965 | 965 | $timeelapsed = microtime(true); |
966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | 967 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
969 | 969 | $SpotterLive = new SpotterLive($this->db); |
970 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
970 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
971 | 971 | $SpotterLive->db = null; |
972 | 972 | if ($globalDebug) echo $result."\n"; |
973 | 973 | } |
974 | 974 | } |
975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
976 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
977 | 977 | } |
978 | 978 | $this->all_flights[$id]['putinarchive'] = false; |
979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
979 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
980 | 980 | |
981 | 981 | // Put statistics in $this->stats variable |
982 | 982 | //if ($line['format_source'] != 'aprs') { |
@@ -995,19 +995,19 @@ discard block |
||
995 | 995 | $latitude = $globalCenterLatitude; |
996 | 996 | $longitude = $globalCenterLongitude; |
997 | 997 | } |
998 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
998 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
999 | 999 | } else { |
1000 | 1000 | $latitude = $this->source_location[$source]['latitude']; |
1001 | 1001 | $longitude = $this->source_location[$source]['longitude']; |
1002 | 1002 | } |
1003 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1003 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1004 | 1004 | //$stats_heading = $stats_heading%22.5; |
1005 | 1005 | $stats_heading = round($stats_heading/22.5); |
1006 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1006 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1007 | 1007 | $current_date = date('Y-m-d'); |
1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | - for ($i=0;$i<=15;$i++) { |
|
1010 | + for ($i = 0; $i <= 15; $i++) { |
|
1011 | 1011 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1012 | 1012 | } |
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1022,9 +1022,9 @@ discard block |
||
1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | 1024 | end($this->stats[$current_date][$source]['hist']); |
1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1025 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1026 | 1026 | } else $mini = 0; |
1027 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1027 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1028 | 1028 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1029 | 1029 | } |
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
1038 | 1038 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1039 | 1039 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1040 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1040 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1041 | 1041 | //$this->del(); |
1042 | 1042 | |
1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public $db; |
11 | 11 | public $SI; |
12 | 12 | private $fromACARSscript = false; |
13 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
13 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
14 | 14 | $Connection = new Connection($dbc); |
15 | 15 | $this->db = $Connection->db(); |
16 | 16 | if ($this->db === null) die('Error: No DB connection.'); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * @return String the icao |
27 | 27 | */ |
28 | 28 | public function ident2icao($ident) { |
29 | - if (substr($ident,0,2) == 'AF') { |
|
30 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
29 | + if (substr($ident, 0, 2) == 'AF') { |
|
30 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
32 | 32 | } else { |
33 | 33 | $Spotter = new Spotter($this->db); |
34 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
34 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
35 | 35 | if (isset($identicao[0])) { |
36 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
36 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
37 | 37 | } else $icao = $ident; |
38 | 38 | } |
39 | 39 | return $icao; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $sth = $this->db->prepare($query); |
59 | 59 | $sth->execute(); |
60 | - } catch(PDOException $e) { |
|
60 | + } catch (PDOException $e) { |
|
61 | 61 | return "error"; |
62 | 62 | } |
63 | 63 | return "success"; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $sth = $this->db->prepare($query); |
83 | 83 | $sth->execute(); |
84 | - } catch(PDOException $e) { |
|
84 | + } catch (PDOException $e) { |
|
85 | 85 | return "error"; |
86 | 86 | } |
87 | 87 | return "success"; |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $ident = ''; |
107 | 107 | $message = ''; |
108 | 108 | $result = array(); |
109 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
110 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
111 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
112 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
109 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
110 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
111 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
112 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
113 | 113 | if ($n != 0) { |
114 | - $registration = str_replace('.','',$registration); |
|
115 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
114 | + $registration = str_replace('.', '', $registration); |
|
115 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
116 | 116 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
117 | 117 | } else $message = $data; |
118 | 118 | $decode = array(); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | $temp = ''; |
133 | 133 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
134 | 134 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
135 | - $latitude = $la / 10000.0; |
|
136 | - $longitude = $ln / 10000.0; |
|
135 | + $latitude = $la/10000.0; |
|
136 | + $longitude = $ln/10000.0; |
|
137 | 137 | if ($lac == 'S') $latitude = '-'.$latitude; |
138 | 138 | if ($lnc == 'W') $longitude = '-'.$longitude; |
139 | 139 | // Temp not always available |
140 | 140 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
141 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
141 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
142 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
143 | 143 | |
144 | 144 | //$icao = $Translation->checkTranslation($ident); |
145 | 145 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | $dhour = ''; |
152 | 152 | $darr = ''; |
153 | 153 | $ahour = ''; |
154 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
154 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
155 | 155 | if ($n == 4 && strlen($darr) == 4) { |
156 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
157 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
158 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
156 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
157 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
158 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
159 | 159 | //$icao = ACARS->ident2icao($ident); |
160 | 160 | //$icao = $Translation->checkTranslation($ident); |
161 | 161 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
162 | 162 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
163 | 163 | $found = true; |
164 | 164 | } |
165 | - elseif ($n == 2 || $n == 4) { |
|
166 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
165 | + elseif ($n == 2 || $n == 4) { |
|
166 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
167 | 167 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
168 | 168 | //$icao = ACARS->ident2icao($ident); |
169 | 169 | //$icao = $Translation->checkTranslation($ident); |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | $ahour = ''; |
222 | 222 | $aair = ''; |
223 | 223 | $apiste = ''; |
224 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
224 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
225 | 225 | if ($n > 8) { |
226 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
228 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
226 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
228 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
229 | 229 | $icao = trim($aident); |
230 | 230 | |
231 | 231 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
251 | 251 | $las = $las.'.'.$lass; |
252 | 252 | $lns = $lns.'.'.$lns; |
253 | - $latitude = $las / 1000.0; |
|
254 | - $longitude = $lns / 1000.0; |
|
253 | + $latitude = $las/1000.0; |
|
254 | + $longitude = $lns/1000.0; |
|
255 | 255 | if ($lac == 'S') $latitude = '-'.$latitude; |
256 | 256 | if ($lnc == 'W') $longitude = '-'.$longitude; |
257 | 257 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -346,17 +346,17 @@ discard block |
||
346 | 346 | $alt = ''; |
347 | 347 | $fuel = ''; |
348 | 348 | $speed = ''; |
349 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
349 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
350 | 350 | if ($n == 9) { |
351 | 351 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
352 | 352 | $icao = trim($aident); |
353 | 353 | $decode['icao'] = $icao; |
354 | - $latitude = $las / 100.0; |
|
355 | - $longitude = $lns / 100.0; |
|
354 | + $latitude = $las/100.0; |
|
355 | + $longitude = $lns/100.0; |
|
356 | 356 | if ($lac == 'S') $latitude = '-'.$latitude; |
357 | 357 | if ($lnc == 'W') $longitude = '-'.$longitude; |
358 | 358 | |
359 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
359 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
360 | 360 | $found = true; |
361 | 361 | } |
362 | 362 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | if ($lac == 'S') $latitude = '-'.$latitude; |
376 | 376 | if ($lnc == 'W') $longitude = '-'.$longitude; |
377 | 377 | |
378 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
378 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
379 | 379 | $found = true; |
380 | 380 | } |
381 | 381 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $dair = ''; |
409 | 409 | $darr = ''; |
410 | 410 | $aident = ''; |
411 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
411 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
412 | 412 | if ($n == 8) { |
413 | 413 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
414 | 414 | $icao = trim($aident); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | $dair = ''; |
442 | 442 | $darr = ''; |
443 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
443 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
444 | 444 | if ($n == 3) { |
445 | 445 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
446 | 446 | //$icao = $Translation->checkTranslation($ident); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | $dair = ''; |
457 | 457 | $darr = ''; |
458 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
458 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
459 | 459 | if ($n == 3) { |
460 | 460 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
461 | 461 | //$icao = $Translation->checkTranslation($ident); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | } |
467 | 467 | if (!$found) { |
468 | - $n = sscanf($message,'MET01%4c',$airport); |
|
468 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
469 | 469 | if ($n == 1) { |
470 | 470 | if ($globalDebug) echo 'airport name : '.$airport; |
471 | 471 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -473,241 +473,241 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | if ($label == 'H1') { |
476 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
477 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
476 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
477 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
478 | 478 | } |
479 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
480 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
479 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
480 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
481 | 481 | } |
482 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
483 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
482 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
483 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
484 | 484 | } |
485 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
486 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
485 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
486 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
487 | 487 | } |
488 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
488 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
491 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
494 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
497 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
500 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match(':^#CF:',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
503 | + elseif (preg_match(':^#CF:', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#DF:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
506 | + elseif (preg_match(':^#DF:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#EC:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
509 | + elseif (preg_match(':^#EC:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#EI:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
512 | + elseif (preg_match(':^#EI:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#H1:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
515 | + elseif (preg_match(':^#H1:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#H2:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
518 | + elseif (preg_match(':^#H2:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#HD:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
521 | + elseif (preg_match(':^#HD:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#M1:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
524 | + elseif (preg_match(':^#M1:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#M2:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
527 | + elseif (preg_match(':^#M2:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#M3:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
530 | + elseif (preg_match(':^#M3:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#MD:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
533 | + elseif (preg_match(':^#MD:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#PS:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
536 | + elseif (preg_match(':^#PS:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#S1:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
539 | + elseif (preg_match(':^#S1:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#S2:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
542 | + elseif (preg_match(':^#S2:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#SD:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
545 | + elseif (preg_match(':^#SD:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
548 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#WO:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
551 | + elseif (preg_match(':^#WO:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#A1:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
554 | + elseif (preg_match(':^#A1:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#A3:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
557 | + elseif (preg_match(':^#A3:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#A4:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
560 | + elseif (preg_match(':^#A4:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#A6:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
563 | + elseif (preg_match(':^#A6:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#A8:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
566 | + elseif (preg_match(':^#A8:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
568 | 568 | } |
569 | - elseif (preg_match(':^#A9:',$message)) { |
|
570 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
569 | + elseif (preg_match(':^#A9:', $message)) { |
|
570 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
571 | 571 | } |
572 | - elseif (preg_match(':^#A0:',$message)) { |
|
573 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
572 | + elseif (preg_match(':^#A0:', $message)) { |
|
573 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
574 | 574 | } |
575 | - elseif (preg_match(':^#AA:',$message)) { |
|
576 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
575 | + elseif (preg_match(':^#AA:', $message)) { |
|
576 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
577 | 577 | } |
578 | - elseif (preg_match(':^#AB:',$message)) { |
|
579 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
578 | + elseif (preg_match(':^#AB:', $message)) { |
|
579 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
580 | 580 | } |
581 | - elseif (preg_match(':^#AC:',$message)) { |
|
582 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
581 | + elseif (preg_match(':^#AC:', $message)) { |
|
582 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
583 | 583 | } |
584 | - elseif (preg_match(':^#AD:',$message)) { |
|
585 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
584 | + elseif (preg_match(':^#AD:', $message)) { |
|
585 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
586 | 586 | } |
587 | - elseif (preg_match(':^#AF:',$message)) { |
|
588 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
587 | + elseif (preg_match(':^#AF:', $message)) { |
|
588 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
589 | 589 | } |
590 | - elseif (preg_match(':^#B1:',$message)) { |
|
591 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
590 | + elseif (preg_match(':^#B1:', $message)) { |
|
591 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
592 | 592 | } |
593 | - elseif (preg_match(':^#B2:',$message)) { |
|
594 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
593 | + elseif (preg_match(':^#B2:', $message)) { |
|
594 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
595 | 595 | } |
596 | - elseif (preg_match(':^#B3:',$message)) { |
|
597 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
596 | + elseif (preg_match(':^#B3:', $message)) { |
|
597 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
598 | 598 | } |
599 | - elseif (preg_match(':^#B4:',$message)) { |
|
600 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
599 | + elseif (preg_match(':^#B4:', $message)) { |
|
600 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
601 | 601 | } |
602 | - elseif (preg_match(':^#B6:',$message)) { |
|
603 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
602 | + elseif (preg_match(':^#B6:', $message)) { |
|
603 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
604 | 604 | } |
605 | - elseif (preg_match(':^#B8:',$message)) { |
|
606 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
605 | + elseif (preg_match(':^#B8:', $message)) { |
|
606 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
607 | 607 | } |
608 | - elseif (preg_match(':^#B9:',$message)) { |
|
609 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
608 | + elseif (preg_match(':^#B9:', $message)) { |
|
609 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
610 | 610 | } |
611 | - elseif (preg_match(':^#B0:',$message)) { |
|
612 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
611 | + elseif (preg_match(':^#B0:', $message)) { |
|
612 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
613 | 613 | } |
614 | - elseif (preg_match(':^#BA:',$message)) { |
|
615 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
614 | + elseif (preg_match(':^#BA:', $message)) { |
|
615 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
616 | 616 | } |
617 | - elseif (preg_match(':^#BB:',$message)) { |
|
618 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
617 | + elseif (preg_match(':^#BB:', $message)) { |
|
618 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
619 | 619 | } |
620 | - elseif (preg_match(':^#BC:',$message)) { |
|
621 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
620 | + elseif (preg_match(':^#BC:', $message)) { |
|
621 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
622 | 622 | } |
623 | - elseif (preg_match(':^#BD:',$message)) { |
|
624 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
623 | + elseif (preg_match(':^#BD:', $message)) { |
|
624 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
625 | 625 | } |
626 | - elseif (preg_match(':^#BE:',$message)) { |
|
627 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
626 | + elseif (preg_match(':^#BE:', $message)) { |
|
627 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
628 | 628 | } |
629 | - elseif (preg_match(':^#BF:',$message)) { |
|
630 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
629 | + elseif (preg_match(':^#BF:', $message)) { |
|
630 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
631 | 631 | } |
632 | - elseif (preg_match(':^#H3:',$message)) { |
|
633 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
632 | + elseif (preg_match(':^#H3:', $message)) { |
|
633 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | if ($label == '10') { |
637 | - if (preg_match(':^DTO01:',$message)) { |
|
638 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
637 | + if (preg_match(':^DTO01:', $message)) { |
|
638 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
639 | 639 | } |
640 | - elseif (preg_match(':^AIS01:',$message)) { |
|
641 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
640 | + elseif (preg_match(':^AIS01:', $message)) { |
|
641 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
642 | 642 | } |
643 | - elseif (preg_match(':^FTX01:',$message)) { |
|
644 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
643 | + elseif (preg_match(':^FTX01:', $message)) { |
|
644 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
645 | 645 | } |
646 | - elseif (preg_match(':^FPL01:',$message)) { |
|
647 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
646 | + elseif (preg_match(':^FPL01:', $message)) { |
|
647 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
648 | 648 | } |
649 | - elseif (preg_match(':^WAB01:',$message)) { |
|
650 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
649 | + elseif (preg_match(':^WAB01:', $message)) { |
|
650 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
651 | 651 | } |
652 | - elseif (preg_match(':^MET01:',$message)) { |
|
653 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
652 | + elseif (preg_match(':^MET01:', $message)) { |
|
653 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
654 | 654 | } |
655 | - elseif (preg_match(':^WAB02:',$message)) { |
|
656 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
655 | + elseif (preg_match(':^WAB02:', $message)) { |
|
656 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | if ($label == '15') { |
660 | - if (preg_match(':^FST01:',$message)) { |
|
661 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
660 | + if (preg_match(':^FST01:', $message)) { |
|
661 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
662 | 662 | } |
663 | 663 | } |
664 | 664 | if (!$found && $label == 'SA') { |
665 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
665 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
666 | 666 | if ($n == 4) { |
667 | 667 | $vsta = array('Version' => $version); |
668 | 668 | if ($state == 'E') { |
669 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
669 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
670 | 670 | } |
671 | 671 | elseif ($state == 'L') { |
672 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
672 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
673 | 673 | } |
674 | 674 | else { |
675 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
675 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
676 | 676 | } |
677 | 677 | if ($type == 'V') { |
678 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
678 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
679 | 679 | } |
680 | 680 | elseif ($type == 'S') { |
681 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
681 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
682 | 682 | } |
683 | 683 | elseif ($type == 'H') { |
684 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
684 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
685 | 685 | } |
686 | 686 | elseif ($type == 'G') { |
687 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
687 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
688 | 688 | } |
689 | 689 | elseif ($type == 'C') { |
690 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
690 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
691 | 691 | } |
692 | 692 | elseif ($type == '2') { |
693 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
693 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
694 | 694 | } |
695 | 695 | elseif ($type == 'X') { |
696 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
696 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
697 | 697 | } |
698 | 698 | elseif ($type == 'I') { |
699 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
699 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
700 | 700 | } |
701 | 701 | else { |
702 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
702 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
703 | 703 | } |
704 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
705 | - $decode = array_merge($vsta,$decode); |
|
704 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
705 | + $decode = array_merge($vsta, $decode); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
709 | 709 | $title = $this->getTitlefromLabel($label); |
710 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
710 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
711 | 711 | /* |
712 | 712 | // Business jets always use GS0001 |
713 | 713 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | $Translation = new Translation($this->db); |
736 | 736 | $message = $this->parse($data); |
737 | 737 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
738 | - $ident = (string)$message['ident']; |
|
738 | + $ident = (string) $message['ident']; |
|
739 | 739 | $label = $message['label']; |
740 | 740 | $block_id = $message['block_id']; |
741 | 741 | $msg_no = $message['msg_no']; |
742 | 742 | $msg = $message['message']; |
743 | 743 | $decode = $message['decode']; |
744 | - $registration = (string)$message['registration']; |
|
744 | + $registration = (string) $message['registration']; |
|
745 | 745 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
746 | 746 | else $latitude = ''; |
747 | 747 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -755,20 +755,20 @@ discard block |
||
755 | 755 | $Image->addSpotterImage($registration); |
756 | 756 | } |
757 | 757 | // Business jets always use GS0001 |
758 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
758 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
759 | 759 | if ($globalDebug && isset($info) && $info != '') echo $info; |
760 | 760 | if (count($decode) > 0) $decode_json = json_encode($decode); |
761 | 761 | else $decode_json = ''; |
762 | 762 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
763 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
763 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
764 | 764 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
765 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
765 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
766 | 766 | } |
767 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
768 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
769 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
767 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
768 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
769 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
770 | 770 | if ($globalDebug && count($decode) > 0) { |
771 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
771 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @param String $msg_no Number of the ACARS message |
784 | 784 | * @param String $message ACARS message |
785 | 785 | */ |
786 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
786 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
787 | 787 | global $globalDebug; |
788 | 788 | date_default_timezone_set('UTC'); |
789 | 789 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -791,21 +791,21 @@ discard block |
||
791 | 791 | $this->db = $Connection->db; |
792 | 792 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
793 | 793 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
794 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
794 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
795 | 795 | try { |
796 | 796 | $stht = $this->db->prepare($query_test); |
797 | 797 | $stht->execute($query_test_values); |
798 | - } catch(PDOException $e) { |
|
798 | + } catch (PDOException $e) { |
|
799 | 799 | return "error : ".$e->getMessage(); |
800 | 800 | } |
801 | 801 | if ($stht->fetchColumn() == 0) { |
802 | 802 | if ($globalDebug) echo "Add Live ACARS data..."; |
803 | 803 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
804 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
804 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
805 | 805 | try { |
806 | 806 | $sth = $this->db->prepare($query); |
807 | 807 | $sth->execute($query_values); |
808 | - } catch(PDOException $e) { |
|
808 | + } catch (PDOException $e) { |
|
809 | 809 | return "error : ".$e->getMessage(); |
810 | 810 | } |
811 | 811 | } else { |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | * @param String $msg_no Number of the ACARS message |
828 | 828 | * @param String $message ACARS message |
829 | 829 | */ |
830 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
830 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
831 | 831 | global $globalDebug; |
832 | 832 | date_default_timezone_set('UTC'); |
833 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
833 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
834 | 834 | /* |
835 | 835 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
836 | 836 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -845,11 +845,11 @@ discard block |
||
845 | 845 | */ |
846 | 846 | if ($globalDebug) echo "Add Live ACARS data..."; |
847 | 847 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
848 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
848 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
849 | 849 | try { |
850 | 850 | $sth = $this->db->prepare($query); |
851 | 851 | $sth->execute($query_values); |
852 | - } catch(PDOException $e) { |
|
852 | + } catch (PDOException $e) { |
|
853 | 853 | return "error : ".$e->getMessage(); |
854 | 854 | } |
855 | 855 | if ($globalDebug) echo "Done\n"; |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | try { |
871 | 871 | $sth = $this->db->prepare($query); |
872 | 872 | $sth->execute($query_values); |
873 | - } catch(PDOException $e) { |
|
873 | + } catch (PDOException $e) { |
|
874 | 874 | echo "error : ".$e->getMessage(); |
875 | 875 | return ''; |
876 | 876 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | try { |
891 | 891 | $sth = $this->db->prepare($query); |
892 | 892 | $sth->execute($query_values); |
893 | - } catch(PDOException $e) { |
|
893 | + } catch (PDOException $e) { |
|
894 | 894 | echo "error : ".$e->getMessage(); |
895 | 895 | return array(); |
896 | 896 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | try { |
912 | 912 | $sth = $this->db->prepare($query); |
913 | 913 | $sth->execute($query_values); |
914 | - } catch(PDOException $e) { |
|
914 | + } catch (PDOException $e) { |
|
915 | 915 | echo "error : ".$e->getMessage(); |
916 | 916 | return array(); |
917 | 917 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @return Array Return ACARS data in array |
927 | 927 | */ |
928 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
928 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
929 | 929 | global $globalURL, $globalDBdriver; |
930 | 930 | $Image = new Image($this->db); |
931 | 931 | $Spotter = new Spotter($this->db); |
@@ -936,8 +936,8 @@ discard block |
||
936 | 936 | if ($limit != "") |
937 | 937 | { |
938 | 938 | $limit_array = explode(",", $limit); |
939 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
940 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
939 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
940 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
941 | 941 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
942 | 942 | { |
943 | 943 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -953,46 +953,46 @@ discard block |
||
953 | 953 | try { |
954 | 954 | $sth = $this->db->prepare($query); |
955 | 955 | $sth->execute($query_values); |
956 | - } catch(PDOException $e) { |
|
956 | + } catch (PDOException $e) { |
|
957 | 957 | return "error : ".$e->getMessage(); |
958 | 958 | } |
959 | 959 | $i = 0; |
960 | 960 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
961 | 961 | $data = array(); |
962 | 962 | if ($row['registration'] != '') { |
963 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
963 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
964 | 964 | $image_array = $Image->getSpotterImage($row['registration']); |
965 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
966 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
967 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
965 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
966 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
967 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
968 | 968 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
969 | 969 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
970 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
970 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
971 | 971 | if (isset($identicao[0])) { |
972 | - if (substr($row['ident'],0,2) == 'AF') { |
|
973 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
975 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
976 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
972 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
973 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
975 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
976 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
977 | 977 | } else $icao = $row['ident']; |
978 | - $icao = $Translation->checkTranslation($icao,false); |
|
979 | - $decode = json_decode($row['decode'],true); |
|
978 | + $icao = $Translation->checkTranslation($icao, false); |
|
979 | + $decode = json_decode($row['decode'], true); |
|
980 | 980 | $found = false; |
981 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
981 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
982 | 982 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
983 | 983 | if (isset($airport_info[0]['icao'])) { |
984 | 984 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
985 | 985 | $found = true; |
986 | 986 | } |
987 | 987 | } |
988 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
988 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
989 | 989 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
990 | 990 | if (isset($airport_info[0]['icao'])) { |
991 | 991 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
992 | 992 | $found = true; |
993 | 993 | } |
994 | 994 | } |
995 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
995 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
996 | 996 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
997 | 997 | if (isset($airport_info[0]['icao'])) { |
998 | 998 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | if ($found) $row['decode'] = json_encode($decode); |
1003 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1003 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1004 | 1004 | $result[] = $data; |
1005 | 1005 | $i++; |
1006 | 1006 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return Array Return ACARS data in array |
1018 | 1018 | */ |
1019 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1019 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1020 | 1020 | global $globalURL, $globalDBdriver; |
1021 | 1021 | $Image = new Image($this->db); |
1022 | 1022 | $Spotter = new Spotter($this->db); |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | if ($limit != "") |
1027 | 1027 | { |
1028 | 1028 | $limit_array = explode(",", $limit); |
1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1031 | 1031 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1032 | 1032 | { |
1033 | 1033 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1048,43 +1048,43 @@ discard block |
||
1048 | 1048 | try { |
1049 | 1049 | $sth = $this->db->prepare($query); |
1050 | 1050 | $sth->execute($query_values); |
1051 | - } catch(PDOException $e) { |
|
1051 | + } catch (PDOException $e) { |
|
1052 | 1052 | return "error : ".$e->getMessage(); |
1053 | 1053 | } |
1054 | - $i=0; |
|
1054 | + $i = 0; |
|
1055 | 1055 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1056 | 1056 | $data = array(); |
1057 | 1057 | if ($row['registration'] != '') { |
1058 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1058 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1059 | 1059 | $image_array = $Image->getSpotterImage($row['registration']); |
1060 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1061 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1062 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1060 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
1061 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1062 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1063 | 1063 | $icao = ''; |
1064 | 1064 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1065 | 1065 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1066 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1066 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1067 | 1067 | if (isset($identicao[0])) { |
1068 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1069 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1071 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1072 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1068 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1069 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1071 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1072 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1073 | 1073 | } else $icao = $row['ident']; |
1074 | 1074 | $icao = $Translation->checkTranslation($icao); |
1075 | - $decode = json_decode($row['decode'],true); |
|
1075 | + $decode = json_decode($row['decode'], true); |
|
1076 | 1076 | $found = false; |
1077 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1077 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1078 | 1078 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1079 | 1079 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1080 | 1080 | $found = true; |
1081 | 1081 | } |
1082 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1082 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1083 | 1083 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1084 | 1084 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1085 | 1085 | $found = true; |
1086 | 1086 | } |
1087 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1087 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1088 | 1088 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1089 | 1089 | if (isset($airport_info[0]['icao'])) { |
1090 | 1090 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | if ($found) $row['decode'] = json_encode($decode); |
1095 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1095 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1096 | 1096 | $result[] = $data; |
1097 | 1097 | $i++; |
1098 | 1098 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | * @param String $icao |
1111 | 1111 | * @param String $ICAOTypeCode |
1112 | 1112 | */ |
1113 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1113 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1114 | 1114 | global $globalDebug, $globalDBdriver; |
1115 | 1115 | $ident = trim($ident); |
1116 | 1116 | $Translation = new Translation($this->db); |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1124 | 1124 | return ''; |
1125 | 1125 | } |
1126 | - $registration = str_replace('.','',$registration); |
|
1126 | + $registration = str_replace('.', '', $registration); |
|
1127 | 1127 | $ident = $Translation->ident2icao($ident); |
1128 | 1128 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1129 | 1129 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | try { |
1133 | 1133 | $sthsi = $this->db->prepare($querysi); |
1134 | 1134 | $sthsi->execute($querysi_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | if ($globalDebug) echo $e->getMessage(); |
1137 | 1137 | return "error : ".$e->getMessage(); |
1138 | 1138 | } |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | $Translation = new Translation($this->db); |
1143 | 1143 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1144 | 1144 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1145 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1146 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1145 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1146 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1147 | 1147 | } else { |
1148 | 1148 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1149 | 1149 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | try { |
1152 | 1152 | $sth = $this->db->prepare($query); |
1153 | 1153 | $sth->execute($query_values); |
1154 | - } catch(PDOException $e) { |
|
1154 | + } catch (PDOException $e) { |
|
1155 | 1155 | if ($globalDebug) echo $e->getMessage(); |
1156 | 1156 | return "error : ".$e->getMessage(); |
1157 | 1157 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $sth->closeCursor(); |
1160 | 1160 | if (isset($result['modes'])) $hex = $result['modes']; |
1161 | 1161 | else $hex = ''; |
1162 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1162 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1163 | 1163 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1164 | 1164 | } |
1165 | 1165 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | try { |
1170 | 1170 | $sth = $this->db->prepare($query); |
1171 | 1171 | $sth->execute($query_values); |
1172 | - } catch(PDOException $e) { |
|
1172 | + } catch (PDOException $e) { |
|
1173 | 1173 | if ($globalDebug) echo $e->getMessage(); |
1174 | 1174 | return "error : ".$e->getMessage(); |
1175 | 1175 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1180 | 1180 | else $ModeS = ''; |
1181 | 1181 | if ($ModeS == '') { |
1182 | - $id = explode('-',$result['flightaware_id']); |
|
1182 | + $id = explode('-', $result['flightaware_id']); |
|
1183 | 1183 | $ModeS = $id[0]; |
1184 | 1184 | } |
1185 | 1185 | if ($ModeS != '') { |
@@ -1189,20 +1189,20 @@ discard block |
||
1189 | 1189 | try { |
1190 | 1190 | $sthc = $this->db->prepare($queryc); |
1191 | 1191 | $sthc->execute($queryc_values); |
1192 | - } catch(PDOException $e) { |
|
1192 | + } catch (PDOException $e) { |
|
1193 | 1193 | if ($globalDebug) echo $e->getMessage(); |
1194 | 1194 | return "error : ".$e->getMessage(); |
1195 | 1195 | } |
1196 | 1196 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1197 | 1197 | $sthc->closeCursor(); |
1198 | - if (count($row) == 0) { |
|
1198 | + if (count($row) == 0) { |
|
1199 | 1199 | if ($globalDebug) echo " Add to ModeS table - "; |
1200 | 1200 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1201 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1201 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1202 | 1202 | try { |
1203 | 1203 | $sthi = $this->db->prepare($queryi); |
1204 | 1204 | $sthi->execute($queryi_values); |
1205 | - } catch(PDOException $e) { |
|
1205 | + } catch (PDOException $e) { |
|
1206 | 1206 | if ($globalDebug) echo $e->getMessage(); |
1207 | 1207 | return "error : ".$e->getMessage(); |
1208 | 1208 | } |
@@ -1210,15 +1210,15 @@ discard block |
||
1210 | 1210 | if ($globalDebug) echo " Update ModeS table - "; |
1211 | 1211 | if ($ICAOTypeCode != '') { |
1212 | 1212 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1213 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1213 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1214 | 1214 | } else { |
1215 | 1215 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1216 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1216 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1217 | 1217 | } |
1218 | 1218 | try { |
1219 | 1219 | $sthi = $this->db->prepare($queryi); |
1220 | 1220 | $sthi->execute($queryi_values); |
1221 | - } catch(PDOException $e) { |
|
1221 | + } catch (PDOException $e) { |
|
1222 | 1222 | if ($globalDebug) echo $e->getMessage(); |
1223 | 1223 | return "error : ".$e->getMessage(); |
1224 | 1224 | } |
@@ -1255,12 +1255,12 @@ discard block |
||
1255 | 1255 | elseif ($globalDBdriver == 'pgsql') { |
1256 | 1256 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1257 | 1257 | } |
1258 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1258 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1259 | 1259 | } |
1260 | 1260 | try { |
1261 | 1261 | $sthi = $this->db->prepare($queryi); |
1262 | 1262 | $sthi->execute($queryi_values); |
1263 | - } catch(PDOException $e) { |
|
1263 | + } catch (PDOException $e) { |
|
1264 | 1264 | if ($globalDebug) echo $e->getMessage(); |
1265 | 1265 | return "error : ".$e->getMessage(); |
1266 | 1266 | } |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | if ($this->db === null) die('Error: No DB connection.'); |
20 | 20 | } |
21 | 21 | |
22 | - public function addLastStatsUpdate($type,$stats_date) { |
|
22 | + public function addLastStatsUpdate($type, $stats_date) { |
|
23 | 23 | $query = "DELETE FROM config WHERE name = :type; |
24 | 24 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
25 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
25 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
26 | 26 | try { |
27 | 27 | $sth = $this->db->prepare($query); |
28 | 28 | $sth->execute($query_values); |
29 | - } catch(PDOException $e) { |
|
29 | + } catch (PDOException $e) { |
|
30 | 30 | return "error : ".$e->getMessage(); |
31 | 31 | } |
32 | 32 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | try { |
37 | 37 | $sth = $this->db->prepare($query); |
38 | 38 | $sth->execute(array(':type' => $type)); |
39 | - } catch(PDOException $e) { |
|
39 | + } catch (PDOException $e) { |
|
40 | 40 | echo "error : ".$e->getMessage(); |
41 | 41 | } |
42 | 42 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | try { |
58 | 58 | $sth = $this->db->prepare($query); |
59 | 59 | $sth->execute(array(':filter_name' => $filter_name)); |
60 | - } catch(PDOException $e) { |
|
60 | + } catch (PDOException $e) { |
|
61 | 61 | return "error : ".$e->getMessage(); |
62 | 62 | } |
63 | 63 | } |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | try { |
71 | 71 | $sth = $this->db->prepare($query); |
72 | 72 | $sth->execute(); |
73 | - } catch(PDOException $e) { |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | return "error : ".$e->getMessage(); |
75 | 75 | } |
76 | 76 | $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
77 | 77 | try { |
78 | 78 | $sth = $this->db->prepare($query); |
79 | 79 | $sth->execute(array(':filter_name' => $filter_name)); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error : ".$e->getMessage(); |
82 | 82 | } |
83 | 83 | } |
@@ -89,77 +89,77 @@ discard block |
||
89 | 89 | try { |
90 | 90 | $sth = $this->db->prepare($query); |
91 | 91 | $sth->execute(array(':filter_name' => $filter_name)); |
92 | - } catch(PDOException $e) { |
|
92 | + } catch (PDOException $e) { |
|
93 | 93 | echo "error : ".$e->getMessage(); |
94 | 94 | } |
95 | 95 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
96 | 96 | if (empty($all)) { |
97 | 97 | $filters = array(); |
98 | 98 | if ($filter_name != '') { |
99 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
99 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
100 | 100 | } |
101 | 101 | $Spotter = new Spotter($this->db); |
102 | - $all = $Spotter->getAllAirlineNames('',NULL,$filters); |
|
102 | + $all = $Spotter->getAllAirlineNames('', NULL, $filters); |
|
103 | 103 | } |
104 | 104 | return $all; |
105 | 105 | } |
106 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
106 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
107 | 107 | if ($filter_name == '') $filter_name = $this->filter_name; |
108 | 108 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
109 | 109 | try { |
110 | 110 | $sth = $this->db->prepare($query); |
111 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
112 | - } catch(PDOException $e) { |
|
111 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
112 | + } catch (PDOException $e) { |
|
113 | 113 | echo "error : ".$e->getMessage(); |
114 | 114 | } |
115 | 115 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
116 | 116 | return $all; |
117 | 117 | } |
118 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
118 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
119 | 119 | if ($filter_name == '') $filter_name = $this->filter_name; |
120 | 120 | $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"; |
121 | 121 | try { |
122 | 122 | $sth = $this->db->prepare($query); |
123 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
124 | - } catch(PDOException $e) { |
|
123 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
124 | + } catch (PDOException $e) { |
|
125 | 125 | echo "error : ".$e->getMessage(); |
126 | 126 | } |
127 | 127 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
128 | 128 | return $all; |
129 | 129 | } |
130 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
130 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
131 | 131 | if ($filter_name == '') $filter_name = $this->filter_name; |
132 | 132 | $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"; |
133 | 133 | try { |
134 | 134 | $sth = $this->db->prepare($query); |
135 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
136 | - } catch(PDOException $e) { |
|
135 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
136 | + } catch (PDOException $e) { |
|
137 | 137 | echo "error : ".$e->getMessage(); |
138 | 138 | } |
139 | 139 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
140 | 140 | return $all; |
141 | 141 | } |
142 | 142 | |
143 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
143 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
144 | 144 | if ($filter_name == '') $filter_name = $this->filter_name; |
145 | 145 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
146 | 146 | try { |
147 | 147 | $sth = $this->db->prepare($query); |
148 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
149 | - } catch(PDOException $e) { |
|
148 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
149 | + } catch (PDOException $e) { |
|
150 | 150 | echo "error : ".$e->getMessage(); |
151 | 151 | } |
152 | 152 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
153 | 153 | return $all; |
154 | 154 | } |
155 | 155 | |
156 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
156 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name; |
158 | 158 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
159 | 159 | try { |
160 | 160 | $sth = $this->db->prepare($query); |
161 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
162 | - } catch(PDOException $e) { |
|
161 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
162 | + } catch (PDOException $e) { |
|
163 | 163 | echo "error : ".$e->getMessage(); |
164 | 164 | } |
165 | 165 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -167,23 +167,23 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | |
170 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
170 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
171 | 171 | global $globalStatsFilters; |
172 | 172 | if ($filter_name == '') $filter_name = $this->filter_name; |
173 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
173 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
174 | 174 | $Spotter = new Spotter($this->db); |
175 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
175 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
176 | 176 | $alliance_airlines = array(); |
177 | 177 | foreach ($airlines as $airline) { |
178 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
178 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
179 | 179 | } |
180 | 180 | if ($year == '' && $month == '') { |
181 | - 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 stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
181 | + 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 stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
182 | + else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
183 | 183 | try { |
184 | 184 | $sth = $this->db->prepare($query); |
185 | 185 | $sth->execute(array(':filter_name' => $filter_name)); |
186 | - } catch(PDOException $e) { |
|
186 | + } catch (PDOException $e) { |
|
187 | 187 | echo "error : ".$e->getMessage(); |
188 | 188 | } |
189 | 189 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -194,29 +194,29 @@ discard block |
||
194 | 194 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
195 | 195 | try { |
196 | 196 | $sth = $this->db->prepare($query); |
197 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
198 | - } catch(PDOException $e) { |
|
197 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
198 | + } catch (PDOException $e) { |
|
199 | 199 | echo "error : ".$e->getMessage(); |
200 | 200 | } |
201 | 201 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
202 | 202 | } else $all = array(); |
203 | 203 | } |
204 | 204 | if (empty($all)) { |
205 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
206 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
205 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
206 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
207 | 207 | } else { |
208 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
208 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
209 | 209 | } |
210 | 210 | if ($filter_name != '') { |
211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
211 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
212 | 212 | } |
213 | 213 | $Spotter = new Spotter($this->db); |
214 | 214 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
215 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
215 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
216 | 216 | } |
217 | 217 | return $all; |
218 | 218 | } |
219 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
219 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
220 | 220 | global $globalStatsFilters; |
221 | 221 | if ($filter_name == '') $filter_name = $this->filter_name; |
222 | 222 | if ($year == '' && $month == '') { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $this->db->prepare($query); |
227 | 227 | $sth->execute(array(':filter_name' => $filter_name)); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | echo "error : ".$e->getMessage(); |
230 | 230 | } |
231 | 231 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -233,32 +233,32 @@ discard block |
||
233 | 233 | if (empty($all)) { |
234 | 234 | $Spotter = new Spotter($this->db); |
235 | 235 | $filters = array(); |
236 | - $filters = array('year' => $year,'month' => $month); |
|
236 | + $filters = array('year' => $year, 'month' => $month); |
|
237 | 237 | if ($filter_name != '') { |
238 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
238 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
239 | 239 | } |
240 | 240 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
241 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
241 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
242 | 242 | } |
243 | 243 | return $all; |
244 | 244 | } |
245 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
245 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
246 | 246 | global $globalStatsFilters; |
247 | 247 | if ($filter_name == '') $filter_name = $this->filter_name; |
248 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
248 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
249 | 249 | $Spotter = new Spotter($this->db); |
250 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
250 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
251 | 251 | $alliance_airlines = array(); |
252 | 252 | foreach ($airlines as $airline) { |
253 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
253 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
254 | 254 | } |
255 | 255 | if ($year == '' && $month == '') { |
256 | - 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"; |
|
257 | - 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"; |
|
256 | + 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"; |
|
257 | + 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"; |
|
258 | 258 | try { |
259 | 259 | $sth = $this->db->prepare($query); |
260 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
261 | - } catch(PDOException $e) { |
|
261 | + } catch (PDOException $e) { |
|
262 | 262 | echo "error : ".$e->getMessage(); |
263 | 263 | } |
264 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -269,21 +269,21 @@ discard block |
||
269 | 269 | 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"; |
270 | 270 | try { |
271 | 271 | $sth = $this->db->prepare($query); |
272 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
273 | - } catch(PDOException $e) { |
|
272 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
273 | + } catch (PDOException $e) { |
|
274 | 274 | echo "error : ".$e->getMessage(); |
275 | 275 | } |
276 | 276 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
277 | 277 | } else $all = array(); |
278 | 278 | } |
279 | 279 | if (empty($all)) { |
280 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
281 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
280 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
281 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
282 | 282 | } else { |
283 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
283 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
284 | 284 | } |
285 | 285 | if ($filter_name != '') { |
286 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
286 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
287 | 287 | } |
288 | 288 | $Spotter = new Spotter($this->db); |
289 | 289 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -292,23 +292,23 @@ discard block |
||
292 | 292 | return $all; |
293 | 293 | } |
294 | 294 | |
295 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
295 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
296 | 296 | global $globalStatsFilters; |
297 | 297 | if ($filter_name == '') $filter_name = $this->filter_name; |
298 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
298 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
299 | 299 | $Spotter = new Spotter($this->db); |
300 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
300 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
301 | 301 | $alliance_airlines = array(); |
302 | 302 | foreach ($airlines as $airline) { |
303 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
303 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
304 | 304 | } |
305 | 305 | if ($year == '' && $month == '') { |
306 | - 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"; |
|
307 | - 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"; |
|
306 | + 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"; |
|
307 | + 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"; |
|
308 | 308 | try { |
309 | 309 | $sth = $this->db->prepare($query); |
310 | 310 | $sth->execute(array(':filter_name' => $filter_name)); |
311 | - } catch(PDOException $e) { |
|
311 | + } catch (PDOException $e) { |
|
312 | 312 | echo "error : ".$e->getMessage(); |
313 | 313 | } |
314 | 314 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -319,61 +319,61 @@ discard block |
||
319 | 319 | 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"; |
320 | 320 | try { |
321 | 321 | $sth = $this->db->prepare($query); |
322 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
323 | - } catch(PDOException $e) { |
|
322 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | echo "error : ".$e->getMessage(); |
325 | 325 | } |
326 | 326 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
327 | 327 | } else $all = array(); |
328 | 328 | } |
329 | 329 | if (empty($all)) { |
330 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
331 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
330 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
331 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
332 | 332 | } else { |
333 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
333 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
334 | 334 | } |
335 | 335 | if ($filter_name != '') { |
336 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
336 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
337 | 337 | } |
338 | 338 | $Spotter = new Spotter($this->db); |
339 | 339 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
340 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
340 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
341 | 341 | } |
342 | 342 | return $all; |
343 | 343 | } |
344 | 344 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
345 | 345 | global $globalStatsFilters; |
346 | 346 | if ($filter_name == '') $filter_name = $this->filter_name; |
347 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
347 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
348 | 348 | $Spotter = new Spotter($this->db); |
349 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
349 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
350 | 350 | $alliance_airlines = array(); |
351 | 351 | foreach ($airlines as $airline) { |
352 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
352 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
353 | 353 | } |
354 | - 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"; |
|
355 | - 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"; |
|
354 | + 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"; |
|
355 | + 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"; |
|
356 | 356 | $query_values = array(':filter_name' => $filter_name); |
357 | 357 | } else { |
358 | 358 | 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"; |
359 | 359 | 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"; |
360 | - $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
360 | + $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
361 | 361 | } |
362 | 362 | try { |
363 | 363 | $sth = $this->db->prepare($query); |
364 | 364 | $sth->execute($query_values); |
365 | - } catch(PDOException $e) { |
|
365 | + } catch (PDOException $e) { |
|
366 | 366 | echo "error : ".$e->getMessage(); |
367 | 367 | } |
368 | 368 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
369 | 369 | if (empty($all)) { |
370 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
371 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
370 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
371 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
372 | 372 | } else { |
373 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
373 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
374 | 374 | } |
375 | 375 | if ($filter_name != '') { |
376 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
376 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
377 | 377 | } |
378 | 378 | $Spotter = new Spotter($this->db); |
379 | 379 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | return $all; |
383 | 383 | } |
384 | 384 | |
385 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
385 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
386 | 386 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
387 | 387 | if ($filter_name == '') $filter_name = $this->filter_name; |
388 | 388 | if ($year == '' && $month == '') { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | if (isset($forsource)) { |
392 | 392 | 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"; |
393 | 393 | 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"; |
394 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
394 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
395 | 395 | } else { |
396 | 396 | 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"; |
397 | 397 | 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"; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | try { |
401 | 401 | $sth = $this->db->prepare($query); |
402 | 402 | $sth->execute($query_values); |
403 | - } catch(PDOException $e) { |
|
403 | + } catch (PDOException $e) { |
|
404 | 404 | echo "error : ".$e->getMessage(); |
405 | 405 | } |
406 | 406 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -408,32 +408,32 @@ discard block |
||
408 | 408 | if (empty($all)) { |
409 | 409 | $Spotter = new Spotter($this->db); |
410 | 410 | $filters = array(); |
411 | - $filters = array('year' => $year,'month' => $month); |
|
411 | + $filters = array('year' => $year, 'month' => $month); |
|
412 | 412 | if ($filter_name != '') { |
413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
413 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
414 | 414 | } |
415 | 415 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
416 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
416 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
417 | 417 | } |
418 | 418 | return $all; |
419 | 419 | } |
420 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
420 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
421 | 421 | global $globalStatsFilters; |
422 | 422 | if ($filter_name == '') $filter_name = $this->filter_name; |
423 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
423 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
424 | 424 | $Spotter = new Spotter($this->db); |
425 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
425 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
426 | 426 | $alliance_airlines = array(); |
427 | 427 | foreach ($airlines as $airline) { |
428 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
428 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
429 | 429 | } |
430 | 430 | if ($year == '' && $month == '') { |
431 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_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 aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
432 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_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 aircraft_registration_count DESC"; |
|
431 | + if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_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 aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
432 | + else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_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 aircraft_registration_count DESC"; |
|
433 | 433 | try { |
434 | 434 | $sth = $this->db->prepare($query); |
435 | 435 | $sth->execute(array(':filter_name' => $filter_name)); |
436 | - } catch(PDOException $e) { |
|
436 | + } catch (PDOException $e) { |
|
437 | 437 | echo "error : ".$e->getMessage(); |
438 | 438 | } |
439 | 439 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -444,45 +444,45 @@ discard block |
||
444 | 444 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_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 aircraft_registration_count DESC"; |
445 | 445 | try { |
446 | 446 | $sth = $this->db->prepare($query); |
447 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
448 | - } catch(PDOException $e) { |
|
447 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
448 | + } catch (PDOException $e) { |
|
449 | 449 | echo "error : ".$e->getMessage(); |
450 | 450 | } |
451 | 451 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
452 | 452 | } else $all = array(); |
453 | 453 | } |
454 | 454 | if (empty($all)) { |
455 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
456 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
455 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
456 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
457 | 457 | } else { |
458 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
458 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
459 | 459 | } |
460 | 460 | if ($filter_name != '') { |
461 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
461 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
462 | 462 | } |
463 | 463 | $Spotter = new Spotter($this->db); |
464 | 464 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
465 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
465 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
466 | 466 | } |
467 | 467 | return $all; |
468 | 468 | } |
469 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
469 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
470 | 470 | global $globalStatsFilters; |
471 | 471 | if ($filter_name == '') $filter_name = $this->filter_name; |
472 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
472 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
473 | 473 | $Spotter = new Spotter($this->db); |
474 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
474 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
475 | 475 | $alliance_airlines = array(); |
476 | 476 | foreach ($airlines as $airline) { |
477 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
477 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
478 | 478 | } |
479 | 479 | if ($year == '' && $month == '') { |
480 | - 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"; |
|
481 | - 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"; |
|
480 | + 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"; |
|
481 | + 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"; |
|
482 | 482 | try { |
483 | 483 | $sth = $this->db->prepare($query); |
484 | 484 | $sth->execute(array(':filter_name' => $filter_name)); |
485 | - } catch(PDOException $e) { |
|
485 | + } catch (PDOException $e) { |
|
486 | 486 | echo "error : ".$e->getMessage(); |
487 | 487 | } |
488 | 488 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -493,46 +493,46 @@ discard block |
||
493 | 493 | 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"; |
494 | 494 | try { |
495 | 495 | $sth = $this->db->prepare($query); |
496 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
497 | - } catch(PDOException $e) { |
|
496 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
497 | + } catch (PDOException $e) { |
|
498 | 498 | echo "error : ".$e->getMessage(); |
499 | 499 | } |
500 | 500 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
501 | 501 | } else $all = array(); |
502 | 502 | } |
503 | 503 | if (empty($all)) { |
504 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
505 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
504 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
505 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
506 | 506 | } else { |
507 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
507 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
508 | 508 | } |
509 | 509 | if ($filter_name != '') { |
510 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
510 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
511 | 511 | } |
512 | 512 | $Spotter = new Spotter($this->db); |
513 | 513 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
514 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
514 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
515 | 515 | } |
516 | 516 | return $all; |
517 | 517 | } |
518 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
518 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
519 | 519 | $Connection = new Connection(); |
520 | 520 | if ($filter_name == '') $filter_name = $this->filter_name; |
521 | 521 | if ($Connection->tableExists('countries')) { |
522 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
522 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
523 | 523 | $Spotter = new Spotter($this->db); |
524 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
524 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
525 | 525 | if ($year == '' && $month == '') { |
526 | 526 | $alliance_airlines = array(); |
527 | 527 | foreach ($airlines as $airline) { |
528 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
528 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
529 | 529 | } |
530 | - 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"; |
|
531 | - 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"; |
|
530 | + 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"; |
|
531 | + 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"; |
|
532 | 532 | try { |
533 | 533 | $sth = $this->db->prepare($query); |
534 | 534 | $sth->execute(array(':filter_name' => $filter_name)); |
535 | - } catch(PDOException $e) { |
|
535 | + } catch (PDOException $e) { |
|
536 | 536 | echo "error : ".$e->getMessage(); |
537 | 537 | } |
538 | 538 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | 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"; |
545 | 545 | try { |
546 | 546 | $sth = $this->db->prepare($query); |
547 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
548 | - } catch(PDOException $e) { |
|
547 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
548 | + } catch (PDOException $e) { |
|
549 | 549 | echo "error : ".$e->getMessage(); |
550 | 550 | } |
551 | 551 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | return array(); |
563 | 563 | } |
564 | 564 | } |
565 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
565 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
566 | 566 | global $globalStatsFilters; |
567 | 567 | if ($filter_name == '') $filter_name = $this->filter_name; |
568 | 568 | if ($year == '' && $month == '') { |
@@ -570,41 +570,41 @@ discard block |
||
570 | 570 | 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"; |
571 | 571 | try { |
572 | 572 | $sth = $this->db->prepare($query); |
573 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
574 | - } catch(PDOException $e) { |
|
573 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | echo "error : ".$e->getMessage(); |
576 | 576 | } |
577 | 577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
578 | 578 | } else $all = array(); |
579 | 579 | if (empty($all)) { |
580 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
580 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
581 | 581 | if ($filter_name != '') { |
582 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
582 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
583 | 583 | } |
584 | 584 | $Spotter = new Spotter($this->db); |
585 | 585 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
586 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
586 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
587 | 587 | } |
588 | 588 | return $all; |
589 | 589 | } |
590 | 590 | |
591 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
591 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
592 | 592 | global $globalStatsFilters; |
593 | 593 | if ($filter_name == '') $filter_name = $this->filter_name; |
594 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
594 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
595 | 595 | $Spotter = new Spotter($this->db); |
596 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
596 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
597 | 597 | if ($year == '' && $month == '') { |
598 | 598 | $alliance_airlines = array(); |
599 | 599 | foreach ($airlines as $airline) { |
600 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
600 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
601 | 601 | } |
602 | - 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"; |
|
603 | - 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"; |
|
602 | + 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"; |
|
603 | + 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"; |
|
604 | 604 | try { |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':filter_name' => $filter_name)); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | echo "error : ".$e->getMessage(); |
609 | 609 | } |
610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -615,45 +615,45 @@ discard block |
||
615 | 615 | 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"; |
616 | 616 | try { |
617 | 617 | $sth = $this->db->prepare($query); |
618 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
619 | - } catch(PDOException $e) { |
|
618 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
619 | + } catch (PDOException $e) { |
|
620 | 620 | echo "error : ".$e->getMessage(); |
621 | 621 | } |
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | 623 | } else $all = array(); |
624 | 624 | } |
625 | 625 | if (empty($all)) { |
626 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
627 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
626 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
627 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
628 | 628 | } else { |
629 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
629 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
630 | 630 | } |
631 | 631 | if ($filter_name != '') { |
632 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
632 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
633 | 633 | } |
634 | 634 | $Spotter = new Spotter($this->db); |
635 | 635 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
636 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
636 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
637 | 637 | } |
638 | 638 | return $all; |
639 | 639 | } |
640 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
640 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
641 | 641 | global $globalStatsFilters; |
642 | 642 | if ($filter_name == '') $filter_name = $this->filter_name; |
643 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
643 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
644 | 644 | $Spotter = new Spotter($this->db); |
645 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
645 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
646 | 646 | if ($year == '' && $month == '') { |
647 | 647 | $alliance_airlines = array(); |
648 | 648 | foreach ($airlines as $airline) { |
649 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
649 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
650 | 650 | } |
651 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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"; |
|
652 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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"; |
|
651 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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"; |
|
652 | + else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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"; |
|
653 | 653 | try { |
654 | 654 | $sth = $this->db->prepare($query); |
655 | 655 | $sth->execute(array(':filter_name' => $filter_name)); |
656 | - } catch(PDOException $e) { |
|
656 | + } catch (PDOException $e) { |
|
657 | 657 | echo "error : ".$e->getMessage(); |
658 | 658 | } |
659 | 659 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -664,27 +664,27 @@ discard block |
||
664 | 664 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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"; |
665 | 665 | try { |
666 | 666 | $sth = $this->db->prepare($query); |
667 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
668 | - } catch(PDOException $e) { |
|
667 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | echo "error : ".$e->getMessage(); |
670 | 670 | } |
671 | 671 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
672 | 672 | } else $all = array(); |
673 | 673 | } |
674 | 674 | if (empty($all)) { |
675 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
676 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
675 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
676 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
677 | 677 | } else { |
678 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
678 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
679 | 679 | } |
680 | 680 | if ($filter_name != '') { |
681 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
681 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
682 | 682 | } |
683 | 683 | $Spotter = new Spotter($this->db); |
684 | 684 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
685 | 685 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
686 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
687 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
686 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
687 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
688 | 688 | $all = array(); |
689 | 689 | foreach ($pall as $value) { |
690 | 690 | $icao = $value['airport_departure_icao']; |
@@ -700,27 +700,27 @@ discard block |
||
700 | 700 | foreach ($all as $key => $row) { |
701 | 701 | $count[$key] = $row['airport_departure_icao_count']; |
702 | 702 | } |
703 | - array_multisort($count,SORT_DESC,$all); |
|
703 | + array_multisort($count, SORT_DESC, $all); |
|
704 | 704 | } |
705 | 705 | return $all; |
706 | 706 | } |
707 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
707 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
708 | 708 | global $globalStatsFilters; |
709 | 709 | if ($filter_name == '') $filter_name = $this->filter_name; |
710 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
710 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
711 | 711 | $Spotter = new Spotter($this->db); |
712 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
712 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
713 | 713 | if ($year == '' && $month == '') { |
714 | 714 | $alliance_airlines = array(); |
715 | 715 | foreach ($airlines as $airline) { |
716 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
716 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
717 | 717 | } |
718 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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"; |
|
719 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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"; |
|
718 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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"; |
|
719 | + else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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"; |
|
720 | 720 | try { |
721 | 721 | $sth = $this->db->prepare($query); |
722 | 722 | $sth->execute(array(':filter_name' => $filter_name)); |
723 | - } catch(PDOException $e) { |
|
723 | + } catch (PDOException $e) { |
|
724 | 724 | echo "error : ".$e->getMessage(); |
725 | 725 | } |
726 | 726 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -731,27 +731,27 @@ discard block |
||
731 | 731 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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"; |
732 | 732 | try { |
733 | 733 | $sth = $this->db->prepare($query); |
734 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
735 | - } catch(PDOException $e) { |
|
734 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
735 | + } catch (PDOException $e) { |
|
736 | 736 | echo "error : ".$e->getMessage(); |
737 | 737 | } |
738 | 738 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
739 | 739 | } else $all = array(); |
740 | 740 | } |
741 | 741 | if (empty($all)) { |
742 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
743 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
742 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
743 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
744 | 744 | } else { |
745 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
745 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
746 | 746 | } |
747 | 747 | if ($filter_name != '') { |
748 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
748 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
749 | 749 | } |
750 | 750 | $Spotter = new Spotter($this->db); |
751 | 751 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
752 | 752 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
753 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
754 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
753 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
754 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
755 | 755 | $all = array(); |
756 | 756 | foreach ($pall as $value) { |
757 | 757 | $icao = $value['airport_arrival_icao']; |
@@ -767,26 +767,26 @@ discard block |
||
767 | 767 | foreach ($all as $key => $row) { |
768 | 768 | $count[$key] = $row['airport_arrival_icao_count']; |
769 | 769 | } |
770 | - array_multisort($count,SORT_DESC,$all); |
|
770 | + array_multisort($count, SORT_DESC, $all); |
|
771 | 771 | } |
772 | 772 | return $all; |
773 | 773 | } |
774 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
774 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
775 | 775 | global $globalDBdriver, $globalStatsFilters; |
776 | 776 | if ($filter_name == '') $filter_name = $this->filter_name; |
777 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
777 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
778 | 778 | $Spotter = new Spotter($this->db); |
779 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
779 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
780 | 780 | $alliance_airlines = array(); |
781 | 781 | foreach ($airlines as $airline) { |
782 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
782 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
783 | 783 | } |
784 | 784 | if ($globalDBdriver == 'mysql') { |
785 | - 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"; |
|
786 | - 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"; |
|
785 | + 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"; |
|
786 | + 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"; |
|
787 | 787 | } else { |
788 | - 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"; |
|
789 | - 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"; |
|
788 | + 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"; |
|
789 | + 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"; |
|
790 | 790 | } |
791 | 791 | $query_data = array(':filter_name' => $filter_name); |
792 | 792 | } else { |
@@ -797,23 +797,23 @@ discard block |
||
797 | 797 | 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"; |
798 | 798 | 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"; |
799 | 799 | } |
800 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
800 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
801 | 801 | } |
802 | 802 | try { |
803 | 803 | $sth = $this->db->prepare($query); |
804 | 804 | $sth->execute($query_data); |
805 | - } catch(PDOException $e) { |
|
805 | + } catch (PDOException $e) { |
|
806 | 806 | echo "error : ".$e->getMessage(); |
807 | 807 | } |
808 | 808 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
809 | 809 | if (empty($all)) { |
810 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
811 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
810 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
811 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
812 | 812 | } else { |
813 | 813 | $filters = array('airlines' => array($stats_airline)); |
814 | 814 | } |
815 | 815 | if ($filter_name != '') { |
816 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
816 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
817 | 817 | } |
818 | 818 | $Spotter = new Spotter($this->db); |
819 | 819 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -821,57 +821,57 @@ discard block |
||
821 | 821 | return $all; |
822 | 822 | } |
823 | 823 | |
824 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
824 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
825 | 825 | global $globalStatsFilters; |
826 | 826 | if ($filter_name == '') $filter_name = $this->filter_name; |
827 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
827 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
828 | 828 | $Spotter = new Spotter($this->db); |
829 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
829 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
830 | 830 | $alliance_airlines = array(); |
831 | 831 | foreach ($airlines as $airline) { |
832 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
832 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
833 | 833 | } |
834 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
834 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
835 | 835 | $query_data = array(':filter_name' => $filter_name); |
836 | 836 | } else { |
837 | 837 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
838 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
838 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
839 | 839 | } |
840 | 840 | try { |
841 | 841 | $sth = $this->db->prepare($query); |
842 | 842 | $sth->execute($query_data); |
843 | - } catch(PDOException $e) { |
|
843 | + } catch (PDOException $e) { |
|
844 | 844 | echo "error : ".$e->getMessage(); |
845 | 845 | } |
846 | 846 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
847 | 847 | if (empty($all)) { |
848 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
849 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
848 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
849 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
850 | 850 | } else { |
851 | 851 | $filters = array('airlines' => array($stats_airline)); |
852 | 852 | } |
853 | 853 | if ($filter_name != '') { |
854 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
854 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
855 | 855 | } |
856 | 856 | $Spotter = new Spotter($this->db); |
857 | 857 | $all = $Spotter->countAllDatesLastMonth($filters); |
858 | 858 | } |
859 | 859 | return $all; |
860 | 860 | } |
861 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
861 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
862 | 862 | global $globalDBdriver, $globalStatsFilters; |
863 | 863 | if ($filter_name == '') $filter_name = $this->filter_name; |
864 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
864 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
865 | 865 | $Spotter = new Spotter($this->db); |
866 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
866 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
867 | 867 | $alliance_airlines = array(); |
868 | 868 | foreach ($airlines as $airline) { |
869 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
869 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
870 | 870 | } |
871 | 871 | if ($globalDBdriver == 'mysql') { |
872 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
872 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
873 | 873 | } else { |
874 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
874 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
875 | 875 | } |
876 | 876 | $query_data = array(':filter_name' => $filter_name); |
877 | 877 | } else { |
@@ -880,60 +880,60 @@ discard block |
||
880 | 880 | } else { |
881 | 881 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
882 | 882 | } |
883 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
883 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
884 | 884 | } |
885 | 885 | try { |
886 | 886 | $sth = $this->db->prepare($query); |
887 | 887 | $sth->execute($query_data); |
888 | - } catch(PDOException $e) { |
|
888 | + } catch (PDOException $e) { |
|
889 | 889 | echo "error : ".$e->getMessage(); |
890 | 890 | } |
891 | 891 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
892 | 892 | if (empty($all)) { |
893 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
894 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
893 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
894 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
895 | 895 | } else { |
896 | 896 | $filters = array('airlines' => array($stats_airline)); |
897 | 897 | } |
898 | 898 | if ($filter_name != '') { |
899 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
899 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
900 | 900 | } |
901 | 901 | $Spotter = new Spotter($this->db); |
902 | 902 | $all = $Spotter->countAllDatesLast7Days($filters); |
903 | 903 | } |
904 | 904 | return $all; |
905 | 905 | } |
906 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
906 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
907 | 907 | global $globalStatsFilters; |
908 | 908 | if ($filter_name == '') $filter_name = $this->filter_name; |
909 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
909 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
910 | 910 | $Spotter = new Spotter($this->db); |
911 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
911 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
912 | 912 | $alliance_airlines = array(); |
913 | 913 | foreach ($airlines as $airline) { |
914 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
914 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
915 | 915 | } |
916 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
916 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
917 | 917 | $query_data = array(':filter_name' => $filter_name); |
918 | 918 | } else { |
919 | 919 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
920 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
920 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
921 | 921 | } |
922 | 922 | try { |
923 | 923 | $sth = $this->db->prepare($query); |
924 | 924 | $sth->execute($query_data); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | echo "error : ".$e->getMessage(); |
927 | 927 | } |
928 | 928 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
929 | 929 | if (empty($all)) { |
930 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
931 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
930 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
931 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
932 | 932 | } else { |
933 | 933 | $filters = array('airlines' => array($stats_airline)); |
934 | 934 | } |
935 | 935 | if ($filter_name != '') { |
936 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
936 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
937 | 937 | } |
938 | 938 | $Spotter = new Spotter($this->db); |
939 | 939 | $all = $Spotter->countAllDates($filters); |
@@ -948,34 +948,34 @@ discard block |
||
948 | 948 | try { |
949 | 949 | $sth = $this->db->prepare($query); |
950 | 950 | $sth->execute($query_data); |
951 | - } catch(PDOException $e) { |
|
951 | + } catch (PDOException $e) { |
|
952 | 952 | echo "error : ".$e->getMessage(); |
953 | 953 | } |
954 | 954 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
955 | 955 | if (empty($all)) { |
956 | 956 | $filters = array(); |
957 | 957 | if ($filter_name != '') { |
958 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
958 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
959 | 959 | } |
960 | 960 | $Spotter = new Spotter($this->db); |
961 | 961 | $all = $Spotter->countAllDatesByAirlines($filters); |
962 | 962 | } |
963 | 963 | return $all; |
964 | 964 | } |
965 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
965 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
966 | 966 | global $globalStatsFilters, $globalDBdriver; |
967 | 967 | if ($filter_name == '') $filter_name = $this->filter_name; |
968 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
968 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
969 | 969 | $Spotter = new Spotter($this->db); |
970 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
970 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
971 | 971 | $alliance_airlines = array(); |
972 | 972 | foreach ($airlines as $airline) { |
973 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
973 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
974 | 974 | } |
975 | 975 | if ($globalDBdriver == 'mysql') { |
976 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_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 ORDER BY date_count DESC"; |
|
976 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_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 ORDER BY date_count DESC"; |
|
977 | 977 | } else { |
978 | - $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_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 ORDER BY date_count DESC"; |
|
978 | + $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_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 ORDER BY date_count DESC"; |
|
979 | 979 | } |
980 | 980 | $query_data = array(':filter_name' => $filter_name); |
981 | 981 | } else { |
@@ -989,18 +989,18 @@ discard block |
||
989 | 989 | try { |
990 | 990 | $sth = $this->db->prepare($query); |
991 | 991 | $sth->execute($query_data); |
992 | - } catch(PDOException $e) { |
|
992 | + } catch (PDOException $e) { |
|
993 | 993 | echo "error : ".$e->getMessage(); |
994 | 994 | } |
995 | 995 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
996 | 996 | if (empty($all)) { |
997 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
998 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
997 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
998 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
999 | 999 | } else { |
1000 | 1000 | $filters = array('airlines' => array($stats_airline)); |
1001 | 1001 | } |
1002 | 1002 | if ($filter_name != '') { |
1003 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1003 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1004 | 1004 | } |
1005 | 1005 | $Spotter = new Spotter($this->db); |
1006 | 1006 | $all = $Spotter->countAllMonths($filters); |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | try { |
1018 | 1018 | $sth = $this->db->prepare($query); |
1019 | 1019 | $sth->execute(); |
1020 | - } catch(PDOException $e) { |
|
1020 | + } catch (PDOException $e) { |
|
1021 | 1021 | echo "error : ".$e->getMessage(); |
1022 | 1022 | } |
1023 | 1023 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | try { |
1038 | 1038 | $sth = $this->db->prepare($query); |
1039 | 1039 | $sth->execute(); |
1040 | - } catch(PDOException $e) { |
|
1040 | + } catch (PDOException $e) { |
|
1041 | 1041 | echo "error : ".$e->getMessage(); |
1042 | 1042 | } |
1043 | 1043 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1054,32 +1054,32 @@ discard block |
||
1054 | 1054 | try { |
1055 | 1055 | $sth = $this->db->prepare($query); |
1056 | 1056 | $sth->execute(array(':filter_name' => $filter_name)); |
1057 | - } catch(PDOException $e) { |
|
1057 | + } catch (PDOException $e) { |
|
1058 | 1058 | echo "error : ".$e->getMessage(); |
1059 | 1059 | } |
1060 | 1060 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1061 | 1061 | if (empty($all)) { |
1062 | 1062 | $filters = array(); |
1063 | 1063 | if ($filter_name != '') { |
1064 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1064 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1065 | 1065 | } |
1066 | 1066 | $Spotter = new Spotter($this->db); |
1067 | 1067 | $all = $Spotter->countAllMilitaryMonths($filters); |
1068 | 1068 | } |
1069 | 1069 | return $all; |
1070 | 1070 | } |
1071 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
1071 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
1072 | 1072 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1073 | 1073 | if ($filter_name == '') $filter_name = $this->filter_name; |
1074 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1074 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1075 | 1075 | $Spotter = new Spotter($this->db); |
1076 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1076 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1077 | 1077 | $alliance_airlines = array(); |
1078 | 1078 | foreach ($airlines as $airline) { |
1079 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1079 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1080 | 1080 | } |
1081 | - 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"; |
|
1082 | - 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"; |
|
1081 | + 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"; |
|
1082 | + 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"; |
|
1083 | 1083 | $query_data = array(':filter_name' => $filter_name); |
1084 | 1084 | } else { |
1085 | 1085 | 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"; |
@@ -1097,37 +1097,37 @@ discard block |
||
1097 | 1097 | try { |
1098 | 1098 | $sth = $this->db->prepare($query); |
1099 | 1099 | $sth->execute($query_data); |
1100 | - } catch(PDOException $e) { |
|
1100 | + } catch (PDOException $e) { |
|
1101 | 1101 | echo "error : ".$e->getMessage(); |
1102 | 1102 | } |
1103 | 1103 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1104 | 1104 | if (empty($all)) { |
1105 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1106 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1105 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1106 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1107 | 1107 | } else { |
1108 | 1108 | $filters = array('airlines' => array($stats_airline)); |
1109 | 1109 | } |
1110 | 1110 | if ($filter_name != '') { |
1111 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1111 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1112 | 1112 | } |
1113 | 1113 | $Spotter = new Spotter($this->db); |
1114 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
1114 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
1115 | 1115 | } |
1116 | 1116 | return $all; |
1117 | 1117 | } |
1118 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
1118 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1119 | 1119 | global $globalStatsFilters; |
1120 | 1120 | if ($filter_name == '') $filter_name = $this->filter_name; |
1121 | 1121 | if ($year == '') $year = date('Y'); |
1122 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1122 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1123 | 1123 | if (empty($all)) { |
1124 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1125 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1124 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1125 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1126 | 1126 | } else { |
1127 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1127 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1128 | 1128 | } |
1129 | 1129 | if ($filter_name != '') { |
1130 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1130 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1131 | 1131 | } |
1132 | 1132 | $Spotter = new Spotter($this->db); |
1133 | 1133 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1135,16 +1135,16 @@ discard block |
||
1135 | 1135 | } |
1136 | 1136 | return $all; |
1137 | 1137 | } |
1138 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
1138 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
1139 | 1139 | global $globalStatsFilters; |
1140 | 1140 | if ($filter_name == '') $filter_name = $this->filter_name; |
1141 | 1141 | if ($year == '') $year = date('Y'); |
1142 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
1142 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
1143 | 1143 | if (empty($all)) { |
1144 | 1144 | $filters = array(); |
1145 | - $filters = array('year' => $year,'month' => $month); |
|
1145 | + $filters = array('year' => $year, 'month' => $month); |
|
1146 | 1146 | if ($filter_name != '') { |
1147 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1147 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1148 | 1148 | } |
1149 | 1149 | $Spotter = new Spotter($this->db); |
1150 | 1150 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -1152,19 +1152,19 @@ discard block |
||
1152 | 1152 | } |
1153 | 1153 | return $all; |
1154 | 1154 | } |
1155 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
1155 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1156 | 1156 | global $globalStatsFilters; |
1157 | 1157 | if ($filter_name == '') $filter_name = $this->filter_name; |
1158 | 1158 | if ($year == '') $year = date('Y'); |
1159 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1159 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1160 | 1160 | if (empty($all)) { |
1161 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1162 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1161 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1162 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1163 | 1163 | } else { |
1164 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1164 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1165 | 1165 | } |
1166 | 1166 | if ($filter_name != '') { |
1167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1167 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1168 | 1168 | } |
1169 | 1169 | $Spotter = new Spotter($this->db); |
1170 | 1170 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -1172,48 +1172,48 @@ discard block |
||
1172 | 1172 | } |
1173 | 1173 | return $all; |
1174 | 1174 | } |
1175 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
1175 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1176 | 1176 | global $globalStatsFilters; |
1177 | 1177 | if ($filter_name == '') $filter_name = $this->filter_name; |
1178 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1178 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1179 | 1179 | $Spotter = new Spotter($this->db); |
1180 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1180 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1181 | 1181 | if ($year == '' && $month == '') { |
1182 | 1182 | $alliance_airlines = array(); |
1183 | 1183 | foreach ($airlines as $airline) { |
1184 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1184 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1185 | 1185 | } |
1186 | - $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1186 | + $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1187 | 1187 | try { |
1188 | 1188 | $sth = $this->db->prepare($query); |
1189 | 1189 | $sth->execute(array(':filter_name' => $filter_name)); |
1190 | - } catch(PDOException $e) { |
|
1190 | + } catch (PDOException $e) { |
|
1191 | 1191 | echo "error : ".$e->getMessage(); |
1192 | 1192 | } |
1193 | 1193 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1194 | 1194 | $all = $result[0]['nb']; |
1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1195 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1196 | 1196 | } else { |
1197 | 1197 | if ($year == '' && $month == '') { |
1198 | 1198 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1199 | 1199 | try { |
1200 | 1200 | $sth = $this->db->prepare($query); |
1201 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
1202 | - } catch(PDOException $e) { |
|
1201 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
1202 | + } catch (PDOException $e) { |
|
1203 | 1203 | echo "error : ".$e->getMessage(); |
1204 | 1204 | } |
1205 | 1205 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1206 | 1206 | $all = $result[0]['nb']; |
1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1207 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1208 | 1208 | } |
1209 | 1209 | if (empty($all)) { |
1210 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1211 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1210 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1211 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1212 | 1212 | } else { |
1213 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1213 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1214 | 1214 | } |
1215 | 1215 | if ($filter_name != '') { |
1216 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1216 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1217 | 1217 | } |
1218 | 1218 | $Spotter = new Spotter($this->db); |
1219 | 1219 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | } |
1222 | 1222 | return $all; |
1223 | 1223 | } |
1224 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
1224 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
1225 | 1225 | global $globalStatsFilters; |
1226 | 1226 | if ($filter_name == '') $filter_name = $this->filter_name; |
1227 | 1227 | if ($year == '' && $month == '') { |
@@ -1229,17 +1229,17 @@ discard block |
||
1229 | 1229 | try { |
1230 | 1230 | $sth = $this->db->prepare($query); |
1231 | 1231 | $sth->execute(array(':filter_name' => $filter_name)); |
1232 | - } catch(PDOException $e) { |
|
1232 | + } catch (PDOException $e) { |
|
1233 | 1233 | echo "error : ".$e->getMessage(); |
1234 | 1234 | } |
1235 | 1235 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1236 | 1236 | $all = $result[0]['nb_airline']; |
1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1237 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
1238 | 1238 | if (empty($all)) { |
1239 | 1239 | $filters = array(); |
1240 | - $filters = array('year' => $year,'month' => $month); |
|
1240 | + $filters = array('year' => $year, 'month' => $month); |
|
1241 | 1241 | if ($filter_name != '') { |
1242 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1242 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1243 | 1243 | } |
1244 | 1244 | $Spotter = new Spotter($this->db); |
1245 | 1245 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1247,29 +1247,29 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | return $all; |
1249 | 1249 | } |
1250 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
1250 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1251 | 1251 | global $globalStatsFilters; |
1252 | 1252 | if ($filter_name == '') $filter_name = $this->filter_name; |
1253 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1253 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1254 | 1254 | $Spotter = new Spotter($this->db); |
1255 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1255 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1256 | 1256 | if ($year == '' && $month == '') { |
1257 | 1257 | $alliance_airlines = array(); |
1258 | 1258 | foreach ($airlines as $airline) { |
1259 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1259 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1260 | 1260 | } |
1261 | - $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1261 | + $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1262 | 1262 | $query_values = array(':filter_name' => $filter_name); |
1263 | 1263 | try { |
1264 | 1264 | $sth = $this->db->prepare($query); |
1265 | 1265 | $sth->execute($query_values); |
1266 | - } catch(PDOException $e) { |
|
1266 | + } catch (PDOException $e) { |
|
1267 | 1267 | echo "error : ".$e->getMessage(); |
1268 | 1268 | } |
1269 | 1269 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1270 | 1270 | $all = $result[0]['nb']; |
1271 | 1271 | } else { |
1272 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1272 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1273 | 1273 | } |
1274 | 1274 | } else { |
1275 | 1275 | if ($year == '' && $month == '') { |
@@ -1278,23 +1278,23 @@ discard block |
||
1278 | 1278 | try { |
1279 | 1279 | $sth = $this->db->prepare($query); |
1280 | 1280 | $sth->execute($query_values); |
1281 | - } catch(PDOException $e) { |
|
1281 | + } catch (PDOException $e) { |
|
1282 | 1282 | echo "error : ".$e->getMessage(); |
1283 | 1283 | } |
1284 | 1284 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1285 | 1285 | $all = $result[0]['nb']; |
1286 | 1286 | } else { |
1287 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1287 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | if (empty($all)) { |
1291 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1292 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
1291 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1292 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
1293 | 1293 | } else { |
1294 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1294 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1295 | 1295 | } |
1296 | 1296 | if ($filter_name != '') { |
1297 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1297 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1298 | 1298 | } |
1299 | 1299 | $Spotter = new Spotter($this->db); |
1300 | 1300 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | } |
1303 | 1303 | return $all; |
1304 | 1304 | } |
1305 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
1305 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
1306 | 1306 | global $globalStatsFilters; |
1307 | 1307 | if ($filter_name == '') $filter_name = $this->filter_name; |
1308 | 1308 | //if ($year == '') $year = date('Y'); |
@@ -1312,18 +1312,18 @@ discard block |
||
1312 | 1312 | try { |
1313 | 1313 | $sth = $this->db->prepare($query); |
1314 | 1314 | $sth->execute($query_values); |
1315 | - } catch(PDOException $e) { |
|
1315 | + } catch (PDOException $e) { |
|
1316 | 1316 | echo "error : ".$e->getMessage(); |
1317 | 1317 | } |
1318 | 1318 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1319 | 1319 | $all = $result[0]['nb']; |
1320 | 1320 | } else { |
1321 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1321 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
1322 | 1322 | } |
1323 | 1323 | if (empty($all)) { |
1324 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
1324 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
1325 | 1325 | if ($filter_name != '') { |
1326 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
1326 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
1327 | 1327 | } |
1328 | 1328 | $Spotter = new Spotter($this->db); |
1329 | 1329 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -1332,104 +1332,104 @@ discard block |
||
1332 | 1332 | return $all; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
1335 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
1336 | 1336 | if ($filter_name == '') $filter_name = $this->filter_name; |
1337 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1337 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1338 | 1338 | $Spotter = new Spotter($this->db); |
1339 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1339 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1340 | 1340 | $alliance_airlines = array(); |
1341 | 1341 | foreach ($airlines as $airline) { |
1342 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1342 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1343 | 1343 | } |
1344 | - $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
1345 | - $query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name); |
|
1344 | + $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
1345 | + $query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name); |
|
1346 | 1346 | } else { |
1347 | 1347 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
1348 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1348 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1349 | 1349 | } |
1350 | 1350 | try { |
1351 | 1351 | $sth = $this->db->prepare($query); |
1352 | 1352 | $sth->execute($query_values); |
1353 | - } catch(PDOException $e) { |
|
1353 | + } catch (PDOException $e) { |
|
1354 | 1354 | echo "error : ".$e->getMessage(); |
1355 | 1355 | } |
1356 | 1356 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1357 | 1357 | return $all; |
1358 | 1358 | } |
1359 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
1359 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
1360 | 1360 | if ($filter_name == '') $filter_name = $this->filter_name; |
1361 | 1361 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
1362 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1362 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1363 | 1363 | try { |
1364 | 1364 | $sth = $this->db->prepare($query); |
1365 | 1365 | $sth->execute($query_values); |
1366 | - } catch(PDOException $e) { |
|
1366 | + } catch (PDOException $e) { |
|
1367 | 1367 | echo "error : ".$e->getMessage(); |
1368 | 1368 | } |
1369 | 1369 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1370 | 1370 | return $all; |
1371 | 1371 | } |
1372 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
1372 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
1373 | 1373 | if ($filter_name == '') $filter_name = $this->filter_name; |
1374 | 1374 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1375 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1375 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1376 | 1376 | try { |
1377 | 1377 | $sth = $this->db->prepare($query); |
1378 | 1378 | $sth->execute($query_values); |
1379 | - } catch(PDOException $e) { |
|
1379 | + } catch (PDOException $e) { |
|
1380 | 1380 | echo "error : ".$e->getMessage(); |
1381 | 1381 | } |
1382 | 1382 | } |
1383 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
1383 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
1384 | 1384 | if ($filter_name == '') $filter_name = $this->filter_name; |
1385 | 1385 | global $globalArchiveMonths, $globalDBdriver; |
1386 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1386 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1387 | 1387 | $Spotter = new Spotter($this->db); |
1388 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1388 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1389 | 1389 | $alliance_airlines = array(); |
1390 | 1390 | foreach ($airlines as $airline) { |
1391 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1391 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1392 | 1392 | } |
1393 | 1393 | if ($globalDBdriver == 'mysql') { |
1394 | 1394 | if ($month == '') { |
1395 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1395 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1396 | 1396 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
1397 | 1397 | } else { |
1398 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1399 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
1398 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1399 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
1400 | 1400 | } |
1401 | 1401 | } else { |
1402 | 1402 | if ($month == '') { |
1403 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1403 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1404 | 1404 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
1405 | 1405 | } else { |
1406 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1407 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
1406 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1407 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
1408 | 1408 | } |
1409 | 1409 | } |
1410 | 1410 | } else { |
1411 | 1411 | if ($globalDBdriver == 'mysql') { |
1412 | 1412 | if ($month == '') { |
1413 | 1413 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1414 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1414 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1415 | 1415 | } else { |
1416 | 1416 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1417 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
1417 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
1418 | 1418 | } |
1419 | 1419 | } else { |
1420 | 1420 | if ($month == '') { |
1421 | 1421 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1422 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1422 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1423 | 1423 | } else { |
1424 | 1424 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1425 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
1425 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
1426 | 1426 | } |
1427 | 1427 | } |
1428 | 1428 | } |
1429 | 1429 | try { |
1430 | 1430 | $sth = $this->db->prepare($query); |
1431 | 1431 | $sth->execute($query_values); |
1432 | - } catch(PDOException $e) { |
|
1432 | + } catch (PDOException $e) { |
|
1433 | 1433 | echo "error : ".$e->getMessage(); |
1434 | 1434 | } |
1435 | 1435 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1438,17 +1438,17 @@ discard block |
||
1438 | 1438 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1439 | 1439 | global $globalArchiveMonths, $globalDBdriver; |
1440 | 1440 | if ($filter_name == '') $filter_name = $this->filter_name; |
1441 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1441 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1442 | 1442 | $Spotter = new Spotter($this->db); |
1443 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1443 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1444 | 1444 | $alliance_airlines = array(); |
1445 | 1445 | foreach ($airlines as $airline) { |
1446 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1446 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1447 | 1447 | } |
1448 | 1448 | if ($globalDBdriver == 'mysql') { |
1449 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1449 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1450 | 1450 | } else { |
1451 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1451 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1452 | 1452 | } |
1453 | 1453 | $query_values = array(':type' => $type, ':filter_name' => $filter_name); |
1454 | 1454 | } else { |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | try { |
1463 | 1463 | $sth = $this->db->prepare($query); |
1464 | 1464 | $sth->execute($query_values); |
1465 | - } catch(PDOException $e) { |
|
1465 | + } catch (PDOException $e) { |
|
1466 | 1466 | echo "error : ".$e->getMessage(); |
1467 | 1467 | } |
1468 | 1468 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1471,17 +1471,17 @@ discard block |
||
1471 | 1471 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1472 | 1472 | global $globalArchiveMonths, $globalDBdriver; |
1473 | 1473 | if ($filter_name == '') $filter_name = $this->filter_name; |
1474 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
1474 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
1475 | 1475 | $Spotter = new Spotter($this->db); |
1476 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
1476 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
1477 | 1477 | $alliance_airlines = array(); |
1478 | 1478 | foreach ($airlines as $airline) { |
1479 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
1479 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
1480 | 1480 | } |
1481 | 1481 | if ($globalDBdriver == 'mysql') { |
1482 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1482 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1483 | 1483 | } else { |
1484 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
1484 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
1485 | 1485 | } |
1486 | 1486 | } else { |
1487 | 1487 | if ($globalDBdriver == 'mysql') { |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | try { |
1494 | 1494 | $sth = $this->db->prepare($query); |
1495 | 1495 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
1496 | - } catch(PDOException $e) { |
|
1496 | + } catch (PDOException $e) { |
|
1497 | 1497 | echo "error : ".$e->getMessage(); |
1498 | 1498 | } |
1499 | 1499 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | try { |
1511 | 1511 | $sth = $this->db->prepare($query); |
1512 | 1512 | $sth->execute(array(':filter_name' => $filter_name)); |
1513 | - } catch(PDOException $e) { |
|
1513 | + } catch (PDOException $e) { |
|
1514 | 1514 | echo "error : ".$e->getMessage(); |
1515 | 1515 | } |
1516 | 1516 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1527,20 +1527,20 @@ discard block |
||
1527 | 1527 | try { |
1528 | 1528 | $sth = $this->db->prepare($query); |
1529 | 1529 | $sth->execute(array(':filter_name' => $filter_name)); |
1530 | - } catch(PDOException $e) { |
|
1530 | + } catch (PDOException $e) { |
|
1531 | 1531 | echo "error : ".$e->getMessage(); |
1532 | 1532 | } |
1533 | 1533 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1534 | 1534 | return $all[0]['total']; |
1535 | 1535 | } |
1536 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
1536 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
1537 | 1537 | global $globalArchiveMonths, $globalDBdriver; |
1538 | 1538 | if ($filter_name == '') $filter_name = $this->filter_name; |
1539 | 1539 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1540 | 1540 | try { |
1541 | 1541 | $sth = $this->db->prepare($query); |
1542 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1543 | - } catch(PDOException $e) { |
|
1542 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
1543 | + } catch (PDOException $e) { |
|
1544 | 1544 | echo "error : ".$e->getMessage(); |
1545 | 1545 | } |
1546 | 1546 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1558,20 +1558,20 @@ discard block |
||
1558 | 1558 | try { |
1559 | 1559 | $sth = $this->db->prepare($query); |
1560 | 1560 | $sth->execute(array(':filter_name' => $filter_name)); |
1561 | - } catch(PDOException $e) { |
|
1561 | + } catch (PDOException $e) { |
|
1562 | 1562 | echo "error : ".$e->getMessage(); |
1563 | 1563 | } |
1564 | 1564 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1565 | 1565 | return $all[0]['total']; |
1566 | 1566 | } |
1567 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
1567 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
1568 | 1568 | global $globalArchiveMonths, $globalDBdriver; |
1569 | 1569 | if ($filter_name == '') $filter_name = $this->filter_name; |
1570 | 1570 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1571 | 1571 | try { |
1572 | 1572 | $sth = $this->db->prepare($query); |
1573 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1574 | - } catch(PDOException $e) { |
|
1573 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
1574 | + } catch (PDOException $e) { |
|
1575 | 1575 | echo "error : ".$e->getMessage(); |
1576 | 1576 | } |
1577 | 1577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | else return 0; |
1580 | 1580 | } |
1581 | 1581 | |
1582 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
1582 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
1583 | 1583 | global $globalDBdriver; |
1584 | 1584 | if ($filter_name == '') $filter_name = $this->filter_name; |
1585 | 1585 | if ($globalDBdriver == 'mysql') { |
@@ -1587,15 +1587,15 @@ discard block |
||
1587 | 1587 | } else { |
1588 | 1588 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1589 | 1589 | } |
1590 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1590 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1591 | 1591 | try { |
1592 | 1592 | $sth = $this->db->prepare($query); |
1593 | 1593 | $sth->execute($query_values); |
1594 | - } catch(PDOException $e) { |
|
1594 | + } catch (PDOException $e) { |
|
1595 | 1595 | return "error : ".$e->getMessage(); |
1596 | 1596 | } |
1597 | 1597 | } |
1598 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
1598 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
1599 | 1599 | global $globalDBdriver; |
1600 | 1600 | if ($filter_name == '') $filter_name = $this->filter_name; |
1601 | 1601 | if ($globalDBdriver == 'mysql') { |
@@ -1604,11 +1604,11 @@ discard block |
||
1604 | 1604 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1605 | 1605 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1606 | 1606 | } |
1607 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1607 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1608 | 1608 | try { |
1609 | 1609 | $sth = $this->db->prepare($query); |
1610 | 1610 | $sth->execute($query_values); |
1611 | - } catch(PDOException $e) { |
|
1611 | + } catch (PDOException $e) { |
|
1612 | 1612 | return "error : ".$e->getMessage(); |
1613 | 1613 | } |
1614 | 1614 | } |
@@ -1632,75 +1632,75 @@ discard block |
||
1632 | 1632 | } |
1633 | 1633 | */ |
1634 | 1634 | |
1635 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
1635 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
1636 | 1636 | global $globalDBdriver; |
1637 | 1637 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
1638 | 1638 | $query_values = array(); |
1639 | 1639 | if ($globalDBdriver == 'mysql') { |
1640 | 1640 | if ($year != '') { |
1641 | 1641 | $query .= ' AND YEAR(stats_date) = :year'; |
1642 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1642 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1643 | 1643 | } |
1644 | 1644 | if ($month != '') { |
1645 | 1645 | $query .= ' AND MONTH(stats_date) = :month'; |
1646 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1646 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1647 | 1647 | } |
1648 | 1648 | if ($day != '') { |
1649 | 1649 | $query .= ' AND DAY(stats_date) = :day'; |
1650 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1650 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1651 | 1651 | } |
1652 | 1652 | } else { |
1653 | 1653 | if ($year != '') { |
1654 | 1654 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
1655 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1655 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1656 | 1656 | } |
1657 | 1657 | if ($month != '') { |
1658 | 1658 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
1659 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1659 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1660 | 1660 | } |
1661 | 1661 | if ($day != '') { |
1662 | 1662 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
1663 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1663 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1664 | 1664 | } |
1665 | 1665 | } |
1666 | 1666 | $query .= " ORDER BY source_name"; |
1667 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
1667 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
1668 | 1668 | try { |
1669 | 1669 | $sth = $this->db->prepare($query); |
1670 | 1670 | $sth->execute($query_values); |
1671 | - } catch(PDOException $e) { |
|
1671 | + } catch (PDOException $e) { |
|
1672 | 1672 | echo "error : ".$e->getMessage(); |
1673 | 1673 | } |
1674 | 1674 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1675 | 1675 | return $all; |
1676 | 1676 | } |
1677 | 1677 | |
1678 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
1678 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
1679 | 1679 | global $globalDBdriver; |
1680 | 1680 | if ($globalDBdriver == 'mysql') { |
1681 | 1681 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1682 | 1682 | } else { |
1683 | 1683 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1684 | 1684 | } |
1685 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1685 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
1686 | 1686 | try { |
1687 | 1687 | $sth = $this->db->prepare($query); |
1688 | 1688 | $sth->execute($query_values); |
1689 | - } catch(PDOException $e) { |
|
1689 | + } catch (PDOException $e) { |
|
1690 | 1690 | return "error : ".$e->getMessage(); |
1691 | 1691 | } |
1692 | 1692 | } |
1693 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1693 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1694 | 1694 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
1695 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1695 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1696 | 1696 | try { |
1697 | 1697 | $sth = $this->db->prepare($query); |
1698 | 1698 | $sth->execute($query_values); |
1699 | - } catch(PDOException $e) { |
|
1699 | + } catch (PDOException $e) { |
|
1700 | 1700 | return "error : ".$e->getMessage(); |
1701 | 1701 | } |
1702 | 1702 | } |
1703 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
1703 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1704 | 1704 | global $globalDBdriver; |
1705 | 1705 | if ($globalDBdriver == 'mysql') { |
1706 | 1706 | if ($reset) { |
@@ -1715,15 +1715,15 @@ discard block |
||
1715 | 1715 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1716 | 1716 | } |
1717 | 1717 | } |
1718 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1718 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1719 | 1719 | try { |
1720 | 1720 | $sth = $this->db->prepare($query); |
1721 | 1721 | $sth->execute($query_values); |
1722 | - } catch(PDOException $e) { |
|
1722 | + } catch (PDOException $e) { |
|
1723 | 1723 | return "error : ".$e->getMessage(); |
1724 | 1724 | } |
1725 | 1725 | } |
1726 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
1726 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1727 | 1727 | global $globalDBdriver; |
1728 | 1728 | if ($globalDBdriver == 'mysql') { |
1729 | 1729 | if ($reset) { |
@@ -1738,15 +1738,15 @@ discard block |
||
1738 | 1738 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1739 | 1739 | } |
1740 | 1740 | } |
1741 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1741 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1742 | 1742 | try { |
1743 | 1743 | $sth = $this->db->prepare($query); |
1744 | 1744 | $sth->execute($query_values); |
1745 | - } catch(PDOException $e) { |
|
1745 | + } catch (PDOException $e) { |
|
1746 | 1746 | return "error : ".$e->getMessage(); |
1747 | 1747 | } |
1748 | 1748 | } |
1749 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1749 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1750 | 1750 | global $globalDBdriver; |
1751 | 1751 | if ($globalDBdriver == 'mysql') { |
1752 | 1752 | if ($reset) { |
@@ -1761,15 +1761,15 @@ discard block |
||
1761 | 1761 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1762 | 1762 | } |
1763 | 1763 | } |
1764 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1764 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
1765 | 1765 | try { |
1766 | 1766 | $sth = $this->db->prepare($query); |
1767 | 1767 | $sth->execute($query_values); |
1768 | - } catch(PDOException $e) { |
|
1768 | + } catch (PDOException $e) { |
|
1769 | 1769 | return "error : ".$e->getMessage(); |
1770 | 1770 | } |
1771 | 1771 | } |
1772 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1772 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1773 | 1773 | global $globalDBdriver; |
1774 | 1774 | if ($globalDBdriver == 'mysql') { |
1775 | 1775 | if ($reset) { |
@@ -1784,15 +1784,15 @@ discard block |
||
1784 | 1784 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1785 | 1785 | } |
1786 | 1786 | } |
1787 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1787 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1788 | 1788 | try { |
1789 | 1789 | $sth = $this->db->prepare($query); |
1790 | 1790 | $sth->execute($query_values); |
1791 | - } catch(PDOException $e) { |
|
1791 | + } catch (PDOException $e) { |
|
1792 | 1792 | return "error : ".$e->getMessage(); |
1793 | 1793 | } |
1794 | 1794 | } |
1795 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
1795 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
1796 | 1796 | global $globalDBdriver; |
1797 | 1797 | if ($globalDBdriver == 'mysql') { |
1798 | 1798 | if ($reset) { |
@@ -1807,15 +1807,15 @@ discard block |
||
1807 | 1807 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1808 | 1808 | } |
1809 | 1809 | } |
1810 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1810 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1811 | 1811 | try { |
1812 | 1812 | $sth = $this->db->prepare($query); |
1813 | 1813 | $sth->execute($query_values); |
1814 | - } catch(PDOException $e) { |
|
1814 | + } catch (PDOException $e) { |
|
1815 | 1815 | return "error : ".$e->getMessage(); |
1816 | 1816 | } |
1817 | 1817 | } |
1818 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
1818 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
1819 | 1819 | global $globalDBdriver; |
1820 | 1820 | if ($globalDBdriver == 'mysql') { |
1821 | 1821 | if ($reset) { |
@@ -1830,15 +1830,15 @@ discard block |
||
1830 | 1830 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1831 | 1831 | } |
1832 | 1832 | } |
1833 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1833 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1834 | 1834 | try { |
1835 | 1835 | $sth = $this->db->prepare($query); |
1836 | 1836 | $sth->execute($query_values); |
1837 | - } catch(PDOException $e) { |
|
1837 | + } catch (PDOException $e) { |
|
1838 | 1838 | return "error : ".$e->getMessage(); |
1839 | 1839 | } |
1840 | 1840 | } |
1841 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
1841 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
1842 | 1842 | global $globalDBdriver; |
1843 | 1843 | if ($globalDBdriver == 'mysql') { |
1844 | 1844 | if ($reset) { |
@@ -1853,15 +1853,15 @@ discard block |
||
1853 | 1853 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1854 | 1854 | } |
1855 | 1855 | } |
1856 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1856 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
1857 | 1857 | try { |
1858 | 1858 | $sth = $this->db->prepare($query); |
1859 | 1859 | $sth->execute($query_values); |
1860 | - } catch(PDOException $e) { |
|
1860 | + } catch (PDOException $e) { |
|
1861 | 1861 | return "error : ".$e->getMessage(); |
1862 | 1862 | } |
1863 | 1863 | } |
1864 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1864 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1865 | 1865 | global $globalDBdriver; |
1866 | 1866 | if ($airport_icao != '') { |
1867 | 1867 | if ($globalDBdriver == 'mysql') { |
@@ -1877,16 +1877,16 @@ discard block |
||
1877 | 1877 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1878 | 1878 | } |
1879 | 1879 | } |
1880 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1880 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1881 | 1881 | try { |
1882 | 1882 | $sth = $this->db->prepare($query); |
1883 | 1883 | $sth->execute($query_values); |
1884 | - } catch(PDOException $e) { |
|
1884 | + } catch (PDOException $e) { |
|
1885 | 1885 | return "error : ".$e->getMessage(); |
1886 | 1886 | } |
1887 | 1887 | } |
1888 | 1888 | } |
1889 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1889 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1890 | 1890 | global $globalDBdriver; |
1891 | 1891 | if ($airport_icao != '') { |
1892 | 1892 | if ($globalDBdriver == 'mysql') { |
@@ -1894,16 +1894,16 @@ discard block |
||
1894 | 1894 | } else { |
1895 | 1895 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1896 | 1896 | } |
1897 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1897 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1898 | 1898 | try { |
1899 | 1899 | $sth = $this->db->prepare($query); |
1900 | 1900 | $sth->execute($query_values); |
1901 | - } catch(PDOException $e) { |
|
1901 | + } catch (PDOException $e) { |
|
1902 | 1902 | return "error : ".$e->getMessage(); |
1903 | 1903 | } |
1904 | 1904 | } |
1905 | 1905 | } |
1906 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1906 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1907 | 1907 | global $globalDBdriver; |
1908 | 1908 | if ($airport_icao != '') { |
1909 | 1909 | if ($globalDBdriver == 'mysql') { |
@@ -1919,16 +1919,16 @@ discard block |
||
1919 | 1919 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1920 | 1920 | } |
1921 | 1921 | } |
1922 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1922 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1923 | 1923 | try { |
1924 | 1924 | $sth = $this->db->prepare($query); |
1925 | 1925 | $sth->execute($query_values); |
1926 | - } catch(PDOException $e) { |
|
1926 | + } catch (PDOException $e) { |
|
1927 | 1927 | return "error : ".$e->getMessage(); |
1928 | 1928 | } |
1929 | 1929 | } |
1930 | 1930 | } |
1931 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1931 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1932 | 1932 | global $globalDBdriver; |
1933 | 1933 | if ($airport_icao != '') { |
1934 | 1934 | if ($globalDBdriver == 'mysql') { |
@@ -1936,11 +1936,11 @@ discard block |
||
1936 | 1936 | } else { |
1937 | 1937 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1938 | 1938 | } |
1939 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1939 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1940 | 1940 | try { |
1941 | 1941 | $sth = $this->db->prepare($query); |
1942 | 1942 | $sth->execute($query_values); |
1943 | - } catch(PDOException $e) { |
|
1943 | + } catch (PDOException $e) { |
|
1944 | 1944 | return "error : ".$e->getMessage(); |
1945 | 1945 | } |
1946 | 1946 | } |
@@ -1952,7 +1952,7 @@ discard block |
||
1952 | 1952 | try { |
1953 | 1953 | $sth = $this->db->prepare($query); |
1954 | 1954 | $sth->execute($query_values); |
1955 | - } catch(PDOException $e) { |
|
1955 | + } catch (PDOException $e) { |
|
1956 | 1956 | return "error : ".$e->getMessage(); |
1957 | 1957 | } |
1958 | 1958 | } |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | try { |
1963 | 1963 | $sth = $this->db->prepare($query); |
1964 | 1964 | $sth->execute($query_values); |
1965 | - } catch(PDOException $e) { |
|
1965 | + } catch (PDOException $e) { |
|
1966 | 1966 | return "error : ".$e->getMessage(); |
1967 | 1967 | } |
1968 | 1968 | } |
@@ -1972,13 +1972,13 @@ discard block |
||
1972 | 1972 | try { |
1973 | 1973 | $sth = $this->db->prepare($query); |
1974 | 1974 | $sth->execute($query_values); |
1975 | - } catch(PDOException $e) { |
|
1975 | + } catch (PDOException $e) { |
|
1976 | 1976 | return "error : ".$e->getMessage(); |
1977 | 1977 | } |
1978 | 1978 | } |
1979 | 1979 | |
1980 | 1980 | public function addOldStats() { |
1981 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1981 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
1982 | 1982 | $Common = new Common(); |
1983 | 1983 | $Connection = new Connection(); |
1984 | 1984 | date_default_timezone_set('UTC'); |
@@ -1996,41 +1996,41 @@ discard block |
||
1996 | 1996 | $Spotter = new Spotter($this->db); |
1997 | 1997 | |
1998 | 1998 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
1999 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1999 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
2000 | 2000 | foreach ($alldata as $number) { |
2001 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
2001 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
2002 | 2002 | } |
2003 | 2003 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
2004 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
2004 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
2005 | 2005 | foreach ($alldata as $number) { |
2006 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
2006 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
2007 | 2007 | } |
2008 | 2008 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
2009 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
2009 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
2010 | 2010 | foreach ($alldata as $number) { |
2011 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
2011 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
2012 | 2012 | } |
2013 | 2013 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
2014 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
2014 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
2015 | 2015 | foreach ($alldata as $number) { |
2016 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
2016 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
2017 | 2017 | } |
2018 | 2018 | if ($globalDebug) echo 'Count all owners...'."\n"; |
2019 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
2019 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
2020 | 2020 | foreach ($alldata as $number) { |
2021 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
2021 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
2022 | 2022 | } |
2023 | 2023 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
2024 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
2024 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
2025 | 2025 | foreach ($alldata as $number) { |
2026 | 2026 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
2027 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
2027 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
2028 | 2028 | } |
2029 | 2029 | |
2030 | 2030 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
2031 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
2031 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
2032 | 2032 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
2033 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
2033 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
2034 | 2034 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
2035 | 2035 | $alldata = array(); |
2036 | 2036 | foreach ($pall as $value) { |
@@ -2047,14 +2047,14 @@ discard block |
||
2047 | 2047 | foreach ($alldata as $key => $row) { |
2048 | 2048 | $count[$key] = $row['airport_departure_icao_count']; |
2049 | 2049 | } |
2050 | - array_multisort($count,SORT_DESC,$alldata); |
|
2050 | + array_multisort($count, SORT_DESC, $alldata); |
|
2051 | 2051 | foreach ($alldata as $number) { |
2052 | - 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); |
|
2052 | + 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); |
|
2053 | 2053 | } |
2054 | 2054 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
2055 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
2055 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
2056 | 2056 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
2057 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
2057 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
2058 | 2058 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
2059 | 2059 | $alldata = array(); |
2060 | 2060 | foreach ($pall as $value) { |
@@ -2071,18 +2071,18 @@ discard block |
||
2071 | 2071 | foreach ($alldata as $key => $row) { |
2072 | 2072 | $count[$key] = $row['airport_arrival_icao_count']; |
2073 | 2073 | } |
2074 | - array_multisort($count,SORT_DESC,$alldata); |
|
2074 | + array_multisort($count, SORT_DESC, $alldata); |
|
2075 | 2075 | foreach ($alldata as $number) { |
2076 | - 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); |
|
2076 | + 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); |
|
2077 | 2077 | } |
2078 | 2078 | if ($Connection->tableExists('countries')) { |
2079 | 2079 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
2080 | 2080 | //$SpotterArchive = new SpotterArchive(); |
2081 | 2081 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
2082 | 2082 | $Spotter = new Spotter($this->db); |
2083 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
2083 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
2084 | 2084 | foreach ($alldata as $number) { |
2085 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
2085 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
2086 | 2086 | } |
2087 | 2087 | } |
2088 | 2088 | |
@@ -2092,12 +2092,12 @@ discard block |
||
2092 | 2092 | $this->deleteStatsByType('fatalities_byyear'); |
2093 | 2093 | $alldata = $Accident->countFatalitiesByYear(); |
2094 | 2094 | foreach ($alldata as $number) { |
2095 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
2095 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
2096 | 2096 | } |
2097 | 2097 | $this->deleteStatsByType('fatalities_bymonth'); |
2098 | 2098 | $alldata = $Accident->countFatalitiesLast12Months(); |
2099 | 2099 | foreach ($alldata as $number) { |
2100 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
2100 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
2101 | 2101 | } |
2102 | 2102 | } |
2103 | 2103 | |
@@ -2111,37 +2111,37 @@ discard block |
||
2111 | 2111 | $lastyear = false; |
2112 | 2112 | foreach ($alldata as $number) { |
2113 | 2113 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2114 | - $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']))); |
|
2114 | + $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']))); |
|
2115 | 2115 | } |
2116 | 2116 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
2117 | 2117 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
2118 | 2118 | foreach ($alldata as $number) { |
2119 | - $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']))); |
|
2119 | + $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']))); |
|
2120 | 2120 | } |
2121 | 2121 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
2122 | 2122 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
2123 | 2123 | foreach ($alldata as $number) { |
2124 | - $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']))); |
|
2124 | + $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']))); |
|
2125 | 2125 | } |
2126 | 2126 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
2127 | 2127 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
2128 | 2128 | foreach ($alldata as $number) { |
2129 | - $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']))); |
|
2129 | + $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']))); |
|
2130 | 2130 | } |
2131 | 2131 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
2132 | 2132 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
2133 | 2133 | foreach ($alldata as $number) { |
2134 | - $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']))); |
|
2134 | + $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']))); |
|
2135 | 2135 | } |
2136 | 2136 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
2137 | 2137 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
2138 | 2138 | foreach ($alldata as $number) { |
2139 | - $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']))); |
|
2139 | + $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']))); |
|
2140 | 2140 | } |
2141 | 2141 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
2142 | 2142 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
2143 | 2143 | foreach ($alldata as $number) { |
2144 | - $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']))); |
|
2144 | + $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']))); |
|
2145 | 2145 | } |
2146 | 2146 | if ($globalDebug) echo 'Airports data...'."\n"; |
2147 | 2147 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -2186,7 +2186,7 @@ discard block |
||
2186 | 2186 | } |
2187 | 2187 | $alldata = $pall; |
2188 | 2188 | foreach ($alldata as $number) { |
2189 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
2189 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
2190 | 2190 | } |
2191 | 2191 | echo '...Arrival'."\n"; |
2192 | 2192 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | } |
2228 | 2228 | $alldata = $pall; |
2229 | 2229 | foreach ($alldata as $number) { |
2230 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
2230 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | echo 'Flights data...'."\n"; |
@@ -2235,28 +2235,28 @@ discard block |
||
2235 | 2235 | echo '-> countAllDatesLastMonth...'."\n"; |
2236 | 2236 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
2237 | 2237 | foreach ($alldata as $number) { |
2238 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
2238 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
2239 | 2239 | } |
2240 | 2240 | echo '-> countAllDates...'."\n"; |
2241 | 2241 | $previousdata = $this->countAllDates(); |
2242 | 2242 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
2243 | 2243 | $this->deleteStatFlight('date'); |
2244 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
2244 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
2245 | 2245 | $values = array(); |
2246 | 2246 | foreach ($alldata as $cnt) { |
2247 | 2247 | $values[] = $cnt['date_count']; |
2248 | 2248 | } |
2249 | - array_multisort($values,SORT_DESC,$alldata); |
|
2250 | - array_splice($alldata,11); |
|
2249 | + array_multisort($values, SORT_DESC, $alldata); |
|
2250 | + array_splice($alldata, 11); |
|
2251 | 2251 | foreach ($alldata as $number) { |
2252 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
2252 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
2253 | 2253 | } |
2254 | 2254 | |
2255 | 2255 | $this->deleteStatFlight('hour'); |
2256 | 2256 | echo '-> countAllHours...'."\n"; |
2257 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
2257 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
2258 | 2258 | foreach ($alldata as $number) { |
2259 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
2259 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | // Count by airlines |
@@ -2265,42 +2265,42 @@ discard block |
||
2265 | 2265 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
2266 | 2266 | $SpotterArchive = new SpotterArchive(); |
2267 | 2267 | //$Spotter = new Spotter($this->db); |
2268 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
2268 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
2269 | 2269 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
2270 | 2270 | foreach ($alldata as $number) { |
2271 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
2271 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
2272 | 2272 | } |
2273 | 2273 | } |
2274 | 2274 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
2275 | 2275 | $Spotter = new Spotter($this->db); |
2276 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
2276 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
2277 | 2277 | foreach ($alldata as $number) { |
2278 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
2278 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
2279 | 2279 | } |
2280 | 2280 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
2281 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
2281 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
2282 | 2282 | foreach ($alldata as $number) { |
2283 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
2283 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
2284 | 2284 | } |
2285 | 2285 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
2286 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
2286 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
2287 | 2287 | foreach ($alldata as $number) { |
2288 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
2288 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
2289 | 2289 | } |
2290 | 2290 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
2291 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
2291 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
2292 | 2292 | foreach ($alldata as $number) { |
2293 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
2293 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
2294 | 2294 | } |
2295 | 2295 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
2296 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
2296 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
2297 | 2297 | foreach ($alldata as $number) { |
2298 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
2298 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
2299 | 2299 | } |
2300 | 2300 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
2301 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
2301 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
2302 | 2302 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
2303 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
2303 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
2304 | 2304 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
2305 | 2305 | //$alldata = array(); |
2306 | 2306 | foreach ($dall as $value) { |
@@ -2320,12 +2320,12 @@ discard block |
||
2320 | 2320 | } |
2321 | 2321 | $alldata = $pall; |
2322 | 2322 | foreach ($alldata as $number) { |
2323 | - 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); |
|
2323 | + 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); |
|
2324 | 2324 | } |
2325 | 2325 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
2326 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
2326 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
2327 | 2327 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
2328 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
2328 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
2329 | 2329 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
2330 | 2330 | //$alldata = array(); |
2331 | 2331 | foreach ($dall as $value) { |
@@ -2345,7 +2345,7 @@ discard block |
||
2345 | 2345 | } |
2346 | 2346 | $alldata = $pall; |
2347 | 2347 | foreach ($alldata as $number) { |
2348 | - 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); |
|
2348 | + 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); |
|
2349 | 2349 | } |
2350 | 2350 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
2351 | 2351 | $Spotter = new Spotter($this->db); |
@@ -2353,27 +2353,27 @@ discard block |
||
2353 | 2353 | $lastyear = false; |
2354 | 2354 | foreach ($alldata as $number) { |
2355 | 2355 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2356 | - $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']); |
|
2356 | + $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']); |
|
2357 | 2357 | } |
2358 | 2358 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
2359 | 2359 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
2360 | 2360 | foreach ($alldata as $number) { |
2361 | - $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']); |
|
2361 | + $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']); |
|
2362 | 2362 | } |
2363 | 2363 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
2364 | 2364 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
2365 | 2365 | foreach ($alldata as $number) { |
2366 | - $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']); |
|
2366 | + $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']); |
|
2367 | 2367 | } |
2368 | 2368 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
2369 | 2369 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
2370 | 2370 | foreach ($alldata as $number) { |
2371 | - $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']); |
|
2371 | + $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']); |
|
2372 | 2372 | } |
2373 | 2373 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
2374 | 2374 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
2375 | 2375 | foreach ($alldata as $number) { |
2376 | - $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']); |
|
2376 | + $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']); |
|
2377 | 2377 | } |
2378 | 2378 | if ($globalDebug) echo '...Departure'."\n"; |
2379 | 2379 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | } |
2397 | 2397 | $alldata = $pall; |
2398 | 2398 | foreach ($alldata as $number) { |
2399 | - $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']); |
|
2399 | + $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']); |
|
2400 | 2400 | } |
2401 | 2401 | if ($globalDebug) echo '...Arrival'."\n"; |
2402 | 2402 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -2419,32 +2419,32 @@ discard block |
||
2419 | 2419 | } |
2420 | 2420 | $alldata = $pall; |
2421 | 2421 | foreach ($alldata as $number) { |
2422 | - $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']); |
|
2422 | + $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']); |
|
2423 | 2423 | } |
2424 | 2424 | |
2425 | 2425 | if ($globalDebug) echo 'Flights data...'."\n"; |
2426 | 2426 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
2427 | 2427 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
2428 | 2428 | foreach ($alldata as $number) { |
2429 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
2429 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
2430 | 2430 | } |
2431 | 2431 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
2432 | 2432 | //$previousdata = $this->countAllDatesByAirlines(); |
2433 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
2433 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
2434 | 2434 | $values = array(); |
2435 | 2435 | foreach ($alldata as $cnt) { |
2436 | 2436 | $values[] = $cnt['date_count']; |
2437 | 2437 | } |
2438 | - array_multisort($values,SORT_DESC,$alldata); |
|
2439 | - array_splice($alldata,11); |
|
2438 | + array_multisort($values, SORT_DESC, $alldata); |
|
2439 | + array_splice($alldata, 11); |
|
2440 | 2440 | foreach ($alldata as $number) { |
2441 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
2441 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
2442 | 2442 | } |
2443 | 2443 | |
2444 | 2444 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
2445 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
2445 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
2446 | 2446 | foreach ($alldata as $number) { |
2447 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
2447 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
2448 | 2448 | } |
2449 | 2449 | |
2450 | 2450 | // Stats by filters |
@@ -2467,7 +2467,7 @@ discard block |
||
2467 | 2467 | $last_update_day = date('Y').'-01-01 00:00:00'; |
2468 | 2468 | } |
2469 | 2469 | } |
2470 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2470 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2471 | 2471 | $last_update_day = date('Y').'-01-01 00:00:00'; |
2472 | 2472 | $reset = true; |
2473 | 2473 | } |
@@ -2476,32 +2476,32 @@ discard block |
||
2476 | 2476 | // Count by filter |
2477 | 2477 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
2478 | 2478 | $Spotter = new Spotter($this->db); |
2479 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
2479 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
2480 | 2480 | foreach ($alldata as $number) { |
2481 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
2481 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
2482 | 2482 | } |
2483 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
2483 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
2484 | 2484 | foreach ($alldata as $number) { |
2485 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
2485 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
2486 | 2486 | } |
2487 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
2487 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
2488 | 2488 | foreach ($alldata as $number) { |
2489 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
2489 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
2490 | 2490 | } |
2491 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
2491 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
2492 | 2492 | foreach ($alldata as $number) { |
2493 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
2493 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
2494 | 2494 | } |
2495 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
2495 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
2496 | 2496 | foreach ($alldata as $number) { |
2497 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
2497 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
2498 | 2498 | } |
2499 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
2499 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
2500 | 2500 | foreach ($alldata as $number) { |
2501 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
2501 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
2502 | 2502 | } |
2503 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
2504 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2503 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
2504 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
2505 | 2505 | $alldata = array(); |
2506 | 2506 | foreach ($pall as $value) { |
2507 | 2507 | $icao = $value['airport_departure_icao']; |
@@ -2517,12 +2517,12 @@ discard block |
||
2517 | 2517 | foreach ($alldata as $key => $row) { |
2518 | 2518 | $count[$key] = $row['airport_departure_icao_count']; |
2519 | 2519 | } |
2520 | - array_multisort($count,SORT_DESC,$alldata); |
|
2520 | + array_multisort($count, SORT_DESC, $alldata); |
|
2521 | 2521 | foreach ($alldata as $number) { |
2522 | - 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); |
|
2522 | + 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); |
|
2523 | 2523 | } |
2524 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2525 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2524 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
2525 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
2526 | 2526 | $alldata = array(); |
2527 | 2527 | foreach ($pall as $value) { |
2528 | 2528 | $icao = $value['airport_arrival_icao']; |
@@ -2538,40 +2538,40 @@ discard block |
||
2538 | 2538 | foreach ($alldata as $key => $row) { |
2539 | 2539 | $count[$key] = $row['airport_arrival_icao_count']; |
2540 | 2540 | } |
2541 | - array_multisort($count,SORT_DESC,$alldata); |
|
2541 | + array_multisort($count, SORT_DESC, $alldata); |
|
2542 | 2542 | foreach ($alldata as $number) { |
2543 | - 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); |
|
2543 | + 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); |
|
2544 | 2544 | } |
2545 | 2545 | $Spotter = new Spotter($this->db); |
2546 | 2546 | $alldata = $Spotter->countAllMonths($filter); |
2547 | 2547 | $lastyear = false; |
2548 | 2548 | foreach ($alldata as $number) { |
2549 | 2549 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2550 | - $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); |
|
2550 | + $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); |
|
2551 | 2551 | } |
2552 | 2552 | $alldata = $Spotter->countAllMonthsOwners($filter); |
2553 | 2553 | foreach ($alldata as $number) { |
2554 | - $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); |
|
2554 | + $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); |
|
2555 | 2555 | } |
2556 | 2556 | $alldata = $Spotter->countAllMonthsPilots($filter); |
2557 | 2557 | foreach ($alldata as $number) { |
2558 | - $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); |
|
2558 | + $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); |
|
2559 | 2559 | } |
2560 | 2560 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
2561 | 2561 | foreach ($alldata as $number) { |
2562 | - $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); |
|
2562 | + $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); |
|
2563 | 2563 | } |
2564 | 2564 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
2565 | 2565 | foreach ($alldata as $number) { |
2566 | - $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); |
|
2566 | + $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); |
|
2567 | 2567 | } |
2568 | 2568 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
2569 | 2569 | foreach ($alldata as $number) { |
2570 | - $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); |
|
2570 | + $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); |
|
2571 | 2571 | } |
2572 | 2572 | echo '...Departure'."\n"; |
2573 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
2574 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2573 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
2574 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
2575 | 2575 | foreach ($dall as $value) { |
2576 | 2576 | $icao = $value['departure_airport_icao']; |
2577 | 2577 | $ddate = $value['date']; |
@@ -2589,11 +2589,11 @@ discard block |
||
2589 | 2589 | } |
2590 | 2590 | $alldata = $pall; |
2591 | 2591 | foreach ($alldata as $number) { |
2592 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
2592 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
2593 | 2593 | } |
2594 | 2594 | echo '...Arrival'."\n"; |
2595 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
2596 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2595 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
2596 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
2597 | 2597 | foreach ($dall as $value) { |
2598 | 2598 | $icao = $value['arrival_airport_icao']; |
2599 | 2599 | $ddate = $value['date']; |
@@ -2611,39 +2611,39 @@ discard block |
||
2611 | 2611 | } |
2612 | 2612 | $alldata = $pall; |
2613 | 2613 | foreach ($alldata as $number) { |
2614 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
2614 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
2615 | 2615 | } |
2616 | 2616 | echo 'Flights data...'."\n"; |
2617 | 2617 | echo '-> countAllDatesLastMonth...'."\n"; |
2618 | 2618 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
2619 | 2619 | foreach ($alldata as $number) { |
2620 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
2620 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2621 | 2621 | } |
2622 | 2622 | echo '-> countAllDates...'."\n"; |
2623 | - $previousdata = $this->countAllDates('',$filter_name); |
|
2624 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
2623 | + $previousdata = $this->countAllDates('', $filter_name); |
|
2624 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
2625 | 2625 | $values = array(); |
2626 | 2626 | foreach ($alldata as $cnt) { |
2627 | 2627 | $values[] = $cnt['date_count']; |
2628 | 2628 | } |
2629 | - array_multisort($values,SORT_DESC,$alldata); |
|
2630 | - array_splice($alldata,11); |
|
2629 | + array_multisort($values, SORT_DESC, $alldata); |
|
2630 | + array_splice($alldata, 11); |
|
2631 | 2631 | foreach ($alldata as $number) { |
2632 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
2632 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2633 | 2633 | } |
2634 | 2634 | |
2635 | 2635 | echo '-> countAllHours...'."\n"; |
2636 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
2636 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
2637 | 2637 | foreach ($alldata as $number) { |
2638 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
2638 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
2639 | 2639 | } |
2640 | 2640 | echo 'Insert last stats update date...'."\n"; |
2641 | 2641 | date_default_timezone_set('UTC'); |
2642 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
2642 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
2643 | 2643 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
2644 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2644 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2645 | 2645 | $this->deleteOldStats($filter_name); |
2646 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
2646 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
2647 | 2647 | } |
2648 | 2648 | } |
2649 | 2649 | } |
@@ -2654,16 +2654,16 @@ discard block |
||
2654 | 2654 | // SUM all previous month to put as year |
2655 | 2655 | $previous_year = date('Y'); |
2656 | 2656 | $previous_year--; |
2657 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2658 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2659 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2660 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2657 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2658 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2659 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2660 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2661 | 2661 | $allairlines = $this->getAllAirlineNames(); |
2662 | 2662 | foreach ($allairlines as $data) { |
2663 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2664 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2665 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2666 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2663 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2664 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2665 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2666 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2667 | 2667 | } |
2668 | 2668 | |
2669 | 2669 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2672,7 +2672,7 @@ discard block |
||
2672 | 2672 | try { |
2673 | 2673 | $sth = $this->db->prepare($query); |
2674 | 2674 | $sth->execute(); |
2675 | - } catch(PDOException $e) { |
|
2675 | + } catch (PDOException $e) { |
|
2676 | 2676 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2677 | 2677 | } |
2678 | 2678 | } |
@@ -2681,15 +2681,15 @@ discard block |
||
2681 | 2681 | try { |
2682 | 2682 | $sth = $this->db->prepare($query); |
2683 | 2683 | $sth->execute(); |
2684 | - } catch(PDOException $e) { |
|
2684 | + } catch (PDOException $e) { |
|
2685 | 2685 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2686 | 2686 | } |
2687 | 2687 | } |
2688 | 2688 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
2689 | 2689 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2690 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
2690 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
2691 | 2691 | $this->deleteOldStats(); |
2692 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
2692 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
2693 | 2693 | $lastyearupdate = true; |
2694 | 2694 | } |
2695 | 2695 | } |
@@ -2711,7 +2711,7 @@ discard block |
||
2711 | 2711 | try { |
2712 | 2712 | $sth = $this->db->prepare($query); |
2713 | 2713 | $sth->execute(); |
2714 | - } catch(PDOException $e) { |
|
2714 | + } catch (PDOException $e) { |
|
2715 | 2715 | return "error : ".$e->getMessage(); |
2716 | 2716 | } |
2717 | 2717 | } |
@@ -2725,14 +2725,14 @@ discard block |
||
2725 | 2725 | try { |
2726 | 2726 | $sth = $this->db->prepare($query); |
2727 | 2727 | $sth->execute(); |
2728 | - } catch(PDOException $e) { |
|
2728 | + } catch (PDOException $e) { |
|
2729 | 2729 | return "error : ".$e->getMessage(); |
2730 | 2730 | } |
2731 | 2731 | } |
2732 | 2732 | if (!isset($lastyearupdate)) { |
2733 | 2733 | echo 'Insert last stats update date...'."\n"; |
2734 | 2734 | date_default_timezone_set('UTC'); |
2735 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2735 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2736 | 2736 | } |
2737 | 2737 | if ($globalStatsResetYear) { |
2738 | 2738 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | $hex = str_replace("#", "", $hex); |
5 | 5 | $color = array(); |
6 | 6 | if (strlen($hex) == 3) { |
7 | - $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | - $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | - $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
7 | + $color['r'] = hexdec(substr($hex, 0, 1).substr($hex, 0, 1)); |
|
8 | + $color['g'] = hexdec(substr($hex, 1, 1).substr($hex, 1, 1)); |
|
9 | + $color['b'] = hexdec(substr($hex, 2, 1).substr($hex, 2, 1)); |
|
10 | 10 | } else if (strlen($hex) == 6) { |
11 | 11 | $color['r'] = hexdec(substr($hex, 0, 2)); |
12 | 12 | $color['g'] = hexdec(substr($hex, 2, 2)); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | |
19 | -if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { |
|
19 | +if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/', $_GET['color'])) { |
|
20 | 20 | exit(0); |
21 | 21 | } |
22 | 22 | $color = $_GET['color']; |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | |
48 | 48 | if (extension_loaded('gd') && function_exists('gd_info')) { |
49 | 49 | $image = imagecreatefrompng($original); |
50 | - $index = imagecolorexact($image,26,49,81); |
|
50 | + $index = imagecolorexact($image, 26, 49, 81); |
|
51 | 51 | if ($index < 0) { |
52 | - $index = imagecolorexact($image,25,49,79); |
|
52 | + $index = imagecolorexact($image, 25, 49, 79); |
|
53 | 53 | } |
54 | 54 | if ($index < 0) { |
55 | - $index = imagecolorexact($image,0,0,0); |
|
55 | + $index = imagecolorexact($image, 0, 0, 0); |
|
56 | 56 | } |
57 | 57 | $c = hexToRGB($color); |
58 | - imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
58 | + imagecolorset($image, $index, $c['r'], $c['g'], $c['b']); |
|
59 | 59 | /* |
60 | 60 | $ig = imagecolorat($image, 0, 0); |
61 | 61 | imagecolortransparent($image, $ig); |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | |
64 | 64 | header('Content-type: image/png'); |
65 | 65 | if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
66 | - $resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT); |
|
67 | - $newimg = imagecreatetruecolor($resize,$resize); |
|
66 | + $resize = filter_input(INPUT_GET, 'resize', FILTER_SANITIZE_NUMBER_INT); |
|
67 | + $newimg = imagecreatetruecolor($resize, $resize); |
|
68 | 68 | imagealphablending($newimg, false); |
69 | 69 | imagesavealpha($newimg, true); |
70 | - imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image)); |
|
70 | + imagecopyresampled($newimg, $image, 0, 0, 0, 0, 15, 15, imagesx($image), imagesy($image)); |
|
71 | 71 | if (isset($_GET['heading'])) { |
72 | - $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
73 | - $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
72 | + $heading = filter_input(INPUT_GET, 'heading', FILTER_SANITIZE_NUMBER_INT); |
|
73 | + $rotation = imagerotate($newimg, $heading, imageColorAllocateAlpha($newimg, 0, 0, 0, 127)); |
|
74 | 74 | imagealphablending($rotation, false); |
75 | 75 | imagesavealpha($rotation, true); |
76 | 76 | imagepng($rotation); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | imagepng($image); |
90 | 90 | imagepng($image); |
91 | 91 | if (is_writable(dirname(__FILE__).'/cache')) { |
92 | - imagepng($image,dirname(__FILE__).'/cache/'.$color.'-'.$filename); |
|
92 | + imagepng($image, dirname(__FILE__).'/cache/'.$color.'-'.$filename); |
|
93 | 93 | } |
94 | 94 | imagedestroy($image); |
95 | 95 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -814,17 +814,17 @@ discard block |
||
814 | 814 | try { |
815 | 815 | $sth = $Connection->db->prepare($query); |
816 | 816 | $sth->execute(); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
819 | 819 | } |
820 | 820 | } |
821 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
821 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
822 | 822 | // Add aircraft_manufacturer to stats_aircraft |
823 | 823 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
824 | 824 | try { |
825 | 825 | $sth = $Connection->db->prepare($query); |
826 | 826 | $sth->execute(); |
827 | - } catch(PDOException $e) { |
|
827 | + } catch (PDOException $e) { |
|
828 | 828 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
829 | 829 | } |
830 | 830 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | try { |
834 | 834 | $sth = $Connection->db->prepare($query); |
835 | 835 | $sth->execute(); |
836 | - } catch(PDOException $e) { |
|
836 | + } catch (PDOException $e) { |
|
837 | 837 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
838 | 838 | } |
839 | 839 | return $error; |
@@ -849,23 +849,23 @@ discard block |
||
849 | 849 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 850 | } |
851 | 851 | if ($error != '') return 'Import airlines.sql : '.$error; |
852 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
852 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
853 | 853 | // Add forsource to airlines |
854 | 854 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
855 | 855 | try { |
856 | 856 | $sth = $Connection->db->prepare($query); |
857 | 857 | $sth->execute(); |
858 | - } catch(PDOException $e) { |
|
858 | + } catch (PDOException $e) { |
|
859 | 859 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
860 | 860 | } |
861 | 861 | } |
862 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
862 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
863 | 863 | // Add forsource to airlines |
864 | 864 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
865 | 865 | try { |
866 | 866 | $sth = $Connection->db->prepare($query); |
867 | 867 | $sth->execute(); |
868 | - } catch(PDOException $e) { |
|
868 | + } catch (PDOException $e) { |
|
869 | 869 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
870 | 870 | } |
871 | 871 | // Add unique key |
@@ -877,17 +877,17 @@ discard block |
||
877 | 877 | try { |
878 | 878 | $sth = $Connection->db->prepare($query); |
879 | 879 | $sth->execute(); |
880 | - } catch(PDOException $e) { |
|
880 | + } catch (PDOException $e) { |
|
881 | 881 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
882 | 882 | } |
883 | 883 | } |
884 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
884 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
885 | 885 | // Add forsource to airlines |
886 | 886 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
887 | 887 | try { |
888 | 888 | $sth = $Connection->db->prepare($query); |
889 | 889 | $sth->execute(); |
890 | - } catch(PDOException $e) { |
|
890 | + } catch (PDOException $e) { |
|
891 | 891 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
892 | 892 | } |
893 | 893 | // Add unique key |
@@ -899,17 +899,17 @@ discard block |
||
899 | 899 | try { |
900 | 900 | $sth = $Connection->db->prepare($query); |
901 | 901 | $sth->execute(); |
902 | - } catch(PDOException $e) { |
|
902 | + } catch (PDOException $e) { |
|
903 | 903 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
904 | 904 | } |
905 | 905 | } |
906 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
906 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
907 | 907 | // Add forsource to airlines |
908 | 908 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
909 | 909 | try { |
910 | 910 | $sth = $Connection->db->prepare($query); |
911 | 911 | $sth->execute(); |
912 | - } catch(PDOException $e) { |
|
912 | + } catch (PDOException $e) { |
|
913 | 913 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
914 | 914 | } |
915 | 915 | // Add unique key |
@@ -921,36 +921,36 @@ discard block |
||
921 | 921 | try { |
922 | 922 | $sth = $Connection->db->prepare($query); |
923 | 923 | $sth->execute(); |
924 | - } catch(PDOException $e) { |
|
924 | + } catch (PDOException $e) { |
|
925 | 925 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
926 | 926 | } |
927 | 927 | } |
928 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
928 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
929 | 929 | // Add forsource to airlines |
930 | 930 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
931 | 931 | try { |
932 | 932 | $sth = $Connection->db->prepare($query); |
933 | 933 | $sth->execute(); |
934 | - } catch(PDOException $e) { |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
936 | 936 | } |
937 | 937 | } |
938 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
938 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
939 | 939 | // Add forsource to airlines |
940 | 940 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
941 | 941 | try { |
942 | 942 | $sth = $Connection->db->prepare($query); |
943 | 943 | $sth->execute(); |
944 | - } catch(PDOException $e) { |
|
944 | + } catch (PDOException $e) { |
|
945 | 945 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
946 | 946 | } |
947 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
947 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
948 | 948 | // Add unique key |
949 | 949 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
950 | 950 | try { |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | 952 | $sth->execute(); |
953 | - } catch(PDOException $e) { |
|
953 | + } catch (PDOException $e) { |
|
954 | 954 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
955 | 955 | } |
956 | 956 | } else { |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | try { |
964 | 964 | $sth = $Connection->db->prepare($query); |
965 | 965 | $sth->execute(); |
966 | - } catch(PDOException $e) { |
|
966 | + } catch (PDOException $e) { |
|
967 | 967 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
968 | 968 | } |
969 | 969 | } |
970 | 970 | } |
971 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
971 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
972 | 972 | // Add forsource to airlines |
973 | 973 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
974 | 974 | try { |
975 | 975 | $sth = $Connection->db->prepare($query); |
976 | 976 | $sth->execute(); |
977 | - } catch(PDOException $e) { |
|
977 | + } catch (PDOException $e) { |
|
978 | 978 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
979 | 979 | } |
980 | 980 | // Add unique key |
@@ -986,17 +986,17 @@ discard block |
||
986 | 986 | try { |
987 | 987 | $sth = $Connection->db->prepare($query); |
988 | 988 | $sth->execute(); |
989 | - } catch(PDOException $e) { |
|
989 | + } catch (PDOException $e) { |
|
990 | 990 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
991 | 991 | } |
992 | 992 | } |
993 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
993 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
994 | 994 | // Add forsource to airlines |
995 | 995 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
996 | 996 | try { |
997 | 997 | $sth = $Connection->db->prepare($query); |
998 | 998 | $sth->execute(); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1001 | 1001 | } |
1002 | 1002 | // Add unique key |
@@ -1008,17 +1008,17 @@ discard block |
||
1008 | 1008 | try { |
1009 | 1009 | $sth = $Connection->db->prepare($query); |
1010 | 1010 | $sth->execute(); |
1011 | - } catch(PDOException $e) { |
|
1011 | + } catch (PDOException $e) { |
|
1012 | 1012 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1013 | 1013 | } |
1014 | 1014 | } |
1015 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1015 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1016 | 1016 | // Add forsource to airlines |
1017 | 1017 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1018 | 1018 | try { |
1019 | 1019 | $sth = $Connection->db->prepare($query); |
1020 | 1020 | $sth->execute(); |
1021 | - } catch(PDOException $e) { |
|
1021 | + } catch (PDOException $e) { |
|
1022 | 1022 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1023 | 1023 | } |
1024 | 1024 | // Add unique key |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | try { |
1031 | 1031 | $sth = $Connection->db->prepare($query); |
1032 | 1032 | $sth->execute(); |
1033 | - } catch(PDOException $e) { |
|
1033 | + } catch (PDOException $e) { |
|
1034 | 1034 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | try { |
1040 | 1040 | $sth = $Connection->db->prepare($query); |
1041 | 1041 | $sth->execute(); |
1042 | - } catch(PDOException $e) { |
|
1042 | + } catch (PDOException $e) { |
|
1043 | 1043 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1044 | 1044 | } |
1045 | 1045 | return $error; |
@@ -1049,13 +1049,13 @@ discard block |
||
1049 | 1049 | global $globalDBdriver; |
1050 | 1050 | $Connection = new Connection(); |
1051 | 1051 | $error = ''; |
1052 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1052 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1053 | 1053 | // Add forsource to airlines |
1054 | 1054 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1055 | 1055 | try { |
1056 | 1056 | $sth = $Connection->db->prepare($query); |
1057 | 1057 | $sth->execute(); |
1058 | - } catch(PDOException $e) { |
|
1058 | + } catch (PDOException $e) { |
|
1059 | 1059 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1060 | 1060 | } |
1061 | 1061 | // Add unique key |
@@ -1067,17 +1067,17 @@ discard block |
||
1067 | 1067 | try { |
1068 | 1068 | $sth = $Connection->db->prepare($query); |
1069 | 1069 | $sth->execute(); |
1070 | - } catch(PDOException $e) { |
|
1070 | + } catch (PDOException $e) { |
|
1071 | 1071 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1074 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1075 | 1075 | // Add forsource to airlines |
1076 | 1076 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1077 | 1077 | try { |
1078 | 1078 | $sth = $Connection->db->prepare($query); |
1079 | 1079 | $sth->execute(); |
1080 | - } catch(PDOException $e) { |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1082 | 1082 | } |
1083 | 1083 | // Add unique key |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | try { |
1090 | 1090 | $sth = $Connection->db->prepare($query); |
1091 | 1091 | $sth->execute(); |
1092 | - } catch(PDOException $e) { |
|
1092 | + } catch (PDOException $e) { |
|
1093 | 1093 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | try { |
1098 | 1098 | $sth = $Connection->db->prepare($query); |
1099 | 1099 | $sth->execute(); |
1100 | - } catch(PDOException $e) { |
|
1100 | + } catch (PDOException $e) { |
|
1101 | 1101 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1102 | 1102 | } |
1103 | 1103 | return $error; |
@@ -1107,12 +1107,12 @@ discard block |
||
1107 | 1107 | global $globalDBdriver; |
1108 | 1108 | $Connection = new Connection(); |
1109 | 1109 | $error = ''; |
1110 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1110 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1111 | 1111 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1112 | 1112 | try { |
1113 | 1113 | $sth = $Connection->db->prepare($query); |
1114 | 1114 | $sth->execute(); |
1115 | - } catch(PDOException $e) { |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | try { |
1121 | 1121 | $sth = $Connection->db->prepare($query); |
1122 | 1122 | $sth->execute(); |
1123 | - } catch(PDOException $e) { |
|
1123 | + } catch (PDOException $e) { |
|
1124 | 1124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1125 | 1125 | } |
1126 | 1126 | return $error; |
@@ -1130,13 +1130,13 @@ discard block |
||
1130 | 1130 | global $globalDBdriver; |
1131 | 1131 | $Connection = new Connection(); |
1132 | 1132 | $error = ''; |
1133 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1133 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1134 | 1134 | // Add forsource to airlines |
1135 | 1135 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1136 | 1136 | try { |
1137 | 1137 | $sth = $Connection->db->prepare($query); |
1138 | 1138 | $sth->execute(); |
1139 | - } catch(PDOException $e) { |
|
1139 | + } catch (PDOException $e) { |
|
1140 | 1140 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1141 | 1141 | } |
1142 | 1142 | // Add unique key |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | try { |
1149 | 1149 | $sth = $Connection->db->prepare($query); |
1150 | 1150 | $sth->execute(); |
1151 | - } catch(PDOException $e) { |
|
1151 | + } catch (PDOException $e) { |
|
1152 | 1152 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | try { |
1157 | 1157 | $sth = $Connection->db->prepare($query); |
1158 | 1158 | $sth->execute(); |
1159 | - } catch(PDOException $e) { |
|
1159 | + } catch (PDOException $e) { |
|
1160 | 1160 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1161 | 1161 | } |
1162 | 1162 | return $error; |
@@ -1166,23 +1166,23 @@ discard block |
||
1166 | 1166 | global $globalDBdriver; |
1167 | 1167 | $Connection = new Connection(); |
1168 | 1168 | $error = ''; |
1169 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1169 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1170 | 1170 | // Add unique key |
1171 | 1171 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1172 | 1172 | try { |
1173 | 1173 | $sth = $Connection->db->prepare($query); |
1174 | 1174 | $sth->execute(); |
1175 | - } catch(PDOException $e) { |
|
1175 | + } catch (PDOException $e) { |
|
1176 | 1176 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1177 | 1177 | } |
1178 | 1178 | } |
1179 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1179 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1180 | 1180 | // Add mfr to aircraft |
1181 | 1181 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1182 | 1182 | try { |
1183 | 1183 | $sth = $Connection->db->prepare($query); |
1184 | 1184 | $sth->execute(); |
1185 | - } catch(PDOException $e) { |
|
1185 | + } catch (PDOException $e) { |
|
1186 | 1186 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1187 | 1187 | } |
1188 | 1188 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | try { |
1199 | 1199 | $sth = $Connection->db->prepare($query); |
1200 | 1200 | $sth->execute(); |
1201 | - } catch(PDOException $e) { |
|
1201 | + } catch (PDOException $e) { |
|
1202 | 1202 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1203 | 1203 | } |
1204 | 1204 | return $error; |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | global $globalDBdriver; |
1209 | 1209 | $Connection = new Connection(); |
1210 | 1210 | $error = ''; |
1211 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1211 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1212 | 1212 | // drop mfr to aircraft |
1213 | 1213 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1214 | 1214 | try { |
1215 | 1215 | $sth = $Connection->db->prepare($query); |
1216 | 1216 | $sth->execute(); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | try { |
1231 | 1231 | $sth = $Connection->db->prepare($query); |
1232 | 1232 | $sth->execute(); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1235 | 1235 | } |
1236 | 1236 | return $error; |
@@ -1240,33 +1240,33 @@ discard block |
||
1240 | 1240 | global $globalDBdriver; |
1241 | 1241 | $Connection = new Connection(); |
1242 | 1242 | $error = ''; |
1243 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1243 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1244 | 1244 | // Add index key |
1245 | 1245 | $query = "create index ref_idx on notam (ref)"; |
1246 | 1246 | try { |
1247 | 1247 | $sth = $Connection->db->prepare($query); |
1248 | 1248 | $sth->execute(); |
1249 | - } catch(PDOException $e) { |
|
1249 | + } catch (PDOException $e) { |
|
1250 | 1250 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1253 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1254 | 1254 | // Add index key |
1255 | 1255 | $query = "create index registration_idx on accidents (registration)"; |
1256 | 1256 | try { |
1257 | 1257 | $sth = $Connection->db->prepare($query); |
1258 | 1258 | $sth->execute(); |
1259 | - } catch(PDOException $e) { |
|
1259 | + } catch (PDOException $e) { |
|
1260 | 1260 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1261 | 1261 | } |
1262 | 1262 | } |
1263 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1263 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1264 | 1264 | // Add index key |
1265 | 1265 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1266 | 1266 | try { |
1267 | 1267 | $sth = $Connection->db->prepare($query); |
1268 | 1268 | $sth->execute(); |
1269 | - } catch(PDOException $e) { |
|
1269 | + } catch (PDOException $e) { |
|
1270 | 1270 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1271 | 1271 | } |
1272 | 1272 | } |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | try { |
1276 | 1276 | $sth = $Connection->db->prepare($query); |
1277 | 1277 | $sth->execute(); |
1278 | - } catch(PDOException $e) { |
|
1278 | + } catch (PDOException $e) { |
|
1279 | 1279 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1280 | 1280 | } |
1281 | 1281 | return $error; |
@@ -1285,23 +1285,23 @@ discard block |
||
1285 | 1285 | global $globalDBdriver; |
1286 | 1286 | $Connection = new Connection(); |
1287 | 1287 | $error = ''; |
1288 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1288 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1289 | 1289 | // Add airline_name to accidents |
1290 | 1290 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1291 | 1291 | try { |
1292 | 1292 | $sth = $Connection->db->prepare($query); |
1293 | 1293 | $sth->execute(); |
1294 | - } catch(PDOException $e) { |
|
1294 | + } catch (PDOException $e) { |
|
1295 | 1295 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1298 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1299 | 1299 | // Add airline_icao to accidents |
1300 | 1300 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1301 | 1301 | try { |
1302 | 1302 | $sth = $Connection->db->prepare($query); |
1303 | 1303 | $sth->execute(); |
1304 | - } catch(PDOException $e) { |
|
1304 | + } catch (PDOException $e) { |
|
1305 | 1305 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1306 | 1306 | } |
1307 | 1307 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | try { |
1310 | 1310 | $sth = $Connection->db->prepare($query); |
1311 | 1311 | $sth->execute(); |
1312 | - } catch(PDOException $e) { |
|
1312 | + } catch (PDOException $e) { |
|
1313 | 1313 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1314 | 1314 | } |
1315 | 1315 | return $error; |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1320 | 1320 | $Connection = new Connection(); |
1321 | 1321 | $error = ''; |
1322 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1322 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1323 | 1323 | // Add alliance to airlines |
1324 | 1324 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1325 | 1325 | try { |
1326 | 1326 | $sth = $Connection->db->prepare($query); |
1327 | 1327 | $sth->execute(); |
1328 | - } catch(PDOException $e) { |
|
1328 | + } catch (PDOException $e) { |
|
1329 | 1329 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | try { |
1353 | 1353 | $sth = $Connection->db->prepare($query); |
1354 | 1354 | $sth->execute(); |
1355 | - } catch(PDOException $e) { |
|
1355 | + } catch (PDOException $e) { |
|
1356 | 1356 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1357 | 1357 | } |
1358 | 1358 | return $error; |
@@ -1362,13 +1362,13 @@ discard block |
||
1362 | 1362 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1363 | 1363 | $Connection = new Connection(); |
1364 | 1364 | $error = ''; |
1365 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1365 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1366 | 1366 | // Add ban_eu to airlines |
1367 | 1367 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1368 | 1368 | try { |
1369 | 1369 | $sth = $Connection->db->prepare($query); |
1370 | 1370 | $sth->execute(); |
1371 | - } catch(PDOException $e) { |
|
1371 | + } catch (PDOException $e) { |
|
1372 | 1372 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1373 | 1373 | } |
1374 | 1374 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | try { |
1377 | 1377 | $sth = $Connection->db->prepare($query); |
1378 | 1378 | $sth->execute(); |
1379 | - } catch(PDOException $e) { |
|
1379 | + } catch (PDOException $e) { |
|
1380 | 1380 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1381 | 1381 | } |
1382 | 1382 | return $error; |
@@ -1387,19 +1387,19 @@ discard block |
||
1387 | 1387 | $Connection = new Connection(); |
1388 | 1388 | $error = ''; |
1389 | 1389 | if ($globalDBdriver == 'mysql') { |
1390 | - if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { |
|
1390 | + if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { |
|
1391 | 1391 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; |
1392 | 1392 | try { |
1393 | 1393 | $sth = $Connection->db->prepare($query); |
1394 | 1394 | $sth->execute(); |
1395 | - } catch(PDOException $e) { |
|
1395 | + } catch (PDOException $e) { |
|
1396 | 1396 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1397 | 1397 | } |
1398 | 1398 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; |
1399 | 1399 | try { |
1400 | 1400 | $sth = $Connection->db->prepare($query); |
1401 | 1401 | $sth->execute(); |
1402 | - } catch(PDOException $e) { |
|
1402 | + } catch (PDOException $e) { |
|
1403 | 1403 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | try { |
1408 | 1408 | $sth = $Connection->db->prepare($query); |
1409 | 1409 | $sth->execute(); |
1410 | - } catch(PDOException $e) { |
|
1410 | + } catch (PDOException $e) { |
|
1411 | 1411 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1412 | 1412 | } |
1413 | 1413 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | try { |
1459 | 1459 | $sth = $Connection->db->prepare($query); |
1460 | 1460 | $sth->execute(); |
1461 | - } catch(PDOException $e) { |
|
1461 | + } catch (PDOException $e) { |
|
1462 | 1462 | return "error (fix date) : ".$e->getMessage()."\n"; |
1463 | 1463 | } |
1464 | 1464 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | try { |
1544 | 1544 | $sth = $Connection->db->prepare($query); |
1545 | 1545 | $sth->execute(); |
1546 | - } catch(PDOException $e) { |
|
1546 | + } catch (PDOException $e) { |
|
1547 | 1547 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1548 | 1548 | } |
1549 | 1549 | return $error; |
@@ -1552,13 +1552,13 @@ discard block |
||
1552 | 1552 | global $globalDBdriver; |
1553 | 1553 | $Connection = new Connection(); |
1554 | 1554 | $error = ''; |
1555 | - if (!$Connection->indexExists('accidents','type')) { |
|
1555 | + if (!$Connection->indexExists('accidents', 'type')) { |
|
1556 | 1556 | // Add index key |
1557 | 1557 | $query = "create index type on accidents (type,date)"; |
1558 | 1558 | try { |
1559 | 1559 | $sth = $Connection->db->prepare($query); |
1560 | 1560 | $sth->execute(); |
1561 | - } catch(PDOException $e) { |
|
1561 | + } catch (PDOException $e) { |
|
1562 | 1562 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1563 | 1563 | } |
1564 | 1564 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | try { |
1567 | 1567 | $sth = $Connection->db->prepare($query); |
1568 | 1568 | $sth->execute(); |
1569 | - } catch(PDOException $e) { |
|
1569 | + } catch (PDOException $e) { |
|
1570 | 1570 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1571 | 1571 | } |
1572 | 1572 | return $error; |
@@ -1576,12 +1576,12 @@ discard block |
||
1576 | 1576 | global $globalDBdriver; |
1577 | 1577 | $Connection = new Connection(); |
1578 | 1578 | $error = ''; |
1579 | - if (!$Connection->checkColumnName('aircraft_modes','source_type')) { |
|
1579 | + if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { |
|
1580 | 1580 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; |
1581 | 1581 | try { |
1582 | 1582 | $sth = $Connection->db->prepare($query); |
1583 | 1583 | $sth->execute(); |
1584 | - } catch(PDOException $e) { |
|
1584 | + } catch (PDOException $e) { |
|
1585 | 1585 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; |
1586 | 1586 | } |
1587 | 1587 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | try { |
1648 | 1648 | $sth = $Connection->db->prepare($query); |
1649 | 1649 | $sth->execute(); |
1650 | - } catch(PDOException $e) { |
|
1650 | + } catch (PDOException $e) { |
|
1651 | 1651 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1652 | 1652 | } |
1653 | 1653 | return $error; |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | try { |
1700 | 1700 | $sth = $Connection->db->prepare($query); |
1701 | 1701 | $sth->execute(); |
1702 | - } catch(PDOException $e) { |
|
1702 | + } catch (PDOException $e) { |
|
1703 | 1703 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
1704 | 1704 | } |
1705 | 1705 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1708,18 +1708,18 @@ discard block |
||
1708 | 1708 | try { |
1709 | 1709 | $sth = $Connection->db->prepare($query); |
1710 | 1710 | $sth->execute(); |
1711 | - } catch(PDOException $e) { |
|
1711 | + } catch (PDOException $e) { |
|
1712 | 1712 | return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n"; |
1713 | 1713 | } |
1714 | 1714 | } |
1715 | 1715 | } |
1716 | - if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
|
1716 | + if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { |
|
1717 | 1717 | // Add index key |
1718 | 1718 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; |
1719 | 1719 | try { |
1720 | 1720 | $sth = $Connection->db->prepare($query); |
1721 | 1721 | $sth->execute(); |
1722 | - } catch(PDOException $e) { |
|
1722 | + } catch (PDOException $e) { |
|
1723 | 1723 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1724 | 1724 | } |
1725 | 1725 | } |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | try { |
1728 | 1728 | $sth = $Connection->db->prepare($query); |
1729 | 1729 | $sth->execute(); |
1730 | - } catch(PDOException $e) { |
|
1730 | + } catch (PDOException $e) { |
|
1731 | 1731 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1732 | 1732 | } |
1733 | 1733 | return $error; |
@@ -1738,148 +1738,148 @@ discard block |
||
1738 | 1738 | $Connection = new Connection(); |
1739 | 1739 | $error = ''; |
1740 | 1740 | if ($globalDBdriver == 'mysql') { |
1741 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1741 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1742 | 1742 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1743 | 1743 | try { |
1744 | 1744 | $sth = $Connection->db->prepare($query); |
1745 | 1745 | $sth->execute(); |
1746 | - } catch(PDOException $e) { |
|
1746 | + } catch (PDOException $e) { |
|
1747 | 1747 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1750 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1751 | 1751 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; |
1752 | 1752 | try { |
1753 | 1753 | $sth = $Connection->db->prepare($query); |
1754 | 1754 | $sth->execute(); |
1755 | - } catch(PDOException $e) { |
|
1755 | + } catch (PDOException $e) { |
|
1756 | 1756 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1757 | 1757 | } |
1758 | 1758 | } |
1759 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1759 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1760 | 1760 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; |
1761 | 1761 | try { |
1762 | 1762 | $sth = $Connection->db->prepare($query); |
1763 | 1763 | $sth->execute(); |
1764 | - } catch(PDOException $e) { |
|
1764 | + } catch (PDOException $e) { |
|
1765 | 1765 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1768 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1769 | 1769 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1770 | 1770 | try { |
1771 | 1771 | $sth = $Connection->db->prepare($query); |
1772 | 1772 | $sth->execute(); |
1773 | - } catch(PDOException $e) { |
|
1773 | + } catch (PDOException $e) { |
|
1774 | 1774 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1775 | 1775 | } |
1776 | 1776 | } |
1777 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1777 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1778 | 1778 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1779 | 1779 | try { |
1780 | 1780 | $sth = $Connection->db->prepare($query); |
1781 | 1781 | $sth->execute(); |
1782 | - } catch(PDOException $e) { |
|
1782 | + } catch (PDOException $e) { |
|
1783 | 1783 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1784 | 1784 | } |
1785 | 1785 | } |
1786 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1786 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1787 | 1787 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; |
1788 | 1788 | try { |
1789 | 1789 | $sth = $Connection->db->prepare($query); |
1790 | 1790 | $sth->execute(); |
1791 | - } catch(PDOException $e) { |
|
1791 | + } catch (PDOException $e) { |
|
1792 | 1792 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1793 | 1793 | } |
1794 | 1794 | } |
1795 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1795 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1796 | 1796 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; |
1797 | 1797 | try { |
1798 | 1798 | $sth = $Connection->db->prepare($query); |
1799 | 1799 | $sth->execute(); |
1800 | - } catch(PDOException $e) { |
|
1800 | + } catch (PDOException $e) { |
|
1801 | 1801 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1802 | 1802 | } |
1803 | 1803 | } |
1804 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1804 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1805 | 1805 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1806 | 1806 | try { |
1807 | 1807 | $sth = $Connection->db->prepare($query); |
1808 | 1808 | $sth->execute(); |
1809 | - } catch(PDOException $e) { |
|
1809 | + } catch (PDOException $e) { |
|
1810 | 1810 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 | } else { |
1814 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1814 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1815 | 1815 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; |
1816 | 1816 | try { |
1817 | 1817 | $sth = $Connection->db->prepare($query); |
1818 | 1818 | $sth->execute(); |
1819 | - } catch(PDOException $e) { |
|
1819 | + } catch (PDOException $e) { |
|
1820 | 1820 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1821 | 1821 | } |
1822 | 1822 | } |
1823 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1823 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1824 | 1824 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; |
1825 | 1825 | try { |
1826 | 1826 | $sth = $Connection->db->prepare($query); |
1827 | 1827 | $sth->execute(); |
1828 | - } catch(PDOException $e) { |
|
1828 | + } catch (PDOException $e) { |
|
1829 | 1829 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1830 | 1830 | } |
1831 | 1831 | } |
1832 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1832 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1833 | 1833 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; |
1834 | 1834 | try { |
1835 | 1835 | $sth = $Connection->db->prepare($query); |
1836 | 1836 | $sth->execute(); |
1837 | - } catch(PDOException $e) { |
|
1837 | + } catch (PDOException $e) { |
|
1838 | 1838 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1839 | 1839 | } |
1840 | 1840 | } |
1841 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1841 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1842 | 1842 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; |
1843 | 1843 | try { |
1844 | 1844 | $sth = $Connection->db->prepare($query); |
1845 | 1845 | $sth->execute(); |
1846 | - } catch(PDOException $e) { |
|
1846 | + } catch (PDOException $e) { |
|
1847 | 1847 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1848 | 1848 | } |
1849 | 1849 | } |
1850 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1850 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1851 | 1851 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; |
1852 | 1852 | try { |
1853 | 1853 | $sth = $Connection->db->prepare($query); |
1854 | 1854 | $sth->execute(); |
1855 | - } catch(PDOException $e) { |
|
1855 | + } catch (PDOException $e) { |
|
1856 | 1856 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1857 | 1857 | } |
1858 | 1858 | } |
1859 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1859 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1860 | 1860 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; |
1861 | 1861 | try { |
1862 | 1862 | $sth = $Connection->db->prepare($query); |
1863 | 1863 | $sth->execute(); |
1864 | - } catch(PDOException $e) { |
|
1864 | + } catch (PDOException $e) { |
|
1865 | 1865 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1866 | 1866 | } |
1867 | 1867 | } |
1868 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1868 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1869 | 1869 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; |
1870 | 1870 | try { |
1871 | 1871 | $sth = $Connection->db->prepare($query); |
1872 | 1872 | $sth->execute(); |
1873 | - } catch(PDOException $e) { |
|
1873 | + } catch (PDOException $e) { |
|
1874 | 1874 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1875 | 1875 | } |
1876 | 1876 | } |
1877 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1877 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1878 | 1878 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; |
1879 | 1879 | try { |
1880 | 1880 | $sth = $Connection->db->prepare($query); |
1881 | 1881 | $sth->execute(); |
1882 | - } catch(PDOException $e) { |
|
1882 | + } catch (PDOException $e) { |
|
1883 | 1883 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1884 | 1884 | } |
1885 | 1885 | } |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | try { |
1889 | 1889 | $sth = $Connection->db->prepare($query); |
1890 | 1890 | $sth->execute(); |
1891 | - } catch(PDOException $e) { |
|
1891 | + } catch (PDOException $e) { |
|
1892 | 1892 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1893 | 1893 | } |
1894 | 1894 | return $error; |
@@ -1903,14 +1903,14 @@ discard block |
||
1903 | 1903 | try { |
1904 | 1904 | $sth = $Connection->db->prepare($query); |
1905 | 1905 | $sth->execute(); |
1906 | - } catch(PDOException $e) { |
|
1906 | + } catch (PDOException $e) { |
|
1907 | 1907 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1908 | 1908 | } |
1909 | 1909 | $query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL"; |
1910 | 1910 | try { |
1911 | 1911 | $sth = $Connection->db->prepare($query); |
1912 | 1912 | $sth->execute(); |
1913 | - } catch(PDOException $e) { |
|
1913 | + } catch (PDOException $e) { |
|
1914 | 1914 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1915 | 1915 | } |
1916 | 1916 | } else { |
@@ -1918,14 +1918,14 @@ discard block |
||
1918 | 1918 | try { |
1919 | 1919 | $sth = $Connection->db->prepare($query); |
1920 | 1920 | $sth->execute(); |
1921 | - } catch(PDOException $e) { |
|
1921 | + } catch (PDOException $e) { |
|
1922 | 1922 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1923 | 1923 | } |
1924 | 1924 | $query = "alter table marine_identity alter column mmsi type varchar(255)"; |
1925 | 1925 | try { |
1926 | 1926 | $sth = $Connection->db->prepare($query); |
1927 | 1927 | $sth->execute(); |
1928 | - } catch(PDOException $e) { |
|
1928 | + } catch (PDOException $e) { |
|
1929 | 1929 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1930 | 1930 | } |
1931 | 1931 | } |
@@ -1933,7 +1933,7 @@ discard block |
||
1933 | 1933 | try { |
1934 | 1934 | $sth = $Connection->db->prepare($query); |
1935 | 1935 | $sth->execute(); |
1936 | - } catch(PDOException $e) { |
|
1936 | + } catch (PDOException $e) { |
|
1937 | 1937 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1938 | 1938 | } |
1939 | 1939 | return $error; |
@@ -1943,32 +1943,32 @@ discard block |
||
1943 | 1943 | global $globalDBdriver; |
1944 | 1944 | $Connection = new Connection(); |
1945 | 1945 | $error = ''; |
1946 | - if (!$Connection->checkColumnName('source_location','last_seen')) { |
|
1946 | + if (!$Connection->checkColumnName('source_location', 'last_seen')) { |
|
1947 | 1947 | $query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL"; |
1948 | 1948 | try { |
1949 | 1949 | $sth = $Connection->db->prepare($query); |
1950 | 1950 | $sth->execute(); |
1951 | - } catch(PDOException $e) { |
|
1951 | + } catch (PDOException $e) { |
|
1952 | 1952 | return "error (add column last_seen in source_location) : ".$e->getMessage()."\n"; |
1953 | 1953 | } |
1954 | 1954 | } |
1955 | 1955 | if ($globalDBdriver == 'mysql') { |
1956 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1956 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1957 | 1957 | $query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL"; |
1958 | 1958 | try { |
1959 | 1959 | $sth = $Connection->db->prepare($query); |
1960 | 1960 | $sth->execute(); |
1961 | - } catch(PDOException $e) { |
|
1961 | + } catch (PDOException $e) { |
|
1962 | 1962 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | } else { |
1966 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1966 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1967 | 1967 | $query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL"; |
1968 | 1968 | try { |
1969 | 1969 | $sth = $Connection->db->prepare($query); |
1970 | 1970 | $sth->execute(); |
1971 | - } catch(PDOException $e) { |
|
1971 | + } catch (PDOException $e) { |
|
1972 | 1972 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1973 | 1973 | } |
1974 | 1974 | } |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | try { |
1978 | 1978 | $sth = $Connection->db->prepare($query); |
1979 | 1979 | $sth->execute(); |
1980 | - } catch(PDOException $e) { |
|
1980 | + } catch (PDOException $e) { |
|
1981 | 1981 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1982 | 1982 | } |
1983 | 1983 | return $error; |
@@ -1987,12 +1987,12 @@ discard block |
||
1987 | 1987 | global $globalDBdriver; |
1988 | 1988 | $Connection = new Connection(); |
1989 | 1989 | $error = ''; |
1990 | - if (!$Connection->checkColumnName('source_location','description')) { |
|
1990 | + if (!$Connection->checkColumnName('source_location', 'description')) { |
|
1991 | 1991 | $query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL"; |
1992 | 1992 | try { |
1993 | 1993 | $sth = $Connection->db->prepare($query); |
1994 | 1994 | $sth->execute(); |
1995 | - } catch(PDOException $e) { |
|
1995 | + } catch (PDOException $e) { |
|
1996 | 1996 | return "error (add column description in source_location) : ".$e->getMessage()."\n"; |
1997 | 1997 | } |
1998 | 1998 | } |
@@ -2000,7 +2000,7 @@ discard block |
||
2000 | 2000 | try { |
2001 | 2001 | $sth = $Connection->db->prepare($query); |
2002 | 2002 | $sth->execute(); |
2003 | - } catch(PDOException $e) { |
|
2003 | + } catch (PDOException $e) { |
|
2004 | 2004 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2005 | 2005 | } |
2006 | 2006 | return $error; |
@@ -2010,39 +2010,39 @@ discard block |
||
2010 | 2010 | global $globalDBdriver; |
2011 | 2011 | $Connection = new Connection(); |
2012 | 2012 | $error = ''; |
2013 | - if (!$Connection->checkColumnName('spotter_live','real_altitude')) { |
|
2013 | + if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) { |
|
2014 | 2014 | $query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL"; |
2015 | 2015 | try { |
2016 | 2016 | $sth = $Connection->db->prepare($query); |
2017 | 2017 | $sth->execute(); |
2018 | - } catch(PDOException $e) { |
|
2018 | + } catch (PDOException $e) { |
|
2019 | 2019 | return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n"; |
2020 | 2020 | } |
2021 | 2021 | } |
2022 | - if (!$Connection->checkColumnName('spotter_output','real_altitude')) { |
|
2022 | + if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) { |
|
2023 | 2023 | $query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2024 | 2024 | try { |
2025 | 2025 | $sth = $Connection->db->prepare($query); |
2026 | 2026 | $sth->execute(); |
2027 | - } catch(PDOException $e) { |
|
2027 | + } catch (PDOException $e) { |
|
2028 | 2028 | return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n"; |
2029 | 2029 | } |
2030 | 2030 | } |
2031 | - if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) { |
|
2031 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) { |
|
2032 | 2032 | $query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2033 | 2033 | try { |
2034 | 2034 | $sth = $Connection->db->prepare($query); |
2035 | 2035 | $sth->execute(); |
2036 | - } catch(PDOException $e) { |
|
2036 | + } catch (PDOException $e) { |
|
2037 | 2037 | return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n"; |
2038 | 2038 | } |
2039 | 2039 | } |
2040 | - if (!$Connection->checkColumnName('spotter_archive','real_altitude')) { |
|
2040 | + if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) { |
|
2041 | 2041 | $query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL"; |
2042 | 2042 | try { |
2043 | 2043 | $sth = $Connection->db->prepare($query); |
2044 | 2044 | $sth->execute(); |
2045 | - } catch(PDOException $e) { |
|
2045 | + } catch (PDOException $e) { |
|
2046 | 2046 | return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n"; |
2047 | 2047 | } |
2048 | 2048 | } |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | try { |
2051 | 2051 | $sth = $Connection->db->prepare($query); |
2052 | 2052 | $sth->execute(); |
2053 | - } catch(PDOException $e) { |
|
2053 | + } catch (PDOException $e) { |
|
2054 | 2054 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2055 | 2055 | } |
2056 | 2056 | return $error; |
@@ -2072,14 +2072,14 @@ discard block |
||
2072 | 2072 | try { |
2073 | 2073 | $sth = $Connection->db->prepare($query); |
2074 | 2074 | $sth->execute(); |
2075 | - } catch(PDOException $e) { |
|
2075 | + } catch (PDOException $e) { |
|
2076 | 2076 | return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n"; |
2077 | 2077 | } |
2078 | 2078 | $query = "UPDATE config SET value = '44' WHERE name = 'schema_version'"; |
2079 | 2079 | try { |
2080 | 2080 | $sth = $Connection->db->prepare($query); |
2081 | 2081 | $sth->execute(); |
2082 | - } catch(PDOException $e) { |
|
2082 | + } catch (PDOException $e) { |
|
2083 | 2083 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2084 | 2084 | } |
2085 | 2085 | return $error; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | 2122 | $sth->execute(); |
2123 | - } catch(PDOException $e) { |
|
2123 | + } catch (PDOException $e) { |
|
2124 | 2124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2125 | 2125 | } |
2126 | 2126 | return $error; |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | try { |
2144 | 2144 | $sth = $Connection->db->prepare($query); |
2145 | 2145 | $sth->execute(); |
2146 | - } catch(PDOException $e) { |
|
2146 | + } catch (PDOException $e) { |
|
2147 | 2147 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2148 | 2148 | } |
2149 | 2149 | return $error; |
@@ -2166,7 +2166,7 @@ discard block |
||
2166 | 2166 | try { |
2167 | 2167 | $sth = $Connection->db->prepare($query); |
2168 | 2168 | $sth->execute(); |
2169 | - } catch(PDOException $e) { |
|
2169 | + } catch (PDOException $e) { |
|
2170 | 2170 | return "error (check_version): ".$e->getMessage()."\n"; |
2171 | 2171 | } |
2172 | 2172 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | if (isset($_POST['pilot'])) |
9 | 9 | { |
10 | - header('Location: '.$globalURL.'/pilot/'.filter_input(INPUT_POST,'pilot',FILTER_SANITIZE_STRING)); |
|
10 | + header('Location: '.$globalURL.'/pilot/'.filter_input(INPUT_POST, 'pilot', FILTER_SANITIZE_STRING)); |
|
11 | 11 | //} else if (isset($_GET['airport'])){ |
12 | 12 | } else { |
13 | - $Spotter= new Spotter(); |
|
13 | + $Spotter = new Spotter(); |
|
14 | 14 | $Stats = new Stats(); |
15 | 15 | $Common = new Common(); |
16 | 16 | $title = _("Pilots"); |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | //ksort($pilot_names); |
25 | 25 | $previous = null; |
26 | 26 | print '<div class="alphabet-legend">'; |
27 | - foreach($pilot_names as $value) { |
|
27 | + foreach ($pilot_names as $value) { |
|
28 | 28 | $firstLetter = strtoupper($Common->replace_mb_substr($value['pilot_name'], 0, 1)); |
29 | - if($previous !== $firstLetter && $firstLetter != "'") |
|
29 | + if ($previous !== $firstLetter && $firstLetter != "'") |
|
30 | 30 | { |
31 | - if ($previous !== null){ |
|
31 | + if ($previous !== null) { |
|
32 | 32 | print ' | '; |
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | } |
38 | 38 | print '</div>'; |
39 | 39 | $previous = null; |
40 | - foreach($pilot_names as $value) { |
|
40 | + foreach ($pilot_names as $value) { |
|
41 | 41 | $firstLetter = strtoupper($Common->replace_mb_substr($value['pilot_name'], 0, 1)); |
42 | 42 | if ($firstLetter != "") |
43 | 43 | { |
44 | - if($previous !== $firstLetter && $firstLetter != "'") |
|
44 | + if ($previous !== $firstLetter && $firstLetter != "'") |
|
45 | 45 | { |
46 | - if ($previous !== null){ |
|
46 | + if ($previous !== null) { |
|
47 | 47 | print '</div>'; |
48 | 48 | } |
49 | 49 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | if (isset($_POST['owner'])) |
9 | 9 | { |
10 | - header('Location: '.$globalURL.'/owner/'.filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING)); |
|
10 | + header('Location: '.$globalURL.'/owner/'.filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING)); |
|
11 | 11 | //} else if (isset($_GET['airport'])){ |
12 | 12 | } else { |
13 | - $Spotter= new Spotter(); |
|
13 | + $Spotter = new Spotter(); |
|
14 | 14 | $Stats = new Stats(); |
15 | 15 | $Common = new Common(); |
16 | 16 | $title = _("Owners"); |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | ksort($owner_names); |
25 | 25 | $previous = null; |
26 | 26 | print '<div class="alphabet-legend">'; |
27 | - foreach($owner_names as $value) { |
|
27 | + foreach ($owner_names as $value) { |
|
28 | 28 | $firstLetter = $Common->remove_accents(strtoupper($Common->replace_mb_substr($value['owner_name'], 0, 1))); |
29 | - if($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
29 | + if ($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
30 | 30 | { |
31 | - if ($previous !== null){ |
|
31 | + if ($previous !== null) { |
|
32 | 32 | print ' | '; |
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | } |
38 | 38 | print '</div>'; |
39 | 39 | $previous = null; |
40 | - foreach($owner_names as $value) { |
|
40 | + foreach ($owner_names as $value) { |
|
41 | 41 | $firstLetter = $Common->remove_accents(strtoupper($Common->replace_mb_substr($value['owner_name'], 0, 1))); |
42 | 42 | if ($firstLetter != "") |
43 | 43 | { |
44 | - if($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
44 | + if ($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
45 | 45 | { |
46 | - if ($previous !== null){ |
|
46 | + if ($previous !== null) { |
|
47 | 47 | print '</div>'; |
48 | 48 | } |
49 | 49 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | * @param String $date get data for a date |
29 | 29 | * @return Array Return Accidents data in array |
30 | 30 | */ |
31 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
31 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
32 | 32 | global $globalURL, $globalDBdriver; |
33 | 33 | $Image = new Image($this->db); |
34 | 34 | $Spotter = new Spotter($this->db); |
35 | 35 | $Translation = new Translation($this->db); |
36 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
36 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
37 | 37 | date_default_timezone_set('UTC'); |
38 | 38 | $result = array(); |
39 | 39 | $limit_query = ''; |
40 | 40 | if ($limit != "") |
41 | 41 | { |
42 | 42 | $limit_array = explode(",", $limit); |
43 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
44 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
43 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
44 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
45 | 45 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
46 | 46 | { |
47 | 47 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | |
51 | 51 | if ($type != '') { |
52 | 52 | if ($date != '') { |
53 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
53 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
54 | 54 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
55 | 55 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
56 | - $query_values = array(':type' => $type,':date' => $date); |
|
57 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
56 | + $query_values = array(':type' => $type, ':date' => $date); |
|
57 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
58 | 58 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
59 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
60 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
59 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
60 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
61 | 61 | if ($globalDBdriver == 'mysql') { |
62 | 62 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
63 | 63 | } else { |
64 | 64 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
65 | 65 | } |
66 | - $query_values = array(':type' => $type,':date' => $date); |
|
66 | + $query_values = array(':type' => $type, ':date' => $date); |
|
67 | 67 | } else { |
68 | 68 | $date = $date.'%'; |
69 | 69 | if ($globalDBdriver == 'mysql') { |
70 | 70 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
71 | - $query_values = array(':type' => $type,':date' => $date); |
|
71 | + $query_values = array(':type' => $type, ':date' => $date); |
|
72 | 72 | } else { |
73 | 73 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
74 | 74 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
75 | - $query_values = array(':type' => $type,':date' => $date); |
|
75 | + $query_values = array(':type' => $type, ':date' => $date); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | } else { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | if ($date != '') { |
85 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
85 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
86 | 86 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
87 | 87 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
88 | 88 | } else { |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | try { |
101 | 101 | $sth = $this->db->prepare($query); |
102 | 102 | $sth->execute($query_values); |
103 | - } catch(PDOException $e) { |
|
103 | + } catch (PDOException $e) { |
|
104 | 104 | echo "error : ".$e->getMessage(); |
105 | 105 | } |
106 | 106 | $i = 0; |
107 | 107 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
108 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
108 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
109 | 109 | $data = array(); |
110 | 110 | if ($row['registration'] != '') { |
111 | 111 | $image_array = $Image->getSpotterImage($row['registration']); |
112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
112 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
113 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
114 | 114 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
115 | 115 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
116 | 116 | if (!empty($aircraft_info)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
119 | 119 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
120 | 120 | } else { |
121 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
121 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
122 | 122 | } |
123 | 123 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
124 | 124 | if (!empty($owner_data)) { |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | $data['aircraft_base'] = $owner_data['base']; |
127 | 127 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
128 | 128 | } |
129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
129 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
130 | 130 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
131 | 131 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
132 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
132 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
133 | 133 | if (isset($identicao[0])) { |
134 | - if (substr($row['ident'],0,2) == 'AF') { |
|
135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
138 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
134 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
135 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
136 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
137 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
138 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
139 | 139 | } else $icao = $row['ident']; |
140 | - $icao = $Translation->checkTranslation($icao,false); |
|
140 | + $icao = $Translation->checkTranslation($icao, false); |
|
141 | 141 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
142 | 142 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
143 | 143 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | if (!empty($airline_info)) { |
147 | 147 | //echo 'data found !'."\n"; |
148 | 148 | //print_r($airline_info); |
149 | - $data = array_merge($data,$airline_info); |
|
149 | + $data = array_merge($data, $airline_info); |
|
150 | 150 | } |
151 | 151 | //else echo 'No data...'."\n"; |
152 | 152 | } |
153 | - $data = array_merge($row,$data); |
|
153 | + $data = array_merge($row, $data); |
|
154 | 154 | if ($data['ident'] == null) $data['ident'] = $icao; |
155 | 155 | if ($data['title'] == null) { |
156 | 156 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
157 | 157 | } else $data['message'] = strtolower($data['title']); |
158 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
158 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
159 | 159 | $date = $data['date']; |
160 | 160 | if (isset($ids[$date])) { |
161 | 161 | $data['spotted'] = TRUE; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | try { |
188 | 188 | $sth = $this->db->prepare($query); |
189 | 189 | $sth->execute(); |
190 | - } catch(PDOException $e) { |
|
190 | + } catch (PDOException $e) { |
|
191 | 191 | echo "Error : ".$e->getMessage(); |
192 | 192 | } |
193 | 193 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | try { |
208 | 208 | $sth = $this->db->prepare($query); |
209 | 209 | $sth->execute(); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | echo "Error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | if ($globalDebug) echo 'Import '.$file."\n"; |
223 | 223 | $result = array(); |
224 | 224 | if (file_exists($file)) { |
225 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
226 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
225 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
226 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
227 | 227 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
228 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
228 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | fclose($handle); |
232 | 232 | } |
233 | - if (!empty($result)) $this->add($result,true); |
|
233 | + if (!empty($result)) $this->add($result, true); |
|
234 | 234 | elseif ($globalDebug) echo 'Nothing to import'; |
235 | 235 | } |
236 | 236 | } |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | $all_md5_new = array(); |
247 | 247 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
248 | 248 | if ($this->check_accidents_nb() > 0) { |
249 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
250 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
249 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
250 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
251 | 251 | if (isset($data[1])) { |
252 | 252 | $year = $data[0]; |
253 | 253 | $all_md5[$year] = $data[1]; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
260 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
261 | 261 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
262 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
263 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
262 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
263 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
264 | 264 | if (isset($data[1])) { |
265 | 265 | $year = $data[0]; |
266 | 266 | $all_md5_new[$year] = $data[1]; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | fclose($handle); |
270 | 270 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
271 | 271 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
272 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
272 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
273 | 273 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
274 | 274 | foreach ($result as $file => $md5) { |
275 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
275 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
276 | 276 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
277 | 277 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * Add data to DB |
283 | 283 | * @param Array $crash An array with accidents/incidents data |
284 | 284 | */ |
285 | - public function add($crash,$new = false) { |
|
285 | + public function add($crash, $new = false) { |
|
286 | 286 | global $globalTransaction, $globalDebug; |
287 | 287 | require_once('class.Connection.php'); |
288 | 288 | require_once('class.Image.php'); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $sthd->execute(array(':source' => $crash[0]['source'])); |
299 | 299 | } |
300 | 300 | if ($globalTransaction) $Connection->db->beginTransaction(); |
301 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
301 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
302 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
303 | 303 | $sth_check = $Connection->db->prepare($query_check); |
304 | 304 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -311,15 +311,15 @@ discard block |
||
311 | 311 | $cr = array_map(function($value) { |
312 | 312 | return $value === "" ? NULL : $value; |
313 | 313 | }, $cr); |
314 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
316 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
314 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
315 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
316 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
317 | 317 | $sth_check->execute($query_check_values); |
318 | 318 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
319 | 319 | if ($result_check['nb'] == 0) { |
320 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
320 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
321 | 321 | $sth->execute($query_values); |
322 | - if ($cr['date'] > time()-(30*86400)) { |
|
322 | + if ($cr['date'] > time() - (30*86400)) { |
|
323 | 323 | if (empty($Image->getSpotterImage($cr['registration']))) { |
324 | 324 | if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
325 | 325 | $Image->addSpotterImage($cr['registration']); |
@@ -328,16 +328,16 @@ discard block |
||
328 | 328 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
329 | 329 | } |
330 | 330 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
331 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
331 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
332 | 332 | } |
333 | 333 | } |
334 | - if ($globalTransaction && $j % 1000 == 0) { |
|
334 | + if ($globalTransaction && $j%1000 == 0) { |
|
335 | 335 | $Connection->db->commit(); |
336 | 336 | $Connection->db->beginTransaction(); |
337 | 337 | } |
338 | 338 | } |
339 | 339 | if ($globalTransaction) $Connection->db->commit(); |
340 | - } catch(PDOException $e) { |
|
340 | + } catch (PDOException $e) { |
|
341 | 341 | if ($globalTransaction) $Connection->db->rollBack(); |
342 | 342 | echo $e->getMessage(); |
343 | 343 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $Connection = new Connection(); |
356 | 356 | $sth = $Connection->db->prepare($query); |
357 | 357 | $sth->execute(); |
358 | - } catch(PDOException $e) { |
|
358 | + } catch (PDOException $e) { |
|
359 | 359 | return "error : ".$e->getMessage(); |
360 | 360 | } |
361 | 361 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $Connection = new Connection(); |
374 | 374 | $sth = $Connection->db->prepare($query); |
375 | 375 | $sth->execute(); |
376 | - } catch(PDOException $e) { |
|
376 | + } catch (PDOException $e) { |
|
377 | 377 | return "error : ".$e->getMessage(); |
378 | 378 | } |
379 | 379 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $Connection = new Connection(); |
389 | 389 | $sth = $Connection->db->prepare($query); |
390 | 390 | $sth->execute(); |
391 | - } catch(PDOException $e) { |
|
391 | + } catch (PDOException $e) { |
|
392 | 392 | return "error : ".$e->getMessage(); |
393 | 393 | } |
394 | 394 | } |