Completed
Push — master ( d2633e...078d82 )
by Yannick
06:44
created
scripts/daemon-spotter.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -112,34 +112,34 @@  discard block
 block discarded – undo
112 112
 
113 113
 function connect_all($hosts) {
114 114
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
115
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
115
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
141 141
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
142
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
143 143
         	//$formats[$id] = 'radarvirtueljson';
144 144
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 145
         	//$last_exec['radarvirtueljson'] = 0;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 149
         	    exit(0);
150 150
         	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
151
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
152 152
         	//$formats[$id] = 'planeupdatefaa';
153 153
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 154
         	//$last_exec['planeupdatefaa'] = 0;
@@ -157,26 +157,26 @@  discard block
 block discarded – undo
157 157
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 158
         	    exit(0);
159 159
         	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
160
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
161 161
         	//$formats[$id] = 'phpvmacars';
162 162
         	$globalSources[$id]['format'] = 'phpvmacars';
163 163
         	//$last_exec['phpvmacars'] = 0;
164 164
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
165
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'vam';
168 168
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
169
+            } else if (preg_match('/whazzup/i', $host)) {
170 170
         	//$formats[$id] = 'whazzup';
171 171
         	$globalSources[$id]['format'] = 'whazzup';
172 172
         	//$last_exec['whazzup'] = 0;
173 173
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
174
+            } else if (preg_match('/recentpireps/i', $host)) {
175 175
         	//$formats[$id] = 'pirepsjson';
176 176
         	$globalSources[$id]['format'] = 'pirepsjson';
177 177
         	//$last_exec['pirepsjson'] = 0;
178 178
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
179
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
180 180
         	//$formats[$id] = 'fr24json';
181 181
         	$globalSources[$id]['format'] = 'fr24json';
182 182
         	//$last_exec['fr24json'] = 0;
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
         	    exit(0);
187 187
         	}
188 188
             //} else if (preg_match('/10001/',$host)) {
189
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
189
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
190 190
         	//$formats[$id] = 'tsv';
191 191
         	$globalSources[$id]['format'] = 'tsv';
192 192
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
193 193
             }
194
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
194
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
195 195
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
196
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
197
-	    $hostport = explode(':',$host);
196
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
197
+	    $hostport = explode(':', $host);
198 198
 	    if (isset($hostport[1])) {
199 199
 		$port = $hostport[1];
200 200
 		$hostn = $hostport[0];
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 		$hostn = $globalSources[$id]['host'];
204 204
 	    }
205 205
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
206
-        	$s = create_socket($hostn,$port, $errno, $errstr);
206
+        	$s = create_socket($hostn, $port, $errno, $errstr);
207 207
     	    } else {
208
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
209 209
 	    }
210 210
 	    if ($s) {
211 211
     	        $sockets[$id] = $s;
212 212
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
213
-		    if (preg_match('/aprs/',$hostn)) {
213
+		    if (preg_match('/aprs/', $hostn)) {
214 214
 			//$formats[$id] = 'aprs';
215 215
 			$globalSources[$id]['format'] = 'aprs';
216 216
 			//$aprs_connect = 0;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
252 252
 else $timeout = 20;
253 253
 $errno = '';
254
-$errstr='';
254
+$errstr = '';
255 255
 
256 256
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
257 257
 /* Initiate connections to all the hosts simultaneously */
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
 if ($use_aprs) {
282 282
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
283
-	$APRS=new APRS();
283
+	$APRS = new APRS();
284 284
 	$aprs_connect = 0;
285 285
 	$aprs_keep = 120;
286 286
 	$aprs_last_tx = time();
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	else $aprs_ssid = 'FAM';
292 292
 	//else $aprs_ssid = 'PerlEx';
293 293
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
294
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295 295
 	if ($aprs_full) $aprs_filter = '';
296 296
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
297 297
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 sleep(1);
303 303
 if ($globalDebug) echo "SCAN MODE \n\n";
304 304
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
305
-$endtime = time()+$globalCronEnd;
305
+$endtime = time() + $globalCronEnd;
306 306
 $i = 1;
307 307
 $tt = array();
308 308
 // Delete all ATC
309 309
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
310
-	$ATC=new ATC($Connection->db);
310
+	$ATC = new ATC($Connection->db);
311 311
 }
312 312
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
313 313
 	$ATC->deleteAll();
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
317 317
 while ($i > 0) {
318
-    if (!$globalDaemon) $i = $endtime-time();
318
+    if (!$globalDaemon) $i = $endtime - time();
319 319
     // Delete old ATC
320 320
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
321 321
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 	if ($max != $globalMinFetch) {
331 331
 	    if ($globalDebug) echo 'Sleeping...'."\n";
332
-	    sleep($globalMinFetch-$max+2);
332
+	    sleep($globalMinFetch - $max + 2);
333 333
 	}
334 334
     }
335 335
 
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
341 341
 	    //$buffer = $Common->getData($hosts[$id]);
342 342
 	    $buffer = $Common->getData($value['host']);
343
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
344
-	    $buffer = explode('\n',$buffer);
343
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
344
+	    $buffer = explode('\n', $buffer);
345 345
 	    foreach ($buffer as $line) {
346 346
     		if ($line != '' && count($line) > 7) {
347 347
     		    $line = explode(',', $line);
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
371 371
 	    //$buffer = $Common->getData($hosts[$id]);
372 372
 	    $buffer = $Common->getData($value['host']);
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
373
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
374
+	    $buffer = explode('\n', $buffer);
375 375
 	    foreach ($buffer as $line) {
376 376
     		if ($line != '') {
377 377
     		    $line = explode(':', $line);
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			$data['id'] = $line[1].'-'.$line[0];
381 381
 			$data['pilot_id'] = $line[1];
382 382
 			$data['pilot_name'] = $line[2];
383
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
383
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
384 384
 			$data['ident'] = $line[0]; // ident
385 385
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
386 386
 			$data['speed'] = $line[8]; // speed
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
397 397
 			if (isset($line[37])) $data['last_update'] = $line[37];
398 398
 		        $data['departure_airport_icao'] = $line[11];
399
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
399
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
400 400
 		        $data['arrival_airport_icao'] = $line[13];
401 401
 			$data['frequency'] = $line[4];
402 402
 			$data['type'] = $line[18];
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     			$data['id_source'] = $id_source;
406 406
 	    		//$data['arrival_airport_time'] = ;
407 407
 	    		if ($line[9] != '') {
408
-	    		    $aircraft_data = explode('/',$line[9]);
408
+	    		    $aircraft_data = explode('/', $line[9]);
409 409
 	    		    if (isset($aircraft_data[1])) {
410 410
 	    			$data['aircraft_icao'] = $aircraft_data[1];
411 411
 	    		    }
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
     			if ($line[3] == 'PILOT') $SI->add($data);
420 420
 			elseif ($line[3] == 'ATC') {
421 421
 				//print_r($data);
422
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
423
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
424
-				$typec = substr($data['ident'],-3);
422
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
423
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
424
+				$typec = substr($data['ident'], -3);
425 425
 				if ($typec == 'APP') $data['type'] = 'Approach';
426 426
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
427 427
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
433 433
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
434 434
 				if (!isset($data['source_name'])) $data['source_name'] = '';
435
-				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']);
435
+				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']);
436 436
 			}
437 437
     			unset($data);
438 438
     		    }
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
     	    $last_exec[$id]['last'] = time();
444 444
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
445 445
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
446
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
446
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
447 447
 	    if ($buffer != '') {
448
-	    $all_data = json_decode($buffer,true);
448
+	    $all_data = json_decode($buffer, true);
449 449
 	    if (isset($all_data['acList'])) {
450 450
 		foreach ($all_data['acList'] as $line) {
451 451
 		    $data = array();
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
500 500
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
501 501
 	    $buffer = $Common->getData($value['host']);
502
-	    $all_data = json_decode($buffer,true);
502
+	    $all_data = json_decode($buffer, true);
503 503
 	    if (isset($all_data['planes'])) {
504 504
 		foreach ($all_data['planes'] as $key => $line) {
505 505
 		    $data = array();
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 		    $data['emergency'] = ''; // emergency
516 516
 		    $data['registration'] = $line[2];
517 517
 		    $data['aircraft_icao'] = $line[0];
518
-		    $deparr = explode('-',$line[1]);
518
+		    $deparr = explode('-', $line[1]);
519 519
 		    if (count($deparr) == 2) {
520 520
 			$data['departure_airport_icao'] = $deparr[0];
521 521
 			$data['arrival_airport_icao'] = $deparr[1];
522 522
 		    }
523
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
523
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
524 524
 	    	    $data['format_source'] = 'planeupdatefaa';
525 525
     		    $data['id_source'] = $id_source;
526 526
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     	    $last_exec[$id]['last'] = time();
533 533
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
534 534
 	    $buffer = $Common->getData($value['host']);
535
-	    $all_data = json_decode($buffer,true);
535
+	    $all_data = json_decode($buffer, true);
536 536
 	    if (isset($all_data['states'])) {
537 537
 		foreach ($all_data['states'] as $key => $line) {
538 538
 		    $data = array();
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		    //$data['emergency'] = ''; // emergency
549 549
 		    //$data['registration'] = $line[2];
550 550
 		    //$data['aircraft_icao'] = $line[0];
551
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
551
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
552 552
 	    	    $data['format_source'] = 'opensky';
553 553
     		    $data['id_source'] = $id_source;
554 554
 		    $SI->add($data);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
562 562
 	    //$buffer = $Common->getData($hosts[$id]);
563 563
 	    $buffer = $Common->getData($value['host']);
564
-	    $all_data = json_decode($buffer,true);
564
+	    $all_data = json_decode($buffer, true);
565 565
 	    foreach ($all_data as $key => $line) {
566 566
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
567 567
 		    $data = array();
@@ -592,11 +592,11 @@  discard block
 block discarded – undo
592 592
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
593 593
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
594 594
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
595
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
595
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
596 596
 	    //echo $buffer;
597
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
598
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
599
-	    $all_data = json_decode($buffer,true);
597
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
598
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
599
+	    $all_data = json_decode($buffer, true);
600 600
 	    if (json_last_error() != JSON_ERROR_NONE) {
601 601
 		die(json_last_error_msg());
602 602
 	    }
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 			//$data['departure_airport_iata'] = $line[11];
619 619
 			//$data['arrival_airport_iata'] = $line[12];
620 620
 	    		//$data['emergency'] = ''; // emergency
621
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
621
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
622 622
 	    		$data['format_source'] = 'radarvirtueljson';
623 623
     			$data['id_source'] = $id_source;
624 624
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -633,13 +633,13 @@  discard block
 block discarded – undo
633 633
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
634 634
 	    //$buffer = $Common->getData($hosts[$id]);
635 635
 	    $buffer = $Common->getData($value['host'].'?'.time());
636
-	    $all_data = json_decode(utf8_encode($buffer),true);
636
+	    $all_data = json_decode(utf8_encode($buffer), true);
637 637
 	    
638 638
 	    if (isset($all_data['pireps'])) {
639 639
 	        foreach ($all_data['pireps'] as $line) {
640 640
 		    $data = array();
641 641
 		    $data['id'] = $line['id'];
642
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
642
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
643 643
 		    $data['ident'] = $line['callsign']; // ident
644 644
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
645 645
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
 			$SI->add($data);
669 669
 		    //    print_r($data);
670 670
     		    } elseif ($line['icon'] == 'ct') {
671
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
672
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
673
-			$typec = substr($data['ident'],-3);
671
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
672
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
673
+			$typec = substr($data['ident'], -3);
674 674
 			$data['type'] = '';
675 675
 			if ($typec == 'APP') $data['type'] = 'Approach';
676 676
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
682 682
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
683 683
 			else $data['type'] = 'Observer';
684
-			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']);
684
+			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']);
685 685
 		    }
686 686
 		    unset($data);
687 687
 		}
@@ -693,13 +693,13 @@  discard block
 block discarded – undo
693 693
 	    //$buffer = $Common->getData($hosts[$id]);
694 694
 	    if ($globalDebug) echo 'Get Data...'."\n";
695 695
 	    $buffer = $Common->getData($value['host']);
696
-	    $all_data = json_decode($buffer,true);
696
+	    $all_data = json_decode($buffer, true);
697 697
 	    if ($buffer != '' && is_array($all_data)) {
698 698
 		foreach ($all_data as $line) {
699 699
 	    	    $data = array();
700 700
 	    	    //$data['id'] = $line['id']; // id not usable
701 701
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
702
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
702
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
703 703
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
704 704
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
705 705
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -722,12 +722,12 @@  discard block
 block discarded – undo
722 722
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
723 723
 		    if (isset($line['aircraftname'])) {
724 724
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
725
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
726
-	    		$aircraft_data = explode('-',$line['aircraftname']);
725
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
726
+	    		$aircraft_data = explode('-', $line['aircraftname']);
727 727
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
728 728
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
729 729
 	    		else {
730
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
730
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
731 731
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
732 732
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
733 733
 	    		}
@@ -749,13 +749,13 @@  discard block
 block discarded – undo
749 749
 	    //$buffer = $Common->getData($hosts[$id]);
750 750
 	    if ($globalDebug) echo 'Get Data...'."\n";
751 751
 	    $buffer = $Common->getData($value['host']);
752
-	    $all_data = json_decode($buffer,true);
752
+	    $all_data = json_decode($buffer, true);
753 753
 	    if ($buffer != '' && is_array($all_data)) {
754 754
 		foreach ($all_data as $line) {
755 755
 	    	    $data = array();
756 756
 	    	    //$data['id'] = $line['id']; // id not usable
757 757
 	    	    $data['id'] = trim($line['flight_id']);
758
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
758
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
759 759
 	    	    $data['pilot_name'] = $line['pilot_name'];
760 760
 	    	    $data['pilot_id'] = $line['pilot_id'];
761 761
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -805,9 +805,9 @@  discard block
 block discarded – undo
805 805
 		    //$value = $formats[$nb];
806 806
 		    $format = $globalSources[$nb]['format'];
807 807
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
808
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
808
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
809 809
         	    } else {
810
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
810
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
811 811
 	    	    }
812 812
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
813 813
         	    //echo $buffer."\n";
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
816 816
 		    $error = false;
817 817
 		    //$SI::del();
818
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
818
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
819 819
 		    // SBS format is CSV format
820 820
 		    if ($buffer != '') {
821 821
 			$tt[$format] = 0;
@@ -836,10 +836,10 @@  discard block
 block discarded – undo
836 836
                         } elseif ($format == 'flightgearsp') {
837 837
                     	    //echo $buffer."\n";
838 838
                     	    if (strlen($buffer) > 5) {
839
-				$line = explode(',',$buffer);
839
+				$line = explode(',', $buffer);
840 840
 				$data = array();
841 841
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
842
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
842
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
843 843
 				$data['ident'] = $line[6];
844 844
 				$data['aircraft_name'] = $line[7];
845 845
 				$data['longitude'] = $line[1];
@@ -850,21 +850,21 @@  discard block
 block discarded – undo
850 850
 				$data['datetime'] = date('Y-m-d H:i:s');
851 851
 				$data['format_source'] = 'flightgearsp';
852 852
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
853
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
853
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
854 854
 			    }
855 855
                         } elseif ($format == 'acars') {
856 856
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
857 857
 			    $ACARS->add(trim($buffer));
858
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
858
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
859 859
 			    $ACARS->deleteLiveAcarsData();
860 860
 			} elseif ($format == 'flightgearmp') {
861
-			    if (substr($buffer,0,1) != '#') {
861
+			    if (substr($buffer, 0, 1) != '#') {
862 862
 				$data = array();
863 863
 				//echo $buffer."\n";
864
-				$line = explode(' ',$buffer);
864
+				$line = explode(' ', $buffer);
865 865
 				if (count($line) == 11) {
866
-				    $userserver = explode('@',$line[0]);
867
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
866
+				    $userserver = explode('@', $line[0]);
867
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
868 868
 				    $data['ident'] = $userserver[0];
869 869
 				    $data['registration'] = $userserver[0];
870 870
 				    $data['latitude'] = $line[4];
@@ -872,24 +872,24 @@  discard block
 block discarded – undo
872 872
 				    $data['altitude'] = $line[6];
873 873
 				    $data['datetime'] = date('Y-m-d H:i:s');
874 874
 				    $aircraft_type = $line[10];
875
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
876
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
875
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
876
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
877 877
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
878 878
 				}
879 879
 			    }
880 880
 			} elseif ($format == 'beast') {
881 881
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
882 882
 			    die;
883
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
883
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
884 884
 			    $line = explode("\t", $buffer);
885
-			    for($k = 0; $k < count($line); $k=$k+2) {
885
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
886 886
 				$key = $line[$k];
887
-			        $lined[$key] = $line[$k+1];
887
+			        $lined[$key] = $line[$k + 1];
888 888
 			    }
889 889
     			    if (count($lined) > 3) {
890 890
     				$data['hex'] = $lined['hexid'];
891 891
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
892
-    				$data['datetime'] = date('Y-m-d H:i:s');;
892
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
893 893
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
894 894
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
895 895
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -907,24 +907,24 @@  discard block
 block discarded – undo
907 907
     			    } else $error = true;
908 908
 			} elseif ($format == 'aprs' && $use_aprs) {
909 909
 			    if ($aprs_connect == 0) {
910
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
910
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
911 911
 				$aprs_connect = 1;
912 912
 			    }
913
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
913
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
914 914
 				$aprs_last_tx = time();
915 915
 				$data_aprs = "# Keep alive";
916
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
916
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
917 917
 			    }
918 918
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
919
-			    $buffer = str_replace('APRS <- ','',$buffer);
920
-			    $buffer = str_replace('APRS -> ','',$buffer);
921
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
919
+			    $buffer = str_replace('APRS <- ', '', $buffer);
920
+			    $buffer = str_replace('APRS -> ', '', $buffer);
921
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
922 922
 				$line = $APRS->parse($buffer);
923 923
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
924 924
 				    $data = array();
925 925
 				    //print_r($line);
926 926
 				    $data['hex'] = $line['address'];
927
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
927
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
928 928
 				    //$data['datetime'] = date('Y-m-d H:i:s');
929 929
 				    $data['ident'] = $line['ident'];
930 930
 				    $data['latitude'] = $line['latitude'];
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 				    $currentdate = date('Y-m-d H:i:s');
945 945
 				    $aprsdate = strtotime($data['datetime']);
946 946
 				    // Accept data if time <= system time + 20s
947
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
947
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
948 948
 				    else {
949 949
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
950 950
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 				connect_all($sourceee);
1030 1030
 				$sourceee = array();
1031 1031
 				//connect_all($globalSources);
1032
-				$tt[$format]=0;
1032
+				$tt[$format] = 0;
1033 1033
 				break;
1034 1034
 			    }
1035 1035
 			}
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 		}
1038 1038
 	    } else {
1039 1039
 		$error = socket_strerror(socket_last_error());
1040
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1040
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1041 1041
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1042 1042
 			if (isset($globalDebug)) echo "Restarting...\n";
1043 1043
 			// Restart the script if possible
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 			    if ($globalDebug) echo "Shutdown all sockets...";
1046 1046
 			    
1047 1047
 			    foreach ($sockets as $sock) {
1048
-				@socket_shutdown($sock,2);
1048
+				@socket_shutdown($sock, 2);
1049 1049
 				@socket_close($sock);
1050 1050
 			    }
1051 1051
 			    
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 		    try {
1145 1145
             		$sth = $Connection->db->prepare($query);
1146 1146
 		        $sth->execute();
1147
-		    } catch(PDOException $e) {
1147
+		    } catch (PDOException $e) {
1148 1148
 			return "error : ".$e->getMessage()."\n";
1149 1149
     		    }
1150 1150
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
route-detailed.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 
6
-if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])){
6
+if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])) {
7 7
 	header('Location: '.$globalURL.'');
8 8
 } else {
9 9
 	$Spotter = new Spotter();
10 10
 	//calculuation for the pagination
11
-	if(!isset($_GET['limit']))
11
+	if (!isset($_GET['limit']))
12 12
 	{
13 13
 		$limit_start = 0;
14 14
 		$limit_end = 25;
15 15
 		$absolute_difference = 25;
16
-	}  else {
16
+	} else {
17 17
 		$limit_explode = explode(",", $_GET['limit']);
18 18
 		$limit_start = $limit_explode[0];
19 19
 		$limit_end = $limit_explode[1];
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	$limit_previous_1 = $limit_start - $absolute_difference;
28 28
 	$limit_previous_2 = $limit_end - $absolute_difference;
29 29
 	
30
-	$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
31
-	$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
30
+	$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING);
31
+	$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING);
32 32
 	$page_url = $globalURL.'/route/'.$departure_airport.'/'.$arrival_airport;
33 33
 	if (isset($_GET['sort'])) {
34 34
 		$spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, $limit_start.",".$absolute_difference, $_GET['sort']);
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  
39 39
 	if (!empty($spotter_array))
40 40
 	{
41
-		$title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
41
+		$title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']);
42 42
 		require_once('header.php');
43 43
 		print '<div class="info column">';
44 44
 		print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 		include('route-sub-menu.php');
50 50
 		print '<div class="table column">';
51
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."),$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['arrival_airport_icao']).'</p>';
51
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."), $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['arrival_airport_icao']).'</p>';
52 52
     
53 53
 		include('table-output.php'); 
54 54
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Spacing   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -46,43 +46,43 @@  discard block
 block discarded – undo
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
48 48
                         $sth->execute(array(':filter_name' => $filter_name));
49
-                } catch(PDOException $e) {
49
+                } catch (PDOException $e) {
50 50
                         echo "error : ".$e->getMessage();
51 51
                 }
52 52
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
53 53
                 return $all;
54 54
         }
55
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
55
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
56 56
 		if ($filter_name == '') $filter_name = $this->filter_name;
57 57
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58 58
                  try {
59 59
                         $sth = $this->db->prepare($query);
60
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
61
-                } catch(PDOException $e) {
60
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
61
+                } catch (PDOException $e) {
62 62
                         echo "error : ".$e->getMessage();
63 63
                 }
64 64
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
65 65
                 return $all;
66 66
         }
67
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
67
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
68 68
 		if ($filter_name == '') $filter_name = $this->filter_name;
69 69
                 $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";
70 70
                  try {
71 71
                         $sth = $this->db->prepare($query);
72
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
73
-                } catch(PDOException $e) {
72
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
73
+                } catch (PDOException $e) {
74 74
                         echo "error : ".$e->getMessage();
75 75
                 }
76 76
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
77 77
                 return $all;
78 78
         }
79
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
79
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81 81
                 $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";
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
84
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
98 98
                  try {
99 99
                         $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
100
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
101
+                } catch (PDOException $e) {
102 102
                         echo "error : ".$e->getMessage();
103 103
                 }
104 104
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
                 if (empty($all)) {
106 106
             	    $filters = array('airlines' => array($stats_airline));
107 107
             	    if ($filter_name != '') {
108
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
108
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
109 109
             	    }
110 110
             	    $Spotter = new Spotter($this->db);
111
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
111
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
112 112
                 }
113 113
                 return $all;
114 114
 	}
115
-	public function countAllAirlineCountries($limit = true,$filter_name = '') {
115
+	public function countAllAirlineCountries($limit = true, $filter_name = '') {
116 116
 		global $globalStatsFilters;
117 117
 		if ($filter_name == '') $filter_name = $this->filter_name;
118 118
 		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                  try {
121 121
                         $sth = $this->db->prepare($query);
122 122
                         $sth->execute(array(':filter_name' => $filter_name));
123
-                } catch(PDOException $e) {
123
+                } catch (PDOException $e) {
124 124
                         echo "error : ".$e->getMessage();
125 125
                 }
126 126
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -128,28 +128,28 @@  discard block
 block discarded – undo
128 128
             		$Spotter = new Spotter($this->db);
129 129
             		$filters = array();
130 130
             		if ($filter_name != '') {
131
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
131
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
132 132
 			}
133
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
133
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
134 134
                 }
135 135
                 return $all;
136 136
 	}
137
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
137
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') {
138 138
 		global $globalStatsFilters;
139 139
 		if ($filter_name == '') $filter_name = $this->filter_name;
140 140
 		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
141 141
 		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";
142 142
                  try {
143 143
                         $sth = $this->db->prepare($query);
144
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
145
-                } catch(PDOException $e) {
144
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
145
+                } catch (PDOException $e) {
146 146
                         echo "error : ".$e->getMessage();
147 147
                 }
148 148
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
149 149
                 if (empty($all)) {
150 150
             		$filters = array('airlines' => array($stats_airline));
151 151
             		if ($filter_name != '') {
152
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
152
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
153 153
 			}
154 154
             		$Spotter = new Spotter($this->db);
155 155
 			$all = $Spotter->countAllAircraftManufacturers($filters);
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
165 165
                  try {
166 166
                         $sth = $this->db->prepare($query);
167
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
168
-                } catch(PDOException $e) {
167
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
168
+                } catch (PDOException $e) {
169 169
                         echo "error : ".$e->getMessage();
170 170
                 }
171 171
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
172 172
                 if (empty($all)) {
173 173
 			$filters = array('airlines' => array($stats_airline));
174 174
 			if ($filter_name != '') {
175
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
175
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
176 176
 			}
177 177
 			$Spotter = new Spotter($this->db);
178
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
178
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
179 179
                 }
180 180
                 return $all;
181 181
 	}
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
187 187
                  try {
188 188
                         $sth = $this->db->prepare($query);
189
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
190
-                } catch(PDOException $e) {
189
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
190
+                } catch (PDOException $e) {
191 191
                         echo "error : ".$e->getMessage();
192 192
                 }
193 193
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
194 194
                 if (empty($all)) {
195 195
 			$filters = array('airlines' => array($stats_airline));
196 196
 			if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199 199
 			$Spotter = new Spotter($this->db);
200 200
 			$all = $Spotter->countAllDepartureCountries($filters);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                 return $all;
203 203
 	}
204 204
 
205
-	public function countAllAirlines($limit = true,$filter_name = '') {
205
+	public function countAllAirlines($limit = true, $filter_name = '') {
206 206
 		global $globalStatsFilters;
207 207
 		if ($filter_name == '') $filter_name = $this->filter_name;
208 208
 		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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                  try {
211 211
                         $sth = $this->db->prepare($query);
212 212
                         $sth->execute(array(':filter_name' => $filter_name));
213
-                } catch(PDOException $e) {
213
+                } catch (PDOException $e) {
214 214
                         echo "error : ".$e->getMessage();
215 215
                 }
216 216
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -218,58 +218,58 @@  discard block
 block discarded – undo
218 218
 	                $Spotter = new Spotter($this->db);
219 219
             		$filters = array();
220 220
             		if ($filter_name != '') {
221
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
221
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
222 222
 			}
223 223
 
224
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
224
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
225 225
                 }
226 226
                 return $all;
227 227
 	}
228
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
228
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
232 232
 		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";
233 233
                  try {
234 234
                         $sth = $this->db->prepare($query);
235
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
236
-                } catch(PDOException $e) {
235
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
236
+                } catch (PDOException $e) {
237 237
                         echo "error : ".$e->getMessage();
238 238
                 }
239 239
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
240 240
                 if (empty($all)) {
241 241
 			$filters = array('airlines' => array($stats_airline));
242 242
 			if ($filter_name != '') {
243
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
243
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
244 244
 			}
245 245
 	                $Spotter = new Spotter($this->db);
246
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
246
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
247 247
                 }
248 248
                 return $all;
249 249
 	}
250
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
250
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') {
251 251
 		global $globalStatsFilters;
252 252
 		if ($filter_name == '') $filter_name = $this->filter_name;
253 253
 		if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
254 254
 		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";
255 255
 		 try {
256 256
 			$sth = $this->db->prepare($query);
257
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
258
-		} catch(PDOException $e) {
257
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
258
+		} catch (PDOException $e) {
259 259
 			echo "error : ".$e->getMessage();
260 260
 		}
261 261
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
262 262
 		if (empty($all)) {
263 263
 			$filters = array('airlines' => array($stats_airline));
264 264
 			if ($filter_name != '') {
265
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
265
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
266 266
 			}
267 267
 			$Spotter = new Spotter($this->db);
268
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
268
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
269 269
 		}
270 270
 		return $all;
271 271
 	}
272
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
272
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') {
273 273
 		$Connection = new Connection();
274 274
 		if ($filter_name == '') $filter_name = $this->filter_name;
275 275
 		if ($Connection->tableExists('countries')) {
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 			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";
278 278
 			 try {
279 279
 				$sth = $this->db->prepare($query);
280
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
281
-			} catch(PDOException $e) {
280
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
281
+			} catch (PDOException $e) {
282 282
 				echo "error : ".$e->getMessage();
283 283
 			}
284 284
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -293,70 +293,70 @@  discard block
 block discarded – undo
293 293
 			return array();
294 294
 		}
295 295
 	}
296
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
296
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') {
297 297
 		global $globalStatsFilters;
298 298
 		if ($filter_name == '') $filter_name = $this->filter_name;
299 299
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
300 300
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
301 301
                  try {
302 302
                         $sth = $this->db->prepare($query);
303
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
304
-                } catch(PDOException $e) {
303
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
304
+                } catch (PDOException $e) {
305 305
                         echo "error : ".$e->getMessage();
306 306
                 }
307 307
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
308 308
                 if (empty($all)) {
309 309
 			$filters = array('airlines' => array($stats_airline));
310 310
 			if ($filter_name != '') {
311
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
311
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
312 312
 			}
313 313
             		$Spotter = new Spotter($this->db);
314
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
314
+            		$all = $Spotter->countAllPilots($limit, 0, '', $filters);
315 315
                 }
316 316
                 return $all;
317 317
 	}
318
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
318
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') {
319 319
 		global $globalStatsFilters;
320 320
 		if ($filter_name == '') $filter_name = $this->filter_name;
321 321
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
322 322
 		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";
323 323
                  try {
324 324
                         $sth = $this->db->prepare($query);
325
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
326
-                } catch(PDOException $e) {
325
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
326
+                } catch (PDOException $e) {
327 327
                         echo "error : ".$e->getMessage();
328 328
                 }
329 329
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
330 330
                 if (empty($all)) {
331 331
 			$filters = array('airlines' => array($stats_airline));
332 332
 			if ($filter_name != '') {
333
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
333
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
334 334
 			}
335 335
             		$Spotter = new Spotter($this->db);
336
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
336
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
337 337
                 }
338 338
                 return $all;
339 339
 	}
340
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
340
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') {
341 341
 		global $globalStatsFilters;
342 342
 		if ($filter_name == '') $filter_name = $this->filter_name;
343 343
 		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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
344 344
 		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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
345 345
                  try {
346 346
                         $sth = $this->db->prepare($query);
347
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
348
-                } catch(PDOException $e) {
347
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
348
+                } catch (PDOException $e) {
349 349
                         echo "error : ".$e->getMessage();
350 350
                 }
351 351
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
352 352
                 if (empty($all)) {
353 353
 			$filters = array('airlines' => array($stats_airline));
354 354
             		if ($filter_name != '') {
355
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
355
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
356 356
 			}
357 357
             		$Spotter = new Spotter($this->db);
358
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
359
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
358
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
359
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
360 360
         		$all = array();
361 361
         		foreach ($pall as $value) {
362 362
         			$icao = $value['airport_departure_icao'];
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
         		foreach ($all as $key => $row) {
374 374
         			$count[$key] = $row['airport_departure_icao_count'];
375 375
         		}
376
-        		array_multisort($count,SORT_DESC,$all);
376
+        		array_multisort($count, SORT_DESC, $all);
377 377
                 }
378 378
                 return $all;
379 379
 	}
380
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
380
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') {
381 381
 		global $globalStatsFilters;
382 382
 		if ($filter_name == '') $filter_name = $this->filter_name;
383 383
 		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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
384 384
 		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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
385 385
 		try {
386 386
 			$sth = $this->db->prepare($query);
387
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
388
-		} catch(PDOException $e) {
387
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
388
+		} catch (PDOException $e) {
389 389
 			echo "error : ".$e->getMessage();
390 390
 		}
391 391
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
392 392
 		if (empty($all)) {
393 393
 			$filters = array('airlines' => array($stats_airline));
394 394
 			if ($filter_name != '') {
395
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
395
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
396 396
 			}
397 397
 			$Spotter = new Spotter($this->db);
398
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
399
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
398
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
399
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
400 400
         		$all = array();
401 401
         		foreach ($pall as $value) {
402 402
         			$icao = $value['airport_arrival_icao'];
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
         		foreach ($all as $key => $row) {
414 414
         			$count[$key] = $row['airport_arrival_icao_count'];
415 415
         		}
416
-        		array_multisort($count,SORT_DESC,$all);
416
+        		array_multisort($count, SORT_DESC, $all);
417 417
                 }
418 418
  
419 419
                 return $all;
420 420
 	}
421
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
421
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
422 422
 		global $globalDBdriver, $globalStatsFilters;
423 423
 		if ($filter_name == '') $filter_name = $this->filter_name;
424 424
 		if ($globalDBdriver == 'mysql') {
@@ -428,18 +428,18 @@  discard block
 block discarded – undo
428 428
 			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";
429 429
 			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";
430 430
 		}
431
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
431
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
432 432
                  try {
433 433
                         $sth = $this->db->prepare($query);
434 434
                         $sth->execute($query_data);
435
-                } catch(PDOException $e) {
435
+                } catch (PDOException $e) {
436 436
                         echo "error : ".$e->getMessage();
437 437
                 }
438 438
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
439 439
                 if (empty($all)) {
440 440
 			$filters = array('airlines' => array($stats_airline));
441 441
 			if ($filter_name != '') {
442
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
442
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
443 443
 			}
444 444
             		$Spotter = new Spotter($this->db);
445 445
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -448,29 +448,29 @@  discard block
 block discarded – undo
448 448
                 return $all;
449 449
 	}
450 450
 	
451
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
451
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
452 452
 		global $globalStatsFilters;
453 453
 		if ($filter_name == '') $filter_name = $this->filter_name;
454 454
 		$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";
455
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
455
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
456 456
                  try {
457 457
                         $sth = $this->db->prepare($query);
458 458
                         $sth->execute($query_data);
459
-                } catch(PDOException $e) {
459
+                } catch (PDOException $e) {
460 460
                         echo "error : ".$e->getMessage();
461 461
                 }
462 462
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
463 463
                 if (empty($all)) {
464 464
 			$filters = array('airlines' => array($stats_airline));
465 465
 			if ($filter_name != '') {
466
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
466
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
467 467
 			}
468 468
             		$Spotter = new Spotter($this->db);
469 469
             		$all = $Spotter->countAllDatesLastMonth($filters);
470 470
                 }
471 471
                 return $all;
472 472
 	}
473
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
473
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
474 474
 		global $globalDBdriver, $globalStatsFilters;
475 475
 		if ($filter_name == '') $filter_name = $this->filter_name;
476 476
 		if ($globalDBdriver == 'mysql') {
@@ -478,40 +478,40 @@  discard block
 block discarded – undo
478 478
 		} else {
479 479
 			$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";
480 480
 		}
481
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
481
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
482 482
                  try {
483 483
                         $sth = $this->db->prepare($query);
484 484
                         $sth->execute($query_data);
485
-                } catch(PDOException $e) {
485
+                } catch (PDOException $e) {
486 486
                         echo "error : ".$e->getMessage();
487 487
                 }
488 488
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
489 489
                 if (empty($all)) {
490 490
 			$filters = array('airlines' => array($stats_airline));
491 491
 			if ($filter_name != '') {
492
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
492
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
493 493
 			}
494 494
             		$Spotter = new Spotter($this->db);
495 495
             		$all = $Spotter->countAllDatesLast7Days($filters);
496 496
                 }
497 497
                 return $all;
498 498
 	}
499
-	public function countAllDates($stats_airline = '',$filter_name = '') {
499
+	public function countAllDates($stats_airline = '', $filter_name = '') {
500 500
 		global $globalStatsFilters;
501 501
 		if ($filter_name == '') $filter_name = $this->filter_name;
502 502
 		$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";
503
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
503
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
504 504
                  try {
505 505
                         $sth = $this->db->prepare($query);
506 506
                         $sth->execute($query_data);
507
-                } catch(PDOException $e) {
507
+                } catch (PDOException $e) {
508 508
                         echo "error : ".$e->getMessage();
509 509
                 }
510 510
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
511 511
                 if (empty($all)) {
512 512
 			$filters = array('airlines' => array($stats_airline));
513 513
 			if ($filter_name != '') {
514
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
514
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
515 515
 			}
516 516
             		$Spotter = new Spotter($this->db);
517 517
             		$all = $Spotter->countAllDates($filters);
@@ -526,35 +526,35 @@  discard block
 block discarded – undo
526 526
                  try {
527 527
                         $sth = $this->db->prepare($query);
528 528
                         $sth->execute($query_data);
529
-                } catch(PDOException $e) {
529
+                } catch (PDOException $e) {
530 530
                         echo "error : ".$e->getMessage();
531 531
                 }
532 532
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
533 533
                 if (empty($all)) {
534 534
             		$filters = array();
535 535
             		if ($filter_name != '') {
536
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
536
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
537 537
 			}
538 538
             		$Spotter = new Spotter($this->db);
539 539
             		$all = $Spotter->countAllDatesByAirlines($filters);
540 540
                 }
541 541
                 return $all;
542 542
 	}
543
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
543
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
544 544
 		global $globalStatsFilters;
545 545
 		if ($filter_name == '') $filter_name = $this->filter_name;
546 546
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
547 547
                  try {
548 548
                         $sth = $this->db->prepare($query);
549 549
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
550
-                } catch(PDOException $e) {
550
+                } catch (PDOException $e) {
551 551
                         echo "error : ".$e->getMessage();
552 552
                 }
553 553
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 554
                 if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
557
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
558 558
 			}
559 559
             		$Spotter = new Spotter($this->db);
560 560
             		$all = $Spotter->countAllMonths($filters);
@@ -568,21 +568,21 @@  discard block
 block discarded – undo
568 568
                  try {
569 569
                         $sth = $this->db->prepare($query);
570 570
                         $sth->execute(array(':filter_name' => $filter_name));
571
-                } catch(PDOException $e) {
571
+                } catch (PDOException $e) {
572 572
                         echo "error : ".$e->getMessage();
573 573
                 }
574 574
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
575 575
                 if (empty($all)) {
576 576
             		$filters = array();
577 577
             		if ($filter_name != '') {
578
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
578
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
579 579
 			}
580 580
             		$Spotter = new Spotter($this->db);
581 581
             		$all = $Spotter->countAllMilitaryMonths($filters);
582 582
                 }
583 583
                 return $all;
584 584
 	}
585
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
585
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
586 586
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
587 587
 		if ($filter_name == '') $filter_name = $this->filter_name;
588 588
 		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";
@@ -599,17 +599,17 @@  discard block
 block discarded – undo
599 599
                  try {
600 600
                         $sth = $this->db->prepare($query);
601 601
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
602
-                } catch(PDOException $e) {
602
+                } catch (PDOException $e) {
603 603
                         echo "error : ".$e->getMessage();
604 604
                 }
605 605
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
606 606
                 if (empty($all)) {
607 607
 			$filters = array('airlines' => array($stats_airline));
608 608
 			if ($filter_name != '') {
609
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
609
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
610 610
 			}
611 611
             		$Spotter = new Spotter($this->db);
612
-            		$all = $Spotter->countAllHours($orderby,$filters);
612
+            		$all = $Spotter->countAllHours($orderby, $filters);
613 613
                 }
614 614
                 return $all;
615 615
 	}
@@ -617,11 +617,11 @@  discard block
 block discarded – undo
617 617
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
618 618
 		global $globalStatsFilters;
619 619
 		if ($filter_name == '') $filter_name = $this->filter_name;
620
-		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
620
+		$all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name);
621 621
 		if (empty($all)) {
622 622
 			$filters = array('airlines' => array($stats_airline));
623 623
 			if ($filter_name != '') {
624
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
625 625
 			}
626 626
 			$Spotter = new Spotter($this->db);
627 627
 			$all = $Spotter->countOverallFlights($filters);
@@ -631,39 +631,39 @@  discard block
 block discarded – undo
631 631
 	public function countOverallMilitaryFlights($filter_name = '') {
632 632
 		global $globalStatsFilters;
633 633
 		if ($filter_name == '') $filter_name = $this->filter_name;
634
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
634
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name);
635 635
 		if (empty($all)) {
636 636
 		        $filters = array();
637 637
             		if ($filter_name != '') {
638
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
638
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
639 639
 			}
640 640
 			$Spotter = new Spotter($this->db);
641 641
 			$all = $Spotter->countOverallMilitaryFlights($filters);
642 642
 		}
643 643
 		return $all;
644 644
 	}
645
-	public function countOverallArrival($stats_airline = '',$filter_name = '') {
645
+	public function countOverallArrival($stats_airline = '', $filter_name = '') {
646 646
 		global $globalStatsFilters;
647 647
 		if ($filter_name == '') $filter_name = $this->filter_name;
648
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
648
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name);
649 649
 		if (empty($all)) {
650 650
 			$filters = array('airlines' => array($stats_airline));
651 651
 			if ($filter_name != '') {
652
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
652
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
653 653
 			}
654 654
 			$Spotter = new Spotter($this->db);
655 655
 			$all = $Spotter->countOverallArrival($filters);
656 656
 		}
657 657
 		return $all;
658 658
 	}
659
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
659
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '') {
660 660
 		global $globalStatsFilters;
661 661
 		if ($filter_name == '') $filter_name = $this->filter_name;
662
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
662
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name);
663 663
 		if (empty($all)) {
664 664
 			$filters = array('airlines' => array($stats_airline));
665 665
 			if ($filter_name != '') {
666
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
666
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
667 667
 			}
668 668
 			$Spotter = new Spotter($this->db);
669 669
 			$all = $Spotter->countOverallAircrafts($filters);
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
                  try {
678 678
                         $sth = $this->db->prepare($query);
679 679
                         $sth->execute(array(':filter_name' => $filter_name));
680
-                } catch(PDOException $e) {
680
+                } catch (PDOException $e) {
681 681
                         echo "error : ".$e->getMessage();
682 682
                 }
683 683
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -686,14 +686,14 @@  discard block
 block discarded – undo
686 686
 		if (empty($all)) {
687 687
             		$filters = array();
688 688
             		if ($filter_name != '') {
689
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
689
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
690 690
 			}
691 691
 			$Spotter = new Spotter($this->db);
692 692
 			$all = $Spotter->countOverallAirlines($filters);
693 693
 		}
694 694
 		return $all;
695 695
 	}
696
-	public function countOverallOwners($stats_airline = '',$filter_name = '') {
696
+	public function countOverallOwners($stats_airline = '', $filter_name = '') {
697 697
 		global $globalStatsFilters;
698 698
 		if ($filter_name == '') $filter_name = $this->filter_name;
699 699
 		/*
@@ -707,25 +707,25 @@  discard block
 block discarded – undo
707 707
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
708 708
                 $all = $result[0]['nb_owner'];
709 709
                 */
710
-		$all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name);
710
+		$all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name);
711 711
 		if (empty($all)) {
712 712
 			$filters = array('airlines' => array($stats_airline));
713 713
 			if ($filter_name != '') {
714
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
714
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
715 715
 			}
716 716
 			$Spotter = new Spotter($this->db);
717 717
 			$all = $Spotter->countOverallOwners($filters);
718 718
 		}
719 719
 		return $all;
720 720
 	}
721
-	public function countOverallPilots($stats_airline = '',$filter_name = '') {
721
+	public function countOverallPilots($stats_airline = '', $filter_name = '') {
722 722
 		global $globalStatsFilters;
723 723
 		if ($filter_name == '') $filter_name = $this->filter_name;
724
-		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
724
+		$all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name);
725 725
 		if (empty($all)) {
726 726
 			$filters = array('airlines' => array($stats_airline));
727 727
 			if ($filter_name != '') {
728
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
728
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
729 729
 			}
730 730
 			$Spotter = new Spotter($this->db);
731 731
 			$all = $Spotter->countOverallPilots($filters);
@@ -733,33 +733,33 @@  discard block
 block discarded – undo
733 733
 		return $all;
734 734
 	}
735 735
 
736
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
736
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
737 737
 		if ($filter_name == '') $filter_name = $this->filter_name;
738 738
 		$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";
739
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
739
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
740 740
                  try {
741 741
                         $sth = $this->db->prepare($query);
742 742
                         $sth->execute($query_values);
743
-                } catch(PDOException $e) {
743
+                } catch (PDOException $e) {
744 744
                         echo "error : ".$e->getMessage();
745 745
                 }
746 746
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
747 747
                 return $all;
748 748
 	}
749
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
749
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
750 750
 		if ($filter_name == '') $filter_name = $this->filter_name;
751 751
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
752
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
752
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
753 753
                  try {
754 754
                         $sth = $this->db->prepare($query);
755 755
                         $sth->execute($query_values);
756
-                } catch(PDOException $e) {
756
+                } catch (PDOException $e) {
757 757
                         echo "error : ".$e->getMessage();
758 758
                 }
759 759
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
760 760
                 return $all;
761 761
         }
762
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
762
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') {
763 763
 		if ($filter_name == '') $filter_name = $this->filter_name;
764 764
     		global $globalArchiveMonths, $globalDBdriver;
765 765
     		if ($globalDBdriver == 'mysql') {
@@ -767,11 +767,11 @@  discard block
 block discarded – undo
767 767
 	        } else {
768 768
             		$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";
769 769
                 }
770
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
770
+                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
771 771
                  try {
772 772
                         $sth = $this->db->prepare($query);
773 773
                         $sth->execute($query_values);
774
-                } catch(PDOException $e) {
774
+                } catch (PDOException $e) {
775 775
                         echo "error : ".$e->getMessage();
776 776
                 }
777 777
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
                  try {
790 790
                         $sth = $this->db->prepare($query);
791 791
                         $sth->execute($query_values);
792
-                } catch(PDOException $e) {
792
+                } catch (PDOException $e) {
793 793
                         echo "error : ".$e->getMessage();
794 794
                 }
795 795
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
                  try {
807 807
                         $sth = $this->db->prepare($query);
808 808
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
809
-                } catch(PDOException $e) {
809
+                } catch (PDOException $e) {
810 810
                         echo "error : ".$e->getMessage();
811 811
                 }
812 812
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
                  try {
824 824
                         $sth = $this->db->prepare($query);
825 825
                         $sth->execute(array(':filter_name' => $filter_name));
826
-                } catch(PDOException $e) {
826
+                } catch (PDOException $e) {
827 827
                         echo "error : ".$e->getMessage();
828 828
                 }
829 829
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
                  try {
841 841
                         $sth = $this->db->prepare($query);
842 842
                         $sth->execute(array(':filter_name' => $filter_name));
843
-                } catch(PDOException $e) {
843
+                } catch (PDOException $e) {
844 844
                         echo "error : ".$e->getMessage();
845 845
                 }
846 846
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
                  try {
858 858
                         $sth = $this->db->prepare($query);
859 859
                         $sth->execute(array(':filter_name' => $filter_name));
860
-                } catch(PDOException $e) {
860
+                } catch (PDOException $e) {
861 861
                         echo "error : ".$e->getMessage();
862 862
                 }
863 863
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
864 864
                 return $all[0]['total'];
865 865
         }
866 866
 
867
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
867
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
868 868
 		global $globalDBdriver;
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870 870
 		if ($globalDBdriver == 'mysql') {
@@ -872,15 +872,15 @@  discard block
 block discarded – undo
872 872
                 } else {
873 873
 			$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);"; 
874 874
 		}
875
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
875
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
876 876
                  try {
877 877
                         $sth = $this->db->prepare($query);
878 878
                         $sth->execute($query_values);
879
-                } catch(PDOException $e) {
879
+                } catch (PDOException $e) {
880 880
                         return "error : ".$e->getMessage();
881 881
                 }
882 882
         }
883
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
883
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
884 884
 		global $globalDBdriver;
885 885
 		if ($filter_name == '') $filter_name = $this->filter_name;
886 886
 		if ($globalDBdriver == 'mysql') {
@@ -889,219 +889,219 @@  discard block
 block discarded – undo
889 889
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
890 890
 			$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);"; 
891 891
                 }
892
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
892
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
893 893
                  try {
894 894
                         $sth = $this->db->prepare($query);
895 895
                         $sth->execute($query_values);
896
-                } catch(PDOException $e) {
896
+                } catch (PDOException $e) {
897 897
                         return "error : ".$e->getMessage();
898 898
                 }
899 899
         }
900
-	public function getStatsSource($date,$stats_type = '') {
900
+	public function getStatsSource($date, $stats_type = '') {
901 901
 		if ($stats_type == '') {
902 902
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
903 903
 			$query_values = array(':date' => $date);
904 904
 		} else {
905 905
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
906
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
906
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
907 907
 		}
908 908
                  try {
909 909
                         $sth = $this->db->prepare($query);
910 910
                         $sth->execute($query_values);
911
-                } catch(PDOException $e) {
911
+                } catch (PDOException $e) {
912 912
                         echo "error : ".$e->getMessage();
913 913
                 }
914 914
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
915 915
                 return $all;
916 916
         }
917 917
 
918
-	public function addStatSource($data,$source_name,$stats_type,$date) {
918
+	public function addStatSource($data, $source_name, $stats_type, $date) {
919 919
 		global $globalDBdriver;
920 920
 		if ($globalDBdriver == 'mysql') {
921 921
 			$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";
922 922
 		} else {
923 923
 			$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);"; 
924 924
                 }
925
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
925
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
926 926
                  try {
927 927
                         $sth = $this->db->prepare($query);
928 928
                         $sth->execute($query_values);
929
-                } catch(PDOException $e) {
929
+                } catch (PDOException $e) {
930 930
                         return "error : ".$e->getMessage();
931 931
                 }
932 932
         }
933
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
933
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
934 934
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
935
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
935
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
936 936
                  try {
937 937
                         $sth = $this->db->prepare($query);
938 938
                         $sth->execute($query_values);
939
-                } catch(PDOException $e) {
939
+                } catch (PDOException $e) {
940 940
                         return "error : ".$e->getMessage();
941 941
                 }
942 942
         }
943
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
943
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') {
944 944
 		global $globalDBdriver;
945 945
 		if ($globalDBdriver == 'mysql') {
946 946
 			$query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
947 947
 		} else {
948 948
 			$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);"; 
949 949
 		}
950
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
950
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
951 951
                  try {
952 952
                         $sth = $this->db->prepare($query);
953 953
                         $sth->execute($query_values);
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
         }
958
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
958
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') {
959 959
 		global $globalDBdriver;
960 960
 		if ($globalDBdriver == 'mysql') {
961 961
 			$query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
962 962
 		} else {
963 963
 			$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);"; 
964 964
 		}
965
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
965
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
966 966
                  try {
967 967
                         $sth = $this->db->prepare($query);
968 968
                         $sth->execute($query_values);
969
-                } catch(PDOException $e) {
969
+                } catch (PDOException $e) {
970 970
                         return "error : ".$e->getMessage();
971 971
                 }
972 972
         }
973
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
973
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') {
974 974
 		global $globalDBdriver;
975 975
 		if ($globalDBdriver == 'mysql') {
976 976
 			$query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
977 977
 		} else {
978 978
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
979 979
 		}
980
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
980
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
981 981
                  try {
982 982
                         $sth = $this->db->prepare($query);
983 983
                         $sth->execute($query_values);
984
-                } catch(PDOException $e) {
984
+                } catch (PDOException $e) {
985 985
                         return "error : ".$e->getMessage();
986 986
                 }
987 987
         }
988
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
988
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
989 989
 		global $globalDBdriver;
990 990
 		if ($globalDBdriver == 'mysql') {
991 991
 			$query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline";
992 992
 		} else {
993 993
 			$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);"; 
994 994
 		}
995
-                $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);
995
+                $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);
996 996
                  try {
997 997
                         $sth = $this->db->prepare($query);
998 998
                         $sth->execute($query_values);
999
-                } catch(PDOException $e) {
999
+                } catch (PDOException $e) {
1000 1000
                         return "error : ".$e->getMessage();
1001 1001
                 }
1002 1002
         }
1003
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
1003
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') {
1004 1004
 		global $globalDBdriver;
1005 1005
 		if ($globalDBdriver == 'mysql') {
1006 1006
 			$query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";
1007 1007
 		} else {
1008 1008
 			$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);"; 
1009 1009
 		}
1010
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1010
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1011 1011
                  try {
1012 1012
                         $sth = $this->db->prepare($query);
1013 1013
                         $sth->execute($query_values);
1014
-                } catch(PDOException $e) {
1014
+                } catch (PDOException $e) {
1015 1015
                         return "error : ".$e->getMessage();
1016 1016
                 }
1017 1017
         }
1018
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
1018
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') {
1019 1019
 		global $globalDBdriver;
1020 1020
 		if ($globalDBdriver == 'mysql') {
1021 1021
 			$query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
1022 1022
 		} else {
1023 1023
 			$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);"; 
1024 1024
 		}
1025
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1025
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1026 1026
                  try {
1027 1027
                         $sth = $this->db->prepare($query);
1028 1028
                         $sth->execute($query_values);
1029
-                } catch(PDOException $e) {
1029
+                } catch (PDOException $e) {
1030 1030
                         return "error : ".$e->getMessage();
1031 1031
                 }
1032 1032
         }
1033
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') {
1033
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '') {
1034 1034
 		global $globalDBdriver;
1035 1035
 		if ($globalDBdriver == 'mysql') {
1036 1036
 			$query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name";
1037 1037
 		} else {
1038 1038
 			$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; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1039 1039
 		}
1040
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1040
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1041 1041
                  try {
1042 1042
                         $sth = $this->db->prepare($query);
1043 1043
                         $sth->execute($query_values);
1044
-                } catch(PDOException $e) {
1044
+                } catch (PDOException $e) {
1045 1045
                         return "error : ".$e->getMessage();
1046 1046
                 }
1047 1047
         }
1048
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1048
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1049 1049
 		global $globalDBdriver;
1050 1050
 		if ($globalDBdriver == 'mysql') {
1051 1051
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = departure+:departure";
1052 1052
 		} else {
1053 1053
 			$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);"; 
1054 1054
 		}
1055
-                $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);
1055
+                $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);
1056 1056
                  try {
1057 1057
                         $sth = $this->db->prepare($query);
1058 1058
                         $sth->execute($query_values);
1059
-                } catch(PDOException $e) {
1059
+                } catch (PDOException $e) {
1060 1060
                         return "error : ".$e->getMessage();
1061 1061
                 }
1062 1062
         }
1063
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1063
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1064 1064
 		global $globalDBdriver;
1065 1065
 		if ($globalDBdriver == 'mysql') {
1066 1066
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = :departure";
1067 1067
 		} else {
1068 1068
 			$query = "UPDATE stats_airport SET departure = 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);"; 
1069 1069
 		}
1070
-                $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);
1070
+                $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);
1071 1071
                  try {
1072 1072
                         $sth = $this->db->prepare($query);
1073 1073
                         $sth->execute($query_values);
1074
-                } catch(PDOException $e) {
1074
+                } catch (PDOException $e) {
1075 1075
                         return "error : ".$e->getMessage();
1076 1076
                 }
1077 1077
         }
1078
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1078
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1079 1079
 		global $globalDBdriver;
1080 1080
 		if ($globalDBdriver == 'mysql') {
1081 1081
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";
1082 1082
 		} else {
1083 1083
 			$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);"; 
1084 1084
 		}
1085
-                $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);
1085
+                $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);
1086 1086
                  try {
1087 1087
                         $sth = $this->db->prepare($query);
1088 1088
                         $sth->execute($query_values);
1089
-                } catch(PDOException $e) {
1089
+                } catch (PDOException $e) {
1090 1090
                         return "error : ".$e->getMessage();
1091 1091
                 }
1092 1092
         }
1093
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1093
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1094 1094
 		global $globalDBdriver;
1095 1095
 		if ($globalDBdriver == 'mysql') {
1096 1096
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = :arrival";
1097 1097
 		} else {
1098 1098
 			$query = "UPDATE stats_airport SET arrival = 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);"; 
1099 1099
 		}
1100
-                $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);
1100
+                $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);
1101 1101
                  try {
1102 1102
                         $sth = $this->db->prepare($query);
1103 1103
                         $sth->execute($query_values);
1104
-                } catch(PDOException $e) {
1104
+                } catch (PDOException $e) {
1105 1105
                         return "error : ".$e->getMessage();
1106 1106
                 }
1107 1107
         }
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
                  try {
1113 1113
                         $sth = $this->db->prepare($query);
1114 1114
                         $sth->execute($query_values);
1115
-                } catch(PDOException $e) {
1115
+                } catch (PDOException $e) {
1116 1116
                         return "error : ".$e->getMessage();
1117 1117
                 }
1118 1118
         }
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
                  try {
1123 1123
                         $sth = $this->db->prepare($query);
1124 1124
                         $sth->execute($query_values);
1125
-                } catch(PDOException $e) {
1125
+                } catch (PDOException $e) {
1126 1126
                         return "error : ".$e->getMessage();
1127 1127
                 }
1128 1128
         }
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
                  try {
1133 1133
                         $sth = $this->db->prepare($query);
1134 1134
                         $sth->execute($query_values);
1135
-                } catch(PDOException $e) {
1135
+                } catch (PDOException $e) {
1136 1136
                         return "error : ".$e->getMessage();
1137 1137
                 }
1138 1138
         }
@@ -1371,40 +1371,40 @@  discard block
 block discarded – undo
1371 1371
 				$last_update_day = $last_update[0]['value'];
1372 1372
 			} else $last_update_day = '2012-12-12 12:12:12';
1373 1373
 			$Spotter = new Spotter($this->db);
1374
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1374
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1375 1375
 			foreach ($alldata as $number) {
1376
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1376
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']);
1377 1377
 			}
1378 1378
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1379
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1379
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1380 1380
 			foreach ($alldata as $number) {
1381
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1381
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1382 1382
 			}
1383 1383
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1384
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1384
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1385 1385
 			foreach ($alldata as $number) {
1386
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1386
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1387 1387
 			}
1388 1388
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1389
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1389
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1390 1390
 			foreach ($alldata as $number) {
1391
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1391
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1392 1392
 			}
1393 1393
 			if ($globalDebug) echo 'Count all owners...'."\n";
1394
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1394
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1395 1395
 			foreach ($alldata as $number) {
1396
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1396
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1397 1397
 			}
1398 1398
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1399
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1399
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1400 1400
 			foreach ($alldata as $number) {
1401
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']);
1401
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name']);
1402 1402
 			}
1403 1403
 			
1404 1404
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1405
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1405
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1406 1406
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1407
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1407
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1408 1408
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1409 1409
 	        	$alldata = array();
1410 1410
 	        	
@@ -1422,14 +1422,14 @@  discard block
 block discarded – undo
1422 1422
     			foreach ($alldata as $key => $row) {
1423 1423
     				$count[$key] = $row['airport_departure_icao_count'];
1424 1424
         		}
1425
-			array_multisort($count,SORT_DESC,$alldata);
1425
+			array_multisort($count, SORT_DESC, $alldata);
1426 1426
 			foreach ($alldata as $number) {
1427
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1427
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1428 1428
 			}
1429 1429
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1430
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1430
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1431 1431
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1432
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1432
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1433 1433
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1434 1434
 	        	$alldata = array();
1435 1435
     			foreach ($pall as $value) {
@@ -1446,16 +1446,16 @@  discard block
 block discarded – undo
1446 1446
         		foreach ($alldata as $key => $row) {
1447 1447
         			$count[$key] = $row['airport_arrival_icao_count'];
1448 1448
 	        	}
1449
-    			array_multisort($count,SORT_DESC,$alldata);
1449
+    			array_multisort($count, SORT_DESC, $alldata);
1450 1450
                         foreach ($alldata as $number) {
1451
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1451
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1452 1452
 			}
1453 1453
 			if ($Connection->tableExists('countries')) {
1454 1454
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1455 1455
 				$SpotterArchive = new SpotterArchive();
1456
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1456
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1457 1457
 				foreach ($alldata as $number) {
1458
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1458
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1459 1459
 				}
1460 1460
 			}
1461 1461
 			
@@ -1469,37 +1469,37 @@  discard block
 block discarded – undo
1469 1469
 			$lastyear = false;
1470 1470
 			foreach ($alldata as $number) {
1471 1471
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1472
-				$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'])));
1472
+				$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'])));
1473 1473
 			}
1474 1474
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1475 1475
 			$alldata = $Spotter->countAllMilitaryMonths();
1476 1476
 			foreach ($alldata as $number) {
1477
-				$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'])));
1477
+				$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'])));
1478 1478
 			}
1479 1479
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1480 1480
 			$alldata = $Spotter->countAllMonthsOwners();
1481 1481
 			foreach ($alldata as $number) {
1482
-				$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'])));
1482
+				$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'])));
1483 1483
 			}
1484 1484
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1485 1485
 			$alldata = $Spotter->countAllMonthsPilots();
1486 1486
 			foreach ($alldata as $number) {
1487
-				$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'])));
1487
+				$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'])));
1488 1488
 			}
1489 1489
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1490 1490
 			$alldata = $Spotter->countAllMonthsAirlines();
1491 1491
 			foreach ($alldata as $number) {
1492
-				$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'])));
1492
+				$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'])));
1493 1493
 			}
1494 1494
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1495 1495
 			$alldata = $Spotter->countAllMonthsAircrafts();
1496 1496
 			foreach ($alldata as $number) {
1497
-				$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'])));
1497
+				$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'])));
1498 1498
 			}
1499 1499
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1500 1500
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1501 1501
 			foreach ($alldata as $number) {
1502
-				$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'])));
1502
+				$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'])));
1503 1503
 			}
1504 1504
 			if ($globalDebug) echo 'Airports data...'."\n";
1505 1505
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
     			}
1545 1545
     			$alldata = $pall;
1546 1546
 			foreach ($alldata as $number) {
1547
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1547
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1548 1548
 			}
1549 1549
 			echo '...Arrival'."\n";
1550 1550
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
     			}
1587 1587
     			$alldata = $pall;
1588 1588
 			foreach ($alldata as $number) {
1589
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1589
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1590 1590
 			}
1591 1591
 
1592 1592
 			echo 'Flights data...'."\n";
@@ -1594,28 +1594,28 @@  discard block
 block discarded – undo
1594 1594
 			echo '-> countAllDatesLastMonth...'."\n";
1595 1595
 			$alldata = $Spotter->countAllDatesLastMonth();
1596 1596
 			foreach ($alldata as $number) {
1597
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1597
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1598 1598
 			}
1599 1599
 			echo '-> countAllDates...'."\n";
1600 1600
 			$previousdata = $this->countAllDates();
1601 1601
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1602 1602
 			$this->deleteStatFlight('date');
1603
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1603
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1604 1604
 			$values = array();
1605 1605
 			foreach ($alldata as $cnt) {
1606 1606
 				$values[] = $cnt['date_count'];
1607 1607
 			}
1608
-			array_multisort($values,SORT_DESC,$alldata);
1609
-			array_splice($alldata,11);
1608
+			array_multisort($values, SORT_DESC, $alldata);
1609
+			array_splice($alldata, 11);
1610 1610
 			foreach ($alldata as $number) {
1611
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1611
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1612 1612
 			}
1613 1613
 			
1614 1614
 			$this->deleteStatFlight('hour');
1615 1615
 			echo '-> countAllHours...'."\n";
1616 1616
 			$alldata = $Spotter->countAllHours('hour');
1617 1617
 			foreach ($alldata as $number) {
1618
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1618
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1619 1619
 			}
1620 1620
 
1621 1621
 
@@ -1624,34 +1624,34 @@  discard block
 block discarded – undo
1624 1624
 			echo '--- Stats by airlines ---'."\n";
1625 1625
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1626 1626
 			$Spotter = new Spotter($this->db);
1627
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1627
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1628 1628
 			foreach ($alldata as $number) {
1629
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1629
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']);
1630 1630
 			}
1631 1631
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1632
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1632
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1633 1633
 			foreach ($alldata as $number) {
1634
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1634
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']);
1635 1635
 			}
1636 1636
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1637
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1637
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1638 1638
 			foreach ($alldata as $number) {
1639
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1639
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1640 1640
 			}
1641 1641
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1642
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1642
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1643 1643
 			foreach ($alldata as $number) {
1644
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1644
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']);
1645 1645
 			}
1646 1646
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1647
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1647
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1648 1648
 			foreach ($alldata as $number) {
1649
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']);
1649
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao']);
1650 1650
 			}
1651 1651
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1652
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1652
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1653 1653
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1654
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1654
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1655 1655
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1656 1656
 	        	//$alldata = array();
1657 1657
     			foreach ($dall as $value) {
@@ -1671,12 +1671,12 @@  discard block
 block discarded – undo
1671 1671
     			}
1672 1672
     			$alldata = $pall;
1673 1673
 			foreach ($alldata as $number) {
1674
-				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']);
1674
+				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']);
1675 1675
 			}
1676 1676
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1677
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1677
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1678 1678
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1679
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1679
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1680 1680
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1681 1681
 	        	//$alldata = array();
1682 1682
     			foreach ($dall as $value) {
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
     			}
1697 1697
     			$alldata = $pall;
1698 1698
                         foreach ($alldata as $number) {
1699
-				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']);
1699
+				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']);
1700 1700
 			}
1701 1701
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1702 1702
 			$Spotter = new Spotter($this->db);
@@ -1704,27 +1704,27 @@  discard block
 block discarded – undo
1704 1704
 			$lastyear = false;
1705 1705
 			foreach ($alldata as $number) {
1706 1706
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1707
-				$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']);
1707
+				$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']);
1708 1708
 			}
1709 1709
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1710 1710
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1711 1711
 			foreach ($alldata as $number) {
1712
-				$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']);
1712
+				$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']);
1713 1713
 			}
1714 1714
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1715 1715
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1716 1716
 			foreach ($alldata as $number) {
1717
-				$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']);
1717
+				$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']);
1718 1718
 			}
1719 1719
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1720 1720
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1721 1721
 			foreach ($alldata as $number) {
1722
-				$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']);
1722
+				$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']);
1723 1723
 			}
1724 1724
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1725 1725
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1726 1726
 			foreach ($alldata as $number) {
1727
-				$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']);
1727
+				$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']);
1728 1728
 			}
1729 1729
 			if ($globalDebug) echo '...Departure'."\n";
1730 1730
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
     			}
1748 1748
     			$alldata = $pall;
1749 1749
 			foreach ($alldata as $number) {
1750
-				$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']);
1750
+				$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']);
1751 1751
 			}
1752 1752
 			if ($globalDebug) echo '...Arrival'."\n";
1753 1753
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1770,32 +1770,32 @@  discard block
 block discarded – undo
1770 1770
     			}
1771 1771
     			$alldata = $pall;
1772 1772
 			foreach ($alldata as $number) {
1773
-				$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']);
1773
+				$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']);
1774 1774
 			}
1775 1775
 
1776 1776
 			if ($globalDebug) echo 'Flights data...'."\n";
1777 1777
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1778 1778
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1779 1779
 			foreach ($alldata as $number) {
1780
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1780
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1781 1781
 			}
1782 1782
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1783 1783
 			//$previousdata = $this->countAllDatesByAirlines();
1784
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1784
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1785 1785
 			$values = array();
1786 1786
 			foreach ($alldata as $cnt) {
1787 1787
 				$values[] = $cnt['date_count'];
1788 1788
 			}
1789
-			array_multisort($values,SORT_DESC,$alldata);
1790
-			array_splice($alldata,11);
1789
+			array_multisort($values, SORT_DESC, $alldata);
1790
+			array_splice($alldata, 11);
1791 1791
 			foreach ($alldata as $number) {
1792
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1792
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1793 1793
 			}
1794 1794
 			
1795 1795
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1796 1796
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1797 1797
 			foreach ($alldata as $number) {
1798
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1798
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1799 1799
 			}
1800 1800
 			
1801 1801
 
@@ -1806,33 +1806,33 @@  discard block
 block discarded – undo
1806 1806
 				// Count by filter
1807 1807
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1808 1808
 				$Spotter = new Spotter($this->db);
1809
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1809
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1810 1810
 				foreach ($alldata as $number) {
1811
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name);
1811
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name);
1812 1812
 				}
1813
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1813
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1814 1814
 				foreach ($alldata as $number) {
1815
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name);
1815
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name);
1816 1816
 				}
1817
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1817
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1818 1818
 				foreach ($alldata as $number) {
1819
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name);
1819
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name);
1820 1820
 				}
1821
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1821
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1822 1822
 				foreach ($alldata as $number) {
1823
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name);
1823
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name);
1824 1824
 				}
1825
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1825
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1826 1826
 				foreach ($alldata as $number) {
1827
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name);
1827
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name);
1828 1828
 				}
1829
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1829
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1830 1830
 				foreach ($alldata as $number) {
1831
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name);
1831
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name);
1832 1832
 				}
1833 1833
     			
1834
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1835
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1834
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1835
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1836 1836
 		        	$alldata = array();
1837 1837
 	    			foreach ($pall as $value) {
1838 1838
 		        		$icao = $value['airport_departure_icao'];
@@ -1848,12 +1848,12 @@  discard block
 block discarded – undo
1848 1848
     				foreach ($alldata as $key => $row) {
1849 1849
     					$count[$key] = $row['airport_departure_icao_count'];
1850 1850
     				}
1851
-				array_multisort($count,SORT_DESC,$alldata);
1851
+				array_multisort($count, SORT_DESC, $alldata);
1852 1852
 				foreach ($alldata as $number) {
1853
-    					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);
1853
+    					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);
1854 1854
 				}
1855
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1856
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1855
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter);
1856
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter);
1857 1857
 				$alldata = array();
1858 1858
     				foreach ($pall as $value) {
1859 1859
 		        		$icao = $value['airport_arrival_icao'];
@@ -1869,36 +1869,36 @@  discard block
 block discarded – undo
1869 1869
         			foreach ($alldata as $key => $row) {
1870 1870
     					$count[$key] = $row['airport_arrival_icao_count'];
1871 1871
 		        	}
1872
-        			array_multisort($count,SORT_DESC,$alldata);
1872
+        			array_multisort($count, SORT_DESC, $alldata);
1873 1873
 				foreach ($alldata as $number) {
1874
-					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);
1874
+					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);
1875 1875
 				}
1876 1876
 				$Spotter = new Spotter($this->db);
1877 1877
 				$alldata = $Spotter->countAllMonths($filter);
1878 1878
 				$lastyear = false;
1879 1879
 				foreach ($alldata as $number) {
1880 1880
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1881
-					$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);
1881
+					$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);
1882 1882
 				}
1883 1883
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1884 1884
 				foreach ($alldata as $number) {
1885
-					$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);
1885
+					$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);
1886 1886
 				}
1887 1887
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1888 1888
 				foreach ($alldata as $number) {
1889
-					$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);
1889
+					$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);
1890 1890
 				}
1891 1891
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1892 1892
 				foreach ($alldata as $number) {
1893
-					$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);
1893
+					$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);
1894 1894
 				}
1895 1895
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1896 1896
 				foreach ($alldata as $number) {
1897
-					$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);
1897
+					$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);
1898 1898
 				}
1899 1899
 				echo '...Departure'."\n";
1900
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1901
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1900
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1901
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1902 1902
 				foreach ($dall as $value) {
1903 1903
     					$icao = $value['departure_airport_icao'];
1904 1904
     					$ddate = $value['date'];
@@ -1916,11 +1916,11 @@  discard block
 block discarded – undo
1916 1916
     				}
1917 1917
 	    			$alldata = $pall;
1918 1918
 				foreach ($alldata as $number) {
1919
-					$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);
1919
+					$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);
1920 1920
 				}
1921 1921
 				echo '...Arrival'."\n";
1922
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1923
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1922
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1923
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1924 1924
 				foreach ($dall as $value) {
1925 1925
 					$icao = $value['arrival_airport_icao'];
1926 1926
 					$ddate = $value['date'];
@@ -1938,32 +1938,32 @@  discard block
 block discarded – undo
1938 1938
     				}
1939 1939
     				$alldata = $pall;
1940 1940
 				foreach ($alldata as $number) {
1941
-					$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);
1941
+					$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);
1942 1942
 				}
1943 1943
     
1944 1944
 				echo 'Flights data...'."\n";
1945 1945
 				echo '-> countAllDatesLastMonth...'."\n";
1946 1946
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1947 1947
 				foreach ($alldata as $number) {
1948
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1948
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1949 1949
 				}
1950 1950
 				echo '-> countAllDates...'."\n";
1951
-				$previousdata = $this->countAllDates('',$filter_name);
1952
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1951
+				$previousdata = $this->countAllDates('', $filter_name);
1952
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1953 1953
 				$values = array();
1954 1954
 				foreach ($alldata as $cnt) {
1955 1955
 					$values[] = $cnt['date_count'];
1956 1956
 				}
1957
-				array_multisort($values,SORT_DESC,$alldata);
1958
-				array_splice($alldata,11);
1957
+				array_multisort($values, SORT_DESC, $alldata);
1958
+				array_splice($alldata, 11);
1959 1959
 				foreach ($alldata as $number) {
1960
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1960
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1961 1961
 				}
1962 1962
 				
1963 1963
 				echo '-> countAllHours...'."\n";
1964
-				$alldata = $Spotter->countAllHours('hour',$filter);
1964
+				$alldata = $Spotter->countAllHours('hour', $filter);
1965 1965
 				foreach ($alldata as $number) {
1966
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1966
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1967 1967
 				}
1968 1968
 			}
1969 1969
 	
@@ -1974,16 +1974,16 @@  discard block
 block discarded – undo
1974 1974
 				// SUM all previous month to put as year
1975 1975
 				$previous_year = date('Y');
1976 1976
 				$previous_year--;
1977
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1978
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1979
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1980
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1977
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1978
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1979
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1980
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1981 1981
 				$allairlines = $this->getAllAirlineNames();
1982 1982
 				foreach ($allairlines as $data) {
1983
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1984
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1985
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1986
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1983
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1984
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1985
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1986
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1987 1987
 				}
1988 1988
 				
1989 1989
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 						try {
1993 1993
 							$sth = $this->db->prepare($query);
1994 1994
 							$sth->execute();
1995
-						} catch(PDOException $e) {
1995
+						} catch (PDOException $e) {
1996 1996
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1997 1997
 						}
1998 1998
 					}
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 					try {
2002 2002
 						$sth = $this->db->prepare($query);
2003 2003
 						$sth->execute();
2004
-					} catch(PDOException $e) {
2004
+					} catch (PDOException $e) {
2005 2005
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2006 2006
 					}
2007 2007
 				}
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 					try {
2024 2024
 						$sth = $this->db->prepare($query);
2025 2025
 						$sth->execute();
2026
-					} catch(PDOException $e) {
2026
+					} catch (PDOException $e) {
2027 2027
 						return "error : ".$e->getMessage();
2028 2028
 					}
2029 2029
 				}
@@ -2037,13 +2037,13 @@  discard block
 block discarded – undo
2037 2037
 				try {
2038 2038
 					$sth = $this->db->prepare($query);
2039 2039
 					$sth->execute();
2040
-				} catch(PDOException $e) {
2040
+				} catch (PDOException $e) {
2041 2041
 					return "error : ".$e->getMessage();
2042 2042
 				}
2043 2043
 			}
2044 2044
 			echo 'Insert last stats update date...'."\n";
2045 2045
 			date_default_timezone_set('UTC');
2046
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2046
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2047 2047
 		//}
2048 2048
 	}
2049 2049
 }
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
     * @param Array $filter the filter
16 16
     * @return Array the SQL part
17 17
     */
18
-    public function getFilter($filter = array(),$where = false,$and = false) {
18
+    public function getFilter($filter = array(), $where = false, $and = false) {
19 19
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22
-		foreach($globalStatsFilters[$globalFilterName] as $source) {
22
+		foreach ($globalStatsFilters[$globalFilterName] as $source) {
23 23
 			$filter['source'][] = $source;
24 24
 		}
25 25
 	    } else {
26 26
 		$filter = $globalStatsFilters[$globalFilterName];
27 27
 	    }
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	if (isset($filter['source']) && !empty($filter['source'])) {
33
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
34 34
 	}
35 35
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
     }
40 40
 
41 41
        public function getAll() {
42
-    		$filter_query = $this->getFilter(array(),true);
42
+    		$filter_query = $this->getFilter(array(), true);
43 43
                 $query = "SELECT * FROM atc".$filter_query;
44 44
                 $query_values = array();
45 45
                  try {
46 46
                         $sth = $this->db->prepare($query);
47 47
                         $sth->execute($query_values);
48
-                } catch(PDOException $e) {
48
+                } catch (PDOException $e) {
49 49
                         return "error : ".$e->getMessage();
50 50
                 }
51 51
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
52 52
                 return $all;
53 53
         }
54 54
 
55
-       public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
56
-    		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
57
-    		$info = str_replace('^','<br />',$info);
58
-    		$info = str_replace('&amp;sect;','',$info);
59
-    		$info = str_replace('"','',$info);
55
+       public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
56
+    		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
57
+    		$info = str_replace('^', '<br />', $info);
58
+    		$info = str_replace('&amp;sect;', '', $info);
59
+    		$info = str_replace('"', '', $info);
60 60
     		if ($type == '') $type = NULL;
61 61
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62
-                $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
62
+                $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65 65
                         $sth->execute($query_values);
66
-                } catch(PDOException $e) {
66
+                } catch (PDOException $e) {
67 67
                         return "error : ".$e->getMessage();
68 68
                 }
69 69
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                  try {
75 75
                         $sth = $this->db->prepare($query);
76 76
                         $sth->execute($query_values);
77
-                } catch(PDOException $e) {
77
+                } catch (PDOException $e) {
78 78
                         return "error : ".$e->getMessage();
79 79
                 }
80 80
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                  try {
86 86
                         $sth = $this->db->prepare($query);
87 87
                         $sth->execute($query_values);
88
-                } catch(PDOException $e) {
88
+                } catch (PDOException $e) {
89 89
                         return "error : ".$e->getMessage();
90 90
                 }
91 91
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 try {
101 101
                         $sth = $this->db->prepare($query);
102 102
                         $sth->execute();
103
-                } catch(PDOException $e) {
103
+                } catch (PDOException $e) {
104 104
                         return "error";
105 105
                 }
106 106
                 return "success";
Please login to merge, or discard this patch.
require/class.Spotter.php 1 patch
Spacing   +1000 added lines, -1000 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT spotter_output.* FROM spotter_output";
6 6
 
7
-class Spotter{
7
+class Spotter {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -17,64 +17,64 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
35 35
 				if ($flt['airlines'][0] != '') {
36 36
 					if (isset($flt['source'])) {
37
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
37
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
38 38
 					} else {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
40 40
 					}
41 41
 				}
42 42
 			}
43 43
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
44 44
 				if (isset($flt['source'])) {
45
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
45
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
46 46
 				} else {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
48 48
 				}
49 49
 			}
50 50
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
51 51
 				if (isset($flt['source'])) {
52
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
52
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
53 53
 				}
54 54
 			}
55 55
 		}
56 56
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
57 57
 			if ($filter['airlines'][0] != '') {
58
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
58
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
59 59
 			}
60 60
 		}
61 61
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
62 62
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id ";
63 63
 		}
64 64
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
65
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
65
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
66 66
 			}
67 67
 		if (isset($filter['source']) && !empty($filter['source'])) {
68
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
68
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
69 69
 		}
70 70
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
71 71
 			$filter_query_where = " WHERE ident = '".$filter['ident']."'";
72 72
 		}
73 73
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 74
 			if ($filter_query_where == '') {
75
-				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75
+				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
76 76
 			} else {
77
-				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 			}
79 79
 		}
80 80
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	* @return Array the spotter information
93 93
 	*
94 94
 	*/
95
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
95
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
96 96
 	{
97 97
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
98 98
 		$Image = new Image($this->db);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			$sth = $this->db->prepare($query.$limitQuery);
123 123
 			$sth->execute($params);
124 124
 		} catch (PDOException $e) {
125
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
125
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
126 126
 			exit();
127 127
 		}
128 128
 		
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		$spotter_array = array();
133 133
 		
134 134
 
135
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
135
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
136 136
 		{
137 137
 			$num_rows++;
138 138
 			$temp_array = array();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 			if (isset($row['route_stop'])) {
178 178
 				$temp_array['route_stop'] = $row['route_stop'];
179 179
 				if ($row['route_stop'] != '') {
180
-					$allroute = explode(' ',$row['route_stop']);
180
+					$allroute = explode(' ', $row['route_stop']);
181 181
 			
182 182
 					foreach ($allroute as $route) {
183 183
 						$route_airport_array = $this->getAllAirportInfo($route);
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 				{
233 233
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
234 234
 				} else {
235
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
235
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
236 236
 				}
237 237
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
238
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
239
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
238
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
239
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
240 240
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
241 241
 			}
242 242
 			
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
271 271
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
272 272
 					if (is_numeric(substr($row['ident'], 2, 1))) {
273
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
273
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
274 274
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
275
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
275
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
276 276
 					} else {
277 277
 						$airline_array = $this->getAllAirlineInfo('NA');
278 278
 					}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 				}
310 310
 			}
311 311
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
312
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
312
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
313 313
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
314 314
 				if (count($acars_array) > 0) {
315 315
 					$temp_array['acars'] = $acars_array;
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
327 327
 			}
328 328
 
329
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
329
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
330 330
 			{
331 331
 				if ($globalIVAO) {
332
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
333
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
332
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
333
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
334 334
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
335 335
 				if (count($image_array) > 0) {
336 336
 					$temp_array['image'] = $image_array[0]['image'];
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') {
354 354
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
355 355
 			}
356
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
356
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
357 357
 				if ($schedules === true) {
358 358
 					$schedule_array = $Schedule->getSchedule($temp_array['ident']);
359 359
 					//print_r($schedule_array);
@@ -435,12 +435,12 @@  discard block
 block discarded – undo
435 435
 			if (isset($row['squawk'])) {
436 436
 				$temp_array['squawk'] = $row['squawk'];
437 437
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
438
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
439
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
438
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
439
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
440 440
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
441
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
442
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
443
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
441
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
442
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
443
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
444 444
 			}
445 445
     			
446 446
 			$temp_array['query_number_rows'] = $num_rows;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	* @return Array the spotter information
460 460
 	*
461 461
 	*/
462
-	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
462
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
463 463
 	{
464 464
 		global $globalTimezone, $globalDBdriver;
465 465
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
 		$query_values = array();
471 471
 		$additional_query = '';
472
-		$filter_query = $this->getFilter($filters,true,true);
472
+		$filter_query = $this->getFilter($filters, true, true);
473 473
 		if ($q != "")
474 474
 		{
475 475
 			if (!is_string($q))
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
 				return false;
478 478
 			} else {
479 479
 				$q_array = explode(" ", $q);
480
-				foreach ($q_array as $q_item){
481
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
480
+				foreach ($q_array as $q_item) {
481
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
482 482
 					$additional_query .= " AND (";
483 483
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
484 484
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -510,37 +510,37 @@  discard block
 block discarded – undo
510 510
 
511 511
 		if ($registration != "")
512 512
 		{
513
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
513
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
514 514
 			if (!is_string($registration))
515 515
 			{
516 516
 				return false;
517 517
 			} else {
518 518
 				$additional_query .= " AND spotter_output.registration = :registration";
519
-				$query_values = array_merge($query_values,array(':registration' => $registration));
519
+				$query_values = array_merge($query_values, array(':registration' => $registration));
520 520
 			}
521 521
 		}
522 522
 
523 523
 		if ($aircraft_icao != "")
524 524
 		{
525
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
525
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
526 526
 			if (!is_string($aircraft_icao))
527 527
 			{
528 528
 				return false;
529 529
 			} else {
530 530
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
531
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
531
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
532 532
 			}
533 533
 		}
534 534
 
535 535
 		if ($aircraft_manufacturer != "")
536 536
 		{
537
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
537
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
538 538
 			if (!is_string($aircraft_manufacturer))
539 539
 			{
540 540
 				return false;
541 541
 			} else {
542 542
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
543
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
543
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
544 544
 			}
545 545
 		}
546 546
 
@@ -556,25 +556,25 @@  discard block
 block discarded – undo
556 556
 
557 557
 		if ($airline_icao != "")
558 558
 		{
559
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
559
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
560 560
 			if (!is_string($airline_icao))
561 561
 			{
562 562
 				return false;
563 563
 			} else {
564 564
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
565
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
565
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
566 566
 			}
567 567
 		}
568 568
 
569 569
 		if ($airline_country != "")
570 570
 		{
571
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
571
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
572 572
 			if (!is_string($airline_country))
573 573
 			{
574 574
 				return false;
575 575
 			} else {
576 576
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
577
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
577
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
578 578
 			}
579 579
 		}
580 580
 
@@ -601,31 +601,31 @@  discard block
 block discarded – undo
601 601
 
602 602
 		if ($airport != "")
603 603
 		{
604
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
604
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
605 605
 			if (!is_string($airport))
606 606
 			{
607 607
 				return false;
608 608
 			} else {
609 609
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
610
-				$query_values = array_merge($query_values,array(':airport' => $airport));
610
+				$query_values = array_merge($query_values, array(':airport' => $airport));
611 611
 			}
612 612
 		}
613 613
 
614 614
 		if ($airport_country != "")
615 615
 		{
616
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
616
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
617 617
 			if (!is_string($airport_country))
618 618
 			{
619 619
 				return false;
620 620
 			} else {
621 621
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
622
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
622
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
623 623
 			}
624 624
 		}
625 625
     
626 626
 		if ($callsign != "")
627 627
 		{
628
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
628
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
629 629
 			if (!is_string($callsign))
630 630
 			{
631 631
 				return false;
@@ -633,79 +633,79 @@  discard block
 block discarded – undo
633 633
 				$translate = $Translation->ident2icao($callsign);
634 634
 				if ($translate != $callsign) {
635 635
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
636
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
636
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
637 637
 				} else {
638 638
 					$additional_query .= " AND spotter_output.ident = :callsign";
639
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
639
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
640 640
 				}
641 641
 			}
642 642
 		}
643 643
 
644 644
 		if ($owner != "")
645 645
 		{
646
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
646
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
647 647
 			if (!is_string($owner))
648 648
 			{
649 649
 				return false;
650 650
 			} else {
651 651
 				$additional_query .= " AND spotter_output.owner_name = :owner";
652
-				$query_values = array_merge($query_values,array(':owner' => $owner));
652
+				$query_values = array_merge($query_values, array(':owner' => $owner));
653 653
 			}
654 654
 		}
655 655
 
656 656
 		if ($pilot_name != "")
657 657
 		{
658
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
658
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
659 659
 			if (!is_string($pilot_name))
660 660
 			{
661 661
 				return false;
662 662
 			} else {
663 663
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
664
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
664
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
665 665
 			}
666 666
 		}
667 667
 
668 668
 		if ($pilot_id != "")
669 669
 		{
670
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
670
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
671 671
 			if (!is_string($pilot_id))
672 672
 			{
673 673
 				return false;
674 674
 			} else {
675 675
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
676
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
676
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
677 677
 			}
678 678
 		}
679 679
 
680 680
 		if ($departure_airport_route != "")
681 681
 		{
682
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
682
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
683 683
 			if (!is_string($departure_airport_route))
684 684
 			{
685 685
 				return false;
686 686
 			} else {
687 687
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
688
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
688
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
689 689
 			}
690 690
 		}
691 691
 
692 692
 		if ($arrival_airport_route != "")
693 693
 		{
694
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
694
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
695 695
 			if (!is_string($arrival_airport_route))
696 696
 			{
697 697
 				return false;
698 698
 			} else {
699 699
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
700
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
700
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
701 701
 			}
702 702
 		}
703 703
 
704 704
 		if ($altitude != "")
705 705
 		{
706 706
 			$altitude_array = explode(",", $altitude);
707
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
708
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
707
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
708
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
709 709
 
710 710
 			if ($altitude_array[1] != "")
711 711
 			{                
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 		if ($date_posted != "")
722 722
 		{
723 723
 			$date_array = explode(",", $date_posted);
724
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
725
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
724
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
725
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
726 726
 
727 727
 			if ($globalTimezone != '') {
728 728
 				date_default_timezone_set($globalTimezone);
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 		{
754 754
 			$limit_array = explode(",", $limit);
755 755
 			
756
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
757
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
756
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
757
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
758 758
 			
759 759
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
760 760
 			{
@@ -783,23 +783,23 @@  discard block
 block discarded – undo
783 783
 
784 784
 
785 785
 		if ($origLat != "" && $origLon != "" && $dist != "") {
786
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
786
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
787 787
 
788 788
 			if ($globalDBdriver == 'mysql') {
789
-				$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
789
+				$query = "SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
790 790
 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
791 791
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
792 792
 			} else {
793
-				$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
793
+				$query = "SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
794 794
 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
795 795
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
796 796
 			}
797 797
 		} else {		
798
-			$query  = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
798
+			$query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
799 799
 					".$additional_query."
800 800
 					".$orderby_query;
801 801
 		}
802
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
802
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
803 803
 		return $spotter_array;
804 804
 	}
805 805
 	
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 		{
823 823
 			$limit_array = explode(",", $limit);
824 824
 			
825
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
826
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
825
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
826
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
827 827
 			
828 828
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
829 829
 			{
@@ -840,9 +840,9 @@  discard block
 block discarded – undo
840 840
 			$orderby_query = " ORDER BY spotter_output.date DESC";
841 841
 		}
842 842
 
843
-		$query  = $global_query.$filter_query." ".$orderby_query;
843
+		$query = $global_query.$filter_query." ".$orderby_query;
844 844
 
845
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
845
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
846 846
 
847 847
 		return $spotter_array;
848 848
 	}
@@ -888,34 +888,34 @@  discard block
 block discarded – undo
888 888
 			{
889 889
 				return false;
890 890
 			} else {
891
-				if ($interval == "30m"){
891
+				if ($interval == "30m") {
892 892
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
893
-				} else if ($interval == "1h"){
893
+				} else if ($interval == "1h") {
894 894
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
895
-				} else if ($interval == "3h"){
895
+				} else if ($interval == "3h") {
896 896
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
897
-				} else if ($interval == "6h"){
897
+				} else if ($interval == "6h") {
898 898
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
899
-				} else if ($interval == "12h"){
899
+				} else if ($interval == "12h") {
900 900
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
901
-				} else if ($interval == "24h"){
901
+				} else if ($interval == "24h") {
902 902
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
903
-				} else if ($interval == "7d"){
903
+				} else if ($interval == "7d") {
904 904
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
905
-				} else if ($interval == "30d"){
905
+				} else if ($interval == "30d") {
906 906
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
907 907
 				} 
908 908
 			}
909 909
 		}
910 910
 
911
-		$query  = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
911
+		$query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
912 912
                    WHERE spotter_output.latitude <> '' 
913 913
 				   AND spotter_output.longitude <> '' 
914 914
                    ".$additional_query."
915 915
                    HAVING distance < :radius  
916 916
 				   ORDER BY distance";
917 917
 
918
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
918
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
919 919
 
920 920
 		return $spotter_array;
921 921
 	}
@@ -927,21 +927,21 @@  discard block
 block discarded – undo
927 927
 	* @return Array the spotter information
928 928
 	*
929 929
 	*/
930
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
930
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
931 931
 	{
932 932
 		global $global_query;
933 933
 		
934 934
 		date_default_timezone_set('UTC');
935 935
 
936
-		$filter_query = $this->getFilter($filter,true,true);
936
+		$filter_query = $this->getFilter($filter, true, true);
937 937
 
938 938
 		$limit_query = '';
939 939
 		if ($limit != "")
940 940
 		{
941 941
 			$limit_array = explode(",", $limit);
942 942
 			
943
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
944
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
943
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
944
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
945 945
 			
946 946
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
947 947
 			{
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
959 959
 		}
960 960
 
961
-		$query  = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
961
+		$query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
962 962
 
963 963
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
964 964
 
@@ -977,15 +977,15 @@  discard block
 block discarded – undo
977 977
 		global $global_query;
978 978
 		
979 979
 		date_default_timezone_set('UTC');
980
-		$filter_query = $this->getFilter($filter,true,true);
980
+		$filter_query = $this->getFilter($filter, true, true);
981 981
 
982 982
 		$limit_query = '';
983 983
 		if ($limit != "")
984 984
 		{
985 985
 			$limit_array = explode(",", $limit);
986 986
 			
987
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
988
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
987
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
988
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
989 989
 			
990 990
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
991 991
 			{
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1003 1003
 		}
1004 1004
 
1005
-		$query  = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1005
+		$query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1006 1006
 
1007 1007
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1008 1008
 
@@ -1016,20 +1016,20 @@  discard block
 block discarded – undo
1016 1016
 	* @return Array the spotter information
1017 1017
 	*
1018 1018
 	*/
1019
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1019
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
1020 1020
 	{
1021 1021
 		global $global_query;
1022 1022
 		
1023 1023
 		date_default_timezone_set('UTC');
1024
-		$filter_query = $this->getFilter($filter,true,true);
1024
+		$filter_query = $this->getFilter($filter, true, true);
1025 1025
 		
1026 1026
 		$limit_query = '';
1027 1027
 		if ($limit != "")
1028 1028
 		{
1029 1029
 			$limit_array = explode(",", $limit);
1030 1030
 			
1031
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1032
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1031
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1032
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1033 1033
 			
1034 1034
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1035 1035
 			{
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1047 1047
 		}
1048 1048
 
1049
-		$query  = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1049
+		$query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1050 1050
 
1051 1051
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1052 1052
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 		
1067 1067
 		date_default_timezone_set('UTC');
1068 1068
 		
1069
-		$filter_query = $this->getFilter($filter,true,true);
1069
+		$filter_query = $this->getFilter($filter, true, true);
1070 1070
 		
1071 1071
 		$limit_query = '';
1072 1072
 		
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
 		{
1075 1075
 			$limit_array = explode(",", $limit);
1076 1076
 			
1077
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1078
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1077
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1078
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1079 1079
 			
1080 1080
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1081 1081
 			{
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1093 1093
 		}
1094 1094
 
1095
-		$query  = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1095
+		$query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1096 1096
 
1097 1097
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1098 1098
 
@@ -1111,14 +1111,14 @@  discard block
 block discarded – undo
1111 1111
 		global $global_query;
1112 1112
 		
1113 1113
 		date_default_timezone_set('UTC');
1114
-		$filter_query = $this->getFilter($filter,true,true);
1114
+		$filter_query = $this->getFilter($filter, true, true);
1115 1115
 		$limit_query = '';
1116 1116
 		if ($limit != "")
1117 1117
 		{
1118 1118
 			$limit_array = explode(",", $limit);
1119 1119
 			
1120
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1121
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1120
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1121
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1122 1122
 			
1123 1123
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1124 1124
 			{
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1136 1136
 		}
1137 1137
 
1138
-		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1138
+		$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1139 1139
 
1140 1140
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1141 1141
 
@@ -1159,9 +1159,9 @@  discard block
 block discarded – undo
1159 1159
 		$query_values = array(':id' => $id);
1160 1160
 
1161 1161
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1162
-		$query  = $global_query." WHERE ".$additional_query." ";
1162
+		$query = $global_query." WHERE ".$additional_query." ";
1163 1163
 
1164
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1164
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1165 1165
 
1166 1166
 		return $spotter_array;
1167 1167
 	}
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
 		{
1200 1200
 			$limit_array = explode(",", $limit);
1201 1201
 			
1202
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1203
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1202
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1203
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1204 1204
 			
1205 1205
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1206 1206
 			{
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 		$query_values = array();
1242 1242
 		$limit_query = '';
1243 1243
 		$additional_query = '';
1244
-		$filter_query = $this->getFilter($filter,true,true);
1244
+		$filter_query = $this->getFilter($filter, true, true);
1245 1245
 		
1246 1246
 		if ($aircraft_type != "")
1247 1247
 		{
@@ -1258,8 +1258,8 @@  discard block
 block discarded – undo
1258 1258
 		{
1259 1259
 			$limit_array = explode(",", $limit);
1260 1260
 			
1261
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1262
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1261
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1262
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1263 1263
 			
1264 1264
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1265 1265
 			{
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 		{
1316 1316
 			$limit_array = explode(",", $limit);
1317 1317
 			
1318
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1319
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1318
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1319
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1320 1320
 			
1321 1321
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1322 1322
 			{
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 		} else {
1333 1333
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1334 1334
 		}
1335
-		$filter_query = $this->getFilter($filter,true,true);
1335
+		$filter_query = $this->getFilter($filter, true, true);
1336 1336
 
1337 1337
 		//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1338 1338
 		$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query;
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
 	* @return Array the spotter information
1352 1352
 	*
1353 1353
 	*/
1354
-	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1354
+	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '', $filters = array())
1355 1355
 	{
1356 1356
 		global $global_query;
1357 1357
 		
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 		$query_values = array();
1361 1361
 		$limit_query = '';
1362 1362
 		$additional_query = '';
1363
-		$filter_query = $this->getFilter($filters,true,true);
1363
+		$filter_query = $this->getFilter($filters, true, true);
1364 1364
 		
1365 1365
 		if ($airline != "")
1366 1366
 		{
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
 		{
1378 1378
 			$limit_array = explode(",", $limit);
1379 1379
 			
1380
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1381
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1380
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1381
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1382 1382
 			
1383 1383
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1384 1384
 			{
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 	* @return Array the spotter information
1409 1409
 	*
1410 1410
 	*/
1411
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1411
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1412 1412
 	{
1413 1413
 		global $global_query;
1414 1414
 		
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
 		$query_values = array();
1417 1417
 		$limit_query = '';
1418 1418
 		$additional_query = '';
1419
-		$filter_query = $this->getFilter($filters,true,true);
1419
+		$filter_query = $this->getFilter($filters, true, true);
1420 1420
 		
1421 1421
 		if ($airport != "")
1422 1422
 		{
@@ -1433,8 +1433,8 @@  discard block
 block discarded – undo
1433 1433
 		{
1434 1434
 			$limit_array = explode(",", $limit);
1435 1435
 			
1436
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1437
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1436
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1437
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1438 1438
 			
1439 1439
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1440 1440
 			{
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	* @return Array the spotter information
1467 1467
 	*
1468 1468
 	*/
1469
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1469
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1470 1470
 	{
1471 1471
 		global $global_query, $globalTimezone, $globalDBdriver;
1472 1472
 		
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
 		$limit_query = '';
1475 1475
 		$additional_query = '';
1476 1476
 
1477
-		$filter_query = $this->getFilter($filter,true,true);
1477
+		$filter_query = $this->getFilter($filter, true, true);
1478 1478
 		
1479 1479
 		if ($date != "")
1480 1480
 		{
@@ -1500,8 +1500,8 @@  discard block
 block discarded – undo
1500 1500
 		{
1501 1501
 			$limit_array = explode(",", $limit);
1502 1502
 			
1503
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1504
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1503
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1504
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1505 1505
 			
1506 1506
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1507 1507
 			{
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
 	* @return Array the spotter information
1532 1532
 	*
1533 1533
 	*/
1534
-	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1534
+	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '', $filters = array())
1535 1535
 	{
1536 1536
 		global $global_query;
1537 1537
 		
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
 		$query_values = array();
1541 1541
 		$limit_query = '';
1542 1542
 		$additional_query = '';
1543
-		$filter_query = $this->getFilter($filters,true,true);
1543
+		$filter_query = $this->getFilter($filters, true, true);
1544 1544
 		if ($country != "")
1545 1545
 		{
1546 1546
 			if (!is_string($country))
@@ -1557,8 +1557,8 @@  discard block
 block discarded – undo
1557 1557
 		{
1558 1558
 			$limit_array = explode(",", $limit);
1559 1559
 			
1560
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1561
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1560
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1561
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1562 1562
 			
1563 1563
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1564 1564
 			{
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 		$query_values = array();
1599 1599
 		$additional_query = '';
1600 1600
 		$limit_query = '';
1601
-		$filter_query = $this->getFilter($filters,true,true);
1601
+		$filter_query = $this->getFilter($filters, true, true);
1602 1602
 		
1603 1603
 		if ($aircraft_manufacturer != "")
1604 1604
 		{
@@ -1615,8 +1615,8 @@  discard block
 block discarded – undo
1615 1615
 		{
1616 1616
 			$limit_array = explode(",", $limit);
1617 1617
 			
1618
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1619
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1618
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1619
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1620 1620
 			
1621 1621
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1622 1622
 			{
@@ -1658,14 +1658,14 @@  discard block
 block discarded – undo
1658 1658
 		$query_values = array();
1659 1659
 		$additional_query = '';
1660 1660
 		$limit_query = '';
1661
-		$filter_query = $this->getFilter($filters,true,true);
1661
+		$filter_query = $this->getFilter($filters, true, true);
1662 1662
 		if ($departure_airport_icao != "")
1663 1663
 		{
1664 1664
 			if (!is_string($departure_airport_icao))
1665 1665
 			{
1666 1666
 				return false;
1667 1667
 			} else {
1668
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1668
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1669 1669
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1670 1670
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
1671 1671
 			}
@@ -1677,9 +1677,9 @@  discard block
 block discarded – undo
1677 1677
 			{
1678 1678
 				return false;
1679 1679
 			} else {
1680
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1680
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1681 1681
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1682
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1682
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1683 1683
 			}
1684 1684
 		}
1685 1685
 		
@@ -1687,8 +1687,8 @@  discard block
 block discarded – undo
1687 1687
 		{
1688 1688
 			$limit_array = explode(",", $limit);
1689 1689
 			
1690
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1691
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1690
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1691
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1692 1692
 			
1693 1693
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1694 1694
 			{
@@ -1727,15 +1727,15 @@  discard block
 block discarded – undo
1727 1727
 		global $global_query;
1728 1728
 		
1729 1729
 		date_default_timezone_set('UTC');
1730
-		$filter_query = $this->getFilter($filter,true,true);
1730
+		$filter_query = $this->getFilter($filter, true, true);
1731 1731
 		$limit_query = '';
1732 1732
 		
1733 1733
 		if ($limit != "")
1734 1734
 		{
1735 1735
 			$limit_array = explode(",", $limit);
1736 1736
 			
1737
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1738
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1737
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1738
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1739 1739
 			
1740 1740
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1741 1741
 			{
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1753 1753
 		}
1754 1754
 
1755
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1755
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1756 1756
 
1757 1757
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1758 1758
 
@@ -1765,19 +1765,19 @@  discard block
 block discarded – undo
1765 1765
 	* @return String the highlight text
1766 1766
 	*
1767 1767
 	*/
1768
-	public function getHighlightByRegistration($registration,$filter = array())
1768
+	public function getHighlightByRegistration($registration, $filter = array())
1769 1769
 	{
1770 1770
 		global $global_query;
1771 1771
 		
1772 1772
 		date_default_timezone_set('UTC');
1773
-		$filter_query = $this->getFilter($filter,true,true);
1774
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1773
+		$filter_query = $this->getFilter($filter, true, true);
1774
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1775 1775
 		
1776
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1776
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1777 1777
 		$sth = $this->db->prepare($query);
1778 1778
 		$sth->execute(array(':registration' => $registration));
1779 1779
 
1780
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1780
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1781 1781
 		{
1782 1782
 			$highlight = $row['highlight'];
1783 1783
 		}
@@ -1793,14 +1793,14 @@  discard block
 block discarded – undo
1793 1793
 	* @return String usage
1794 1794
 	*
1795 1795
 	*/
1796
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1796
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1797 1797
 	{
1798 1798
 		
1799
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
1800
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
1799
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
1800
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
1801 1801
 
1802 1802
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
1803
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
1803
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
1804 1804
 		
1805 1805
 		$sth = $this->db->prepare($query);
1806 1806
 		$sth->execute($query_values);
@@ -1822,9 +1822,9 @@  discard block
 block discarded – undo
1822 1822
 	public function getAirportIcao($airport_iata = '')
1823 1823
 	{
1824 1824
 		
1825
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
1825
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
1826 1826
 
1827
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1827
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1828 1828
 		$query_values = array(':airport' => $airport_iata);
1829 1829
 		
1830 1830
 		$sth = $this->db->prepare($query);
@@ -1846,12 +1846,12 @@  discard block
 block discarded – undo
1846 1846
 	* @return Float distance to the airport
1847 1847
 	*
1848 1848
 	*/
1849
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
1849
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
1850 1850
 	{
1851 1851
 		
1852
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
1852
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
1853 1853
 
1854
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1854
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1855 1855
 		$query_values = array(':airport' => $airport_icao);
1856 1856
 		$sth = $this->db->prepare($query);
1857 1857
 		$sth->execute($query_values);
@@ -1861,7 +1861,7 @@  discard block
 block discarded – undo
1861 1861
 			$airport_latitude = $row['latitude'];
1862 1862
 			$airport_longitude = $row['longitude'];
1863 1863
 			$Common = new Common();
1864
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1864
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
1865 1865
 		} else return '';
1866 1866
 	}
1867 1867
 	
@@ -1875,11 +1875,11 @@  discard block
 block discarded – undo
1875 1875
 	public function getAllAirportInfo($airport = '')
1876 1876
 	{
1877 1877
 		
1878
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
1878
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
1879 1879
 
1880 1880
 		$query_values = array();
1881 1881
 		if ($airport == 'NA') {
1882
-			return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => ''));
1882
+			return array(array('name' => 'Not available', 'city' => 'N/A', 'country' => 'N/A', 'iata' => 'NA', 'icao' => 'NA', 'altitude' => NULL, 'latitude' => 0, 'longitude' => 0, 'type' => 'NA', 'home_link' => '', 'wikipedia_link' => '', 'image_thumb' => '', 'image' => ''));
1883 1883
 		} elseif ($airport == '') {
1884 1884
 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport";
1885 1885
 		} else {
@@ -1927,14 +1927,14 @@  discard block
 block discarded – undo
1927 1927
 	{
1928 1928
 		$lst_countries = '';
1929 1929
 		foreach ($countries as $country) {
1930
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
1930
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
1931 1931
 			if ($lst_countries == '') {
1932 1932
 				$lst_countries = "'".$country."'";
1933 1933
 			} else {
1934 1934
 				$lst_countries .= ",'".$country."'";
1935 1935
 			}
1936 1936
 		}
1937
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1937
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1938 1938
 		
1939 1939
 		$sth = $this->db->prepare($query);
1940 1940
 		$sth->execute();
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
 		$airport_array = array();
1943 1943
 		$temp_array = array();
1944 1944
 		
1945
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1945
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1946 1946
 		{
1947 1947
 			$temp_array['name'] = $row['name'];
1948 1948
 			$temp_array['city'] = $row['city'];
@@ -1970,10 +1970,10 @@  discard block
 block discarded – undo
1970 1970
 	{
1971 1971
 		global $globalDBdriver;
1972 1972
 		if (is_array($coord)) {
1973
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1974
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1975
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1976
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1973
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1974
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1975
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1976
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1977 1977
 		} else return array();
1978 1978
 		if ($globalDBdriver == 'mysql') {
1979 1979
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
     
1986 1986
 		$airport_array = array();
1987 1987
 		
1988
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1988
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1989 1989
 		{
1990 1990
 			$temp_array = $row;
1991 1991
 
@@ -2005,13 +2005,13 @@  discard block
 block discarded – undo
2005 2005
 	public function getAllWaypointsInfobyCoord($coord)
2006 2006
 	{
2007 2007
 		if (is_array($coord)) {
2008
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2009
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2010
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2011
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2008
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2009
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2010
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2011
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2012 2012
 		} else return array();
2013 2013
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2014
-		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2014
+		$query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2015 2015
 		//$query  = "SELECT waypoints.* FROM waypoints";
2016 2016
 		//$query  = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end";
2017 2017
 		//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
     
2024 2024
 		$waypoints_array = array();
2025 2025
 		
2026
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2026
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2027 2027
 		{
2028 2028
 			$temp_array = $row;
2029 2029
 
@@ -2045,10 +2045,10 @@  discard block
 block discarded – undo
2045 2045
 	{
2046 2046
 		global $globalUseRealAirlines;
2047 2047
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2048
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2048
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2049 2049
 		if ($airline_icao == 'NA') {
2050 2050
 			$airline_array = array();
2051
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2051
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2052 2052
 			return $airline_array;
2053 2053
 		} else {
2054 2054
 			if (strlen($airline_icao) == 2) {
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 			if ($fromsource === NULL) {
2070 2070
 				$sth->execute(array(':airline_icao' => $airline_icao));
2071 2071
 			} else {
2072
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2072
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2073 2073
 			}
2074 2074
                         /*
2075 2075
 			$airline_array = array();
@@ -2111,12 +2111,12 @@  discard block
 block discarded – undo
2111 2111
 	*/
2112 2112
 	public function getAllAircraftInfo($aircraft_type)
2113 2113
 	{
2114
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2114
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2115 2115
 
2116 2116
 		if ($aircraft_type == 'NA') {
2117
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2117
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2118 2118
 		}
2119
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
2119
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
2120 2120
 		
2121 2121
 		$sth = $this->db->prepare($query);
2122 2122
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
 	*/
2149 2149
 	public function getAircraftIcao($aircraft_type)
2150 2150
 	{
2151
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2151
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2152 2152
 		$all_aircraft = array('737-300' => 'B733',
2153 2153
 				'777-200' => 'B772',
2154 2154
 				'777-200ER' => 'B772',
@@ -2160,10 +2160,10 @@  discard block
 block discarded – undo
2160 2160
 				'A380' => 'A388');
2161 2161
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2162 2162
 
2163
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2163
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2164 2164
 		$aircraft_type = strtoupper($aircraft_type);
2165 2165
 		$sth = $this->db->prepare($query);
2166
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2166
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2167 2167
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2168 2168
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2169 2169
 		else return '';
@@ -2178,9 +2178,9 @@  discard block
 block discarded – undo
2178 2178
 	*/
2179 2179
 	public function getAllAircraftType($aircraft_modes)
2180 2180
 	{
2181
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2181
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2182 2182
 
2183
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2183
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2184 2184
 		
2185 2185
 		$sth = $this->db->prepare($query);
2186 2186
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -2201,8 +2201,8 @@  discard block
 block discarded – undo
2201 2201
 	*/
2202 2202
 	public function getOperator($operator)
2203 2203
 	{
2204
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2205
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2204
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2205
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2206 2206
 		
2207 2207
 		$sth = $this->db->prepare($query);
2208 2208
 		$sth->execute(array(':operator' => $operator));
@@ -2223,9 +2223,9 @@  discard block
 block discarded – undo
2223 2223
 	*/
2224 2224
 	public function getRouteInfo($callsign)
2225 2225
 	{
2226
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2226
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2227 2227
                 if ($callsign == '') return array();
2228
-		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2228
+		$query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2229 2229
 		
2230 2230
 		$sth = $this->db->prepare($query);
2231 2231
 		$sth->execute(array(':callsign' => $callsign));
@@ -2246,9 +2246,9 @@  discard block
 block discarded – undo
2246 2246
 	*/
2247 2247
 	public function getAircraftInfoByRegistration($registration)
2248 2248
 	{
2249
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2249
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2250 2250
 
2251
-		$query  = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2251
+		$query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2252 2252
 		
2253 2253
 		$sth = $this->db->prepare($query);
2254 2254
 		$sth->execute(array(':registration' => $registration));
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
 		$aircraft_array = array();
2257 2257
 		$temp_array = array();
2258 2258
 		
2259
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2259
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2260 2260
 		{
2261 2261
 			$temp_array['airline_icao'] = $row['airline_icao'];
2262 2262
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
 	*/
2279 2279
 	public function getAircraftOwnerByRegistration($registration)
2280 2280
 	{
2281
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2281
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2282 2282
 		$Connection = new Connection($this->db);
2283 2283
 		if ($Connection->tableExists('aircraft_owner')) {
2284 2284
 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 	public function getAllFlightsforSitemap()
2301 2301
 	{
2302 2302
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
2303
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2303
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2304 2304
 		
2305 2305
 		$sth = $this->db->prepare($query);
2306 2306
 		$sth->execute();
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 		$manufacturer_array = array();
2348 2348
 		$temp_array = array();
2349 2349
 		
2350
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2350
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2351 2351
 		{
2352 2352
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2353 2353
 
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
 								ORDER BY spotter_output.aircraft_name ASC";
2374 2374
 								
2375 2375
 		*/
2376
-		$filter_query = $this->getFilter($filters,true,true);
2376
+		$filter_query = $this->getFilter($filters, true, true);
2377 2377
 		$query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft".$filter_query." icao <> '' ORDER BY aircraft_manufacturer ASC";
2378 2378
 		
2379 2379
 		$sth = $this->db->prepare($query);
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 		$aircraft_array = array();
2383 2383
 		$temp_array = array();
2384 2384
 		
2385
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2385
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2386 2386
 		{
2387 2387
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2388 2388
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	*/
2404 2404
 	public function getAllAircraftRegistrations($filters = array())
2405 2405
 	{
2406
-		$filter_query = $this->getFilter($filters,true,true);
2407
-		$query  = "SELECT DISTINCT spotter_output.registration 
2406
+		$filter_query = $this->getFilter($filters, true, true);
2407
+		$query = "SELECT DISTINCT spotter_output.registration 
2408 2408
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' 
2409 2409
 				ORDER BY spotter_output.registration ASC";
2410 2410
 
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
 		$aircraft_array = array();
2415 2415
 		$temp_array = array();
2416 2416
 		
2417
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2417
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2418 2418
 		{
2419 2419
 			$temp_array['registration'] = $row['registration'];
2420 2420
 
@@ -2431,11 +2431,11 @@  discard block
 block discarded – undo
2431 2431
 	* @return Array list of source name
2432 2432
 	*
2433 2433
 	*/
2434
-	public function getAllSourceName($type = '',$filters = array())
2434
+	public function getAllSourceName($type = '', $filters = array())
2435 2435
 	{
2436
-		$filter_query = $this->getFilter($filters,true,true);
2436
+		$filter_query = $this->getFilter($filters, true, true);
2437 2437
 		$query_values = array();
2438
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2438
+		$query = "SELECT DISTINCT spotter_output.source_name 
2439 2439
 				FROM spotter_output".$filter_query." spotter_output.source_name <> ''";
2440 2440
 		if ($type != '') {
2441 2441
 			$query_values = array(':type' => $type);
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
 		$source_array = array();
2451 2451
 		$temp_array = array();
2452 2452
 		
2453
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2453
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2454 2454
 		{
2455 2455
 			$temp_array['source_name'] = $row['source_name'];
2456 2456
 			$source_array[] = $temp_array;
@@ -2466,11 +2466,11 @@  discard block
 block discarded – undo
2466 2466
 	* @return Array list of airline names
2467 2467
 	*
2468 2468
 	*/
2469
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2469
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL, $filters = array())
2470 2470
 	{
2471
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2472
-		$filter_query = $this->getFilter($filters,true,true);
2473
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2471
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2472
+		$filter_query = $this->getFilter($filters, true, true);
2473
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2474 2474
 		if ($airline_type == '' || $airline_type == 'all') {
2475 2475
 			/*
2476 2476
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
 				$query_data = array(':forsource' => $forsource);
2490 2490
 			}
2491 2491
 		} else {
2492
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2492
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2493 2493
 					FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
2494 2494
 					AND spotter_output.airline_type = :airline_type 
2495 2495
 					ORDER BY spotter_output.airline_icao ASC";
@@ -2502,7 +2502,7 @@  discard block
 block discarded – undo
2502 2502
 		$airline_array = array();
2503 2503
 		$temp_array = array();
2504 2504
 		
2505
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2505
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2506 2506
 		{
2507 2507
 			$temp_array['airline_icao'] = $row['airline_icao'];
2508 2508
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2522,8 +2522,8 @@  discard block
 block discarded – undo
2522 2522
 	*/
2523 2523
 	public function getAllAirlineCountries($filters = array())
2524 2524
 	{
2525
-		$filter_query = $this->getFilter($filters,true,true);
2526
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2525
+		$filter_query = $this->getFilter($filters, true, true);
2526
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2527 2527
 				FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
2528 2528
 				ORDER BY spotter_output.airline_country ASC";
2529 2529
 		
@@ -2534,7 +2534,7 @@  discard block
 block discarded – undo
2534 2534
 		$airline_array = array();
2535 2535
 		$temp_array = array();
2536 2536
 		
2537
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2537
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2538 2538
 		{
2539 2539
 			$temp_array['airline_country'] = $row['airline_country'];
2540 2540
 
@@ -2554,9 +2554,9 @@  discard block
 block discarded – undo
2554 2554
 	*/
2555 2555
 	public function getAllAirportNames($filters = array())
2556 2556
 	{
2557
-		$filter_query = $this->getFilter($filters,true,true);
2557
+		$filter_query = $this->getFilter($filters, true, true);
2558 2558
 		$airport_array = array();
2559
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2559
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2560 2560
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2561 2561
 				ORDER BY spotter_output.departure_airport_city ASC";
2562 2562
 		
@@ -2565,7 +2565,7 @@  discard block
 block discarded – undo
2565 2565
 		$sth->execute();
2566 2566
 
2567 2567
 		$temp_array = array();
2568
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2568
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2569 2569
 		{
2570 2570
 			$temp_array['airport_icao'] = $row['airport_icao'];
2571 2571
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2575,14 +2575,14 @@  discard block
 block discarded – undo
2575 2575
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2576 2576
 		}
2577 2577
 
2578
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2578
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2579 2579
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2580 2580
 								ORDER BY spotter_output.arrival_airport_city ASC";
2581 2581
 					
2582 2582
 		$sth = $this->db->prepare($query);
2583 2583
 		$sth->execute();
2584 2584
 
2585
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2585
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2586 2586
 			{
2587 2587
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2588 2588
 		//	{
@@ -2622,21 +2622,21 @@  discard block
 block discarded – undo
2622 2622
    
2623 2623
 		$temp_array = array();
2624 2624
 		
2625
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2625
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2626 2626
 		{
2627 2627
 			$temp_array['airport_country'] = $row['airport_country'];
2628 2628
 
2629 2629
 			$airport_array[$row['airport_country']] = $temp_array;
2630 2630
 		}
2631
-		$filter_query = $this->getFilter($filters,true,true);
2632
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2631
+		$filter_query = $this->getFilter($filters, true, true);
2632
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2633 2633
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
2634 2634
 								ORDER BY spotter_output.arrival_airport_country ASC";
2635 2635
 					
2636 2636
 		$sth = $this->db->prepare($query);
2637 2637
 		$sth->execute();
2638 2638
 		
2639
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2639
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2640 2640
 		{
2641 2641
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
2642 2642
 			{
@@ -2659,9 +2659,9 @@  discard block
 block discarded – undo
2659 2659
 	*/
2660 2660
 	public function getAllCountries($filters = array())
2661 2661
 	{
2662
-		$Connection= new Connection($this->db);
2662
+		$Connection = new Connection($this->db);
2663 2663
 		if ($Connection->tableExists('countries')) {
2664
-			$query  = "SELECT countries.name AS airport_country
2664
+			$query = "SELECT countries.name AS airport_country
2665 2665
 				FROM countries
2666 2666
 				ORDER BY countries.name ASC";
2667 2667
 			$sth = $this->db->prepare($query);
@@ -2670,14 +2670,14 @@  discard block
 block discarded – undo
2670 2670
 			$temp_array = array();
2671 2671
 			$country_array = array();
2672 2672
 		
2673
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
2673
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2674 2674
 			{
2675 2675
 				$temp_array['country'] = $row['airport_country'];
2676 2676
 				$country_array[$row['airport_country']] = $temp_array;
2677 2677
 			}
2678 2678
 		} else {
2679
-			$filter_query = $this->getFilter($filters,true,true);
2680
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2679
+			$filter_query = $this->getFilter($filters, true, true);
2680
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2681 2681
 								FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' 
2682 2682
 								ORDER BY spotter_output.departure_airport_country ASC";
2683 2683
 
@@ -2686,20 +2686,20 @@  discard block
 block discarded – undo
2686 2686
    
2687 2687
 			$temp_array = array();
2688 2688
 			$country_array = array();
2689
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
2689
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2690 2690
 			{
2691 2691
 				$temp_array['country'] = $row['airport_country'];
2692 2692
 				$country_array[$row['airport_country']] = $temp_array;
2693 2693
 			}
2694 2694
 
2695
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2695
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2696 2696
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
2697 2697
 								ORDER BY spotter_output.arrival_airport_country ASC";
2698 2698
 					
2699 2699
 		$sth = $this->db->prepare($query);
2700 2700
 		$sth->execute();
2701 2701
 		
2702
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2702
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2703 2703
 		{
2704 2704
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
2705 2705
 			{
@@ -2709,14 +2709,14 @@  discard block
 block discarded – undo
2709 2709
 			}
2710 2710
 		}
2711 2711
 		
2712
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2712
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2713 2713
 								FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
2714 2714
 								ORDER BY spotter_output.airline_country ASC";
2715 2715
 					
2716 2716
 		$sth = $this->db->prepare($query);
2717 2717
 		$sth->execute();
2718 2718
 		
2719
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2719
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2720 2720
 		{
2721 2721
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
2722 2722
 			{
@@ -2740,8 +2740,8 @@  discard block
 block discarded – undo
2740 2740
 	*/
2741 2741
 	public function getAllIdents($filters = array())
2742 2742
 	{
2743
-		$filter_query = $this->getFilter($filters,true,true);
2744
-		$query  = "SELECT DISTINCT spotter_output.ident
2743
+		$filter_query = $this->getFilter($filters, true, true);
2744
+		$query = "SELECT DISTINCT spotter_output.ident
2745 2745
 								FROM spotter_output".$filter_query." spotter_output.ident <> '' 
2746 2746
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
2747 2747
 
@@ -2751,7 +2751,7 @@  discard block
 block discarded – undo
2751 2751
 		$ident_array = array();
2752 2752
 		$temp_array = array();
2753 2753
 		
2754
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2754
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2755 2755
 		{
2756 2756
 			$temp_array['ident'] = $row['ident'];
2757 2757
 			$ident_array[] = $temp_array;
@@ -2765,9 +2765,9 @@  discard block
 block discarded – undo
2765 2765
 	* @return Array number, icao, name and city of airports
2766 2766
 	*/
2767 2767
 
2768
-	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
2768
+	public function getLast7DaysAirportsDeparture($airport_icao = '', $filters = array()) {
2769 2769
 		global $globalTimezone, $globalDBdriver;
2770
-		$filter_query = $this->getFilter($filters,true,true);
2770
+		$filter_query = $this->getFilter($filters, true, true);
2771 2771
 		if ($globalTimezone != '') {
2772 2772
 			date_default_timezone_set($globalTimezone);
2773 2773
 			$datetime = new DateTime();
@@ -2832,7 +2832,7 @@  discard block
 block discarded – undo
2832 2832
 
2833 2833
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
2834 2834
 		global $globalTimezone, $globalDBdriver;
2835
-		$filter_query = $this->getFilter($filters,true,true);
2835
+		$filter_query = $this->getFilter($filters, true, true);
2836 2836
 		if ($globalTimezone != '') {
2837 2837
 			date_default_timezone_set($globalTimezone);
2838 2838
 			$datetime = new DateTime();
@@ -2916,7 +2916,7 @@  discard block
 block discarded – undo
2916 2916
 
2917 2917
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
2918 2918
 		global $globalTimezone, $globalDBdriver;
2919
-		$filter_query = $this->getFilter($filters,true,true);
2919
+		$filter_query = $this->getFilter($filters, true, true);
2920 2920
 		if ($globalTimezone != '') {
2921 2921
 			date_default_timezone_set($globalTimezone);
2922 2922
 			$datetime = new DateTime();
@@ -2949,9 +2949,9 @@  discard block
 block discarded – undo
2949 2949
 	* @return Array number, icao, name and city of airports
2950 2950
 	*/
2951 2951
 
2952
-	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
2952
+	public function getLast7DaysDetectedAirportsArrival($airport_icao = '', $filters = array()) {
2953 2953
 		global $globalTimezone, $globalDBdriver;
2954
-		$filter_query = $this->getFilter($filters,true,true);
2954
+		$filter_query = $this->getFilter($filters, true, true);
2955 2955
 		if ($globalTimezone != '') {
2956 2956
 			date_default_timezone_set($globalTimezone);
2957 2957
 			$datetime = new DateTime();
@@ -3083,12 +3083,12 @@  discard block
 block discarded – undo
3083 3083
 		} else $offset = '+00:00';
3084 3084
 
3085 3085
 		if ($globalDBdriver == 'mysql') {
3086
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3086
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3087 3087
 								FROM spotter_output
3088 3088
 								WHERE spotter_output.date <> '' 
3089 3089
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3090 3090
 		} else {
3091
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3091
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3092 3092
 								FROM spotter_output
3093 3093
 								WHERE spotter_output.date <> '' 
3094 3094
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3100,7 +3100,7 @@  discard block
 block discarded – undo
3100 3100
 		$date_array = array();
3101 3101
 		$temp_array = array();
3102 3102
 		
3103
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3103
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3104 3104
 		{
3105 3105
 			$temp_array['date'] = $row['date'];
3106 3106
 
@@ -3120,7 +3120,7 @@  discard block
 block discarded – undo
3120 3120
 	*/
3121 3121
 	public function getAllRoutes()
3122 3122
 	{
3123
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
3123
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
3124 3124
 				FROM spotter_output
3125 3125
 				WHERE spotter_output.ident <> '' 
3126 3126
 				GROUP BY route
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 
3132 3132
 		$routes_array = array();
3133 3133
 		$temp_array = array();
3134
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3134
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3135 3135
 		{
3136 3136
 			$temp_array['route'] = $row['route'];
3137 3137
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3150,21 +3150,21 @@  discard block
 block discarded – undo
3150 3150
 	* @return String success or false
3151 3151
 	*
3152 3152
 	*/	
3153
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3153
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3154 3154
 	{
3155 3155
 		if (!is_numeric(substr($ident, 0, 3)))
3156 3156
 		{
3157 3157
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3158
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3158
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3159 3159
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3160
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3160
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3161 3161
 			} else {
3162 3162
 				$airline_array = $this->getAllAirlineInfo("NA");
3163 3163
 			}
3164 3164
 			if (count($airline_array) == 0) {
3165 3165
 				$airline_array = $this->getAllAirlineInfo("NA");
3166 3166
 			}
3167
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3167
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3168 3168
 				$airline_array = $this->getAllAirlineInfo("NA");
3169 3169
 			}
3170 3170
 		} else {
@@ -3177,7 +3177,7 @@  discard block
 block discarded – undo
3177 3177
 
3178 3178
 
3179 3179
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
3180
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3180
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type);
3181 3181
 
3182 3182
 		try {
3183 3183
 			$sth = $this->db->prepare($query);
@@ -3198,11 +3198,11 @@  discard block
 block discarded – undo
3198 3198
 	* @return String success or false
3199 3199
 	*
3200 3200
 	*/	
3201
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3201
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
3202 3202
 	{
3203 3203
 		if ($groundspeed == '') $groundspeed = NULL;
3204 3204
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3205
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3205
+                $query_values = array(':flightaware_id' => $flightaware_id, ':real_arrival_airport_icao' => $arrival_airport_icao, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3206 3206
 
3207 3207
 		try {
3208 3208
 			$sth = $this->db->prepare($query);
@@ -3242,7 +3242,7 @@  discard block
 block discarded – undo
3242 3242
 	* @param String $verticalrate vertival rate of flight
3243 3243
 	* @return String success or false
3244 3244
 	*/
3245
-	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '')
3245
+	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false, $format_source = '', $source_name = '')
3246 3246
 	{
3247 3247
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
3248 3248
 		
@@ -3266,13 +3266,13 @@  discard block
 block discarded – undo
3266 3266
 				if ($ModeS != '') {
3267 3267
 					$timeelapsed = microtime(true);
3268 3268
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3269
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3269
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3270 3270
 				} else {
3271
-					$myhex = explode('-',$flightaware_id);
3271
+					$myhex = explode('-', $flightaware_id);
3272 3272
 					if (count($myhex) > 0) {
3273 3273
 						$timeelapsed = microtime(true);
3274 3274
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3275
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3275
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3276 3276
 					}
3277 3277
 				}
3278 3278
 			}
@@ -3294,24 +3294,24 @@  discard block
 block discarded – undo
3294 3294
 				{
3295 3295
 					$timeelapsed = microtime(true);
3296 3296
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3297
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3297
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3298 3298
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3299
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3299
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3300 3300
 					} else {
3301 3301
 						$airline_array = $this->getAllAirlineInfo("NA");
3302 3302
 					}
3303 3303
 					if (count($airline_array) == 0) {
3304 3304
 						$airline_array = $this->getAllAirlineInfo("NA");
3305 3305
 					}
3306
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3306
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3307 3307
 						$airline_array = $this->getAllAirlineInfo("NA");
3308 3308
 					}
3309
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3309
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3310 3310
 
3311 3311
 				} else {
3312 3312
 					$timeelapsed = microtime(true);
3313 3313
 					$airline_array = $this->getAllAirlineInfo("NA");
3314
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3314
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3315 3315
 				}
3316 3316
 			}
3317 3317
 		} else $airline_array = array();
@@ -3328,27 +3328,27 @@  discard block
 block discarded – undo
3328 3328
 				{
3329 3329
 					$timeelapsed = microtime(true);
3330 3330
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3331
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3331
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3332 3332
 				} else {
3333 3333
 					$timeelapsed = microtime(true);
3334 3334
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3335
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3335
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3336 3336
 				}
3337 3337
 			}
3338 3338
 		} else {
3339 3339
 			if ($ModeS != '') {
3340 3340
 				$timeelapsed = microtime(true);
3341 3341
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3342
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3342
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3343 3343
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3344 3344
 				{
3345 3345
 					$timeelapsed = microtime(true);
3346 3346
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3347
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3347
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3348 3348
 				} else {
3349 3349
 					$timeelapsed = microtime(true);
3350 3350
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3351
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3351
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3352 3352
 				}
3353 3353
 			}
3354 3354
 		}
@@ -3363,7 +3363,7 @@  discard block
 block discarded – undo
3363 3363
 			} else {
3364 3364
 				$timeelapsed = microtime(true);
3365 3365
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3366
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3366
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3367 3367
 			}
3368 3368
 		}
3369 3369
 		
@@ -3377,7 +3377,7 @@  discard block
 block discarded – undo
3377 3377
 			} else {
3378 3378
 				$timeelapsed = microtime(true);
3379 3379
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3380
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3380
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3381 3381
 			}
3382 3382
 		}
3383 3383
 
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
 		{
3442 3442
 			$timeelapsed = microtime(true);
3443 3443
 			$image_array = $Image->getSpotterImage($registration);
3444
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3444
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3445 3445
 			if (!isset($image_array[0]['registration']))
3446 3446
 			{
3447 3447
 				//echo "Add image !!!! \n";
@@ -3449,7 +3449,7 @@  discard block
 block discarded – undo
3449 3449
 			}
3450 3450
 			$timeelapsed = microtime(true);
3451 3451
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3452
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3452
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3453 3453
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3454 3454
 		}
3455 3455
     
@@ -3457,33 +3457,33 @@  discard block
 block discarded – undo
3457 3457
 		{
3458 3458
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3459 3459
             		else $airline_icao = '';
3460
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3460
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3461 3461
 			if (!isset($image_array[0]['registration']))
3462 3462
 			{
3463 3463
 				//echo "Add image !!!! \n";
3464
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3464
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3465 3465
 			}
3466 3466
 		}
3467 3467
     
3468
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3469
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3470
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3471
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3472
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3473
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3474
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3475
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3476
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3477
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3478
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3479
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3480
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3481
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3482
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3483
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3484
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3485
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3486
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3468
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3469
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3470
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3471
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3472
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3473
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3474
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3475
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3476
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3477
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3478
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3479
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3480
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3481
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3482
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3483
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3484
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3485
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3486
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3487 3487
 	
3488 3488
 		if (count($airline_array) == 0) 
3489 3489
 		{
@@ -3511,7 +3511,7 @@  discard block
 block discarded – undo
3511 3511
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3512 3512
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3513 3513
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3514
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3514
+                $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3515 3515
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3516 3516
 
3517 3517
                 $airline_name = $airline_array[0]['name'];
@@ -3521,7 +3521,7 @@  discard block
 block discarded – undo
3521 3521
 		if ($airline_type == '') {
3522 3522
 			$timeelapsed = microtime(true);
3523 3523
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3524
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3524
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3525 3525
 		}
3526 3526
 		if ($airline_type == null) $airline_type = '';
3527 3527
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3532,7 +3532,7 @@  discard block
 block discarded – undo
3532 3532
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3533 3533
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3534 3534
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3535
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3535
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3536 3536
 
3537 3537
 		try {
3538 3538
 		        
@@ -3558,13 +3558,13 @@  discard block
 block discarded – undo
3558 3558
 	{
3559 3559
 		global $globalDBdriver, $globalTimezone;
3560 3560
 		if ($globalDBdriver == 'mysql') {
3561
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3561
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3562 3562
 								WHERE spotter_output.ident = :ident 
3563 3563
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3564 3564
 								AND spotter_output.date < UTC_TIMESTAMP()";
3565 3565
 			$query_data = array(':ident' => $ident);
3566 3566
 		} else {
3567
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3567
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3568 3568
 								WHERE spotter_output.ident = :ident 
3569 3569
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3570 3570
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3573,8 +3573,8 @@  discard block
 block discarded – undo
3573 3573
 		
3574 3574
 		$sth = $this->db->prepare($query);
3575 3575
 		$sth->execute($query_data);
3576
-    		$ident_result='';
3577
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3576
+    		$ident_result = '';
3577
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3578 3578
 		{
3579 3579
 			$ident_result = $row['ident'];
3580 3580
 		}
@@ -3600,8 +3600,8 @@  discard block
 block discarded – undo
3600 3600
 				return false;
3601 3601
 			} else {
3602 3602
 				$q_array = explode(" ", $q);
3603
-				foreach ($q_array as $q_item){
3604
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3603
+				foreach ($q_array as $q_item) {
3604
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3605 3605
 					$additional_query .= " AND (";
3606 3606
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3607 3607
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3616,11 +3616,11 @@  discard block
 block discarded – undo
3616 3616
 			}
3617 3617
 		}
3618 3618
 		if ($globalDBdriver == 'mysql') {
3619
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3619
+			$query = "SELECT spotter_output.* FROM spotter_output 
3620 3620
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3621 3621
 				AND spotter_output.date < UTC_TIMESTAMP()";
3622 3622
 		} else {
3623
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3623
+			$query = "SELECT spotter_output.* FROM spotter_output 
3624 3624
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3625 3625
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3626 3626
 		}
@@ -3637,11 +3637,11 @@  discard block
 block discarded – undo
3637 3637
 	* @return Array the airline list
3638 3638
 	*
3639 3639
 	*/
3640
-	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3640
+	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3641 3641
 	{
3642 3642
 		global $globalDBdriver;
3643
-		$filter_query = $this->getFilter($filters,true,true);
3644
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3643
+		$filter_query = $this->getFilter($filters, true, true);
3644
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3645 3645
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' ";
3646 3646
 		if ($olderthanmonths > 0) {
3647 3647
 			if ($globalDBdriver == 'mysql') {
@@ -3665,7 +3665,7 @@  discard block
 block discarded – undo
3665 3665
  
3666 3666
 		$airline_array = array();
3667 3667
 		$temp_array = array();
3668
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3668
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3669 3669
 		{
3670 3670
 			$temp_array['airline_name'] = $row['airline_name'];
3671 3671
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3682,11 +3682,11 @@  discard block
 block discarded – undo
3682 3682
 	* @return Array the pilots list
3683 3683
 	*
3684 3684
 	*/
3685
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3685
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3686 3686
 	{
3687 3687
 		global $globalDBdriver;
3688
-		$filter_query = $this->getFilter($filters,true,true);
3689
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3688
+		$filter_query = $this->getFilter($filters, true, true);
3689
+		$query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3690 3690
 		 			FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' ";
3691 3691
                 if ($olderthanmonths > 0) {
3692 3692
             		if ($globalDBdriver == 'mysql') {
@@ -3712,7 +3712,7 @@  discard block
 block discarded – undo
3712 3712
 		$airline_array = array();
3713 3713
 		$temp_array = array();
3714 3714
         
3715
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3715
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3716 3716
 		{
3717 3717
 			$temp_array['pilot_name'] = $row['pilot_name'];
3718 3718
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3731,7 +3731,7 @@  discard block
 block discarded – undo
3731 3731
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3732 3732
 	{
3733 3733
 		global $globalDBdriver;
3734
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3734
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3735 3735
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
3736 3736
                 if ($olderthanmonths > 0) {
3737 3737
             		if ($globalDBdriver == 'mysql') {
@@ -3757,7 +3757,7 @@  discard block
 block discarded – undo
3757 3757
 		$airline_array = array();
3758 3758
 		$temp_array = array();
3759 3759
         
3760
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3760
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3761 3761
 		{
3762 3762
 			$temp_array['pilot_name'] = $row['pilot_name'];
3763 3763
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3774,11 +3774,11 @@  discard block
 block discarded – undo
3774 3774
 	* @return Array the pilots list
3775 3775
 	*
3776 3776
 	*/
3777
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3777
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3778 3778
 	{
3779 3779
 		global $globalDBdriver;
3780
-		$filter_query = $this->getFilter($filters,true,true);
3781
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3780
+		$filter_query = $this->getFilter($filters, true, true);
3781
+		$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3782 3782
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3783 3783
                 if ($olderthanmonths > 0) {
3784 3784
             		if ($globalDBdriver == 'mysql') {
@@ -3804,7 +3804,7 @@  discard block
 block discarded – undo
3804 3804
 		$airline_array = array();
3805 3805
 		$temp_array = array();
3806 3806
         
3807
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3807
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3808 3808
 		{
3809 3809
 			$temp_array['owner_name'] = $row['owner_name'];
3810 3810
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3819,11 +3819,11 @@  discard block
 block discarded – undo
3819 3819
 	* @return Array the pilots list
3820 3820
 	*
3821 3821
 	*/
3822
-	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3822
+	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3823 3823
 	{
3824 3824
 		global $globalDBdriver;
3825
-		$filter_query = $this->getFilter($filters,true,true);
3826
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3825
+		$filter_query = $this->getFilter($filters, true, true);
3826
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3827 3827
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3828 3828
                 if ($olderthanmonths > 0) {
3829 3829
             		if ($globalDBdriver == 'mysql') {
@@ -3849,7 +3849,7 @@  discard block
 block discarded – undo
3849 3849
 		$airline_array = array();
3850 3850
 		$temp_array = array();
3851 3851
         
3852
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3852
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3853 3853
 		{
3854 3854
 			$temp_array['owner_name'] = $row['owner_name'];
3855 3855
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3865,11 +3865,11 @@  discard block
 block discarded – undo
3865 3865
 	* @return Array the airline list
3866 3866
 	*
3867 3867
 	*/
3868
-	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
3868
+	public function countAllAirlinesByAircraft($aircraft_icao, $filters = array())
3869 3869
 	{
3870
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3871
-		$filter_query = $this->getFilter($filters,true,true);
3872
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3870
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3871
+		$filter_query = $this->getFilter($filters, true, true);
3872
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3873 3873
 		 	    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
3874 3874
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
3875 3875
 			    ORDER BY airline_count DESC";
@@ -3881,7 +3881,7 @@  discard block
 block discarded – undo
3881 3881
 		$airline_array = array();
3882 3882
 		$temp_array = array();
3883 3883
         
3884
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3884
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3885 3885
 		{
3886 3886
 			$temp_array['airline_name'] = $row['airline_name'];
3887 3887
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3901,11 +3901,11 @@  discard block
 block discarded – undo
3901 3901
 	* @return Array the airline country list
3902 3902
 	*
3903 3903
 	*/
3904
-	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
3904
+	public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array())
3905 3905
 	{
3906
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3907
-		$filter_query = $this->getFilter($filters,true,true);
3908
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3906
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3907
+		$filter_query = $this->getFilter($filters, true, true);
3908
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3909 3909
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
3910 3910
                     GROUP BY spotter_output.airline_country
3911 3911
 					ORDER BY airline_country_count DESC
@@ -3918,7 +3918,7 @@  discard block
 block discarded – undo
3918 3918
 		$airline_country_array = array();
3919 3919
 		$temp_array = array();
3920 3920
         
3921
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3921
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3922 3922
 		{
3923 3923
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3924 3924
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3937,11 +3937,11 @@  discard block
 block discarded – undo
3937 3937
 	* @return Array the airline list
3938 3938
 	*
3939 3939
 	*/
3940
-	public function countAllAirlinesByAirport($airport_icao,$filters = array())
3940
+	public function countAllAirlinesByAirport($airport_icao, $filters = array())
3941 3941
 	{
3942
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3943
-		$filter_query = $this->getFilter($filters,true,true);
3944
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3942
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3943
+		$filter_query = $this->getFilter($filters, true, true);
3944
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3945 3945
 		    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) 
3946 3946
                     GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country
3947 3947
 		    ORDER BY airline_count DESC";
@@ -3953,7 +3953,7 @@  discard block
 block discarded – undo
3953 3953
 		$airline_array = array();
3954 3954
 		$temp_array = array();
3955 3955
         
3956
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3956
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3957 3957
 		{
3958 3958
 			$temp_array['airline_name'] = $row['airline_name'];
3959 3959
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3972,11 +3972,11 @@  discard block
 block discarded – undo
3972 3972
 	* @return Array the airline country list
3973 3973
 	*
3974 3974
 	*/
3975
-	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
3975
+	public function countAllAirlineCountriesByAirport($airport_icao, $filters = array())
3976 3976
 	{
3977
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3978
-		$filter_query = $this->getFilter($filters,true,true);
3979
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3977
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3978
+		$filter_query = $this->getFilter($filters, true, true);
3979
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3980 3980
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao )
3981 3981
 					GROUP BY spotter_output.airline_country
3982 3982
 					ORDER BY airline_country_count DESC
@@ -3989,7 +3989,7 @@  discard block
 block discarded – undo
3989 3989
 		$airline_country_array = array();
3990 3990
 		$temp_array = array();
3991 3991
         
3992
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3992
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3993 3993
 		{
3994 3994
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3995 3995
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4006,11 +4006,11 @@  discard block
 block discarded – undo
4006 4006
 	* @return Array the airline list
4007 4007
 	*
4008 4008
 	*/
4009
-	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4009
+	public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array())
4010 4010
 	{
4011
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4012
-		$filter_query = $this->getFilter($filters,true,true);
4013
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4011
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4012
+		$filter_query = $this->getFilter($filters, true, true);
4013
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4014 4014
 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4015 4015
 					GROUP BY spotter_output.airline_name
4016 4016
 					ORDER BY airline_count DESC";
@@ -4021,7 +4021,7 @@  discard block
 block discarded – undo
4021 4021
 		$airline_array = array();
4022 4022
 		$temp_array = array();
4023 4023
         
4024
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4024
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4025 4025
 		{
4026 4026
 			$temp_array['airline_name'] = $row['airline_name'];
4027 4027
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4041,11 +4041,11 @@  discard block
 block discarded – undo
4041 4041
 	* @return Array the airline country list
4042 4042
 	*
4043 4043
 	*/
4044
-	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4044
+	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array())
4045 4045
 	{
4046
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4047
-		$filter_query = $this->getFilter($filters,true,true);
4048
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4046
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4047
+		$filter_query = $this->getFilter($filters, true, true);
4048
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4049 4049
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4050 4050
 					GROUP BY spotter_output.airline_country
4051 4051
 					ORDER BY airline_country_count DESC
@@ -4058,7 +4058,7 @@  discard block
 block discarded – undo
4058 4058
 		$airline_country_array = array();
4059 4059
 		$temp_array = array();
4060 4060
         
4061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4062 4062
 		{
4063 4063
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4064 4064
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4074,11 +4074,11 @@  discard block
 block discarded – undo
4074 4074
 	* @return Array the airline list
4075 4075
 	*
4076 4076
 	*/
4077
-	public function countAllAirlinesByDate($date,$filters = array())
4077
+	public function countAllAirlinesByDate($date, $filters = array())
4078 4078
 	{
4079 4079
 		global $globalTimezone, $globalDBdriver;
4080
-		$filter_query = $this->getFilter($filters,true,true);
4081
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4080
+		$filter_query = $this->getFilter($filters, true, true);
4081
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4082 4082
 		if ($globalTimezone != '') {
4083 4083
 			date_default_timezone_set($globalTimezone);
4084 4084
 			$datetime = new DateTime($date);
@@ -4086,12 +4086,12 @@  discard block
 block discarded – undo
4086 4086
 		} else $offset = '+00:00';
4087 4087
 
4088 4088
 		if ($globalDBdriver == 'mysql') {
4089
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4089
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4090 4090
 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4091 4091
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country 
4092 4092
 					ORDER BY airline_count DESC";
4093 4093
 		} else {
4094
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4094
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4095 4095
 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4096 4096
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country
4097 4097
 					ORDER BY airline_count DESC";
@@ -4102,7 +4102,7 @@  discard block
 block discarded – undo
4102 4102
 
4103 4103
 		$airline_array = array();
4104 4104
 		$temp_array = array();
4105
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4105
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4106 4106
 		{
4107 4107
 			$temp_array['airline_name'] = $row['airline_name'];
4108 4108
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4122,11 +4122,11 @@  discard block
 block discarded – undo
4122 4122
 	* @return Array the airline country list
4123 4123
 	*
4124 4124
 	*/
4125
-	public function countAllAirlineCountriesByDate($date,$filters = array())
4125
+	public function countAllAirlineCountriesByDate($date, $filters = array())
4126 4126
 	{
4127 4127
 		global $globalTimezone, $globalDBdriver;
4128
-		$filter_query = $this->getFilter($filters,true,true);
4129
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4128
+		$filter_query = $this->getFilter($filters, true, true);
4129
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4130 4130
 		if ($globalTimezone != '') {
4131 4131
 			date_default_timezone_set($globalTimezone);
4132 4132
 			$datetime = new DateTime($date);
@@ -4134,13 +4134,13 @@  discard block
 block discarded – undo
4134 4134
 		} else $offset = '+00:00';
4135 4135
 		
4136 4136
 		if ($globalDBdriver == 'mysql') {
4137
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4137
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4138 4138
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4139 4139
 					GROUP BY spotter_output.airline_country
4140 4140
 					ORDER BY airline_country_count DESC
4141 4141
 					LIMIT 10 OFFSET 0";
4142 4142
 		} else {
4143
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4143
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4144 4144
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4145 4145
 					GROUP BY spotter_output.airline_country
4146 4146
 					ORDER BY airline_country_count DESC
@@ -4152,7 +4152,7 @@  discard block
 block discarded – undo
4152 4152
  
4153 4153
 		$airline_country_array = array();
4154 4154
 		$temp_array = array();
4155
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4155
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4156 4156
 		{
4157 4157
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4158 4158
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4169,11 +4169,11 @@  discard block
 block discarded – undo
4169 4169
 	* @return Array the airline list
4170 4170
 	*
4171 4171
 	*/
4172
-	public function countAllAirlinesByIdent($ident,$filters = array())
4172
+	public function countAllAirlinesByIdent($ident, $filters = array())
4173 4173
 	{
4174
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4175
-		$filter_query = $this->getFilter($filters,true,true);
4176
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4174
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4175
+		$filter_query = $this->getFilter($filters, true, true);
4176
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4177 4177
 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident  
4178 4178
 				GROUP BY spotter_output.airline_name
4179 4179
 				ORDER BY airline_count DESC";
@@ -4185,7 +4185,7 @@  discard block
 block discarded – undo
4185 4185
 		$airline_array = array();
4186 4186
 		$temp_array = array();
4187 4187
         
4188
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4188
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4189 4189
 		{
4190 4190
 			$temp_array['airline_name'] = $row['airline_name'];
4191 4191
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4203,25 +4203,25 @@  discard block
 block discarded – undo
4203 4203
 	* @return Array the airline list
4204 4204
 	*
4205 4205
 	*/
4206
-	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4206
+	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4207 4207
 	{
4208
-		$filter_query = $this->getFilter($filters,true,true);
4209
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4210
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4208
+		$filter_query = $this->getFilter($filters, true, true);
4209
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4210
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4211 4211
 
4212
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4212
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4213 4213
 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4214 4214
 					GROUP BY spotter_output.airline_name
4215 4215
 					ORDER BY airline_count DESC";
4216 4216
       
4217 4217
 		
4218 4218
 		$sth = $this->db->prepare($query);
4219
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4219
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4220 4220
       
4221 4221
 		$airline_array = array();
4222 4222
 		$temp_array = array();
4223 4223
         
4224
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4224
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4225 4225
 		{
4226 4226
 			$temp_array['airline_name'] = $row['airline_name'];
4227 4227
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4239,13 +4239,13 @@  discard block
 block discarded – undo
4239 4239
 	* @return Array the airline country list
4240 4240
 	*
4241 4241
 	*/
4242
-	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4242
+	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4243 4243
 	{
4244
-		$filter_query = $this->getFilter($filters,true,true);
4245
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4246
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4244
+		$filter_query = $this->getFilter($filters, true, true);
4245
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4246
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4247 4247
       
4248
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4248
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4249 4249
 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4250 4250
 				GROUP BY spotter_output.airline_country
4251 4251
 				ORDER BY airline_country_count DESC
@@ -4253,11 +4253,11 @@  discard block
 block discarded – undo
4253 4253
       
4254 4254
 		
4255 4255
 		$sth = $this->db->prepare($query);
4256
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4256
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4257 4257
       
4258 4258
 		$airline_country_array = array();
4259 4259
 		$temp_array = array();
4260
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4260
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4261 4261
 		{
4262 4262
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4263 4263
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4275,11 +4275,11 @@  discard block
 block discarded – undo
4275 4275
 	* @return Array the airline list
4276 4276
 	*
4277 4277
 	*/
4278
-	public function countAllAirlinesByCountry($country,$filters = array())
4278
+	public function countAllAirlinesByCountry($country, $filters = array())
4279 4279
 	{
4280
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4281
-		$filter_query = $this->getFilter($filters,true,true);
4282
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4280
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4281
+		$filter_query = $this->getFilter($filters, true, true);
4282
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4283 4283
 		 	    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4284 4284
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4285 4285
 			    ORDER BY airline_count DESC";
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
 
4291 4291
 		$airline_array = array();
4292 4292
 		$temp_array = array();
4293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4294 4294
 		{
4295 4295
 			$temp_array['airline_name'] = $row['airline_name'];
4296 4296
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4309,11 +4309,11 @@  discard block
 block discarded – undo
4309 4309
 	* @return Array the airline country list
4310 4310
 	*
4311 4311
 	*/
4312
-	public function countAllAirlineCountriesByCountry($country,$filters = array())
4312
+	public function countAllAirlineCountriesByCountry($country, $filters = array())
4313 4313
 	{
4314
-		$filter_query = $this->getFilter($filters,true,true);
4315
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4316
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4314
+		$filter_query = $this->getFilter($filters, true, true);
4315
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4316
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4317 4317
 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
4318 4318
 				GROUP BY spotter_output.airline_country
4319 4319
 				ORDER BY airline_country_count DESC
@@ -4325,7 +4325,7 @@  discard block
 block discarded – undo
4325 4325
 
4326 4326
 		$airline_country_array = array();
4327 4327
 		$temp_array = array();
4328
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4328
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4329 4329
 		{
4330 4330
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4331 4331
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4344,8 +4344,8 @@  discard block
 block discarded – undo
4344 4344
 	*/
4345 4345
 	public function countAllAirlineCountries($limit = true, $filters = array())
4346 4346
 	{
4347
-		$filter_query = $this->getFilter($filters,true,true);
4348
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4347
+		$filter_query = $this->getFilter($filters, true, true);
4348
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4349 4349
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4350 4350
 					GROUP BY spotter_output.airline_country
4351 4351
 					ORDER BY airline_country_count DESC";
@@ -4356,7 +4356,7 @@  discard block
 block discarded – undo
4356 4356
 
4357 4357
 		$airline_array = array();
4358 4358
 		$temp_array = array();
4359
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4359
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4360 4360
 		{
4361 4361
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4362 4362
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4372,11 +4372,11 @@  discard block
 block discarded – undo
4372 4372
 	* @return Array the airline country list
4373 4373
 	*
4374 4374
 	*/
4375
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
4375
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
4376 4376
 	{
4377 4377
 		global $globalDBdriver;
4378 4378
 		//$filter_query = $this->getFilter($filters,true,true);
4379
-		$Connection= new Connection($this->db);
4379
+		$Connection = new Connection($this->db);
4380 4380
 		if (!$Connection->tableExists('countries')) return array();
4381 4381
 		/*
4382 4382
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -4411,7 +4411,7 @@  discard block
 block discarded – undo
4411 4411
 		$flight_array = array();
4412 4412
 		$temp_array = array();
4413 4413
         
4414
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4414
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4415 4415
 		{
4416 4416
 			$temp_array['flight_count'] = $row['nb'];
4417 4417
 			$temp_array['flight_country'] = $row['name'];
@@ -4429,12 +4429,12 @@  discard block
 block discarded – undo
4429 4429
 	* @return Array the aircraft list
4430 4430
 	*
4431 4431
 	*/
4432
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4432
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4433 4433
 	{
4434 4434
 		global $globalDBdriver;
4435
-		$filter_query = $this->getFilter($filters,true,true);
4435
+		$filter_query = $this->getFilter($filters, true, true);
4436 4436
 
4437
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4437
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4438 4438
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
4439 4439
 		if ($olderthanmonths > 0) {
4440 4440
 			if ($globalDBdriver == 'mysql') {
@@ -4459,7 +4459,7 @@  discard block
 block discarded – undo
4459 4459
 
4460 4460
 		$aircraft_array = array();
4461 4461
 		$temp_array = array();
4462
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4462
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4463 4463
 		{
4464 4464
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4465 4465
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4476,11 +4476,11 @@  discard block
 block discarded – undo
4476 4476
 	* @return Array the aircraft list
4477 4477
 	*
4478 4478
 	*/
4479
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4479
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4480 4480
 	{
4481 4481
 		global $globalDBdriver;
4482
-		$filter_query = $this->getFilter($filters,true,true);
4483
-		$query  = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4482
+		$filter_query = $this->getFilter($filters, true, true);
4483
+		$query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4484 4484
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' ";
4485 4485
 		if ($olderthanmonths > 0) {
4486 4486
 			if ($globalDBdriver == 'mysql') {
@@ -4505,7 +4505,7 @@  discard block
 block discarded – undo
4505 4505
 
4506 4506
 		$aircraft_array = array();
4507 4507
 		$temp_array = array();
4508
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4508
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4509 4509
 		{
4510 4510
 			$temp_array['airline_icao'] = $row['airline_icao'];
4511 4511
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -4524,13 +4524,13 @@  discard block
 block discarded – undo
4524 4524
 	* @return Array the aircraft list
4525 4525
 	*
4526 4526
 	*/
4527
-	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
4527
+	public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array())
4528 4528
 	{
4529 4529
 		$Image = new Image($this->db);
4530
-		$filter_query = $this->getFilter($filters,true,true);
4531
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4530
+		$filter_query = $this->getFilter($filters, true, true);
4531
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4532 4532
 
4533
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4533
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4534 4534
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
4535 4535
 				GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4536 4536
 				ORDER BY registration_count DESC";
@@ -4541,14 +4541,14 @@  discard block
 block discarded – undo
4541 4541
 		$aircraft_array = array();
4542 4542
 		$temp_array = array();
4543 4543
         
4544
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4544
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4545 4545
 		{
4546 4546
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4547 4547
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4548 4548
 			$temp_array['registration'] = $row['registration'];
4549 4549
 			$temp_array['airline_name'] = $row['airline_name'];
4550 4550
 			$temp_array['image_thumbnail'] = "";
4551
-			if($row['registration'] != "")
4551
+			if ($row['registration'] != "")
4552 4552
 			{
4553 4553
 				$image_array = $Image->getSpotterImage($row['registration']);
4554 4554
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4567,11 +4567,11 @@  discard block
 block discarded – undo
4567 4567
 	* @return Array the aircraft list
4568 4568
 	*
4569 4569
 	*/
4570
-	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
4570
+	public function countAllAircraftTypesByAirline($airline_icao, $filters = array())
4571 4571
 	{
4572
-		$filter_query = $this->getFilter($filters,true,true);
4573
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4574
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4572
+		$filter_query = $this->getFilter($filters, true, true);
4573
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4574
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4575 4575
 			    FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
4576 4576
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
4577 4577
 			    ORDER BY aircraft_icao_count DESC";
@@ -4582,7 +4582,7 @@  discard block
 block discarded – undo
4582 4582
 		$aircraft_array = array();
4583 4583
 		$temp_array = array();
4584 4584
 
4585
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4585
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4586 4586
 		{
4587 4587
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4588 4588
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4600,13 +4600,13 @@  discard block
 block discarded – undo
4600 4600
 	* @return Array the aircraft list
4601 4601
 	*
4602 4602
 	*/
4603
-	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
4603
+	public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array())
4604 4604
 	{
4605
-		$filter_query = $this->getFilter($filters,true,true);
4605
+		$filter_query = $this->getFilter($filters, true, true);
4606 4606
 		$Image = new Image($this->db);
4607
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4607
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4608 4608
 
4609
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4609
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4610 4610
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
4611 4611
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
4612 4612
 			    ORDER BY registration_count DESC";
@@ -4616,14 +4616,14 @@  discard block
 block discarded – undo
4616 4616
 
4617 4617
 		$aircraft_array = array();
4618 4618
 		$temp_array = array();
4619
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4619
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4620 4620
 		{
4621 4621
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4622 4622
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4623 4623
 			$temp_array['registration'] = $row['registration'];
4624 4624
 			$temp_array['airline_name'] = $row['airline_name'];
4625 4625
 			$temp_array['image_thumbnail'] = "";
4626
-			if($row['registration'] != "")
4626
+			if ($row['registration'] != "")
4627 4627
 			{
4628 4628
 				$image_array = $Image->getSpotterImage($row['registration']);
4629 4629
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4642,11 +4642,11 @@  discard block
 block discarded – undo
4642 4642
 	* @return Array the aircraft list
4643 4643
 	*
4644 4644
 	*/
4645
-	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
4645
+	public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array())
4646 4646
 	{
4647
-		$filter_query = $this->getFilter($filters,true,true);
4648
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4649
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4647
+		$filter_query = $this->getFilter($filters, true, true);
4648
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4649
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4650 4650
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
4651 4651
 				GROUP BY spotter_output.aircraft_manufacturer 
4652 4652
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -4657,7 +4657,7 @@  discard block
 block discarded – undo
4657 4657
 		$aircraft_array = array();
4658 4658
 		$temp_array = array();
4659 4659
 
4660
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4660
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4661 4661
 		{
4662 4662
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4663 4663
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4674,12 +4674,12 @@  discard block
 block discarded – undo
4674 4674
 	* @return Array the aircraft list
4675 4675
 	*
4676 4676
 	*/
4677
-	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
4677
+	public function countAllAircraftTypesByAirport($airport_icao, $filters = array())
4678 4678
 	{
4679
-		$filter_query = $this->getFilter($filters,true,true);
4680
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4679
+		$filter_query = $this->getFilter($filters, true, true);
4680
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4681 4681
 
4682
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4682
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4683 4683
 				FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) 
4684 4684
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
4685 4685
 				ORDER BY aircraft_icao_count DESC";
@@ -4689,7 +4689,7 @@  discard block
 block discarded – undo
4689 4689
 
4690 4690
 		$aircraft_array = array();
4691 4691
 		$temp_array = array();
4692
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4692
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4693 4693
 		{
4694 4694
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4695 4695
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4707,13 +4707,13 @@  discard block
 block discarded – undo
4707 4707
 	* @return Array the aircraft list
4708 4708
 	*
4709 4709
 	*/
4710
-	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
4710
+	public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array())
4711 4711
 	{
4712
-		$filter_query = $this->getFilter($filters,true,true);
4712
+		$filter_query = $this->getFilter($filters, true, true);
4713 4713
 		$Image = new Image($this->db);
4714
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4714
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4715 4715
 
4716
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4716
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4717 4717
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
4718 4718
                     GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
4719 4719
 		    ORDER BY registration_count DESC";
@@ -4723,14 +4723,14 @@  discard block
 block discarded – undo
4723 4723
 
4724 4724
 		$aircraft_array = array();
4725 4725
 		$temp_array = array();
4726
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4726
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4727 4727
 		{
4728 4728
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4729 4729
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4730 4730
 			$temp_array['registration'] = $row['registration'];
4731 4731
 			$temp_array['airline_name'] = $row['airline_name'];
4732 4732
 			$temp_array['image_thumbnail'] = "";
4733
-			if($row['registration'] != "")
4733
+			if ($row['registration'] != "")
4734 4734
 			{
4735 4735
 				$image_array = $Image->getSpotterImage($row['registration']);
4736 4736
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4748,11 +4748,11 @@  discard block
 block discarded – undo
4748 4748
 	* @return Array the aircraft list
4749 4749
 	*
4750 4750
 	*/
4751
-	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
4751
+	public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array())
4752 4752
 	{
4753
-		$filter_query = $this->getFilter($filters,true,true);
4754
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4755
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4753
+		$filter_query = $this->getFilter($filters, true, true);
4754
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4755
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4756 4756
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)  
4757 4757
                     GROUP BY spotter_output.aircraft_manufacturer 
4758 4758
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -4763,7 +4763,7 @@  discard block
 block discarded – undo
4763 4763
 
4764 4764
 		$aircraft_array = array();
4765 4765
 		$temp_array = array();
4766
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4766
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4767 4767
 		{
4768 4768
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4769 4769
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4778,12 +4778,12 @@  discard block
 block discarded – undo
4778 4778
 	* @return Array the aircraft list
4779 4779
 	*
4780 4780
 	*/
4781
-	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
4781
+	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array())
4782 4782
 	{
4783
-		$filter_query = $this->getFilter($filters,true,true);
4784
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4783
+		$filter_query = $this->getFilter($filters, true, true);
4784
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4785 4785
 
4786
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4786
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4787 4787
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
4788 4788
                     GROUP BY spotter_output.aircraft_name 
4789 4789
 					ORDER BY aircraft_icao_count DESC";
@@ -4792,7 +4792,7 @@  discard block
 block discarded – undo
4792 4792
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4793 4793
 		$aircraft_array = array();
4794 4794
 		$temp_array = array();
4795
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4795
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4796 4796
 		{
4797 4797
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4798 4798
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4811,11 +4811,11 @@  discard block
 block discarded – undo
4811 4811
 	*/
4812 4812
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
4813 4813
 	{
4814
-		$filter_query = $this->getFilter($filters,true,true);
4814
+		$filter_query = $this->getFilter($filters, true, true);
4815 4815
 		$Image = new Image($this->db);
4816
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4816
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4817 4817
 
4818
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4818
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4819 4819
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
4820 4820
                     GROUP BY spotter_output.registration 
4821 4821
 					ORDER BY registration_count DESC";
@@ -4825,14 +4825,14 @@  discard block
 block discarded – undo
4825 4825
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4826 4826
 		$aircraft_array = array();
4827 4827
 		$temp_array = array();
4828
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4828
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4829 4829
 		{
4830 4830
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4831 4831
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4832 4832
 			$temp_array['registration'] = $row['registration'];
4833 4833
 			$temp_array['airline_name'] = $row['airline_name'];
4834 4834
 			$temp_array['image_thumbnail'] = "";
4835
-			if($row['registration'] != "")
4835
+			if ($row['registration'] != "")
4836 4836
 			{
4837 4837
 				$image_array = $Image->getSpotterImage($row['registration']);
4838 4838
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4849,11 +4849,11 @@  discard block
 block discarded – undo
4849 4849
 	* @return Array the aircraft list
4850 4850
 	*
4851 4851
 	*/
4852
-	public function countAllAircraftTypesByDate($date,$filters = array())
4852
+	public function countAllAircraftTypesByDate($date, $filters = array())
4853 4853
 	{
4854 4854
 		global $globalTimezone, $globalDBdriver;
4855
-		$filter_query = $this->getFilter($filters,true,true);
4856
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4855
+		$filter_query = $this->getFilter($filters, true, true);
4856
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4857 4857
 		if ($globalTimezone != '') {
4858 4858
 			date_default_timezone_set($globalTimezone);
4859 4859
 			$datetime = new DateTime($date);
@@ -4861,12 +4861,12 @@  discard block
 block discarded – undo
4861 4861
 		} else $offset = '+00:00';
4862 4862
 
4863 4863
 		if ($globalDBdriver == 'mysql') {
4864
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4864
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4865 4865
 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
4866 4866
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
4867 4867
 					ORDER BY aircraft_icao_count DESC";
4868 4868
 		} else {
4869
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4869
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4870 4870
 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
4871 4871
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
4872 4872
 					ORDER BY aircraft_icao_count DESC";
@@ -4877,7 +4877,7 @@  discard block
 block discarded – undo
4877 4877
 
4878 4878
 		$aircraft_array = array();
4879 4879
 		$temp_array = array();
4880
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4880
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4881 4881
 		{
4882 4882
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4883 4883
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4895,12 +4895,12 @@  discard block
 block discarded – undo
4895 4895
 	* @return Array the aircraft list
4896 4896
 	*
4897 4897
 	*/
4898
-	public function countAllAircraftRegistrationByDate($date,$filters = array())
4898
+	public function countAllAircraftRegistrationByDate($date, $filters = array())
4899 4899
 	{
4900 4900
 		global $globalTimezone, $globalDBdriver;
4901
-		$filter_query = $this->getFilter($filters,true,true);
4901
+		$filter_query = $this->getFilter($filters, true, true);
4902 4902
 		$Image = new Image($this->db);
4903
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4903
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4904 4904
 		if ($globalTimezone != '') {
4905 4905
 			date_default_timezone_set($globalTimezone);
4906 4906
 			$datetime = new DateTime($date);
@@ -4908,12 +4908,12 @@  discard block
 block discarded – undo
4908 4908
 		} else $offset = '+00:00';
4909 4909
 
4910 4910
 		if ($globalDBdriver == 'mysql') {
4911
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4911
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4912 4912
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4913 4913
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
4914 4914
 					ORDER BY registration_count DESC";
4915 4915
 		} else {
4916
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4916
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4917 4917
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4918 4918
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
4919 4919
 					ORDER BY registration_count DESC";
@@ -4924,14 +4924,14 @@  discard block
 block discarded – undo
4924 4924
 
4925 4925
 		$aircraft_array = array();
4926 4926
 		$temp_array = array();
4927
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4927
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4928 4928
 		{
4929 4929
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4930 4930
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4931 4931
 			$temp_array['registration'] = $row['registration'];
4932 4932
 			$temp_array['airline_name'] = $row['airline_name'];
4933 4933
 			$temp_array['image_thumbnail'] = "";
4934
-			if($row['registration'] != "")
4934
+			if ($row['registration'] != "")
4935 4935
 			{
4936 4936
 				$image_array = $Image->getSpotterImage($row['registration']);
4937 4937
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4950,11 +4950,11 @@  discard block
 block discarded – undo
4950 4950
 	* @return Array the aircraft manufacturer list
4951 4951
 	*
4952 4952
 	*/
4953
-	public function countAllAircraftManufacturerByDate($date,$filters = array())
4953
+	public function countAllAircraftManufacturerByDate($date, $filters = array())
4954 4954
 	{
4955 4955
 		global $globalTimezone, $globalDBdriver;
4956
-		$filter_query = $this->getFilter($filters,true,true);
4957
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4956
+		$filter_query = $this->getFilter($filters, true, true);
4957
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4958 4958
 		if ($globalTimezone != '') {
4959 4959
 			date_default_timezone_set($globalTimezone);
4960 4960
 			$datetime = new DateTime($date);
@@ -4962,12 +4962,12 @@  discard block
 block discarded – undo
4962 4962
 		} else $offset = '+00:00';
4963 4963
 
4964 4964
 		if ($globalDBdriver == 'mysql') {
4965
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4965
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4966 4966
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4967 4967
 				GROUP BY spotter_output.aircraft_manufacturer 
4968 4968
 				ORDER BY aircraft_manufacturer_count DESC";
4969 4969
 		} else {
4970
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4970
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4971 4971
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4972 4972
 				GROUP BY spotter_output.aircraft_manufacturer 
4973 4973
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -4979,7 +4979,7 @@  discard block
 block discarded – undo
4979 4979
 		$aircraft_array = array();
4980 4980
 		$temp_array = array();
4981 4981
 
4982
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4982
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4983 4983
 		{
4984 4984
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4985 4985
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4996,11 +4996,11 @@  discard block
 block discarded – undo
4996 4996
 	* @return Array the aircraft list
4997 4997
 	*
4998 4998
 	*/
4999
-	public function countAllAircraftTypesByIdent($ident,$filters = array())
4999
+	public function countAllAircraftTypesByIdent($ident, $filters = array())
5000 5000
 	{
5001
-		$filter_query = $this->getFilter($filters,true,true);
5002
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5003
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5001
+		$filter_query = $this->getFilter($filters, true, true);
5002
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5003
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5004 5004
 				FROM spotter_output".$filter_query." spotter_output.ident = :ident 
5005 5005
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5006 5006
 				ORDER BY aircraft_icao_count DESC";
@@ -5011,7 +5011,7 @@  discard block
 block discarded – undo
5011 5011
 		$aircraft_array = array();
5012 5012
 		$temp_array = array();
5013 5013
 
5014
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5014
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5015 5015
 		{
5016 5016
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5017 5017
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5029,13 +5029,13 @@  discard block
 block discarded – undo
5029 5029
 	* @return Array the aircraft list
5030 5030
 	*
5031 5031
 	*/
5032
-	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5032
+	public function countAllAircraftRegistrationByIdent($ident, $filters = array())
5033 5033
 	{
5034
-		$filter_query = $this->getFilter($filters,true,true);
5034
+		$filter_query = $this->getFilter($filters, true, true);
5035 5035
 		$Image = new Image($this->db);
5036
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5036
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5037 5037
 
5038
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5038
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5039 5039
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident   
5040 5040
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5041 5041
 		    ORDER BY registration_count DESC";
@@ -5047,14 +5047,14 @@  discard block
 block discarded – undo
5047 5047
 		$aircraft_array = array();
5048 5048
 		$temp_array = array();
5049 5049
         
5050
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5050
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5051 5051
 		{
5052 5052
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5053 5053
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5054 5054
 			$temp_array['registration'] = $row['registration'];
5055 5055
 			$temp_array['airline_name'] = $row['airline_name'];
5056 5056
 			$temp_array['image_thumbnail'] = "";
5057
-			if($row['registration'] != "")
5057
+			if ($row['registration'] != "")
5058 5058
 			{
5059 5059
 				$image_array = $Image->getSpotterImage($row['registration']);
5060 5060
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5073,11 +5073,11 @@  discard block
 block discarded – undo
5073 5073
 	* @return Array the aircraft manufacturer list
5074 5074
 	*
5075 5075
 	*/
5076
-	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
5076
+	public function countAllAircraftManufacturerByIdent($ident, $filters = array())
5077 5077
 	{
5078
-		$filter_query = $this->getFilter($filters,true,true);
5079
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5080
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5078
+		$filter_query = $this->getFilter($filters, true, true);
5079
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5080
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5081 5081
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
5082 5082
                     GROUP BY spotter_output.aircraft_manufacturer 
5083 5083
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
 		$sth->execute(array(':ident' => $ident));
5088 5088
 		$aircraft_array = array();
5089 5089
 		$temp_array = array();
5090
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5090
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5091 5091
 		{
5092 5092
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5093 5093
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5103,24 +5103,24 @@  discard block
 block discarded – undo
5103 5103
 	* @return Array the aircraft list
5104 5104
 	*
5105 5105
 	*/
5106
-	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
5106
+	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
5107 5107
 	{
5108
-		$filter_query = $this->getFilter($filters,true,true);
5109
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5110
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5108
+		$filter_query = $this->getFilter($filters, true, true);
5109
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5110
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5111 5111
 		
5112 5112
 
5113
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5113
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5114 5114
                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
5115 5115
                     GROUP BY spotter_output.aircraft_name 
5116 5116
 					ORDER BY aircraft_icao_count DESC";
5117 5117
  
5118 5118
 		
5119 5119
 		$sth = $this->db->prepare($query);
5120
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5120
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5121 5121
 		$aircraft_array = array();
5122 5122
 		$temp_array = array();
5123
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5123
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5124 5124
 		{
5125 5125
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5126 5126
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5136,33 +5136,33 @@  discard block
 block discarded – undo
5136 5136
 	* @return Array the aircraft list
5137 5137
 	*
5138 5138
 	*/
5139
-	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
5139
+	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
5140 5140
 	{
5141
-		$filter_query = $this->getFilter($filters,true,true);
5141
+		$filter_query = $this->getFilter($filters, true, true);
5142 5142
 		$Image = new Image($this->db);
5143
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5144
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5143
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5144
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5145 5145
 
5146
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5146
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5147 5147
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)   
5148 5148
                     GROUP BY spotter_output.registration 
5149 5149
 					ORDER BY registration_count DESC";
5150 5150
 
5151 5151
 		
5152 5152
 		$sth = $this->db->prepare($query);
5153
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5153
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5154 5154
       
5155 5155
 		$aircraft_array = array();
5156 5156
 		$temp_array = array();
5157 5157
         
5158
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5158
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5159 5159
 		{
5160 5160
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5161 5161
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5162 5162
 			$temp_array['registration'] = $row['registration'];
5163 5163
 			$temp_array['airline_name'] = $row['airline_name'];
5164 5164
 			$temp_array['image_thumbnail'] = "";
5165
-			if($row['registration'] != "")
5165
+			if ($row['registration'] != "")
5166 5166
 			{
5167 5167
 				$image_array = $Image->getSpotterImage($row['registration']);
5168 5168
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5182,25 +5182,25 @@  discard block
 block discarded – undo
5182 5182
 	* @return Array the aircraft manufacturer list
5183 5183
 	*
5184 5184
 	*/
5185
-	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
5185
+	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
5186 5186
 	{
5187
-		$filter_query = $this->getFilter($filters,true,true);
5188
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5189
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5187
+		$filter_query = $this->getFilter($filters, true, true);
5188
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5189
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5190 5190
 
5191
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5191
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5192 5192
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
5193 5193
                     GROUP BY spotter_output.aircraft_manufacturer 
5194 5194
 					ORDER BY aircraft_manufacturer_count DESC";
5195 5195
 
5196 5196
 		
5197 5197
 		$sth = $this->db->prepare($query);
5198
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5198
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5199 5199
       
5200 5200
 		$aircraft_array = array();
5201 5201
 		$temp_array = array();
5202 5202
         
5203
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5203
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5204 5204
 		{
5205 5205
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5206 5206
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5220,11 +5220,11 @@  discard block
 block discarded – undo
5220 5220
 	* @return Array the aircraft list
5221 5221
 	*
5222 5222
 	*/
5223
-	public function countAllAircraftTypesByCountry($country,$filters = array())
5223
+	public function countAllAircraftTypesByCountry($country, $filters = array())
5224 5224
 	{
5225
-		$filter_query = $this->getFilter($filters,true,true);
5226
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5227
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5225
+		$filter_query = $this->getFilter($filters, true, true);
5226
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5227
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5228 5228
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
5229 5229
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5230 5230
 			    ORDER BY aircraft_icao_count DESC";
@@ -5236,7 +5236,7 @@  discard block
 block discarded – undo
5236 5236
 		$aircraft_array = array();
5237 5237
 		$temp_array = array();
5238 5238
         
5239
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5239
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5240 5240
 		{
5241 5241
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5242 5242
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5255,12 +5255,12 @@  discard block
 block discarded – undo
5255 5255
 	* @return Array the aircraft list
5256 5256
 	*
5257 5257
 	*/
5258
-	public function countAllAircraftRegistrationByCountry($country,$filters = array())
5258
+	public function countAllAircraftRegistrationByCountry($country, $filters = array())
5259 5259
 	{
5260
-		$filter_query = $this->getFilter($filters,true,true);
5260
+		$filter_query = $this->getFilter($filters, true, true);
5261 5261
 		$Image = new Image($this->db);
5262
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5263
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5262
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5263
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5264 5264
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)    
5265 5265
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5266 5266
 			    ORDER BY registration_count DESC";
@@ -5272,14 +5272,14 @@  discard block
 block discarded – undo
5272 5272
 		$aircraft_array = array();
5273 5273
 		$temp_array = array();
5274 5274
         
5275
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5275
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5276 5276
 		{
5277 5277
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5278 5278
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5279 5279
 			$temp_array['registration'] = $row['registration'];
5280 5280
 			$temp_array['airline_name'] = $row['airline_name'];
5281 5281
 			$temp_array['image_thumbnail'] = "";
5282
-			if($row['registration'] != "")
5282
+			if ($row['registration'] != "")
5283 5283
 			{
5284 5284
 				$image_array = $Image->getSpotterImage($row['registration']);
5285 5285
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5299,11 +5299,11 @@  discard block
 block discarded – undo
5299 5299
 	* @return Array the aircraft manufacturer list
5300 5300
 	*
5301 5301
 	*/
5302
-	public function countAllAircraftManufacturerByCountry($country,$filters = array())
5302
+	public function countAllAircraftManufacturerByCountry($country, $filters = array())
5303 5303
 	{
5304
-		$filter_query = $this->getFilter($filters,true,true);
5305
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5306
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5304
+		$filter_query = $this->getFilter($filters, true, true);
5305
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5306
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5307 5307
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) 
5308 5308
                     GROUP BY spotter_output.aircraft_manufacturer 
5309 5309
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5315,7 +5315,7 @@  discard block
 block discarded – undo
5315 5315
 		$aircraft_array = array();
5316 5316
 		$temp_array = array();
5317 5317
         
5318
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5318
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5319 5319
 		{
5320 5320
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5321 5321
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5336,8 +5336,8 @@  discard block
 block discarded – undo
5336 5336
 	*/
5337 5337
 	public function countAllAircraftManufacturers($filters = array())
5338 5338
 	{
5339
-		$filter_query = $this->getFilter($filters,true,true);
5340
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5339
+		$filter_query = $this->getFilter($filters, true, true);
5340
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5341 5341
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
5342 5342
                 $query .= " GROUP BY spotter_output.aircraft_manufacturer
5343 5343
 					ORDER BY aircraft_manufacturer_count DESC
@@ -5350,7 +5350,7 @@  discard block
 block discarded – undo
5350 5350
 		$manufacturer_array = array();
5351 5351
 		$temp_array = array();
5352 5352
         
5353
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5353
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5354 5354
 		{
5355 5355
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5356 5356
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5369,12 +5369,12 @@  discard block
 block discarded – undo
5369 5369
 	* @return Array the aircraft list
5370 5370
 	*
5371 5371
 	*/
5372
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5372
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5373 5373
 	{
5374 5374
 		global $globalDBdriver;
5375 5375
 		$Image = new Image($this->db);
5376
-		$filter_query = $this->getFilter($filters,true,true);
5377
-		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5376
+		$filter_query = $this->getFilter($filters, true, true);
5377
+		$query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5378 5378
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
5379 5379
                 if ($olderthanmonths > 0) {
5380 5380
             		if ($globalDBdriver == 'mysql') {
@@ -5402,7 +5402,7 @@  discard block
 block discarded – undo
5402 5402
 		$aircraft_array = array();
5403 5403
 		$temp_array = array();
5404 5404
         
5405
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5405
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5406 5406
 		{
5407 5407
 			$temp_array['registration'] = $row['registration'];
5408 5408
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -5410,7 +5410,7 @@  discard block
 block discarded – undo
5410 5410
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5411 5411
 			$temp_array['airline_name'] = $row['airline_name'];
5412 5412
 			$temp_array['image_thumbnail'] = "";
5413
-			if($row['registration'] != "")
5413
+			if ($row['registration'] != "")
5414 5414
 			{
5415 5415
 				$image_array = $Image->getSpotterImage($row['registration']);
5416 5416
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5429,12 +5429,12 @@  discard block
 block discarded – undo
5429 5429
 	* @return Array the aircraft list
5430 5430
 	*
5431 5431
 	*/
5432
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5432
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5433 5433
 	{
5434 5434
 		global $globalDBdriver;
5435
-		$filter_query = $this->getFilter($filters,true,true);
5435
+		$filter_query = $this->getFilter($filters, true, true);
5436 5436
 		$Image = new Image($this->db);
5437
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5437
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5438 5438
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
5439 5439
                 if ($olderthanmonths > 0) {
5440 5440
             		if ($globalDBdriver == 'mysql') {
@@ -5462,7 +5462,7 @@  discard block
 block discarded – undo
5462 5462
 		$aircraft_array = array();
5463 5463
 		$temp_array = array();
5464 5464
         
5465
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5465
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5466 5466
 		{
5467 5467
 			$temp_array['registration'] = $row['registration'];
5468 5468
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -5471,7 +5471,7 @@  discard block
 block discarded – undo
5471 5471
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5472 5472
 			$temp_array['airline_name'] = $row['airline_name'];
5473 5473
 			$temp_array['image_thumbnail'] = "";
5474
-			if($row['registration'] != "")
5474
+			if ($row['registration'] != "")
5475 5475
 			{
5476 5476
 				$image_array = $Image->getSpotterImage($row['registration']);
5477 5477
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5490,11 +5490,11 @@  discard block
 block discarded – undo
5490 5490
 	* @return Array the airport list
5491 5491
 	*
5492 5492
 	*/
5493
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5493
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5494 5494
 	{
5495 5495
 		global $globalDBdriver;
5496
-		$filter_query = $this->getFilter($filters,true,true);
5497
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5496
+		$filter_query = $this->getFilter($filters, true, true);
5497
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5498 5498
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA'";
5499 5499
                 if ($olderthanmonths > 0) {
5500 5500
             		if ($globalDBdriver == 'mysql') {
@@ -5523,7 +5523,7 @@  discard block
 block discarded – undo
5523 5523
 		$airport_array = array();
5524 5524
 		$temp_array = array();
5525 5525
         
5526
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5526
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5527 5527
 		{
5528 5528
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5529 5529
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5542,11 +5542,11 @@  discard block
 block discarded – undo
5542 5542
 	* @return Array the airport list
5543 5543
 	*
5544 5544
 	*/
5545
-	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5545
+	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5546 5546
 	{
5547 5547
 		global $globalDBdriver;
5548
-		$filter_query = $this->getFilter($filters,true,true);
5549
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5548
+		$filter_query = $this->getFilter($filters, true, true);
5549
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5550 5550
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' ";
5551 5551
                 if ($olderthanmonths > 0) {
5552 5552
             		if ($globalDBdriver == 'mysql') {
@@ -5575,7 +5575,7 @@  discard block
 block discarded – undo
5575 5575
 		$airport_array = array();
5576 5576
 		$temp_array = array();
5577 5577
         
5578
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5578
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5579 5579
 		{
5580 5580
 			$temp_array['airline_icao'] = $row['airline_icao'];
5581 5581
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -5595,11 +5595,11 @@  discard block
 block discarded – undo
5595 5595
 	* @return Array the airport list
5596 5596
 	*
5597 5597
 	*/
5598
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5598
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5599 5599
 	{
5600 5600
 		global $globalDBdriver;
5601
-		$filter_query = $this->getFilter($filters,true,true);
5602
-		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5601
+		$filter_query = $this->getFilter($filters, true, true);
5602
+		$query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5603 5603
 				FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao";
5604 5604
                 if ($olderthanmonths > 0) {
5605 5605
             		if ($globalDBdriver == 'mysql') {
@@ -5627,7 +5627,7 @@  discard block
 block discarded – undo
5627 5627
 		$airport_array = array();
5628 5628
 		$temp_array = array();
5629 5629
         
5630
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5630
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5631 5631
 		{
5632 5632
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5633 5633
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5646,11 +5646,11 @@  discard block
 block discarded – undo
5646 5646
 	* @return Array the airport list
5647 5647
 	*
5648 5648
 	*/
5649
-	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5649
+	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5650 5650
 	{
5651 5651
 		global $globalDBdriver;
5652
-		$filter_query = $this->getFilter($filters,true,true);
5653
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5652
+		$filter_query = $this->getFilter($filters, true, true);
5653
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5654 5654
 				FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
5655 5655
                 if ($olderthanmonths > 0) {
5656 5656
             		if ($globalDBdriver == 'mysql') {
@@ -5679,7 +5679,7 @@  discard block
 block discarded – undo
5679 5679
 		$airport_array = array();
5680 5680
 		$temp_array = array();
5681 5681
         
5682
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5682
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5683 5683
 		{
5684 5684
 			$temp_array['airline_icao'] = $row['airline_icao'];
5685 5685
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -5699,11 +5699,11 @@  discard block
 block discarded – undo
5699 5699
 	* @return Array the airport list
5700 5700
 	*
5701 5701
 	*/
5702
-	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
5702
+	public function countAllDepartureAirportsByAirline($airline_icao, $filters = array())
5703 5703
 	{
5704
-		$filter_query = $this->getFilter($filters,true,true);
5705
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5706
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5704
+		$filter_query = $this->getFilter($filters, true, true);
5705
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5706
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5707 5707
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
5708 5708
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5709 5709
 			    ORDER BY airport_departure_icao_count DESC";
@@ -5715,7 +5715,7 @@  discard block
 block discarded – undo
5715 5715
 		$airport_array = array();
5716 5716
 		$temp_array = array();
5717 5717
         
5718
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5718
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5719 5719
 		{
5720 5720
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5721 5721
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5737,11 +5737,11 @@  discard block
 block discarded – undo
5737 5737
 	* @return Array the airport list
5738 5738
 	*
5739 5739
 	*/
5740
-	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
5740
+	public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array())
5741 5741
 	{
5742
-		$filter_query = $this->getFilter($filters,true,true);
5743
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5744
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5742
+		$filter_query = $this->getFilter($filters, true, true);
5743
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5744
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5745 5745
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
5746 5746
                     GROUP BY spotter_output.departure_airport_country
5747 5747
 					ORDER BY airport_departure_country_count DESC";
@@ -5753,7 +5753,7 @@  discard block
 block discarded – undo
5753 5753
 		$airport_array = array();
5754 5754
 		$temp_array = array();
5755 5755
         
5756
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5756
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5757 5757
 		{
5758 5758
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5759 5759
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5772,11 +5772,11 @@  discard block
 block discarded – undo
5772 5772
 	* @return Array the airport list
5773 5773
 	*
5774 5774
 	*/
5775
-	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
5775
+	public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array())
5776 5776
 	{
5777
-		$filter_query = $this->getFilter($filters,true,true);
5778
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5779
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5777
+		$filter_query = $this->getFilter($filters, true, true);
5778
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5779
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5780 5780
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
5781 5781
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5782 5782
 			    ORDER BY airport_departure_icao_count DESC";
@@ -5788,7 +5788,7 @@  discard block
 block discarded – undo
5788 5788
 		$airport_array = array();
5789 5789
 		$temp_array = array();
5790 5790
         
5791
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5791
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5792 5792
 		{
5793 5793
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5794 5794
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5809,11 +5809,11 @@  discard block
 block discarded – undo
5809 5809
 	* @return Array the airport list
5810 5810
 	*
5811 5811
 	*/
5812
-	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
5812
+	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array())
5813 5813
 	{
5814
-		$filter_query = $this->getFilter($filters,true,true);
5815
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5816
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5814
+		$filter_query = $this->getFilter($filters, true, true);
5815
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5816
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5817 5817
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
5818 5818
                     GROUP BY spotter_output.departure_airport_country
5819 5819
 					ORDER BY airport_departure_country_count DESC";
@@ -5825,7 +5825,7 @@  discard block
 block discarded – undo
5825 5825
 		$airport_array = array();
5826 5826
 		$temp_array = array();
5827 5827
         
5828
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5828
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5829 5829
 		{
5830 5830
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5831 5831
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5843,11 +5843,11 @@  discard block
 block discarded – undo
5843 5843
 	* @return Array the airport list
5844 5844
 	*
5845 5845
 	*/
5846
-	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
5846
+	public function countAllDepartureAirportsByRegistration($registration, $filters = array())
5847 5847
 	{
5848
-		$filter_query = $this->getFilter($filters,true,true);
5849
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5850
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5848
+		$filter_query = $this->getFilter($filters, true, true);
5849
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5850
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5851 5851
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration 
5852 5852
                     GROUP BY spotter_output.departure_airport_icao
5853 5853
 					ORDER BY airport_departure_icao_count DESC";
@@ -5859,7 +5859,7 @@  discard block
 block discarded – undo
5859 5859
 		$airport_array = array();
5860 5860
 		$temp_array = array();
5861 5861
         
5862
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5862
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5863 5863
 		{
5864 5864
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5865 5865
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5880,11 +5880,11 @@  discard block
 block discarded – undo
5880 5880
 	* @return Array the airport list
5881 5881
 	*
5882 5882
 	*/
5883
-	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
5883
+	public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array())
5884 5884
 	{
5885
-		$filter_query = $this->getFilter($filters,true,true);
5886
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5887
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5885
+		$filter_query = $this->getFilter($filters, true, true);
5886
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5887
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5888 5888
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
5889 5889
                     GROUP BY spotter_output.departure_airport_country
5890 5890
 					ORDER BY airport_departure_country_count DESC";
@@ -5896,7 +5896,7 @@  discard block
 block discarded – undo
5896 5896
 		$airport_array = array();
5897 5897
 		$temp_array = array();
5898 5898
         
5899
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5899
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5900 5900
 		{
5901 5901
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5902 5902
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5914,11 +5914,11 @@  discard block
 block discarded – undo
5914 5914
 	* @return Array the airport list
5915 5915
 	*
5916 5916
 	*/
5917
-	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
5917
+	public function countAllDepartureAirportsByAirport($airport_icao, $filters = array())
5918 5918
 	{
5919
-		$filter_query = $this->getFilter($filters,true,true);
5920
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5921
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5919
+		$filter_query = $this->getFilter($filters, true, true);
5920
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5921
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5922 5922
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao 
5923 5923
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5924 5924
 			    ORDER BY airport_departure_icao_count DESC";
@@ -5930,7 +5930,7 @@  discard block
 block discarded – undo
5930 5930
 		$airport_array = array();
5931 5931
 		$temp_array = array();
5932 5932
         
5933
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5933
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5934 5934
 		{
5935 5935
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5936 5936
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5951,11 +5951,11 @@  discard block
 block discarded – undo
5951 5951
 	* @return Array the airport list
5952 5952
 	*
5953 5953
 	*/
5954
-	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
5954
+	public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array())
5955 5955
 	{
5956
-		$filter_query = $this->getFilter($filters,true,true);
5957
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5958
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5956
+		$filter_query = $this->getFilter($filters, true, true);
5957
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5958
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5959 5959
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
5960 5960
                     GROUP BY spotter_output.departure_airport_country
5961 5961
 					ORDER BY airport_departure_country_count DESC";
@@ -5967,7 +5967,7 @@  discard block
 block discarded – undo
5967 5967
 		$airport_array = array();
5968 5968
 		$temp_array = array();
5969 5969
         
5970
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5970
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5971 5971
 		{
5972 5972
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5973 5973
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5986,11 +5986,11 @@  discard block
 block discarded – undo
5986 5986
 	* @return Array the airport list
5987 5987
 	*
5988 5988
 	*/
5989
-	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
5989
+	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array())
5990 5990
 	{
5991
-		$filter_query = $this->getFilter($filters,true,true);
5992
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5993
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5991
+		$filter_query = $this->getFilter($filters, true, true);
5992
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5993
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5994 5994
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
5995 5995
                     GROUP BY spotter_output.departure_airport_icao
5996 5996
 					ORDER BY airport_departure_icao_count DESC";
@@ -6002,7 +6002,7 @@  discard block
 block discarded – undo
6002 6002
 		$airport_array = array();
6003 6003
 		$temp_array = array();
6004 6004
         
6005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6006 6006
 		{
6007 6007
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6008 6008
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6023,11 +6023,11 @@  discard block
 block discarded – undo
6023 6023
 	* @return Array the airport list
6024 6024
 	*
6025 6025
 	*/
6026
-	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
6026
+	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
6027 6027
 	{
6028
-		$filter_query = $this->getFilter($filters,true,true);
6029
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6030
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6028
+		$filter_query = $this->getFilter($filters, true, true);
6029
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6030
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6031 6031
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6032 6032
                     GROUP BY spotter_output.departure_airport_country
6033 6033
 					ORDER BY airport_departure_country_count DESC";
@@ -6039,7 +6039,7 @@  discard block
 block discarded – undo
6039 6039
 		$airport_array = array();
6040 6040
 		$temp_array = array();
6041 6041
         
6042
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6042
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6043 6043
 		{
6044 6044
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6045 6045
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6057,11 +6057,11 @@  discard block
 block discarded – undo
6057 6057
 	* @return Array the airport list
6058 6058
 	*
6059 6059
 	*/
6060
-	public function countAllDepartureAirportsByDate($date,$filters = array())
6060
+	public function countAllDepartureAirportsByDate($date, $filters = array())
6061 6061
 	{
6062 6062
 		global $globalTimezone, $globalDBdriver;
6063
-		$filter_query = $this->getFilter($filters,true,true);
6064
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6063
+		$filter_query = $this->getFilter($filters, true, true);
6064
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6065 6065
 		if ($globalTimezone != '') {
6066 6066
 			date_default_timezone_set($globalTimezone);
6067 6067
 			$datetime = new DateTime($date);
@@ -6069,12 +6069,12 @@  discard block
 block discarded – undo
6069 6069
 		} else $offset = '+00:00';
6070 6070
 
6071 6071
 		if ($globalDBdriver == 'mysql') {
6072
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6072
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6073 6073
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
6074 6074
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6075 6075
 					ORDER BY airport_departure_icao_count DESC";
6076 6076
 		} else {
6077
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6077
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6078 6078
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
6079 6079
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6080 6080
 					ORDER BY airport_departure_icao_count DESC";
@@ -6086,7 +6086,7 @@  discard block
 block discarded – undo
6086 6086
 		$airport_array = array();
6087 6087
 		$temp_array = array();
6088 6088
         
6089
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6089
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6090 6090
 		{
6091 6091
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6092 6092
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6107,11 +6107,11 @@  discard block
 block discarded – undo
6107 6107
 	* @return Array the airport list
6108 6108
 	*
6109 6109
 	*/
6110
-	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
6110
+	public function countAllDepartureAirportCountriesByDate($date, $filters = array())
6111 6111
 	{
6112 6112
 		global $globalTimezone, $globalDBdriver;
6113
-		$filter_query = $this->getFilter($filters,true,true);
6114
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6113
+		$filter_query = $this->getFilter($filters, true, true);
6114
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6115 6115
 		if ($globalTimezone != '') {
6116 6116
 			date_default_timezone_set($globalTimezone);
6117 6117
 			$datetime = new DateTime($date);
@@ -6119,12 +6119,12 @@  discard block
 block discarded – undo
6119 6119
 		} else $offset = '+00:00';
6120 6120
 
6121 6121
 		if ($globalDBdriver == 'mysql') {
6122
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6122
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6123 6123
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6124 6124
 					GROUP BY spotter_output.departure_airport_country
6125 6125
 					ORDER BY airport_departure_country_count DESC";
6126 6126
 		} else {
6127
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6127
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6128 6128
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
6129 6129
 					GROUP BY spotter_output.departure_airport_country
6130 6130
 					ORDER BY airport_departure_country_count DESC";
@@ -6136,7 +6136,7 @@  discard block
 block discarded – undo
6136 6136
 		$airport_array = array();
6137 6137
 		$temp_array = array();
6138 6138
         
6139
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6139
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6140 6140
 		{
6141 6141
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6142 6142
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6154,11 +6154,11 @@  discard block
 block discarded – undo
6154 6154
 	* @return Array the airport list
6155 6155
 	*
6156 6156
 	*/
6157
-	public function countAllDepartureAirportsByIdent($ident,$filters = array())
6157
+	public function countAllDepartureAirportsByIdent($ident, $filters = array())
6158 6158
 	{
6159
-		$filter_query = $this->getFilter($filters,true,true);
6160
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6161
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6159
+		$filter_query = $this->getFilter($filters, true, true);
6160
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6161
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6162 6162
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.ident = :ident 
6163 6163
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6164 6164
 		    ORDER BY airport_departure_icao_count DESC";
@@ -6170,7 +6170,7 @@  discard block
 block discarded – undo
6170 6170
 		$airport_array = array();
6171 6171
 		$temp_array = array();
6172 6172
         
6173
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6173
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6174 6174
 		{
6175 6175
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6176 6176
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6192,11 +6192,11 @@  discard block
 block discarded – undo
6192 6192
 	* @return Array the airport list
6193 6193
 	*
6194 6194
 	*/
6195
-	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
6195
+	public function countAllDepartureAirportCountriesByIdent($ident, $filters = array())
6196 6196
 	{
6197
-		$filter_query = $this->getFilter($filters,true,true);
6198
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6199
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6197
+		$filter_query = $this->getFilter($filters, true, true);
6198
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6199
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6200 6200
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
6201 6201
                     GROUP BY spotter_output.departure_airport_country
6202 6202
 					ORDER BY airport_departure_country_count DESC";
@@ -6208,7 +6208,7 @@  discard block
 block discarded – undo
6208 6208
 		$airport_array = array();
6209 6209
 		$temp_array = array();
6210 6210
         
6211
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6211
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6212 6212
 		{
6213 6213
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6214 6214
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6227,12 +6227,12 @@  discard block
 block discarded – undo
6227 6227
 	* @return Array the airport list
6228 6228
 	*
6229 6229
 	*/
6230
-	public function countAllDepartureAirportsByCountry($country,$filters = array())
6230
+	public function countAllDepartureAirportsByCountry($country, $filters = array())
6231 6231
 	{
6232
-		$filter_query = $this->getFilter($filters,true,true);
6233
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6232
+		$filter_query = $this->getFilter($filters, true, true);
6233
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6234 6234
 
6235
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6235
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6236 6236
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
6237 6237
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6238 6238
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6244,7 +6244,7 @@  discard block
 block discarded – undo
6244 6244
 		$airport_array = array();
6245 6245
 		$temp_array = array();
6246 6246
         
6247
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6247
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6248 6248
 		{
6249 6249
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6250 6250
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6265,11 +6265,11 @@  discard block
 block discarded – undo
6265 6265
 	* @return Array the airport list
6266 6266
 	*
6267 6267
 	*/
6268
-	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
6268
+	public function countAllDepartureAirportCountriesByCountry($country, $filters = array())
6269 6269
 	{
6270
-		$filter_query = $this->getFilter($filters,true,true);
6271
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6272
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6270
+		$filter_query = $this->getFilter($filters, true, true);
6271
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6272
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6273 6273
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6274 6274
                     GROUP BY spotter_output.departure_airport_country
6275 6275
 					ORDER BY airport_departure_country_count DESC";
@@ -6281,7 +6281,7 @@  discard block
 block discarded – undo
6281 6281
 		$airport_array = array();
6282 6282
 		$temp_array = array();
6283 6283
         
6284
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6284
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6285 6285
 		{
6286 6286
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6287 6287
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6299,11 +6299,11 @@  discard block
 block discarded – undo
6299 6299
 	* @return Array the airport list
6300 6300
 	*
6301 6301
 	*/
6302
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
6302
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6303 6303
 	{
6304 6304
 		global $globalDBdriver;
6305
-		$filter_query = $this->getFilter($filters,true,true);
6306
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6305
+		$filter_query = $this->getFilter($filters, true, true);
6306
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6307 6307
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
6308 6308
                 if ($olderthanmonths > 0) {
6309 6309
             		if ($globalDBdriver == 'mysql') {
@@ -6338,7 +6338,7 @@  discard block
 block discarded – undo
6338 6338
 		$airport_array = array();
6339 6339
 		$temp_array = array();
6340 6340
         
6341
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6341
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6342 6342
 		{
6343 6343
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6344 6344
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6361,11 +6361,11 @@  discard block
 block discarded – undo
6361 6361
 	* @return Array the airport list
6362 6362
 	*
6363 6363
 	*/
6364
-	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
6364
+	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6365 6365
 	{
6366 6366
 		global $globalDBdriver;
6367
-		$filter_query = $this->getFilter($filters,true,true);
6368
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6367
+		$filter_query = $this->getFilter($filters, true, true);
6368
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6369 6369
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' ";
6370 6370
                 if ($olderthanmonths > 0) {
6371 6371
             		if ($globalDBdriver == 'mysql') {
@@ -6400,7 +6400,7 @@  discard block
 block discarded – undo
6400 6400
 		$airport_array = array();
6401 6401
 		$temp_array = array();
6402 6402
         
6403
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6403
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6404 6404
 		{
6405 6405
 			$temp_array['airline_icao'] = $row['airline_icao'];
6406 6406
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -6425,11 +6425,11 @@  discard block
 block discarded – undo
6425 6425
 	* @return Array the airport list
6426 6426
 	*
6427 6427
 	*/
6428
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
6428
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6429 6429
 	{
6430 6430
 		global $globalDBdriver;
6431
-		$filter_query = $this->getFilter($filters,true,true);
6432
-		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6431
+		$filter_query = $this->getFilter($filters, true, true);
6432
+		$query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6433 6433
 			FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao";
6434 6434
                 if ($olderthanmonths > 0) {
6435 6435
             		if ($globalDBdriver == 'mysql') {
@@ -6463,7 +6463,7 @@  discard block
 block discarded – undo
6463 6463
 		$airport_array = array();
6464 6464
 		$temp_array = array();
6465 6465
         
6466
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6466
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6467 6467
 		{
6468 6468
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6469 6469
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6486,11 +6486,11 @@  discard block
 block discarded – undo
6486 6486
 	* @return Array the airport list
6487 6487
 	*
6488 6488
 	*/
6489
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
6489
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6490 6490
 	{
6491 6491
 		global $globalDBdriver;
6492
-		$filter_query = $this->getFilter($filters,true,true);
6493
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6492
+		$filter_query = $this->getFilter($filters, true, true);
6493
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6494 6494
 			FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
6495 6495
                 if ($olderthanmonths > 0) {
6496 6496
             		if ($globalDBdriver == 'mysql') {
@@ -6525,7 +6525,7 @@  discard block
 block discarded – undo
6525 6525
 		$airport_array = array();
6526 6526
 		$temp_array = array();
6527 6527
         
6528
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6528
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6529 6529
 		{
6530 6530
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6531 6531
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6551,9 +6551,9 @@  discard block
 block discarded – undo
6551 6551
 	*/
6552 6552
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
6553 6553
 	{
6554
-		$filter_query = $this->getFilter($filters,true,true);
6555
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6556
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6554
+		$filter_query = $this->getFilter($filters, true, true);
6555
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6556
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6557 6557
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
6558 6558
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6559 6559
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -6564,7 +6564,7 @@  discard block
 block discarded – undo
6564 6564
 		$airport_array = array();
6565 6565
 		$temp_array = array();
6566 6566
         
6567
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6567
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6568 6568
 		{
6569 6569
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6570 6570
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6585,12 +6585,12 @@  discard block
 block discarded – undo
6585 6585
 	* @return Array the airport list
6586 6586
 	*
6587 6587
 	*/
6588
-	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
6588
+	public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array())
6589 6589
 	{
6590
-		$filter_query = $this->getFilter($filters,true,true);
6591
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6590
+		$filter_query = $this->getFilter($filters, true, true);
6591
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6592 6592
 					
6593
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6593
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6594 6594
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6595 6595
                     GROUP BY spotter_output.arrival_airport_country
6596 6596
 					ORDER BY airport_arrival_country_count DESC";
@@ -6602,7 +6602,7 @@  discard block
 block discarded – undo
6602 6602
 		$airport_array = array();
6603 6603
 		$temp_array = array();
6604 6604
         
6605
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6605
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6606 6606
 		{
6607 6607
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6608 6608
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6620,11 +6620,11 @@  discard block
 block discarded – undo
6620 6620
 	* @return Array the airport list
6621 6621
 	*
6622 6622
 	*/
6623
-	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
6623
+	public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array())
6624 6624
 	{
6625
-		$filter_query = $this->getFilter($filters,true,true);
6626
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6627
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6625
+		$filter_query = $this->getFilter($filters, true, true);
6626
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6627
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6628 6628
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
6629 6629
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6630 6630
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -6636,7 +6636,7 @@  discard block
 block discarded – undo
6636 6636
 		$airport_array = array();
6637 6637
 		$temp_array = array();
6638 6638
         
6639
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6639
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6640 6640
 		{
6641 6641
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6642 6642
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6658,11 +6658,11 @@  discard block
 block discarded – undo
6658 6658
 	* @return Array the airport list
6659 6659
 	*
6660 6660
 	*/
6661
-	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
6661
+	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array())
6662 6662
 	{
6663
-		$filter_query = $this->getFilter($filters,true,true);
6664
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6665
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6663
+		$filter_query = $this->getFilter($filters, true, true);
6664
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6665
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6666 6666
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
6667 6667
                     GROUP BY spotter_output.arrival_airport_country
6668 6668
 					ORDER BY airport_arrival_country_count DESC";
@@ -6674,7 +6674,7 @@  discard block
 block discarded – undo
6674 6674
 		$airport_array = array();
6675 6675
 		$temp_array = array();
6676 6676
         
6677
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6677
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6678 6678
 		{
6679 6679
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6680 6680
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6692,12 +6692,12 @@  discard block
 block discarded – undo
6692 6692
 	* @return Array the airport list
6693 6693
 	*
6694 6694
 	*/
6695
-	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
6695
+	public function countAllArrivalAirportsByRegistration($registration, $filters = array())
6696 6696
 	{
6697
-		$filter_query = $this->getFilter($filters,true,true);
6698
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6697
+		$filter_query = $this->getFilter($filters, true, true);
6698
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6699 6699
 
6700
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6700
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6701 6701
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.registration = :registration 
6702 6702
                     GROUP BY spotter_output.arrival_airport_icao
6703 6703
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6709,7 +6709,7 @@  discard block
 block discarded – undo
6709 6709
 		$airport_array = array();
6710 6710
 		$temp_array = array();
6711 6711
         
6712
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6712
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6713 6713
 		{
6714 6714
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6715 6715
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6730,11 +6730,11 @@  discard block
 block discarded – undo
6730 6730
 	* @return Array the airport list
6731 6731
 	*
6732 6732
 	*/
6733
-	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
6733
+	public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array())
6734 6734
 	{
6735
-		$filter_query = $this->getFilter($filters,true,true);
6736
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6737
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6735
+		$filter_query = $this->getFilter($filters, true, true);
6736
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6737
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6738 6738
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
6739 6739
                     GROUP BY spotter_output.arrival_airport_country
6740 6740
 					ORDER BY airport_arrival_country_count DESC";
@@ -6746,7 +6746,7 @@  discard block
 block discarded – undo
6746 6746
 		$airport_array = array();
6747 6747
 		$temp_array = array();
6748 6748
         
6749
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6749
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6750 6750
 		{
6751 6751
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6752 6752
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6765,11 +6765,11 @@  discard block
 block discarded – undo
6765 6765
 	* @return Array the airport list
6766 6766
 	*
6767 6767
 	*/
6768
-	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
6768
+	public function countAllArrivalAirportsByAirport($airport_icao, $filters = array())
6769 6769
 	{
6770
-		$filter_query = $this->getFilter($filters,true,true);
6771
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6772
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6770
+		$filter_query = $this->getFilter($filters, true, true);
6771
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6772
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6773 6773
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.departure_airport_icao = :airport_icao 
6774 6774
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6775 6775
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -6781,7 +6781,7 @@  discard block
 block discarded – undo
6781 6781
 		$airport_array = array();
6782 6782
 		$temp_array = array();
6783 6783
         
6784
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6784
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6785 6785
 		{
6786 6786
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6787 6787
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6802,11 +6802,11 @@  discard block
 block discarded – undo
6802 6802
 	* @return Array the airport list
6803 6803
 	*
6804 6804
 	*/
6805
-	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
6805
+	public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array())
6806 6806
 	{
6807
-		$filter_query = $this->getFilter($filters,true,true);
6808
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6809
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6807
+		$filter_query = $this->getFilter($filters, true, true);
6808
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6809
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6810 6810
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
6811 6811
                     GROUP BY spotter_output.arrival_airport_country
6812 6812
 					ORDER BY airport_arrival_country_count DESC";
@@ -6818,7 +6818,7 @@  discard block
 block discarded – undo
6818 6818
 		$airport_array = array();
6819 6819
 		$temp_array = array();
6820 6820
         
6821
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6821
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6822 6822
 		{
6823 6823
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6824 6824
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6836,11 +6836,11 @@  discard block
 block discarded – undo
6836 6836
 	* @return Array the airport list
6837 6837
 	*
6838 6838
 	*/
6839
-	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
6839
+	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array())
6840 6840
 	{
6841
-		$filter_query = $this->getFilter($filters,true,true);
6842
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6843
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6841
+		$filter_query = $this->getFilter($filters, true, true);
6842
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6843
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6844 6844
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6845 6845
                     GROUP BY spotter_output.arrival_airport_icao
6846 6846
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6852,7 +6852,7 @@  discard block
 block discarded – undo
6852 6852
 		$airport_array = array();
6853 6853
 		$temp_array = array();
6854 6854
         
6855
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6855
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6856 6856
 		{
6857 6857
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6858 6858
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6874,11 +6874,11 @@  discard block
 block discarded – undo
6874 6874
 	* @return Array the airport list
6875 6875
 	*
6876 6876
 	*/
6877
-	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
6877
+	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
6878 6878
 	{
6879
-		$filter_query = $this->getFilter($filters,true,true);
6880
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6881
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6879
+		$filter_query = $this->getFilter($filters, true, true);
6880
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6881
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6882 6882
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6883 6883
                     GROUP BY spotter_output.arrival_airport_country
6884 6884
 					ORDER BY airport_arrival_country_count DESC";
@@ -6890,7 +6890,7 @@  discard block
 block discarded – undo
6890 6890
 		$airport_array = array();
6891 6891
 		$temp_array = array();
6892 6892
         
6893
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6893
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6894 6894
 		{
6895 6895
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6896 6896
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6909,11 +6909,11 @@  discard block
 block discarded – undo
6909 6909
 	* @return Array the airport list
6910 6910
 	*
6911 6911
 	*/
6912
-	public function countAllArrivalAirportsByDate($date,$filters = array())
6912
+	public function countAllArrivalAirportsByDate($date, $filters = array())
6913 6913
 	{
6914 6914
 		global $globalTimezone, $globalDBdriver;
6915
-		$filter_query = $this->getFilter($filters,true,true);
6916
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6915
+		$filter_query = $this->getFilter($filters, true, true);
6916
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6917 6917
 		if ($globalTimezone != '') {
6918 6918
 			date_default_timezone_set($globalTimezone);
6919 6919
 			$datetime = new DateTime($date);
@@ -6921,12 +6921,12 @@  discard block
 block discarded – undo
6921 6921
 		} else $offset = '+00:00';
6922 6922
 
6923 6923
 		if ($globalDBdriver == 'mysql') {
6924
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6924
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6925 6925
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
6926 6926
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6927 6927
 					ORDER BY airport_arrival_icao_count DESC";
6928 6928
 		} else {
6929
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6929
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6930 6930
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
6931 6931
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6932 6932
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6938,7 +6938,7 @@  discard block
 block discarded – undo
6938 6938
 		$airport_array = array();
6939 6939
 		$temp_array = array();
6940 6940
         
6941
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6941
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6942 6942
 		{
6943 6943
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6944 6944
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6962,8 +6962,8 @@  discard block
 block discarded – undo
6962 6962
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
6963 6963
 	{
6964 6964
 		global $globalTimezone, $globalDBdriver;
6965
-		$filter_query = $this->getFilter($filters,true,true);
6966
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6965
+		$filter_query = $this->getFilter($filters, true, true);
6966
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6967 6967
 		if ($globalTimezone != '') {
6968 6968
 			date_default_timezone_set($globalTimezone);
6969 6969
 			$datetime = new DateTime($date);
@@ -6971,12 +6971,12 @@  discard block
 block discarded – undo
6971 6971
 		} else $offset = '+00:00';
6972 6972
 
6973 6973
 		if ($globalDBdriver == 'mysql') {
6974
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6974
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6975 6975
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6976 6976
 					GROUP BY spotter_output.arrival_airport_country
6977 6977
 					ORDER BY airport_arrival_country_count DESC";
6978 6978
 		} else {
6979
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6979
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6980 6980
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
6981 6981
 					GROUP BY spotter_output.arrival_airport_country
6982 6982
 					ORDER BY airport_arrival_country_count DESC";
@@ -6988,7 +6988,7 @@  discard block
 block discarded – undo
6988 6988
 		$airport_array = array();
6989 6989
 		$temp_array = array();
6990 6990
         
6991
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6991
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6992 6992
 		{
6993 6993
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6994 6994
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7006,11 +7006,11 @@  discard block
 block discarded – undo
7006 7006
 	* @return Array the airport list
7007 7007
 	*
7008 7008
 	*/
7009
-	public function countAllArrivalAirportsByIdent($ident,$filters = array())
7009
+	public function countAllArrivalAirportsByIdent($ident, $filters = array())
7010 7010
 	{
7011
-		$filter_query = $this->getFilter($filters,true,true);
7012
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7013
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7011
+		$filter_query = $this->getFilter($filters, true, true);
7012
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7013
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7014 7014
 		    FROM spotter_output".$filter_query." WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.ident = :ident  
7015 7015
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7016 7016
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -7022,7 +7022,7 @@  discard block
 block discarded – undo
7022 7022
 		$airport_array = array();
7023 7023
 		$temp_array = array();
7024 7024
         
7025
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7025
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7026 7026
 		{
7027 7027
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7028 7028
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7045,9 +7045,9 @@  discard block
 block discarded – undo
7045 7045
 	*/
7046 7046
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
7047 7047
 	{
7048
-		$filter_query = $this->getFilter($filters,true,true);
7049
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7050
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7048
+		$filter_query = $this->getFilter($filters, true, true);
7049
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7050
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7051 7051
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
7052 7052
                     GROUP BY spotter_output.arrival_airport_country
7053 7053
 					ORDER BY airport_arrival_country_count DESC";
@@ -7059,7 +7059,7 @@  discard block
 block discarded – undo
7059 7059
 		$airport_array = array();
7060 7060
 		$temp_array = array();
7061 7061
         
7062
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7062
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7063 7063
 		{
7064 7064
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7065 7065
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7078,11 +7078,11 @@  discard block
 block discarded – undo
7078 7078
 	* @return Array the airport list
7079 7079
 	*
7080 7080
 	*/
7081
-	public function countAllArrivalAirportsByCountry($country,$filters = array())
7081
+	public function countAllArrivalAirportsByCountry($country, $filters = array())
7082 7082
 	{
7083
-		$filter_query = $this->getFilter($filters,true,true);
7084
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7085
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7083
+		$filter_query = $this->getFilter($filters, true, true);
7084
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7085
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7086 7086
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
7087 7087
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7088 7088
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7094,7 +7094,7 @@  discard block
 block discarded – undo
7094 7094
 		$airport_array = array();
7095 7095
 		$temp_array = array();
7096 7096
         
7097
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7097
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7098 7098
 		{
7099 7099
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7100 7100
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7115,11 +7115,11 @@  discard block
 block discarded – undo
7115 7115
 	* @return Array the airport list
7116 7116
 	*
7117 7117
 	*/
7118
-	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
7118
+	public function countAllArrivalAirportCountriesByCountry($country, $filters = array())
7119 7119
 	{
7120
-		$filter_query = $this->getFilter($filters,true,true);
7121
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7122
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7120
+		$filter_query = $this->getFilter($filters, true, true);
7121
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7122
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7123 7123
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
7124 7124
                     GROUP BY spotter_output.arrival_airport_country
7125 7125
 					ORDER BY airport_arrival_country_count DESC";
@@ -7131,7 +7131,7 @@  discard block
 block discarded – undo
7131 7131
 		$airport_array = array();
7132 7132
 		$temp_array = array();
7133 7133
         
7134
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7134
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7135 7135
 		{
7136 7136
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7137 7137
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7152,7 +7152,7 @@  discard block
 block discarded – undo
7152 7152
 	*/
7153 7153
 	public function countAllDepartureCountries($filters = array())
7154 7154
 	{
7155
-		$filter_query = $this->getFilter($filters,true,true);
7155
+		$filter_query = $this->getFilter($filters, true, true);
7156 7156
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7157 7157
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA'";
7158 7158
 		$query .= " GROUP BY spotter_output.departure_airport_country
@@ -7166,7 +7166,7 @@  discard block
 block discarded – undo
7166 7166
 		$airport_array = array();
7167 7167
 		$temp_array = array();
7168 7168
         
7169
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7169
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7170 7170
 		{
7171 7171
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
7172 7172
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -7184,9 +7184,9 @@  discard block
 block discarded – undo
7184 7184
 	* @return Array the airport arrival list
7185 7185
 	*
7186 7186
 	*/
7187
-	public function countAllArrivalCountries($limit = true,$filters = array())
7187
+	public function countAllArrivalCountries($limit = true, $filters = array())
7188 7188
 	{
7189
-		$filter_query = $this->getFilter($filters,true,true);
7189
+		$filter_query = $this->getFilter($filters, true, true);
7190 7190
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7191 7191
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7192 7192
 		$query .= " GROUP BY spotter_output.arrival_airport_country
@@ -7200,7 +7200,7 @@  discard block
 block discarded – undo
7200 7200
 		$airport_array = array();
7201 7201
 		$temp_array = array();
7202 7202
         
7203
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7203
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7204 7204
 		{
7205 7205
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
7206 7206
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -7223,8 +7223,8 @@  discard block
 block discarded – undo
7223 7223
 	*/
7224 7224
 	public function countAllRoutes($filters = array())
7225 7225
 	{
7226
-		$filter_query = $this->getFilter($filters,true,true);
7227
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7226
+		$filter_query = $this->getFilter($filters, true, true);
7227
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7228 7228
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> 'NA'
7229 7229
                     GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7230 7230
                     ORDER BY route_count DESC
@@ -7237,7 +7237,7 @@  discard block
 block discarded – undo
7237 7237
 		$routes_array = array();
7238 7238
 		$temp_array = array();
7239 7239
         
7240
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7240
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7241 7241
 		{
7242 7242
 			$temp_array['route_count'] = $row['route_count'];
7243 7243
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7264,11 +7264,11 @@  discard block
 block discarded – undo
7264 7264
 	* @return Array the route list
7265 7265
 	*
7266 7266
 	*/
7267
-	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
7267
+	public function countAllRoutesByAircraft($aircraft_icao, $filters = array())
7268 7268
 	{
7269
-		$filter_query = $this->getFilter($filters,true,true);
7270
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7271
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7269
+		$filter_query = $this->getFilter($filters, true, true);
7270
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7271
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7272 7272
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
7273 7273
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7274 7274
 			    ORDER BY route_count DESC";
@@ -7279,7 +7279,7 @@  discard block
 block discarded – undo
7279 7279
 		$routes_array = array();
7280 7280
 		$temp_array = array();
7281 7281
         
7282
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7282
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7283 7283
 		{
7284 7284
 			$temp_array['route_count'] = $row['route_count'];
7285 7285
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7306,9 +7306,9 @@  discard block
 block discarded – undo
7306 7306
 	*/
7307 7307
 	public function countAllRoutesByRegistration($registration, $filters = array())
7308 7308
 	{
7309
-		$filter_query = $this->getFilter($filters,true,true);
7309
+		$filter_query = $this->getFilter($filters, true, true);
7310 7310
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7311
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7311
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7312 7312
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration 
7313 7313
                     GROUP BY route
7314 7314
                     ORDER BY route_count DESC";
@@ -7320,7 +7320,7 @@  discard block
 block discarded – undo
7320 7320
 		$routes_array = array();
7321 7321
 		$temp_array = array();
7322 7322
         
7323
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7323
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7324 7324
 		{
7325 7325
 			$temp_array['route_count'] = $row['route_count'];
7326 7326
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7348,9 +7348,9 @@  discard block
 block discarded – undo
7348 7348
 	*/
7349 7349
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
7350 7350
 	{
7351
-		$filter_query = $this->getFilter($filters,true,true);
7352
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7353
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7351
+		$filter_query = $this->getFilter($filters, true, true);
7352
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7353
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7354 7354
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
7355 7355
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7356 7356
 			    ORDER BY route_count DESC";
@@ -7362,7 +7362,7 @@  discard block
 block discarded – undo
7362 7362
 		$routes_array = array();
7363 7363
 		$temp_array = array();
7364 7364
         
7365
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7365
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7366 7366
 		{
7367 7367
 			$temp_array['route_count'] = $row['route_count'];
7368 7368
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7390,9 +7390,9 @@  discard block
 block discarded – undo
7390 7390
 	*/
7391 7391
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
7392 7392
 	{
7393
-		$filter_query = $this->getFilter($filters,true,true);
7394
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7395
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7393
+		$filter_query = $this->getFilter($filters, true, true);
7394
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7395
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7396 7396
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
7397 7397
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7398 7398
 			    ORDER BY route_count DESC";
@@ -7403,7 +7403,7 @@  discard block
 block discarded – undo
7403 7403
 		$routes_array = array();
7404 7404
 		$temp_array = array();
7405 7405
         
7406
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7406
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7407 7407
 		{
7408 7408
 			$temp_array['route_count'] = $row['route_count'];
7409 7409
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7431,9 +7431,9 @@  discard block
 block discarded – undo
7431 7431
 	*/
7432 7432
 	public function countAllRoutesByCountry($country, $filters = array())
7433 7433
 	{
7434
-		$filter_query = $this->getFilter($filters,true,true);
7435
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7436
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7434
+		$filter_query = $this->getFilter($filters, true, true);
7435
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7436
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7437 7437
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
7438 7438
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7439 7439
 			    ORDER BY route_count DESC";
@@ -7444,7 +7444,7 @@  discard block
 block discarded – undo
7444 7444
 		$routes_array = array();
7445 7445
 		$temp_array = array();
7446 7446
         
7447
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7447
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7448 7448
 		{
7449 7449
 			$temp_array['route_count'] = $row['route_count'];
7450 7450
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7472,8 +7472,8 @@  discard block
 block discarded – undo
7472 7472
 	public function countAllRoutesByDate($date, $filters = array())
7473 7473
 	{
7474 7474
 		global $globalTimezone, $globalDBdriver;
7475
-		$filter_query = $this->getFilter($filters,true,true);
7476
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7475
+		$filter_query = $this->getFilter($filters, true, true);
7476
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7477 7477
 		if ($globalTimezone != '') {
7478 7478
 			date_default_timezone_set($globalTimezone);
7479 7479
 			$datetime = new DateTime($date);
@@ -7481,12 +7481,12 @@  discard block
 block discarded – undo
7481 7481
 		} else $offset = '+00:00';
7482 7482
 		
7483 7483
 		if ($globalDBdriver == 'mysql') {
7484
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7484
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7485 7485
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
7486 7486
 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7487 7487
 				    ORDER BY route_count DESC";
7488 7488
 		} else {
7489
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7489
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7490 7490
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
7491 7491
 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7492 7492
 				    ORDER BY route_count DESC";
@@ -7498,7 +7498,7 @@  discard block
 block discarded – undo
7498 7498
 		$routes_array = array();
7499 7499
 		$temp_array = array();
7500 7500
         
7501
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7501
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7502 7502
 		{
7503 7503
 			$temp_array['route_count'] = $row['route_count'];
7504 7504
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7525,9 +7525,9 @@  discard block
 block discarded – undo
7525 7525
 	*/
7526 7526
 	public function countAllRoutesByIdent($ident, $filters = array())
7527 7527
 	{
7528
-		$filter_query = $this->getFilter($filters,true,true);
7529
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7530
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7528
+		$filter_query = $this->getFilter($filters, true, true);
7529
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7530
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7531 7531
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident   
7532 7532
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7533 7533
                     ORDER BY route_count DESC";
@@ -7539,7 +7539,7 @@  discard block
 block discarded – undo
7539 7539
 		$routes_array = array();
7540 7540
 		$temp_array = array();
7541 7541
         
7542
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7542
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7543 7543
 		{
7544 7544
 			$temp_array['route_count'] = $row['route_count'];
7545 7545
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7566,9 +7566,9 @@  discard block
 block discarded – undo
7566 7566
 	*/
7567 7567
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
7568 7568
 	{
7569
-		$filter_query = $this->getFilter($filters,true,true);
7570
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7571
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7569
+		$filter_query = $this->getFilter($filters, true, true);
7570
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7571
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7572 7572
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
7573 7573
                     GROUP BY route
7574 7574
                     ORDER BY route_count DESC";
@@ -7580,7 +7580,7 @@  discard block
 block discarded – undo
7580 7580
 		$routes_array = array();
7581 7581
 		$temp_array = array();
7582 7582
         
7583
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7583
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7584 7584
 		{
7585 7585
 			$temp_array['route_count'] = $row['route_count'];
7586 7586
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7608,8 +7608,8 @@  discard block
 block discarded – undo
7608 7608
 	*/
7609 7609
 	public function countAllRoutesWithWaypoints($filters = array())
7610 7610
 	{
7611
-		$filter_query = $this->getFilter($filters,true,true);
7612
-		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7611
+		$filter_query = $this->getFilter($filters, true, true);
7612
+		$query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7613 7613
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
7614 7614
                     GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7615 7615
                     ORDER BY route_count DESC
@@ -7622,7 +7622,7 @@  discard block
 block discarded – undo
7622 7622
 		$routes_array = array();
7623 7623
 		$temp_array = array();
7624 7624
         
7625
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7625
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7626 7626
 		{
7627 7627
 			$temp_array['spotter_id'] = $row['spotter_id'];
7628 7628
 			$temp_array['route_count'] = $row['route_count'];
@@ -7647,11 +7647,11 @@  discard block
 block discarded – undo
7647 7647
 	* @return Array the callsign list
7648 7648
 	*
7649 7649
 	*/
7650
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
7650
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
7651 7651
 	{
7652 7652
 		global $globalDBdriver;
7653
-		$filter_query = $this->getFilter($filters,true,true);
7654
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7653
+		$filter_query = $this->getFilter($filters, true, true);
7654
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7655 7655
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7656 7656
 		 if ($olderthanmonths > 0) {
7657 7657
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -7670,7 +7670,7 @@  discard block
 block discarded – undo
7670 7670
 		$callsign_array = array();
7671 7671
 		$temp_array = array();
7672 7672
         
7673
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7673
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7674 7674
 		{
7675 7675
 			$temp_array['callsign_icao'] = $row['ident'];
7676 7676
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7692,8 +7692,8 @@  discard block
 block discarded – undo
7692 7692
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
7693 7693
 	{
7694 7694
 		global $globalDBdriver;
7695
-		$filter_query = $this->getFilter($filters,true,true);
7696
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7695
+		$filter_query = $this->getFilter($filters, true, true);
7696
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7697 7697
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7698 7698
 		 if ($olderthanmonths > 0) {
7699 7699
 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
@@ -7712,7 +7712,7 @@  discard block
 block discarded – undo
7712 7712
 		$callsign_array = array();
7713 7713
 		$temp_array = array();
7714 7714
         
7715
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7715
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7716 7716
 		{
7717 7717
 			$temp_array['callsign_icao'] = $row['ident'];
7718 7718
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7766,7 +7766,7 @@  discard block
 block discarded – undo
7766 7766
 		$date_array = array();
7767 7767
 		$temp_array = array();
7768 7768
         
7769
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7769
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7770 7770
 		{
7771 7771
 			$temp_array['date_name'] = $row['date_name'];
7772 7772
 			$temp_array['date_count'] = $row['date_count'];
@@ -7791,15 +7791,15 @@  discard block
 block discarded – undo
7791 7791
 			$datetime = new DateTime();
7792 7792
 			$offset = $datetime->format('P');
7793 7793
 		} else $offset = '+00:00';
7794
-		$filter_query = $this->getFilter($filters,true,true);
7794
+		$filter_query = $this->getFilter($filters, true, true);
7795 7795
 		if ($globalDBdriver == 'mysql') {
7796
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7796
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7797 7797
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
7798 7798
 								GROUP BY spotter_output.airline_icao, date_name 
7799 7799
 								ORDER BY date_count DESC
7800 7800
 								LIMIT 10 OFFSET 0";
7801 7801
 		} else {
7802
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7802
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7803 7803
 								FROM spotter_output 
7804 7804
 								WHERE spotter_output.airline_icao <> '' 
7805 7805
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -7814,7 +7814,7 @@  discard block
 block discarded – undo
7814 7814
 		$date_array = array();
7815 7815
 		$temp_array = array();
7816 7816
         
7817
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7817
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7818 7818
 		{
7819 7819
 			$temp_array['date_name'] = $row['date_name'];
7820 7820
 			$temp_array['date_count'] = $row['date_count'];
@@ -7840,7 +7840,7 @@  discard block
 block discarded – undo
7840 7840
 			$datetime = new DateTime();
7841 7841
 			$offset = $datetime->format('P');
7842 7842
 		} else $offset = '+00:00';
7843
-		$filter_query = $this->getFilter($filters,true,true);
7843
+		$filter_query = $this->getFilter($filters, true, true);
7844 7844
 		if ($globalDBdriver == 'mysql') {
7845 7845
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7846 7846
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -7861,7 +7861,7 @@  discard block
 block discarded – undo
7861 7861
 		$date_array = array();
7862 7862
 		$temp_array = array();
7863 7863
         
7864
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7864
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7865 7865
 		{
7866 7866
 			$temp_array['date_name'] = $row['date_name'];
7867 7867
 			$temp_array['date_count'] = $row['date_count'];
@@ -7886,7 +7886,7 @@  discard block
 block discarded – undo
7886 7886
 			$datetime = new DateTime();
7887 7887
 			$offset = $datetime->format('P');
7888 7888
 		} else $offset = '+00:00';
7889
-		$filter_query = $this->getFilter($filters,true,true);
7889
+		$filter_query = $this->getFilter($filters, true, true);
7890 7890
 		if ($globalDBdriver == 'mysql') {
7891 7891
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7892 7892
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -7907,7 +7907,7 @@  discard block
 block discarded – undo
7907 7907
 		$date_array = array();
7908 7908
 		$temp_array = array();
7909 7909
         
7910
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7910
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7911 7911
 		{
7912 7912
 			$temp_array['date_name'] = $row['date_name'];
7913 7913
 			$temp_array['date_count'] = $row['date_count'];
@@ -7928,7 +7928,7 @@  discard block
 block discarded – undo
7928 7928
 	public function countAllDatesLastMonthByAirlines($filters = array())
7929 7929
 	{
7930 7930
 		global $globalTimezone, $globalDBdriver;
7931
-		$filter_query = $this->getFilter($filters,true,true);
7931
+		$filter_query = $this->getFilter($filters, true, true);
7932 7932
 		if ($globalTimezone != '') {
7933 7933
 			date_default_timezone_set($globalTimezone);
7934 7934
 			$datetime = new DateTime();
@@ -7936,13 +7936,13 @@  discard block
 block discarded – undo
7936 7936
 		} else $offset = '+00:00';
7937 7937
 		
7938 7938
 		if ($globalDBdriver == 'mysql') {
7939
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7939
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7940 7940
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
7941 7941
 								GROUP BY spotter_output.airline_icao, date_name 
7942 7942
 								ORDER BY spotter_output.date ASC";
7943 7943
 			$query_data = array(':offset' => $offset);
7944 7944
 		} else {
7945
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7945
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7946 7946
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
7947 7947
 								GROUP BY spotter_output.airline_icao, date_name 
7948 7948
 								ORDER BY date_name ASC";
@@ -7955,7 +7955,7 @@  discard block
 block discarded – undo
7955 7955
 		$date_array = array();
7956 7956
 		$temp_array = array();
7957 7957
         
7958
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7958
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7959 7959
 		{
7960 7960
 			$temp_array['date_name'] = $row['date_name'];
7961 7961
 			$temp_array['date_count'] = $row['date_count'];
@@ -8002,7 +8002,7 @@  discard block
 block discarded – undo
8002 8002
 		$date_array = array();
8003 8003
 		$temp_array = array();
8004 8004
         
8005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8006 8006
 		{
8007 8007
 			$temp_array['month_name'] = $row['month_name'];
8008 8008
 			$temp_array['year_name'] = $row['year_name'];
@@ -8023,7 +8023,7 @@  discard block
 block discarded – undo
8023 8023
 	public function countAllMonthsByAirlines($filters = array())
8024 8024
 	{
8025 8025
 		global $globalTimezone, $globalDBdriver;
8026
-		$filter_query = $this->getFilter($filters,true,true);
8026
+		$filter_query = $this->getFilter($filters, true, true);
8027 8027
 		if ($globalTimezone != '') {
8028 8028
 			date_default_timezone_set($globalTimezone);
8029 8029
 			$datetime = new DateTime();
@@ -8031,12 +8031,12 @@  discard block
 block discarded – undo
8031 8031
 		} else $offset = '+00:00';
8032 8032
 
8033 8033
 		if ($globalDBdriver == 'mysql') {
8034
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8034
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8035 8035
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
8036 8036
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
8037 8037
 								ORDER BY date_count DESC";
8038 8038
 		} else {
8039
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8039
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8040 8040
 								FROM spotter_output 
8041 8041
 								WHERE spotter_output.airline_icao <> '' 
8042 8042
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -8050,7 +8050,7 @@  discard block
 block discarded – undo
8050 8050
 		$date_array = array();
8051 8051
 		$temp_array = array();
8052 8052
         
8053
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8053
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8054 8054
 		{
8055 8055
 			$temp_array['month_name'] = $row['month_name'];
8056 8056
 			$temp_array['year_name'] = $row['year_name'];
@@ -8077,14 +8077,14 @@  discard block
 block discarded – undo
8077 8077
 			$datetime = new DateTime();
8078 8078
 			$offset = $datetime->format('P');
8079 8079
 		} else $offset = '+00:00';
8080
-		$filter_query = $this->getFilter($filters,true,true);
8080
+		$filter_query = $this->getFilter($filters, true, true);
8081 8081
 		if ($globalDBdriver == 'mysql') {
8082
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8082
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8083 8083
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
8084 8084
 								GROUP BY year_name, month_name 
8085 8085
 								ORDER BY date_count DESC";
8086 8086
 		} else {
8087
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8087
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8088 8088
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
8089 8089
 								GROUP BY year_name, month_name 
8090 8090
 								ORDER BY date_count DESC";
@@ -8096,7 +8096,7 @@  discard block
 block discarded – undo
8096 8096
 		$date_array = array();
8097 8097
 		$temp_array = array();
8098 8098
         
8099
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8099
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8100 8100
 		{
8101 8101
 			$temp_array['month_name'] = $row['month_name'];
8102 8102
 			$temp_array['year_name'] = $row['year_name'];
@@ -8122,15 +8122,15 @@  discard block
 block discarded – undo
8122 8122
 			$datetime = new DateTime();
8123 8123
 			$offset = $datetime->format('P');
8124 8124
 		} else $offset = '+00:00';
8125
-		$filter_query = $this->getFilter($filters,true,true);
8125
+		$filter_query = $this->getFilter($filters, true, true);
8126 8126
 
8127 8127
 		if ($globalDBdriver == 'mysql') {
8128
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8128
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8129 8129
 								FROM spotter_output".$filter_query." owner_name <> ''
8130 8130
 								GROUP BY year_name, month_name
8131 8131
 								ORDER BY date_count DESC";
8132 8132
 		} else {
8133
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8133
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8134 8134
 								FROM spotter_output".$filter_query." owner_name <> ''
8135 8135
 								GROUP BY year_name, month_name
8136 8136
 								ORDER BY date_count DESC";
@@ -8142,7 +8142,7 @@  discard block
 block discarded – undo
8142 8142
 		$date_array = array();
8143 8143
 		$temp_array = array();
8144 8144
         
8145
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8145
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8146 8146
 		{
8147 8147
 			$temp_array['month_name'] = $row['month_name'];
8148 8148
 			$temp_array['year_name'] = $row['year_name'];
@@ -8163,7 +8163,7 @@  discard block
 block discarded – undo
8163 8163
 	public function countAllMonthsOwnersByAirlines($filters = array())
8164 8164
 	{
8165 8165
 		global $globalTimezone, $globalDBdriver;
8166
-		$filter_query = $this->getFilter($filters,true,true);
8166
+		$filter_query = $this->getFilter($filters, true, true);
8167 8167
 		if ($globalTimezone != '') {
8168 8168
 			date_default_timezone_set($globalTimezone);
8169 8169
 			$datetime = new DateTime();
@@ -8171,12 +8171,12 @@  discard block
 block discarded – undo
8171 8171
 		} else $offset = '+00:00';
8172 8172
 
8173 8173
 		if ($globalDBdriver == 'mysql') {
8174
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8174
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8175 8175
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
8176 8176
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8177 8177
 								ORDER BY date_count DESC";
8178 8178
 		} else {
8179
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8179
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8180 8180
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
8181 8181
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8182 8182
 								ORDER BY date_count DESC";
@@ -8188,7 +8188,7 @@  discard block
 block discarded – undo
8188 8188
 		$date_array = array();
8189 8189
 		$temp_array = array();
8190 8190
         
8191
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8191
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8192 8192
 		{
8193 8193
 			$temp_array['month_name'] = $row['month_name'];
8194 8194
 			$temp_array['year_name'] = $row['year_name'];
@@ -8215,15 +8215,15 @@  discard block
 block discarded – undo
8215 8215
 			$datetime = new DateTime();
8216 8216
 			$offset = $datetime->format('P');
8217 8217
 		} else $offset = '+00:00';
8218
-		$filter_query = $this->getFilter($filters,true,true);
8218
+		$filter_query = $this->getFilter($filters, true, true);
8219 8219
 
8220 8220
 		if ($globalDBdriver == 'mysql') {
8221
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8221
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8222 8222
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
8223 8223
 								GROUP BY year_name, month_name
8224 8224
 								ORDER BY date_count DESC";
8225 8225
 		} else {
8226
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8226
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8227 8227
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
8228 8228
 								GROUP BY year_name, month_name
8229 8229
 								ORDER BY date_count DESC";
@@ -8235,7 +8235,7 @@  discard block
 block discarded – undo
8235 8235
 		$date_array = array();
8236 8236
 		$temp_array = array();
8237 8237
         
8238
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8238
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8239 8239
 		{
8240 8240
 			$temp_array['month_name'] = $row['month_name'];
8241 8241
 			$temp_array['year_name'] = $row['year_name'];
@@ -8256,7 +8256,7 @@  discard block
 block discarded – undo
8256 8256
 	public function countAllMonthsPilotsByAirlines($filters = array())
8257 8257
 	{
8258 8258
 		global $globalTimezone, $globalDBdriver;
8259
-		$filter_query = $this->getFilter($filters,true,true);
8259
+		$filter_query = $this->getFilter($filters, true, true);
8260 8260
 		if ($globalTimezone != '') {
8261 8261
 			date_default_timezone_set($globalTimezone);
8262 8262
 			$datetime = new DateTime();
@@ -8264,12 +8264,12 @@  discard block
 block discarded – undo
8264 8264
 		} else $offset = '+00:00';
8265 8265
 
8266 8266
 		if ($globalDBdriver == 'mysql') {
8267
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8267
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8268 8268
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
8269 8269
 								GROUP BY spotter_output.airline_icao,year_name, month_name
8270 8270
 								ORDER BY date_count DESC";
8271 8271
 		} else {
8272
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8272
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8273 8273
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
8274 8274
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8275 8275
 								ORDER BY date_count DESC";
@@ -8281,7 +8281,7 @@  discard block
 block discarded – undo
8281 8281
 		$date_array = array();
8282 8282
 		$temp_array = array();
8283 8283
         
8284
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8284
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8285 8285
 		{
8286 8286
 			$temp_array['month_name'] = $row['month_name'];
8287 8287
 			$temp_array['year_name'] = $row['year_name'];
@@ -8303,7 +8303,7 @@  discard block
 block discarded – undo
8303 8303
 	public function countAllMonthsAirlines($filters = array())
8304 8304
 	{
8305 8305
 		global $globalTimezone, $globalDBdriver;
8306
-		$filter_query = $this->getFilter($filters,true,true);
8306
+		$filter_query = $this->getFilter($filters, true, true);
8307 8307
 		if ($globalTimezone != '') {
8308 8308
 			date_default_timezone_set($globalTimezone);
8309 8309
 			$datetime = new DateTime();
@@ -8311,12 +8311,12 @@  discard block
 block discarded – undo
8311 8311
 		} else $offset = '+00:00';
8312 8312
 
8313 8313
 		if ($globalDBdriver == 'mysql') {
8314
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
8314
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
8315 8315
 								FROM spotter_output".$filter_query." airline_icao <> '' 
8316 8316
 								GROUP BY year_name, month_name
8317 8317
 								ORDER BY date_count DESC";
8318 8318
 		} else {
8319
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
8319
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
8320 8320
 								FROM spotter_output".$filter_query." airline_icao <> '' 
8321 8321
 								GROUP BY year_name, month_name
8322 8322
 								ORDER BY date_count DESC";
@@ -8328,7 +8328,7 @@  discard block
 block discarded – undo
8328 8328
 		$date_array = array();
8329 8329
 		$temp_array = array();
8330 8330
         
8331
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8331
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8332 8332
 		{
8333 8333
 			$temp_array['month_name'] = $row['month_name'];
8334 8334
 			$temp_array['year_name'] = $row['year_name'];
@@ -8354,15 +8354,15 @@  discard block
 block discarded – undo
8354 8354
 			$datetime = new DateTime();
8355 8355
 			$offset = $datetime->format('P');
8356 8356
 		} else $offset = '+00:00';
8357
-		$filter_query = $this->getFilter($filters,true,true);
8357
+		$filter_query = $this->getFilter($filters, true, true);
8358 8358
 
8359 8359
 		if ($globalDBdriver == 'mysql') {
8360
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8360
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8361 8361
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
8362 8362
 								GROUP BY year_name, month_name
8363 8363
 								ORDER BY date_count DESC";
8364 8364
 		} else {
8365
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8365
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8366 8366
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
8367 8367
 								GROUP BY year_name, month_name
8368 8368
 								ORDER BY date_count DESC";
@@ -8374,7 +8374,7 @@  discard block
 block discarded – undo
8374 8374
 		$date_array = array();
8375 8375
 		$temp_array = array();
8376 8376
         
8377
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8377
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8378 8378
 		{
8379 8379
 			$temp_array['month_name'] = $row['month_name'];
8380 8380
 			$temp_array['year_name'] = $row['year_name'];
@@ -8396,7 +8396,7 @@  discard block
 block discarded – undo
8396 8396
 	public function countAllMonthsAircraftsByAirlines($filters = array())
8397 8397
 	{
8398 8398
 		global $globalTimezone, $globalDBdriver;
8399
-		$filter_query = $this->getFilter($filters,true,true);
8399
+		$filter_query = $this->getFilter($filters, true, true);
8400 8400
 		if ($globalTimezone != '') {
8401 8401
 			date_default_timezone_set($globalTimezone);
8402 8402
 			$datetime = new DateTime();
@@ -8404,12 +8404,12 @@  discard block
 block discarded – undo
8404 8404
 		} else $offset = '+00:00';
8405 8405
 
8406 8406
 		if ($globalDBdriver == 'mysql') {
8407
-			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8407
+			$query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8408 8408
 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
8409 8409
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8410 8410
 								ORDER BY date_count DESC";
8411 8411
 		} else {
8412
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8412
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8413 8413
 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
8414 8414
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8415 8415
 								ORDER BY date_count DESC";
@@ -8421,7 +8421,7 @@  discard block
 block discarded – undo
8421 8421
 		$date_array = array();
8422 8422
 		$temp_array = array();
8423 8423
         
8424
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8424
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8425 8425
 		{
8426 8426
 			$temp_array['month_name'] = $row['month_name'];
8427 8427
 			$temp_array['year_name'] = $row['year_name'];
@@ -8448,15 +8448,15 @@  discard block
 block discarded – undo
8448 8448
 			$datetime = new DateTime();
8449 8449
 			$offset = $datetime->format('P');
8450 8450
 		} else $offset = '+00:00';
8451
-		$filter_query = $this->getFilter($filters,true,true);
8451
+		$filter_query = $this->getFilter($filters, true, true);
8452 8452
 
8453 8453
 		if ($globalDBdriver == 'mysql') {
8454
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8454
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8455 8455
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
8456 8456
 								GROUP BY year_name, month_name
8457 8457
 								ORDER BY date_count DESC";
8458 8458
 		} else {
8459
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8459
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8460 8460
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
8461 8461
 								GROUP BY year_name, month_name
8462 8462
 								ORDER BY date_count DESC";
@@ -8468,7 +8468,7 @@  discard block
 block discarded – undo
8468 8468
 		$date_array = array();
8469 8469
 		$temp_array = array();
8470 8470
         
8471
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8471
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8472 8472
 		{
8473 8473
 			$temp_array['month_name'] = $row['month_name'];
8474 8474
 			$temp_array['year_name'] = $row['year_name'];
@@ -8490,7 +8490,7 @@  discard block
 block discarded – undo
8490 8490
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
8491 8491
 	{
8492 8492
 		global $globalTimezone, $globalDBdriver;
8493
-		$filter_query = $this->getFilter($filters,true,true);
8493
+		$filter_query = $this->getFilter($filters, true, true);
8494 8494
 		if ($globalTimezone != '') {
8495 8495
 			date_default_timezone_set($globalTimezone);
8496 8496
 			$datetime = new DateTime();
@@ -8498,12 +8498,12 @@  discard block
 block discarded – undo
8498 8498
 		} else $offset = '+00:00';
8499 8499
 
8500 8500
 		if ($globalDBdriver == 'mysql') {
8501
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8501
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8502 8502
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
8503 8503
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8504 8504
 								ORDER BY date_count DESC";
8505 8505
 		} else {
8506
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8506
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8507 8507
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
8508 8508
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8509 8509
 								ORDER BY date_count DESC";
@@ -8515,7 +8515,7 @@  discard block
 block discarded – undo
8515 8515
 		$date_array = array();
8516 8516
 		$temp_array = array();
8517 8517
         
8518
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8518
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8519 8519
 		{
8520 8520
 			$temp_array['month_name'] = $row['month_name'];
8521 8521
 			$temp_array['year_name'] = $row['year_name'];
@@ -8543,7 +8543,7 @@  discard block
 block discarded – undo
8543 8543
 			$datetime = new DateTime();
8544 8544
 			$offset = $datetime->format('P');
8545 8545
 		} else $offset = '+00:00';
8546
-		$filter_query = $this->getFilter($filters,true,true);
8546
+		$filter_query = $this->getFilter($filters, true, true);
8547 8547
 		if ($globalDBdriver == 'mysql') {
8548 8548
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
8549 8549
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -8564,7 +8564,7 @@  discard block
 block discarded – undo
8564 8564
 		$date_array = array();
8565 8565
 		$temp_array = array();
8566 8566
         
8567
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8567
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8568 8568
 		{
8569 8569
 			$temp_array['year_name'] = $row['year_name'];
8570 8570
 			$temp_array['month_name'] = $row['month_name'];
@@ -8584,7 +8584,7 @@  discard block
 block discarded – undo
8584 8584
 	* @return Array the hour list
8585 8585
 	*
8586 8586
 	*/
8587
-	public function countAllHours($orderby,$filters = array())
8587
+	public function countAllHours($orderby, $filters = array())
8588 8588
 	{
8589 8589
 		global $globalTimezone, $globalDBdriver;
8590 8590
 		if ($globalTimezone != '') {
@@ -8632,7 +8632,7 @@  discard block
 block discarded – undo
8632 8632
 		$hour_array = array();
8633 8633
 		$temp_array = array();
8634 8634
         
8635
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8635
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8636 8636
 		{
8637 8637
 			$temp_array['hour_name'] = $row['hour_name'];
8638 8638
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8652,7 +8652,7 @@  discard block
 block discarded – undo
8652 8652
 	public function countAllHoursByAirlines($orderby, $filters = array())
8653 8653
 	{
8654 8654
 		global $globalTimezone, $globalDBdriver;
8655
-		$filter_query = $this->getFilter($filters,true,true);
8655
+		$filter_query = $this->getFilter($filters, true, true);
8656 8656
 		if ($globalTimezone != '') {
8657 8657
 			date_default_timezone_set($globalTimezone);
8658 8658
 			$datetime = new DateTime();
@@ -8670,7 +8670,7 @@  discard block
 block discarded – undo
8670 8670
 		}
8671 8671
 		
8672 8672
 		if ($globalDBdriver == 'mysql') {
8673
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8673
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8674 8674
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
8675 8675
 								GROUP BY spotter_output.airline_icao, hour_name 
8676 8676
 								".$orderby_sql;
@@ -8683,7 +8683,7 @@  discard block
 block discarded – undo
8683 8683
   */    
8684 8684
 		$query_data = array(':offset' => $offset);
8685 8685
 		} else {
8686
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8686
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8687 8687
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
8688 8688
 								GROUP BY spotter_output.airline_icao, hour_name 
8689 8689
 								".$orderby_sql;
@@ -8696,7 +8696,7 @@  discard block
 block discarded – undo
8696 8696
 		$hour_array = array();
8697 8697
 		$temp_array = array();
8698 8698
         
8699
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8699
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8700 8700
 		{
8701 8701
 			$temp_array['hour_name'] = $row['hour_name'];
8702 8702
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8719,34 +8719,34 @@  discard block
 block discarded – undo
8719 8719
 	public function countAllHoursByAirline($airline_icao, $filters = array())
8720 8720
 	{
8721 8721
 		global $globalTimezone, $globalDBdriver;
8722
-		$filter_query = $this->getFilter($filters,true,true);
8722
+		$filter_query = $this->getFilter($filters, true, true);
8723 8723
 		if ($globalTimezone != '') {
8724 8724
 			date_default_timezone_set($globalTimezone);
8725 8725
 			$datetime = new DateTime();
8726 8726
 			$offset = $datetime->format('P');
8727 8727
 		} else $offset = '+00:00';
8728 8728
 
8729
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8729
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8730 8730
 
8731 8731
 		if ($globalDBdriver == 'mysql') {
8732
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8732
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8733 8733
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
8734 8734
 								GROUP BY hour_name 
8735 8735
 								ORDER BY hour_name ASC";
8736 8736
 		} else {
8737
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8737
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8738 8738
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
8739 8739
 								GROUP BY hour_name 
8740 8740
 								ORDER BY hour_name ASC";
8741 8741
 		}
8742 8742
 		
8743 8743
 		$sth = $this->db->prepare($query);
8744
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
8744
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
8745 8745
       
8746 8746
 		$hour_array = array();
8747 8747
 		$temp_array = array();
8748 8748
         
8749
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8749
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8750 8750
 		{
8751 8751
 			$temp_array['hour_name'] = $row['hour_name'];
8752 8752
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8769,8 +8769,8 @@  discard block
 block discarded – undo
8769 8769
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
8770 8770
 	{
8771 8771
 		global $globalTimezone, $globalDBdriver;
8772
-		$filter_query = $this->getFilter($filters,true,true);
8773
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8772
+		$filter_query = $this->getFilter($filters, true, true);
8773
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8774 8774
 		if ($globalTimezone != '') {
8775 8775
 			date_default_timezone_set($globalTimezone);
8776 8776
 			$datetime = new DateTime();
@@ -8778,24 +8778,24 @@  discard block
 block discarded – undo
8778 8778
 		} else $offset = '+00:00';
8779 8779
 
8780 8780
 		if ($globalDBdriver == 'mysql') {
8781
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8781
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8782 8782
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
8783 8783
 								GROUP BY hour_name 
8784 8784
 								ORDER BY hour_name ASC";
8785 8785
 		} else {
8786
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8786
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8787 8787
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
8788 8788
 								GROUP BY hour_name 
8789 8789
 								ORDER BY hour_name ASC";
8790 8790
 		}
8791 8791
 		
8792 8792
 		$sth = $this->db->prepare($query);
8793
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
8793
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
8794 8794
       
8795 8795
 		$hour_array = array();
8796 8796
 		$temp_array = array();
8797 8797
         
8798
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8798
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8799 8799
 		{
8800 8800
 			$temp_array['hour_name'] = $row['hour_name'];
8801 8801
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8816,8 +8816,8 @@  discard block
 block discarded – undo
8816 8816
 	public function countAllHoursByRegistration($registration, $filters = array())
8817 8817
 	{
8818 8818
 		global $globalTimezone, $globalDBdriver;
8819
-		$filter_query = $this->getFilter($filters,true,true);
8820
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8819
+		$filter_query = $this->getFilter($filters, true, true);
8820
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8821 8821
 		if ($globalTimezone != '') {
8822 8822
 			date_default_timezone_set($globalTimezone);
8823 8823
 			$datetime = new DateTime();
@@ -8825,24 +8825,24 @@  discard block
 block discarded – undo
8825 8825
 		} else $offset = '+00:00';
8826 8826
 
8827 8827
 		if ($globalDBdriver == 'mysql') {
8828
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8828
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8829 8829
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
8830 8830
 								GROUP BY hour_name 
8831 8831
 								ORDER BY hour_name ASC";
8832 8832
 		} else {
8833
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8833
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8834 8834
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
8835 8835
 								GROUP BY hour_name 
8836 8836
 								ORDER BY hour_name ASC";
8837 8837
 		}
8838 8838
 		
8839 8839
 		$sth = $this->db->prepare($query);
8840
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
8840
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
8841 8841
       
8842 8842
 		$hour_array = array();
8843 8843
 		$temp_array = array();
8844 8844
         
8845
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8845
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8846 8846
 		{
8847 8847
 			$temp_array['hour_name'] = $row['hour_name'];
8848 8848
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8863,8 +8863,8 @@  discard block
 block discarded – undo
8863 8863
 	public function countAllHoursByAirport($airport_icao, $filters = array())
8864 8864
 	{
8865 8865
 		global $globalTimezone, $globalDBdriver;
8866
-		$filter_query = $this->getFilter($filters,true,true);
8867
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8866
+		$filter_query = $this->getFilter($filters, true, true);
8867
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8868 8868
 		if ($globalTimezone != '') {
8869 8869
 			date_default_timezone_set($globalTimezone);
8870 8870
 			$datetime = new DateTime();
@@ -8872,24 +8872,24 @@  discard block
 block discarded – undo
8872 8872
 		} else $offset = '+00:00';
8873 8873
 
8874 8874
 		if ($globalDBdriver == 'mysql') {
8875
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8875
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8876 8876
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8877 8877
 								GROUP BY hour_name 
8878 8878
 								ORDER BY hour_name ASC";
8879 8879
 		} else {
8880
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8880
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8881 8881
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8882 8882
 								GROUP BY hour_name 
8883 8883
 								ORDER BY hour_name ASC";
8884 8884
 		}
8885 8885
 		
8886 8886
 		$sth = $this->db->prepare($query);
8887
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
8887
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
8888 8888
       
8889 8889
 		$hour_array = array();
8890 8890
 		$temp_array = array();
8891 8891
         
8892
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8892
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8893 8893
 		{
8894 8894
 			$temp_array['hour_name'] = $row['hour_name'];
8895 8895
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8908,11 +8908,11 @@  discard block
 block discarded – undo
8908 8908
 	* @return Array the hour list
8909 8909
 	*
8910 8910
 	*/
8911
-	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
8911
+	public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array())
8912 8912
 	{
8913 8913
 		global $globalTimezone, $globalDBdriver;
8914
-		$filter_query = $this->getFilter($filters,true,true);
8915
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8914
+		$filter_query = $this->getFilter($filters, true, true);
8915
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8916 8916
 		if ($globalTimezone != '') {
8917 8917
 			date_default_timezone_set($globalTimezone);
8918 8918
 			$datetime = new DateTime();
@@ -8920,24 +8920,24 @@  discard block
 block discarded – undo
8920 8920
 		} else $offset = '+00:00';
8921 8921
 
8922 8922
 		if ($globalDBdriver == 'mysql') {
8923
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8923
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8924 8924
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
8925 8925
 								GROUP BY hour_name 
8926 8926
 								ORDER BY hour_name ASC";
8927 8927
 		} else {
8928
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8928
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8929 8929
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
8930 8930
 								GROUP BY hour_name 
8931 8931
 								ORDER BY hour_name ASC";
8932 8932
 		}
8933 8933
 		
8934 8934
 		$sth = $this->db->prepare($query);
8935
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
8935
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
8936 8936
       
8937 8937
 		$hour_array = array();
8938 8938
 		$temp_array = array();
8939 8939
         
8940
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8940
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8941 8941
 		{
8942 8942
 			$temp_array['hour_name'] = $row['hour_name'];
8943 8943
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8959,8 +8959,8 @@  discard block
 block discarded – undo
8959 8959
 	public function countAllHoursByDate($date, $filters = array())
8960 8960
 	{
8961 8961
 		global $globalTimezone, $globalDBdriver;
8962
-		$filter_query = $this->getFilter($filters,true,true);
8963
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8962
+		$filter_query = $this->getFilter($filters, true, true);
8963
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8964 8964
 		if ($globalTimezone != '') {
8965 8965
 			date_default_timezone_set($globalTimezone);
8966 8966
 			$datetime = new DateTime($date);
@@ -8968,12 +8968,12 @@  discard block
 block discarded – undo
8968 8968
 		} else $offset = '+00:00';
8969 8969
 
8970 8970
 		if ($globalDBdriver == 'mysql') {
8971
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8971
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8972 8972
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
8973 8973
 								GROUP BY hour_name 
8974 8974
 								ORDER BY hour_name ASC";
8975 8975
 		} else {
8976
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8976
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8977 8977
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
8978 8978
 								GROUP BY hour_name 
8979 8979
 								ORDER BY hour_name ASC";
@@ -8985,7 +8985,7 @@  discard block
 block discarded – undo
8985 8985
 		$hour_array = array();
8986 8986
 		$temp_array = array();
8987 8987
         
8988
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8988
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8989 8989
 		{
8990 8990
 			$temp_array['hour_name'] = $row['hour_name'];
8991 8991
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9007,8 +9007,8 @@  discard block
 block discarded – undo
9007 9007
 	public function countAllHoursByIdent($ident, $filters = array())
9008 9008
 	{
9009 9009
 		global $globalTimezone, $globalDBdriver;
9010
-		$filter_query = $this->getFilter($filters,true,true);
9011
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
9010
+		$filter_query = $this->getFilter($filters, true, true);
9011
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
9012 9012
 		if ($globalTimezone != '') {
9013 9013
 			date_default_timezone_set($globalTimezone);
9014 9014
 			$datetime = new DateTime();
@@ -9016,12 +9016,12 @@  discard block
 block discarded – undo
9016 9016
 		} else $offset = '+00:00';
9017 9017
 
9018 9018
 		if ($globalDBdriver == 'mysql') {
9019
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9019
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9020 9020
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
9021 9021
 								GROUP BY hour_name 
9022 9022
 								ORDER BY hour_name ASC";
9023 9023
 		} else {
9024
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9024
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9025 9025
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
9026 9026
 								GROUP BY hour_name 
9027 9027
 								ORDER BY hour_name ASC";
@@ -9029,12 +9029,12 @@  discard block
 block discarded – undo
9029 9029
       
9030 9030
 		
9031 9031
 		$sth = $this->db->prepare($query);
9032
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
9032
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
9033 9033
       
9034 9034
 		$hour_array = array();
9035 9035
 		$temp_array = array();
9036 9036
         
9037
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9037
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9038 9038
 		{
9039 9039
 			$temp_array['hour_name'] = $row['hour_name'];
9040 9040
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9053,12 +9053,12 @@  discard block
 block discarded – undo
9053 9053
 	* @return Array the hour list
9054 9054
 	*
9055 9055
 	*/
9056
-	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
9056
+	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
9057 9057
 	{
9058 9058
 		global $globalTimezone, $globalDBdriver;
9059
-		$filter_query = $this->getFilter($filters,true,true);
9060
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
9061
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
9059
+		$filter_query = $this->getFilter($filters, true, true);
9060
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
9061
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
9062 9062
 		if ($globalTimezone != '') {
9063 9063
 			date_default_timezone_set($globalTimezone);
9064 9064
 			$datetime = new DateTime();
@@ -9066,24 +9066,24 @@  discard block
 block discarded – undo
9066 9066
 		} else $offset = '+00:00';
9067 9067
 
9068 9068
 		if ($globalDBdriver == 'mysql') {
9069
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9069
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9070 9070
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
9071 9071
 								GROUP BY hour_name 
9072 9072
 								ORDER BY hour_name ASC";
9073 9073
 		} else {
9074
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9074
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9075 9075
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
9076 9076
 								GROUP BY hour_name 
9077 9077
 								ORDER BY hour_name ASC";
9078 9078
 		}
9079 9079
 		
9080 9080
 		$sth = $this->db->prepare($query);
9081
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
9081
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
9082 9082
       
9083 9083
 		$hour_array = array();
9084 9084
 		$temp_array = array();
9085 9085
         
9086
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9086
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9087 9087
 		{
9088 9088
 			$temp_array['hour_name'] = $row['hour_name'];
9089 9089
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9104,8 +9104,8 @@  discard block
 block discarded – undo
9104 9104
 	public function countAllHoursByCountry($country, $filters = array())
9105 9105
 	{
9106 9106
 		global $globalTimezone, $globalDBdriver;
9107
-		$filter_query = $this->getFilter($filters,true,true);
9108
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
9107
+		$filter_query = $this->getFilter($filters, true, true);
9108
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
9109 9109
 		if ($globalTimezone != '') {
9110 9110
 			date_default_timezone_set($globalTimezone);
9111 9111
 			$datetime = new DateTime();
@@ -9113,24 +9113,24 @@  discard block
 block discarded – undo
9113 9113
 		} else $offset = '+00:00';
9114 9114
 
9115 9115
 		if ($globalDBdriver == 'mysql') {
9116
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9116
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9117 9117
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
9118 9118
 								GROUP BY hour_name 
9119 9119
 								ORDER BY hour_name ASC";
9120 9120
 		} else {
9121
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9121
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9122 9122
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
9123 9123
 								GROUP BY hour_name 
9124 9124
 								ORDER BY hour_name ASC";
9125 9125
 		}
9126 9126
 		
9127 9127
 		$sth = $this->db->prepare($query);
9128
-		$sth->execute(array(':country' => $country,':offset' => $offset));
9128
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
9129 9129
       
9130 9130
 		$hour_array = array();
9131 9131
 		$temp_array = array();
9132 9132
         
9133
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9133
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9134 9134
 		{
9135 9135
 			$temp_array['hour_name'] = $row['hour_name'];
9136 9136
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9152,8 +9152,8 @@  discard block
 block discarded – undo
9152 9152
 	*/
9153 9153
 	public function countOverallAircrafts($filters = array())
9154 9154
 	{
9155
-		$filter_query = $this->getFilter($filters,true,true);
9156
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
9155
+		$filter_query = $this->getFilter($filters, true, true);
9156
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
9157 9157
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9158 9158
 		$sth = $this->db->prepare($query);
9159 9159
 		$sth->execute();
@@ -9168,8 +9168,8 @@  discard block
 block discarded – undo
9168 9168
 	*/
9169 9169
 	public function countOverallArrival($filters = array())
9170 9170
 	{
9171
-		$filter_query = $this->getFilter($filters,true,true);
9172
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
9171
+		$filter_query = $this->getFilter($filters, true, true);
9172
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
9173 9173
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
9174 9174
 		
9175 9175
 		$sth = $this->db->prepare($query);
@@ -9185,8 +9185,8 @@  discard block
 block discarded – undo
9185 9185
 	*/
9186 9186
 	public function countOverallPilots($filters = array())
9187 9187
 	{
9188
-		$filter_query = $this->getFilter($filters,true,true);
9189
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
9188
+		$filter_query = $this->getFilter($filters, true, true);
9189
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
9190 9190
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
9191 9191
 		$sth = $this->db->prepare($query);
9192 9192
 		$sth->execute();
@@ -9201,8 +9201,8 @@  discard block
 block discarded – undo
9201 9201
 	*/
9202 9202
 	public function countOverallOwners($filters = array())
9203 9203
 	{
9204
-		$filter_query = $this->getFilter($filters,true,true);
9205
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
9204
+		$filter_query = $this->getFilter($filters, true, true);
9205
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
9206 9206
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
9207 9207
 		$sth = $this->db->prepare($query);
9208 9208
 		$sth->execute();
@@ -9235,8 +9235,8 @@  discard block
 block discarded – undo
9235 9235
 	*/
9236 9236
 	public function countOverallMilitaryFlights($filters = array())
9237 9237
 	{
9238
-		$filter_query = $this->getFilter($filters,true,true);
9239
-		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
9238
+		$filter_query = $this->getFilter($filters, true, true);
9239
+		$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
9240 9240
                     FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'";
9241 9241
       
9242 9242
 		$sth = $this->db->prepare($query);
@@ -9273,7 +9273,7 @@  discard block
 block discarded – undo
9273 9273
 	public function countAllHoursFromToday($filters = array())
9274 9274
 	{
9275 9275
 		global $globalTimezone, $globalDBdriver;
9276
-		$filter_query = $this->getFilter($filters,true,true);
9276
+		$filter_query = $this->getFilter($filters, true, true);
9277 9277
 		if ($globalTimezone != '') {
9278 9278
 			date_default_timezone_set($globalTimezone);
9279 9279
 			$datetime = new DateTime();
@@ -9281,12 +9281,12 @@  discard block
 block discarded – undo
9281 9281
 		} else $offset = '+00:00';
9282 9282
 
9283 9283
 		if ($globalDBdriver == 'mysql') {
9284
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9284
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9285 9285
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
9286 9286
 								GROUP BY hour_name 
9287 9287
 								ORDER BY hour_name ASC";
9288 9288
 		} else {
9289
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9289
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9290 9290
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
9291 9291
 								GROUP BY hour_name 
9292 9292
 								ORDER BY hour_name ASC";
@@ -9298,7 +9298,7 @@  discard block
 block discarded – undo
9298 9298
 		$hour_array = array();
9299 9299
 		$temp_array = array();
9300 9300
         
9301
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9301
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9302 9302
 		{
9303 9303
 			$temp_array['hour_name'] = $row['hour_name'];
9304 9304
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9317,14 +9317,14 @@  discard block
 block discarded – undo
9317 9317
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
9318 9318
 	{
9319 9319
 		global $global_query, $globalDBdriver, $globalTimezone;
9320
-		$filter_query = $this->getFilter($filters,true,true);
9320
+		$filter_query = $this->getFilter($filters, true, true);
9321 9321
 		date_default_timezone_set('UTC');
9322 9322
 		$limit_query = '';
9323 9323
 		if ($limit != "")
9324 9324
 		{
9325 9325
 			$limit_array = explode(",", $limit);
9326
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
9327
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
9326
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
9327
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
9328 9328
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
9329 9329
 			{
9330 9330
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -9377,7 +9377,7 @@  discard block
 block discarded – undo
9377 9377
 			    GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH')
9378 9378
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
9379 9379
 			//echo $query;
9380
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
9380
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
9381 9381
 			/*
9382 9382
 			$sth = $this->db->prepare($query);
9383 9383
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -9396,9 +9396,9 @@  discard block
 block discarded – undo
9396 9396
 	*/
9397 9397
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
9398 9398
 	{
9399
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
9399
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
9400 9400
 
9401
-		$query  = "SELECT spotter_output.spotter_id
9401
+		$query = "SELECT spotter_output.spotter_id
9402 9402
 								FROM spotter_output 
9403 9403
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
9404 9404
         
@@ -9406,7 +9406,7 @@  discard block
 block discarded – undo
9406 9406
 		$sth = $this->db->prepare($query);
9407 9407
 		$sth->execute();
9408 9408
 
9409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9410 9410
 		{
9411 9411
 			return $row['spotter_id'];
9412 9412
 		}
@@ -9431,23 +9431,23 @@  discard block
 block discarded – undo
9431 9431
 		}
9432 9432
 		
9433 9433
 		$current_date = date("Y-m-d H:i:s");
9434
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
9434
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
9435 9435
 		
9436 9436
 		$diff = abs(strtotime($current_date) - strtotime($date));
9437 9437
 
9438
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
9438
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
9439 9439
 		$years = $time_array['years'];
9440 9440
 		
9441
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
9441
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
9442 9442
 		$months = $time_array['months'];
9443 9443
 		
9444
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
9444
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
9445 9445
 		$days = $time_array['days'];
9446
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
9446
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
9447 9447
 		$hours = $time_array['hours'];
9448
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
9448
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
9449 9449
 		$minutes = $time_array['minutes'];
9450
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
9450
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
9451 9451
 		
9452 9452
 		return $time_array;	
9453 9453
 	}	
@@ -9473,63 +9473,63 @@  discard block
 block discarded – undo
9473 9473
 			$temp_array['direction_degree'] = $direction;
9474 9474
 			$temp_array['direction_shortname'] = "N";
9475 9475
 			$temp_array['direction_fullname'] = "North";
9476
-		} elseif ($direction >= 22.5 && $direction < 45){
9476
+		} elseif ($direction >= 22.5 && $direction < 45) {
9477 9477
 			$temp_array['direction_degree'] = $direction;
9478 9478
 			$temp_array['direction_shortname'] = "NNE";
9479 9479
 			$temp_array['direction_fullname'] = "North-Northeast";
9480
-		} elseif ($direction >= 45 && $direction < 67.5){
9480
+		} elseif ($direction >= 45 && $direction < 67.5) {
9481 9481
 			$temp_array['direction_degree'] = $direction;
9482 9482
 			$temp_array['direction_shortname'] = "NE";
9483 9483
 			$temp_array['direction_fullname'] = "Northeast";
9484
-		} elseif ($direction >= 67.5 && $direction < 90){
9484
+		} elseif ($direction >= 67.5 && $direction < 90) {
9485 9485
 			$temp_array['direction_degree'] = $direction;
9486 9486
 			$temp_array['direction_shortname'] = "ENE";
9487 9487
 			$temp_array['direction_fullname'] = "East-Northeast";
9488
-		} elseif ($direction >= 90 && $direction < 112.5){
9488
+		} elseif ($direction >= 90 && $direction < 112.5) {
9489 9489
 			$temp_array['direction_degree'] = $direction;
9490 9490
 			$temp_array['direction_shortname'] = "E";
9491 9491
 			$temp_array['direction_fullname'] = "East";
9492
-		} elseif ($direction >= 112.5 && $direction < 135){
9492
+		} elseif ($direction >= 112.5 && $direction < 135) {
9493 9493
 			$temp_array['direction_degree'] = $direction;
9494 9494
 			$temp_array['direction_shortname'] = "ESE";
9495 9495
 			$temp_array['direction_fullname'] = "East-Southeast";
9496
-		} elseif ($direction >= 135 && $direction < 157.5){
9496
+		} elseif ($direction >= 135 && $direction < 157.5) {
9497 9497
 			$temp_array['direction_degree'] = $direction;
9498 9498
 			$temp_array['direction_shortname'] = "SE";
9499 9499
 			$temp_array['direction_fullname'] = "Southeast";
9500
-		} elseif ($direction >= 157.5 && $direction < 180){
9500
+		} elseif ($direction >= 157.5 && $direction < 180) {
9501 9501
 			$temp_array['direction_degree'] = $direction;
9502 9502
 			$temp_array['direction_shortname'] = "SSE";
9503 9503
 			$temp_array['direction_fullname'] = "South-Southeast";
9504
-		} elseif ($direction >= 180 && $direction < 202.5){
9504
+		} elseif ($direction >= 180 && $direction < 202.5) {
9505 9505
 			$temp_array['direction_degree'] = $direction;
9506 9506
 			$temp_array['direction_shortname'] = "S";
9507 9507
 			$temp_array['direction_fullname'] = "South";
9508
-		} elseif ($direction >= 202.5 && $direction < 225){
9508
+		} elseif ($direction >= 202.5 && $direction < 225) {
9509 9509
 			$temp_array['direction_degree'] = $direction;
9510 9510
 			$temp_array['direction_shortname'] = "SSW";
9511 9511
 			$temp_array['direction_fullname'] = "South-Southwest";
9512
-		} elseif ($direction >= 225 && $direction < 247.5){
9512
+		} elseif ($direction >= 225 && $direction < 247.5) {
9513 9513
 			$temp_array['direction_degree'] = $direction;
9514 9514
 			$temp_array['direction_shortname'] = "SW";
9515 9515
 			$temp_array['direction_fullname'] = "Southwest";
9516
-		} elseif ($direction >= 247.5 && $direction < 270){
9516
+		} elseif ($direction >= 247.5 && $direction < 270) {
9517 9517
 			$temp_array['direction_degree'] = $direction;
9518 9518
 			$temp_array['direction_shortname'] = "WSW";
9519 9519
 			$temp_array['direction_fullname'] = "West-Southwest";
9520
-		} elseif ($direction >= 270 && $direction < 292.5){
9520
+		} elseif ($direction >= 270 && $direction < 292.5) {
9521 9521
 			$temp_array['direction_degree'] = $direction;
9522 9522
 			$temp_array['direction_shortname'] = "W";
9523 9523
 			$temp_array['direction_fullname'] = "West";
9524
-		} elseif ($direction >= 292.5 && $direction < 315){
9524
+		} elseif ($direction >= 292.5 && $direction < 315) {
9525 9525
 			$temp_array['direction_degree'] = $direction;
9526 9526
 			$temp_array['direction_shortname'] = "WNW";
9527 9527
 			$temp_array['direction_fullname'] = "West-Northwest";
9528
-		} elseif ($direction >= 315 && $direction < 337.5){
9528
+		} elseif ($direction >= 315 && $direction < 337.5) {
9529 9529
 			$temp_array['direction_degree'] = $direction;
9530 9530
 			$temp_array['direction_shortname'] = "NW";
9531 9531
 			$temp_array['direction_fullname'] = "Northwest";
9532
-		} elseif ($direction >= 337.5 && $direction < 360){
9532
+		} elseif ($direction >= 337.5 && $direction < 360) {
9533 9533
 			$temp_array['direction_degree'] = $direction;
9534 9534
 			$temp_array['direction_shortname'] = "NNW";
9535 9535
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -9582,9 +9582,9 @@  discard block
 block discarded – undo
9582 9582
 	*/
9583 9583
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
9584 9584
 	{
9585
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
9585
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
9586 9586
 	
9587
-		$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9587
+		$query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9588 9588
 		
9589 9589
 		$sth = $this->db->prepare($query);
9590 9590
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -9607,9 +9607,9 @@  discard block
 block discarded – undo
9607 9607
 	*/
9608 9608
 	public function getAircraftTypeBymodeS($aircraft_modes)
9609 9609
 	{
9610
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
9610
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
9611 9611
 	
9612
-		$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9612
+		$query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9613 9613
 		
9614 9614
 		$sth = $this->db->prepare($query);
9615 9615
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -9630,11 +9630,11 @@  discard block
 block discarded – undo
9630 9630
 	* @param Float $longitude longitute of the flight
9631 9631
 	* @return String the countrie
9632 9632
 	*/
9633
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
9633
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
9634 9634
 	{
9635 9635
 		global $globalDBdriver, $globalDebug;
9636
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9637
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9636
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
9637
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
9638 9638
 	
9639 9639
 		$Connection = new Connection($this->db);
9640 9640
 		if (!$Connection->tableExists('countries')) return '';
@@ -9674,19 +9674,19 @@  discard block
 block discarded – undo
9674 9674
 	*/
9675 9675
 	public function convertAircraftRegistration($registration)
9676 9676
 	{
9677
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
9677
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
9678 9678
 		$registration_prefix = '';
9679 9679
 		$registration_1 = substr($registration, 0, 1);
9680 9680
 		$registration_2 = substr($registration, 0, 2);
9681 9681
 
9682 9682
 		//first get the prefix based on two characters
9683
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
9683
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
9684 9684
       
9685 9685
 		
9686 9686
 		$sth = $this->db->prepare($query);
9687 9687
 		$sth->execute(array(':registration_2' => $registration_2));
9688 9688
         
9689
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9689
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9690 9690
 		{
9691 9691
 			$registration_prefix = $row['registration_prefix'];
9692 9692
 		}
@@ -9694,11 +9694,11 @@  discard block
 block discarded – undo
9694 9694
 		//if we didn't find a two chracter prefix lets just search the one with one character
9695 9695
 		if ($registration_prefix == '')
9696 9696
 		{
9697
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
9697
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
9698 9698
 			$sth = $this->db->prepare($query);
9699 9699
 			$sth->execute(array(':registration_1' => $registration_1));
9700 9700
 	        
9701
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9701
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9702 9702
 			{
9703 9703
 				$registration_prefix = $row['registration_prefix'];
9704 9704
 			}
@@ -9712,7 +9712,7 @@  discard block
 block discarded – undo
9712 9712
 			} else {
9713 9713
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
9714 9714
 			}
9715
-		} else if(strlen($registration_prefix) == 2){
9715
+		} else if (strlen($registration_prefix) == 2) {
9716 9716
 			if (0 === strpos($registration, 'N')) {
9717 9717
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
9718 9718
 			} else {
@@ -9731,17 +9731,17 @@  discard block
 block discarded – undo
9731 9731
 	*/
9732 9732
 	public function countryFromAircraftRegistration($registration)
9733 9733
 	{
9734
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
9734
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
9735 9735
 		
9736 9736
 		$registration_prefix = '';
9737
-		$registration_test = explode('-',$registration);
9737
+		$registration_test = explode('-', $registration);
9738 9738
 		$country = '';
9739 9739
 		if ($registration_test[0] != $registration) {
9740 9740
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9741 9741
 	      
9742 9742
 			$sth = $this->db->prepare($query);
9743 9743
 			$sth->execute(array(':registration_1' => $registration_test[0]));
9744
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9744
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9745 9745
 			{
9746 9746
 				//$registration_prefix = $row['registration_prefix'];
9747 9747
 				$country = $row['country'];
@@ -9752,13 +9752,13 @@  discard block
 block discarded – undo
9752 9752
 
9753 9753
 			$country = '';
9754 9754
 			//first get the prefix based on two characters
9755
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
9755
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
9756 9756
       
9757 9757
 			
9758 9758
 			$sth = $this->db->prepare($query);
9759 9759
 			$sth->execute(array(':registration_2' => $registration_2));
9760 9760
         
9761
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9761
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9762 9762
 			{
9763 9763
 				$registration_prefix = $row['registration_prefix'];
9764 9764
 				$country = $row['country'];
@@ -9767,12 +9767,12 @@  discard block
 block discarded – undo
9767 9767
 			//if we didn't find a two chracter prefix lets just search the one with one character
9768 9768
 			if ($registration_prefix == "")
9769 9769
 			{
9770
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9770
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9771 9771
 	      
9772 9772
 				$sth = $this->db->prepare($query);
9773 9773
 				$sth->execute(array(':registration_1' => $registration_1));
9774 9774
 	        
9775
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
9775
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9776 9776
 				{
9777 9777
 					//$registration_prefix = $row['registration_prefix'];
9778 9778
 					$country = $row['country'];
@@ -9789,9 +9789,9 @@  discard block
 block discarded – undo
9789 9789
 	* @param String $flightaware_id flightaware_id from spotter_output table
9790 9790
 	* @param String $highlight New highlight value
9791 9791
 	*/
9792
-	public function setHighlightFlight($flightaware_id,$highlight) {
9792
+	public function setHighlightFlight($flightaware_id, $highlight) {
9793 9793
 		
9794
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
9794
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
9795 9795
 		$sth = $this->db->prepare($query);
9796 9796
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
9797 9797
 	}
@@ -9820,7 +9820,7 @@  discard block
 block discarded – undo
9820 9820
 		
9821 9821
 		$bitly_data = json_decode($bitly_data);
9822 9822
 		$bitly_url = '';
9823
-		if ($bitly_data->status_txt = "OK"){
9823
+		if ($bitly_data->status_txt = "OK") {
9824 9824
 			$bitly_url = $bitly_data->data->url;
9825 9825
 		}
9826 9826
 
@@ -9830,7 +9830,7 @@  discard block
 block discarded – undo
9830 9830
 
9831 9831
 	public function getOrderBy()
9832 9832
 	{
9833
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
9833
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
9834 9834
 		
9835 9835
 		return $orderby;
9836 9836
 		
@@ -9964,14 +9964,14 @@  discard block
 block discarded – undo
9964 9964
 		}
9965 9965
 		$sth = $this->db->prepare($query);
9966 9966
 		$sth->execute();
9967
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9967
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9968 9968
 		{
9969 9969
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
9970 9970
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
9971 9971
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
9972
-				$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
9972
+				$update_query = "UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
9973 9973
 				$sthu = $this->db->prepare($update_query);
9974
-				$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country']));
9974
+				$sthu->execute(array(':fromicao' => $row['fromairport_icao'], ':toicao' => $row['toairport_icao'], ':spotter_id' => $row['spotter_id'], ':departure_airport_name' => $departure_airport_array[0]['name'], ':departure_airport_city' => $departure_airport_array[0]['city'], ':departure_airport_country' => $departure_airport_array[0]['country'], ':arrival_airport_name' => $arrival_airport_array[0]['name'], ':arrival_airport_city' => $arrival_airport_array[0]['city'], ':arrival_airport_country' => $arrival_airport_array[0]['country']));
9975 9975
 			}
9976 9976
 		}
9977 9977
 		
@@ -9984,7 +9984,7 @@  discard block
 block discarded – undo
9984 9984
 		}
9985 9985
 		$sth = $this->db->prepare($query);
9986 9986
 		$sth->execute();
9987
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9987
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9988 9988
 		{
9989 9989
 			if (is_numeric(substr($row['ident'], -1, 1)))
9990 9990
 			{
@@ -9993,11 +9993,11 @@  discard block
 block discarded – undo
9993 9993
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
9994 9994
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
9995 9995
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
9996
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
9996
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
9997 9997
 				if (isset($airline_array[0]['name'])) {
9998
-					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
9998
+					$update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
9999 9999
 					$sthu = $this->db->prepare($update_query);
10000
-					$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
10000
+					$sthu->execute(array(':airline_name' => $airline_array[0]['name'], ':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
10001 10001
 				}
10002 10002
 			}
10003 10003
 		}
@@ -10017,18 +10017,18 @@  discard block
 block discarded – undo
10017 10017
 		}
10018 10018
 		$sth = $this->db->prepare($query);
10019 10019
 		$sth->execute();
10020
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10020
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10021 10021
 		{
10022 10022
 			if ($row['aircraft_icao'] != '') {
10023 10023
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
10024
-				if ($row['registration'] != ""){
10024
+				if ($row['registration'] != "") {
10025 10025
 					$image_array = $Image->getSpotterImage($row['registration']);
10026 10026
 					if (!isset($image_array[0]['registration'])) {
10027 10027
 						$Image->addSpotterImage($row['registration']);
10028 10028
 					}
10029 10029
 				}
10030 10030
 				if (count($aircraft_name) > 0) {
10031
-					$update_query  = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
10031
+					$update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
10032 10032
 					$sthu = $this->db->prepare($update_query);
10033 10033
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
10034 10034
 				}
@@ -10043,10 +10043,10 @@  discard block
 block discarded – undo
10043 10043
 		$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output";
10044 10044
 		$sth = $this->db->prepare($query);
10045 10045
 		$sth->execute();
10046
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10046
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10047 10047
 		{
10048 10048
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
10049
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
10049
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
10050 10050
 				$airport_icao = '';
10051 10051
 				 if (isset($closestAirports[0])) {
10052 10052
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -10060,7 +10060,7 @@  discard block
 block discarded – undo
10060 10060
 								break;
10061 10061
 							}
10062 10062
 						}
10063
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10063
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
10064 10064
 						$airport_icao = $closestAirports[0]['icao'];
10065 10065
 						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10066 10066
 					} else {
@@ -10071,28 +10071,28 @@  discard block
 block discarded – undo
10071 10071
 				}
10072 10072
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10073 10073
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10074
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10074
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10075 10075
 					$sthu = $this->db->prepare($update_query);
10076
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
10076
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
10077 10077
 				}
10078 10078
 			}
10079 10079
 		}
10080 10080
 	}
10081 10081
 	
10082
-	public function closestAirports($origLat,$origLon,$dist = 10) {
10082
+	public function closestAirports($origLat, $origLon, $dist = 10) {
10083 10083
 		global $globalDBdriver;
10084
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
10084
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
10085 10085
 /*
10086 10086
 		$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
10087 10087
                       FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
10088 10088
                       having distance < $dist ORDER BY distance limit 100;";
10089 10089
 */
10090 10090
 		if ($globalDBdriver == 'mysql') {
10091
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
10091
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
10092 10092
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
10093 10093
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
10094 10094
                 } else {
10095
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
10095
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
10096 10096
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
10097 10097
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
10098 10098
     		}
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -16,64 +16,64 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32
-		foreach($filters as $flt) {
32
+		foreach ($filters as $flt) {
33 33
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 				if ($flt['airlines'][0] != '') {
35 35
 					if (isset($flt['source'])) {
36
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
36
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
37 37
 					} else {
38
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
38
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
39 39
 					}
40 40
 				}
41 41
 			}
42 42
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 				if (isset($flt['source'])) {
44
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
44
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
45 45
 				} else {
46
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
46
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
47 47
 				}
48 48
 			}
49 49
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
50 50
 				if (isset($flt['source'])) {
51
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
51
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
52 52
 				}
53 53
 			}
54 54
 		}
55 55
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
56 56
 			if ($filter['airlines'][0] != '') {
57
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
57
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
58 58
 			}
59 59
 		}
60 60
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
61 61
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
62 62
 		}
63 63
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
64
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
64
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
65 65
 		}
66 66
 		if (isset($filter['source']) && !empty($filter['source'])) {
67
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
67
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
68 68
 		}
69 69
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
70 70
 			$filter_query_where = " WHERE ident = '".$filter['ident']."'";
71 71
 		}
72 72
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73 73
 			if ($filter_query_where == '') {
74
-				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 			} else {
76
-				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
76
+				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
77 77
 			}
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 		if ($limit != '')
100 100
 		{
101 101
 			$limit_array = explode(',', $limit);
102
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
103
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
102
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
103
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
104 104
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
105 105
 			{
106 106
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		} else {
121 121
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
122 122
 		}
123
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
123
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
124 124
 
125 125
 		return $spotter_array;
126 126
 	}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		global $globalDBdriver, $globalLiveInterval;
137 137
 		date_default_timezone_set('UTC');
138 138
 
139
-		$filter_query = $this->getFilter($filter,true,true);
139
+		$filter_query = $this->getFilter($filter, true, true);
140 140
 
141 141
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
142 142
 		if ($globalDBdriver == 'mysql') {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
145 145
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
146 146
 
147
-			$query  = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
147
+			$query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
148 148
 			FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
149 149
 
150 150
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
155 155
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
156 156
 			//$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
157
-			$query  = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
157
+			$query = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
158 158
 			FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
159 159
 		}
160 160
 //		$spotter_array = Spotter->getDataFromDB($query.$limit_query);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute();
166
-		} catch(PDOException $e) {
166
+		} catch (PDOException $e) {
167 167
 			echo $e->getMessage();
168 168
 			die;
169 169
 		}
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 		global $globalDBdriver, $globalLiveInterval;
184 184
 		date_default_timezone_set('UTC');
185 185
 
186
-		$filter_query = $this->getFilter($filter,true,true);
186
+		$filter_query = $this->getFilter($filter, true, true);
187 187
 
188 188
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189 189
 		if ($globalDBdriver == 'mysql') {
190 190
 
191
-			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
191
+			$query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
192 192
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
193 193
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
194 194
                 } else {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 			FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
198 198
 			".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao ORDER BY spotter_live.flightaware_id, spotter_live.date';
199 199
 */
200
-			$query  = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
200
+			$query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
201 201
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
202 202
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
203 203
 //			echo $query;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     		try {
207 207
 			$sth = $this->db->prepare($query);
208 208
 			$sth->execute();
209
-		} catch(PDOException $e) {
209
+		} catch (PDOException $e) {
210 210
 			echo $e->getMessage();
211 211
 			die;
212 212
 		}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	public function getLiveSpotterCount($filter = array())
224 224
 	{
225 225
 		global $globalDBdriver, $globalLiveInterval;
226
-		$filter_query = $this->getFilter($filter,true,true);
226
+		$filter_query = $this->getFilter($filter, true, true);
227 227
 
228 228
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229 229
 		if ($globalDBdriver == 'mysql') {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		try {
237 237
 			$sth = $this->db->prepare($query);
238 238
 			$sth->execute();
239
-		} catch(PDOException $e) {
239
+		} catch (PDOException $e) {
240 240
 			echo $e->getMessage();
241 241
 			die;
242 242
 		}
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		$filter_query = $this->getFilter($filter);
260 260
 
261 261
 		if (is_array($coord)) {
262
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
263
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
262
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
263
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
264
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
265
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
266 266
 		} else return array();
267 267
 		if ($globalDBdriver == 'mysql') {
268 268
 			//$query  = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                 if ($interval == '1m')
316 316
                 {
317 317
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
318
-                } else if ($interval == '15m'){
318
+                } else if ($interval == '15m') {
319 319
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
320 320
                 } 
321 321
             }
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
324 324
         }
325 325
 
326
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
326
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
327 327
                    WHERE spotter_live.latitude <> '' 
328 328
                                    AND spotter_live.longitude <> '' 
329 329
                    ".$additional_query."
330 330
                    HAVING distance < :radius  
331 331
                                    ORDER BY distance";
332 332
 
333
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
333
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
334 334
 
335 335
                 return $spotter_array;
336 336
         }
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 		date_default_timezone_set('UTC');
349 349
 
350 350
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
351
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
352 352
 
353
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
353
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
354 354
 
355 355
 		return $spotter_array;
356 356
 	}
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
 	* @return Array the spotter information
362 362
 	*
363 363
 	*/
364
-	public function getDateLiveSpotterDataByIdent($ident,$date)
364
+	public function getDateLiveSpotterDataByIdent($ident, $date)
365 365
 	{
366 366
 		$Spotter = new Spotter($this->db);
367 367
 		date_default_timezone_set('UTC');
368 368
 
369 369
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
370
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
370
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
371 371
 
372
-                $date = date('c',$date);
373
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
372
+                $date = date('c', $date);
373
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
374 374
 
375 375
 		return $spotter_array;
376 376
 	}
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 		date_default_timezone_set('UTC');
388 388
 
389 389
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
390
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
390
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
391 391
 
392
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
392
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
393 393
 
394 394
 		return $spotter_array;
395 395
 	}
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
 	* @return Array the spotter information
401 401
 	*
402 402
 	*/
403
-	public function getDateLiveSpotterDataById($id,$date)
403
+	public function getDateLiveSpotterDataById($id, $date)
404 404
 	{
405 405
 		$Spotter = new Spotter($this->db);
406 406
 		date_default_timezone_set('UTC');
407 407
 
408 408
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
409
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
410
-                $date = date('c',$date);
411
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
409
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
410
+                $date = date('c', $date);
411
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
412 412
 
413 413
 		return $spotter_array;
414 414
 	}
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 		date_default_timezone_set('UTC');
426 426
 
427 427
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
428
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
428
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
429 429
 
430 430
     		try {
431 431
 			
432 432
 			$sth = $this->db->prepare($query);
433 433
 			$sth->execute(array(':ident' => $ident));
434
-		} catch(PDOException $e) {
434
+		} catch (PDOException $e) {
435 435
 			echo $e->getMessage();
436 436
 			die;
437 437
 		}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	* @return Array the spotter information
447 447
 	*
448 448
 	*/
449
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
449
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
450 450
 	{
451 451
 		global $globalDBdriver, $globalLiveInterval;
452 452
 		date_default_timezone_set('UTC');
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 		try {
466 466
 			$sth = $this->db->prepare($query);
467 467
 			$sth->execute(array(':id' => $id));
468
-		} catch(PDOException $e) {
468
+		} catch (PDOException $e) {
469 469
 			echo $e->getMessage();
470 470
 			die;
471 471
 		}
@@ -483,12 +483,12 @@  discard block
 block discarded – undo
483 483
 	{
484 484
 		date_default_timezone_set('UTC');
485 485
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
486
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
486
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
487 487
     		try {
488 488
 			
489 489
 			$sth = $this->db->prepare($query);
490 490
 			$sth->execute(array(':ident' => $ident));
491
-		} catch(PDOException $e) {
491
+		} catch (PDOException $e) {
492 492
 			echo $e->getMessage();
493 493
 			die;
494 494
 		}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 			
519 519
 			$sth = $this->db->prepare($query);
520 520
 			$sth->execute();
521
-		} catch(PDOException $e) {
521
+		} catch (PDOException $e) {
522 522
 			return "error";
523 523
 		}
524 524
 
@@ -541,14 +541,14 @@  discard block
 block discarded – undo
541 541
 				
542 542
 				$sth = $this->db->prepare($query);
543 543
 				$sth->execute();
544
-			} catch(PDOException $e) {
544
+			} catch (PDOException $e) {
545 545
 				return "error";
546 546
 			}
547 547
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
548 548
                         $i = 0;
549
-                        $j =0;
549
+                        $j = 0;
550 550
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
551
-			foreach($all as $row)
551
+			foreach ($all as $row)
552 552
 			{
553 553
 				$i++;
554 554
 				$j++;
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
 					if ($globalDebug) echo ".";
557 557
 				    	try {
558 558
 						
559
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
559
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
560 560
 						$sth->execute();
561
-					} catch(PDOException $e) {
561
+					} catch (PDOException $e) {
562 562
 						return "error";
563 563
 					}
564 564
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 			if ($i > 0) {
570 570
     				try {
571 571
 					
572
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
572
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
573 573
 					$sth->execute();
574
-				} catch(PDOException $e) {
574
+				} catch (PDOException $e) {
575 575
 					return "error";
576 576
 				}
577 577
 			}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 				
585 585
 				$sth = $this->db->prepare($query);
586 586
 				$sth->execute();
587
-			} catch(PDOException $e) {
587
+			} catch (PDOException $e) {
588 588
 				return "error";
589 589
 			}
590 590
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -632,13 +632,13 @@  discard block
 block discarded – undo
632 632
 	public function deleteLiveSpotterDataByIdent($ident)
633 633
 	{
634 634
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
635
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
635
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
636 636
         
637 637
     		try {
638 638
 			
639 639
 			$sth = $this->db->prepare($query);
640 640
 			$sth->execute(array(':ident' => $ident));
641
-		} catch(PDOException $e) {
641
+		} catch (PDOException $e) {
642 642
 			return "error";
643 643
 		}
644 644
 
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 	public function deleteLiveSpotterDataById($id)
655 655
 	{
656 656
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
657
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
657
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
658 658
         
659 659
     		try {
660 660
 			
661 661
 			$sth = $this->db->prepare($query);
662 662
 			$sth->execute(array(':id' => $id));
663
-		} catch(PDOException $e) {
663
+		} catch (PDOException $e) {
664 664
 			return "error";
665 665
 		}
666 666
 
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
680 680
 		if ($globalDBdriver == 'mysql') {
681
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
681
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
682 682
 				WHERE spotter_live.ident = :ident 
683 683
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
684 684
 				AND spotter_live.date < UTC_TIMESTAMP()';
685 685
 			$query_data = array(':ident' => $ident);
686 686
 		} else {
687
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
687
+			$query = "SELECT spotter_live.ident FROM spotter_live 
688 688
 				WHERE spotter_live.ident = :ident 
689 689
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-		$ident_result='';
697
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
696
+		$ident_result = '';
697
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
700 700
 		}
@@ -711,13 +711,13 @@  discard block
 block discarded – undo
711 711
 	{
712 712
 		global $globalDBdriver, $globalTimezone;
713 713
 		if ($globalDBdriver == 'mysql') {
714
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
714
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
715 715
 				WHERE spotter_live.ident = :ident 
716 716
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
717 717
 //				AND spotter_live.date < UTC_TIMESTAMP()";
718 718
 			$query_data = array(':ident' => $ident);
719 719
 		} else {
720
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
720
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
721 721
 				WHERE spotter_live.ident = :ident 
722 722
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
723 723
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 		
727 727
 		$sth = $this->db->prepare($query);
728 728
 		$sth->execute($query_data);
729
-		$ident_result='';
730
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
729
+		$ident_result = '';
730
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
731 731
 		{
732 732
 			$ident_result = $row['flightaware_id'];
733 733
 		}
@@ -744,13 +744,13 @@  discard block
 block discarded – undo
744 744
 	{
745 745
 		global $globalDBdriver, $globalTimezone;
746 746
 		if ($globalDBdriver == 'mysql') {
747
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
747
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
748 748
 				WHERE spotter_live.flightaware_id = :id 
749 749
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
750 750
 //				AND spotter_live.date < UTC_TIMESTAMP()";
751 751
 			$query_data = array(':id' => $id);
752 752
 		} else {
753
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
753
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
754 754
 				WHERE spotter_live.flightaware_id = :id 
755 755
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
756 756
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 		
760 760
 		$sth = $this->db->prepare($query);
761 761
 		$sth->execute($query_data);
762
-		$ident_result='';
763
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
762
+		$ident_result = '';
763
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
764 764
 		{
765 765
 			$ident_result = $row['flightaware_id'];
766 766
 		}
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
 	{
778 778
 		global $globalDBdriver, $globalTimezone;
779 779
 		if ($globalDBdriver == 'mysql') {
780
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
780
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
781 781
 				WHERE spotter_live.ModeS = :modes 
782 782
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
783 783
 //				AND spotter_live.date < UTC_TIMESTAMP()";
784 784
 			$query_data = array(':modes' => $modes);
785 785
 		} else {
786
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
786
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
787 787
 				WHERE spotter_live.ModeS = :modes 
788 788
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
789 789
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 		
793 793
 		$sth = $this->db->prepare($query);
794 794
 		$sth->execute($query_data);
795
-		$ident_result='';
796
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
795
+		$ident_result = '';
796
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
797 797
 		{
798 798
 			//$ident_result = $row['spotter_live_id'];
799 799
 			$ident_result = $row['flightaware_id'];
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 	* @return String success or false
813 813
 	*
814 814
 	*/
815
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
815
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
816 816
 	{
817 817
 		global $globalURL, $globalArchive, $globalDebug;
818 818
 		$Common = new Common();
@@ -906,26 +906,26 @@  discard block
 block discarded – undo
906 906
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
907 907
 
908 908
         
909
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
910
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
911
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
912
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
913
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
914
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
915
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
916
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
917
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
918
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
919
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
920
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
921
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
922
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
923
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
924
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
925
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
926
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
927
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
928
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
909
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
910
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
911
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
912
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
913
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
914
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
915
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
916
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
917
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
918
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
919
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
920
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
921
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
922
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
923
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
924
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
925
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
926
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
927
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
928
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
929 929
 
930 930
 		$airline_name = '';
931 931
 		$airline_icao = '';
@@ -947,26 +947,26 @@  discard block
 block discarded – undo
947 947
 		$arrival_airport_country = '';
948 948
 		
949 949
             	
950
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
951
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
952
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
953
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
950
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
951
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
952
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
953
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
954 954
             	
955
-		$query  = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
955
+		$query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
956 956
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
957 957
 
958
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
958
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
959 959
 		//$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'],':airline_country' => $airline_array[0]['country'],':airline_type' => $airline_array[0]['type'],':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_array[0]['type'],':aircraft_manufacturer' => $aircraft_array[0]['manufacturer'],':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date);
960 960
 		try {
961 961
 			
962 962
 			$sth = $this->db->prepare($query);
963 963
 			$sth->execute($query_values);
964
-                } catch(PDOException $e) {
964
+                } catch (PDOException $e) {
965 965
                 	return "error : ".$e->getMessage();
966 966
                 }
967 967
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
968 968
 		    if ($globalDebug) echo '(Add to SBS archive : ';
969
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
969
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
970 970
 		    if ($globalDebug) echo $result.')';
971 971
 		}
972 972
 		return "success";
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 
976 976
 	public function getOrderBy()
977 977
 	{
978
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
978
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
979 979
 		return $orderby;
980 980
 	}
981 981
 
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -13,45 +13,45 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
16
+    public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+			$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
26
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
27 27
 	$filter_query_join = '';
28 28
 	$filter_query_where = '';
29
-	foreach($filters as $flt) {
29
+	foreach ($filters as $flt) {
30 30
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
31 31
 		if ($flt['airlines'][0] != '') {
32 32
 		    if (isset($flt['source'])) {
33
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
33
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
34 34
 		    } else {
35
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
35
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
36 36
 		    }
37 37
 		}
38 38
 	    }
39 39
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
40 40
 		if (isset($flt['source'])) {
41
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
41
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
42 42
 		} else {
43
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
43
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
44 44
 		}
45 45
 	    }
46 46
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
47 47
 		if (isset($flt['source'])) {
48
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
48
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
49 49
 		}
50 50
 	    }
51 51
 	}
52 52
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
53 53
 	    if ($filter['airlines'][0] != '') {
54
-		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
54
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
55 55
 	    }
56 56
 	}
57 57
 	
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
60 60
 	}
61 61
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
62
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
62
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
63 63
 	}
64 64
 	if (isset($filter['source']) && !empty($filter['source'])) {
65
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
65
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
66 66
 	}
67 67
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
68 68
 	    $filter_query_where = " WHERE ident = '".$filter['ident']."'";
69 69
 	}
70 70
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
71 71
 	    if ($filter_query_where == '') {
72
-		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
72
+		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
73 73
 	    } else {
74
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 	    }
76 76
 	}
77 77
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
 	// Spotter_archive
84
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
84
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
85 85
 		require_once(dirname(__FILE__).'/class.Spotter.php');
86 86
 		if ($over_country == '') {
87 87
 			$Spotter = new Spotter($this->db);
88
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
88
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
89 89
 			if (!empty($data_country)) $country = $data_country['iso2'];
90 90
 			else $country = '';
91 91
 		} else $country = $over_country;
92
-		if ($airline_type === NULL) $airline_type ='';
92
+		if ($airline_type === NULL) $airline_type = '';
93 93
 	
94 94
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
95 95
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
96 96
 
97 97
 		// Route is not added in spotter_archive
98
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
98
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
99 99
 		        VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
100 100
 
101
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
101
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			return "error : ".$e->getMessage();
107 107
 		}
108 108
 		return "success";
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
124 124
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
125
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
125
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126 126
 
127
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
127
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
128 128
 
129 129
                 return $spotter_array;
130 130
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
144 144
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
145 145
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
146
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
146
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
147 147
 
148 148
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
149 149
                   /*
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 }
157 157
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
158 158
                 */
159
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
159
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
160 160
 
161 161
                 return $spotter_array;
162 162
         }
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         {
172 172
                 date_default_timezone_set('UTC');
173 173
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
174
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
174
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
175 175
 
176 176
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
177 177
 
178 178
                 try {
179 179
                         $sth = $this->db->prepare($query);
180 180
                         $sth->execute(array(':id' => $id));
181
-                } catch(PDOException $e) {
181
+                } catch (PDOException $e) {
182 182
                         echo $e->getMessage();
183 183
                         die;
184 184
                 }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
         {
198 198
                 date_default_timezone_set('UTC');
199 199
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
200
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
200
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
201 201
 
202 202
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
203 203
 
204 204
                 try {
205 205
                         $sth = $this->db->prepare($query);
206 206
                         $sth->execute(array(':id' => $id));
207
-                } catch(PDOException $e) {
207
+                } catch (PDOException $e) {
208 208
                         echo $e->getMessage();
209 209
                         die;
210 210
                 }
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
                 date_default_timezone_set('UTC');
227 227
 
228 228
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
229
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
229
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
230 230
 
231 231
                 try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute(array(':ident' => $ident));
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo $e->getMessage();
236 236
                         die;
237 237
                 }
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
                 date_default_timezone_set('UTC');
253 253
 
254 254
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
255
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
255
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
256 256
 
257 257
                 try {
258 258
                         $sth = $this->db->prepare($query);
259 259
                         $sth->execute(array(':id' => $id));
260
-                } catch(PDOException $e) {
260
+                } catch (PDOException $e) {
261 261
                         echo $e->getMessage();
262 262
                         die;
263 263
                 }
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
                 date_default_timezone_set('UTC');
279 279
 
280 280
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
281
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
281
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
282 282
 
283 283
                 try {
284 284
                         $sth = $this->db->prepare($query);
285 285
                         $sth->execute(array(':id' => $id));
286
-                } catch(PDOException $e) {
286
+                } catch (PDOException $e) {
287 287
                         echo $e->getMessage();
288 288
                         die;
289 289
                 }
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
                 date_default_timezone_set('UTC');
306 306
 
307 307
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
308
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
308
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
309 309
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
310 310
 
311 311
                 try {
312 312
                         $sth = $this->db->prepare($query);
313 313
                         $sth->execute(array(':ident' => $ident));
314
-                } catch(PDOException $e) {
314
+                } catch (PDOException $e) {
315 315
                         echo $e->getMessage();
316 316
                         die;
317 317
                 }
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
         * @return Array the spotter information
329 329
         *
330 330
         */
331
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
331
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
332 332
         {
333 333
     		$Spotter = new Spotter($this->db);
334 334
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
335
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
335
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
336 336
 
337
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
337
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
338 338
 
339 339
                 return $spotter_array;
340 340
         }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                 try {
348 348
                         $sth = $this->db->prepare($query);
349 349
                         $sth->execute();
350
-                } catch(PDOException $e) {
350
+                } catch (PDOException $e) {
351 351
                         echo $e->getMessage();
352 352
                         die;
353 353
                 }
@@ -359,24 +359,24 @@  discard block
 block discarded – undo
359 359
         * @return Array the spotter information
360 360
         *
361 361
         */
362
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
362
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
363 363
         {
364 364
                 global $globalDBdriver, $globalLiveInterval;
365 365
                 date_default_timezone_set('UTC');
366 366
 
367 367
                 $filter_query = '';
368 368
                 if (isset($filter['source']) && !empty($filter['source'])) {
369
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
370 370
                 }
371 371
                 // Use spotter_output also ?
372 372
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
373
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
373
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
374 374
                 }
375 375
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
376 376
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
377 377
                 }
378 378
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
379
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
380 380
                 }
381 381
 
382 382
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
396 396
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
397 397
 */
398
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
398
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399 399
 				    FROM spotter_archive 
400 400
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
401 401
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
402 402
                         	    '.$filter_query.' ORDER BY flightaware_id';
403 403
                 } else {
404 404
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
405
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
405
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406 406
                         	    FROM spotter_archive 
407 407
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
408 408
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
                 try {
413 413
                         $sth = $this->db->prepare($query);
414 414
                         $sth->execute();
415
-                } catch(PDOException $e) {
415
+                } catch (PDOException $e) {
416 416
                         echo $e->getMessage();
417 417
                         die;
418 418
                 }
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
         * @return Array the spotter information
428 428
         *
429 429
         */
430
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
430
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
431 431
         {
432 432
                 global $globalDBdriver, $globalLiveInterval;
433 433
                 date_default_timezone_set('UTC');
434 434
 
435 435
                 $filter_query = '';
436 436
                 if (isset($filter['source']) && !empty($filter['source'])) {
437
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
438 438
                 }
439 439
                 // Should use spotter_output also ?
440 440
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
441
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
441
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
442 442
                 }
443 443
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
444 444
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
445 445
                 }
446 446
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
447
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
448 448
                 }
449 449
 
450 450
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                     		    FROM spotter_archive 
455 455
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
456 456
 			*/
457
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
457
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
458 458
 				    FROM spotter_archive_output 
459 459
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
460 460
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
470 470
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
471 471
                         */
472
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
472
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
473 473
                         	    FROM spotter_archive_output 
474 474
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
475 475
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                 try {
482 482
                         $sth = $this->db->prepare($query);
483 483
                         $sth->execute();
484
-                } catch(PDOException $e) {
484
+                } catch (PDOException $e) {
485 485
                         echo $e->getMessage();
486 486
                         die;
487 487
                 }
@@ -496,23 +496,23 @@  discard block
 block discarded – undo
496 496
         * @return Array the spotter information
497 497
         *
498 498
         */
499
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
499
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
500 500
         {
501 501
                 global $globalDBdriver, $globalLiveInterval;
502 502
                 date_default_timezone_set('UTC');
503 503
 
504 504
                 $filter_query = '';
505 505
                 if (isset($filter['source']) && !empty($filter['source'])) {
506
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
507 507
                 }
508 508
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
509
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
509
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
510 510
                 }
511 511
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
512 512
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
513 513
                 }
514 514
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
515
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
516 516
                 }
517 517
 
518 518
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute();
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo $e->getMessage();
532 532
                         die;
533 533
                 }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     * @return Array the spotter information
548 548
     *
549 549
     */
550
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
550
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
551 551
     {
552 552
 	global $globalTimezone, $globalDBdriver;
553 553
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	        
570 570
 		$q_array = explode(" ", $q);
571 571
 		
572
-		foreach ($q_array as $q_item){
572
+		foreach ($q_array as $q_item) {
573 573
 		    $additional_query .= " AND (";
574 574
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
575 575
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	
602 602
 	if ($registration != "")
603 603
 	{
604
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
605 605
 	    if (!is_string($registration))
606 606
 	    {
607 607
 		return false;
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	
613 613
 	if ($aircraft_icao != "")
614 614
 	{
615
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
616 616
 	    if (!is_string($aircraft_icao))
617 617
 	    {
618 618
 		return false;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	
624 624
 	if ($aircraft_manufacturer != "")
625 625
 	{
626
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
627 627
 	    if (!is_string($aircraft_manufacturer))
628 628
 	    {
629 629
 		return false;
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	
645 645
 	if ($airline_icao != "")
646 646
 	{
647
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
648 648
 	    if (!is_string($airline_icao))
649 649
 	    {
650 650
 		return false;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	
656 656
 	if ($airline_country != "")
657 657
 	{
658
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
659 659
 	    if (!is_string($airline_country))
660 660
 	    {
661 661
 		return false;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	
667 667
 	if ($airline_type != "")
668 668
 	{
669
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
670 670
 	    if (!is_string($airline_type))
671 671
 	    {
672 672
 		return false;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 	
689 689
 	if ($airport != "")
690 690
 	{
691
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
692 692
 	    if (!is_string($airport))
693 693
 	    {
694 694
 		return false;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	
700 700
 	if ($airport_country != "")
701 701
 	{
702
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
703 703
 	    if (!is_string($airport_country))
704 704
 	    {
705 705
 		return false;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     
711 711
 	if ($callsign != "")
712 712
 	{
713
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
714 714
 	    if (!is_string($callsign))
715 715
 	    {
716 716
 		return false;
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 		$translate = $Translation->ident2icao($callsign);
719 719
 		if ($translate != $callsign) {
720 720
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
721
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
721
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
722 722
 		} else {
723 723
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
724 724
 		}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
 	if ($owner != "")
729 729
 	{
730
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
731 731
 	    if (!is_string($owner))
732 732
 	    {
733 733
 		return false;
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 
739 739
 	if ($pilot_name != "")
740 740
 	{
741
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
742 742
 	    if (!is_string($pilot_name))
743 743
 	    {
744 744
 		return false;
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	
750 750
 	if ($pilot_id != "")
751 751
 	{
752
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
753 753
 	    if (!is_string($pilot_id))
754 754
 	    {
755 755
 		return false;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	if ($departure_airport_route != "")
762 762
 	{
763
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
764 764
 	    if (!is_string($departure_airport_route))
765 765
 	    {
766 766
 		return false;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	
772 772
 	if ($arrival_airport_route != "")
773 773
 	{
774
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
775 775
 	    if (!is_string($arrival_airport_route))
776 776
 	    {
777 777
 		return false;
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	{
785 785
 	    $altitude_array = explode(",", $altitude);
786 786
 	    
787
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789 789
 	    
790 790
 
791 791
 	    if ($altitude_array[1] != "")
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 	{
804 804
 	    $date_array = explode(",", $date_posted);
805 805
 	    
806
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
807
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
806
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
807
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
808 808
 	    
809 809
 	    if ($globalTimezone != '') {
810 810
 		date_default_timezone_set($globalTimezone);
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	{
837 837
 	    $limit_array = explode(",", $limit);
838 838
 	    
839
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
840
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
839
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
841 841
 	    
842 842
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
843 843
 	    {
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	
849 849
 
850 850
 	if ($origLat != "" && $origLon != "" && $dist != "") {
851
-		$dist = number_format($dist*0.621371,2,'.','');
852
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
851
+		$dist = number_format($dist*0.621371, 2, '.', '');
852
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
853 853
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
854 854
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
855 855
 	} else {
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
867 867
 		}
868 868
 
869
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
869
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
870 870
 		    WHERE spotter_archive_output.ident <> '' 
871 871
 		    ".$additional_query."
872 872
 		    ".$filter_query.$orderby_query;
873 873
 	}
874
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
874
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
875 875
 
876 876
 	return $spotter_array;
877 877
     }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                 try {
889 889
                         $sth = $this->db->prepare($query);
890 890
                         $sth->execute();
891
-                } catch(PDOException $e) {
891
+                } catch (PDOException $e) {
892 892
                         return "error";
893 893
                 }
894 894
 	}
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	{
926 926
 	    $limit_array = explode(",", $limit);
927 927
 	    
928
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
929
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
928
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
930 930
 	    
931 931
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
932 932
 	    {
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
     * @return Array the airline country list
957 957
     *
958 958
     */
959
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
959
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
960 960
     {
961 961
 	global $globalDBdriver;
962 962
 	/*
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 	$flight_array = array();
986 986
 	$temp_array = array();
987 987
         
988
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
988
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
989 989
 	{
990 990
 	    $temp_array['flight_count'] = $row['nb'];
991 991
 	    $temp_array['flight_country'] = $row['name'];
@@ -1002,14 +1002,14 @@  discard block
 block discarded – undo
1002 1002
     * @return Array the spotter information
1003 1003
     *
1004 1004
     */
1005
-    public function getDateArchiveSpotterDataById($id,$date)
1005
+    public function getDateArchiveSpotterDataById($id, $date)
1006 1006
     {
1007 1007
 	$Spotter = new Spotter($this->db);
1008 1008
 	date_default_timezone_set('UTC');
1009 1009
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1010
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1011
-	$date = date('c',$date);
1012
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1010
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1011
+	$date = date('c', $date);
1012
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1013 1013
 	return $spotter_array;
1014 1014
     }
1015 1015
 
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
     * @return Array the spotter information
1020 1020
     *
1021 1021
     */
1022
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1022
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1023 1023
     {
1024 1024
 	$Spotter = new Spotter($this->db);
1025 1025
 	date_default_timezone_set('UTC');
1026 1026
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1027
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1028
-	$date = date('c',$date);
1029
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1027
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1028
+	$date = date('c', $date);
1029
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1030 1030
 	return $spotter_array;
1031 1031
     }
1032 1032
 
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
     * @return Array the spotter information
1037 1037
     *
1038 1038
     */
1039
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1039
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1040 1040
     {
1041 1041
 	global $global_query;
1042 1042
 	$Spotter = new Spotter();
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	$query_values = array();
1045 1045
 	$limit_query = '';
1046 1046
 	$additional_query = '';
1047
-	$filter_query = $this->getFilter($filters,true,true);
1047
+	$filter_query = $this->getFilter($filters, true, true);
1048 1048
 	
1049 1049
 	if ($airport != "")
1050 1050
 	{
@@ -1061,8 +1061,8 @@  discard block
 block discarded – undo
1061 1061
 	{
1062 1062
 	    $limit_array = explode(",", $limit);
1063 1063
 	    
1064
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1065
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1064
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1065
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1066 1066
 	    
1067 1067
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1068 1068
 	    {
Please login to merge, or discard this patch.