Completed
Push — master ( 254fbc...96a3ac )
by Yannick
07:47
created
require/class.APRS.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -89,6 +89,10 @@  discard block
 block discarded – undo
89 89
 	'y' => 'Yagi At QTH');
90 90
 	
91 91
 
92
+    /**
93
+     * @param integer $n
94
+     * @param integer $s
95
+     */
92 96
     private function urshift($n, $s) {
93 97
 	return ($n >= 0) ? ($n >> $s) :
94 98
 	    (($n & 0x7fffffff) >> $s) | 
@@ -455,6 +459,9 @@  discard block
 block discarded – undo
455 459
 	}
456 460
     }
457 461
     
462
+    /**
463
+     * @param string $data
464
+     */
458 465
     function send($data) {
459 466
 	if ($this->connected == false) $this->connect();
460 467
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 class aprs {
5
-    private $socket;
6
-    private $connected = false;
5
+	private $socket;
6
+	private $connected = false;
7 7
 
8
-    protected $symbols = array('!' => 'Police',
8
+	protected $symbols = array('!' => 'Police',
9 9
 	'#' => 'DIGI',
10 10
 	'$' => 'Phone',
11 11
 	'%' => 'DX Cluster',
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	'y' => 'Yagi At QTH');
90 90
 	
91 91
 
92
-    private function urshift($n, $s) {
92
+	private function urshift($n, $s) {
93 93
 	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
94
+		(($n & 0x7fffffff) >> $s) | 
95 95
 		(0x40000000 >> ($s - 1));
96
-    }
96
+	}
97 97
 
98
-    public function parse($input) {
98
+	public function parse($input) {
99 99
 	global $globalDebug;
100 100
 	$debug = false;
101 101
 	$result = array();
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
-	    return false;
110
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
+		return false;
112 112
 	}
113 113
 	
114 114
 	if ($debug) echo 'input : '.$input."\n";
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
 	/* Parse source, target and path. */
123 123
 	//FLRDF0A52>APRS,qAS,LSTB
124 124
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
125
-	    $ident = $matches[1];
126
-	    $all_elements = $matches[2];
127
-	    if ($debug) echo 'ident : '.$ident."\n";
128
-	    $result['ident'] = $ident;
125
+		$ident = $matches[1];
126
+		$all_elements = $matches[2];
127
+		if ($debug) echo 'ident : '.$ident."\n";
128
+		$result['ident'] = $ident;
129 129
 	} else return false;
130 130
 	$elements = explode(',',$all_elements);
131 131
 	$source = end($elements);
132 132
 	$result['source'] = $source;
133 133
 	foreach ($elements as $element) {
134
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
135
-	        //echo "ok";
136
-	        //if ($element == 'TCPIP*') return false;
137
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
134
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
135
+			//echo "ok";
136
+			//if ($element == 'TCPIP*') return false;
137
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
138 138
 		if ($debug) echo 'element : '.$element."\n";
139 139
 		return false;
140
-	    }
141
-	    /*
140
+		}
141
+		/*
142 142
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
143 143
 		//echo "ok";
144 144
 	    } else {
@@ -161,49 +161,49 @@  discard block
 block discarded – undo
161 161
 	$body_parse = substr($body,1);
162 162
 	//echo 'Body : '.$body."\n";
163 163
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
164
-	    $body_parse = substr($body_parse,10);
165
-	    $find = true;
166
-	    //echo $body_parse."\n";
164
+		$body_parse = substr($body_parse,10);
165
+		$find = true;
166
+		//echo $body_parse."\n";
167 167
 	}
168 168
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
169
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
170
-	    $find = true;
171
-	    //echo $body_parse."\n";
169
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
170
+		$find = true;
171
+		//echo $body_parse."\n";
172 172
 	}
173 173
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
174
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
175
-	    $find = true;
176
-	    //echo $body_parse."\n";
174
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
175
+		$find = true;
176
+		//echo $body_parse."\n";
177 177
 	}
178 178
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
179
-	    $find = true;
180
-	    //print_r($matches);
181
-	    $timestamp = $matches[0];
182
-	    if ($matches[4] == 'h') {
179
+		$find = true;
180
+		//print_r($matches);
181
+		$timestamp = $matches[0];
182
+		if ($matches[4] == 'h') {
183 183
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
184 184
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
185 185
 		/*
186 186
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
187 187
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
188 188
 		*/
189
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
189
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
190 190
 		// This work or not ?
191 191
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
192
-	    }
193
-	    $body_parse = substr($body_parse,7);
194
-	    $result['timestamp'] = $timestamp;
195
-	    //echo date('Ymd H:i:s',$timestamp);
192
+		}
193
+		$body_parse = substr($body_parse,7);
194
+		$result['timestamp'] = $timestamp;
195
+		//echo date('Ymd H:i:s',$timestamp);
196 196
 	}
197 197
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
198
-	    $find = true;
199
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
200
-	    $body_parse = substr($body_parse,8);
201
-	    $result['timestamp'] = $timestamp;
202
-	    //echo date('Ymd H:i:s',$timestamp);
198
+		$find = true;
199
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
200
+		$body_parse = substr($body_parse,8);
201
+		$result['timestamp'] = $timestamp;
202
+		//echo date('Ymd H:i:s',$timestamp);
203 203
 	}
204 204
 	//if (strlen($body_parse) > 19) {
205
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
206
-	    $find = true;
205
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
206
+		$find = true;
207 207
 		// 4658.70N/00707.78Ez
208 208
 		//print_r(str_split($body_parse));
209 209
 		
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$lon = intval($lon_deg);
221 221
 		if ($lat > 89 || $lon > 179) return false;
222 222
 	    
223
-	    /*
223
+		/*
224 224
 	    $tmp_5b = str_replace('.','',$lat_min);
225 225
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
226 226
 	        print_r($matches);
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 		$result['longitude'] = $longitude;
235 235
 		$body_parse = substr($body_parse,18);
236 236
 		$body_parse_len = strlen($body_parse);
237
-	    }
238
-	    $body_parse_len = strlen($body_parse);
239
-	    if ($body_parse_len > 0) {
237
+		}
238
+		$body_parse_len = strlen($body_parse);
239
+		if ($body_parse_len > 0) {
240 240
 		/*
241 241
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
242 242
 			$body_split = str_split($body);
@@ -265,85 +265,85 @@  discard block
 block discarded – undo
265 265
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
266 266
 			if ($symbol_code != '_') {
267 267
 			}
268
-		    //$body_parse = substr($body_parse,1);
269
-		    //$body_parse = trim($body_parse);
270
-		    //$body_parse_len = strlen($body_parse);
271
-		    if ($body_parse_len >= 7) {
268
+			//$body_parse = substr($body_parse,1);
269
+			//$body_parse = trim($body_parse);
270
+			//$body_parse_len = strlen($body_parse);
271
+			if ($body_parse_len >= 7) {
272 272
 			
273
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
274
-		    	    $course = substr($body_parse,0,3);
275
-		    	    $tmp_s = intval($course);
276
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
277
-		    	    $speed = substr($body_parse,4,3);
278
-		    	    if ($speed != '...') {
279
-		    		    $result['speed'] = round($speed*1.852);
280
-		    	    }
281
-		    	    $body_parse = substr($body_parse,7);
282
-		        }
283
-		        // Check PHGR, PHG, RNG
284
-		    } 
285
-		    /*
273
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
274
+					$course = substr($body_parse,0,3);
275
+					$tmp_s = intval($course);
276
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
277
+					$speed = substr($body_parse,4,3);
278
+					if ($speed != '...') {
279
+						$result['speed'] = round($speed*1.852);
280
+					}
281
+					$body_parse = substr($body_parse,7);
282
+				}
283
+				// Check PHGR, PHG, RNG
284
+			} 
285
+			/*
286 286
 		    else if ($body_parse_len > 0) {
287 287
 			$rest = $body_parse;
288 288
 		    }
289 289
 		    */
290
-		    if (strlen($body_parse) > 0) {
291
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
292
-		            $altitude = intval($matches[1]);
293
-		            //$result['altitude'] = round($altitude*0.3048);
294
-		            $result['altitude'] = $altitude;
295
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
296
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
297
-		        }
298
-		    }
290
+			if (strlen($body_parse) > 0) {
291
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
292
+					$altitude = intval($matches[1]);
293
+					//$result['altitude'] = round($altitude*0.3048);
294
+					$result['altitude'] = $altitude;
295
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
296
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
297
+				}
298
+			}
299 299
 		    
300
-		    // Telemetry
301
-		    /*
300
+			// Telemetry
301
+			/*
302 302
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
303 303
 		        // Nothing yet...
304 304
 		    }
305 305
 		    */
306
-		    // DAO
307
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
308
-			    $dao = $matches[1];
309
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
306
+			// DAO
307
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
308
+				$dao = $matches[1];
309
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
310 310
 				$dao_split = str_split($dao);
311
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
312
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
311
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
312
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
313 313
 			    
314 314
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
315 315
 				else $result['latitude'] += $lat_off;
316 316
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
317 317
 				else $result['longitude'] += $lon_off;
318
-			    }
319
-		            $body_parse = substr($body_parse,6);
320
-		    }
318
+				}
319
+					$body_parse = substr($body_parse,6);
320
+			}
321 321
 		    
322
-		    if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
322
+			if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
323 323
 			$result['callsign'] = $matches[1];
324
-		    }
325
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
324
+			}
325
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
326 326
 			$result['squawk'] = $matches[1];
327
-		    }
328
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
327
+			}
328
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
329 329
 			$result['aircraft_icao'] = $matches[1];
330
-		    }
331
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
330
+			}
331
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
332 332
 			$result['typeid'] = $matches[1];
333
-		    }
334
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
333
+			}
334
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
335 335
 			$result['imo'] = $matches[1];
336
-		    }
337
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
336
+			}
337
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
338 338
 			$result['arrival_date'] = $matches[1];
339
-		    }
340
-		    if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
339
+			}
340
+			if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
341 341
 			$result['arrival_code'] = $matches[1];
342
-		    }
343
-		    // OGN comment
342
+			}
343
+			// OGN comment
344 344
 		   // echo "Before OGN : ".$body_parse."\n";
345
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
346
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
345
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
346
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
347 347
 			$id = $matches[1];
348 348
 			//$mode = substr($id,0,2);
349 349
 			$address = substr($id,2);
@@ -373,53 +373,53 @@  discard block
 block discarded – undo
373 373
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
374 374
 			$result['stealth'] = $stealth;
375 375
 			$result['address'] = $address;
376
-		    }
376
+			}
377 377
 		    
378
-		    //Comment
379
-		    $result['comment'] = trim($body_parse);
378
+			//Comment
379
+			$result['comment'] = trim($body_parse);
380 380
 		} else {
381
-		    // parse weather
382
-		    //$body_parse = substr($body_parse,1);
383
-		    //$body_parse_len = strlen($body_parse);
381
+			// parse weather
382
+			//$body_parse = substr($body_parse,1);
383
+			//$body_parse_len = strlen($body_parse);
384 384
 
385
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
386
-			    $result['wind_dir'] = intval($matches[1]);
387
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
388
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
389
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
390
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
391
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
385
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
386
+				$result['wind_dir'] = intval($matches[1]);
387
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
388
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
389
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
390
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
391
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
392 392
 			$result['wind_dir'] = intval($matches[1]);
393 393
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
394 394
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
395 395
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
396
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
397
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
396
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
397
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
398 398
 			$result['wind_dir'] = intval($matches[1]);
399 399
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
400 400
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
401
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
402
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
401
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
402
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
403 403
 			$result['wind_dir'] = intval($matches[1]);
404 404
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
405 405
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
406
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
407
-		    }
408
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
406
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
407
+			}
408
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
409 409
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
410
-		    }
410
+			}
411 411
 		}
412 412
 		} else $result['comment'] = trim($body_parse);
413 413
 
414
-	    }
414
+		}
415 415
 	//}
416 416
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
417 417
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
418 418
 	if ($debug) print_r($result);
419 419
 	return $result;
420
-    }
420
+	}
421 421
     
422
-    function connect() {
422
+	function connect() {
423 423
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
424 424
 	$aprs_connect = 0;
425 425
 	$aprs_keep = 120;
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
 		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
443 443
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
444 444
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
445
-			    echo 'APRS user verified !'."\n";
446
-			    $this->connected = true;
447
-			    return true;
448
-			    break;
445
+				echo 'APRS user verified !'."\n";
446
+				$this->connected = true;
447
+				return true;
448
+				break;
449 449
 			}
450 450
 			if (time()-$authstart > 5) {
451
-			    echo 'APRS timeout'."\n";
452
-			    break;
451
+				echo 'APRS timeout'."\n";
452
+				break;
453 453
 			}
454 454
 		}
455 455
 	}
456
-    }
456
+	}
457 457
     
458
-    function send($data) {
458
+	function send($data) {
459 459
 	if ($this->connected == false) $this->connect();
460 460
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
461 461
 	if ($send === FALSE) $this->connect();
462
-    }
462
+	}
463 463
 }
464 464
 
465 465
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
Spacing   +94 added lines, -95 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 	
91 91
 
92 92
     private function urshift($n, $s) {
93
-	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
93
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
95 94
 		(0x40000000 >> ($s - 1));
96 95
     }
97 96
 
@@ -103,7 +102,7 @@  discard block
 block discarded – undo
103 102
 	//$split_input = str_split($input);
104 103
 
105 104
 	/* Find the end of header checking for NULL bytes while doing it. */
106
-	$splitpos = strpos($input,':');
105
+	$splitpos = strpos($input, ':');
107 106
 	
108 107
 	/* Check that end was found and body has at least one byte. */
109 108
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -113,28 +112,28 @@  discard block
 block discarded – undo
113 112
 	
114 113
 	if ($debug) echo 'input : '.$input."\n";
115 114
 	/* Save header and body. */
116
-	$body = substr($input,$splitpos+1,$input_len);
115
+	$body = substr($input, $splitpos + 1, $input_len);
117 116
 	$body_len = strlen($body);
118
-	$header = substr($input,0,$splitpos);
117
+	$header = substr($input, 0, $splitpos);
119 118
 	//$header_len = strlen($header);
120 119
 	if ($debug) echo 'header : '.$header."\n";
121 120
 	
122 121
 	/* Parse source, target and path. */
123 122
 	//FLRDF0A52>APRS,qAS,LSTB
124
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
123
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
125 124
 	    $ident = $matches[1];
126 125
 	    $all_elements = $matches[2];
127 126
 	    if ($debug) echo 'ident : '.$ident."\n";
128 127
 	    $result['ident'] = $ident;
129 128
 	} else return false;
130
-	$elements = explode(',',$all_elements);
129
+	$elements = explode(',', $all_elements);
131 130
 	$source = end($elements);
132 131
 	$result['source'] = $source;
133 132
 	foreach ($elements as $element) {
134
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
133
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
135 134
 	        //echo "ok";
136 135
 	        //if ($element == 'TCPIP*') return false;
137
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
136
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
138 137
 		if ($debug) echo 'element : '.$element."\n";
139 138
 		return false;
140 139
 	    }
@@ -147,10 +146,10 @@  discard block
 block discarded – undo
147 146
 	    */
148 147
 	}
149 148
 	
150
-	$type = substr($body,0,1);
149
+	$type = substr($body, 0, 1);
151 150
 	if ($debug) echo 'type : '.$type."\n";
152 151
 	if ($type == ';') {
153
-		$result['ident'] = trim(substr($body,1,9));
152
+		$result['ident'] = trim(substr($body, 1, 9));
154 153
 	} elseif ($type == ',') {
155 154
 		// Invalid data or test data
156 155
 		return false;
@@ -158,24 +157,24 @@  discard block
 block discarded – undo
158 157
 	
159 158
 	// Check for Timestamp
160 159
 	$find = false;
161
-	$body_parse = substr($body,1);
160
+	$body_parse = substr($body, 1);
162 161
 	//echo 'Body : '.$body."\n";
163
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
164
-	    $body_parse = substr($body_parse,10);
162
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
163
+	    $body_parse = substr($body_parse, 10);
165 164
 	    $find = true;
166 165
 	    //echo $body_parse."\n";
167 166
 	}
168
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
169
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
167
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
168
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
170 169
 	    $find = true;
171 170
 	    //echo $body_parse."\n";
172 171
 	}
173
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
174
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
172
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
173
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
175 174
 	    $find = true;
176 175
 	    //echo $body_parse."\n";
177 176
 	}
178
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
177
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
179 178
 	    $find = true;
180 179
 	    //print_r($matches);
181 180
 	    $timestamp = $matches[0];
@@ -190,19 +189,19 @@  discard block
 block discarded – undo
190 189
 		// This work or not ?
191 190
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
192 191
 	    }
193
-	    $body_parse = substr($body_parse,7);
192
+	    $body_parse = substr($body_parse, 7);
194 193
 	    $result['timestamp'] = $timestamp;
195 194
 	    //echo date('Ymd H:i:s',$timestamp);
196 195
 	}
197
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
196
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
198 197
 	    $find = true;
199 198
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
200
-	    $body_parse = substr($body_parse,8);
199
+	    $body_parse = substr($body_parse, 8);
201 200
 	    $result['timestamp'] = $timestamp;
202 201
 	    //echo date('Ymd H:i:s',$timestamp);
203 202
 	}
204 203
 	//if (strlen($body_parse) > 19) {
205
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
204
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
206 205
 	    $find = true;
207 206
 		// 4658.70N/00707.78Ez
208 207
 		//print_r(str_split($body_parse));
@@ -228,11 +227,11 @@  discard block
 block discarded – undo
228 227
 	    */
229 228
 		$latitude = $lat + floatval($lat_min)/60;
230 229
 		$longitude = $lon + floatval($lon_min)/60;
231
-		if ($sind == 'S') $latitude = 0-$latitude;
232
-		if ($wind == 'W') $longitude = 0-$longitude;
230
+		if ($sind == 'S') $latitude = 0 - $latitude;
231
+		if ($wind == 'W') $longitude = 0 - $longitude;
233 232
 		$result['latitude'] = $latitude;
234 233
 		$result['longitude'] = $longitude;
235
-		$body_parse = substr($body_parse,18);
234
+		$body_parse = substr($body_parse, 18);
236 235
 		$body_parse_len = strlen($body_parse);
237 236
 	    }
238 237
 	    $body_parse_len = strlen($body_parse);
@@ -259,7 +258,7 @@  discard block
 block discarded – undo
259 258
 		//}
260 259
 		//echo $body_parse;
261 260
 			if ($type != ';' && $type != '>') {
262
-			$body_parse = substr($body_parse,1);
261
+			$body_parse = substr($body_parse, 1);
263 262
 			$body_parse_len = strlen($body_parse);
264 263
 			$result['symbol_code'] = $symbol_code;
265 264
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -270,15 +269,15 @@  discard block
 block discarded – undo
270 269
 		    //$body_parse_len = strlen($body_parse);
271 270
 		    if ($body_parse_len >= 7) {
272 271
 			
273
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
274
-		    	    $course = substr($body_parse,0,3);
272
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
273
+		    	    $course = substr($body_parse, 0, 3);
275 274
 		    	    $tmp_s = intval($course);
276 275
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
277
-		    	    $speed = substr($body_parse,4,3);
276
+		    	    $speed = substr($body_parse, 4, 3);
278 277
 		    	    if ($speed != '...') {
279 278
 		    		    $result['speed'] = round($speed*1.852);
280 279
 		    	    }
281
-		    	    $body_parse = substr($body_parse,7);
280
+		    	    $body_parse = substr($body_parse, 7);
282 281
 		        }
283 282
 		        // Check PHGR, PHG, RNG
284 283
 		    } 
@@ -288,12 +287,12 @@  discard block
 block discarded – undo
288 287
 		    }
289 288
 		    */
290 289
 		    if (strlen($body_parse) > 0) {
291
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
290
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
292 291
 		            $altitude = intval($matches[1]);
293 292
 		            //$result['altitude'] = round($altitude*0.3048);
294 293
 		            $result['altitude'] = $altitude;
295 294
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
296
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
295
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
297 296
 		        }
298 297
 		    }
299 298
 		    
@@ -304,56 +303,56 @@  discard block
 block discarded – undo
304 303
 		    }
305 304
 		    */
306 305
 		    // DAO
307
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
306
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
308 307
 			    $dao = $matches[1];
309
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
308
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
310 309
 				$dao_split = str_split($dao);
311
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
312
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
310
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
311
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
313 312
 			    
314 313
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
315 314
 				else $result['latitude'] += $lat_off;
316 315
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
317 316
 				else $result['longitude'] += $lon_off;
318 317
 			    }
319
-		            $body_parse = substr($body_parse,6);
318
+		            $body_parse = substr($body_parse, 6);
320 319
 		    }
321 320
 		    
322
-		    if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
321
+		    if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) {
323 322
 			$result['callsign'] = $matches[1];
324 323
 		    }
325
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
324
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
326 325
 			$result['squawk'] = $matches[1];
327 326
 		    }
328
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
327
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
329 328
 			$result['aircraft_icao'] = $matches[1];
330 329
 		    }
331
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
330
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
332 331
 			$result['typeid'] = $matches[1];
333 332
 		    }
334
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
333
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
335 334
 			$result['imo'] = $matches[1];
336 335
 		    }
337
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
336
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
338 337
 			$result['arrival_date'] = $matches[1];
339 338
 		    }
340
-		    if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
339
+		    if (preg_match('/AC=([0-9A-Z]*)/', $body_parse, $matches)) {
341 340
 			$result['arrival_code'] = $matches[1];
342 341
 		    }
343 342
 		    // OGN comment
344 343
 		   // echo "Before OGN : ".$body_parse."\n";
345 344
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
346
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
345
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
347 346
 			$id = $matches[1];
348 347
 			//$mode = substr($id,0,2);
349
-			$address = substr($id,2);
348
+			$address = substr($id, 2);
350 349
 			//print_r($matches);
351
-			$addressType = (intval(substr($id,0,2),16))&3;
350
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
352 351
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
353 352
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
354 353
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
355 354
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
356
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
355
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
357 356
 			$result['aircrafttype_code'] = $aircraftType;
358 357
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
359 358
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -370,7 +369,7 @@  discard block
 block discarded – undo
370 369
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
371 370
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
372 371
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
373
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
372
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
374 373
 			$result['stealth'] = $stealth;
375 374
 			$result['address'] = $address;
376 375
 		    }
@@ -382,72 +381,72 @@  discard block
 block discarded – undo
382 381
 		    //$body_parse = substr($body_parse,1);
383 382
 		    //$body_parse_len = strlen($body_parse);
384 383
 
385
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
384
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
386 385
 			    $result['wind_dir'] = intval($matches[1]);
387
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
388
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
389
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
390
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
391
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
386
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
387
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
388
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
389
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
390
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
392 391
 			$result['wind_dir'] = intval($matches[1]);
393
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
394
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
395
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
396
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
397
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
392
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
393
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
394
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
395
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
396
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
398 397
 			$result['wind_dir'] = intval($matches[1]);
399
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
400
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
401
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
402
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
398
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
399
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
400
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
401
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
403 402
 			$result['wind_dir'] = intval($matches[1]);
404
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
405
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
406
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
403
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
404
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
405
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
407 406
 		    }
408
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
409
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
407
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
408
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
410 409
 		    }
411 410
 		}
412 411
 		} else $result['comment'] = trim($body_parse);
413 412
 
414 413
 	    }
415 414
 	//}
416
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
417
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
415
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
416
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
418 417
 	if ($debug) print_r($result);
419 418
 	return $result;
420 419
     }
421 420
     
422 421
     function connect() {
423
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
422
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
424 423
 	$aprs_connect = 0;
425 424
 	$aprs_keep = 120;
426 425
 	$aprs_last_tx = time();
427 426
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
428
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
427
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
429 428
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
430
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
429
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
431 430
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
432 431
 	else $aprs_pass = '-1';
433 432
 	
434
-	$aprs_filter  = '';
433
+	$aprs_filter = '';
435 434
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
436 435
 	$Common = new Common();
437
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
436
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
438 437
 	if ($s !== false) {
439 438
 		echo 'Connected to APRS server! '."\n";
440 439
 		$authstart = time();
441 440
 		$this->socket = $s;
442
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
443
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
441
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
442
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
444 443
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
445 444
 			    echo 'APRS user verified !'."\n";
446 445
 			    $this->connected = true;
447 446
 			    return true;
448 447
 			    break;
449 448
 			}
450
-			if (time()-$authstart > 5) {
449
+			if (time() - $authstart > 5) {
451 450
 			    echo 'APRS timeout'."\n";
452 451
 			    break;
453 452
 			}
@@ -457,20 +456,20 @@  discard block
 block discarded – undo
457 456
     
458 457
     function send($data) {
459 458
 	if ($this->connected == false) $this->connect();
460
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
459
+	$send = socket_send($this->socket, $data, strlen($data), 0);
461 460
 	if ($send === FALSE) $this->connect();
462 461
     }
463 462
 }
464 463
 
465 464
 class APRSSpotter extends APRS {
466
-	function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
465
+	function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
467 466
 		$Common = new Common();
468 467
 		if ($latitude != '' && $longitude != '') {
469
-			$latitude = $Common->convertDM($latitude,'latitude');
470
-			$longitude = $Common->convertDM($longitude,'longitude');
471
-			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW'];
472
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
473
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
468
+			$latitude = $Common->convertDM($latitude, 'latitude');
469
+			$longitude = $Common->convertDM($longitude, 'longitude');
470
+			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW'];
471
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
472
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
474 473
 			$w = $w1.$w2;
475 474
 			//$w = '00';
476 475
 			$custom = '';
@@ -487,19 +486,19 @@  discard block
 block discarded – undo
487 486
 				$custom .= 'AI='.$aircraft_icao;
488 487
 			}
489 488
 			if ($custom != '') $custom = ' '.$custom;
490
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
489
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
491 490
 		}
492 491
 	}
493 492
 }
494 493
 class APRSMarine extends APRS {
495
-	function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source,$source_name,$over_country) {
494
+	function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country) {
496 495
 		$Common = new Common();
497 496
 		if ($latitude != '' && $longitude != '') {
498
-			$latitude = $Common->convertDM($latitude,'latitude');
499
-			$longitude = $Common->convertDM($longitude,'longitude');
500
-			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW'];
501
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
502
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
497
+			$latitude = $Common->convertDM($latitude, 'latitude');
498
+			$longitude = $Common->convertDM($longitude, 'longitude');
499
+			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW'];
500
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
501
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
503 502
 			$w = $w1.$w2;
504 503
 			//$w = '00';
505 504
 			$custom = '';
@@ -525,7 +524,7 @@  discard block
 block discarded – undo
525 524
 			}
526 525
 			if ($custom != '') $custom = ' '.$custom;
527 526
 			$altitude = 0;
528
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
527
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
529 528
 		}
530 529
 	}
531 530
 }
Please login to merge, or discard this patch.
Braces   +149 added lines, -57 removed lines patch added patch discarded remove patch
@@ -107,26 +107,36 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
110
+	    if ($globalDebug) {
111
+	    	echo '!!! APRS invalid : '.$input."\n";
112
+	    }
111 113
 	    return false;
112 114
 	}
113 115
 	
114
-	if ($debug) echo 'input : '.$input."\n";
116
+	if ($debug) {
117
+		echo 'input : '.$input."\n";
118
+	}
115 119
 	/* Save header and body. */
116 120
 	$body = substr($input,$splitpos+1,$input_len);
117 121
 	$body_len = strlen($body);
118 122
 	$header = substr($input,0,$splitpos);
119 123
 	//$header_len = strlen($header);
120
-	if ($debug) echo 'header : '.$header."\n";
124
+	if ($debug) {
125
+		echo 'header : '.$header."\n";
126
+	}
121 127
 	
122 128
 	/* Parse source, target and path. */
123 129
 	//FLRDF0A52>APRS,qAS,LSTB
124 130
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
125 131
 	    $ident = $matches[1];
126 132
 	    $all_elements = $matches[2];
127
-	    if ($debug) echo 'ident : '.$ident."\n";
133
+	    if ($debug) {
134
+	    	echo 'ident : '.$ident."\n";
135
+	    }
128 136
 	    $result['ident'] = $ident;
129
-	} else return false;
137
+	} else {
138
+		return false;
139
+	}
130 140
 	$elements = explode(',',$all_elements);
131 141
 	$source = end($elements);
132 142
 	$result['source'] = $source;
@@ -135,7 +145,9 @@  discard block
 block discarded – undo
135 145
 	        //echo "ok";
136 146
 	        //if ($element == 'TCPIP*') return false;
137 147
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
138
-		if ($debug) echo 'element : '.$element."\n";
148
+		if ($debug) {
149
+			echo 'element : '.$element."\n";
150
+		}
139 151
 		return false;
140 152
 	    }
141 153
 	    /*
@@ -148,7 +160,9 @@  discard block
 block discarded – undo
148 160
 	}
149 161
 	
150 162
 	$type = substr($body,0,1);
151
-	if ($debug) echo 'type : '.$type."\n";
163
+	if ($debug) {
164
+		echo 'type : '.$type."\n";
165
+	}
152 166
 	if ($type == ';') {
153 167
 		$result['ident'] = trim(substr($body,1,9));
154 168
 	} elseif ($type == ',') {
@@ -218,7 +232,9 @@  discard block
 block discarded – undo
218 232
 		//$symbol_table = $matches[4];
219 233
 		$lat = intval($lat_deg);
220 234
 		$lon = intval($lon_deg);
221
-		if ($lat > 89 || $lon > 179) return false;
235
+		if ($lat > 89 || $lon > 179) {
236
+			return false;
237
+		}
222 238
 	    
223 239
 	    /*
224 240
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -228,8 +244,12 @@  discard block
 block discarded – undo
228 244
 	    */
229 245
 		$latitude = $lat + floatval($lat_min)/60;
230 246
 		$longitude = $lon + floatval($lon_min)/60;
231
-		if ($sind == 'S') $latitude = 0-$latitude;
232
-		if ($wind == 'W') $longitude = 0-$longitude;
247
+		if ($sind == 'S') {
248
+			$latitude = 0-$latitude;
249
+		}
250
+		if ($wind == 'W') {
251
+			$longitude = 0-$longitude;
252
+		}
233 253
 		$result['latitude'] = $latitude;
234 254
 		$result['longitude'] = $longitude;
235 255
 		$body_parse = substr($body_parse,18);
@@ -262,7 +282,9 @@  discard block
 block discarded – undo
262 282
 			$body_parse = substr($body_parse,1);
263 283
 			$body_parse_len = strlen($body_parse);
264 284
 			$result['symbol_code'] = $symbol_code;
265
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
285
+			if (isset($this->symbols[$symbol_code])) {
286
+				$result['symbol'] = $this->symbols[$symbol_code];
287
+			}
266 288
 			if ($symbol_code != '_') {
267 289
 			}
268 290
 		    //$body_parse = substr($body_parse,1);
@@ -273,7 +295,9 @@  discard block
 block discarded – undo
273 295
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
274 296
 		    	    $course = substr($body_parse,0,3);
275 297
 		    	    $tmp_s = intval($course);
276
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
298
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
299
+		    	    	$result['heading'] = intval($course);
300
+		    	    }
277 301
 		    	    $speed = substr($body_parse,4,3);
278 302
 		    	    if ($speed != '...') {
279 303
 		    		    $result['speed'] = round($speed*1.852);
@@ -311,10 +335,16 @@  discard block
 block discarded – undo
311 335
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
312 336
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
313 337
 			    
314
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
315
-				else $result['latitude'] += $lat_off;
316
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
317
-				else $result['longitude'] += $lon_off;
338
+				if ($result['latitude'] < 0) {
339
+					$result['latitude'] -= $lat_off;
340
+				} else {
341
+					$result['latitude'] += $lat_off;
342
+				}
343
+				if ($result['longitude'] < 0) {
344
+					$result['longitude'] -= $lon_off;
345
+				} else {
346
+					$result['longitude'] += $lon_off;
347
+				}
318 348
 			    }
319 349
 		            $body_parse = substr($body_parse,6);
320 350
 		    }
@@ -349,27 +379,48 @@  discard block
 block discarded – undo
349 379
 			$address = substr($id,2);
350 380
 			//print_r($matches);
351 381
 			$addressType = (intval(substr($id,0,2),16))&3;
352
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
353
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
354
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
355
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
382
+			if ($addressType == 0) {
383
+				$result['addresstype'] = "RANDOM";
384
+			} elseif ($addressType == 1) {
385
+				$result['addresstype'] = "ICAO";
386
+			} elseif ($addressType == 2) {
387
+				$result['addresstype'] = "FLARM";
388
+			} elseif ($addressType == 3) {
389
+				$result['addresstype'] = "OGN";
390
+			}
356 391
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
357 392
 			$result['aircrafttype_code'] = $aircraftType;
358
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
359
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
360
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
361
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
362
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
363
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
364
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
365
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
366
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
367
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
368
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
369
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
370
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
371
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
372
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
393
+			if ($aircraftType == 0) {
394
+				$result['aircrafttype'] = "UNKNOWN";
395
+			} elseif ($aircraftType == 1) {
396
+				$result['aircrafttype'] = "GLIDER";
397
+			} elseif ($aircraftType == 2) {
398
+				$result['aircrafttype'] = "TOW_PLANE";
399
+			} elseif ($aircraftType == 3) {
400
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
401
+			} elseif ($aircraftType == 4) {
402
+				$result['aircrafttype'] = "PARACHUTE";
403
+			} elseif ($aircraftType == 5) {
404
+				$result['aircrafttype'] = "DROP_PLANE";
405
+			} elseif ($aircraftType == 6) {
406
+				$result['aircrafttype'] = "HANG_GLIDER";
407
+			} elseif ($aircraftType == 7) {
408
+				$result['aircrafttype'] = "PARA_GLIDER";
409
+			} elseif ($aircraftType == 8) {
410
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
411
+			} elseif ($aircraftType == 9) {
412
+				$result['aircrafttype'] = "JET_AIRCRAFT";
413
+			} elseif ($aircraftType == 10) {
414
+				$result['aircrafttype'] = "UFO";
415
+			} elseif ($aircraftType == 11) {
416
+				$result['aircrafttype'] = "BALLOON";
417
+			} elseif ($aircraftType == 12) {
418
+				$result['aircrafttype'] = "AIRSHIP";
419
+			} elseif ($aircraftType == 13) {
420
+				$result['aircrafttype'] = "UAV";
421
+			} elseif ($aircraftType == 15) {
422
+				$result['aircrafttype'] = "STATIC_OBJECT";
423
+			}
373 424
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
374 425
 			$result['stealth'] = $stealth;
375 426
 			$result['address'] = $address;
@@ -409,13 +460,21 @@  discard block
 block discarded – undo
409 460
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
410 461
 		    }
411 462
 		}
412
-		} else $result['comment'] = trim($body_parse);
463
+		} else {
464
+			$result['comment'] = trim($body_parse);
465
+		}
413 466
 
414 467
 	    }
415 468
 	//}
416
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
417
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
418
-	if ($debug) print_r($result);
469
+	if (isset($result['latitude'])) {
470
+		$result['latitude'] = round($result['latitude'],4);
471
+	}
472
+	if (isset($result['longitude'])) {
473
+		$result['longitude'] = round($result['longitude'],4);
474
+	}
475
+	if ($debug) {
476
+		print_r($result);
477
+	}
419 478
 	return $result;
420 479
     }
421 480
     
@@ -424,12 +483,21 @@  discard block
 block discarded – undo
424 483
 	$aprs_connect = 0;
425 484
 	$aprs_keep = 120;
426 485
 	$aprs_last_tx = time();
427
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
428
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
429
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
430
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
431
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
432
-	else $aprs_pass = '-1';
486
+	if (isset($globalAPRSversion)) {
487
+		$aprs_version = $globalAPRSversion;
488
+	} else {
489
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
490
+	}
491
+	if (isset($globalServerAPRSssid)) {
492
+		$aprs_ssid = $globalServerAPRSssid;
493
+	} else {
494
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
495
+	}
496
+	if (isset($globalServerAPRSpass)) {
497
+		$aprs_pass = $globalServerAPRSpass;
498
+	} else {
499
+		$aprs_pass = '-1';
500
+	}
433 501
 	
434 502
 	$aprs_filter  = '';
435 503
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -456,9 +524,13 @@  discard block
 block discarded – undo
456 524
     }
457 525
     
458 526
     function send($data) {
459
-	if ($this->connected == false) $this->connect();
527
+	if ($this->connected == false) {
528
+		$this->connect();
529
+	}
460 530
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
461
-	if ($send === FALSE) $this->connect();
531
+	if ($send === FALSE) {
532
+		$this->connect();
533
+	}
462 534
     }
463 535
 }
464 536
 
@@ -475,18 +547,26 @@  discard block
 block discarded – undo
475 547
 			//$w = '00';
476 548
 			$custom = '';
477 549
 			if ($ident != '') {
478
-				if ($custom != '') $custom .= '/';
550
+				if ($custom != '') {
551
+					$custom .= '/';
552
+				}
479 553
 				$custom .= 'CS='.$ident;
480 554
 			}
481 555
 			if ($squawk != '') {
482
-				if ($custom != '') $custom .= '/';
556
+				if ($custom != '') {
557
+					$custom .= '/';
558
+				}
483 559
 				$custom .= 'SQ='.$squawk;
484 560
 			}
485 561
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
486
-				if ($custom != '') $custom .= '/';
562
+				if ($custom != '') {
563
+					$custom .= '/';
564
+				}
487 565
 				$custom .= 'AI='.$aircraft_icao;
488 566
 			}
489
-			if ($custom != '') $custom = ' '.$custom;
567
+			if ($custom != '') {
568
+				$custom = ' '.$custom;
569
+			}
490 570
 			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
491 571
 		}
492 572
 	}
@@ -504,26 +584,38 @@  discard block
 block discarded – undo
504 584
 			//$w = '00';
505 585
 			$custom = '';
506 586
 			if ($ident != '') {
507
-				if ($custom != '') $custom .= '/';
587
+				if ($custom != '') {
588
+					$custom .= '/';
589
+				}
508 590
 				$custom .= 'CS='.$ident;
509 591
 			}
510 592
 			if ($typeid != '') {
511
-				if ($custom != '') $custom .= '/';
593
+				if ($custom != '') {
594
+					$custom .= '/';
595
+				}
512 596
 				$custom .= 'TI='.$typeid;
513 597
 			}
514 598
 			if ($imo != '') {
515
-				if ($custom != '') $custom .= '/';
599
+				if ($custom != '') {
600
+					$custom .= '/';
601
+				}
516 602
 				$custom .= 'IMO='.$imo;
517 603
 			}
518 604
 			if ($arrival_date != '') {
519
-				if ($custom != '') $custom .= '/';
605
+				if ($custom != '') {
606
+					$custom .= '/';
607
+				}
520 608
 				$custom .= 'AD='.strtotime($arrival_date);
521 609
 			}
522 610
 			if ($arrival_code != '') {
523
-				if ($custom != '') $custom .= '/';
611
+				if ($custom != '') {
612
+					$custom .= '/';
613
+				}
524 614
 				$custom .= 'AC='.$arrival_code;
525 615
 			}
526
-			if ($custom != '') $custom = ' '.$custom;
616
+			if ($custom != '') {
617
+				$custom = ' '.$custom;
618
+			}
527 619
 			$altitude = 0;
528 620
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
529 621
 		}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 3 patches
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 
12 12
 class SpotterImport {
13
-    private $all_flights = array();
14
-    private $last_delete_hourly = 0;
15
-    private $last_delete = 0;
16
-    private $stats = array();
17
-    private $tmd = 0;
18
-    private $source_location = array();
19
-    public $db = null;
20
-    public $nb = 0;
21
-
22
-    public function __construct($dbc = null) {
13
+	private $all_flights = array();
14
+	private $last_delete_hourly = 0;
15
+	private $last_delete = 0;
16
+	private $stats = array();
17
+	private $tmd = 0;
18
+	private $source_location = array();
19
+	public $db = null;
20
+	public $nb = 0;
21
+
22
+	public function __construct($dbc = null) {
23 23
 	global $globalBeta, $globalServerAPRS, $APRSSpotter;
24 24
 	$Connection = new Connection($dbc);
25 25
 	$this->db = $Connection->db();
@@ -30,23 +30,23 @@  discard block
 block discarded – undo
30 30
 	$currentdate = date('Y-m-d');
31 31
 	$sourcestat = $Stats->getStatsSource($currentdate);
32 32
 	if (!empty($sourcestat)) {
33
-	    foreach($sourcestat as $srcst) {
34
-	    	$type = $srcst['stats_type'];
33
+		foreach($sourcestat as $srcst) {
34
+			$type = $srcst['stats_type'];
35 35
 		if ($type == 'polar' || $type == 'hist') {
36
-		    $source = $srcst['source_name'];
37
-		    $data = $srcst['source_data'];
38
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
39
-	        }
40
-	    }
36
+			$source = $srcst['source_name'];
37
+			$data = $srcst['source_data'];
38
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
39
+			}
40
+		}
41 41
 	}
42 42
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
43 43
 		$APRSSpotter = new APRSSpotter();
44 44
 		//$APRSSpotter->connect();
45 45
 	}
46 46
 
47
-    }
47
+	}
48 48
 
49
-    public function get_Schedule($id,$ident) {
49
+	public function get_Schedule($id,$ident) {
50 50
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
51 51
 	// Get schedule here, so it's done only one time
52 52
 	
@@ -66,42 +66,42 @@  discard block
 block discarded – undo
66 66
 	$operator = $Spotter->getOperator($ident);
67 67
 	$scheduleexist = false;
68 68
 	if ($Schedule->checkSchedule($operator) == 0) {
69
-	    $operator = $Translation->checkTranslation($ident);
70
-	    if ($Schedule->checkSchedule($operator) == 0) {
69
+		$operator = $Translation->checkTranslation($ident);
70
+		if ($Schedule->checkSchedule($operator) == 0) {
71 71
 		$schedule = $Schedule->fetchSchedule($operator);
72 72
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
73
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
74
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
75
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
76
-		    // Should also check if route schedule = route from DB
77
-		    if ($schedule['DepartureAirportIATA'] != '') {
73
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
74
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
75
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
76
+			// Should also check if route schedule = route from DB
77
+			if ($schedule['DepartureAirportIATA'] != '') {
78 78
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
79
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
80
-			    if (trim($airport_icao) != '') {
79
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
80
+				if (trim($airport_icao) != '') {
81 81
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
82 82
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
83
-			    }
83
+				}
84
+			}
84 85
 			}
85
-		    }
86
-		    if ($schedule['ArrivalAirportIATA'] != '') {
86
+			if ($schedule['ArrivalAirportIATA'] != '') {
87 87
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
88
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
89
-			    if (trim($airport_icao) != '') {
88
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
89
+				if (trim($airport_icao) != '') {
90 90
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
91 91
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
92
-			    }
92
+				}
93
+			}
93 94
 			}
94
-		    }
95
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
95
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
96 96
 		}
97
-	    } else $scheduleexist = true;
97
+		} else $scheduleexist = true;
98 98
 	} else $scheduleexist = true;
99 99
 	// close connection, at least one way will work ?
100
-       if ($scheduleexist) {
100
+	   if ($scheduleexist) {
101 101
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
102
-    		$sch = $Schedule->getSchedule($operator);
102
+			$sch = $Schedule->getSchedule($operator);
103 103
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
104
-       }
104
+	   }
105 105
 	$Spotter->db = null;
106 106
 	$Schedule->db = null;
107 107
 	$Translation->db = null;
@@ -116,96 +116,96 @@  discard block
 block discarded – undo
116 116
 	}
117 117
 	  */
118 118
 	}
119
-    }
119
+	}
120 120
 
121
-    public function checkAll() {
121
+	public function checkAll() {
122 122
 	global $globalDebug, $globalNoImport;
123 123
 	if ($globalDebug) echo "Update last seen flights data...\n";
124 124
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
125
-	    foreach ($this->all_flights as $key => $flight) {
125
+		foreach ($this->all_flights as $key => $flight) {
126 126
 		if (isset($this->all_flights[$key]['id'])) {
127
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
128
-    		    $Spotter = new Spotter($this->db);
129
-        	    $real_arrival = $this->arrival($key);
130
-        	    $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
131
-        	}
132
-	    }
127
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
128
+				$Spotter = new Spotter($this->db);
129
+				$real_arrival = $this->arrival($key);
130
+				$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
131
+			}
132
+		}
133
+	}
133 134
 	}
134
-    }
135 135
 
136
-    public function arrival($key) {
136
+	public function arrival($key) {
137 137
 	global $globalClosestMinDist, $globalDebug;
138 138
 	if ($globalDebug) echo 'Update arrival...'."\n";
139 139
 	$Spotter = new Spotter($this->db);
140
-        $airport_icao = '';
141
-        $airport_time = '';
142
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
140
+		$airport_icao = '';
141
+		$airport_time = '';
142
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
143 143
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
144
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
145
-    	    if (isset($closestAirports[0])) {
146
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
147
-        	    $airport_icao = $closestAirports[0]['icao'];
148
-        	    $airport_time = $this->all_flights[$key]['datetime'];
149
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
150
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
151
-        	    foreach ($closestAirports as $airport) {
152
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
153
-        		    $airport_icao = $airport['icao'];
154
-        		    $airport_time = $this->all_flights[$key]['datetime'];
155
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
156
-        		    break;
157
-        		}
158
-        	    }
159
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
160
-        		$airport_icao = $closestAirports[0]['icao'];
161
-        		$airport_time = $this->all_flights[$key]['datetime'];
162
-        	} else {
163
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
164
-        	}
165
-    	    } else {
166
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
167
-    	    }
168
-
169
-        } else {
170
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
171
-        }
172
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
173
-    }
174
-
175
-
176
-
177
-    public function del() {
144
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
145
+			if (isset($closestAirports[0])) {
146
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
147
+				$airport_icao = $closestAirports[0]['icao'];
148
+				$airport_time = $this->all_flights[$key]['datetime'];
149
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
150
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
151
+				foreach ($closestAirports as $airport) {
152
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
153
+					$airport_icao = $airport['icao'];
154
+					$airport_time = $this->all_flights[$key]['datetime'];
155
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
156
+					break;
157
+				}
158
+				}
159
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
160
+				$airport_icao = $closestAirports[0]['icao'];
161
+				$airport_time = $this->all_flights[$key]['datetime'];
162
+			} else {
163
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
164
+			}
165
+			} else {
166
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
167
+			}
168
+
169
+		} else {
170
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
171
+		}
172
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
173
+	}
174
+
175
+
176
+
177
+	public function del() {
178 178
 	global $globalDebug, $globalNoImport;
179 179
 	// Delete old infos
180 180
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
181 181
 	foreach ($this->all_flights as $key => $flight) {
182
-    	    if (isset($flight['lastupdate'])) {
183
-        	if ($flight['lastupdate'] < (time()-3000)) {
184
-            	    if (isset($this->all_flights[$key]['id'])) {
185
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
182
+			if (isset($flight['lastupdate'])) {
183
+			if ($flight['lastupdate'] < (time()-3000)) {
184
+					if (isset($this->all_flights[$key]['id'])) {
185
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
186 186
 			/*
187 187
 			$SpotterLive = new SpotterLive();
188 188
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
189 189
 			$SpotterLive->db = null;
190 190
 			*/
191 191
 			if (!isset($globalNoImport) || $globalNoImport === FALSE) {
192
-            		    $real_arrival = $this->arrival($key);
193
-            		    $Spotter = new Spotter($this->db);
194
-            	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
192
+						$real_arrival = $this->arrival($key);
193
+						$Spotter = new Spotter($this->db);
194
+							if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
195 195
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
196 196
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
197
-			    }
197
+				}
198 198
 			// Put in archive
199 199
 //				$Spotter->db = null;
200 200
 			}
201
-            	    }
202
-            	    unset($this->all_flights[$key]);
203
-    	        }
204
-	    }
205
-        }
206
-    }
201
+					}
202
+					unset($this->all_flights[$key]);
203
+				}
204
+		}
205
+		}
206
+	}
207 207
 
208
-    public function add($line) {
208
+	public function add($line) {
209 209
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport;
210 210
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
211 211
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 	
231 231
 	// SBS format is CSV format
232 232
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
233
-	    //print_r($line);
234
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
233
+		//print_r($line);
234
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
235 235
 
236 236
 		// Increment message number
237 237
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
238
-		    $current_date = date('Y-m-d');
239
-		    $source = $line['source_name'];
240
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
241
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
242
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
243
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
244
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
238
+			$current_date = date('Y-m-d');
239
+			$source = $line['source_name'];
240
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
241
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
242
+				$this->stats[$current_date][$source]['msg']['date'] = time();
243
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
244
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
245 245
 		}
246 246
 		
247 247
 		/*
@@ -257,34 +257,34 @@  discard block
 block discarded – undo
257 257
 		//$this->db = $dbc;
258 258
 
259 259
 		//$hex = trim($line['hex']);
260
-	        if (!isset($line['id'])) $id = trim($line['hex']);
261
-	        else $id = trim($line['id']);
260
+			if (!isset($line['id'])) $id = trim($line['hex']);
261
+			else $id = trim($line['id']);
262 262
 		
263 263
 		if (!isset($this->all_flights[$id])) {
264
-		    $this->all_flights[$id] = array();
265
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
266
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
267
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
268
-		    if (!isset($line['id'])) {
264
+			$this->all_flights[$id] = array();
265
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
266
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
267
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
268
+			if (!isset($line['id'])) {
269 269
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
270 270
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
271 271
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
272 272
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
273
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
274
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
275
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
273
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
274
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
275
+			if ($globalAllFlights !== FALSE) $dataFound = true;
276 276
 		}
277 277
 		if (isset($line['source_type']) && $line['source_type'] != '') {
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
278
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
279 279
 		}
280 280
 		
281 281
 		//print_r($this->all_flights);
282 282
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
284
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
283
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
284
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
285 285
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
286
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
287
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
286
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
287
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
288 288
 			$timeelapsed = microtime(true);
289 289
 			$Spotter = new Spotter($this->db);
290 290
 			if (isset($this->all_flights[$id]['source_type'])) {
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 			$Spotter->db = null;
296 296
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
297 297
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
298
-		    }
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
300
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
298
+			}
299
+			if ($globalAllFlights !== FALSE) $dataFound = true;
300
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
301 301
 		}
302 302
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
303 303
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 		}
322 322
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
323 323
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
324
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
324
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
325 325
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
326
-		    } else {
326
+			} else {
327 327
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
328 328
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
329 329
 				/*
@@ -332,41 +332,41 @@  discard block
 block discarded – undo
332 332
 				print_r($line);
333 333
 				*/
334 334
 				return '';
335
-		    }
335
+			}
336 336
 		} else {
337 337
 			date_default_timezone_set('UTC');
338 338
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
339 339
 		}
340 340
 
341 341
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
342
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
342
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
343 343
 		}
344 344
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
345
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
345
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
346 346
 		}
347 347
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
348
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
348
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
349 349
 		}
350 350
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
351
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
351
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
352 352
 		}
353 353
  
354 354
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
355
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
356
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
355
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
356
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
357 357
 			$timeelapsed = microtime(true);
358
-            		$Spotter = new Spotter($this->db);
359
-            		$fromsource = NULL;
360
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
361
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
358
+					$Spotter = new Spotter($this->db);
359
+					$fromsource = NULL;
360
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
361
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
362 362
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
363 363
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
364 364
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
365
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
365
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
366 366
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
367 367
 			$Spotter->db = null;
368 368
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
-		    }
369
+			}
370 370
 
371 371
 /*
372 372
 		    if (!isset($line['id'])) {
@@ -376,26 +376,26 @@  discard block
 block discarded – undo
376 376
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
377 377
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
378 378
   */
379
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
379
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
380 380
 
381
-		    //$putinarchive = true;
382
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
381
+			//$putinarchive = true;
382
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
383 383
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
384
-		    }
385
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
384
+			}
385
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
386 386
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
387
-		    }
388
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
389
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
390
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
387
+			}
388
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
389
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
390
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
391 391
 				$timeelapsed = microtime(true);
392 392
 				$Spotter = new Spotter($this->db);
393 393
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
394 394
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
395
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
395
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
396 396
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
397 397
 
398
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
398
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
399 399
 			$timeelapsed = microtime(true);
400 400
 			$Spotter = new Spotter($this->db);
401 401
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -409,43 +409,43 @@  discard block
 block discarded – undo
409 409
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
410 410
 
411 411
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
412
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
413
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
412
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
413
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
414 414
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
415
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
416
-		    	    }
415
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
416
+					}
417 417
 			}
418 418
 			if (!isset($globalFork)) $globalFork = TRUE;
419 419
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
420 420
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
421 421
 			}
422
-		    }
422
+			}
423 423
 		}
424 424
 
425 425
 		if (isset($line['speed']) && $line['speed'] != '') {
426 426
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
427
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
428
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
429
-		    //$dataFound = true;
427
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
428
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
429
+			//$dataFound = true;
430 430
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
431
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
432
-		    if ($distance > 1000 && $distance < 10000) {
433
-		    // use datetime
431
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
432
+			if ($distance > 1000 && $distance < 10000) {
433
+			// use datetime
434 434
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
435 435
 			$speed = $speed*3.6;
436 436
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
437 437
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
438
-		    }
438
+			}
439 439
 		}
440 440
 
441 441
 
442 442
 
443
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
444
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
445
-	    	    else unset($timediff);
446
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
443
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
444
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
445
+				else unset($timediff);
446
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
447 447
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
448
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
448
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
449 449
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
450 450
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
451 451
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
460 460
 				$this->tmd = 0;
461 461
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
462
-			    }
462
+				}
463 463
 			}
464 464
 
465 465
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
466
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
466
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
467 467
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
468 468
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
469
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
470
-				    $dataFound = true;
471
-				    $this->all_flights[$id]['time_last_coord'] = time();
469
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
470
+					$dataFound = true;
471
+					$this->all_flights[$id]['time_last_coord'] = time();
472 472
 				}
473 473
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
474 474
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -479,20 +479,20 @@  discard block
 block discarded – undo
479 479
 				    //$putinarchive = true;
480 480
 				}
481 481
 				*/
482
-			    /*
482
+				/*
483 483
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
484 484
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
485 485
 			    }
486 486
 			    */
487 487
 			}
488 488
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
489
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
490
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
489
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
490
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
491 491
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
492 492
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
493
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
494
-				    $dataFound = true;
495
-				    $this->all_flights[$id]['time_last_coord'] = time();
493
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
494
+					$dataFound = true;
495
+					$this->all_flights[$id]['time_last_coord'] = time();
496 496
 				}
497 497
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
498 498
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -510,54 +510,54 @@  discard block
 block discarded – undo
510 510
 			    */
511 511
 			}
512 512
 
513
-		    } else if ($globalDebug && $timediff > 20) {
513
+			} else if ($globalDebug && $timediff > 20) {
514 514
 			$this->tmd = $this->tmd + 1;
515 515
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
516 516
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
517 517
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
518 518
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
519
-		    }
519
+			}
520 520
 		}
521 521
 		if (isset($line['last_update']) && $line['last_update'] != '') {
522
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
523
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
522
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
523
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
524 524
 		}
525 525
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
526
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
527
-		    //$dataFound = true;
526
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
527
+			//$dataFound = true;
528 528
 		}
529 529
 		if (isset($line['format_source']) && $line['format_source'] != '') {
530
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
530
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
531 531
 		}
532 532
 		if (isset($line['source_name']) && $line['source_name'] != '') {
533
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
533
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
534 534
 		}
535 535
 		if (isset($line['emergency']) && $line['emergency'] != '') {
536
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
537
-		    //$dataFound = true;
536
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
537
+			//$dataFound = true;
538 538
 		}
539 539
 		if (isset($line['ground']) && $line['ground'] != '') {
540
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
540
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
541 541
 			// Here we force archive of flight because after ground it's a new one (or should be)
542 542
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
543 543
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
544 544
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
545
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
545
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
546 546
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
547
-		    }
548
-		    if ($line['ground'] != 1) $line['ground'] = 0;
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
550
-		    //$dataFound = true;
547
+			}
548
+			if ($line['ground'] != 1) $line['ground'] = 0;
549
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
550
+			//$dataFound = true;
551 551
 		}
552 552
 		if (isset($line['squawk']) && $line['squawk'] != '') {
553
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
554
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
555
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
556
-			    $highlight = '';
557
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
558
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
559
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
560
-			    if ($highlight != '') {
553
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
554
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
555
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
556
+				$highlight = '';
557
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
558
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
559
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
560
+				if ($highlight != '') {
561 561
 				$timeelapsed = microtime(true);
562 562
 				$Spotter = new Spotter($this->db);
563 563
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -566,38 +566,38 @@  discard block
 block discarded – undo
566 566
 
567 567
 				//$putinarchive = true;
568 568
 				//$highlight = '';
569
-			    }
569
+				}
570 570
 			    
571
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
572
-		    //$dataFound = true;
571
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
572
+			//$dataFound = true;
573 573
 		}
574 574
 
575 575
 		if (isset($line['altitude']) && $line['altitude'] != '') {
576
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
576
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
577 577
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
578 578
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
579 579
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
580 580
 			//$dataFound = true;
581
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
581
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
582 582
   		}
583 583
 
584 584
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
585
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
585
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
586 586
 		}
587 587
 		
588 588
 		if (isset($line['heading']) && $line['heading'] != '') {
589
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
590
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
591
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
592
-		    //$dataFound = true;
589
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
590
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
591
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
592
+			//$dataFound = true;
593 593
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
594
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
595
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
596
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
597
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
594
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
595
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
596
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
597
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
598 598
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
599
-  		    // If not enough messages and ACARS set heading to 0
600
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
599
+  			// If not enough messages and ACARS set heading to 0
600
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
601 601
   		}
602 602
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
603 603
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -608,121 +608,121 @@  discard block
 block discarded – undo
608 608
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
609 609
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
610 610
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
611
-		    $this->all_flights[$id]['lastupdate'] = time();
612
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
613
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
614
-			    //print_r($this->all_flights);
615
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
616
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
617
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
611
+			$this->all_flights[$id]['lastupdate'] = time();
612
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
613
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
614
+				//print_r($this->all_flights);
615
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
616
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
617
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
618 618
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
619 619
 				$timeelapsed = microtime(true);
620 620
 				$SpotterLive = new SpotterLive($this->db);
621 621
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
622
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
623
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
622
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
623
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
624 624
 				} elseif (isset($line['id'])) {
625
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
626
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
625
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
626
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
627 627
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
628
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
629
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
628
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
629
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
630 630
 				} else $recent_ident = '';
631 631
 				$SpotterLive->db=null;
632 632
 
633 633
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
634 634
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
635
-			    } else {
635
+				} else {
636 636
 				$recent_ident = '';
637 637
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
638
-			    }
639
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
640
-			    if($recent_ident == "")
641
-			    {
638
+				}
639
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
640
+				if($recent_ident == "")
641
+				{
642 642
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
643 643
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
644 644
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
645 645
 				//adds the spotter data for the archive
646 646
 				$ignoreImport = false;
647 647
 				foreach($globalAirportIgnore as $airportIgnore) {
648
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
648
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
649 649
 					$ignoreImport = true;
650
-				    }
650
+					}
651 651
 				}
652 652
 				if (count($globalAirportAccept) > 0) {
653
-				    $ignoreImport = true;
654
-				    foreach($globalAirportIgnore as $airportIgnore) {
653
+					$ignoreImport = true;
654
+					foreach($globalAirportIgnore as $airportIgnore) {
655 655
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
656
-					    $ignoreImport = false;
656
+						$ignoreImport = false;
657
+					}
657 658
 					}
658
-				    }
659 659
 				}
660 660
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
661
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
661
+					foreach($globalAirlineIgnore as $airlineIgnore) {
662 662
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
663
-					    $ignoreImport = true;
663
+						$ignoreImport = true;
664
+					}
664 665
 					}
665
-				    }
666 666
 				}
667 667
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
668
-				    $ignoreImport = true;
669
-				    foreach($globalAirlineAccept as $airlineAccept) {
668
+					$ignoreImport = true;
669
+					foreach($globalAirlineAccept as $airlineAccept) {
670 670
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
671
-					    $ignoreImport = false;
671
+						$ignoreImport = false;
672
+					}
672 673
 					}
673
-				    }
674 674
 				}
675 675
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
676
-				    $ignoreImport = true;
677
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
676
+					$ignoreImport = true;
677
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
678 678
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
679
-					    $ignoreImport = false;
679
+						$ignoreImport = false;
680
+					}
680 681
 					}
681
-				    }
682 682
 				}
683 683
 				
684 684
 				if (!$ignoreImport) {
685
-				    $highlight = '';
686
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
687
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
688
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
689
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
690
-				    $timeelapsed = microtime(true);
691
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
685
+					$highlight = '';
686
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
687
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
688
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
689
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
690
+					$timeelapsed = microtime(true);
691
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
692 692
 					$Spotter = new Spotter($this->db);
693 693
 					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
694 694
 					$Spotter->db = null;
695 695
 					if ($globalDebug && isset($result)) echo $result."\n";
696
-				    }
697
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
696
+					}
697
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
698 698
 				    
699
-				    // Add source stat in DB
700
-				    $Stats = new Stats($this->db);
701
-				    if (!empty($this->stats)) {
699
+					// Add source stat in DB
700
+					$Stats = new Stats($this->db);
701
+					if (!empty($this->stats)) {
702 702
 					if ($globalDebug) echo 'Add source stats : ';
703
-				        foreach($this->stats as $date => $data) {
704
-					    foreach($data as $source => $sourced) {
705
-					        //print_r($sourced);
706
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
707
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
708
-				    		if (isset($sourced['msg'])) {
709
-				    		    if (time() - $sourced['msg']['date'] > 10) {
710
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
711
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
712
-			    			        unset($this->stats[$date][$source]['msg']);
713
-			    			    }
714
-			    			}
715
-			    		    }
716
-			    		    if ($date != date('Y-m-d')) {
717
-			    			unset($this->stats[$date]);
718
-			    		    }
719
-				    	}
720
-				    	if ($globalDebug) echo 'Done'."\n";
721
-
722
-				    }
723
-				    $Stats->db = null;
703
+						foreach($this->stats as $date => $data) {
704
+						foreach($data as $source => $sourced) {
705
+							//print_r($sourced);
706
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
707
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
708
+							if (isset($sourced['msg'])) {
709
+								if (time() - $sourced['msg']['date'] > 10) {
710
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
711
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
712
+									unset($this->stats[$date][$source]['msg']);
713
+								}
714
+							}
715
+							}
716
+							if ($date != date('Y-m-d')) {
717
+							unset($this->stats[$date]);
718
+							}
719
+						}
720
+						if ($globalDebug) echo 'Done'."\n";
721
+
722
+					}
723
+					$Stats->db = null;
724 724
 				    
725
-				    $this->del();
725
+					$this->del();
726 726
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
727 727
 				//$ignoreImport = false;
728 728
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -740,37 +740,37 @@  discard block
 block discarded – undo
740 740
 			*/
741 741
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
742 742
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
743
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
744
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
745
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
743
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
744
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
745
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
746 746
 					$SpotterLive = new SpotterLive($this->db);
747 747
 					$SpotterLive->deleteLiveSpotterData();
748 748
 					$SpotterLive->db=null;
749
-				    }
750
-				    if ($globalDebug) echo " Done\n";
751
-				    $this->last_delete = time();
749
+					}
750
+					if ($globalDebug) echo " Done\n";
751
+					$this->last_delete = time();
752 752
 				}
753
-			    } else {
753
+				} else {
754 754
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
755
-				    $this->all_flights[$id]['id'] = $recent_ident;
756
-				    $this->all_flights[$id]['addedSpotter'] = 1;
755
+					$this->all_flights[$id]['id'] = $recent_ident;
756
+					$this->all_flights[$id]['addedSpotter'] = 1;
757 757
 				}
758 758
 				if (isset($globalDaemon) && !$globalDaemon) {
759
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
759
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
760 760
 					$Spotter = new Spotter($this->db);
761 761
 					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
762 762
 					$Spotter->db = null;
763
-				    }
763
+					}
764 764
 				}
765 765
 				
766
-			    }
766
+				}
767
+			}
767 768
 			}
768
-		    }
769
-		    //adds the spotter LIVE data
770
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
771
-		    //echo "\nAdd in Live !! \n";
772
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
773
-		    if ($globalDebug) {
769
+			//adds the spotter LIVE data
770
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
771
+			//echo "\nAdd in Live !! \n";
772
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
773
+			if ($globalDebug) {
774 774
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
775 775
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
776 776
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -778,49 +778,49 @@  discard block
 block discarded – undo
778 778
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
779 779
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
780 780
 			}
781
-		    }
782
-		    $ignoreImport = false;
783
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
784
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
781
+			}
782
+			$ignoreImport = false;
783
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
784
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
785 785
 
786
-		    foreach($globalAirportIgnore as $airportIgnore) {
787
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788
-			    $ignoreImport = true;
786
+			foreach($globalAirportIgnore as $airportIgnore) {
787
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788
+				$ignoreImport = true;
789
+			}
789 790
 			}
790
-		    }
791
-		    if (count($globalAirportAccept) > 0) {
792
-		        $ignoreImport = true;
793
-		        foreach($globalAirportIgnore as $airportIgnore) {
794
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
791
+			if (count($globalAirportAccept) > 0) {
792
+				$ignoreImport = true;
793
+				foreach($globalAirportIgnore as $airportIgnore) {
794
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
795 795
 				$ignoreImport = false;
796
-			    }
796
+				}
797
+			}
797 798
 			}
798
-		    }
799
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
799
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
800 800
 			foreach($globalAirlineIgnore as $airlineIgnore) {
801
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
801
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
802 802
 				$ignoreImport = true;
803
-			    }
803
+				}
804
+			}
804 805
 			}
805
-		    }
806
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
806
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
807 807
 			$ignoreImport = true;
808 808
 			foreach($globalAirlineAccept as $airlineAccept) {
809
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
809
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
810 810
 				$ignoreImport = false;
811
-			    }
811
+				}
812
+			}
812 813
 			}
813
-		    }
814
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
814
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
815 815
 			$ignoreImport = true;
816 816
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
817
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
818
-			        $ignoreImport = false;
819
-			    }
817
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
818
+					$ignoreImport = false;
819
+				}
820
+			}
820 821
 			}
821
-		    }
822 822
 
823
-		    if (!$ignoreImport) {
823
+			if (!$ignoreImport) {
824 824
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
825 825
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
826 826
 				$timeelapsed = microtime(true);
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 					if ($stats_heading == 16) $stats_heading = 0;
866 866
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
867 867
 						for ($i=0;$i<=15;$i++) {
868
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
868
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
869 869
 						}
870 870
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
871 871
 					} else {
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
 					//var_dump($this->stats);
879 879
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
880 880
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
881
-						    end($this->stats[$current_date][$source]['hist']);
882
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
881
+							end($this->stats[$current_date][$source]['hist']);
882
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
883 883
 						} else $mini = 0;
884 884
 						for ($i=$mini;$i<=$distance;$i+=10) {
885
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
885
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
886 886
 						}
887 887
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
888 888
 					} else {
@@ -898,22 +898,22 @@  discard block
 block discarded – undo
898 898
 			
899 899
 			
900 900
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
901
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
902
-			    $SpotterLive = new SpotterLive($this->db);
903
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
904
-			    $SpotterLive->db = null;
905
-			    //SpotterLive->deleteLiveSpotterData();
906
-			    if ($globalDebug) echo " Done\n";
907
-			    $this->last_delete_hourly = time();
901
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
902
+				$SpotterLive = new SpotterLive($this->db);
903
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
904
+				$SpotterLive->db = null;
905
+				//SpotterLive->deleteLiveSpotterData();
906
+				if ($globalDebug) echo " Done\n";
907
+				$this->last_delete_hourly = time();
908 908
 			}
909 909
 			
910
-		    }
911
-		    //$ignoreImport = false;
910
+			}
911
+			//$ignoreImport = false;
912 912
 		}
913 913
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
914 914
 		if ($send) return $this->all_flights[$id];
915
-	    }
915
+		}
916
+	}
916 917
 	}
917
-    }
918 918
 }
919 919
 ?>
Please login to merge, or discard this patch.
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	$currentdate = date('Y-m-d');
31 31
 	$sourcestat = $Stats->getStatsSource($currentdate);
32 32
 	if (!empty($sourcestat)) {
33
-	    foreach($sourcestat as $srcst) {
33
+	    foreach ($sourcestat as $srcst) {
34 34
 	    	$type = $srcst['stats_type'];
35 35
 		if ($type == 'polar' || $type == 'hist') {
36 36
 		    $source = $srcst['source_name'];
37 37
 		    $data = $srcst['source_data'];
38
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
39 39
 	        }
40 40
 	    }
41 41
 	}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
     }
48 48
 
49
-    public function get_Schedule($id,$ident) {
49
+    public function get_Schedule($id, $ident) {
50 50
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
51 51
 	// Get schedule here, so it's done only one time
52 52
 	
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 		$schedule = $Schedule->fetchSchedule($operator);
72 72
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
73 73
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
74
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
75
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
74
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
75
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
76 76
 		    // Should also check if route schedule = route from DB
77 77
 		    if ($schedule['DepartureAirportIATA'] != '') {
78 78
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			    }
93 93
 			}
94 94
 		    }
95
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
95
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
96 96
 		}
97 97
 	    } else $scheduleexist = true;
98 98
 	} else $scheduleexist = true;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
        if ($scheduleexist) {
101 101
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
102 102
     		$sch = $Schedule->getSchedule($operator);
103
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
103
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
104 104
        }
105 105
 	$Spotter->db = null;
106 106
 	$Schedule->db = null;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
128 128
     		    $Spotter = new Spotter($this->db);
129 129
         	    $real_arrival = $this->arrival($key);
130
-        	    $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
130
+        	    $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
131 131
         	}
132 132
 	    }
133 133
 	}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $airport_time = '';
142 142
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
143 143
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
144
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
144
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
145 145
     	    if (isset($closestAirports[0])) {
146 146
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
147 147
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         		    break;
157 157
         		}
158 158
         	    }
159
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
159
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
160 160
         		$airport_icao = $closestAirports[0]['icao'];
161 161
         		$airport_time = $this->all_flights[$key]['datetime'];
162 162
         	} else {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         } else {
170 170
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
171 171
         }
172
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
172
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
173 173
     }
174 174
 
175 175
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
181 181
 	foreach ($this->all_flights as $key => $flight) {
182 182
     	    if (isset($flight['lastupdate'])) {
183
-        	if ($flight['lastupdate'] < (time()-3000)) {
183
+        	if ($flight['lastupdate'] < (time() - 3000)) {
184 184
             	    if (isset($this->all_flights[$key]['id'])) {
185 185
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
186 186
 			/*
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             		    $real_arrival = $this->arrival($key);
193 193
             		    $Spotter = new Spotter($this->db);
194 194
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
195
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
195
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
196 196
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
197 197
 			    }
198 198
 			// Put in archive
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	$send = false;
230 230
 	
231 231
 	// SBS format is CSV format
232
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
232
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
233 233
 	    //print_r($line);
234 234
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
235 235
 
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
 		
263 263
 		if (!isset($this->all_flights[$id])) {
264 264
 		    $this->all_flights[$id] = array();
265
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
266
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
267
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
265
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
266
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
267
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
268 268
 		    if (!isset($line['id'])) {
269 269
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
270 270
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
271 271
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
272
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
272
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
273 273
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
274
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
274
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
275 275
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
276 276
 		}
277 277
 		if (isset($line['source_type']) && $line['source_type'] != '') {
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
278
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
279 279
 		}
280 280
 		
281 281
 		//print_r($this->all_flights);
282 282
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
283
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
284 284
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
285 285
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
286 286
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -288,41 +288,41 @@  discard block
 block discarded – undo
288 288
 			$timeelapsed = microtime(true);
289 289
 			$Spotter = new Spotter($this->db);
290 290
 			if (isset($this->all_flights[$id]['source_type'])) {
291
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
291
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
292 292
 			} else {
293 293
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
294 294
 			}
295 295
 			$Spotter->db = null;
296
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
297
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
296
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
297
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
298 298
 		    }
299 299
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
300 300
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
301 301
 		}
302 302
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
303
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
303
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
304 304
 		}
305 305
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
306 306
 			// Get aircraft ICAO from aircraft name
307 307
 			$Spotter = new Spotter($this->db);
308 308
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
309 309
 			$Spotter->db = null;
310
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
310
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
311 311
 		}
312 312
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
313 313
 			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
314 314
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
315 315
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
316 316
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
317
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
317
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
318 318
 		}
319 319
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
320
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
321 321
 		}
322 322
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
323
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
323
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) {
324 324
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
325
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
325
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
326 326
 		    } else {
327 327
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
328 328
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -335,24 +335,24 @@  discard block
 block discarded – undo
335 335
 		    }
336 336
 		} else {
337 337
 			date_default_timezone_set('UTC');
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
339 339
 		}
340 340
 
341 341
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
342
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
342
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
343 343
 		}
344 344
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
345
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
345
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
346 346
 		}
347 347
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
348
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
348
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
349 349
 		}
350 350
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
351
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
351
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
352 352
 		}
353 353
  
354 354
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
355
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
355
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
356 356
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
357 357
 			$timeelapsed = microtime(true);
358 358
             		$Spotter = new Spotter($this->db);
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
363 363
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
364 364
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
365
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
365
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
366 366
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
367 367
 			$Spotter->db = null;
368
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
368
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
369 369
 		    }
370 370
 
371 371
 /*
@@ -376,24 +376,24 @@  discard block
 block discarded – undo
376 376
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
377 377
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
378 378
   */
379
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
379
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
380 380
 
381 381
 		    //$putinarchive = true;
382 382
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
383
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
383
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
384 384
 		    }
385 385
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
386
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
386
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
387 387
 		    }
388 388
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
389
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
389
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
390 390
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
391 391
 				$timeelapsed = microtime(true);
392 392
 				$Spotter = new Spotter($this->db);
393 393
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
394 394
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
395
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
396
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
395
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
396
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
397 397
 
398 398
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
399 399
 			$timeelapsed = microtime(true);
@@ -406,34 +406,34 @@  discard block
 block discarded – undo
406 406
 				$Translation->db = null;
407 407
 			}
408 408
 			$Spotter->db = null;
409
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
409
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
410 410
 
411 411
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
412 412
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
413 413
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
414 414
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
415
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
415
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
416 416
 		    	    }
417 417
 			}
418 418
 			if (!isset($globalFork)) $globalFork = TRUE;
419 419
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
420
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
420
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
421 421
 			}
422 422
 		    }
423 423
 		}
424 424
 
425 425
 		if (isset($line['speed']) && $line['speed'] != '') {
426 426
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
427
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
428
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
427
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
428
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
429 429
 		    //$dataFound = true;
430 430
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
431
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
431
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
432 432
 		    if ($distance > 1000 && $distance < 10000) {
433 433
 		    // use datetime
434 434
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
435 435
 			$speed = $speed*3.6;
436
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
436
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
437 437
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
438 438
 		    }
439 439
 		}
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
 
442 442
 
443 443
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
444
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
444
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
445 445
 	    	    else unset($timediff);
446
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
446
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
447 447
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
448
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
448
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
449 449
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
450 450
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
451 451
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -453,10 +453,10 @@  discard block
 block discarded – undo
453 453
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
454 454
 				$timeelapsed = microtime(true);
455 455
 				$Spotter = new Spotter($this->db);
456
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
456
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
457 457
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
458 458
 				$Spotter->db = null;
459
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
460 460
 				$this->tmd = 0;
461 461
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
462 462
 			    }
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
466 466
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
467 467
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
468
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
468
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
469 469
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
470 470
 				    $dataFound = true;
471 471
 				    $this->all_flights[$id]['time_last_coord'] = time();
472 472
 				}
473 473
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
474
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
474
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
475 475
 				/*
476 476
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
477 477
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -489,13 +489,13 @@  discard block
 block discarded – undo
489 489
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
490 490
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
491 491
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
492
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
492
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
493 493
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
494 494
 				    $dataFound = true;
495 495
 				    $this->all_flights[$id]['time_last_coord'] = time();
496 496
 				}
497 497
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
498
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
498
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
499 499
 				/*
500 500
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
501 501
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -513,46 +513,46 @@  discard block
 block discarded – undo
513 513
 		    } else if ($globalDebug && $timediff > 20) {
514 514
 			$this->tmd = $this->tmd + 1;
515 515
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
516
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
517
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
516
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
517
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
518 518
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
519 519
 		    }
520 520
 		}
521 521
 		if (isset($line['last_update']) && $line['last_update'] != '') {
522 522
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
523
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
523
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
524 524
 		}
525 525
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
526
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
526
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
527 527
 		    //$dataFound = true;
528 528
 		}
529 529
 		if (isset($line['format_source']) && $line['format_source'] != '') {
530
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
530
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
531 531
 		}
532 532
 		if (isset($line['source_name']) && $line['source_name'] != '') {
533
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
533
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
534 534
 		}
535 535
 		if (isset($line['emergency']) && $line['emergency'] != '') {
536
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
536
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
537 537
 		    //$dataFound = true;
538 538
 		}
539 539
 		if (isset($line['ground']) && $line['ground'] != '') {
540 540
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
541 541
 			// Here we force archive of flight because after ground it's a new one (or should be)
542
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
543
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
544
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
545
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
546
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
542
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
543
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
544
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
545
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
546
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
547 547
 		    }
548 548
 		    if ($line['ground'] != 1) $line['ground'] = 0;
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
549
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
550 550
 		    //$dataFound = true;
551 551
 		}
552 552
 		if (isset($line['squawk']) && $line['squawk'] != '') {
553 553
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
554 554
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
555
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
555
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
556 556
 			    $highlight = '';
557 557
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
558 558
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -560,47 +560,47 @@  discard block
 block discarded – undo
560 560
 			    if ($highlight != '') {
561 561
 				$timeelapsed = microtime(true);
562 562
 				$Spotter = new Spotter($this->db);
563
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
563
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
564 564
 				$Spotter->db = null;
565
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
565
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
566 566
 
567 567
 				//$putinarchive = true;
568 568
 				//$highlight = '';
569 569
 			    }
570 570
 			    
571
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
572 572
 		    //$dataFound = true;
573 573
 		}
574 574
 
575 575
 		if (isset($line['altitude']) && $line['altitude'] != '') {
576 576
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
577
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
578
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
579
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
577
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
578
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
579
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
580 580
 			//$dataFound = true;
581 581
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
582 582
   		}
583 583
 
584 584
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
585
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
585
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
586 586
 		}
587 587
 		
588 588
 		if (isset($line['heading']) && $line['heading'] != '') {
589
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
590
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
591
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
589
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
590
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
591
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
592 592
 		    //$dataFound = true;
593 593
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
594
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
595
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
596
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
594
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
595
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
596
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
597 597
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
598 598
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
599 599
   		    // If not enough messages and ACARS set heading to 0
600
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
600
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
601 601
   		}
602
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
603
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
602
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
603
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
604 604
 
605 605
 //		print_r($this->all_flights[$id]);
606 606
 		//gets the callsign from the last hour
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
611 611
 		    $this->all_flights[$id]['lastupdate'] = time();
612 612
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
613
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
613
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
614 614
 			    //print_r($this->all_flights);
615 615
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
616 616
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -620,61 +620,61 @@  discard block
 block discarded – undo
620 620
 				$SpotterLive = new SpotterLive($this->db);
621 621
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
622 622
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
623
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
623
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
624 624
 				} elseif (isset($line['id'])) {
625 625
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
626
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
626
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
627 627
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
628 628
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
629
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
629
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
630 630
 				} else $recent_ident = '';
631
-				$SpotterLive->db=null;
631
+				$SpotterLive->db = null;
632 632
 
633 633
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
634 634
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
635 635
 			    } else {
636 636
 				$recent_ident = '';
637
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
637
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
638 638
 			    }
639 639
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
640
-			    if($recent_ident == "")
640
+			    if ($recent_ident == "")
641 641
 			    {
642 642
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
643 643
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
644 644
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
645 645
 				//adds the spotter data for the archive
646 646
 				$ignoreImport = false;
647
-				foreach($globalAirportIgnore as $airportIgnore) {
647
+				foreach ($globalAirportIgnore as $airportIgnore) {
648 648
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
649 649
 					$ignoreImport = true;
650 650
 				    }
651 651
 				}
652 652
 				if (count($globalAirportAccept) > 0) {
653 653
 				    $ignoreImport = true;
654
-				    foreach($globalAirportIgnore as $airportIgnore) {
654
+				    foreach ($globalAirportIgnore as $airportIgnore) {
655 655
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
656 656
 					    $ignoreImport = false;
657 657
 					}
658 658
 				    }
659 659
 				}
660 660
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
661
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
662
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
661
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
662
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
663 663
 					    $ignoreImport = true;
664 664
 					}
665 665
 				    }
666 666
 				}
667 667
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
668 668
 				    $ignoreImport = true;
669
-				    foreach($globalAirlineAccept as $airlineAccept) {
670
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
669
+				    foreach ($globalAirlineAccept as $airlineAccept) {
670
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
671 671
 					    $ignoreImport = false;
672 672
 					}
673 673
 				    }
674 674
 				}
675 675
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
676 676
 				    $ignoreImport = true;
677
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
677
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
678 678
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
679 679
 					    $ignoreImport = false;
680 680
 					}
@@ -686,29 +686,29 @@  discard block
 block discarded – undo
686 686
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
687 687
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
688 688
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
689
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
689
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
690 690
 				    $timeelapsed = microtime(true);
691 691
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
692 692
 					$Spotter = new Spotter($this->db);
693
-					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
693
+					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
694 694
 					$Spotter->db = null;
695 695
 					if ($globalDebug && isset($result)) echo $result."\n";
696 696
 				    }
697
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
697
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
698 698
 				    
699 699
 				    // Add source stat in DB
700 700
 				    $Stats = new Stats($this->db);
701 701
 				    if (!empty($this->stats)) {
702 702
 					if ($globalDebug) echo 'Add source stats : ';
703
-				        foreach($this->stats as $date => $data) {
704
-					    foreach($data as $source => $sourced) {
703
+				        foreach ($this->stats as $date => $data) {
704
+					    foreach ($data as $source => $sourced) {
705 705
 					        //print_r($sourced);
706
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
707
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
706
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
707
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
708 708
 				    		if (isset($sourced['msg'])) {
709 709
 				    		    if (time() - $sourced['msg']['date'] > 10) {
710 710
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
711
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
711
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
712 712
 			    			        unset($this->stats[$date][$source]['msg']);
713 713
 			    			    }
714 714
 			    			}
@@ -745,20 +745,20 @@  discard block
 block discarded – undo
745 745
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
746 746
 					$SpotterLive = new SpotterLive($this->db);
747 747
 					$SpotterLive->deleteLiveSpotterData();
748
-					$SpotterLive->db=null;
748
+					$SpotterLive->db = null;
749 749
 				    }
750 750
 				    if ($globalDebug) echo " Done\n";
751 751
 				    $this->last_delete = time();
752 752
 				}
753 753
 			    } else {
754
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
754
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
755 755
 				    $this->all_flights[$id]['id'] = $recent_ident;
756 756
 				    $this->all_flights[$id]['addedSpotter'] = 1;
757 757
 				}
758 758
 				if (isset($globalDaemon) && !$globalDaemon) {
759 759
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
760 760
 					$Spotter = new Spotter($this->db);
761
-					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
761
+					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
762 762
 					$Spotter->db = null;
763 763
 				    }
764 764
 				}
@@ -783,37 +783,37 @@  discard block
 block discarded – undo
783 783
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
784 784
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
785 785
 
786
-		    foreach($globalAirportIgnore as $airportIgnore) {
786
+		    foreach ($globalAirportIgnore as $airportIgnore) {
787 787
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788 788
 			    $ignoreImport = true;
789 789
 			}
790 790
 		    }
791 791
 		    if (count($globalAirportAccept) > 0) {
792 792
 		        $ignoreImport = true;
793
-		        foreach($globalAirportIgnore as $airportIgnore) {
793
+		        foreach ($globalAirportIgnore as $airportIgnore) {
794 794
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
795 795
 				$ignoreImport = false;
796 796
 			    }
797 797
 			}
798 798
 		    }
799 799
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
800
-			foreach($globalAirlineIgnore as $airlineIgnore) {
801
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
800
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
801
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
802 802
 				$ignoreImport = true;
803 803
 			    }
804 804
 			}
805 805
 		    }
806 806
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
807 807
 			$ignoreImport = true;
808
-			foreach($globalAirlineAccept as $airlineAccept) {
809
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
808
+			foreach ($globalAirlineAccept as $airlineAccept) {
809
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
810 810
 				$ignoreImport = false;
811 811
 			    }
812 812
 			}
813 813
 		    }
814 814
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
815 815
 			$ignoreImport = true;
816
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
816
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
817 817
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
818 818
 			        $ignoreImport = false;
819 819
 			    }
@@ -821,20 +821,20 @@  discard block
 block discarded – undo
821 821
 		    }
822 822
 
823 823
 		    if (!$ignoreImport) {
824
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
824
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
825 825
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
826 826
 				$timeelapsed = microtime(true);
827 827
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
828 828
 					$SpotterLive = new SpotterLive($this->db);
829
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
829
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
830 830
 					$SpotterLive->db = null;
831 831
 					if ($globalDebug) echo $result."\n";
832 832
 				}
833 833
 				if (isset($globalServerAPRS) && $globalServerAPRS) {
834
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
834
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
835 835
 				}
836 836
 				$this->all_flights[$id]['putinarchive'] = false;
837
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
837
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
838 838
 
839 839
 				// Put statistics in $this->stats variable
840 840
 				//if ($line['format_source'] != 'aprs') {
@@ -852,19 +852,19 @@  discard block
 block discarded – undo
852 852
 							$latitude = $globalCenterLatitude;
853 853
 							$longitude = $globalCenterLongitude;
854 854
 						}
855
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
855
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
856 856
 					} else {
857 857
 						$latitude = $this->source_location[$source]['latitude'];
858 858
 						$longitude = $this->source_location[$source]['longitude'];
859 859
 					}
860
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
860
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
861 861
 					//$stats_heading = $stats_heading%22.5;
862 862
 					$stats_heading = round($stats_heading/22.5);
863
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
863
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
864 864
 					$current_date = date('Y-m-d');
865 865
 					if ($stats_heading == 16) $stats_heading = 0;
866 866
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
867
-						for ($i=0;$i<=15;$i++) {
867
+						for ($i = 0; $i <= 15; $i++) {
868 868
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
869 869
 						}
870 870
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -879,9 +879,9 @@  discard block
 block discarded – undo
879 879
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
880 880
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
881 881
 						    end($this->stats[$current_date][$source]['hist']);
882
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
882
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
883 883
 						} else $mini = 0;
884
-						for ($i=$mini;$i<=$distance;$i+=10) {
884
+						for ($i = $mini; $i <= $distance; $i += 10) {
885 885
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
886 886
 						}
887 887
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 				$this->all_flights[$id]['lastupdate'] = time();
894 894
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
895 895
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
896
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
896
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
897 897
 			//$this->del();
898 898
 			
899 899
 			
Please login to merge, or discard this patch.
Braces   +331 added lines, -117 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 	$dbc = $this->db;
60 60
 	$this->all_flights[$id]['schedule_check'] = true;
61 61
 	if ($globalSchedulesFetch) {
62
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
62
+	if ($globalDebug) {
63
+		echo 'Getting schedule info...'."\n";
64
+	}
63 65
 	$Spotter = new Spotter($dbc);
64 66
 	$Schedule = new Schedule($dbc);
65 67
 	$Translation = new Translation($dbc);
@@ -70,7 +72,9 @@  discard block
 block discarded – undo
70 72
 	    if ($Schedule->checkSchedule($operator) == 0) {
71 73
 		$schedule = $Schedule->fetchSchedule($operator);
72 74
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
73
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
75
+		    if ($globalDebug) {
76
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
77
+		    }
74 78
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
75 79
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
76 80
 		    // Should also check if route schedule = route from DB
@@ -79,7 +83,9 @@  discard block
 block discarded – undo
79 83
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
80 84
 			    if (trim($airport_icao) != '') {
81 85
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
82
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
86
+				if ($globalDebug) {
87
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
88
+				}
83 89
 			    }
84 90
 			}
85 91
 		    }
@@ -88,17 +94,25 @@  discard block
 block discarded – undo
88 94
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
89 95
 			    if (trim($airport_icao) != '') {
90 96
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
91
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
97
+				if ($globalDebug) {
98
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
99
+				}
92 100
 			    }
93 101
 			}
94 102
 		    }
95 103
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
96 104
 		}
97
-	    } else $scheduleexist = true;
98
-	} else $scheduleexist = true;
105
+	    } else {
106
+	    	$scheduleexist = true;
107
+	    }
108
+	} else {
109
+		$scheduleexist = true;
110
+	}
99 111
 	// close connection, at least one way will work ?
100 112
        if ($scheduleexist) {
101
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
113
+		if ($globalDebug) {
114
+			echo "-> get arrival/departure airport info for ".$ident."\n";
115
+		}
102 116
     		$sch = $Schedule->getSchedule($operator);
103 117
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
104 118
        }
@@ -120,7 +134,9 @@  discard block
 block discarded – undo
120 134
 
121 135
     public function checkAll() {
122 136
 	global $globalDebug, $globalNoImport;
123
-	if ($globalDebug) echo "Update last seen flights data...\n";
137
+	if ($globalDebug) {
138
+		echo "Update last seen flights data...\n";
139
+	}
124 140
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
125 141
 	    foreach ($this->all_flights as $key => $flight) {
126 142
 		if (isset($this->all_flights[$key]['id'])) {
@@ -135,24 +151,32 @@  discard block
 block discarded – undo
135 151
 
136 152
     public function arrival($key) {
137 153
 	global $globalClosestMinDist, $globalDebug;
138
-	if ($globalDebug) echo 'Update arrival...'."\n";
154
+	if ($globalDebug) {
155
+		echo 'Update arrival...'."\n";
156
+	}
139 157
 	$Spotter = new Spotter($this->db);
140 158
         $airport_icao = '';
141 159
         $airport_time = '';
142
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
160
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
161
+        	$globalClosestMinDist = 50;
162
+        }
143 163
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
144 164
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
145 165
     	    if (isset($closestAirports[0])) {
146 166
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
147 167
         	    $airport_icao = $closestAirports[0]['icao'];
148 168
         	    $airport_time = $this->all_flights[$key]['datetime'];
149
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+        	    if ($globalDebug) {
170
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        	    }
150 172
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
151 173
         	    foreach ($closestAirports as $airport) {
152 174
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
153 175
         		    $airport_icao = $airport['icao'];
154 176
         		    $airport_time = $this->all_flights[$key]['datetime'];
155
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        		    if ($globalDebug) {
178
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
179
+        		    }
156 180
         		    break;
157 181
         		}
158 182
         	    }
@@ -160,14 +184,20 @@  discard block
 block discarded – undo
160 184
         		$airport_icao = $closestAirports[0]['icao'];
161 185
         		$airport_time = $this->all_flights[$key]['datetime'];
162 186
         	} else {
163
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
187
+        		if ($globalDebug) {
188
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
189
+        		}
164 190
         	}
165 191
     	    } else {
166
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
192
+    		    if ($globalDebug) {
193
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
194
+    		    }
167 195
     	    }
168 196
 
169 197
         } else {
170
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
198
+        	if ($globalDebug) {
199
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
200
+        	}
171 201
         }
172 202
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
173 203
     }
@@ -177,12 +207,16 @@  discard block
 block discarded – undo
177 207
     public function del() {
178 208
 	global $globalDebug, $globalNoImport;
179 209
 	// Delete old infos
180
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
210
+	if ($globalDebug) {
211
+		echo 'Delete old values and update latest data...'."\n";
212
+	}
181 213
 	foreach ($this->all_flights as $key => $flight) {
182 214
     	    if (isset($flight['lastupdate'])) {
183 215
         	if ($flight['lastupdate'] < (time()-3000)) {
184 216
             	    if (isset($this->all_flights[$key]['id'])) {
185
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
217
+            		if ($globalDebug) {
218
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
219
+            		}
186 220
 			/*
187 221
 			$SpotterLive = new SpotterLive();
188 222
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -193,7 +227,9 @@  discard block
 block discarded – undo
193 227
             		    $Spotter = new Spotter($this->db);
194 228
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
195 229
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
196
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
230
+				if ($globalDebug && $result != 'success') {
231
+					echo '!!! ERROR : '.$result."\n";
232
+				}
197 233
 			    }
198 234
 			// Put in archive
199 235
 //				$Spotter->db = null;
@@ -208,8 +244,10 @@  discard block
 block discarded – undo
208 244
     public function add($line) {
209 245
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport;
210 246
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
211
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
212
-/*
247
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
248
+		$globalCoordMinChange = '0.02';
249
+	}
250
+	/*
213 251
 	$Spotter = new Spotter();
214 252
 	$dbc = $Spotter->db;
215 253
 	$SpotterLive = new SpotterLive($dbc);
@@ -237,11 +275,15 @@  discard block
 block discarded – undo
237 275
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
238 276
 		    $current_date = date('Y-m-d');
239 277
 		    $source = $line['source_name'];
240
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
278
+		    if ($source == '' || $line['format_source'] == 'aprs') {
279
+		    	$source = $line['format_source'];
280
+		    }
241 281
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
242 282
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
243 283
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
244
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
284
+		    } else {
285
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
286
+		    }
245 287
 		}
246 288
 		
247 289
 		/*
@@ -257,8 +299,11 @@  discard block
 block discarded – undo
257 299
 		//$this->db = $dbc;
258 300
 
259 301
 		//$hex = trim($line['hex']);
260
-	        if (!isset($line['id'])) $id = trim($line['hex']);
261
-	        else $id = trim($line['id']);
302
+	        if (!isset($line['id'])) {
303
+	        	$id = trim($line['hex']);
304
+	        } else {
305
+	        	$id = trim($line['id']);
306
+	        }
262 307
 		
263 308
 		if (!isset($this->all_flights[$id])) {
264 309
 		    $this->all_flights[$id] = array();
@@ -266,13 +311,21 @@  discard block
 block discarded – undo
266 311
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
267 312
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
268 313
 		    if (!isset($line['id'])) {
269
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
270
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
314
+			if (!isset($globalDaemon)) {
315
+				$globalDaemon = TRUE;
316
+			}
317
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
271 318
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
272
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
319
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
320
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
321
+			}
273 322
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
274
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
275
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
323
+		     } else {
324
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
325
+		     }
326
+		    if ($globalAllFlights !== FALSE) {
327
+		    	$dataFound = true;
328
+		    }
276 329
 		}
277 330
 		if (isset($line['source_type']) && $line['source_type'] != '') {
278 331
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -293,11 +346,19 @@  discard block
 block discarded – undo
293 346
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
294 347
 			}
295 348
 			$Spotter->db = null;
296
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
297
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
349
+			if ($globalDebugTimeElapsed) {
350
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
351
+			}
352
+			if ($aircraft_icao != '') {
353
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
354
+			}
355
+		    }
356
+		    if ($globalAllFlights !== FALSE) {
357
+		    	$dataFound = true;
358
+		    }
359
+		    if ($globalDebug) {
360
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
298 361
 		    }
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
300
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
301 362
 		}
302 363
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
303 364
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -307,14 +368,23 @@  discard block
 block discarded – undo
307 368
 			$Spotter = new Spotter($this->db);
308 369
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
309 370
 			$Spotter->db = null;
310
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
371
+			if ($aircraft_icao != '') {
372
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
373
+			}
311 374
 		}
312 375
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
313
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
314
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
315
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
316
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
317
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
376
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
377
+				$aircraft_icao = 'GLID';
378
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
379
+				$aircraft_icao = 'UHEL';
380
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
381
+				$aircraft_icao = 'TOWPLANE';
382
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
383
+				$aircraft_icao = 'POWAIRC';
384
+			}
385
+			if (isset($aircraft_icao)) {
386
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
387
+			}
318 388
 		}
319 389
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
320 390
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -324,8 +394,11 @@  discard block
 block discarded – undo
324 394
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
325 395
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
326 396
 		    } else {
327
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
328
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
397
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
398
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
399
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
400
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
401
+				}
329 402
 				/*
330 403
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
331 404
 				print_r($this->all_flights[$id]);
@@ -357,15 +430,25 @@  discard block
 block discarded – undo
357 430
 			$timeelapsed = microtime(true);
358 431
             		$Spotter = new Spotter($this->db);
359 432
             		$fromsource = NULL;
360
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
361
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
362
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
363
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
364
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
433
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
434
+            			$fromsource = $globalAirlinesSource;
435
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
436
+            			$fromsource = 'vatsim';
437
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
438
+				$fromsource = 'ivao';
439
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
440
+				$fromsource = 'vatsim';
441
+			} elseif (isset($globalIVAO) && $globalIVAO) {
442
+				$fromsource = 'ivao';
443
+			}
365 444
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
366
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
445
+			if ($globalDebug && $result != 'success') {
446
+				echo '!!! ERROR : '.$result."\n";
447
+			}
367 448
 			$Spotter->db = null;
368
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
+			if ($globalDebugTimeElapsed) {
450
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
451
+			}
369 452
 		    }
370 453
 
371 454
 /*
@@ -376,7 +459,9 @@  discard block
 block discarded – undo
376 459
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
377 460
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
378 461
   */
379
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
462
+		    if (!isset($this->all_flights[$id]['id'])) {
463
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
464
+		    }
380 465
 
381 466
 		    //$putinarchive = true;
382 467
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -393,7 +478,9 @@  discard block
 block discarded – undo
393 478
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
394 479
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
395 480
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
396
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
397 484
 
398 485
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
399 486
 			$timeelapsed = microtime(true);
@@ -406,7 +493,9 @@  discard block
 block discarded – undo
406 493
 				$Translation->db = null;
407 494
 			}
408 495
 			$Spotter->db = null;
409
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+			if ($globalDebugTimeElapsed) {
497
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+			}
410 499
 
411 500
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
412 501
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -415,9 +504,13 @@  discard block
 block discarded – undo
415 504
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
416 505
 		    	    }
417 506
 			}
418
-			if (!isset($globalFork)) $globalFork = TRUE;
507
+			if (!isset($globalFork)) {
508
+				$globalFork = TRUE;
509
+			}
419 510
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
420
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
511
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
512
+					$this->get_Schedule($id,trim($line['ident']));
513
+				}
421 514
 			}
422 515
 		    }
423 516
 		}
@@ -433,16 +526,23 @@  discard block
 block discarded – undo
433 526
 		    // use datetime
434 527
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
435 528
 			$speed = $speed*3.6;
436
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
437
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
529
+			if ($speed < 1000) {
530
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
531
+			}
532
+  			if ($globalDebug) {
533
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
534
+  			}
438 535
 		    }
439 536
 		}
440 537
 
441 538
 
442 539
 
443 540
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
444
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
445
-	    	    else unset($timediff);
541
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
542
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
543
+	    	    } else {
544
+	    	    	unset($timediff);
545
+	    	    }
446 546
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
447 547
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
448 548
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -450,21 +550,31 @@  discard block
 block discarded – undo
450 550
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
451 551
 				$this->all_flights[$id]['putinarchive'] = true;
452 552
 				
453
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
553
+				if ($globalDebug) {
554
+					echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
555
+				}
454 556
 				$timeelapsed = microtime(true);
455 557
 				$Spotter = new Spotter($this->db);
456 558
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
457
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
559
+				if (!empty($all_country)) {
560
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
561
+				}
458 562
 				$Spotter->db = null;
459
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
563
+				if ($globalDebugTimeElapsed) {
564
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
565
+				}
460 566
 				$this->tmd = 0;
461
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
567
+				if ($globalDebug) {
568
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
569
+				}
462 570
 			    }
463 571
 			}
464 572
 
465 573
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
466 574
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
467
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
575
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
576
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
577
+				}
468 578
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
469 579
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
470 580
 				    $dataFound = true;
@@ -486,9 +596,13 @@  discard block
 block discarded – undo
486 596
 			    */
487 597
 			}
488 598
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
489
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
599
+			    if ($line['longitude'] > 180) {
600
+			    	$line['longitude'] = $line['longitude'] - 360;
601
+			    }
490 602
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
491
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
603
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
604
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
605
+				}
492 606
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
493 607
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
494 608
 				    $dataFound = true;
@@ -519,7 +633,9 @@  discard block
 block discarded – undo
519 633
 		    }
520 634
 		}
521 635
 		if (isset($line['last_update']) && $line['last_update'] != '') {
522
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
636
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
637
+		    	$dataFound = true;
638
+		    }
523 639
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
524 640
 		}
525 641
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -541,40 +657,60 @@  discard block
 block discarded – undo
541 657
 			// Here we force archive of flight because after ground it's a new one (or should be)
542 658
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
543 659
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
544
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
545
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
546
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
660
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
661
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
662
+			} elseif (isset($line['id'])) {
663
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
664
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
665
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
666
+			}
667
+		    }
668
+		    if ($line['ground'] != 1) {
669
+		    	$line['ground'] = 0;
547 670
 		    }
548
-		    if ($line['ground'] != 1) $line['ground'] = 0;
549 671
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
550 672
 		    //$dataFound = true;
551 673
 		}
552 674
 		if (isset($line['squawk']) && $line['squawk'] != '') {
553 675
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
554
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
677
+			    	$this->all_flights[$id]['putinarchive'] = true;
678
+			    }
555 679
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
556 680
 			    $highlight = '';
557
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
558
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
559
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
681
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
682
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
683
+			    }
684
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
685
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
686
+			    }
687
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
688
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
689
+			    }
560 690
 			    if ($highlight != '') {
561 691
 				$timeelapsed = microtime(true);
562 692
 				$Spotter = new Spotter($this->db);
563 693
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
564 694
 				$Spotter->db = null;
565
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
695
+				if ($globalDebugTimeElapsed) {
696
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
697
+				}
566 698
 
567 699
 				//$putinarchive = true;
568 700
 				//$highlight = '';
569 701
 			    }
570 702
 			    
571
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
703
+		    } else {
704
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
705
+		    }
572 706
 		    //$dataFound = true;
573 707
 		}
574 708
 
575 709
 		if (isset($line['altitude']) && $line['altitude'] != '') {
576 710
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
577
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
711
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
712
+				$this->all_flights[$id]['putinarchive'] = true;
713
+			}
578 714
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
579 715
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
580 716
 			//$dataFound = true;
@@ -586,21 +722,30 @@  discard block
 block discarded – undo
586 722
 		}
587 723
 		
588 724
 		if (isset($line['heading']) && $line['heading'] != '') {
589
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
725
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
726
+		    	$this->all_flights[$id]['putinarchive'] = true;
727
+		    }
590 728
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
591 729
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
592 730
 		    //$dataFound = true;
593 731
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
594 732
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
595 733
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
596
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
597
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
734
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
735
+		    	$this->all_flights[$id]['putinarchive'] = true;
736
+		    }
737
+  		    if ($globalDebug) {
738
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
739
+  		    }
598 740
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
599 741
   		    // If not enough messages and ACARS set heading to 0
600 742
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
601 743
   		}
602
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
603
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
745
+			$dataFound = false;
746
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
747
+			$dataFound = false;
748
+		}
604 749
 
605 750
 //		print_r($this->all_flights[$id]);
606 751
 		//gets the callsign from the last hour
@@ -615,23 +760,36 @@  discard block
 block discarded – undo
615 760
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
616 761
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
617 762
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
618
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
763
+				if ($globalDebug) {
764
+					echo "Check if aircraft is already in DB...";
765
+				}
619 766
 				$timeelapsed = microtime(true);
620 767
 				$SpotterLive = new SpotterLive($this->db);
621 768
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
622 769
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
623
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
770
+				    if ($globalDebugTimeElapsed) {
771
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
772
+				    }
624 773
 				} elseif (isset($line['id'])) {
625 774
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
626
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
775
+				    if ($globalDebugTimeElapsed) {
776
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
777
+				    }
627 778
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
628 779
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
629
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
630
-				} else $recent_ident = '';
780
+				    if ($globalDebugTimeElapsed) {
781
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
782
+				    }
783
+				} else {
784
+					$recent_ident = '';
785
+				}
631 786
 				$SpotterLive->db=null;
632 787
 
633
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
634
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
788
+				if ($globalDebug && $recent_ident == '') {
789
+					echo " Not in DB.\n";
790
+				} elseif ($globalDebug && $recent_ident != '') {
791
+					echo " Already in DB.\n";
792
+				}
635 793
 			    } else {
636 794
 				$recent_ident = '';
637 795
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -639,7 +797,9 @@  discard block
 block discarded – undo
639 797
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
640 798
 			    if($recent_ident == "")
641 799
 			    {
642
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
800
+				if ($globalDebug) {
801
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
802
+				}
643 803
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
644 804
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
645 805
 				//adds the spotter data for the archive
@@ -683,28 +843,46 @@  discard block
 block discarded – undo
683 843
 				
684 844
 				if (!$ignoreImport) {
685 845
 				    $highlight = '';
686
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
687
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
688
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
689
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
846
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
847
+				    	$highlight = 'Squawk 7500 : Hijack';
848
+				    }
849
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
850
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
851
+				    }
852
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
853
+				    	$highlight = 'Squawk 7700 : Emergency';
854
+				    }
855
+				    if (!isset($this->all_flights[$id]['id'])) {
856
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
857
+				    }
690 858
 				    $timeelapsed = microtime(true);
691 859
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
692 860
 					$Spotter = new Spotter($this->db);
693 861
 					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
694 862
 					$Spotter->db = null;
695
-					if ($globalDebug && isset($result)) echo $result."\n";
863
+					if ($globalDebug && isset($result)) {
864
+						echo $result."\n";
865
+					}
866
+				    }
867
+				    if ($globalDebugTimeElapsed) {
868
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
696 869
 				    }
697
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
698 870
 				    
699 871
 				    // Add source stat in DB
700 872
 				    $Stats = new Stats($this->db);
701 873
 				    if (!empty($this->stats)) {
702
-					if ($globalDebug) echo 'Add source stats : ';
874
+					if ($globalDebug) {
875
+						echo 'Add source stats : ';
876
+					}
703 877
 				        foreach($this->stats as $date => $data) {
704 878
 					    foreach($data as $source => $sourced) {
705 879
 					        //print_r($sourced);
706
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
707
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
880
+				    	        if (isset($sourced['polar'])) {
881
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
+				    	        }
883
+				    	        if (isset($sourced['hist'])) {
884
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
885
+				    	        }
708 886
 				    		if (isset($sourced['msg'])) {
709 887
 				    		    if (time() - $sourced['msg']['date'] > 10) {
710 888
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -717,13 +895,17 @@  discard block
 block discarded – undo
717 895
 			    			unset($this->stats[$date]);
718 896
 			    		    }
719 897
 				    	}
720
-				    	if ($globalDebug) echo 'Done'."\n";
898
+				    	if ($globalDebug) {
899
+				    		echo 'Done'."\n";
900
+				    	}
721 901
 
722 902
 				    }
723 903
 				    $Stats->db = null;
724 904
 				    
725 905
 				    $this->del();
726
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
906
+				} elseif ($globalDebug) {
907
+					echo 'Ignore data'."\n";
908
+				}
727 909
 				//$ignoreImport = false;
728 910
 				$this->all_flights[$id]['addedSpotter'] = 1;
729 911
 				//print_r($this->all_flights[$id]);
@@ -740,14 +922,18 @@  discard block
 block discarded – undo
740 922
 			*/
741 923
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
742 924
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
743
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
925
+				    if ($globalDebug) {
926
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
927
+				    }
744 928
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
745 929
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
746 930
 					$SpotterLive = new SpotterLive($this->db);
747 931
 					$SpotterLive->deleteLiveSpotterData();
748 932
 					$SpotterLive->db=null;
749 933
 				    }
750
-				    if ($globalDebug) echo " Done\n";
934
+				    if ($globalDebug) {
935
+				    	echo " Done\n";
936
+				    }
751 937
 				    $this->last_delete = time();
752 938
 				}
753 939
 			    } else {
@@ -772,11 +958,17 @@  discard block
 block discarded – undo
772 958
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
773 959
 		    if ($globalDebug) {
774 960
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
775
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
776
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
961
+				if (isset($this->all_flights[$id]['source_name'])) {
962
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
963
+				} else {
964
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
965
+				}
777 966
 			} else {
778
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
779
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
967
+				if (isset($this->all_flights[$id]['source_name'])) {
968
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
969
+				} else {
970
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
971
+				}
780 972
 			}
781 973
 		    }
782 974
 		    $ignoreImport = false;
@@ -822,26 +1014,34 @@  discard block
 block discarded – undo
822 1014
 
823 1015
 		    if (!$ignoreImport) {
824 1016
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
825
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1017
+				if ($globalDebug) {
1018
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1019
+				}
826 1020
 				$timeelapsed = microtime(true);
827 1021
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
828 1022
 					$SpotterLive = new SpotterLive($this->db);
829 1023
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
830 1024
 					$SpotterLive->db = null;
831
-					if ($globalDebug) echo $result."\n";
1025
+					if ($globalDebug) {
1026
+						echo $result."\n";
1027
+					}
832 1028
 				}
833 1029
 				if (isset($globalServerAPRS) && $globalServerAPRS) {
834 1030
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
835 1031
 				}
836 1032
 				$this->all_flights[$id]['putinarchive'] = false;
837
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1033
+				if ($globalDebugTimeElapsed) {
1034
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1035
+				}
838 1036
 
839 1037
 				// Put statistics in $this->stats variable
840 1038
 				//if ($line['format_source'] != 'aprs') {
841 1039
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
842 1040
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
843 1041
 					$source = $this->all_flights[$id]['source_name'];
844
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1042
+					if ($source == '') {
1043
+						$source = $this->all_flights[$id]['format_source'];
1044
+					}
845 1045
 					if (!isset($this->source_location[$source])) {
846 1046
 						$Location = new Source();
847 1047
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -862,7 +1062,9 @@  discard block
 block discarded – undo
862 1062
 					$stats_heading = round($stats_heading/22.5);
863 1063
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
864 1064
 					$current_date = date('Y-m-d');
865
-					if ($stats_heading == 16) $stats_heading = 0;
1065
+					if ($stats_heading == 16) {
1066
+						$stats_heading = 0;
1067
+					}
866 1068
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
867 1069
 						for ($i=0;$i<=15;$i++) {
868 1070
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -880,7 +1082,9 @@  discard block
 block discarded – undo
880 1082
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
881 1083
 						    end($this->stats[$current_date][$source]['hist']);
882 1084
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
883
-						} else $mini = 0;
1085
+						} else {
1086
+							$mini = 0;
1087
+						}
884 1088
 						for ($i=$mini;$i<=$distance;$i+=10) {
885 1089
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
886 1090
 						}
@@ -891,19 +1095,27 @@  discard block
 block discarded – undo
891 1095
 				}
892 1096
 
893 1097
 				$this->all_flights[$id]['lastupdate'] = time();
894
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1098
+				if ($this->all_flights[$id]['putinarchive']) {
1099
+					$send = true;
1100
+				}
895 1101
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
896
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1102
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1103
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1104
+			}
897 1105
 			//$this->del();
898 1106
 			
899 1107
 			
900 1108
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
901
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1109
+			    if ($globalDebug) {
1110
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1111
+			    }
902 1112
 			    $SpotterLive = new SpotterLive($this->db);
903 1113
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
904 1114
 			    $SpotterLive->db = null;
905 1115
 			    //SpotterLive->deleteLiveSpotterData();
906
-			    if ($globalDebug) echo " Done\n";
1116
+			    if ($globalDebug) {
1117
+			    	echo " Done\n";
1118
+			    }
907 1119
 			    $this->last_delete_hourly = time();
908 1120
 			}
909 1121
 			
@@ -911,7 +1123,9 @@  discard block
 block discarded – undo
911 1123
 		    //$ignoreImport = false;
912 1124
 		}
913 1125
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
914
-		if ($send) return $this->all_flights[$id];
1126
+		if ($send) {
1127
+			return $this->all_flights[$id];
1128
+		}
915 1129
 	    }
916 1130
 	}
917 1131
     }
Please login to merge, or discard this patch.
require/class.SpotterLive.php 2 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Gets all the spotter information based on the latest data entry
132
-	*
133
-	* @return Array the spotter information
134
-	*
135
-	*/
131
+	 * Gets all the spotter information based on the latest data entry
132
+	 *
133
+	 * @return Array the spotter information
134
+	 *
135
+	 */
136 136
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
137 137
 	{
138 138
 		global $globalDBdriver, $globalLiveInterval;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Gets Minimal Live Spotter data
178
-	*
179
-	* @return Array the spotter information
180
-	*
181
-	*/
177
+	 * Gets Minimal Live Spotter data
178
+	 *
179
+	 * @return Array the spotter information
180
+	 *
181
+	 */
182 182
 	public function getMinLiveSpotterData($filter = array())
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval;
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	}
232 232
 
233 233
 	/**
234
-	* Gets Minimal Live Spotter data since xx seconds
235
-	*
236
-	* @return Array the spotter information
237
-	*
238
-	*/
234
+	 * Gets Minimal Live Spotter data since xx seconds
235
+	 *
236
+	 * @return Array the spotter information
237
+	 *
238
+	 */
239 239
 	public function getMinLastLiveSpotterData($filter = array())
240 240
 	{
241 241
 		global $globalDBdriver, $globalLiveInterval;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			$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, spotter_live.date, spotter_live.format_source 
254 254
 			FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
255 255
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
256
-                } else {
256
+				} else {
257 257
 /*
258 258
 			$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 
259 259
 			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' 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 //			echo $query;
266 266
 		}
267 267
 
268
-    		try {
268
+			try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271 271
 		} catch(PDOException $e) {
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 	}
278 278
 
279 279
 	/**
280
-	* Gets number of latest data entry
281
-	*
282
-	* @return String number of entry
283
-	*
284
-	*/
280
+	 * Gets number of latest data entry
281
+	 *
282
+	 * @return String number of entry
283
+	 *
284
+	 */
285 285
 	public function getLiveSpotterCount($filter = array())
286 286
 	{
287 287
 		global $globalDBdriver, $globalLiveInterval;
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 	}
309 309
 
310 310
 	/**
311
-	* Gets all the spotter information based on the latest data entry and coord
312
-	*
313
-	* @return Array the spotter information
314
-	*
315
-	*/
311
+	 * Gets all the spotter information based on the latest data entry and coord
312
+	 *
313
+	 * @return Array the spotter information
314
+	 *
315
+	 */
316 316
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
317 317
 	{
318 318
 		global $globalDBdriver, $globalLiveInterval;
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	}
338 338
 
339 339
 	/**
340
-	* Gets all the spotter information based on a user's latitude and longitude
341
-	*
342
-	* @return Array the spotter information
343
-	*
344
-	*/
340
+	 * Gets all the spotter information based on a user's latitude and longitude
341
+	 *
342
+	 * @return Array the spotter information
343
+	 *
344
+	 */
345 345
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
346 346
 	{
347 347
 		$Spotter = new Spotter($this->db);
@@ -351,145 +351,145 @@  discard block
 block discarded – undo
351 351
 				return false;
352 352
 			}
353 353
 		}
354
-        if ($lng != '')
355
-                {
356
-                        if (!is_numeric($lng))
357
-                        {
358
-                                return false;
359
-                        }
360
-                }
361
-
362
-                if ($radius != '')
363
-                {
364
-                        if (!is_numeric($radius))
365
-                        {
366
-                                return false;
367
-                        }
368
-                }
354
+		if ($lng != '')
355
+				{
356
+						if (!is_numeric($lng))
357
+						{
358
+								return false;
359
+						}
360
+				}
361
+
362
+				if ($radius != '')
363
+				{
364
+						if (!is_numeric($radius))
365
+						{
366
+								return false;
367
+						}
368
+				}
369 369
 		$additional_query = '';
370
-        if ($interval != '')
371
-                {
372
-                        if (!is_string($interval))
373
-                        {
374
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
375
-			        return false;
376
-                        } else {
377
-                if ($interval == '1m')
378
-                {
379
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
380
-                } else if ($interval == '15m'){
381
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
382
-                } 
383
-            }
384
-                } else {
385
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
386
-        }
387
-
388
-                $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 
370
+		if ($interval != '')
371
+				{
372
+						if (!is_string($interval))
373
+						{
374
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
375
+					return false;
376
+						} else {
377
+				if ($interval == '1m')
378
+				{
379
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
380
+				} else if ($interval == '15m'){
381
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
382
+				} 
383
+			}
384
+				} else {
385
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
386
+		}
387
+
388
+				$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 
389 389
                    WHERE spotter_live.latitude <> '' 
390 390
                                    AND spotter_live.longitude <> '' 
391 391
                    ".$additional_query."
392 392
                    HAVING distance < :radius  
393 393
                                    ORDER BY distance";
394 394
 
395
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
395
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
396 396
 
397
-                return $spotter_array;
398
-        }
397
+				return $spotter_array;
398
+		}
399 399
 
400 400
     
401
-        /**
402
-	* Gets all the spotter information based on a particular callsign
403
-	*
404
-	* @return Array the spotter information
405
-	*
406
-	*/
401
+		/**
402
+		 * Gets all the spotter information based on a particular callsign
403
+		 *
404
+		 * @return Array the spotter information
405
+		 *
406
+		 */
407 407
 	public function getLastLiveSpotterDataByIdent($ident)
408 408
 	{
409 409
 		$Spotter = new Spotter($this->db);
410 410
 		date_default_timezone_set('UTC');
411 411
 
412 412
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
413
-                $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';
413
+				$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';
414 414
 
415 415
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
416 416
 
417 417
 		return $spotter_array;
418 418
 	}
419 419
 
420
-        /**
421
-	* Gets all the spotter information based on a particular callsign
422
-	*
423
-	* @return Array the spotter information
424
-	*
425
-	*/
420
+		/**
421
+		 * Gets all the spotter information based on a particular callsign
422
+		 *
423
+		 * @return Array the spotter information
424
+		 *
425
+		 */
426 426
 	public function getDateLiveSpotterDataByIdent($ident,$date)
427 427
 	{
428 428
 		$Spotter = new Spotter($this->db);
429 429
 		date_default_timezone_set('UTC');
430 430
 
431 431
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
432
-                $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';
432
+				$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';
433 433
 
434
-                $date = date('c',$date);
434
+				$date = date('c',$date);
435 435
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
436 436
 
437 437
 		return $spotter_array;
438 438
 	}
439 439
 
440
-        /**
441
-	* Gets last spotter information based on a particular callsign
442
-	*
443
-	* @return Array the spotter information
444
-	*
445
-	*/
440
+		/**
441
+		 * Gets last spotter information based on a particular callsign
442
+		 *
443
+		 * @return Array the spotter information
444
+		 *
445
+		 */
446 446
 	public function getLastLiveSpotterDataById($id)
447 447
 	{
448 448
 		$Spotter = new Spotter($this->db);
449 449
 		date_default_timezone_set('UTC');
450 450
 
451 451
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
452
-                $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';
452
+				$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';
453 453
 
454 454
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
455 455
 
456 456
 		return $spotter_array;
457 457
 	}
458 458
 
459
-        /**
460
-	* Gets last spotter information based on a particular callsign
461
-	*
462
-	* @return Array the spotter information
463
-	*
464
-	*/
459
+		/**
460
+		 * Gets last spotter information based on a particular callsign
461
+		 *
462
+		 * @return Array the spotter information
463
+		 *
464
+		 */
465 465
 	public function getDateLiveSpotterDataById($id,$date)
466 466
 	{
467 467
 		$Spotter = new Spotter($this->db);
468 468
 		date_default_timezone_set('UTC');
469 469
 
470 470
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
471
-                $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';
472
-                $date = date('c',$date);
471
+				$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';
472
+				$date = date('c',$date);
473 473
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
474 474
 
475 475
 		return $spotter_array;
476 476
 	}
477 477
 
478
-        /**
479
-	* Gets altitude information based on a particular callsign
480
-	*
481
-	* @return Array the spotter information
482
-	*
483
-	*/
478
+		/**
479
+		 * Gets altitude information based on a particular callsign
480
+		 *
481
+		 * @return Array the spotter information
482
+		 *
483
+		 */
484 484
 	public function getAltitudeLiveSpotterDataByIdent($ident)
485 485
 	{
486 486
 
487 487
 		date_default_timezone_set('UTC');
488 488
 
489 489
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
490
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
490
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
491 491
 
492
-    		try {
492
+			try {
493 493
 			
494 494
 			$sth = $this->db->prepare($query);
495 495
 			$sth->execute(array(':ident' => $ident));
@@ -502,12 +502,12 @@  discard block
 block discarded – undo
502 502
 		return $spotter_array;
503 503
 	}
504 504
 
505
-        /**
506
-	* Gets all the spotter information based on a particular id
507
-	*
508
-	* @return Array the spotter information
509
-	*
510
-	*/
505
+		/**
506
+		 * Gets all the spotter information based on a particular id
507
+		 *
508
+		 * @return Array the spotter information
509
+		 *
510
+		 */
511 511
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
512 512
 	{
513 513
 		global $globalDBdriver, $globalLiveInterval;
@@ -535,18 +535,18 @@  discard block
 block discarded – undo
535 535
 		return $spotter_array;
536 536
 	}
537 537
 
538
-        /**
539
-	* Gets all the spotter information based on a particular ident
540
-	*
541
-	* @return Array the spotter information
542
-	*
543
-	*/
538
+		/**
539
+		 * Gets all the spotter information based on a particular ident
540
+		 *
541
+		 * @return Array the spotter information
542
+		 *
543
+		 */
544 544
 	public function getAllLiveSpotterDataByIdent($ident)
545 545
 	{
546 546
 		date_default_timezone_set('UTC');
547 547
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
548 548
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
549
-    		try {
549
+			try {
550 550
 			
551 551
 			$sth = $this->db->prepare($query);
552 552
 			$sth->execute(array(':ident' => $ident));
@@ -560,23 +560,23 @@  discard block
 block discarded – undo
560 560
 
561 561
 
562 562
 	/**
563
-	* Deletes all info in the table
564
-	*
565
-	* @return String success or false
566
-	*
567
-	*/
563
+	 * Deletes all info in the table
564
+	 *
565
+	 * @return String success or false
566
+	 *
567
+	 */
568 568
 	public function deleteLiveSpotterData()
569 569
 	{
570 570
 		global $globalDBdriver;
571 571
 		if ($globalDBdriver == 'mysql') {
572 572
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
573 573
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
574
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
574
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
575 575
 		} else {
576 576
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
577 577
 		}
578 578
         
579
-    		try {
579
+			try {
580 580
 			
581 581
 			$sth = $this->db->prepare($query);
582 582
 			$sth->execute();
@@ -588,18 +588,18 @@  discard block
 block discarded – undo
588 588
 	}
589 589
 
590 590
 	/**
591
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
592
-	*
593
-	* @return String success or false
594
-	*
595
-	*/
591
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
592
+	 *
593
+	 * @return String success or false
594
+	 *
595
+	 */
596 596
 	public function deleteLiveSpotterDataNotUpdated()
597 597
 	{
598 598
 		global $globalDBdriver, $globalDebug;
599 599
 		if ($globalDBdriver == 'mysql') {
600 600
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
601
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
602
-    			try {
601
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
602
+				try {
603 603
 				
604 604
 				$sth = $this->db->prepare($query);
605 605
 				$sth->execute();
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 				return "error";
608 608
 			}
609 609
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
610
-                        $i = 0;
611
-                        $j =0;
610
+						$i = 0;
611
+						$j =0;
612 612
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
613 613
 			foreach($all as $row)
614 614
 			{
@@ -616,20 +616,20 @@  discard block
 block discarded – undo
616 616
 				$j++;
617 617
 				if ($j == 30) {
618 618
 					if ($globalDebug) echo ".";
619
-				    	try {
619
+						try {
620 620
 						
621 621
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
622 622
 						$sth->execute();
623 623
 					} catch(PDOException $e) {
624 624
 						return "error";
625 625
 					}
626
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
627
-                                	$j = 0;
626
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
627
+									$j = 0;
628 628
 				}
629 629
 				$query_delete .= "'".$row['flightaware_id']."',";
630 630
 			}
631 631
 			if ($i > 0) {
632
-    				try {
632
+					try {
633 633
 					
634 634
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
635 635
 					$sth->execute();
@@ -640,9 +640,9 @@  discard block
 block discarded – undo
640 640
 			return "success";
641 641
 		} elseif ($globalDBdriver == 'pgsql') {
642 642
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
643
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
644
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
645
-    			try {
643
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
644
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
645
+				try {
646 646
 				
647 647
 				$sth = $this->db->prepare($query);
648 648
 				$sth->execute();
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 	}
687 687
 
688 688
 	/**
689
-	* Deletes all info in the table for an ident
690
-	*
691
-	* @return String success or false
692
-	*
693
-	*/
689
+	 * Deletes all info in the table for an ident
690
+	 *
691
+	 * @return String success or false
692
+	 *
693
+	 */
694 694
 	public function deleteLiveSpotterDataByIdent($ident)
695 695
 	{
696 696
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
697 697
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
698 698
         
699
-    		try {
699
+			try {
700 700
 			
701 701
 			$sth = $this->db->prepare($query);
702 702
 			$sth->execute(array(':ident' => $ident));
@@ -708,17 +708,17 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 
710 710
 	/**
711
-	* Deletes all info in the table for an id
712
-	*
713
-	* @return String success or false
714
-	*
715
-	*/
711
+	 * Deletes all info in the table for an id
712
+	 *
713
+	 * @return String success or false
714
+	 *
715
+	 */
716 716
 	public function deleteLiveSpotterDataById($id)
717 717
 	{
718 718
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
719 719
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
720 720
         
721
-    		try {
721
+			try {
722 722
 			
723 723
 			$sth = $this->db->prepare($query);
724 724
 			$sth->execute(array(':id' => $id));
@@ -731,11 +731,11 @@  discard block
 block discarded – undo
731 731
 
732 732
 
733 733
 	/**
734
-	* Gets the aircraft ident within the last hour
735
-	*
736
-	* @return String the ident
737
-	*
738
-	*/
734
+	 * Gets the aircraft ident within the last hour
735
+	 *
736
+	 * @return String the ident
737
+	 *
738
+	 */
739 739
 	public function getIdentFromLastHour($ident)
740 740
 	{
741 741
 		global $globalDBdriver, $globalTimezone;
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 			$ident_result = $row['ident'];
762 762
 		}
763 763
 		return $ident_result;
764
-        }
764
+		}
765 765
 
766 766
 	/**
767
-	* Check recent aircraft
768
-	*
769
-	* @return String the ident
770
-	*
771
-	*/
767
+	 * Check recent aircraft
768
+	 *
769
+	 * @return String the ident
770
+	 *
771
+	 */
772 772
 	public function checkIdentRecent($ident)
773 773
 	{
774 774
 		global $globalDBdriver, $globalTimezone;
@@ -794,14 +794,14 @@  discard block
 block discarded – undo
794 794
 			$ident_result = $row['flightaware_id'];
795 795
 		}
796 796
 		return $ident_result;
797
-        }
797
+		}
798 798
 
799 799
 	/**
800
-	* Check recent aircraft by id
801
-	*
802
-	* @return String the ident
803
-	*
804
-	*/
800
+	 * Check recent aircraft by id
801
+	 *
802
+	 * @return String the ident
803
+	 *
804
+	 */
805 805
 	public function checkIdRecent($id)
806 806
 	{
807 807
 		global $globalDBdriver, $globalTimezone;
@@ -827,14 +827,14 @@  discard block
 block discarded – undo
827 827
 			$ident_result = $row['flightaware_id'];
828 828
 		}
829 829
 		return $ident_result;
830
-        }
830
+		}
831 831
 
832 832
 	/**
833
-	* Check recent aircraft by ModeS
834
-	*
835
-	* @return String the ModeS
836
-	*
837
-	*/
833
+	 * Check recent aircraft by ModeS
834
+	 *
835
+	 * @return String the ModeS
836
+	 *
837
+	 */
838 838
 	public function checkModeSRecent($modes)
839 839
 	{
840 840
 		global $globalDBdriver, $globalTimezone;
@@ -861,19 +861,19 @@  discard block
 block discarded – undo
861 861
 			$ident_result = $row['flightaware_id'];
862 862
 		}
863 863
 		return $ident_result;
864
-        }
864
+		}
865 865
 
866 866
 	/**
867
-	* Adds a new spotter data
868
-	*
869
-	* @param String $flightaware_id the ID from flightaware
870
-	* @param String $ident the flight ident
871
-	* @param String $aircraft_icao the aircraft type
872
-	* @param String $departure_airport_icao the departure airport
873
-	* @param String $arrival_airport_icao the arrival airport
874
-	* @return String success or false
875
-	*
876
-	*/
867
+	 * Adds a new spotter data
868
+	 *
869
+	 * @param String $flightaware_id the ID from flightaware
870
+	 * @param String $ident the flight ident
871
+	 * @param String $aircraft_icao the aircraft type
872
+	 * @param String $departure_airport_icao the departure airport
873
+	 * @param String $arrival_airport_icao the arrival airport
874
+	 * @return String success or false
875
+	 *
876
+	 */
877 877
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '')
878 878
 	{
879 879
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1008,10 +1008,10 @@  discard block
 block discarded – undo
1008 1008
 		$arrival_airport_country = '';
1009 1009
 		
1010 1010
             	
1011
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1012
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1013
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1014
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1011
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1012
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1013
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1014
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1015 1015
             	
1016 1016
 		$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) 
1017 1017
 		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)';
@@ -1021,14 +1021,14 @@  discard block
 block discarded – undo
1021 1021
 			
1022 1022
 			$sth = $this->db->prepare($query);
1023 1023
 			$sth->execute($query_values);
1024
-                } catch(PDOException $e) {
1025
-                	return "error : ".$e->getMessage();
1026
-                }
1024
+				} catch(PDOException $e) {
1025
+					return "error : ".$e->getMessage();
1026
+				}
1027 1027
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1028
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1029
-		    $SpotterArchive = new SpotterArchive($this->db);
1030
-		    $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);
1031
-		    if ($globalDebug) echo $result.')';
1028
+			if ($globalDebug) echo '(Add to SBS archive : ';
1029
+			$SpotterArchive = new SpotterArchive($this->db);
1030
+			$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);
1031
+			if ($globalDebug) echo $result.')';
1032 1032
 		}
1033 1033
 		return "success";
1034 1034
 
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  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, $globalDBdriver;
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 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$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'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
39
+						$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'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40 40
 					} else {
41
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
47
+					$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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48 48
 				} else {
49
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55 55
 				} else {
56
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62 62
 				} else {
63
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64 64
 				}
65 65
 			}
66 66
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
68
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
74
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$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 ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
116
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		} else {
169 169
 			$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;
170 170
 		}
171
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
171
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
172 172
 
173 173
 		return $spotter_array;
174 174
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		global $globalDBdriver, $globalLiveInterval;
185 185
 		date_default_timezone_set('UTC');
186 186
 
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 
189 189
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190 190
 		if ($globalDBdriver == 'mysql') {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			$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 
196 196
 			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";
197 197
 */
198
-			$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, spotter_live.date, spotter_live.format_source 
198
+			$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, spotter_live.date, spotter_live.format_source 
199 199
 			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." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
200 200
 
201 201
 //			$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;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			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'";
211 211
 */
212 212
 
213
-			$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, spotter_live.date, spotter_live.format_source 
213
+			$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, spotter_live.date, spotter_live.format_source 
214 214
 			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." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
215 215
 
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		global $globalDBdriver, $globalLiveInterval;
242 242
 		date_default_timezone_set('UTC');
243 243
 
244
-		$filter_query = $this->getFilter($filter,true,true);
244
+		$filter_query = $this->getFilter($filter, true, true);
245 245
 
246 246
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
247 247
 		if ($globalDBdriver == 'mysql') {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			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' 
251 251
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
252 252
 */
253
-			$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, spotter_live.date, spotter_live.format_source 
253
+			$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, spotter_live.date, spotter_live.format_source 
254 254
 			FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
255 255
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
256 256
                 } else {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			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' 
260 260
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
261 261
 */
262
-			$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, spotter_live.date, spotter_live.format_source 
262
+			$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, spotter_live.date, spotter_live.format_source 
263 263
 			FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
264 264
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
265 265
 //			echo $query;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	public function getLiveSpotterCount($filter = array())
286 286
 	{
287 287
 		global $globalDBdriver, $globalLiveInterval;
288
-		$filter_query = $this->getFilter($filter,true,true);
288
+		$filter_query = $this->getFilter($filter, true, true);
289 289
 
290 290
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291 291
 		if ($globalDBdriver == 'mysql') {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		try {
299 299
 			$sth = $this->db->prepare($query);
300 300
 			$sth->execute();
301
-		} catch(PDOException $e) {
301
+		} catch (PDOException $e) {
302 302
 			echo $e->getMessage();
303 303
 			die;
304 304
 		}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		$filter_query = $this->getFilter($filter);
322 322
 
323 323
 		if (is_array($coord)) {
324
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
327
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
328 328
 		} else return array();
329 329
 		if ($globalDBdriver == 'mysql') {
330 330
 			//$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.")";
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
                 if ($interval == '1m')
378 378
                 {
379 379
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
380
-                } else if ($interval == '15m'){
380
+                } else if ($interval == '15m') {
381 381
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
382 382
                 } 
383 383
             }
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
386 386
         }
387 387
 
388
-                $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 
388
+                $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 
389 389
                    WHERE spotter_live.latitude <> '' 
390 390
                                    AND spotter_live.longitude <> '' 
391 391
                    ".$additional_query."
392 392
                    HAVING distance < :radius  
393 393
                                    ORDER BY distance";
394 394
 
395
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
395
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
396 396
 
397 397
                 return $spotter_array;
398 398
         }
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 		date_default_timezone_set('UTC');
411 411
 
412 412
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
413
-                $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';
413
+                $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';
414 414
 
415
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
415
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
416 416
 
417 417
 		return $spotter_array;
418 418
 	}
@@ -423,16 +423,16 @@  discard block
 block discarded – undo
423 423
 	* @return Array the spotter information
424 424
 	*
425 425
 	*/
426
-	public function getDateLiveSpotterDataByIdent($ident,$date)
426
+	public function getDateLiveSpotterDataByIdent($ident, $date)
427 427
 	{
428 428
 		$Spotter = new Spotter($this->db);
429 429
 		date_default_timezone_set('UTC');
430 430
 
431 431
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
432
-                $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';
432
+                $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';
433 433
 
434
-                $date = date('c',$date);
435
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
434
+                $date = date('c', $date);
435
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
436 436
 
437 437
 		return $spotter_array;
438 438
 	}
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 		date_default_timezone_set('UTC');
450 450
 
451 451
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
452
-                $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';
452
+                $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';
453 453
 
454
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
454
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
455 455
 
456 456
 		return $spotter_array;
457 457
 	}
@@ -462,15 +462,15 @@  discard block
 block discarded – undo
462 462
 	* @return Array the spotter information
463 463
 	*
464 464
 	*/
465
-	public function getDateLiveSpotterDataById($id,$date)
465
+	public function getDateLiveSpotterDataById($id, $date)
466 466
 	{
467 467
 		$Spotter = new Spotter($this->db);
468 468
 		date_default_timezone_set('UTC');
469 469
 
470 470
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
471
-                $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';
472
-                $date = date('c',$date);
473
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
471
+                $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';
472
+                $date = date('c', $date);
473
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
474 474
 
475 475
 		return $spotter_array;
476 476
 	}
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
 		date_default_timezone_set('UTC');
488 488
 
489 489
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
490
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
490
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
491 491
 
492 492
     		try {
493 493
 			
494 494
 			$sth = $this->db->prepare($query);
495 495
 			$sth->execute(array(':ident' => $ident));
496
-		} catch(PDOException $e) {
496
+		} catch (PDOException $e) {
497 497
 			echo $e->getMessage();
498 498
 			die;
499 499
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 	* @return Array the spotter information
509 509
 	*
510 510
 	*/
511
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
511
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
512 512
 	{
513 513
 		global $globalDBdriver, $globalLiveInterval;
514 514
 		date_default_timezone_set('UTC');
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		try {
528 528
 			$sth = $this->db->prepare($query);
529 529
 			$sth->execute(array(':id' => $id));
530
-		} catch(PDOException $e) {
530
+		} catch (PDOException $e) {
531 531
 			echo $e->getMessage();
532 532
 			die;
533 533
 		}
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
 	{
546 546
 		date_default_timezone_set('UTC');
547 547
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
548
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
548
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
549 549
     		try {
550 550
 			
551 551
 			$sth = $this->db->prepare($query);
552 552
 			$sth->execute(array(':ident' => $ident));
553
-		} catch(PDOException $e) {
553
+		} catch (PDOException $e) {
554 554
 			echo $e->getMessage();
555 555
 			die;
556 556
 		}
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			
581 581
 			$sth = $this->db->prepare($query);
582 582
 			$sth->execute();
583
-		} catch(PDOException $e) {
583
+		} catch (PDOException $e) {
584 584
 			return "error";
585 585
 		}
586 586
 
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
 				
604 604
 				$sth = $this->db->prepare($query);
605 605
 				$sth->execute();
606
-			} catch(PDOException $e) {
606
+			} catch (PDOException $e) {
607 607
 				return "error";
608 608
 			}
609 609
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
610 610
                         $i = 0;
611
-                        $j =0;
611
+                        $j = 0;
612 612
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
613
-			foreach($all as $row)
613
+			foreach ($all as $row)
614 614
 			{
615 615
 				$i++;
616 616
 				$j++;
@@ -618,9 +618,9 @@  discard block
 block discarded – undo
618 618
 					if ($globalDebug) echo ".";
619 619
 				    	try {
620 620
 						
621
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
621
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
622 622
 						$sth->execute();
623
-					} catch(PDOException $e) {
623
+					} catch (PDOException $e) {
624 624
 						return "error";
625 625
 					}
626 626
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 			if ($i > 0) {
632 632
     				try {
633 633
 					
634
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
634
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
635 635
 					$sth->execute();
636
-				} catch(PDOException $e) {
636
+				} catch (PDOException $e) {
637 637
 					return "error";
638 638
 				}
639 639
 			}
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 				
647 647
 				$sth = $this->db->prepare($query);
648 648
 				$sth->execute();
649
-			} catch(PDOException $e) {
649
+			} catch (PDOException $e) {
650 650
 				return "error";
651 651
 			}
652 652
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 	public function deleteLiveSpotterDataByIdent($ident)
695 695
 	{
696 696
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
697
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
697
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
698 698
         
699 699
     		try {
700 700
 			
701 701
 			$sth = $this->db->prepare($query);
702 702
 			$sth->execute(array(':ident' => $ident));
703
-		} catch(PDOException $e) {
703
+		} catch (PDOException $e) {
704 704
 			return "error";
705 705
 		}
706 706
 
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 	public function deleteLiveSpotterDataById($id)
717 717
 	{
718 718
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
719
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
719
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
720 720
         
721 721
     		try {
722 722
 			
723 723
 			$sth = $this->db->prepare($query);
724 724
 			$sth->execute(array(':id' => $id));
725
-		} catch(PDOException $e) {
725
+		} catch (PDOException $e) {
726 726
 			return "error";
727 727
 		}
728 728
 
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 	{
741 741
 		global $globalDBdriver, $globalTimezone;
742 742
 		if ($globalDBdriver == 'mysql') {
743
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
743
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
744 744
 				WHERE spotter_live.ident = :ident 
745 745
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
746 746
 				AND spotter_live.date < UTC_TIMESTAMP()';
747 747
 			$query_data = array(':ident' => $ident);
748 748
 		} else {
749
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
749
+			$query = "SELECT spotter_live.ident FROM spotter_live 
750 750
 				WHERE spotter_live.ident = :ident 
751 751
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
752 752
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 		
756 756
 		$sth = $this->db->prepare($query);
757 757
 		$sth->execute($query_data);
758
-		$ident_result='';
759
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
758
+		$ident_result = '';
759
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
760 760
 		{
761 761
 			$ident_result = $row['ident'];
762 762
 		}
@@ -773,13 +773,13 @@  discard block
 block discarded – undo
773 773
 	{
774 774
 		global $globalDBdriver, $globalTimezone;
775 775
 		if ($globalDBdriver == 'mysql') {
776
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
776
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
777 777
 				WHERE spotter_live.ident = :ident 
778 778
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
779 779
 //				AND spotter_live.date < UTC_TIMESTAMP()";
780 780
 			$query_data = array(':ident' => $ident);
781 781
 		} else {
782
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
782
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
783 783
 				WHERE spotter_live.ident = :ident 
784 784
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
785 785
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 		
789 789
 		$sth = $this->db->prepare($query);
790 790
 		$sth->execute($query_data);
791
-		$ident_result='';
792
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
791
+		$ident_result = '';
792
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
793 793
 		{
794 794
 			$ident_result = $row['flightaware_id'];
795 795
 		}
@@ -806,13 +806,13 @@  discard block
 block discarded – undo
806 806
 	{
807 807
 		global $globalDBdriver, $globalTimezone;
808 808
 		if ($globalDBdriver == 'mysql') {
809
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
809
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
810 810
 				WHERE spotter_live.flightaware_id = :id 
811 811
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
812 812
 //				AND spotter_live.date < UTC_TIMESTAMP()";
813 813
 			$query_data = array(':id' => $id);
814 814
 		} else {
815
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
815
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
816 816
 				WHERE spotter_live.flightaware_id = :id 
817 817
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
818 818
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 		
822 822
 		$sth = $this->db->prepare($query);
823 823
 		$sth->execute($query_data);
824
-		$ident_result='';
825
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
824
+		$ident_result = '';
825
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
826 826
 		{
827 827
 			$ident_result = $row['flightaware_id'];
828 828
 		}
@@ -839,13 +839,13 @@  discard block
 block discarded – undo
839 839
 	{
840 840
 		global $globalDBdriver, $globalTimezone;
841 841
 		if ($globalDBdriver == 'mysql') {
842
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
842
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
843 843
 				WHERE spotter_live.ModeS = :modes 
844 844
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
845 845
 //				AND spotter_live.date < UTC_TIMESTAMP()";
846 846
 			$query_data = array(':modes' => $modes);
847 847
 		} else {
848
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
848
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
849 849
 				WHERE spotter_live.ModeS = :modes 
850 850
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
851 851
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 		
855 855
 		$sth = $this->db->prepare($query);
856 856
 		$sth->execute($query_data);
857
-		$ident_result='';
858
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
857
+		$ident_result = '';
858
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
859 859
 		{
860 860
 			//$ident_result = $row['spotter_live_id'];
861 861
 			$ident_result = $row['flightaware_id'];
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 	* @return String success or false
875 875
 	*
876 876
 	*/
877
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '')
877
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $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 = '')
878 878
 	{
879 879
 		global $globalURL, $globalArchive, $globalDebug;
880 880
 		$Common = new Common();
@@ -967,26 +967,26 @@  discard block
 block discarded – undo
967 967
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
968 968
 
969 969
         
970
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
971
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
972
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
973
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
974
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
975
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
976
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
977
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
978
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
979
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
980
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
981
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
982
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
983
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
984
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
985
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
986
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
987
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
988
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
989
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
970
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
971
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
972
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
973
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
974
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
975
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
976
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
977
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
978
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
979
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
980
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
981
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
982
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
983
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
984
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
985
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
986
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
987
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
988
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
989
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
990 990
 
991 991
 		$airline_name = '';
992 992
 		$airline_icao = '';
@@ -1008,26 +1008,26 @@  discard block
 block discarded – undo
1008 1008
 		$arrival_airport_country = '';
1009 1009
 		
1010 1010
             	
1011
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1012
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1013
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1014
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1011
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1012
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1013
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1014
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1015 1015
             	
1016
-		$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) 
1016
+		$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) 
1017 1017
 		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)';
1018 1018
 
1019
-		$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);
1019
+		$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);
1020 1020
 		try {
1021 1021
 			
1022 1022
 			$sth = $this->db->prepare($query);
1023 1023
 			$sth->execute($query_values);
1024
-                } catch(PDOException $e) {
1024
+                } catch (PDOException $e) {
1025 1025
                 	return "error : ".$e->getMessage();
1026 1026
                 }
1027 1027
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1028 1028
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1029 1029
 		    $SpotterArchive = new SpotterArchive($this->db);
1030
-		    $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);
1030
+		    $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);
1031 1031
 		    if ($globalDebug) echo $result.')';
1032 1032
 		}
1033 1033
 		return "success";
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
 	public function getOrderBy()
1038 1038
 	{
1039
-		$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"));
1039
+		$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"));
1040 1040
 		return $orderby;
1041 1041
 	}
1042 1042
 
Please login to merge, or discard this patch.
require/class.Spotter.php 2 patches
Indentation   +1455 added lines, -1455 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/**
58
-	* Get SQL query part for filter used
59
-	* @param Array $filter the filter
60
-	* @return Array the SQL part
61
-	*/
58
+	 * Get SQL query part for filter used
59
+	 * @param Array $filter the filter
60
+	 * @return Array the SQL part
61
+	 */
62 62
 	public function getFilter($filter = array(),$where = false,$and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Executes the SQL statements to get the spotter information
170
-	*
171
-	* @param String $query the SQL query
172
-	* @param Array $params parameter of the query
173
-	* @param String $limitQuery the limit query
174
-	* @return Array the spotter information
175
-	*
176
-	*/
169
+	 * Executes the SQL statements to get the spotter information
170
+	 *
171
+	 * @param String $query the SQL query
172
+	 * @param Array $params parameter of the query
173
+	 * @param String $limitQuery the limit query
174
+	 * @return Array the spotter information
175
+	 *
176
+	 */
177 177
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
178 178
 	{
179 179
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 343
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344 344
 					} else $temp_array['aircraft_shadow'] = 'default.png';
345
-                                } else {
346
-                            		$temp_array['aircraft_shadow'] = 'default.png';
345
+								} else {
346
+									$temp_array['aircraft_shadow'] = 'default.png';
347 347
 					$temp_array['aircraft_name'] = 'N/A';
348 348
 					$temp_array['aircraft_manufacturer'] = 'N/A';
349
-                            	}
349
+								}
350 350
 			}
351 351
 			$fromsource = NULL;
352 352
 			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 	
543 543
 	
544 544
 	/**
545
-	* Gets all the spotter information
546
-	*
547
-	* @return Array the spotter information
548
-	*
549
-	*/
545
+	 * Gets all the spotter information
546
+	 *
547
+	 * @return Array the spotter information
548
+	 *
549
+	 */
550 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;
@@ -893,11 +893,11 @@  discard block
 block discarded – undo
893 893
 	
894 894
 	
895 895
 	/**
896
-	* Gets all the spotter information based on the latest data entry
897
-	*
898
-	* @return Array the spotter information
899
-	*
900
-	*/
896
+	 * Gets all the spotter information based on the latest data entry
897
+	 *
898
+	 * @return Array the spotter information
899
+	 *
900
+	 */
901 901
 	public function getLatestSpotterData($limit = '', $sort = '', $filter = array())
902 902
 	{
903 903
 		global $global_query;
@@ -936,12 +936,12 @@  discard block
 block discarded – undo
936 936
 	}
937 937
     
938 938
     
939
-    /**
940
-	* Gets all the spotter information based on a user's latitude and longitude
941
-	*
942
-	* @return Array the spotter information
943
-	*
944
-	*/
939
+	/**
940
+	 * Gets all the spotter information based on a user's latitude and longitude
941
+	 *
942
+	 * @return Array the spotter information
943
+	 *
944
+	 */
945 945
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
946 946
 	{
947 947
 		date_default_timezone_set('UTC');
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				return false;
970 970
 			}
971 971
 		}
972
-    		$additional_query = '';
972
+			$additional_query = '';
973 973
 		if ($interval != "")
974 974
 		{
975 975
 			if (!is_string($interval))
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 	}
1010 1010
     
1011 1011
     
1012
-    /**
1013
-	* Gets all the spotter information sorted by the newest aircraft type
1014
-	*
1015
-	* @return Array the spotter information
1016
-	*
1017
-	*/
1012
+	/**
1013
+	 * Gets all the spotter information sorted by the newest aircraft type
1014
+	 *
1015
+	 * @return Array the spotter information
1016
+	 *
1017
+	 */
1018 1018
 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1019 1019
 	{
1020 1020
 		global $global_query;
@@ -1055,11 +1055,11 @@  discard block
 block discarded – undo
1055 1055
     
1056 1056
     
1057 1057
 	/**
1058
-	* Gets all the spotter information sorted by the newest aircraft registration
1059
-	*
1060
-	* @return Array the spotter information
1061
-	*
1062
-	*/
1058
+	 * Gets all the spotter information sorted by the newest aircraft registration
1059
+	 *
1060
+	 * @return Array the spotter information
1061
+	 *
1062
+	 */
1063 1063
 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array())
1064 1064
 	{
1065 1065
 		global $global_query;
@@ -1099,11 +1099,11 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 
1101 1101
 	/**
1102
-	* Gets all the spotter information sorted by the newest airline
1103
-	*
1104
-	* @return Array the spotter information
1105
-	*
1106
-	*/
1102
+	 * Gets all the spotter information sorted by the newest airline
1103
+	 *
1104
+	 * @return Array the spotter information
1105
+	 *
1106
+	 */
1107 1107
 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1108 1108
 	{
1109 1109
 		global $global_query;
@@ -1142,12 +1142,12 @@  discard block
 block discarded – undo
1142 1142
 	}
1143 1143
     
1144 1144
     
1145
-    /**
1146
-	* Gets all the spotter information sorted by the newest departure airport
1147
-	*
1148
-	* @return Array the spotter information
1149
-	*
1150
-	*/
1145
+	/**
1146
+	 * Gets all the spotter information sorted by the newest departure airport
1147
+	 *
1148
+	 * @return Array the spotter information
1149
+	 *
1150
+	 */
1151 1151
 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array())
1152 1152
 	{
1153 1153
 		global $global_query;
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 
1191 1191
 	/**
1192
-	* Gets all the spotter information sorted by the newest arrival airport
1193
-	*
1194
-	* @return Array the spotter information
1195
-	*
1196
-	*/
1192
+	 * Gets all the spotter information sorted by the newest arrival airport
1193
+	 *
1194
+	 * @return Array the spotter information
1195
+	 *
1196
+	 */
1197 1197
 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array())
1198 1198
 	{
1199 1199
 		global $global_query;
@@ -1232,11 +1232,11 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 
1234 1234
 	/**
1235
-	* Gets all the spotter information based on the spotter id
1236
-	*
1237
-	* @return Array the spotter information
1238
-	*
1239
-	*/
1235
+	 * Gets all the spotter information based on the spotter id
1236
+	 *
1237
+	 * @return Array the spotter information
1238
+	 *
1239
+	 */
1240 1240
 	public function getSpotterDataByID($id = '')
1241 1241
 	{
1242 1242
 		global $global_query;
@@ -1258,11 +1258,11 @@  discard block
 block discarded – undo
1258 1258
 	
1259 1259
 	
1260 1260
 	/**
1261
-	* Gets all the spotter information based on the callsign
1262
-	*
1263
-	* @return Array the spotter information
1264
-	*
1265
-	*/
1261
+	 * Gets all the spotter information based on the callsign
1262
+	 *
1263
+	 * @return Array the spotter information
1264
+	 *
1265
+	 */
1266 1266
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
1267 1267
 	{
1268 1268
 		global $global_query;
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
 	}
1315 1315
 	
1316 1316
 	/**
1317
-	* Gets all the spotter information based on the owner
1318
-	*
1319
-	* @return Array the spotter information
1320
-	*
1321
-	*/
1317
+	 * Gets all the spotter information based on the owner
1318
+	 *
1319
+	 * @return Array the spotter information
1320
+	 *
1321
+	 */
1322 1322
 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1323 1323
 	{
1324 1324
 		global $global_query;
@@ -1371,11 +1371,11 @@  discard block
 block discarded – undo
1371 1371
 	}
1372 1372
 	
1373 1373
 	/**
1374
-	* Gets all the spotter information based on the pilot
1375
-	*
1376
-	* @return Array the spotter information
1377
-	*
1378
-	*/
1374
+	 * Gets all the spotter information based on the pilot
1375
+	 *
1376
+	 * @return Array the spotter information
1377
+	 *
1378
+	 */
1379 1379
 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1380 1380
 	{
1381 1381
 		global $global_query;
@@ -1424,11 +1424,11 @@  discard block
 block discarded – undo
1424 1424
 	
1425 1425
 	
1426 1426
 	/**
1427
-	* Gets all the spotter information based on the aircraft type
1428
-	*
1429
-	* @return Array the spotter information
1430
-	*
1431
-	*/
1427
+	 * Gets all the spotter information based on the aircraft type
1428
+	 *
1429
+	 * @return Array the spotter information
1430
+	 *
1431
+	 */
1432 1432
 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array())
1433 1433
 	{
1434 1434
 		global $global_query;
@@ -1482,11 +1482,11 @@  discard block
 block discarded – undo
1482 1482
 	
1483 1483
 	
1484 1484
 	/**
1485
-	* Gets all the spotter information based on the aircraft registration
1486
-	*
1487
-	* @return Array the spotter information
1488
-	*
1489
-	*/
1485
+	 * Gets all the spotter information based on the aircraft registration
1486
+	 *
1487
+	 * @return Array the spotter information
1488
+	 *
1489
+	 */
1490 1490
 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array())
1491 1491
 	{
1492 1492
 		global $global_query;
@@ -1543,11 +1543,11 @@  discard block
 block discarded – undo
1543 1543
 	
1544 1544
 	
1545 1545
 	/**
1546
-	* Gets all the spotter information based on the airline
1547
-	*
1548
-	* @return Array the spotter information
1549
-	*
1550
-	*/
1546
+	 * Gets all the spotter information based on the airline
1547
+	 *
1548
+	 * @return Array the spotter information
1549
+	 *
1550
+	 */
1551 1551
 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1552 1552
 	{
1553 1553
 		global $global_query;
@@ -1600,11 +1600,11 @@  discard block
 block discarded – undo
1600 1600
 	
1601 1601
 	
1602 1602
 	/**
1603
-	* Gets all the spotter information based on the airport
1604
-	*
1605
-	* @return Array the spotter information
1606
-	*
1607
-	*/
1603
+	 * Gets all the spotter information based on the airport
1604
+	 *
1605
+	 * @return Array the spotter information
1606
+	 *
1607
+	 */
1608 1608
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1609 1609
 	{
1610 1610
 		global $global_query;
@@ -1658,11 +1658,11 @@  discard block
 block discarded – undo
1658 1658
 
1659 1659
 
1660 1660
 	/**
1661
-	* Gets all the spotter information based on the date
1662
-	*
1663
-	* @return Array the spotter information
1664
-	*
1665
-	*/
1661
+	 * Gets all the spotter information based on the date
1662
+	 *
1663
+	 * @return Array the spotter information
1664
+	 *
1665
+	 */
1666 1666
 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1667 1667
 	{
1668 1668
 		global $global_query, $globalTimezone, $globalDBdriver;
@@ -1726,11 +1726,11 @@  discard block
 block discarded – undo
1726 1726
 
1727 1727
 
1728 1728
 	/**
1729
-	* Gets all the spotter information based on the country name
1730
-	*
1731
-	* @return Array the spotter information
1732
-	*
1733
-	*/
1729
+	 * Gets all the spotter information based on the country name
1730
+	 *
1731
+	 * @return Array the spotter information
1732
+	 *
1733
+	 */
1734 1734
 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1735 1735
 	{
1736 1736
 		global $global_query;
@@ -1784,11 +1784,11 @@  discard block
 block discarded – undo
1784 1784
 	
1785 1785
 	
1786 1786
 	/**
1787
-	* Gets all the spotter information based on the manufacturer name
1788
-	*
1789
-	* @return Array the spotter information
1790
-	*
1791
-	*/
1787
+	 * Gets all the spotter information based on the manufacturer name
1788
+	 *
1789
+	 * @return Array the spotter information
1790
+	 *
1791
+	 */
1792 1792
 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array())
1793 1793
 	{
1794 1794
 		global $global_query;
@@ -1844,13 +1844,13 @@  discard block
 block discarded – undo
1844 1844
   
1845 1845
   
1846 1846
 	/**
1847
-	* Gets a list of all aircraft that take a route
1848
-	*
1849
-	* @param String $departure_airport_icao ICAO code of departure airport
1850
-	* @param String $arrival_airport_icao ICAO code of arrival airport
1851
-	* @return Array the spotter information
1852
-	*
1853
-	*/
1847
+	 * Gets a list of all aircraft that take a route
1848
+	 *
1849
+	 * @param String $departure_airport_icao ICAO code of departure airport
1850
+	 * @param String $arrival_airport_icao ICAO code of arrival airport
1851
+	 * @return Array the spotter information
1852
+	 *
1853
+	 */
1854 1854
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array())
1855 1855
 	{
1856 1856
 		global $global_query;
@@ -1919,11 +1919,11 @@  discard block
 block discarded – undo
1919 1919
 	
1920 1920
 	
1921 1921
 	/**
1922
-	* Gets all the spotter information based on the special column in the table
1923
-	*
1924
-	* @return Array the spotter information
1925
-	*
1926
-	*/
1922
+	 * Gets all the spotter information based on the special column in the table
1923
+	 *
1924
+	 * @return Array the spotter information
1925
+	 *
1926
+	 */
1927 1927
 	public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array())
1928 1928
 	{
1929 1929
 		global $global_query;
@@ -1962,11 +1962,11 @@  discard block
 block discarded – undo
1962 1962
 	}
1963 1963
 
1964 1964
 	/**
1965
-	* Gets all the highlight based on a aircraft registration
1966
-	*
1967
-	* @return String the highlight text
1968
-	*
1969
-	*/
1965
+	 * Gets all the highlight based on a aircraft registration
1966
+	 *
1967
+	 * @return String the highlight text
1968
+	 *
1969
+	 */
1970 1970
 	public function getHighlightByRegistration($registration,$filter = array())
1971 1971
 	{
1972 1972
 		global $global_query;
@@ -1988,13 +1988,13 @@  discard block
 block discarded – undo
1988 1988
 
1989 1989
 	
1990 1990
 	/**
1991
-	* Gets the squawk usage from squawk code
1992
-	*
1993
-	* @param String $squawk squawk code
1994
-	* @param String $country country
1995
-	* @return String usage
1996
-	*
1997
-	*/
1991
+	 * Gets the squawk usage from squawk code
1992
+	 *
1993
+	 * @param String $squawk squawk code
1994
+	 * @param String $country country
1995
+	 * @return String usage
1996
+	 *
1997
+	 */
1998 1998
 	public function getSquawkUsage($squawk = '',$country = 'FR')
1999 1999
 	{
2000 2000
 		
@@ -2015,12 +2015,12 @@  discard block
 block discarded – undo
2015 2015
 	}
2016 2016
 
2017 2017
 	/**
2018
-	* Gets the airport icao from the iata
2019
-	*
2020
-	* @param String $airport_iata the iata code of the airport
2021
-	* @return String airport iata
2022
-	*
2023
-	*/
2018
+	 * Gets the airport icao from the iata
2019
+	 *
2020
+	 * @param String $airport_iata the iata code of the airport
2021
+	 * @return String airport iata
2022
+	 *
2023
+	 */
2024 2024
 	public function getAirportIcao($airport_iata = '')
2025 2025
 	{
2026 2026
 		
@@ -2040,14 +2040,14 @@  discard block
 block discarded – undo
2040 2040
 	}
2041 2041
 
2042 2042
 	/**
2043
-	* Gets the airport distance
2044
-	*
2045
-	* @param String $airport_icao the icao code of the airport
2046
-	* @param Float $latitude the latitude
2047
-	* @param Float $longitude the longitude
2048
-	* @return Float distance to the airport
2049
-	*
2050
-	*/
2043
+	 * Gets the airport distance
2044
+	 *
2045
+	 * @param String $airport_icao the icao code of the airport
2046
+	 * @param Float $latitude the latitude
2047
+	 * @param Float $longitude the longitude
2048
+	 * @return Float distance to the airport
2049
+	 *
2050
+	 */
2051 2051
 	public function getAirportDistance($airport_icao,$latitude,$longitude)
2052 2052
 	{
2053 2053
 		
@@ -2068,12 +2068,12 @@  discard block
 block discarded – undo
2068 2068
 	}
2069 2069
 	
2070 2070
 	/**
2071
-	* Gets the airport info based on the icao
2072
-	*
2073
-	* @param String $airport the icao code of the airport
2074
-	* @return Array airport information
2075
-	*
2076
-	*/
2071
+	 * Gets the airport info based on the icao
2072
+	 *
2073
+	 * @param String $airport the icao code of the airport
2074
+	 * @return Array airport information
2075
+	 *
2076
+	 */
2077 2077
 	public function getAllAirportInfo($airport = '')
2078 2078
 	{
2079 2079
 		
@@ -2119,12 +2119,12 @@  discard block
 block discarded – undo
2119 2119
 	}
2120 2120
 	
2121 2121
 	/**
2122
-	* Gets the airport info based on the country
2123
-	*
2124
-	* @param Array $countries Airports countries
2125
-	* @return Array airport information
2126
-	*
2127
-	*/
2122
+	 * Gets the airport info based on the country
2123
+	 *
2124
+	 * @param Array $countries Airports countries
2125
+	 * @return Array airport information
2126
+	 *
2127
+	 */
2128 2128
 	public function getAllAirportInfobyCountry($countries)
2129 2129
 	{
2130 2130
 		$lst_countries = '';
@@ -2162,12 +2162,12 @@  discard block
 block discarded – undo
2162 2162
 	}
2163 2163
 	
2164 2164
 	/**
2165
-	* Gets airports info based on the coord
2166
-	*
2167
-	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2168
-	* @return Array airport information
2169
-	*
2170
-	*/
2165
+	 * Gets airports info based on the coord
2166
+	 *
2167
+	 * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2168
+	 * @return Array airport information
2169
+	 *
2170
+	 */
2171 2171
 	public function getAllAirportInfobyCoord($coord)
2172 2172
 	{
2173 2173
 		global $globalDBdriver;
@@ -2198,12 +2198,12 @@  discard block
 block discarded – undo
2198 2198
 	}
2199 2199
 
2200 2200
 	/**
2201
-	* Gets waypoints info based on the coord
2202
-	*
2203
-	* @param Array $coord waypoints coord
2204
-	* @return Array airport information
2205
-	*
2206
-	*/
2201
+	 * Gets waypoints info based on the coord
2202
+	 *
2203
+	 * @param Array $coord waypoints coord
2204
+	 * @return Array airport information
2205
+	 *
2206
+	 */
2207 2207
 	public function getAllWaypointsInfobyCoord($coord)
2208 2208
 	{
2209 2209
 		if (is_array($coord)) {
@@ -2237,12 +2237,12 @@  discard block
 block discarded – undo
2237 2237
 	
2238 2238
 	
2239 2239
 	/**
2240
-	* Gets the airline info based on the icao code or iata code
2241
-	*
2242
-	* @param String $airline_icao the iata code of the airport
2243
-	* @return Array airport information
2244
-	*
2245
-	*/
2240
+	 * Gets the airline info based on the icao code or iata code
2241
+	 *
2242
+	 * @param String $airline_icao the iata code of the airport
2243
+	 * @return Array airport information
2244
+	 *
2245
+	 */
2246 2246
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2247
 	{
2248 2248
 		global $globalUseRealAirlines;
@@ -2273,7 +2273,7 @@  discard block
 block discarded – undo
2273 2273
 			} else {
2274 2274
 				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2275 2275
 			}
2276
-                        /*
2276
+						/*
2277 2277
 			$airline_array = array();
2278 2278
 			$temp_array = array();
2279 2279
 		
@@ -2306,12 +2306,12 @@  discard block
 block discarded – undo
2306 2306
 	}
2307 2307
 	
2308 2308
 	/**
2309
-	* Gets the airline info based on the airline name
2310
-	*
2311
-	* @param String $airline_name the name of the airline
2312
-	* @return Array airline information
2313
-	*
2314
-	*/
2309
+	 * Gets the airline info based on the airline name
2310
+	 *
2311
+	 * @param String $airline_name the name of the airline
2312
+	 * @return Array airline information
2313
+	 *
2314
+	 */
2315 2315
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2316
 	{
2317 2317
 		global $globalUseRealAirlines;
@@ -2339,12 +2339,12 @@  discard block
 block discarded – undo
2339 2339
 	
2340 2340
 	
2341 2341
 	/**
2342
-	* Gets the aircraft info based on the aircraft type
2343
-	*
2344
-	* @param String $aircraft_type the aircraft type
2345
-	* @return Array aircraft information
2346
-	*
2347
-	*/
2342
+	 * Gets the aircraft info based on the aircraft type
2343
+	 *
2344
+	 * @param String $aircraft_type the aircraft type
2345
+	 * @return Array aircraft information
2346
+	 *
2347
+	 */
2348 2348
 	public function getAllAircraftInfo($aircraft_type)
2349 2349
 	{
2350 2350
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2376,12 +2376,12 @@  discard block
 block discarded – undo
2376 2376
 	}
2377 2377
 
2378 2378
 	/**
2379
-	* Gets the aircraft icao based on the aircraft name/type
2380
-	*
2381
-	* @param String $aircraft_type the aircraft type
2382
-	* @return String aircraft information
2383
-	*
2384
-	*/
2379
+	 * Gets the aircraft icao based on the aircraft name/type
2380
+	 *
2381
+	 * @param String $aircraft_type the aircraft type
2382
+	 * @return String aircraft information
2383
+	 *
2384
+	 */
2385 2385
 	public function getAircraftIcao($aircraft_type)
2386 2386
 	{
2387 2387
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2406,12 +2406,12 @@  discard block
 block discarded – undo
2406 2406
 	}
2407 2407
 	
2408 2408
 	/**
2409
-	* Gets the aircraft info based on the aircraft modes
2410
-	*
2411
-	* @param String $aircraft_modes the aircraft ident (hex)
2412
-	* @return String aircraft type
2413
-	*
2414
-	*/
2409
+	 * Gets the aircraft info based on the aircraft modes
2410
+	 *
2411
+	 * @param String $aircraft_modes the aircraft ident (hex)
2412
+	 * @return String aircraft type
2413
+	 *
2414
+	 */
2415 2415
 	public function getAllAircraftType($aircraft_modes,$source_type = '')
2416 2416
 	{
2417 2417
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -2438,12 +2438,12 @@  discard block
 block discarded – undo
2438 2438
 	}
2439 2439
 
2440 2440
 	/**
2441
-	* Gets the aircraft info based on the aircraft registration
2442
-	*
2443
-	* @param String $registration the aircraft registration
2444
-	* @return String aircraft type
2445
-	*
2446
-	*/
2441
+	 * Gets the aircraft info based on the aircraft registration
2442
+	 *
2443
+	 * @param String $registration the aircraft registration
2444
+	 * @return String aircraft type
2445
+	 *
2446
+	 */
2447 2447
 	public function getAllAircraftTypeByRegistration($registration)
2448 2448
 	{
2449 2449
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2461,12 +2461,12 @@  discard block
 block discarded – undo
2461 2461
 	}
2462 2462
 
2463 2463
 	/**
2464
-	* Gets the spotter_id and flightaware_id based on the aircraft registration
2465
-	*
2466
-	* @param String $registration the aircraft registration
2467
-	* @return Array spotter_id and flightaware_id
2468
-	*
2469
-	*/
2464
+	 * Gets the spotter_id and flightaware_id based on the aircraft registration
2465
+	 *
2466
+	 * @param String $registration the aircraft registration
2467
+	 * @return Array spotter_id and flightaware_id
2468
+	 *
2469
+	 */
2470 2470
 	public function getAllIDByRegistration($registration)
2471 2471
 	{
2472 2472
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2485,12 +2485,12 @@  discard block
 block discarded – undo
2485 2485
 	}
2486 2486
 
2487 2487
 	/**
2488
-	* Gets correct aircraft operator code
2489
-	*
2490
-	* @param String $operator the aircraft operator code (callsign)
2491
-	* @return String aircraft operator code
2492
-	*
2493
-	*/
2488
+	 * Gets correct aircraft operator code
2489
+	 *
2490
+	 * @param String $operator the aircraft operator code (callsign)
2491
+	 * @return String aircraft operator code
2492
+	 *
2493
+	 */
2494 2494
 	public function getOperator($operator)
2495 2495
 	{
2496 2496
 		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
@@ -2507,16 +2507,16 @@  discard block
 block discarded – undo
2507 2507
 	}
2508 2508
 
2509 2509
 	/**
2510
-	* Gets the aircraft route based on the aircraft callsign
2511
-	*
2512
-	* @param String $callsign the aircraft callsign
2513
-	* @return Array aircraft type
2514
-	*
2515
-	*/
2510
+	 * Gets the aircraft route based on the aircraft callsign
2511
+	 *
2512
+	 * @param String $callsign the aircraft callsign
2513
+	 * @return Array aircraft type
2514
+	 *
2515
+	 */
2516 2516
 	public function getRouteInfo($callsign)
2517 2517
 	{
2518 2518
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2519
+				if ($callsign == '') return array();
2520 2520
 		$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";
2521 2521
 		
2522 2522
 		$sth = $this->db->prepare($query);
@@ -2530,12 +2530,12 @@  discard block
 block discarded – undo
2530 2530
 	}
2531 2531
 	
2532 2532
 	/**
2533
-	* Gets the aircraft info based on the aircraft registration
2534
-	*
2535
-	* @param String $registration the aircraft registration
2536
-	* @return Array aircraft information
2537
-	*
2538
-	*/
2533
+	 * Gets the aircraft info based on the aircraft registration
2534
+	 *
2535
+	 * @param String $registration the aircraft registration
2536
+	 * @return Array aircraft information
2537
+	 *
2538
+	 */
2539 2539
 	public function getAircraftInfoByRegistration($registration)
2540 2540
 	{
2541 2541
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2562,12 +2562,12 @@  discard block
 block discarded – undo
2562 2562
 	}
2563 2563
 	
2564 2564
 	/**
2565
-	* Gets the aircraft owner & base based on the aircraft registration
2566
-	*
2567
-	* @param String $registration the aircraft registration
2568
-	* @return Array aircraft information
2569
-	*
2570
-	*/
2565
+	 * Gets the aircraft owner & base based on the aircraft registration
2566
+	 *
2567
+	 * @param String $registration the aircraft registration
2568
+	 * @return Array aircraft information
2569
+	 *
2570
+	 */
2571 2571
 	public function getAircraftOwnerByRegistration($registration)
2572 2572
 	{
2573 2573
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2584,11 +2584,11 @@  discard block
 block discarded – undo
2584 2584
 	
2585 2585
   
2586 2586
   /**
2587
-	* Gets all flights (but with only little info)
2588
-	*
2589
-	* @return Array basic flight information
2590
-	*
2591
-	*/
2587
+   * Gets all flights (but with only little info)
2588
+   *
2589
+   * @return Array basic flight information
2590
+   *
2591
+   */
2592 2592
 	public function getAllFlightsforSitemap()
2593 2593
 	{
2594 2594
 		//$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 ";
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
 		
2597 2597
 		$sth = $this->db->prepare($query);
2598 2598
 		$sth->execute();
2599
-                  /*
2599
+				  /*
2600 2600
 		$flight_array = array();
2601 2601
 		$temp_array = array();
2602 2602
 		
@@ -2618,11 +2618,11 @@  discard block
 block discarded – undo
2618 2618
 	}
2619 2619
   
2620 2620
 	/**
2621
-	* Gets a list of all aircraft manufacturers
2622
-	*
2623
-	* @return Array list of aircraft types
2624
-	*
2625
-	*/
2621
+	 * Gets a list of all aircraft manufacturers
2622
+	 *
2623
+	 * @return Array list of aircraft types
2624
+	 *
2625
+	 */
2626 2626
 	public function getAllManufacturers()
2627 2627
 	{
2628 2628
 		/*
@@ -2651,11 +2651,11 @@  discard block
 block discarded – undo
2651 2651
   
2652 2652
   
2653 2653
   /**
2654
-	* Gets a list of all aircraft types
2655
-	*
2656
-	* @return Array list of aircraft types
2657
-	*
2658
-	*/
2654
+   * Gets a list of all aircraft types
2655
+   *
2656
+   * @return Array list of aircraft types
2657
+   *
2658
+   */
2659 2659
 	public function getAllAircraftTypes($filters = array())
2660 2660
 	{
2661 2661
 		/*
@@ -2690,11 +2690,11 @@  discard block
 block discarded – undo
2690 2690
 	
2691 2691
 	
2692 2692
 	/**
2693
-	* Gets a list of all aircraft registrations
2694
-	*
2695
-	* @return Array list of aircraft registrations
2696
-	*
2697
-	*/
2693
+	 * Gets a list of all aircraft registrations
2694
+	 *
2695
+	 * @return Array list of aircraft registrations
2696
+	 *
2697
+	 */
2698 2698
 	public function getAllAircraftRegistrations($filters = array())
2699 2699
 	{
2700 2700
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2719,12 +2719,12 @@  discard block
 block discarded – undo
2719 2719
 	}
2720 2720
 
2721 2721
 	/**
2722
-	* Gets all source name
2723
-	*
2724
-	* @param String type format of source
2725
-	* @return Array list of source name
2726
-	*
2727
-	*/
2722
+	 * Gets all source name
2723
+	 *
2724
+	 * @param String type format of source
2725
+	 * @return Array list of source name
2726
+	 *
2727
+	 */
2728 2728
 	public function getAllSourceName($type = '',$filters = array())
2729 2729
 	{
2730 2730
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2755,11 +2755,11 @@  discard block
 block discarded – undo
2755 2755
 
2756 2756
 
2757 2757
 	/**
2758
-	* Gets a list of all airline names
2759
-	*
2760
-	* @return Array list of airline names
2761
-	*
2762
-	*/
2758
+	 * Gets a list of all airline names
2759
+	 *
2760
+	 * @return Array list of airline names
2761
+	 *
2762
+	 */
2763 2763
 	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2764 2764
 	{
2765 2765
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2808,11 +2808,11 @@  discard block
 block discarded – undo
2808 2808
 	}
2809 2809
 	
2810 2810
 	/**
2811
-	* Gets a list of all alliance names
2812
-	*
2813
-	* @return Array list of alliance names
2814
-	*
2815
-	*/
2811
+	 * Gets a list of all alliance names
2812
+	 *
2813
+	 * @return Array list of alliance names
2814
+	 *
2815
+	 */
2816 2816
 	public function getAllAllianceNames($forsource = NULL,$filters = array())
2817 2817
 	{
2818 2818
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2837,11 +2837,11 @@  discard block
 block discarded – undo
2837 2837
 	}
2838 2838
 	
2839 2839
 	/**
2840
-	* Gets a list of all airline countries
2841
-	*
2842
-	* @return Array list of airline countries
2843
-	*
2844
-	*/
2840
+	 * Gets a list of all airline countries
2841
+	 *
2842
+	 * @return Array list of airline countries
2843
+	 *
2844
+	 */
2845 2845
 	public function getAllAirlineCountries($filters = array())
2846 2846
 	{
2847 2847
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2869,11 +2869,11 @@  discard block
 block discarded – undo
2869 2869
 	
2870 2870
 	
2871 2871
 	/**
2872
-	* Gets a list of all departure & arrival names
2873
-	*
2874
-	* @return Array list of airport names
2875
-	*
2876
-	*/
2872
+	 * Gets a list of all departure & arrival names
2873
+	 *
2874
+	 * @return Array list of airport names
2875
+	 *
2876
+	 */
2877 2877
 	public function getAllAirportNames($filters = array())
2878 2878
 	{
2879 2879
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2921,11 +2921,11 @@  discard block
 block discarded – undo
2921 2921
 	} 
2922 2922
 
2923 2923
 	/**
2924
-	* Gets a list of all owner names
2925
-	*
2926
-	* @return Array list of owner names
2927
-	*
2928
-	*/
2924
+	 * Gets a list of all owner names
2925
+	 *
2926
+	 * @return Array list of owner names
2927
+	 *
2928
+	 */
2929 2929
 	public function getAllOwnerNames($filters = array())
2930 2930
 	{
2931 2931
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2939,11 +2939,11 @@  discard block
 block discarded – undo
2939 2939
 	} 
2940 2940
 
2941 2941
 	/**
2942
-	* Gets a list of all pilot names and pilot ids
2943
-	*
2944
-	* @return Array list of pilot names and pilot ids
2945
-	*
2946
-	*/
2942
+	 * Gets a list of all pilot names and pilot ids
2943
+	 *
2944
+	 * @return Array list of pilot names and pilot ids
2945
+	 *
2946
+	 */
2947 2947
 	public function getAllPilotNames($filters = array())
2948 2948
 	{
2949 2949
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2958,11 +2958,11 @@  discard block
 block discarded – undo
2958 2958
 	
2959 2959
 	
2960 2960
 	/**
2961
-	* Gets a list of all departure & arrival airport countries
2962
-	*
2963
-	* @return Array list of airport countries
2964
-	*
2965
-	*/
2961
+	 * Gets a list of all departure & arrival airport countries
2962
+	 *
2963
+	 * @return Array list of airport countries
2964
+	 *
2965
+	 */
2966 2966
 	public function getAllAirportCountries($filters = array())
2967 2967
 	{
2968 2968
 		$airport_array = array();
@@ -3010,11 +3010,11 @@  discard block
 block discarded – undo
3010 3010
 	
3011 3011
 	
3012 3012
 	/**
3013
-	* Gets a list of all countries (airline, departure airport & arrival airport)
3014
-	*
3015
-	* @return Array list of countries
3016
-	*
3017
-	*/
3013
+	 * Gets a list of all countries (airline, departure airport & arrival airport)
3014
+	 *
3015
+	 * @return Array list of countries
3016
+	 *
3017
+	 */
3018 3018
 	public function getAllCountries($filters = array())
3019 3019
 	{
3020 3020
 		$Connection= new Connection($this->db);
@@ -3091,11 +3091,11 @@  discard block
 block discarded – undo
3091 3091
 	
3092 3092
 	
3093 3093
 	/**
3094
-	* Gets a list of all idents/callsigns
3095
-	*
3096
-	* @return Array list of ident/callsign names
3097
-	*
3098
-	*/
3094
+	 * Gets a list of all idents/callsigns
3095
+	 *
3096
+	 * @return Array list of ident/callsign names
3097
+	 *
3098
+	 */
3099 3099
 	public function getAllIdents($filters = array())
3100 3100
 	{
3101 3101
 		$filter_query = $this->getFilter($filters,true,true);
@@ -3119,9 +3119,9 @@  discard block
 block discarded – undo
3119 3119
 	}
3120 3120
 
3121 3121
 	/**
3122
-	* Get a list of flights from airport since 7 days
3123
-	* @return Array number, icao, name and city of airports
3124
-	*/
3122
+	 * Get a list of flights from airport since 7 days
3123
+	 * @return Array number, icao, name and city of airports
3124
+	 */
3125 3125
 
3126 3126
 	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3127 3127
 		global $globalTimezone, $globalDBdriver;
@@ -3152,9 +3152,9 @@  discard block
 block discarded – undo
3152 3152
 	}
3153 3153
 
3154 3154
 	/**
3155
-	* Get a list of flights from airport since 7 days
3156
-	* @return Array number, icao, name and city of airports
3157
-	*/
3155
+	 * Get a list of flights from airport since 7 days
3156
+	 * @return Array number, icao, name and city of airports
3157
+	 */
3158 3158
 
3159 3159
 	public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') {
3160 3160
 		global $globalTimezone, $globalDBdriver;
@@ -3184,9 +3184,9 @@  discard block
 block discarded – undo
3184 3184
 	}
3185 3185
 
3186 3186
 	/**
3187
-	* Get a list of flights from detected airport since 7 days
3188
-	* @return Array number, icao, name and city of airports
3189
-	*/
3187
+	 * Get a list of flights from detected airport since 7 days
3188
+	 * @return Array number, icao, name and city of airports
3189
+	 */
3190 3190
 
3191 3191
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3192 3192
 		global $globalTimezone, $globalDBdriver;
@@ -3224,9 +3224,9 @@  discard block
 block discarded – undo
3224 3224
 	}
3225 3225
 
3226 3226
 	/**
3227
-	* Get a list of flights from detected airport since 7 days
3228
-	* @return Array number, icao, name and city of airports
3229
-	*/
3227
+	 * Get a list of flights from detected airport since 7 days
3228
+	 * @return Array number, icao, name and city of airports
3229
+	 */
3230 3230
 
3231 3231
 	public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') {
3232 3232
 		global $globalTimezone, $globalDBdriver;
@@ -3268,9 +3268,9 @@  discard block
 block discarded – undo
3268 3268
 
3269 3269
 
3270 3270
 	/**
3271
-	* Get a list of flights to airport since 7 days
3272
-	* @return Array number, icao, name and city of airports
3273
-	*/
3271
+	 * Get a list of flights to airport since 7 days
3272
+	 * @return Array number, icao, name and city of airports
3273
+	 */
3274 3274
 
3275 3275
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3276 3276
 		global $globalTimezone, $globalDBdriver;
@@ -3303,9 +3303,9 @@  discard block
 block discarded – undo
3303 3303
 
3304 3304
 
3305 3305
 	/**
3306
-	* Get a list of flights detected to airport since 7 days
3307
-	* @return Array number, icao, name and city of airports
3308
-	*/
3306
+	 * Get a list of flights detected to airport since 7 days
3307
+	 * @return Array number, icao, name and city of airports
3308
+	 */
3309 3309
 
3310 3310
 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3311 3311
 		global $globalTimezone, $globalDBdriver;
@@ -3346,9 +3346,9 @@  discard block
 block discarded – undo
3346 3346
 
3347 3347
 
3348 3348
 	/**
3349
-	* Get a list of flights to airport since 7 days
3350
-	* @return Array number, icao, name and city of airports
3351
-	*/
3349
+	 * Get a list of flights to airport since 7 days
3350
+	 * @return Array number, icao, name and city of airports
3351
+	 */
3352 3352
 
3353 3353
 	public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') {
3354 3354
 		global $globalTimezone, $globalDBdriver;
@@ -3380,9 +3380,9 @@  discard block
 block discarded – undo
3380 3380
 
3381 3381
 
3382 3382
 	/**
3383
-	* Get a list of flights detected to airport since 7 days
3384
-	* @return Array number, icao, name and city of airports
3385
-	*/
3383
+	 * Get a list of flights detected to airport since 7 days
3384
+	 * @return Array number, icao, name and city of airports
3385
+	 */
3386 3386
 
3387 3387
 	public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') {
3388 3388
 		global $globalTimezone, $globalDBdriver;
@@ -3426,11 +3426,11 @@  discard block
 block discarded – undo
3426 3426
 
3427 3427
 
3428 3428
 	/**
3429
-	* Gets a list of all dates
3430
-	*
3431
-	* @return Array list of date names
3432
-	*
3433
-	*/
3429
+	 * Gets a list of all dates
3430
+	 *
3431
+	 * @return Array list of date names
3432
+	 *
3433
+	 */
3434 3434
 	public function getAllDates()
3435 3435
 	{
3436 3436
 		global $globalTimezone, $globalDBdriver;
@@ -3471,11 +3471,11 @@  discard block
 block discarded – undo
3471 3471
 	
3472 3472
 	
3473 3473
 	/**
3474
-	* Gets all route combinations
3475
-	*
3476
-	* @return Array the route list
3477
-	*
3478
-	*/
3474
+	 * Gets all route combinations
3475
+	 *
3476
+	 * @return Array the route list
3477
+	 *
3478
+	 */
3479 3479
 	public function getAllRoutes()
3480 3480
 	{
3481 3481
 		$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 
@@ -3501,13 +3501,13 @@  discard block
 block discarded – undo
3501 3501
 	}
3502 3502
 
3503 3503
 	/**
3504
-	* Update ident spotter data
3505
-	*
3506
-	* @param String $flightaware_id the ID from flightaware
3507
-	* @param String $ident the flight ident
3508
-	* @return String success or false
3509
-	*
3510
-	*/	
3504
+	 * Update ident spotter data
3505
+	 *
3506
+	 * @param String $flightaware_id the ID from flightaware
3507
+	 * @param String $ident the flight ident
3508
+	 * @return String success or false
3509
+	 *
3510
+	 */	
3511 3511
 	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3512 3512
 	{
3513 3513
 		if (!is_numeric(substr($ident, 0, 3)))
@@ -3528,14 +3528,14 @@  discard block
 block discarded – undo
3528 3528
 		} else {
3529 3529
 			$airline_array = $this->getAllAirlineInfo("NA");
3530 3530
 		}
3531
-                $airline_name = $airline_array[0]['name'];
3532
-                $airline_icao = $airline_array[0]['icao'];
3533
-                $airline_country = $airline_array[0]['country'];
3534
-                $airline_type = $airline_array[0]['type'];
3531
+				$airline_name = $airline_array[0]['name'];
3532
+				$airline_icao = $airline_array[0]['icao'];
3533
+				$airline_country = $airline_array[0]['country'];
3534
+				$airline_type = $airline_array[0]['type'];
3535 3535
 
3536 3536
 
3537 3537
 		$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';
3538
-                $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);
3538
+				$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);
3539 3539
 
3540 3540
 		try {
3541 3541
 			$sth = $this->db->prepare($query);
@@ -3548,19 +3548,19 @@  discard block
 block discarded – undo
3548 3548
 
3549 3549
 	}
3550 3550
 	/**
3551
-	* Update latest spotter data
3552
-	*
3553
-	* @param String $flightaware_id the ID from flightaware
3554
-	* @param String $ident the flight ident
3555
-	* @param String $arrival_airport_icao the arrival airport
3556
-	* @return String success or false
3557
-	*
3558
-	*/	
3551
+	 * Update latest spotter data
3552
+	 *
3553
+	 * @param String $flightaware_id the ID from flightaware
3554
+	 * @param String $ident the flight ident
3555
+	 * @param String $arrival_airport_icao the arrival airport
3556
+	 * @return String success or false
3557
+	 *
3558
+	 */	
3559 3559
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3560
 	{
3561 3561
 		if ($groundspeed == '') $groundspeed = NULL;
3562 3562
 		$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';
3563
-                $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);
3563
+				$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);
3564 3564
 
3565 3565
 		try {
3566 3566
 			$sth = $this->db->prepare($query);
@@ -3574,32 +3574,32 @@  discard block
 block discarded – undo
3574 3574
 	}
3575 3575
 
3576 3576
 	/**
3577
-	* Adds a new spotter data
3578
-	*
3579
-	* @param String $flightaware_id the ID from flightaware
3580
-	* @param String $ident the flight ident
3581
-	* @param String $aircraft_icao the aircraft type
3582
-	* @param String $departure_airport_icao the departure airport
3583
-	* @param String $arrival_airport_icao the arrival airport
3584
-	* @param String $latitude latitude of flight
3585
-	* @param String $longitude latitude of flight
3586
-	* @param String $waypoints waypoints of flight
3587
-	* @param String $altitude altitude of flight
3588
-	* @param String $heading heading of flight
3589
-	* @param String $groundspeed speed of flight
3590
-	* @param String $date date of flight
3591
-	* @param String $departure_airport_time departure time of flight
3592
-	* @param String $arrival_airport_time arrival time of flight
3593
-	* @param String $squawk squawk code of flight
3594
-	* @param String $route_stop route stop of flight
3595
-	* @param String $highlight highlight or not
3596
-	* @param String $ModeS ModesS code of flight
3597
-	* @param String $registration registration code of flight
3598
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
3599
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
3600
-	* @param String $verticalrate vertival rate of flight
3601
-	* @return String success or false
3602
-	*/
3577
+	 * Adds a new spotter data
3578
+	 *
3579
+	 * @param String $flightaware_id the ID from flightaware
3580
+	 * @param String $ident the flight ident
3581
+	 * @param String $aircraft_icao the aircraft type
3582
+	 * @param String $departure_airport_icao the departure airport
3583
+	 * @param String $arrival_airport_icao the arrival airport
3584
+	 * @param String $latitude latitude of flight
3585
+	 * @param String $longitude latitude of flight
3586
+	 * @param String $waypoints waypoints of flight
3587
+	 * @param String $altitude altitude of flight
3588
+	 * @param String $heading heading of flight
3589
+	 * @param String $groundspeed speed of flight
3590
+	 * @param String $date date of flight
3591
+	 * @param String $departure_airport_time departure time of flight
3592
+	 * @param String $arrival_airport_time arrival time of flight
3593
+	 * @param String $squawk squawk code of flight
3594
+	 * @param String $route_stop route stop of flight
3595
+	 * @param String $highlight highlight or not
3596
+	 * @param String $ModeS ModesS code of flight
3597
+	 * @param String $registration registration code of flight
3598
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
3599
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
3600
+	 * @param String $verticalrate vertival rate of flight
3601
+	 * @return String success or false
3602
+	 */
3603 3603
 	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '',$source_type = '')
3604 3604
 	{
3605 3605
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
@@ -3814,8 +3814,8 @@  discard block
 block discarded – undo
3814 3814
     
3815 3815
 		if ($globalIVAO && $aircraft_icao != '')
3816 3816
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
3817
+					if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
+					else $airline_icao = '';
3819 3819
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 3820
 			if (!isset($image_array[0]['registration']))
3821 3821
 			{
@@ -3846,53 +3846,53 @@  discard block
 block discarded – undo
3846 3846
 	
3847 3847
 		if (count($airline_array) == 0) 
3848 3848
 		{
3849
-                        $airline_array = $this->getAllAirlineInfo('NA');
3850
-                }
3851
-                if (count($aircraft_array) == 0) 
3852
-                {
3853
-                        $aircraft_array = $this->getAllAircraftInfo('NA');
3854
-                }
3855
-                if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3856
-                {
3857
-                        $departure_airport_array = $this->getAllAirportInfo('NA');
3858
-                }
3859
-                if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3860
-                {
3861
-                        $arrival_airport_array = $this->getAllAirportInfo('NA');
3862
-                }
3863
-                if ($registration == '') $registration = 'NA';
3864
-                if ($latitude == '' && $longitude == '') {
3865
-            		$latitude = 0;
3866
-            		$longitude = 0;
3867
-            	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
-                $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) 
3849
+						$airline_array = $this->getAllAirlineInfo('NA');
3850
+				}
3851
+				if (count($aircraft_array) == 0) 
3852
+				{
3853
+						$aircraft_array = $this->getAllAircraftInfo('NA');
3854
+				}
3855
+				if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3856
+				{
3857
+						$departure_airport_array = $this->getAllAirportInfo('NA');
3858
+				}
3859
+				if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3860
+				{
3861
+						$arrival_airport_array = $this->getAllAirportInfo('NA');
3862
+				}
3863
+				if ($registration == '') $registration = 'NA';
3864
+				if ($latitude == '' && $longitude == '') {
3865
+					$latitude = 0;
3866
+					$longitude = 0;
3867
+				}
3868
+				if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
+				if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
+				$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) 
3874 3874
                 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)";
3875 3875
 
3876
-                $airline_name = $airline_array[0]['name'];
3877
-                $airline_icao = $airline_array[0]['icao'];
3878
-                $airline_country = $airline_array[0]['country'];
3879
-                $airline_type = $airline_array[0]['type'];
3876
+				$airline_name = $airline_array[0]['name'];
3877
+				$airline_icao = $airline_array[0]['icao'];
3878
+				$airline_country = $airline_array[0]['country'];
3879
+				$airline_type = $airline_array[0]['type'];
3880 3880
 		if ($airline_type == '') {
3881 3881
 			$timeelapsed = microtime(true);
3882 3882
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883 3883
 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3884 3884
 		}
3885 3885
 		if ($airline_type == null) $airline_type = '';
3886
-                $aircraft_type = $aircraft_array[0]['type'];
3887
-                $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888
-                $departure_airport_name = $departure_airport_array[0]['name'];
3889
-	        $departure_airport_city = $departure_airport_array[0]['city'];
3890
-            	$departure_airport_country = $departure_airport_array[0]['country'];
3886
+				$aircraft_type = $aircraft_array[0]['type'];
3887
+				$aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888
+				$departure_airport_name = $departure_airport_array[0]['name'];
3889
+			$departure_airport_city = $departure_airport_array[0]['city'];
3890
+				$departure_airport_country = $departure_airport_array[0]['country'];
3891 3891
                 
3892
-                $arrival_airport_name = $arrival_airport_array[0]['name'];
3893
-                $arrival_airport_city = $arrival_airport_array[0]['city'];
3894
-                $arrival_airport_country = $arrival_airport_array[0]['country'];
3895
-                $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);
3892
+				$arrival_airport_name = $arrival_airport_array[0]['name'];
3893
+				$arrival_airport_city = $arrival_airport_array[0]['city'];
3894
+				$arrival_airport_country = $arrival_airport_array[0]['country'];
3895
+				$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);
3896 3896
 
3897 3897
 		try {
3898 3898
 		        
@@ -3900,7 +3900,7 @@  discard block
 block discarded – undo
3900 3900
 			$sth->execute($query_values);
3901 3901
 			$this->db = null;
3902 3902
 		} catch (PDOException $e) {
3903
-		    return "error : ".$e->getMessage();
3903
+			return "error : ".$e->getMessage();
3904 3904
 		}
3905 3905
 		
3906 3906
 		return "success";
@@ -3909,11 +3909,11 @@  discard block
 block discarded – undo
3909 3909
 	
3910 3910
   
3911 3911
 	/**
3912
-	* Gets the aircraft ident within the last hour
3913
-	*
3914
-	* @return String the ident
3915
-	*
3916
-	*/
3912
+	 * Gets the aircraft ident within the last hour
3913
+	 *
3914
+	 * @return String the ident
3915
+	 *
3916
+	 */
3917 3917
 	public function getIdentFromLastHour($ident)
3918 3918
 	{
3919 3919
 		global $globalDBdriver, $globalTimezone;
@@ -3929,11 +3929,11 @@  discard block
 block discarded – undo
3929 3929
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3930 3930
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
3931 3931
 			$query_data = array(':ident' => $ident);
3932
-    		}
3932
+			}
3933 3933
 		
3934 3934
 		$sth = $this->db->prepare($query);
3935 3935
 		$sth->execute($query_data);
3936
-    		$ident_result='';
3936
+			$ident_result='';
3937 3937
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3938 3938
 		{
3939 3939
 			$ident_result = $row['ident'];
@@ -3944,11 +3944,11 @@  discard block
 block discarded – undo
3944 3944
 	
3945 3945
 	
3946 3946
 	/**
3947
-	* Gets the aircraft data from the last 20 seconds
3948
-	*
3949
-	* @return Array the spotter data
3950
-	*
3951
-	*/
3947
+	 * Gets the aircraft data from the last 20 seconds
3948
+	 *
3949
+	 * @return Array the spotter data
3950
+	 *
3951
+	 */
3952 3952
 	public function getRealTimeData($q = '')
3953 3953
 	{
3954 3954
 		global $globalDBdriver;
@@ -3992,11 +3992,11 @@  discard block
 block discarded – undo
3992 3992
 	
3993 3993
 	
3994 3994
 	 /**
3995
-	* Gets all airlines that have flown over
3996
-	*
3997
-	* @return Array the airline list
3998
-	*
3999
-	*/
3995
+	  * Gets all airlines that have flown over
3996
+	  *
3997
+	  * @return Array the airline list
3998
+	  *
3999
+	  */
4000 4000
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
4001 4001
 	{
4002 4002
 		global $globalDBdriver;
@@ -4010,7 +4010,7 @@  discard block
 block discarded – undo
4010 4010
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4011 4011
 			}
4012 4012
 		}
4013
-                if ($sincedate != '') {
4013
+				if ($sincedate != '') {
4014 4014
 			if ($globalDBdriver == 'mysql') {
4015 4015
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4016 4016
 			} else {
@@ -4064,26 +4064,26 @@  discard block
 block discarded – undo
4064 4064
 	}
4065 4065
 
4066 4066
 	 /**
4067
-	* Gets all pilots that have flown over
4068
-	*
4069
-	* @return Array the pilots list
4070
-	*
4071
-	*/
4067
+	  * Gets all pilots that have flown over
4068
+	  *
4069
+	  * @return Array the pilots list
4070
+	  *
4071
+	  */
4072 4072
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4073 4073
 	{
4074 4074
 		global $globalDBdriver;
4075 4075
 		$filter_query = $this->getFilter($filters,true,true);
4076 4076
 		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4077 4077
 			FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''";
4078
-                if ($olderthanmonths > 0) {
4079
-            		if ($globalDBdriver == 'mysql') {
4078
+				if ($olderthanmonths > 0) {
4079
+					if ($globalDBdriver == 'mysql') {
4080 4080
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4081 4081
 			} else {
4082 4082
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4083 4083
 			}
4084 4084
 		}
4085
-                if ($sincedate != '') {
4086
-            		if ($globalDBdriver == 'mysql') {
4085
+				if ($sincedate != '') {
4086
+					if ($globalDBdriver == 'mysql') {
4087 4087
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4088 4088
 			} else {
4089 4089
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4138,25 +4138,25 @@  discard block
 block discarded – undo
4138 4138
 	}
4139 4139
 	
4140 4140
 	/**
4141
-	* Gets all pilots that have flown over
4142
-	*
4143
-	* @return Array the pilots list
4144
-	*
4145
-	*/
4141
+	 * Gets all pilots that have flown over
4142
+	 *
4143
+	 * @return Array the pilots list
4144
+	 *
4145
+	 */
4146 4146
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4147 4147
 	{
4148 4148
 		global $globalDBdriver;
4149 4149
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4150 4150
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4151
-                if ($olderthanmonths > 0) {
4152
-            		if ($globalDBdriver == 'mysql') {
4151
+				if ($olderthanmonths > 0) {
4152
+					if ($globalDBdriver == 'mysql') {
4153 4153
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4154 4154
 			} else {
4155 4155
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4156 4156
 			}
4157 4157
 		}
4158
-                if ($sincedate != '') {
4159
-            		if ($globalDBdriver == 'mysql') {
4158
+				if ($sincedate != '') {
4159
+					if ($globalDBdriver == 'mysql') {
4160 4160
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4161 4161
 			} else {
4162 4162
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4185,26 +4185,26 @@  discard block
 block discarded – undo
4185 4185
 	}
4186 4186
 	
4187 4187
 	 /**
4188
-	* Gets all owner that have flown over
4189
-	*
4190
-	* @return Array the pilots list
4191
-	*
4192
-	*/
4188
+	  * Gets all owner that have flown over
4189
+	  *
4190
+	  * @return Array the pilots list
4191
+	  *
4192
+	  */
4193 4193
 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4194 4194
 	{
4195 4195
 		global $globalDBdriver;
4196 4196
 		$filter_query = $this->getFilter($filters,true,true);
4197 4197
 		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4198 4198
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4199
-                if ($olderthanmonths > 0) {
4200
-            		if ($globalDBdriver == 'mysql') {
4199
+				if ($olderthanmonths > 0) {
4200
+					if ($globalDBdriver == 'mysql') {
4201 4201
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4202 4202
 			} else {
4203 4203
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4204 4204
 			}
4205 4205
 		}
4206
-                if ($sincedate != '') {
4207
-            		if ($globalDBdriver == 'mysql') {
4206
+				if ($sincedate != '') {
4207
+					if ($globalDBdriver == 'mysql') {
4208 4208
 				$query .= " AND spotter_output.date > '".$sincedate."' ";
4209 4209
 			} else {
4210 4210
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4255,26 +4255,26 @@  discard block
 block discarded – undo
4255 4255
 	}
4256 4256
 	
4257 4257
 	 /**
4258
-	* Gets all owner that have flown over
4259
-	*
4260
-	* @return Array the pilots list
4261
-	*
4262
-	*/
4258
+	  * Gets all owner that have flown over
4259
+	  *
4260
+	  * @return Array the pilots list
4261
+	  *
4262
+	  */
4263 4263
 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4264 4264
 	{
4265 4265
 		global $globalDBdriver;
4266 4266
 		$filter_query = $this->getFilter($filters,true,true);
4267 4267
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4268 4268
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4269
-                if ($olderthanmonths > 0) {
4270
-            		if ($globalDBdriver == 'mysql') {
4269
+				if ($olderthanmonths > 0) {
4270
+					if ($globalDBdriver == 'mysql') {
4271 4271
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4272 4272
 			} else {
4273 4273
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4274 4274
 			}
4275 4275
 		}
4276
-                if ($sincedate != '') {
4277
-            		if ($globalDBdriver == 'mysql') {
4276
+				if ($sincedate != '') {
4277
+					if ($globalDBdriver == 'mysql') {
4278 4278
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4279 4279
 			} else {
4280 4280
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4301,11 +4301,11 @@  discard block
 block discarded – undo
4301 4301
 	}
4302 4302
 
4303 4303
 	/**
4304
-	* Gets all airlines that have flown over by aircraft
4305
-	*
4306
-	* @return Array the airline list
4307
-	*
4308
-	*/
4304
+	 * Gets all airlines that have flown over by aircraft
4305
+	 *
4306
+	 * @return Array the airline list
4307
+	 *
4308
+	 */
4309 4309
 	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4310 4310
 	{
4311 4311
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4337,11 +4337,11 @@  discard block
 block discarded – undo
4337 4337
 
4338 4338
 
4339 4339
 	/**
4340
-	* Gets all airline countries that have flown over by aircraft
4341
-	*
4342
-	* @return Array the airline country list
4343
-	*
4344
-	*/
4340
+	 * Gets all airline countries that have flown over by aircraft
4341
+	 *
4342
+	 * @return Array the airline country list
4343
+	 *
4344
+	 */
4345 4345
 	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4346 4346
 	{
4347 4347
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4373,11 +4373,11 @@  discard block
 block discarded – undo
4373 4373
 	
4374 4374
 	
4375 4375
 	/**
4376
-	* Gets all airlines that have flown over by airport
4377
-	*
4378
-	* @return Array the airline list
4379
-	*
4380
-	*/
4376
+	 * Gets all airlines that have flown over by airport
4377
+	 *
4378
+	 * @return Array the airline list
4379
+	 *
4380
+	 */
4381 4381
 	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4382 4382
 	{
4383 4383
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4408,11 +4408,11 @@  discard block
 block discarded – undo
4408 4408
 
4409 4409
 
4410 4410
 	/**
4411
-	* Gets all airline countries that have flown over by airport icao
4412
-	*
4413
-	* @return Array the airline country list
4414
-	*
4415
-	*/
4411
+	 * Gets all airline countries that have flown over by airport icao
4412
+	 *
4413
+	 * @return Array the airline country list
4414
+	 *
4415
+	 */
4416 4416
 	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4417 4417
 	{
4418 4418
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4442,11 +4442,11 @@  discard block
 block discarded – undo
4442 4442
 
4443 4443
 
4444 4444
 	/**
4445
-	* Gets all airlines that have flown over by aircraft manufacturer
4446
-	*
4447
-	* @return Array the airline list
4448
-	*
4449
-	*/
4445
+	 * Gets all airlines that have flown over by aircraft manufacturer
4446
+	 *
4447
+	 * @return Array the airline list
4448
+	 *
4449
+	 */
4450 4450
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4451 4451
 	{
4452 4452
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4477,11 +4477,11 @@  discard block
 block discarded – undo
4477 4477
 
4478 4478
 
4479 4479
 	/**
4480
-	* Gets all airline countries that have flown over by aircraft manufacturer
4481
-	*
4482
-	* @return Array the airline country list
4483
-	*
4484
-	*/
4480
+	 * Gets all airline countries that have flown over by aircraft manufacturer
4481
+	 *
4482
+	 * @return Array the airline country list
4483
+	 *
4484
+	 */
4485 4485
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4486 4486
 	{
4487 4487
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4510,11 +4510,11 @@  discard block
 block discarded – undo
4510 4510
 
4511 4511
 
4512 4512
 	/**
4513
-	* Gets all airlines that have flown over by date
4514
-	*
4515
-	* @return Array the airline list
4516
-	*
4517
-	*/
4513
+	 * Gets all airlines that have flown over by date
4514
+	 *
4515
+	 * @return Array the airline list
4516
+	 *
4517
+	 */
4518 4518
 	public function countAllAirlinesByDate($date,$filters = array())
4519 4519
 	{
4520 4520
 		global $globalTimezone, $globalDBdriver;
@@ -4558,11 +4558,11 @@  discard block
 block discarded – undo
4558 4558
 	
4559 4559
 	
4560 4560
 	/**
4561
-	* Gets all airline countries that have flown over by date
4562
-	*
4563
-	* @return Array the airline country list
4564
-	*
4565
-	*/
4561
+	 * Gets all airline countries that have flown over by date
4562
+	 *
4563
+	 * @return Array the airline country list
4564
+	 *
4565
+	 */
4566 4566
 	public function countAllAirlineCountriesByDate($date,$filters = array())
4567 4567
 	{
4568 4568
 		global $globalTimezone, $globalDBdriver;
@@ -4605,11 +4605,11 @@  discard block
 block discarded – undo
4605 4605
 
4606 4606
 
4607 4607
 	/**
4608
-	* Gets all airlines that have flown over by ident/callsign
4609
-	*
4610
-	* @return Array the airline list
4611
-	*
4612
-	*/
4608
+	 * Gets all airlines that have flown over by ident/callsign
4609
+	 *
4610
+	 * @return Array the airline list
4611
+	 *
4612
+	 */
4613 4613
 	public function countAllAirlinesByIdent($ident,$filters = array())
4614 4614
 	{
4615 4615
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4626,11 +4626,11 @@  discard block
 block discarded – undo
4626 4626
 	}
4627 4627
 
4628 4628
 	/**
4629
-	* Gets all airlines by owner
4630
-	*
4631
-	* @return Array the airline list
4632
-	*
4633
-	*/
4629
+	 * Gets all airlines by owner
4630
+	 *
4631
+	 * @return Array the airline list
4632
+	 *
4633
+	 */
4634 4634
 	public function countAllAirlinesByOwner($owner,$filters = array())
4635 4635
 	{
4636 4636
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4647,11 +4647,11 @@  discard block
 block discarded – undo
4647 4647
 	}
4648 4648
 
4649 4649
 	/**
4650
-	* Gets flight duration by owner
4651
-	*
4652
-	* @return String Duration of all flights
4653
-	*
4654
-	*/
4650
+	 * Gets flight duration by owner
4651
+	 *
4652
+	 * @return String Duration of all flights
4653
+	 *
4654
+	 */
4655 4655
 	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4656 4656
 	{
4657 4657
 		global $globalDBdriver;
@@ -4698,11 +4698,11 @@  discard block
 block discarded – undo
4698 4698
 	}
4699 4699
 
4700 4700
 	/**
4701
-	* Count flights by owner
4702
-	*
4703
-	* @return String Duration of all flights
4704
-	*
4705
-	*/
4701
+	 * Count flights by owner
4702
+	 *
4703
+	 * @return String Duration of all flights
4704
+	 *
4705
+	 */
4706 4706
 	public function countFlightsByOwner($owner,$filters = array())
4707 4707
 	{
4708 4708
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4718,11 +4718,11 @@  discard block
 block discarded – undo
4718 4718
 	}
4719 4719
 
4720 4720
 	/**
4721
-	* Count flights by pilot
4722
-	*
4723
-	* @return String Duration of all flights
4724
-	*
4725
-	*/
4721
+	 * Count flights by pilot
4722
+	 *
4723
+	 * @return String Duration of all flights
4724
+	 *
4725
+	 */
4726 4726
 	public function countFlightsByPilot($pilot,$filters = array())
4727 4727
 	{
4728 4728
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4738,11 +4738,11 @@  discard block
 block discarded – undo
4738 4738
 	}
4739 4739
 
4740 4740
 	/**
4741
-	* Gets flight duration by pilot
4742
-	*
4743
-	* @return String Duration of all flights
4744
-	*
4745
-	*/
4741
+	 * Gets flight duration by pilot
4742
+	 *
4743
+	 * @return String Duration of all flights
4744
+	 *
4745
+	 */
4746 4746
 	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4747 4747
 	{
4748 4748
 		global $globalDBdriver;
@@ -4788,11 +4788,11 @@  discard block
 block discarded – undo
4788 4788
 	}
4789 4789
 
4790 4790
 	/**
4791
-	* Gets all airlines used by pilot
4792
-	*
4793
-	* @return Array the airline list
4794
-	*
4795
-	*/
4791
+	 * Gets all airlines used by pilot
4792
+	 *
4793
+	 * @return Array the airline list
4794
+	 *
4795
+	 */
4796 4796
 	public function countAllAirlinesByPilot($pilot,$filters = array())
4797 4797
 	{
4798 4798
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4809,11 +4809,11 @@  discard block
 block discarded – undo
4809 4809
 	}
4810 4810
 
4811 4811
 	/**
4812
-	* Gets all airlines that have flown over by route
4813
-	*
4814
-	* @return Array the airline list
4815
-	*
4816
-	*/
4812
+	 * Gets all airlines that have flown over by route
4813
+	 *
4814
+	 * @return Array the airline list
4815
+	 *
4816
+	 */
4817 4817
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4818 4818
 	{
4819 4819
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4845,11 +4845,11 @@  discard block
 block discarded – undo
4845 4845
 	}
4846 4846
 
4847 4847
 	/**
4848
-	* Gets all airline countries that have flown over by route
4849
-	*
4850
-	* @return Array the airline country list
4851
-	*
4852
-	*/
4848
+	 * Gets all airline countries that have flown over by route
4849
+	 *
4850
+	 * @return Array the airline country list
4851
+	 *
4852
+	 */
4853 4853
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4854 4854
 	{
4855 4855
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4881,11 +4881,11 @@  discard block
 block discarded – undo
4881 4881
 
4882 4882
 
4883 4883
 	/**
4884
-	* Gets all airlines that have flown over by country
4885
-	*
4886
-	* @return Array the airline list
4887
-	*
4888
-	*/
4884
+	 * Gets all airlines that have flown over by country
4885
+	 *
4886
+	 * @return Array the airline list
4887
+	 *
4888
+	 */
4889 4889
 	public function countAllAirlinesByCountry($country,$filters = array())
4890 4890
 	{
4891 4891
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4915,11 +4915,11 @@  discard block
 block discarded – undo
4915 4915
 
4916 4916
 
4917 4917
 	/**
4918
-	* Gets all airline countries that have flown over by country
4919
-	*
4920
-	* @return Array the airline country list
4921
-	*
4922
-	*/
4918
+	 * Gets all airline countries that have flown over by country
4919
+	 *
4920
+	 * @return Array the airline country list
4921
+	 *
4922
+	 */
4923 4923
 	public function countAllAirlineCountriesByCountry($country,$filters = array())
4924 4924
 	{
4925 4925
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4948,11 +4948,11 @@  discard block
 block discarded – undo
4948 4948
 
4949 4949
 
4950 4950
 	/**
4951
-	* Gets all airlines countries
4952
-	*
4953
-	* @return Array the airline country list
4954
-	*
4955
-	*/
4951
+	 * Gets all airlines countries
4952
+	 *
4953
+	 * @return Array the airline country list
4954
+	 *
4955
+	 */
4956 4956
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4957 4957
 	{
4958 4958
 		global $globalDBdriver;
@@ -5007,11 +5007,11 @@  discard block
 block discarded – undo
5007 5007
 	}
5008 5008
 
5009 5009
 	/**
5010
-	* Gets all number of flight over countries
5011
-	*
5012
-	* @return Array the airline country list
5013
-	*
5014
-	*/
5010
+	 * Gets all number of flight over countries
5011
+	 *
5012
+	 * @return Array the airline country list
5013
+	 *
5014
+	 */
5015 5015
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5016 5016
 	{
5017 5017
 		global $globalDBdriver;
@@ -5033,15 +5033,15 @@  discard block
 block discarded – undo
5033 5033
 		$SpotterLive = new SpotterLive();
5034 5034
 		$filter_query = $SpotterLive->getFilter($filters,true,true);
5035 5035
 		$filter_query .= ' over_country IS NOT NULL';
5036
-                if ($olderthanmonths > 0) {
5036
+				if ($olderthanmonths > 0) {
5037 5037
 			if ($globalDBdriver == 'mysql') {
5038 5038
 				$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5039 5039
 			} else {
5040 5040
 				$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5041 5041
 			}
5042 5042
 		}
5043
-                if ($sincedate != '') {
5044
-            		if ($globalDBdriver == 'mysql') {
5043
+				if ($sincedate != '') {
5044
+					if ($globalDBdriver == 'mysql') {
5045 5045
 				$filter_query .= " AND spotter_live.date > '".$sincedate."' ";
5046 5046
 			} else {
5047 5047
 				$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5071,11 +5071,11 @@  discard block
 block discarded – undo
5071 5071
 	
5072 5072
 	
5073 5073
 	/**
5074
-	* Gets all aircraft types that have flown over
5075
-	*
5076
-	* @return Array the aircraft list
5077
-	*
5078
-	*/
5074
+	 * Gets all aircraft types that have flown over
5075
+	 *
5076
+	 * @return Array the aircraft list
5077
+	 *
5078
+	 */
5079 5079
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5080 5080
 	{
5081 5081
 		global $globalDBdriver;
@@ -5145,11 +5145,11 @@  discard block
 block discarded – undo
5145 5145
 	}
5146 5146
 
5147 5147
 	/**
5148
-	* Gets all aircraft types that have flown over by airline
5149
-	*
5150
-	* @return Array the aircraft list
5151
-	*
5152
-	*/
5148
+	 * Gets all aircraft types that have flown over by airline
5149
+	 *
5150
+	 * @return Array the aircraft list
5151
+	 *
5152
+	 */
5153 5153
 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5154 5154
 	{
5155 5155
 		global $globalDBdriver;
@@ -5220,11 +5220,11 @@  discard block
 block discarded – undo
5220 5220
 	}
5221 5221
 
5222 5222
 	/**
5223
-	* Gets all aircraft types that have flown over by months
5224
-	*
5225
-	* @return Array the aircraft list
5226
-	*
5227
-	*/
5223
+	 * Gets all aircraft types that have flown over by months
5224
+	 *
5225
+	 * @return Array the aircraft list
5226
+	 *
5227
+	 */
5228 5228
 	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5229 5229
 	{
5230 5230
 		global $globalDBdriver;
@@ -5268,11 +5268,11 @@  discard block
 block discarded – undo
5268 5268
 
5269 5269
 
5270 5270
 	/**
5271
-	* Gets all aircraft registration that have flown over by aircaft icao
5272
-	*
5273
-	* @return Array the aircraft list
5274
-	*
5275
-	*/
5271
+	 * Gets all aircraft registration that have flown over by aircaft icao
5272
+	 *
5273
+	 * @return Array the aircraft list
5274
+	 *
5275
+	 */
5276 5276
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5277 5277
 	{
5278 5278
 		$Image = new Image($this->db);
@@ -5311,11 +5311,11 @@  discard block
 block discarded – undo
5311 5311
 
5312 5312
 
5313 5313
 	/**
5314
-	* Gets all aircraft types that have flown over by airline icao
5315
-	*
5316
-	* @return Array the aircraft list
5317
-	*
5318
-	*/
5314
+	 * Gets all aircraft types that have flown over by airline icao
5315
+	 *
5316
+	 * @return Array the aircraft list
5317
+	 *
5318
+	 */
5319 5319
 	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5320 5320
 	{
5321 5321
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5344,11 +5344,11 @@  discard block
 block discarded – undo
5344 5344
 
5345 5345
 
5346 5346
 	/**
5347
-	* Gets all aircraft registration that have flown over by airline icao
5348
-	*
5349
-	* @return Array the aircraft list
5350
-	*
5351
-	*/
5347
+	 * Gets all aircraft registration that have flown over by airline icao
5348
+	 *
5349
+	 * @return Array the aircraft list
5350
+	 *
5351
+	 */
5352 5352
 	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5353 5353
 	{
5354 5354
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5386,11 +5386,11 @@  discard block
 block discarded – undo
5386 5386
 
5387 5387
 
5388 5388
 	/**
5389
-	* Gets all aircraft manufacturer that have flown over by airline icao
5390
-	*
5391
-	* @return Array the aircraft list
5392
-	*
5393
-	*/
5389
+	 * Gets all aircraft manufacturer that have flown over by airline icao
5390
+	 *
5391
+	 * @return Array the aircraft list
5392
+	 *
5393
+	 */
5394 5394
 	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5395 5395
 	{
5396 5396
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5418,11 +5418,11 @@  discard block
 block discarded – undo
5418 5418
 
5419 5419
 
5420 5420
 	/**
5421
-	* Gets all aircraft types that have flown over by airline icao
5422
-	*
5423
-	* @return Array the aircraft list
5424
-	*
5425
-	*/
5421
+	 * Gets all aircraft types that have flown over by airline icao
5422
+	 *
5423
+	 * @return Array the aircraft list
5424
+	 *
5425
+	 */
5426 5426
 	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5427 5427
 	{
5428 5428
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5451,11 +5451,11 @@  discard block
 block discarded – undo
5451 5451
 
5452 5452
 
5453 5453
 	/**
5454
-	* Gets all aircraft registration that have flown over by airport icao
5455
-	*
5456
-	* @return Array the aircraft list
5457
-	*
5458
-	*/
5454
+	 * Gets all aircraft registration that have flown over by airport icao
5455
+	 *
5456
+	 * @return Array the aircraft list
5457
+	 *
5458
+	 */
5459 5459
 	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5460 5460
 	{
5461 5461
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5492,11 +5492,11 @@  discard block
 block discarded – undo
5492 5492
 	
5493 5493
 	
5494 5494
 	/**
5495
-	* Gets all aircraft manufacturer that have flown over by airport icao
5496
-	*
5497
-	* @return Array the aircraft list
5498
-	*
5499
-	*/
5495
+	 * Gets all aircraft manufacturer that have flown over by airport icao
5496
+	 *
5497
+	 * @return Array the aircraft list
5498
+	 *
5499
+	 */
5500 5500
 	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5501 5501
 	{
5502 5502
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5522,11 +5522,11 @@  discard block
 block discarded – undo
5522 5522
 	}
5523 5523
 
5524 5524
 	/**
5525
-	* Gets all aircraft types that have flown over by aircraft manufacturer
5526
-	*
5527
-	* @return Array the aircraft list
5528
-	*
5529
-	*/
5525
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
5526
+	 *
5527
+	 * @return Array the aircraft list
5528
+	 *
5529
+	 */
5530 5530
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5531 5531
 	{
5532 5532
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5553,11 +5553,11 @@  discard block
 block discarded – undo
5553 5553
 
5554 5554
 
5555 5555
 	/**
5556
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
5557
-	*
5558
-	* @return Array the aircraft list
5559
-	*
5560
-	*/
5556
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
5557
+	 *
5558
+	 * @return Array the aircraft list
5559
+	 *
5560
+	 */
5561 5561
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5562 5562
 	{
5563 5563
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5593,11 +5593,11 @@  discard block
 block discarded – undo
5593 5593
 	}
5594 5594
 
5595 5595
 	/**
5596
-	* Gets all aircraft types that have flown over by date
5597
-	*
5598
-	* @return Array the aircraft list
5599
-	*
5600
-	*/
5596
+	 * Gets all aircraft types that have flown over by date
5597
+	 *
5598
+	 * @return Array the aircraft list
5599
+	 *
5600
+	 */
5601 5601
 	public function countAllAircraftTypesByDate($date,$filters = array())
5602 5602
 	{
5603 5603
 		global $globalTimezone, $globalDBdriver;
@@ -5639,11 +5639,11 @@  discard block
 block discarded – undo
5639 5639
 
5640 5640
 
5641 5641
 	/**
5642
-	* Gets all aircraft registration that have flown over by date
5643
-	*
5644
-	* @return Array the aircraft list
5645
-	*
5646
-	*/
5642
+	 * Gets all aircraft registration that have flown over by date
5643
+	 *
5644
+	 * @return Array the aircraft list
5645
+	 *
5646
+	 */
5647 5647
 	public function countAllAircraftRegistrationByDate($date,$filters = array())
5648 5648
 	{
5649 5649
 		global $globalTimezone, $globalDBdriver;
@@ -5694,11 +5694,11 @@  discard block
 block discarded – undo
5694 5694
 
5695 5695
 
5696 5696
 	/**
5697
-	* Gets all aircraft manufacturer that have flown over by date
5698
-	*
5699
-	* @return Array the aircraft manufacturer list
5700
-	*
5701
-	*/
5697
+	 * Gets all aircraft manufacturer that have flown over by date
5698
+	 *
5699
+	 * @return Array the aircraft manufacturer list
5700
+	 *
5701
+	 */
5702 5702
 	public function countAllAircraftManufacturerByDate($date,$filters = array())
5703 5703
 	{
5704 5704
 		global $globalTimezone, $globalDBdriver;
@@ -5740,11 +5740,11 @@  discard block
 block discarded – undo
5740 5740
 
5741 5741
 
5742 5742
 	/**
5743
-	* Gets all aircraft types that have flown over by ident/callsign
5744
-	*
5745
-	* @return Array the aircraft list
5746
-	*
5747
-	*/
5743
+	 * Gets all aircraft types that have flown over by ident/callsign
5744
+	 *
5745
+	 * @return Array the aircraft list
5746
+	 *
5747
+	 */
5748 5748
 	public function countAllAircraftTypesByIdent($ident,$filters = array())
5749 5749
 	{
5750 5750
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5772,11 +5772,11 @@  discard block
 block discarded – undo
5772 5772
 	}
5773 5773
 
5774 5774
 	/**
5775
-	* Gets all aircraft types that have flown over by pilot
5776
-	*
5777
-	* @return Array the aircraft list
5778
-	*
5779
-	*/
5775
+	 * Gets all aircraft types that have flown over by pilot
5776
+	 *
5777
+	 * @return Array the aircraft list
5778
+	 *
5779
+	 */
5780 5780
 	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5781 5781
 	{
5782 5782
 		global $globalDBdriver;
@@ -5822,11 +5822,11 @@  discard block
 block discarded – undo
5822 5822
 	}
5823 5823
 
5824 5824
 	/**
5825
-	* Gets all aircraft types that have flown over by owner
5826
-	*
5827
-	* @return Array the aircraft list
5828
-	*
5829
-	*/
5825
+	 * Gets all aircraft types that have flown over by owner
5826
+	 *
5827
+	 * @return Array the aircraft list
5828
+	 *
5829
+	 */
5830 5830
 	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5831 5831
 	{
5832 5832
 		global $globalDBdriver;
@@ -5871,11 +5871,11 @@  discard block
 block discarded – undo
5871 5871
 	}
5872 5872
 
5873 5873
 	/**
5874
-	* Gets all aircraft registration that have flown over by ident/callsign
5875
-	*
5876
-	* @return Array the aircraft list
5877
-	*
5878
-	*/
5874
+	 * Gets all aircraft registration that have flown over by ident/callsign
5875
+	 *
5876
+	 * @return Array the aircraft list
5877
+	 *
5878
+	 */
5879 5879
 	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5880 5880
 	{
5881 5881
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5914,11 +5914,11 @@  discard block
 block discarded – undo
5914 5914
 	}
5915 5915
 
5916 5916
 	/**
5917
-	* Gets all aircraft registration that have flown over by owner
5918
-	*
5919
-	* @return Array the aircraft list
5920
-	*
5921
-	*/
5917
+	 * Gets all aircraft registration that have flown over by owner
5918
+	 *
5919
+	 * @return Array the aircraft list
5920
+	 *
5921
+	 */
5922 5922
 	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5923 5923
 	{
5924 5924
 		global $globalDBdriver;
@@ -5989,11 +5989,11 @@  discard block
 block discarded – undo
5989 5989
 	}
5990 5990
 
5991 5991
 	/**
5992
-	* Gets all aircraft registration that have flown over by pilot
5993
-	*
5994
-	* @return Array the aircraft list
5995
-	*
5996
-	*/
5992
+	 * Gets all aircraft registration that have flown over by pilot
5993
+	 *
5994
+	 * @return Array the aircraft list
5995
+	 *
5996
+	 */
5997 5997
 	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5998 5998
 	{
5999 5999
 		global $globalDBdriver;
@@ -6065,11 +6065,11 @@  discard block
 block discarded – undo
6065 6065
 
6066 6066
 
6067 6067
 	/**
6068
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
6069
-	*
6070
-	* @return Array the aircraft manufacturer list
6071
-	*
6072
-	*/
6068
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
6069
+	 *
6070
+	 * @return Array the aircraft manufacturer list
6071
+	 *
6072
+	 */
6073 6073
 	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6074 6074
 	{
6075 6075
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6094,11 +6094,11 @@  discard block
 block discarded – undo
6094 6094
 	}
6095 6095
 
6096 6096
 	/**
6097
-	* Gets all aircraft manufacturer that have flown over by owner
6098
-	*
6099
-	* @return Array the aircraft manufacturer list
6100
-	*
6101
-	*/
6097
+	 * Gets all aircraft manufacturer that have flown over by owner
6098
+	 *
6099
+	 * @return Array the aircraft manufacturer list
6100
+	 *
6101
+	 */
6102 6102
 	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6103 6103
 	{
6104 6104
 		global $globalDBdriver;
@@ -6146,11 +6146,11 @@  discard block
 block discarded – undo
6146 6146
 	}
6147 6147
 
6148 6148
 	/**
6149
-	* Gets all aircraft manufacturer that have flown over by pilot
6150
-	*
6151
-	* @return Array the aircraft manufacturer list
6152
-	*
6153
-	*/
6149
+	 * Gets all aircraft manufacturer that have flown over by pilot
6150
+	 *
6151
+	 * @return Array the aircraft manufacturer list
6152
+	 *
6153
+	 */
6154 6154
 	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6155 6155
 	{
6156 6156
 		global $globalDBdriver;
@@ -6199,11 +6199,11 @@  discard block
 block discarded – undo
6199 6199
 
6200 6200
 
6201 6201
 	/**
6202
-	* Gets all aircraft types that have flown over by route
6203
-	*
6204
-	* @return Array the aircraft list
6205
-	*
6206
-	*/
6202
+	 * Gets all aircraft types that have flown over by route
6203
+	 *
6204
+	 * @return Array the aircraft list
6205
+	 *
6206
+	 */
6207 6207
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6208 6208
 	{
6209 6209
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6232,11 +6232,11 @@  discard block
 block discarded – undo
6232 6232
 	}
6233 6233
 
6234 6234
 	/**
6235
-	* Gets all aircraft registration that have flown over by route
6236
-	*
6237
-	* @return Array the aircraft list
6238
-	*
6239
-	*/
6235
+	 * Gets all aircraft registration that have flown over by route
6236
+	 *
6237
+	 * @return Array the aircraft list
6238
+	 *
6239
+	 */
6240 6240
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6241 6241
 	{
6242 6242
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6278,11 +6278,11 @@  discard block
 block discarded – undo
6278 6278
 	
6279 6279
 	
6280 6280
 	/**
6281
-	* Gets all aircraft manufacturer that have flown over by route
6282
-	*
6283
-	* @return Array the aircraft manufacturer list
6284
-	*
6285
-	*/
6281
+	 * Gets all aircraft manufacturer that have flown over by route
6282
+	 *
6283
+	 * @return Array the aircraft manufacturer list
6284
+	 *
6285
+	 */
6286 6286
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6287 6287
 	{
6288 6288
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6316,11 +6316,11 @@  discard block
 block discarded – undo
6316 6316
 	
6317 6317
 	
6318 6318
 	/**
6319
-	* Gets all aircraft types that have flown over by country
6320
-	*
6321
-	* @return Array the aircraft list
6322
-	*
6323
-	*/
6319
+	 * Gets all aircraft types that have flown over by country
6320
+	 *
6321
+	 * @return Array the aircraft list
6322
+	 *
6323
+	 */
6324 6324
 	public function countAllAircraftTypesByCountry($country,$filters = array())
6325 6325
 	{
6326 6326
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6351,11 +6351,11 @@  discard block
 block discarded – undo
6351 6351
 
6352 6352
 
6353 6353
 	/**
6354
-	* Gets all aircraft registration that have flown over by country
6355
-	*
6356
-	* @return Array the aircraft list
6357
-	*
6358
-	*/
6354
+	 * Gets all aircraft registration that have flown over by country
6355
+	 *
6356
+	 * @return Array the aircraft list
6357
+	 *
6358
+	 */
6359 6359
 	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6360 6360
 	{
6361 6361
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6395,11 +6395,11 @@  discard block
 block discarded – undo
6395 6395
 	
6396 6396
 	
6397 6397
 	/**
6398
-	* Gets all aircraft manufacturer that have flown over by country
6399
-	*
6400
-	* @return Array the aircraft manufacturer list
6401
-	*
6402
-	*/
6398
+	 * Gets all aircraft manufacturer that have flown over by country
6399
+	 *
6400
+	 * @return Array the aircraft manufacturer list
6401
+	 *
6402
+	 */
6403 6403
 	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6404 6404
 	{
6405 6405
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6430,18 +6430,18 @@  discard block
 block discarded – undo
6430 6430
 	
6431 6431
 	
6432 6432
 	/**
6433
-	* Gets all aircraft manufacturers that have flown over
6434
-	*
6435
-	* @return Array the aircraft list
6436
-	*
6437
-	*/
6433
+	 * Gets all aircraft manufacturers that have flown over
6434
+	 *
6435
+	 * @return Array the aircraft list
6436
+	 *
6437
+	 */
6438 6438
 	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6439 6439
 	{
6440 6440
 		global $globalDBdriver;
6441 6441
 		$filter_query = $this->getFilter($filters,true,true);
6442 6442
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6443 6443
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6444
-                $query_values = array();
6444
+				$query_values = array();
6445 6445
 		if ($year != '') {
6446 6446
 			if ($globalDBdriver == 'mysql') {
6447 6447
 				$query .= " AND YEAR(spotter_output.date) = :year";
@@ -6494,11 +6494,11 @@  discard block
 block discarded – undo
6494 6494
 	
6495 6495
 	
6496 6496
 	/**
6497
-	* Gets all aircraft registrations that have flown over
6498
-	*
6499
-	* @return Array the aircraft list
6500
-	*
6501
-	*/
6497
+	 * Gets all aircraft registrations that have flown over
6498
+	 *
6499
+	 * @return Array the aircraft list
6500
+	 *
6501
+	 */
6502 6502
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6503 6503
 	{
6504 6504
 		global $globalDBdriver;
@@ -6506,15 +6506,15 @@  discard block
 block discarded – undo
6506 6506
 		$filter_query = $this->getFilter($filters,true,true);
6507 6507
 		$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    
6508 6508
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6509
-                if ($olderthanmonths > 0) {
6510
-            		if ($globalDBdriver == 'mysql') {
6509
+				if ($olderthanmonths > 0) {
6510
+					if ($globalDBdriver == 'mysql') {
6511 6511
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6512 6512
 			} else {
6513 6513
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6514 6514
 			}
6515 6515
 		}
6516
-                if ($sincedate != '') {
6517
-            		if ($globalDBdriver == 'mysql') {
6516
+				if ($sincedate != '') {
6517
+					if ($globalDBdriver == 'mysql') {
6518 6518
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6519 6519
 			} else {
6520 6520
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6579,11 +6579,11 @@  discard block
 block discarded – undo
6579 6579
 
6580 6580
 
6581 6581
 	/**
6582
-	* Gets all aircraft registrations that have flown over
6583
-	*
6584
-	* @return Array the aircraft list
6585
-	*
6586
-	*/
6582
+	 * Gets all aircraft registrations that have flown over
6583
+	 *
6584
+	 * @return Array the aircraft list
6585
+	 *
6586
+	 */
6587 6587
 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6588 6588
 	{
6589 6589
 		global $globalDBdriver;
@@ -6591,15 +6591,15 @@  discard block
 block discarded – undo
6591 6591
 		$Image = new Image($this->db);
6592 6592
 		$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    
6593 6593
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6594
-                if ($olderthanmonths > 0) {
6595
-            		if ($globalDBdriver == 'mysql') {
6594
+				if ($olderthanmonths > 0) {
6595
+					if ($globalDBdriver == 'mysql') {
6596 6596
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6597 6597
 			} else {
6598 6598
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6599 6599
 			}
6600 6600
 		}
6601
-                if ($sincedate != '') {
6602
-            		if ($globalDBdriver == 'mysql') {
6601
+				if ($sincedate != '') {
6602
+					if ($globalDBdriver == 'mysql') {
6603 6603
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6604 6604
 			} else {
6605 6605
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6608,7 +6608,7 @@  discard block
 block discarded – undo
6608 6608
 
6609 6609
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6610 6610
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6611
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6611
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6612 6612
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6613 6613
 		
6614 6614
 		$sth = $this->db->prepare($query);
@@ -6640,26 +6640,26 @@  discard block
 block discarded – undo
6640 6640
 	
6641 6641
 	
6642 6642
 	/**
6643
-	* Gets all departure airports of the airplanes that have flown over
6644
-	*
6645
-	* @return Array the airport list
6646
-	*
6647
-	*/
6643
+	 * Gets all departure airports of the airplanes that have flown over
6644
+	 *
6645
+	 * @return Array the airport list
6646
+	 *
6647
+	 */
6648 6648
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6649 6649
 	{
6650 6650
 		global $globalDBdriver;
6651 6651
 		$filter_query = $this->getFilter($filters,true,true);
6652 6652
 		$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 
6653 6653
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6654
-                if ($olderthanmonths > 0) {
6655
-            		if ($globalDBdriver == 'mysql') {
6654
+				if ($olderthanmonths > 0) {
6655
+					if ($globalDBdriver == 'mysql') {
6656 6656
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6657 6657
 			} else {
6658 6658
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6659 6659
 			}
6660
-                }
6661
-                if ($sincedate != '') {
6662
-            		if ($globalDBdriver == 'mysql') {
6660
+				}
6661
+				if ($sincedate != '') {
6662
+					if ($globalDBdriver == 'mysql') {
6663 6663
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6664 6664
 			} else {
6665 6665
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6693,7 +6693,7 @@  discard block
 block discarded – undo
6693 6693
 				$query_values = array_merge($query_values,array(':day' => $day));
6694 6694
 			}
6695 6695
 		}
6696
-                $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6696
+				$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6697 6697
 				ORDER BY airport_departure_icao_count DESC";
6698 6698
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6699 6699
 
@@ -6716,35 +6716,35 @@  discard block
 block discarded – undo
6716 6716
 	}
6717 6717
 
6718 6718
 	/**
6719
-	* Gets all departure airports of the airplanes that have flown over
6720
-	*
6721
-	* @return Array the airport list
6722
-	*
6723
-	*/
6719
+	 * Gets all departure airports of the airplanes that have flown over
6720
+	 *
6721
+	 * @return Array the airport list
6722
+	 *
6723
+	 */
6724 6724
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6725 6725
 	{
6726 6726
 		global $globalDBdriver;
6727 6727
 		$filter_query = $this->getFilter($filters,true,true);
6728 6728
 		$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 
6729 6729
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' ";
6730
-                if ($olderthanmonths > 0) {
6731
-            		if ($globalDBdriver == 'mysql') {
6730
+				if ($olderthanmonths > 0) {
6731
+					if ($globalDBdriver == 'mysql') {
6732 6732
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6733 6733
 			} else {
6734 6734
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6735 6735
 			}
6736
-                }
6737
-                if ($sincedate != '') {
6738
-            		if ($globalDBdriver == 'mysql') {
6736
+				}
6737
+				if ($sincedate != '') {
6738
+					if ($globalDBdriver == 'mysql') {
6739 6739
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6740 6740
 			} else {
6741 6741
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6742 6742
 			}
6743 6743
 		}
6744 6744
 
6745
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6746
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6745
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6746
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6748 6748
 				ORDER BY airport_departure_icao_count DESC";
6749 6749
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6750 6750
       
@@ -6769,26 +6769,26 @@  discard block
 block discarded – undo
6769 6769
 	}
6770 6770
 
6771 6771
 	/**
6772
-	* Gets all detected departure airports of the airplanes that have flown over
6773
-	*
6774
-	* @return Array the airport list
6775
-	*
6776
-	*/
6772
+	 * Gets all detected departure airports of the airplanes that have flown over
6773
+	 *
6774
+	 * @return Array the airport list
6775
+	 *
6776
+	 */
6777 6777
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6778 6778
 	{
6779 6779
 		global $globalDBdriver;
6780 6780
 		$filter_query = $this->getFilter($filters,true,true);
6781 6781
 		$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
6782 6782
 				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";
6783
-                if ($olderthanmonths > 0) {
6784
-            		if ($globalDBdriver == 'mysql') {
6783
+				if ($olderthanmonths > 0) {
6784
+					if ($globalDBdriver == 'mysql') {
6785 6785
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6786 6786
 			} else {
6787 6787
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6788 6788
 			}
6789
-                }
6790
-                if ($sincedate != '') {
6791
-            		if ($globalDBdriver == 'mysql') {
6789
+				}
6790
+				if ($sincedate != '') {
6791
+					if ($globalDBdriver == 'mysql') {
6792 6792
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6793 6793
 			} else {
6794 6794
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6822,10 +6822,10 @@  discard block
 block discarded – undo
6822 6822
 				$query_values = array_merge($query_values,array(':day' => $day));
6823 6823
 			}
6824 6824
 		}
6825
-                $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6825
+				$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6826 6826
 				ORDER BY airport_departure_icao_count DESC";
6827 6827
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6828
-    		//echo $query;
6828
+			//echo $query;
6829 6829
 		$sth = $this->db->prepare($query);
6830 6830
 		$sth->execute($query_values);
6831 6831
       
@@ -6846,35 +6846,35 @@  discard block
 block discarded – undo
6846 6846
 	}
6847 6847
 	
6848 6848
 	/**
6849
-	* Gets all detected departure airports of the airplanes that have flown over
6850
-	*
6851
-	* @return Array the airport list
6852
-	*
6853
-	*/
6849
+	 * Gets all detected departure airports of the airplanes that have flown over
6850
+	 *
6851
+	 * @return Array the airport list
6852
+	 *
6853
+	 */
6854 6854
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6855 6855
 	{
6856 6856
 		global $globalDBdriver;
6857 6857
 		$filter_query = $this->getFilter($filters,true,true);
6858 6858
 		$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
6859 6859
 				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 ";
6860
-                if ($olderthanmonths > 0) {
6861
-            		if ($globalDBdriver == 'mysql') {
6860
+				if ($olderthanmonths > 0) {
6861
+					if ($globalDBdriver == 'mysql') {
6862 6862
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6863 6863
 			} else {
6864 6864
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6865 6865
 			}
6866
-                }
6867
-                if ($sincedate != '') {
6868
-            		if ($globalDBdriver == 'mysql') {
6866
+				}
6867
+				if ($sincedate != '') {
6868
+					if ($globalDBdriver == 'mysql') {
6869 6869
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6870 6870
 			} else {
6871 6871
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
6872 6872
 			}
6873 6873
 		}
6874 6874
 
6875
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6876
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6875
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6876
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6878 6878
 				ORDER BY airport_departure_icao_count DESC";
6879 6879
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6880 6880
       
@@ -6899,11 +6899,11 @@  discard block
 block discarded – undo
6899 6899
 	}	
6900 6900
 	
6901 6901
 	/**
6902
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
6903
-	*
6904
-	* @return Array the airport list
6905
-	*
6906
-	*/
6902
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
6903
+	 *
6904
+	 * @return Array the airport list
6905
+	 *
6906
+	 */
6907 6907
 	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6908 6908
 	{
6909 6909
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6937,11 +6937,11 @@  discard block
 block discarded – undo
6937 6937
 	
6938 6938
 	
6939 6939
 	/**
6940
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6941
-	*
6942
-	* @return Array the airport list
6943
-	*
6944
-	*/
6940
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6941
+	 *
6942
+	 * @return Array the airport list
6943
+	 *
6944
+	 */
6945 6945
 	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6946 6946
 	{
6947 6947
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6972,11 +6972,11 @@  discard block
 block discarded – undo
6972 6972
 	
6973 6973
 	
6974 6974
 	/**
6975
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6976
-	*
6977
-	* @return Array the airport list
6978
-	*
6979
-	*/
6975
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6976
+	 *
6977
+	 * @return Array the airport list
6978
+	 *
6979
+	 */
6980 6980
 	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6981 6981
 	{
6982 6982
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7009,11 +7009,11 @@  discard block
 block discarded – undo
7009 7009
 	
7010 7010
 	
7011 7011
 	/**
7012
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7013
-	*
7014
-	* @return Array the airport list
7015
-	*
7016
-	*/
7012
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7013
+	 *
7014
+	 * @return Array the airport list
7015
+	 *
7016
+	 */
7017 7017
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7018 7018
 	{
7019 7019
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7043,11 +7043,11 @@  discard block
 block discarded – undo
7043 7043
 	
7044 7044
 	
7045 7045
 	/**
7046
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7047
-	*
7048
-	* @return Array the airport list
7049
-	*
7050
-	*/
7046
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7047
+	 *
7048
+	 * @return Array the airport list
7049
+	 *
7050
+	 */
7051 7051
 	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7052 7052
 	{
7053 7053
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7080,11 +7080,11 @@  discard block
 block discarded – undo
7080 7080
 	
7081 7081
 	
7082 7082
 	/**
7083
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7084
-	*
7085
-	* @return Array the airport list
7086
-	*
7087
-	*/
7083
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7084
+	 *
7085
+	 * @return Array the airport list
7086
+	 *
7087
+	 */
7088 7088
 	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7089 7089
 	{
7090 7090
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7114,11 +7114,11 @@  discard block
 block discarded – undo
7114 7114
 	
7115 7115
 	
7116 7116
 	/**
7117
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7118
-	*
7119
-	* @return Array the airport list
7120
-	*
7121
-	*/
7117
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7118
+	 *
7119
+	 * @return Array the airport list
7120
+	 *
7121
+	 */
7122 7122
 	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7123 7123
 	{
7124 7124
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7151,11 +7151,11 @@  discard block
 block discarded – undo
7151 7151
 	
7152 7152
 	
7153 7153
 	/**
7154
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7155
-	*
7156
-	* @return Array the airport list
7157
-	*
7158
-	*/
7154
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7155
+	 *
7156
+	 * @return Array the airport list
7157
+	 *
7158
+	 */
7159 7159
 	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7160 7160
 	{
7161 7161
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7186,11 +7186,11 @@  discard block
 block discarded – undo
7186 7186
 	
7187 7187
 	
7188 7188
 	/**
7189
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7190
-	*
7191
-	* @return Array the airport list
7192
-	*
7193
-	*/
7189
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7190
+	 *
7191
+	 * @return Array the airport list
7192
+	 *
7193
+	 */
7194 7194
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7195 7195
 	{
7196 7196
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7223,11 +7223,11 @@  discard block
 block discarded – undo
7223 7223
 	
7224 7224
 	
7225 7225
 	/**
7226
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7227
-	*
7228
-	* @return Array the airport list
7229
-	*
7230
-	*/
7226
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7227
+	 *
7228
+	 * @return Array the airport list
7229
+	 *
7230
+	 */
7231 7231
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7232 7232
 	{
7233 7233
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7257,11 +7257,11 @@  discard block
 block discarded – undo
7257 7257
 	
7258 7258
 	
7259 7259
 	/**
7260
-	* Gets all departure airports of the airplanes that have flown over based on a date
7261
-	*
7262
-	* @return Array the airport list
7263
-	*
7264
-	*/
7260
+	 * Gets all departure airports of the airplanes that have flown over based on a date
7261
+	 *
7262
+	 * @return Array the airport list
7263
+	 *
7264
+	 */
7265 7265
 	public function countAllDepartureAirportsByDate($date,$filters = array())
7266 7266
 	{
7267 7267
 		global $globalTimezone, $globalDBdriver;
@@ -7307,11 +7307,11 @@  discard block
 block discarded – undo
7307 7307
 	
7308 7308
 	
7309 7309
 	/**
7310
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
7311
-	*
7312
-	* @return Array the airport list
7313
-	*
7314
-	*/
7310
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
7311
+	 *
7312
+	 * @return Array the airport list
7313
+	 *
7314
+	 */
7315 7315
 	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7316 7316
 	{
7317 7317
 		global $globalTimezone, $globalDBdriver;
@@ -7354,11 +7354,11 @@  discard block
 block discarded – undo
7354 7354
 	
7355 7355
 	
7356 7356
 	/**
7357
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7358
-	*
7359
-	* @return Array the airport list
7360
-	*
7361
-	*/
7357
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7358
+	 *
7359
+	 * @return Array the airport list
7360
+	 *
7361
+	 */
7362 7362
 	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7363 7363
 	{
7364 7364
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7390,11 +7390,11 @@  discard block
 block discarded – undo
7390 7390
 	}
7391 7391
 	
7392 7392
 	/**
7393
-	* Gets all departure airports of the airplanes that have flown over based on a owner
7394
-	*
7395
-	* @return Array the airport list
7396
-	*
7397
-	*/
7393
+	 * Gets all departure airports of the airplanes that have flown over based on a owner
7394
+	 *
7395
+	 * @return Array the airport list
7396
+	 *
7397
+	 */
7398 7398
 	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7399 7399
 	{
7400 7400
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7426,11 +7426,11 @@  discard block
 block discarded – undo
7426 7426
 	}
7427 7427
 	
7428 7428
 	/**
7429
-	* Gets all departure airports of the airplanes that have flown over based on a pilot
7430
-	*
7431
-	* @return Array the airport list
7432
-	*
7433
-	*/
7429
+	 * Gets all departure airports of the airplanes that have flown over based on a pilot
7430
+	 *
7431
+	 * @return Array the airport list
7432
+	 *
7433
+	 */
7434 7434
 	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7435 7435
 	{
7436 7436
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7463,11 +7463,11 @@  discard block
 block discarded – undo
7463 7463
 	
7464 7464
 	
7465 7465
 	/**
7466
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7467
-	*
7468
-	* @return Array the airport list
7469
-	*
7470
-	*/
7466
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7467
+	 *
7468
+	 * @return Array the airport list
7469
+	 *
7470
+	 */
7471 7471
 	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7472 7472
 	{
7473 7473
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7496,11 +7496,11 @@  discard block
 block discarded – undo
7496 7496
 	}
7497 7497
 	
7498 7498
 	/**
7499
-	* Gets all departure airports by country of the airplanes that have flown over based on owner
7500
-	*
7501
-	* @return Array the airport list
7502
-	*
7503
-	*/
7499
+	 * Gets all departure airports by country of the airplanes that have flown over based on owner
7500
+	 *
7501
+	 * @return Array the airport list
7502
+	 *
7503
+	 */
7504 7504
 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7505 7505
 	{
7506 7506
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7516,11 +7516,11 @@  discard block
 block discarded – undo
7516 7516
 	}
7517 7517
 	
7518 7518
 	/**
7519
-	* Gets all departure airports by country of the airplanes that have flown over based on pilot
7520
-	*
7521
-	* @return Array the airport list
7522
-	*
7523
-	*/
7519
+	 * Gets all departure airports by country of the airplanes that have flown over based on pilot
7520
+	 *
7521
+	 * @return Array the airport list
7522
+	 *
7523
+	 */
7524 7524
 	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7525 7525
 	{
7526 7526
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7538,11 +7538,11 @@  discard block
 block discarded – undo
7538 7538
 	
7539 7539
 	
7540 7540
 	/**
7541
-	* Gets all departure airports of the airplanes that have flown over based on a country
7542
-	*
7543
-	* @return Array the airport list
7544
-	*
7545
-	*/
7541
+	 * Gets all departure airports of the airplanes that have flown over based on a country
7542
+	 *
7543
+	 * @return Array the airport list
7544
+	 *
7545
+	 */
7546 7546
 	public function countAllDepartureAirportsByCountry($country,$filters = array())
7547 7547
 	{
7548 7548
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7576,11 +7576,11 @@  discard block
 block discarded – undo
7576 7576
 
7577 7577
 
7578 7578
 	/**
7579
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7580
-	*
7581
-	* @return Array the airport list
7582
-	*
7583
-	*/
7579
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7580
+	 *
7581
+	 * @return Array the airport list
7582
+	 *
7583
+	 */
7584 7584
 	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7585 7585
 	{
7586 7586
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7610,31 +7610,31 @@  discard block
 block discarded – undo
7610 7610
 	
7611 7611
 
7612 7612
 	/**
7613
-	* Gets all arrival airports of the airplanes that have flown over
7614
-	*
7615
-	* @param Boolean $limit Limit result to 10 or not
7616
-	* @param Integer $olderthanmonths Only show result older than x months
7617
-	* @param String $sincedate Only show result since x date
7618
-	* @param Boolean $icaoaskey Show result by ICAO
7619
-	* @param Array $filters Filter used here
7620
-	* @return Array the airport list
7621
-	*
7622
-	*/
7613
+	 * Gets all arrival airports of the airplanes that have flown over
7614
+	 *
7615
+	 * @param Boolean $limit Limit result to 10 or not
7616
+	 * @param Integer $olderthanmonths Only show result older than x months
7617
+	 * @param String $sincedate Only show result since x date
7618
+	 * @param Boolean $icaoaskey Show result by ICAO
7619
+	 * @param Array $filters Filter used here
7620
+	 * @return Array the airport list
7621
+	 *
7622
+	 */
7623 7623
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7624 7624
 	{
7625 7625
 		global $globalDBdriver;
7626 7626
 		$filter_query = $this->getFilter($filters,true,true);
7627 7627
 		$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 
7628 7628
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7629
-                if ($olderthanmonths > 0) {
7630
-            		if ($globalDBdriver == 'mysql') {
7629
+				if ($olderthanmonths > 0) {
7630
+					if ($globalDBdriver == 'mysql') {
7631 7631
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7632 7632
 			} else {
7633 7633
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7634 7634
 			}
7635 7635
 		}
7636
-                if ($sincedate != '') {
7637
-            		if ($globalDBdriver == 'mysql') {
7636
+				if ($sincedate != '') {
7637
+					if ($globalDBdriver == 'mysql') {
7638 7638
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7639 7639
 			} else {
7640 7640
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7668,7 +7668,7 @@  discard block
 block discarded – undo
7668 7668
 				$query_values = array_merge($query_values,array(':day' => $day));
7669 7669
 			}
7670 7670
 		}
7671
-                $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7671
+				$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7672 7672
 					ORDER BY airport_arrival_icao_count DESC";
7673 7673
 		if ($limit) $query .= " LIMIT 10";
7674 7674
       
@@ -7697,35 +7697,35 @@  discard block
 block discarded – undo
7697 7697
 	}
7698 7698
 
7699 7699
 	/**
7700
-	* Gets all arrival airports of the airplanes that have flown over
7701
-	*
7702
-	* @return Array the airport list
7703
-	*
7704
-	*/
7700
+	 * Gets all arrival airports of the airplanes that have flown over
7701
+	 *
7702
+	 * @return Array the airport list
7703
+	 *
7704
+	 */
7705 7705
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7706 7706
 	{
7707 7707
 		global $globalDBdriver;
7708 7708
 		$filter_query = $this->getFilter($filters,true,true);
7709 7709
 		$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 
7710 7710
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7711
-                if ($olderthanmonths > 0) {
7712
-            		if ($globalDBdriver == 'mysql') {
7711
+				if ($olderthanmonths > 0) {
7712
+					if ($globalDBdriver == 'mysql') {
7713 7713
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7714 7714
 			} else {
7715 7715
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7716 7716
 			}
7717 7717
 		}
7718
-                if ($sincedate != '') {
7719
-            		if ($globalDBdriver == 'mysql') {
7718
+				if ($sincedate != '') {
7719
+					if ($globalDBdriver == 'mysql') {
7720 7720
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7721 7721
 			} else {
7722 7722
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7723 7723
 			}
7724 7724
 		}
7725 7725
 
7726
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7727
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728
-                $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7726
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7727
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728
+				$query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7729 7729
 					ORDER BY airport_arrival_icao_count DESC";
7730 7730
 		if ($limit) $query .= " LIMIT 10";
7731 7731
       
@@ -7756,26 +7756,26 @@  discard block
 block discarded – undo
7756 7756
 
7757 7757
 
7758 7758
 	/**
7759
-	* Gets all detected arrival airports of the airplanes that have flown over
7760
-	*
7761
-	* @return Array the airport list
7762
-	*
7763
-	*/
7759
+	 * Gets all detected arrival airports of the airplanes that have flown over
7760
+	 *
7761
+	 * @return Array the airport list
7762
+	 *
7763
+	 */
7764 7764
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7765 7765
 	{
7766 7766
 		global $globalDBdriver;
7767 7767
 		$filter_query = $this->getFilter($filters,true,true);
7768 7768
 		$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 
7769 7769
 			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";
7770
-                if ($olderthanmonths > 0) {
7771
-            		if ($globalDBdriver == 'mysql') {
7770
+				if ($olderthanmonths > 0) {
7771
+					if ($globalDBdriver == 'mysql') {
7772 7772
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7773 7773
 			} else {
7774 7774
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7775 7775
 			}
7776 7776
 		}
7777
-                if ($sincedate != '') {
7778
-            		if ($globalDBdriver == 'mysql') {
7777
+				if ($sincedate != '') {
7778
+					if ($globalDBdriver == 'mysql') {
7779 7779
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7780 7780
 			} else {
7781 7781
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7809,7 +7809,7 @@  discard block
 block discarded – undo
7809 7809
 				$query_values = array_merge($query_values,array(':day' => $day));
7810 7810
 			}
7811 7811
 		}
7812
-                $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7812
+				$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7813 7813
 					ORDER BY airport_arrival_icao_count DESC";
7814 7814
 		if ($limit) $query .= " LIMIT 10";
7815 7815
       
@@ -7837,35 +7837,35 @@  discard block
 block discarded – undo
7837 7837
 	}
7838 7838
 	
7839 7839
 	/**
7840
-	* Gets all detected arrival airports of the airplanes that have flown over
7841
-	*
7842
-	* @return Array the airport list
7843
-	*
7844
-	*/
7840
+	 * Gets all detected arrival airports of the airplanes that have flown over
7841
+	 *
7842
+	 * @return Array the airport list
7843
+	 *
7844
+	 */
7845 7845
 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7846 7846
 	{
7847 7847
 		global $globalDBdriver;
7848 7848
 		$filter_query = $this->getFilter($filters,true,true);
7849 7849
 		$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 
7850 7850
 			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 ";
7851
-                if ($olderthanmonths > 0) {
7852
-            		if ($globalDBdriver == 'mysql') {
7851
+				if ($olderthanmonths > 0) {
7852
+					if ($globalDBdriver == 'mysql') {
7853 7853
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7854 7854
 			} else {
7855 7855
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7856 7856
 			}
7857 7857
 		}
7858
-                if ($sincedate != '') {
7859
-            		if ($globalDBdriver == 'mysql') {
7858
+				if ($sincedate != '') {
7859
+					if ($globalDBdriver == 'mysql') {
7860 7860
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7861 7861
 			} else {
7862 7862
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7863 7863
 			}
7864 7864
 		}
7865 7865
 
7866
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7867
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7866
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7867
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7869 7869
 					ORDER BY airport_arrival_icao_count DESC";
7870 7870
 		if ($limit) $query .= " LIMIT 10";
7871 7871
       
@@ -7895,11 +7895,11 @@  discard block
 block discarded – undo
7895 7895
 	}	
7896 7896
 	
7897 7897
 	/**
7898
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
7899
-	*
7900
-	* @return Array the airport list
7901
-	*
7902
-	*/
7898
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
7899
+	 *
7900
+	 * @return Array the airport list
7901
+	 *
7902
+	 */
7903 7903
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7904 7904
 	{
7905 7905
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7931,11 +7931,11 @@  discard block
 block discarded – undo
7931 7931
 	
7932 7932
 	
7933 7933
 	/**
7934
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7935
-	*
7936
-	* @return Array the airport list
7937
-	*
7938
-	*/
7934
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7935
+	 *
7936
+	 * @return Array the airport list
7937
+	 *
7938
+	 */
7939 7939
 	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7940 7940
 	{
7941 7941
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7966,11 +7966,11 @@  discard block
 block discarded – undo
7966 7966
 	
7967 7967
 	
7968 7968
 	/**
7969
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7970
-	*
7971
-	* @return Array the airport list
7972
-	*
7973
-	*/
7969
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7970
+	 *
7971
+	 * @return Array the airport list
7972
+	 *
7973
+	 */
7974 7974
 	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7975 7975
 	{
7976 7976
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8004,11 +8004,11 @@  discard block
 block discarded – undo
8004 8004
 	
8005 8005
 	
8006 8006
 	/**
8007
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8008
-	*
8009
-	* @return Array the airport list
8010
-	*
8011
-	*/
8007
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8008
+	 *
8009
+	 * @return Array the airport list
8010
+	 *
8011
+	 */
8012 8012
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8013 8013
 	{
8014 8014
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8038,11 +8038,11 @@  discard block
 block discarded – undo
8038 8038
 	
8039 8039
 	
8040 8040
 	/**
8041
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8042
-	*
8043
-	* @return Array the airport list
8044
-	*
8045
-	*/
8041
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8042
+	 *
8043
+	 * @return Array the airport list
8044
+	 *
8045
+	 */
8046 8046
 	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8047 8047
 	{
8048 8048
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8076,11 +8076,11 @@  discard block
 block discarded – undo
8076 8076
 	
8077 8077
 	
8078 8078
 	/**
8079
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8080
-	*
8081
-	* @return Array the airport list
8082
-	*
8083
-	*/
8079
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8080
+	 *
8081
+	 * @return Array the airport list
8082
+	 *
8083
+	 */
8084 8084
 	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8085 8085
 	{
8086 8086
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8111,11 +8111,11 @@  discard block
 block discarded – undo
8111 8111
 	
8112 8112
 	
8113 8113
 	/**
8114
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
8115
-	*
8116
-	* @return Array the airport list
8117
-	*
8118
-	*/
8114
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
8115
+	 *
8116
+	 * @return Array the airport list
8117
+	 *
8118
+	 */
8119 8119
 	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8120 8120
 	{
8121 8121
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8148,11 +8148,11 @@  discard block
 block discarded – undo
8148 8148
 	
8149 8149
 	
8150 8150
 	/**
8151
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8152
-	*
8153
-	* @return Array the airport list
8154
-	*
8155
-	*/
8151
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8152
+	 *
8153
+	 * @return Array the airport list
8154
+	 *
8155
+	 */
8156 8156
 	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8157 8157
 	{
8158 8158
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8182,11 +8182,11 @@  discard block
 block discarded – undo
8182 8182
 	
8183 8183
 	
8184 8184
 	/**
8185
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8186
-	*
8187
-	* @return Array the airport list
8188
-	*
8189
-	*/
8185
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8186
+	 *
8187
+	 * @return Array the airport list
8188
+	 *
8189
+	 */
8190 8190
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8191 8191
 	{
8192 8192
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8220,11 +8220,11 @@  discard block
 block discarded – undo
8220 8220
 	
8221 8221
 	
8222 8222
 	/**
8223
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8224
-	*
8225
-	* @return Array the airport list
8226
-	*
8227
-	*/
8223
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8224
+	 *
8225
+	 * @return Array the airport list
8226
+	 *
8227
+	 */
8228 8228
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8229 8229
 	{
8230 8230
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8255,11 +8255,11 @@  discard block
 block discarded – undo
8255 8255
 	
8256 8256
 	
8257 8257
 	/**
8258
-	* Gets all arrival airports of the airplanes that have flown over based on a date
8259
-	*
8260
-	* @return Array the airport list
8261
-	*
8262
-	*/
8258
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
8259
+	 *
8260
+	 * @return Array the airport list
8261
+	 *
8262
+	 */
8263 8263
 	public function countAllArrivalAirportsByDate($date,$filters = array())
8264 8264
 	{
8265 8265
 		global $globalTimezone, $globalDBdriver;
@@ -8305,11 +8305,11 @@  discard block
 block discarded – undo
8305 8305
 	
8306 8306
 	
8307 8307
 	/**
8308
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
8309
-	*
8310
-	* @return Array the airport list
8311
-	*
8312
-	*/
8308
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
8309
+	 *
8310
+	 * @return Array the airport list
8311
+	 *
8312
+	 */
8313 8313
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8314 8314
 	{
8315 8315
 		global $globalTimezone, $globalDBdriver;
@@ -8352,11 +8352,11 @@  discard block
 block discarded – undo
8352 8352
 	
8353 8353
 	
8354 8354
 	/**
8355
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8356
-	*
8357
-	* @return Array the airport list
8358
-	*
8359
-	*/
8355
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8356
+	 *
8357
+	 * @return Array the airport list
8358
+	 *
8359
+	 */
8360 8360
 	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8361 8361
 	{
8362 8362
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8388,11 +8388,11 @@  discard block
 block discarded – undo
8388 8388
 	}
8389 8389
 	
8390 8390
 	/**
8391
-	* Gets all arrival airports of the airplanes that have flown over based on a owner
8392
-	*
8393
-	* @return Array the airport list
8394
-	*
8395
-	*/
8391
+	 * Gets all arrival airports of the airplanes that have flown over based on a owner
8392
+	 *
8393
+	 * @return Array the airport list
8394
+	 *
8395
+	 */
8396 8396
 	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8397 8397
 	{
8398 8398
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8423,11 +8423,11 @@  discard block
 block discarded – undo
8423 8423
 	}
8424 8424
 
8425 8425
 	/**
8426
-	* Gets all arrival airports of the airplanes that have flown over based on a pilot
8427
-	*
8428
-	* @return Array the airport list
8429
-	*
8430
-	*/
8426
+	 * Gets all arrival airports of the airplanes that have flown over based on a pilot
8427
+	 *
8428
+	 * @return Array the airport list
8429
+	 *
8430
+	 */
8431 8431
 	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8432 8432
 	{
8433 8433
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8458,11 +8458,11 @@  discard block
 block discarded – undo
8458 8458
 	}
8459 8459
 	
8460 8460
 	/**
8461
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8462
-	*
8463
-	* @return Array the airport list
8464
-	*
8465
-	*/
8461
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8462
+	 *
8463
+	 * @return Array the airport list
8464
+	 *
8465
+	 */
8466 8466
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8467 8467
 	{
8468 8468
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8491,11 +8491,11 @@  discard block
 block discarded – undo
8491 8491
 	}
8492 8492
 	
8493 8493
 	/**
8494
-	* Gets all arrival airports by country of the airplanes that have flown over based on a owner
8495
-	*
8496
-	* @return Array the airport list
8497
-	*
8498
-	*/
8494
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a owner
8495
+	 *
8496
+	 * @return Array the airport list
8497
+	 *
8498
+	 */
8499 8499
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8500 8500
 	{
8501 8501
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8511,11 +8511,11 @@  discard block
 block discarded – undo
8511 8511
 	}
8512 8512
 	
8513 8513
 	/**
8514
-	* Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8515
-	*
8516
-	* @return Array the airport list
8517
-	*
8518
-	*/
8514
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8515
+	 *
8516
+	 * @return Array the airport list
8517
+	 *
8518
+	 */
8519 8519
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8520 8520
 	{
8521 8521
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8533,11 +8533,11 @@  discard block
 block discarded – undo
8533 8533
 	
8534 8534
 	
8535 8535
 	/**
8536
-	* Gets all arrival airports of the airplanes that have flown over based on a country
8537
-	*
8538
-	* @return Array the airport list
8539
-	*
8540
-	*/
8536
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
8537
+	 *
8538
+	 * @return Array the airport list
8539
+	 *
8540
+	 */
8541 8541
 	public function countAllArrivalAirportsByCountry($country,$filters = array())
8542 8542
 	{
8543 8543
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8570,11 +8570,11 @@  discard block
 block discarded – undo
8570 8570
 	
8571 8571
 	
8572 8572
 	/**
8573
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
8574
-	*
8575
-	* @return Array the airport list
8576
-	*
8577
-	*/
8573
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
8574
+	 *
8575
+	 * @return Array the airport list
8576
+	 *
8577
+	 */
8578 8578
 	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8579 8579
 	{
8580 8580
 		global $globalDBdriver;
@@ -8606,11 +8606,11 @@  discard block
 block discarded – undo
8606 8606
 
8607 8607
 
8608 8608
 	/**
8609
-	* Counts all airport departure countries
8610
-	*
8611
-	* @return Array the airport departure list
8612
-	*
8613
-	*/
8609
+	 * Counts all airport departure countries
8610
+	 *
8611
+	 * @return Array the airport departure list
8612
+	 *
8613
+	 */
8614 8614
 	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8615 8615
 	{
8616 8616
 		global $globalDBdriver;
@@ -8669,11 +8669,11 @@  discard block
 block discarded – undo
8669 8669
 	
8670 8670
 	
8671 8671
 	/**
8672
-	* Counts all airport arrival countries
8673
-	*
8674
-	* @return Array the airport arrival list
8675
-	*
8676
-	*/
8672
+	 * Counts all airport arrival countries
8673
+	 *
8674
+	 * @return Array the airport arrival list
8675
+	 *
8676
+	 */
8677 8677
 	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8678 8678
 	{
8679 8679
 		global $globalDBdriver;
@@ -8735,11 +8735,11 @@  discard block
 block discarded – undo
8735 8735
 
8736 8736
 
8737 8737
 	/**
8738
-	* Gets all route combinations
8739
-	*
8740
-	* @return Array the route list
8741
-	*
8742
-	*/
8738
+	 * Gets all route combinations
8739
+	 *
8740
+	 * @return Array the route list
8741
+	 *
8742
+	 */
8743 8743
 	public function countAllRoutes($filters = array())
8744 8744
 	{
8745 8745
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8778,11 +8778,11 @@  discard block
 block discarded – undo
8778 8778
 	
8779 8779
 	
8780 8780
 	/**
8781
-	* Gets all route combinations based on an aircraft
8782
-	*
8783
-	* @return Array the route list
8784
-	*
8785
-	*/
8781
+	 * Gets all route combinations based on an aircraft
8782
+	 *
8783
+	 * @return Array the route list
8784
+	 *
8785
+	 */
8786 8786
 	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8787 8787
 	{
8788 8788
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8818,11 +8818,11 @@  discard block
 block discarded – undo
8818 8818
 	
8819 8819
 	
8820 8820
 	/**
8821
-	* Gets all route combinations based on an aircraft registration
8822
-	*
8823
-	* @return Array the route list
8824
-	*
8825
-	*/
8821
+	 * Gets all route combinations based on an aircraft registration
8822
+	 *
8823
+	 * @return Array the route list
8824
+	 *
8825
+	 */
8826 8826
 	public function countAllRoutesByRegistration($registration, $filters = array())
8827 8827
 	{
8828 8828
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8860,11 +8860,11 @@  discard block
 block discarded – undo
8860 8860
 	
8861 8861
 	
8862 8862
 	/**
8863
-	* Gets all route combinations based on an airline
8864
-	*
8865
-	* @return Array the route list
8866
-	*
8867
-	*/
8863
+	 * Gets all route combinations based on an airline
8864
+	 *
8865
+	 * @return Array the route list
8866
+	 *
8867
+	 */
8868 8868
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8869 8869
 	{
8870 8870
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8902,11 +8902,11 @@  discard block
 block discarded – undo
8902 8902
 	
8903 8903
 	
8904 8904
 	/**
8905
-	* Gets all route combinations based on an airport
8906
-	*
8907
-	* @return Array the route list
8908
-	*
8909
-	*/
8905
+	 * Gets all route combinations based on an airport
8906
+	 *
8907
+	 * @return Array the route list
8908
+	 *
8909
+	 */
8910 8910
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8911 8911
 	{
8912 8912
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8943,11 +8943,11 @@  discard block
 block discarded – undo
8943 8943
 	
8944 8944
 	
8945 8945
 	/**
8946
-	* Gets all route combinations based on an country
8947
-	*
8948
-	* @return Array the route list
8949
-	*
8950
-	*/
8946
+	 * Gets all route combinations based on an country
8947
+	 *
8948
+	 * @return Array the route list
8949
+	 *
8950
+	 */
8951 8951
 	public function countAllRoutesByCountry($country, $filters = array())
8952 8952
 	{
8953 8953
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8983,11 +8983,11 @@  discard block
 block discarded – undo
8983 8983
 
8984 8984
 
8985 8985
 	/**
8986
-	* Gets all route combinations based on an date
8987
-	*
8988
-	* @return Array the route list
8989
-	*
8990
-	*/
8986
+	 * Gets all route combinations based on an date
8987
+	 *
8988
+	 * @return Array the route list
8989
+	 *
8990
+	 */
8991 8991
 	public function countAllRoutesByDate($date, $filters = array())
8992 8992
 	{
8993 8993
 		global $globalTimezone, $globalDBdriver;
@@ -9037,11 +9037,11 @@  discard block
 block discarded – undo
9037 9037
 	
9038 9038
 	
9039 9039
 	/**
9040
-	* Gets all route combinations based on an ident/callsign
9041
-	*
9042
-	* @return Array the route list
9043
-	*
9044
-	*/
9040
+	 * Gets all route combinations based on an ident/callsign
9041
+	 *
9042
+	 * @return Array the route list
9043
+	 *
9044
+	 */
9045 9045
 	public function countAllRoutesByIdent($ident, $filters = array())
9046 9046
 	{
9047 9047
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9077,11 +9077,11 @@  discard block
 block discarded – undo
9077 9077
 	}
9078 9078
 	
9079 9079
 	/**
9080
-	* Gets all route combinations based on an owner
9081
-	*
9082
-	* @return Array the route list
9083
-	*
9084
-	*/
9080
+	 * Gets all route combinations based on an owner
9081
+	 *
9082
+	 * @return Array the route list
9083
+	 *
9084
+	 */
9085 9085
 	public function countAllRoutesByOwner($owner,$filters = array())
9086 9086
 	{
9087 9087
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9117,11 +9117,11 @@  discard block
 block discarded – undo
9117 9117
 	}
9118 9118
 	
9119 9119
 	/**
9120
-	* Gets all route combinations based on a pilot
9121
-	*
9122
-	* @return Array the route list
9123
-	*
9124
-	*/
9120
+	 * Gets all route combinations based on a pilot
9121
+	 *
9122
+	 * @return Array the route list
9123
+	 *
9124
+	 */
9125 9125
 	public function countAllRoutesByPilot($pilot,$filters = array())
9126 9126
 	{
9127 9127
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9158,11 +9158,11 @@  discard block
 block discarded – undo
9158 9158
 	
9159 9159
 	
9160 9160
 	/**
9161
-	* Gets all route combinations based on an manufacturer
9162
-	*
9163
-	* @return Array the route list
9164
-	*
9165
-	*/
9161
+	 * Gets all route combinations based on an manufacturer
9162
+	 *
9163
+	 * @return Array the route list
9164
+	 *
9165
+	 */
9166 9166
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9167 9167
 	{
9168 9168
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9200,11 +9200,11 @@  discard block
 block discarded – undo
9200 9200
 	
9201 9201
 	
9202 9202
 	/**
9203
-	* Gets all route combinations with waypoints
9204
-	*
9205
-	* @return Array the route list
9206
-	*
9207
-	*/
9203
+	 * Gets all route combinations with waypoints
9204
+	 *
9205
+	 * @return Array the route list
9206
+	 *
9207
+	 */
9208 9208
 	public function countAllRoutesWithWaypoints($filters = array())
9209 9209
 	{
9210 9210
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9241,11 +9241,11 @@  discard block
 block discarded – undo
9241 9241
 	}
9242 9242
 	
9243 9243
 	/**
9244
-	* Gets all callsigns that have flown over
9245
-	*
9246
-	* @return Array the callsign list
9247
-	*
9248
-	*/
9244
+	 * Gets all callsigns that have flown over
9245
+	 *
9246
+	 * @return Array the callsign list
9247
+	 *
9248
+	 */
9249 9249
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9250 9250
 	{
9251 9251
 		global $globalDBdriver;
@@ -9311,11 +9311,11 @@  discard block
 block discarded – undo
9311 9311
 	}
9312 9312
 
9313 9313
 	/**
9314
-	* Gets all callsigns that have flown over
9315
-	*
9316
-	* @return Array the callsign list
9317
-	*
9318
-	*/
9314
+	 * Gets all callsigns that have flown over
9315
+	 *
9316
+	 * @return Array the callsign list
9317
+	 *
9318
+	 */
9319 9319
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9320 9320
 	{
9321 9321
 		global $globalDBdriver;
@@ -9356,11 +9356,11 @@  discard block
 block discarded – undo
9356 9356
 
9357 9357
 
9358 9358
 	/**
9359
-	* Counts all dates
9360
-	*
9361
-	* @return Array the date list
9362
-	*
9363
-	*/
9359
+	 * Counts all dates
9360
+	 *
9361
+	 * @return Array the date list
9362
+	 *
9363
+	 */
9364 9364
 	public function countAllDates($filters = array())
9365 9365
 	{
9366 9366
 		global $globalTimezone, $globalDBdriver;
@@ -9405,11 +9405,11 @@  discard block
 block discarded – undo
9405 9405
 	}
9406 9406
 	
9407 9407
 	/**
9408
-	* Counts all dates
9409
-	*
9410
-	* @return Array the date list
9411
-	*
9412
-	*/
9408
+	 * Counts all dates
9409
+	 *
9410
+	 * @return Array the date list
9411
+	 *
9412
+	 */
9413 9413
 	public function countAllDatesByAirlines($filters = array())
9414 9414
 	{
9415 9415
 		global $globalTimezone, $globalDBdriver;
@@ -9454,11 +9454,11 @@  discard block
 block discarded – undo
9454 9454
 	}	
9455 9455
 	
9456 9456
 	/**
9457
-	* Counts all dates during the last 7 days
9458
-	*
9459
-	* @return Array the date list
9460
-	*
9461
-	*/
9457
+	 * Counts all dates during the last 7 days
9458
+	 *
9459
+	 * @return Array the date list
9460
+	 *
9461
+	 */
9462 9462
 	public function countAllDatesLast7Days($filters = array())
9463 9463
 	{
9464 9464
 		global $globalTimezone, $globalDBdriver;
@@ -9480,7 +9480,7 @@  discard block
 block discarded – undo
9480 9480
 			$query .= " GROUP BY date_name 
9481 9481
 								ORDER BY date_name ASC";
9482 9482
 			$query_data = array(':offset' => $offset);
9483
-    		}
9483
+			}
9484 9484
 		
9485 9485
 		$sth = $this->db->prepare($query);
9486 9486
 		$sth->execute($query_data);
@@ -9500,11 +9500,11 @@  discard block
 block discarded – undo
9500 9500
 	}
9501 9501
 
9502 9502
 	/**
9503
-	* Counts all dates during the last month
9504
-	*
9505
-	* @return Array the date list
9506
-	*
9507
-	*/
9503
+	 * Counts all dates during the last month
9504
+	 *
9505
+	 * @return Array the date list
9506
+	 *
9507
+	 */
9508 9508
 	public function countAllDatesLastMonth($filters = array())
9509 9509
 	{
9510 9510
 		global $globalTimezone, $globalDBdriver;
@@ -9526,7 +9526,7 @@  discard block
 block discarded – undo
9526 9526
 			$query .= " GROUP BY date_name 
9527 9527
 								ORDER BY date_name ASC";
9528 9528
 			$query_data = array(':offset' => $offset);
9529
-    		}
9529
+			}
9530 9530
 		
9531 9531
 		$sth = $this->db->prepare($query);
9532 9532
 		$sth->execute($query_data);
@@ -9547,11 +9547,11 @@  discard block
 block discarded – undo
9547 9547
 
9548 9548
 
9549 9549
 	/**
9550
-	* Counts all dates during the last month
9551
-	*
9552
-	* @return Array the date list
9553
-	*
9554
-	*/
9550
+	 * Counts all dates during the last month
9551
+	 *
9552
+	 * @return Array the date list
9553
+	 *
9554
+	 */
9555 9555
 	public function countAllDatesLastMonthByAirlines($filters = array())
9556 9556
 	{
9557 9557
 		global $globalTimezone, $globalDBdriver;
@@ -9574,7 +9574,7 @@  discard block
 block discarded – undo
9574 9574
 								GROUP BY spotter_output.airline_icao, date_name 
9575 9575
 								ORDER BY date_name ASC";
9576 9576
 			$query_data = array(':offset' => $offset);
9577
-    		}
9577
+			}
9578 9578
 		
9579 9579
 		$sth = $this->db->prepare($query);
9580 9580
 		$sth->execute($query_data);
@@ -9596,11 +9596,11 @@  discard block
 block discarded – undo
9596 9596
 	
9597 9597
 
9598 9598
 	/**
9599
-	* Counts all month
9600
-	*
9601
-	* @return Array the month list
9602
-	*
9603
-	*/
9599
+	 * Counts all month
9600
+	 *
9601
+	 * @return Array the month list
9602
+	 *
9603
+	 */
9604 9604
 	public function countAllMonths($filters = array())
9605 9605
 	{
9606 9606
 		global $globalTimezone, $globalDBdriver;
@@ -9642,11 +9642,11 @@  discard block
 block discarded – undo
9642 9642
 	}
9643 9643
 
9644 9644
 	/**
9645
-	* Counts all month
9646
-	*
9647
-	* @return Array the month list
9648
-	*
9649
-	*/
9645
+	 * Counts all month
9646
+	 *
9647
+	 * @return Array the month list
9648
+	 *
9649
+	 */
9650 9650
 	public function countAllMonthsByAirlines($filters = array())
9651 9651
 	{
9652 9652
 		global $globalTimezone, $globalDBdriver;
@@ -9691,11 +9691,11 @@  discard block
 block discarded – undo
9691 9691
 	}
9692 9692
 
9693 9693
 	/**
9694
-	* Counts all military month
9695
-	*
9696
-	* @return Array the month list
9697
-	*
9698
-	*/
9694
+	 * Counts all military month
9695
+	 *
9696
+	 * @return Array the month list
9697
+	 *
9698
+	 */
9699 9699
 	public function countAllMilitaryMonths($filters = array())
9700 9700
 	{
9701 9701
 		global $globalTimezone, $globalDBdriver;
@@ -9736,11 +9736,11 @@  discard block
 block discarded – undo
9736 9736
 	}
9737 9737
 	
9738 9738
 	/**
9739
-	* Counts all month owners
9740
-	*
9741
-	* @return Array the month list
9742
-	*
9743
-	*/
9739
+	 * Counts all month owners
9740
+	 *
9741
+	 * @return Array the month list
9742
+	 *
9743
+	 */
9744 9744
 	public function countAllMonthsOwners($filters = array())
9745 9745
 	{
9746 9746
 		global $globalTimezone, $globalDBdriver;
@@ -9782,11 +9782,11 @@  discard block
 block discarded – undo
9782 9782
 	}
9783 9783
 	
9784 9784
 	/**
9785
-	* Counts all month owners
9786
-	*
9787
-	* @return Array the month list
9788
-	*
9789
-	*/
9785
+	 * Counts all month owners
9786
+	 *
9787
+	 * @return Array the month list
9788
+	 *
9789
+	 */
9790 9790
 	public function countAllMonthsOwnersByAirlines($filters = array())
9791 9791
 	{
9792 9792
 		global $globalTimezone, $globalDBdriver;
@@ -9829,11 +9829,11 @@  discard block
 block discarded – undo
9829 9829
 	}
9830 9830
 
9831 9831
 	/**
9832
-	* Counts all month pilot
9833
-	*
9834
-	* @return Array the month list
9835
-	*
9836
-	*/
9832
+	 * Counts all month pilot
9833
+	 *
9834
+	 * @return Array the month list
9835
+	 *
9836
+	 */
9837 9837
 	public function countAllMonthsPilots($filters = array())
9838 9838
 	{
9839 9839
 		global $globalTimezone, $globalDBdriver;
@@ -9875,11 +9875,11 @@  discard block
 block discarded – undo
9875 9875
 	}
9876 9876
 	
9877 9877
 	/**
9878
-	* Counts all month pilot
9879
-	*
9880
-	* @return Array the month list
9881
-	*
9882
-	*/
9878
+	 * Counts all month pilot
9879
+	 *
9880
+	 * @return Array the month list
9881
+	 *
9882
+	 */
9883 9883
 	public function countAllMonthsPilotsByAirlines($filters = array())
9884 9884
 	{
9885 9885
 		global $globalTimezone, $globalDBdriver;
@@ -9922,11 +9922,11 @@  discard block
 block discarded – undo
9922 9922
 	}
9923 9923
 
9924 9924
 	/**
9925
-	* Counts all month airline
9926
-	*
9927
-	* @return Array the month list
9928
-	*
9929
-	*/
9925
+	 * Counts all month airline
9926
+	 *
9927
+	 * @return Array the month list
9928
+	 *
9929
+	 */
9930 9930
 	public function countAllMonthsAirlines($filters = array())
9931 9931
 	{
9932 9932
 		global $globalTimezone, $globalDBdriver;
@@ -9968,11 +9968,11 @@  discard block
 block discarded – undo
9968 9968
 	}
9969 9969
 	
9970 9970
 	/**
9971
-	* Counts all month aircraft
9972
-	*
9973
-	* @return Array the month list
9974
-	*
9975
-	*/
9971
+	 * Counts all month aircraft
9972
+	 *
9973
+	 * @return Array the month list
9974
+	 *
9975
+	 */
9976 9976
 	public function countAllMonthsAircrafts($filters = array())
9977 9977
 	{
9978 9978
 		global $globalTimezone, $globalDBdriver;
@@ -10015,11 +10015,11 @@  discard block
 block discarded – undo
10015 10015
 	
10016 10016
 
10017 10017
 	/**
10018
-	* Counts all month aircraft
10019
-	*
10020
-	* @return Array the month list
10021
-	*
10022
-	*/
10018
+	 * Counts all month aircraft
10019
+	 *
10020
+	 * @return Array the month list
10021
+	 *
10022
+	 */
10023 10023
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10024 10024
 	{
10025 10025
 		global $globalTimezone, $globalDBdriver;
@@ -10062,11 +10062,11 @@  discard block
 block discarded – undo
10062 10062
 	}
10063 10063
 
10064 10064
 	/**
10065
-	* Counts all month real arrival
10066
-	*
10067
-	* @return Array the month list
10068
-	*
10069
-	*/
10065
+	 * Counts all month real arrival
10066
+	 *
10067
+	 * @return Array the month list
10068
+	 *
10069
+	 */
10070 10070
 	public function countAllMonthsRealArrivals($filters = array())
10071 10071
 	{
10072 10072
 		global $globalTimezone, $globalDBdriver;
@@ -10109,11 +10109,11 @@  discard block
 block discarded – undo
10109 10109
 	
10110 10110
 
10111 10111
 	/**
10112
-	* Counts all month real arrival
10113
-	*
10114
-	* @return Array the month list
10115
-	*
10116
-	*/
10112
+	 * Counts all month real arrival
10113
+	 *
10114
+	 * @return Array the month list
10115
+	 *
10116
+	 */
10117 10117
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10118 10118
 	{
10119 10119
 		global $globalTimezone, $globalDBdriver;
@@ -10157,11 +10157,11 @@  discard block
 block discarded – undo
10157 10157
 	
10158 10158
 
10159 10159
 	/**
10160
-	* Counts all dates during the last year
10161
-	*
10162
-	* @return Array the date list
10163
-	*
10164
-	*/
10160
+	 * Counts all dates during the last year
10161
+	 *
10162
+	 * @return Array the date list
10163
+	 *
10164
+	 */
10165 10165
 	public function countAllMonthsLastYear($filters)
10166 10166
 	{
10167 10167
 		global $globalTimezone, $globalDBdriver;
@@ -10183,7 +10183,7 @@  discard block
 block discarded – undo
10183 10183
 			$query .= " GROUP BY year_name, month_name
10184 10184
 								ORDER BY year_name, month_name ASC";
10185 10185
 			$query_data = array(':offset' => $offset);
10186
-    		}
10186
+			}
10187 10187
 		
10188 10188
 		$sth = $this->db->prepare($query);
10189 10189
 		$sth->execute($query_data);
@@ -10206,11 +10206,11 @@  discard block
 block discarded – undo
10206 10206
 	
10207 10207
 	
10208 10208
 	/**
10209
-	* Counts all hours
10210
-	*
10211
-	* @return Array the hour list
10212
-	*
10213
-	*/
10209
+	 * Counts all hours
10210
+	 *
10211
+	 * @return Array the hour list
10212
+	 *
10213
+	 */
10214 10214
 	public function countAllHours($orderby,$filters = array())
10215 10215
 	{
10216 10216
 		global $globalTimezone, $globalDBdriver;
@@ -10271,11 +10271,11 @@  discard block
 block discarded – undo
10271 10271
 	}
10272 10272
 	
10273 10273
 	/**
10274
-	* Counts all hours
10275
-	*
10276
-	* @return Array the hour list
10277
-	*
10278
-	*/
10274
+	 * Counts all hours
10275
+	 *
10276
+	 * @return Array the hour list
10277
+	 *
10278
+	 */
10279 10279
 	public function countAllHoursByAirlines($orderby, $filters = array())
10280 10280
 	{
10281 10281
 		global $globalTimezone, $globalDBdriver;
@@ -10338,11 +10338,11 @@  discard block
 block discarded – undo
10338 10338
 
10339 10339
 
10340 10340
 	/**
10341
-	* Counts all hours by airline
10342
-	*
10343
-	* @return Array the hour list
10344
-	*
10345
-	*/
10341
+	 * Counts all hours by airline
10342
+	 *
10343
+	 * @return Array the hour list
10344
+	 *
10345
+	 */
10346 10346
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10347 10347
 	{
10348 10348
 		global $globalTimezone, $globalDBdriver;
@@ -10388,11 +10388,11 @@  discard block
 block discarded – undo
10388 10388
 	
10389 10389
 	
10390 10390
 	/**
10391
-	* Counts all hours by aircraft
10392
-	*
10393
-	* @return Array the hour list
10394
-	*
10395
-	*/
10391
+	 * Counts all hours by aircraft
10392
+	 *
10393
+	 * @return Array the hour list
10394
+	 *
10395
+	 */
10396 10396
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10397 10397
 	{
10398 10398
 		global $globalTimezone, $globalDBdriver;
@@ -10435,11 +10435,11 @@  discard block
 block discarded – undo
10435 10435
 	
10436 10436
 	
10437 10437
 	/**
10438
-	* Counts all hours by aircraft registration
10439
-	*
10440
-	* @return Array the hour list
10441
-	*
10442
-	*/
10438
+	 * Counts all hours by aircraft registration
10439
+	 *
10440
+	 * @return Array the hour list
10441
+	 *
10442
+	 */
10443 10443
 	public function countAllHoursByRegistration($registration, $filters = array())
10444 10444
 	{
10445 10445
 		global $globalTimezone, $globalDBdriver;
@@ -10482,11 +10482,11 @@  discard block
 block discarded – undo
10482 10482
 	
10483 10483
 	
10484 10484
 	/**
10485
-	* Counts all hours by airport
10486
-	*
10487
-	* @return Array the hour list
10488
-	*
10489
-	*/
10485
+	 * Counts all hours by airport
10486
+	 *
10487
+	 * @return Array the hour list
10488
+	 *
10489
+	 */
10490 10490
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10491 10491
 	{
10492 10492
 		global $globalTimezone, $globalDBdriver;
@@ -10530,11 +10530,11 @@  discard block
 block discarded – undo
10530 10530
 	
10531 10531
 	
10532 10532
 	/**
10533
-	* Counts all hours by manufacturer
10534
-	*
10535
-	* @return Array the hour list
10536
-	*
10537
-	*/
10533
+	 * Counts all hours by manufacturer
10534
+	 *
10535
+	 * @return Array the hour list
10536
+	 *
10537
+	 */
10538 10538
 	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10539 10539
 	{
10540 10540
 		global $globalTimezone, $globalDBdriver;
@@ -10578,11 +10578,11 @@  discard block
 block discarded – undo
10578 10578
 	
10579 10579
 	
10580 10580
 	/**
10581
-	* Counts all hours by date
10582
-	*
10583
-	* @return Array the hour list
10584
-	*
10585
-	*/
10581
+	 * Counts all hours by date
10582
+	 *
10583
+	 * @return Array the hour list
10584
+	 *
10585
+	 */
10586 10586
 	public function countAllHoursByDate($date, $filters = array())
10587 10587
 	{
10588 10588
 		global $globalTimezone, $globalDBdriver;
@@ -10626,11 +10626,11 @@  discard block
 block discarded – undo
10626 10626
 	
10627 10627
 	
10628 10628
 	/**
10629
-	* Counts all hours by a ident/callsign
10630
-	*
10631
-	* @return Array the hour list
10632
-	*
10633
-	*/
10629
+	 * Counts all hours by a ident/callsign
10630
+	 *
10631
+	 * @return Array the hour list
10632
+	 *
10633
+	 */
10634 10634
 	public function countAllHoursByIdent($ident, $filters = array())
10635 10635
 	{
10636 10636
 		global $globalTimezone, $globalDBdriver;
@@ -10673,11 +10673,11 @@  discard block
 block discarded – undo
10673 10673
 	}
10674 10674
 	
10675 10675
 	/**
10676
-	* Counts all hours by a owner
10677
-	*
10678
-	* @return Array the hour list
10679
-	*
10680
-	*/
10676
+	 * Counts all hours by a owner
10677
+	 *
10678
+	 * @return Array the hour list
10679
+	 *
10680
+	 */
10681 10681
 	public function countAllHoursByOwner($owner, $filters = array())
10682 10682
 	{
10683 10683
 		global $globalTimezone, $globalDBdriver;
@@ -10720,11 +10720,11 @@  discard block
 block discarded – undo
10720 10720
 	}
10721 10721
 	
10722 10722
 	/**
10723
-	* Counts all hours by a pilot
10724
-	*
10725
-	* @return Array the hour list
10726
-	*
10727
-	*/
10723
+	 * Counts all hours by a pilot
10724
+	 *
10725
+	 * @return Array the hour list
10726
+	 *
10727
+	 */
10728 10728
 	public function countAllHoursByPilot($pilot, $filters = array())
10729 10729
 	{
10730 10730
 		global $globalTimezone, $globalDBdriver;
@@ -10769,11 +10769,11 @@  discard block
 block discarded – undo
10769 10769
 	
10770 10770
 	
10771 10771
 	/**
10772
-	* Counts all hours by route
10773
-	*
10774
-	* @return Array the hour list
10775
-	*
10776
-	*/
10772
+	 * Counts all hours by route
10773
+	 *
10774
+	 * @return Array the hour list
10775
+	 *
10776
+	 */
10777 10777
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10778 10778
 	{
10779 10779
 		global $globalTimezone, $globalDBdriver;
@@ -10817,11 +10817,11 @@  discard block
 block discarded – undo
10817 10817
 	
10818 10818
 	
10819 10819
 	/**
10820
-	* Counts all hours by country
10821
-	*
10822
-	* @return Array the hour list
10823
-	*
10824
-	*/
10820
+	 * Counts all hours by country
10821
+	 *
10822
+	 * @return Array the hour list
10823
+	 *
10824
+	 */
10825 10825
 	public function countAllHoursByCountry($country, $filters = array())
10826 10826
 	{
10827 10827
 		global $globalTimezone, $globalDBdriver;
@@ -10866,11 +10866,11 @@  discard block
 block discarded – undo
10866 10866
 
10867 10867
 
10868 10868
 	/**
10869
-	* Counts all aircraft that have flown over
10870
-	*
10871
-	* @return Integer the number of aircrafts
10872
-	*
10873
-	*/
10869
+	 * Counts all aircraft that have flown over
10870
+	 *
10871
+	 * @return Integer the number of aircrafts
10872
+	 *
10873
+	 */
10874 10874
 	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10875 10875
 	{
10876 10876
 		global $globalDBdriver;
@@ -10903,11 +10903,11 @@  discard block
 block discarded – undo
10903 10903
 	}
10904 10904
 
10905 10905
 	/**
10906
-	* Counts all flight that really arrival
10907
-	*
10908
-	* @return Integer the number of aircrafts
10909
-	*
10910
-	*/
10906
+	 * Counts all flight that really arrival
10907
+	 *
10908
+	 * @return Integer the number of aircrafts
10909
+	 *
10910
+	 */
10911 10911
 	public function countOverallArrival($filters = array(),$year = '',$month = '')
10912 10912
 	{
10913 10913
 		global $globalDBdriver;
@@ -10940,11 +10940,11 @@  discard block
 block discarded – undo
10940 10940
 	}
10941 10941
 
10942 10942
 	/**
10943
-	* Counts all pilots that have flown over
10944
-	*
10945
-	* @return Integer the number of pilots
10946
-	*
10947
-	*/
10943
+	 * Counts all pilots that have flown over
10944
+	 *
10945
+	 * @return Integer the number of pilots
10946
+	 *
10947
+	 */
10948 10948
 	public function countOverallPilots($filters = array(),$year = '',$month = '')
10949 10949
 	{
10950 10950
 		global $globalDBdriver;
@@ -10976,11 +10976,11 @@  discard block
 block discarded – undo
10976 10976
 	}
10977 10977
 
10978 10978
 	/**
10979
-	* Counts all owners that have flown over
10980
-	*
10981
-	* @return Integer the number of owners
10982
-	*
10983
-	*/
10979
+	 * Counts all owners that have flown over
10980
+	 *
10981
+	 * @return Integer the number of owners
10982
+	 *
10983
+	 */
10984 10984
 	public function countOverallOwners($filters = array(),$year = '',$month = '')
10985 10985
 	{
10986 10986
 		global $globalDBdriver;
@@ -11013,11 +11013,11 @@  discard block
 block discarded – undo
11013 11013
 	
11014 11014
 	
11015 11015
 	/**
11016
-	* Counts all flights that have flown over
11017
-	*
11018
-	* @return Integer the number of flights
11019
-	*
11020
-	*/
11016
+	 * Counts all flights that have flown over
11017
+	 *
11018
+	 * @return Integer the number of flights
11019
+	 *
11020
+	 */
11021 11021
 	public function countOverallFlights($filters = array(),$year = '',$month = '')
11022 11022
 	{
11023 11023
 		global $globalDBdriver;
@@ -11051,11 +11051,11 @@  discard block
 block discarded – undo
11051 11051
 	}
11052 11052
 	
11053 11053
 	/**
11054
-	* Counts all military flights that have flown over
11055
-	*
11056
-	* @return Integer the number of flights
11057
-	*
11058
-	*/
11054
+	 * Counts all military flights that have flown over
11055
+	 *
11056
+	 * @return Integer the number of flights
11057
+	 *
11058
+	 */
11059 11059
 	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11060 11060
 	{
11061 11061
 		global $globalDBdriver;
@@ -11090,11 +11090,11 @@  discard block
 block discarded – undo
11090 11090
 	
11091 11091
 	
11092 11092
 	/**
11093
-	* Counts all airlines that have flown over
11094
-	*
11095
-	* @return Integer the number of airlines
11096
-	*
11097
-	*/
11093
+	 * Counts all airlines that have flown over
11094
+	 *
11095
+	 * @return Integer the number of airlines
11096
+	 *
11097
+	 */
11098 11098
 	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11099 11099
 	{
11100 11100
 		global $globalDBdriver;
@@ -11121,8 +11121,8 @@  discard block
 block discarded – undo
11121 11121
 				$query_values = array_merge($query_values,array(':month' => $month));
11122 11122
 			}
11123 11123
 		}
11124
-                if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11124
+				if ($query == '') $queryi .= $this->getFilter($filters);
11125
+				else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11126 11126
 
11127 11127
 
11128 11128
 		$sth = $this->db->prepare($queryi);
@@ -11132,11 +11132,11 @@  discard block
 block discarded – undo
11132 11132
 
11133 11133
   
11134 11134
 	/**
11135
-	* Counts all hours of today
11136
-	*
11137
-	* @return Array the hour list
11138
-	*
11139
-	*/
11135
+	 * Counts all hours of today
11136
+	 *
11137
+	 * @return Array the hour list
11138
+	 *
11139
+	 */
11140 11140
 	public function countAllHoursFromToday($filters = array())
11141 11141
 	{
11142 11142
 		global $globalTimezone, $globalDBdriver;
@@ -11176,11 +11176,11 @@  discard block
 block discarded – undo
11176 11176
 	}
11177 11177
     
11178 11178
 	/**
11179
-	* Gets all the spotter information based on calculated upcoming flights
11180
-	*
11181
-	* @return Array the spotter information
11182
-	*
11183
-	*/
11179
+	 * Gets all the spotter information based on calculated upcoming flights
11180
+	 *
11181
+	 * @return Array the spotter information
11182
+	 *
11183
+	 */
11184 11184
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11185 11185
 	{
11186 11186
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -11255,12 +11255,12 @@  discard block
 block discarded – undo
11255 11255
 	}
11256 11256
     
11257 11257
     
11258
-     /**
11259
-	* Gets the Barrie Spotter ID based on the FlightAware ID
11260
-	*
11261
-	* @return Integer the Barrie Spotter ID
11258
+	 /**
11259
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
11260
+	  *
11261
+	  * @return Integer the Barrie Spotter ID
11262 11262
 q	*
11263
-	*/
11263
+	  */
11264 11264
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11265 11265
 	{
11266 11266
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -11281,13 +11281,13 @@  discard block
 block discarded – undo
11281 11281
   
11282 11282
  
11283 11283
 	/**
11284
-	* Parses a date string
11285
-	*
11286
-	* @param String $dateString the date string
11287
-	* @param String $timezone the timezone of a user
11288
-	* @return Array the time information
11289
-	*
11290
-	*/
11284
+	 * Parses a date string
11285
+	 *
11286
+	 * @param String $dateString the date string
11287
+	 * @param String $timezone the timezone of a user
11288
+	 * @return Array the time information
11289
+	 *
11290
+	 */
11291 11291
 	public function parseDateString($dateString, $timezone = '')
11292 11292
 	{
11293 11293
 		$time_array = array();
@@ -11323,12 +11323,12 @@  discard block
 block discarded – undo
11323 11323
 	
11324 11324
 	
11325 11325
 	/**
11326
-	* Parses the direction degrees to working
11327
-	*
11328
-	* @param Float $direction the direction in degrees
11329
-	* @return Array the direction information
11330
-	*
11331
-	*/
11326
+	 * Parses the direction degrees to working
11327
+	 *
11328
+	 * @param Float $direction the direction in degrees
11329
+	 * @return Array the direction information
11330
+	 *
11331
+	 */
11332 11332
 	public function parseDirection($direction = 0)
11333 11333
 	{
11334 11334
 		if ($direction == '') $direction = 0;
@@ -11407,12 +11407,12 @@  discard block
 block discarded – undo
11407 11407
 	
11408 11408
 	
11409 11409
 	/**
11410
-	* Gets the aircraft registration
11411
-	*
11412
-	* @param String $flightaware_id the flight aware id
11413
-	* @return String the aircraft registration
11414
-	*
11415
-	*/
11410
+	 * Gets the aircraft registration
11411
+	 *
11412
+	 * @param String $flightaware_id the flight aware id
11413
+	 * @return String the aircraft registration
11414
+	 *
11415
+	 */
11416 11416
 	
11417 11417
 	public function getAircraftRegistration($flightaware_id)
11418 11418
 	{
@@ -11441,12 +11441,12 @@  discard block
 block discarded – undo
11441 11441
 
11442 11442
 
11443 11443
 	/**
11444
-	* Gets the aircraft registration from ModeS
11445
-	*
11446
-	* @param String $aircraft_modes the flight ModeS in hex
11447
-	* @return String the aircraft registration
11448
-	*
11449
-	*/
11444
+	 * Gets the aircraft registration from ModeS
11445
+	 *
11446
+	 * @param String $aircraft_modes the flight ModeS in hex
11447
+	 * @return String the aircraft registration
11448
+	 *
11449
+	 */
11450 11450
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11451 11451
 	{
11452 11452
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11462,8 +11462,8 @@  discard block
 block discarded – undo
11462 11462
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11463 11463
 		$sth->closeCursor();
11464 11464
 		if (count($row) > 0) {
11465
-		    //return $row['Registration'];
11466
-		    return $row['registration'];
11465
+			//return $row['Registration'];
11466
+			return $row['registration'];
11467 11467
 		} elseif ($source_type == 'flarm') {
11468 11468
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11469 11469
 		} else return '';
@@ -11471,12 +11471,12 @@  discard block
 block discarded – undo
11471 11471
 	}
11472 11472
 
11473 11473
 	/**
11474
-	* Gets the aircraft type from ModeS
11475
-	*
11476
-	* @param String $aircraft_modes the flight ModeS in hex
11477
-	* @return String the aircraft type
11478
-	*
11479
-	*/
11474
+	 * Gets the aircraft type from ModeS
11475
+	 *
11476
+	 * @param String $aircraft_modes the flight ModeS in hex
11477
+	 * @return String the aircraft type
11478
+	 *
11479
+	 */
11480 11480
 	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11481 11481
 	{
11482 11482
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11502,12 +11502,12 @@  discard block
 block discarded – undo
11502 11502
 	}
11503 11503
 
11504 11504
 	/**
11505
-	* Gets Country from latitude/longitude
11506
-	*
11507
-	* @param Float $latitude latitute of the flight
11508
-	* @param Float $longitude longitute of the flight
11509
-	* @return String the countrie
11510
-	*/
11505
+	 * Gets Country from latitude/longitude
11506
+	 *
11507
+	 * @param Float $latitude latitute of the flight
11508
+	 * @param Float $longitude longitute of the flight
11509
+	 * @return String the countrie
11510
+	 */
11511 11511
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11512 11512
 	{
11513 11513
 		global $globalDBdriver, $globalDebug;
@@ -11544,11 +11544,11 @@  discard block
 block discarded – undo
11544 11544
 	}
11545 11545
 
11546 11546
 	/**
11547
-	* Gets Country from iso2
11548
-	*
11549
-	* @param String $iso2 ISO2 country code
11550
-	* @return String the countrie
11551
-	*/
11547
+	 * Gets Country from iso2
11548
+	 *
11549
+	 * @param String $iso2 ISO2 country code
11550
+	 * @return String the countrie
11551
+	 */
11552 11552
 	public function getCountryFromISO2($iso2)
11553 11553
 	{
11554 11554
 		global $globalDBdriver, $globalDebug;
@@ -11576,12 +11576,12 @@  discard block
 block discarded – undo
11576 11576
 	}
11577 11577
 
11578 11578
 	/**
11579
-	* converts the registration code using the country prefix
11580
-	*
11581
-	* @param String $registration the aircraft registration
11582
-	* @return String the aircraft registration
11583
-	*
11584
-	*/
11579
+	 * converts the registration code using the country prefix
11580
+	 *
11581
+	 * @param String $registration the aircraft registration
11582
+	 * @return String the aircraft registration
11583
+	 *
11584
+	 */
11585 11585
 	public function convertAircraftRegistration($registration)
11586 11586
 	{
11587 11587
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11633,12 +11633,12 @@  discard block
 block discarded – undo
11633 11633
 	}
11634 11634
 
11635 11635
 	/**
11636
-	* Country from the registration code
11637
-	*
11638
-	* @param String $registration the aircraft registration
11639
-	* @return String the country
11640
-	*
11641
-	*/
11636
+	 * Country from the registration code
11637
+	 *
11638
+	 * @param String $registration the aircraft registration
11639
+	 * @return String the country
11640
+	 *
11641
+	 */
11642 11642
 	public function countryFromAircraftRegistration($registration)
11643 11643
 	{
11644 11644
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11657,8 +11657,8 @@  discard block
 block discarded – undo
11657 11657
 				$country = $row['country'];
11658 11658
 			}
11659 11659
 		} else {
11660
-    			$registration_1 = substr($registration, 0, 1);
11661
-		        $registration_2 = substr($registration, 0, 2);
11660
+				$registration_1 = substr($registration, 0, 1);
11661
+				$registration_2 = substr($registration, 0, 2);
11662 11662
 
11663 11663
 			$country = '';
11664 11664
 			//first get the prefix based on two characters
@@ -11694,12 +11694,12 @@  discard block
 block discarded – undo
11694 11694
 	}
11695 11695
 
11696 11696
 	/**
11697
-	* Registration prefix from the registration code
11698
-	*
11699
-	* @param String $registration the aircraft registration
11700
-	* @return String the registration prefix
11701
-	*
11702
-	*/
11697
+	 * Registration prefix from the registration code
11698
+	 *
11699
+	 * @param String $registration the aircraft registration
11700
+	 * @return String the registration prefix
11701
+	 *
11702
+	 */
11703 11703
 	public function registrationPrefixFromAircraftRegistration($registration)
11704 11704
 	{
11705 11705
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11718,8 +11718,8 @@  discard block
 block discarded – undo
11718 11718
 				//$country = $row['country'];
11719 11719
 			}
11720 11720
 		} else {
11721
-    			$registration_1 = substr($registration, 0, 1);
11722
-		        $registration_2 = substr($registration, 0, 2);
11721
+				$registration_1 = substr($registration, 0, 1);
11722
+				$registration_2 = substr($registration, 0, 2);
11723 11723
 
11724 11724
 			//first get the prefix based on two characters
11725 11725
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
@@ -11755,12 +11755,12 @@  discard block
 block discarded – undo
11755 11755
 
11756 11756
 
11757 11757
 	/**
11758
-	* Country from the registration code
11759
-	*
11760
-	* @param String $registration the aircraft registration
11761
-	* @return String the country
11762
-	*
11763
-	*/
11758
+	 * Country from the registration code
11759
+	 *
11760
+	 * @param String $registration the aircraft registration
11761
+	 * @return String the country
11762
+	 *
11763
+	 */
11764 11764
 	public function countryFromAircraftRegistrationCode($registration)
11765 11765
 	{
11766 11766
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11777,11 +11777,11 @@  discard block
 block discarded – undo
11777 11777
 	}
11778 11778
 	
11779 11779
 	/**
11780
-	* Set a new highlight value for a flight
11781
-	*
11782
-	* @param String $flightaware_id flightaware_id from spotter_output table
11783
-	* @param String $highlight New highlight value
11784
-	*/
11780
+	 * Set a new highlight value for a flight
11781
+	 *
11782
+	 * @param String $flightaware_id flightaware_id from spotter_output table
11783
+	 * @param String $highlight New highlight value
11784
+	 */
11785 11785
 	public function setHighlightFlight($flightaware_id,$highlight) {
11786 11786
 		
11787 11787
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -11790,12 +11790,12 @@  discard block
 block discarded – undo
11790 11790
 	}
11791 11791
 
11792 11792
 	/**
11793
-	* Set a new highlight value for a flight by Registration
11794
-	*
11795
-	* @param String $registration Registration of the aircraft
11796
-	* @param String $date Date of spotted aircraft
11797
-	* @param String $highlight New highlight value
11798
-	*/
11793
+	 * Set a new highlight value for a flight by Registration
11794
+	 *
11795
+	 * @param String $registration Registration of the aircraft
11796
+	 * @param String $date Date of spotted aircraft
11797
+	 * @param String $highlight New highlight value
11798
+	 */
11799 11799
 	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11800 11800
 		if ($date == '') {
11801 11801
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
@@ -11809,12 +11809,12 @@  discard block
 block discarded – undo
11809 11809
 	}
11810 11810
 	
11811 11811
 	/**
11812
-	* Gets the short url from bit.ly
11813
-	*
11814
-	* @param String $url the full url
11815
-	* @return String the bit.ly url
11816
-	*
11817
-	*/
11812
+	 * Gets the short url from bit.ly
11813
+	 *
11814
+	 * @param String $url the full url
11815
+	 * @return String the bit.ly url
11816
+	 *
11817
+	 */
11818 11818
 	public function getBitlyURL($url)
11819 11819
 	{
11820 11820
 		global $globalBitlyAccessToken;
@@ -12103,11 +12103,11 @@  discard block
 block discarded – undo
12103 12103
 			$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 
12104 12104
 	                      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)) 
12105 12105
 	                      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;";
12106
-                } else {
12106
+				} else {
12107 12107
 			$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 
12108 12108
 	                      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)) 
12109 12109
 	                      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;";
12110
-    		}
12110
+			}
12111 12111
 		$sth = $this->db->prepare($query);
12112 12112
 		$sth->execute();
12113 12113
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Spacing   +1353 added lines, -1353 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 $aircraft_correct_icaotype = array('CL64' => 'CL60',
9 9
 					'F9LX' => 'F900',
10 10
 					'K35T' => 'K35R',
@@ -59,62 +59,62 @@  discard block
 block discarded – undo
59 59
 	* @param Array $filter the filter
60 60
 	* @return Array the SQL part
61 61
 	*/
62
-	public function getFilter($filter = array(),$where = false,$and = false) {
62
+	public function getFilter($filter = array(), $where = false, $and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
65 65
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
66 66
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
67 67
 				$filters = $globalStatsFilters[$globalFilterName];
68 68
 			} else {
69
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
69
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter[0]['source'])) {
73
-			$filters = array_merge($filters,$filter);
73
+			$filters = array_merge($filters, $filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
76 76
 		$filter_query_join = '';
77 77
 		$filter_query_where = '';
78
-		foreach($filters as $flt) {
78
+		foreach ($filters as $flt) {
79 79
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
80 80
 				if ($flt['airlines'][0] != '') {
81 81
 					if (isset($flt['source'])) {
82
-						$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'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
82
+						$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'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
83 83
 					} else {
84
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
84
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
85 85
 					}
86 86
 				}
87 87
 			}
88 88
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
89 89
 				if (isset($flt['source'])) {
90
-					$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'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
90
+					$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'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
91 91
 				} else {
92
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
92
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
93 93
 				}
94 94
 			}
95 95
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
96 96
 				if (isset($flt['source'])) {
97
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
97
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
98 98
 				} else {
99
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
99
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
100 100
 				}
101 101
 			}
102 102
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
103 103
 				if (isset($flt['source'])) {
104
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
104
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
105 105
 				} else {
106
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
106
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
107 107
 				}
108 108
 			}
109 109
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
110 110
 				if (isset($flt['source'])) {
111
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id";
111
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id";
112 112
 				}
113 113
 			}
114 114
 		}
115 115
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
116 116
 			if ($filter['airlines'][0] != '') {
117
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id";
117
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id";
118 118
 			}
119 119
 		}
120 120
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 			$filter_query_join .= " INNER JOIN (SELECT icao FROM airlines WHERE alliance = '".$filter['alliance']."') sal ON sal.icao = spotter_output.airline_icao ";
125 125
 		}
126 126
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
127
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id";
127
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id";
128 128
 			}
129 129
 		if (isset($filter['source']) && !empty($filter['source'])) {
130
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
130
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
131 131
 		}
132 132
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
133 133
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
134 134
 		}
135 135
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
136
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
136
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
137 137
 		}
138 138
 		if (isset($filter['year']) && $filter['year'] != '') {
139 139
 			if ($globalDBdriver == 'mysql') {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160 160
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161 161
 		if ($filter_query_where != '') {
162
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
162
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
163 163
 		}
164 164
 		$filter_query = $filter_query_join.$filter_query_where;
165 165
 		return $filter_query;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	* @return Array the spotter information
175 175
 	*
176 176
 	*/
177
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
177
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
178 178
 	{
179 179
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
180 180
 		$Image = new Image($this->db);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 			$sth = $this->db->prepare($query.$limitQuery);
205 205
 			$sth->execute($params);
206 206
 		} catch (PDOException $e) {
207
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
207
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
208 208
 			exit();
209 209
 		}
210 210
 		
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		$spotter_array = array();
215 215
 		
216 216
 
217
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
217
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
218 218
 		{
219 219
 			$num_rows++;
220 220
 			$temp_array = array();
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
259 259
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 260
 				$temp_array['route_stop'] = $row['route_stop'];
261
-				$allroute = explode(' ',$row['route_stop']);
261
+				$allroute = explode(' ', $row['route_stop']);
262 262
 				foreach ($allroute as $route) {
263 263
 					$route_airport_array = $this->getAllAirportInfo($route);
264 264
 					if (isset($route_airport_array[0]['name'])) {
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
 				{
312 312
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
313 313
 				} else {
314
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
314
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
315 315
 				}
316 316
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
317
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
318
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
317
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
318
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
319 319
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
320 320
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
321 321
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
322 322
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
323
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
324
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
323
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
324
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
325 325
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
326 326
 					}
327 327
 				}
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 358
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 359
 					if (is_numeric(substr($row['ident'], 2, 1))) {
360
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
360
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
361 361
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
362
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
362
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
363 363
 					} else {
364 364
 						$airline_array = $this->getAllAirlineInfo('NA');
365 365
 					}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 				}
397 397
 			}
398 398
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
399
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
399
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
400 400
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
401 401
 				if (count($acars_array) > 0) {
402 402
 					$temp_array['acars'] = $acars_array;
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 414
 			}
415 415
 
416
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
416
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 417
 			{
418 418
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
419
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
420
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
421 421
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
422 422
 				if (count($image_array) > 0) {
423 423
 					$temp_array['image'] = $image_array[0]['image'];
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
442 442
 			}
443 443
 			
444
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
444
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
445 445
 				if ($schedules === true) {
446 446
 					$schedule_array = $Schedule->getSchedule($temp_array['ident']);
447 447
 					//print_r($schedule_array);
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 			if (isset($row['squawk'])) {
524 524
 				$temp_array['squawk'] = $row['squawk'];
525 525
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
526
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
527
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
528 528
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
529
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
530
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
531
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
532 532
 			}
533 533
     			
534 534
 			$temp_array['query_number_rows'] = $num_rows;
@@ -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');
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 		$query_values = array();
559 559
 		$additional_query = '';
560
-		$filter_query = $this->getFilter($filters,true,true);
560
+		$filter_query = $this->getFilter($filters, true, true);
561 561
 		if ($q != "")
562 562
 		{
563 563
 			if (!is_string($q))
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
 				return false;
566 566
 			} else {
567 567
 				$q_array = explode(" ", $q);
568
-				foreach ($q_array as $q_item){
569
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
568
+				foreach ($q_array as $q_item) {
569
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
570 570
 					$additional_query .= " AND (";
571 571
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
572 572
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -598,37 +598,37 @@  discard block
 block discarded – undo
598 598
 
599 599
 		if ($registration != "")
600 600
 		{
601
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
601
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
602 602
 			if (!is_string($registration))
603 603
 			{
604 604
 				return false;
605 605
 			} else {
606 606
 				$additional_query .= " AND spotter_output.registration = :registration";
607
-				$query_values = array_merge($query_values,array(':registration' => $registration));
607
+				$query_values = array_merge($query_values, array(':registration' => $registration));
608 608
 			}
609 609
 		}
610 610
 
611 611
 		if ($aircraft_icao != "")
612 612
 		{
613
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
613
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
614 614
 			if (!is_string($aircraft_icao))
615 615
 			{
616 616
 				return false;
617 617
 			} else {
618 618
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
619
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
619
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
620 620
 			}
621 621
 		}
622 622
 
623 623
 		if ($aircraft_manufacturer != "")
624 624
 		{
625
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
625
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
626 626
 			if (!is_string($aircraft_manufacturer))
627 627
 			{
628 628
 				return false;
629 629
 			} else {
630 630
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
631
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
631
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
632 632
 			}
633 633
 		}
634 634
 
@@ -644,25 +644,25 @@  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;
651 651
 			} else {
652 652
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
653
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
653
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
654 654
 			}
655 655
 		}
656 656
 
657 657
 		if ($airline_country != "")
658 658
 		{
659
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 			if (!is_string($airline_country))
661 661
 			{
662 662
 				return false;
663 663
 			} else {
664 664
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
665
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
665
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
666 666
 			}
667 667
 		}
668 668
 
@@ -689,31 +689,31 @@  discard block
 block discarded – undo
689 689
 
690 690
 		if ($airport != "")
691 691
 		{
692
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 			if (!is_string($airport))
694 694
 			{
695 695
 				return false;
696 696
 			} else {
697 697
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
698
-				$query_values = array_merge($query_values,array(':airport' => $airport));
698
+				$query_values = array_merge($query_values, array(':airport' => $airport));
699 699
 			}
700 700
 		}
701 701
 
702 702
 		if ($airport_country != "")
703 703
 		{
704
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
705 705
 			if (!is_string($airport_country))
706 706
 			{
707 707
 				return false;
708 708
 			} else {
709 709
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
710
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
710
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
711 711
 			}
712 712
 		}
713 713
     
714 714
 		if ($callsign != "")
715 715
 		{
716
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
716
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
717 717
 			if (!is_string($callsign))
718 718
 			{
719 719
 				return false;
@@ -721,79 +721,79 @@  discard block
 block discarded – undo
721 721
 				$translate = $Translation->ident2icao($callsign);
722 722
 				if ($translate != $callsign) {
723 723
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
724
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
724
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
725 725
 				} else {
726 726
 					$additional_query .= " AND spotter_output.ident = :callsign";
727
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
727
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
728 728
 				}
729 729
 			}
730 730
 		}
731 731
 
732 732
 		if ($owner != "")
733 733
 		{
734
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
734
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
735 735
 			if (!is_string($owner))
736 736
 			{
737 737
 				return false;
738 738
 			} else {
739 739
 				$additional_query .= " AND spotter_output.owner_name = :owner";
740
-				$query_values = array_merge($query_values,array(':owner' => $owner));
740
+				$query_values = array_merge($query_values, array(':owner' => $owner));
741 741
 			}
742 742
 		}
743 743
 
744 744
 		if ($pilot_name != "")
745 745
 		{
746
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
746
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
747 747
 			if (!is_string($pilot_name))
748 748
 			{
749 749
 				return false;
750 750
 			} else {
751 751
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
752
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
752
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
753 753
 			}
754 754
 		}
755 755
 
756 756
 		if ($pilot_id != "")
757 757
 		{
758
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
758
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
759 759
 			if (!is_string($pilot_id))
760 760
 			{
761 761
 				return false;
762 762
 			} else {
763 763
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
764
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
764
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
765 765
 			}
766 766
 		}
767 767
 
768 768
 		if ($departure_airport_route != "")
769 769
 		{
770
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
771 771
 			if (!is_string($departure_airport_route))
772 772
 			{
773 773
 				return false;
774 774
 			} else {
775 775
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
776
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
776
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
777 777
 			}
778 778
 		}
779 779
 
780 780
 		if ($arrival_airport_route != "")
781 781
 		{
782
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
782
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
783 783
 			if (!is_string($arrival_airport_route))
784 784
 			{
785 785
 				return false;
786 786
 			} else {
787 787
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
788
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
788
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
789 789
 			}
790 790
 		}
791 791
 
792 792
 		if ($altitude != "")
793 793
 		{
794 794
 			$altitude_array = explode(",", $altitude);
795
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
796
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
796
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
797 797
 
798 798
 			if ($altitude_array[1] != "")
799 799
 			{                
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 		if ($date_posted != "")
810 810
 		{
811 811
 			$date_array = explode(",", $date_posted);
812
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
812
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
813
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
814 814
 
815 815
 			if ($globalTimezone != '') {
816 816
 				date_default_timezone_set($globalTimezone);
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 		{
842 842
 			$limit_array = explode(",", $limit);
843 843
 			
844
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
845
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
844
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
845
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
846 846
 			
847 847
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
848 848
 			{
@@ -871,23 +871,23 @@  discard block
 block discarded – undo
871 871
 
872 872
 
873 873
 		if ($origLat != "" && $origLon != "" && $dist != "") {
874
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
874
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
875 875
 
876 876
 			if ($globalDBdriver == 'mysql') {
877
-				$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 
877
+				$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 
878 878
 						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)) 
879 879
 						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;
880 880
 			} else {
881
-				$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 
881
+				$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 
882 882
 						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)) 
883 883
 						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;
884 884
 			}
885 885
 		} else {		
886
-			$query  = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
886
+			$query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
887 887
 					".$additional_query."
888 888
 					".$orderby_query;
889 889
 		}
890
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
890
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
891 891
 		return $spotter_array;
892 892
 	}
893 893
 	
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 		{
911 911
 			$limit_array = explode(",", $limit);
912 912
 			
913
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
914
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
913
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
914
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
915 915
 			
916 916
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
917 917
 			{
@@ -928,9 +928,9 @@  discard block
 block discarded – undo
928 928
 			$orderby_query = " ORDER BY spotter_output.date DESC";
929 929
 		}
930 930
 
931
-		$query  = $global_query.$filter_query." ".$orderby_query;
931
+		$query = $global_query.$filter_query." ".$orderby_query;
932 932
 
933
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
933
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
934 934
 
935 935
 		return $spotter_array;
936 936
 	}
@@ -976,34 +976,34 @@  discard block
 block discarded – undo
976 976
 			{
977 977
 				return false;
978 978
 			} else {
979
-				if ($interval == "30m"){
979
+				if ($interval == "30m") {
980 980
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
981
-				} else if ($interval == "1h"){
981
+				} else if ($interval == "1h") {
982 982
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
983
-				} else if ($interval == "3h"){
983
+				} else if ($interval == "3h") {
984 984
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
985
-				} else if ($interval == "6h"){
985
+				} else if ($interval == "6h") {
986 986
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
987
-				} else if ($interval == "12h"){
987
+				} else if ($interval == "12h") {
988 988
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
989
-				} else if ($interval == "24h"){
989
+				} else if ($interval == "24h") {
990 990
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
991
-				} else if ($interval == "7d"){
991
+				} else if ($interval == "7d") {
992 992
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
993
-				} else if ($interval == "30d"){
993
+				} else if ($interval == "30d") {
994 994
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
995 995
 				} 
996 996
 			}
997 997
 		}
998 998
 
999
-		$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 
999
+		$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 
1000 1000
                    WHERE spotter_output.latitude <> '' 
1001 1001
 				   AND spotter_output.longitude <> '' 
1002 1002
                    ".$additional_query."
1003 1003
                    HAVING distance < :radius  
1004 1004
 				   ORDER BY distance";
1005 1005
 
1006
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
1006
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
1007 1007
 
1008 1008
 		return $spotter_array;
1009 1009
 	}
@@ -1015,21 +1015,21 @@  discard block
 block discarded – undo
1015 1015
 	* @return Array the spotter information
1016 1016
 	*
1017 1017
 	*/
1018
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1018
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
1019 1019
 	{
1020 1020
 		global $global_query;
1021 1021
 		
1022 1022
 		date_default_timezone_set('UTC');
1023 1023
 
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.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;
1049
+		$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;
1050 1050
 
1051 1051
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1052 1052
 
@@ -1065,15 +1065,15 @@  discard block
 block discarded – undo
1065 1065
 		global $global_query;
1066 1066
 		
1067 1067
 		date_default_timezone_set('UTC');
1068
-		$filter_query = $this->getFilter($filter,true,true);
1068
+		$filter_query = $this->getFilter($filter, true, true);
1069 1069
 
1070 1070
 		$limit_query = '';
1071 1071
 		if ($limit != "")
1072 1072
 		{
1073 1073
 			$limit_array = explode(",", $limit);
1074 1074
 			
1075
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1076
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1075
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1076
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1077 1077
 			
1078 1078
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1079 1079
 			{
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1091 1091
 		}
1092 1092
 
1093
-		$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;
1093
+		$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;
1094 1094
 
1095 1095
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1096 1096
 
@@ -1104,20 +1104,20 @@  discard block
 block discarded – undo
1104 1104
 	* @return Array the spotter information
1105 1105
 	*
1106 1106
 	*/
1107
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1107
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
1108 1108
 	{
1109 1109
 		global $global_query;
1110 1110
 		
1111 1111
 		date_default_timezone_set('UTC');
1112
-		$filter_query = $this->getFilter($filter,true,true);
1112
+		$filter_query = $this->getFilter($filter, true, true);
1113 1113
 		
1114 1114
 		$limit_query = '';
1115 1115
 		if ($limit != "")
1116 1116
 		{
1117 1117
 			$limit_array = explode(",", $limit);
1118 1118
 			
1119
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1120
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1119
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1120
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1121 1121
 			
1122 1122
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1123 1123
 			{
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1135 1135
 		}
1136 1136
 
1137
-		$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;
1137
+		$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;
1138 1138
 
1139 1139
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1140 1140
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 		
1155 1155
 		date_default_timezone_set('UTC');
1156 1156
 		
1157
-		$filter_query = $this->getFilter($filter,true,true);
1157
+		$filter_query = $this->getFilter($filter, true, true);
1158 1158
 		
1159 1159
 		$limit_query = '';
1160 1160
 		
@@ -1162,8 +1162,8 @@  discard block
 block discarded – undo
1162 1162
 		{
1163 1163
 			$limit_array = explode(",", $limit);
1164 1164
 			
1165
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1166
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1165
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1166
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1167 1167
 			
1168 1168
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1169 1169
 			{
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1181 1181
 		}
1182 1182
 
1183
-		$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;
1183
+		$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;
1184 1184
 
1185 1185
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1186 1186
 
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 		global $global_query;
1200 1200
 		
1201 1201
 		date_default_timezone_set('UTC');
1202
-		$filter_query = $this->getFilter($filter,true,true);
1202
+		$filter_query = $this->getFilter($filter, true, true);
1203 1203
 		$limit_query = '';
1204 1204
 		if ($limit != "")
1205 1205
 		{
1206 1206
 			$limit_array = explode(",", $limit);
1207 1207
 			
1208
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1209
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1208
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1209
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1210 1210
 			
1211 1211
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1212 1212
 			{
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1224 1224
 		}
1225 1225
 
1226
-		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' 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;
1226
+		$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' 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;
1227 1227
 
1228 1228
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1229 1229
 
@@ -1247,9 +1247,9 @@  discard block
 block discarded – undo
1247 1247
 		$query_values = array(':id' => $id);
1248 1248
 
1249 1249
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1250
-		$query  = $global_query." WHERE ".$additional_query." ";
1250
+		$query = $global_query." WHERE ".$additional_query." ";
1251 1251
 
1252
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1252
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1253 1253
 
1254 1254
 		return $spotter_array;
1255 1255
 	}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 		$query_values = array();
1273 1273
 		$limit_query = '';
1274 1274
 		$additional_query = '';
1275
-		$filter_query = $this->getFilter($filter,true,true);
1275
+		$filter_query = $this->getFilter($filter, true, true);
1276 1276
 		if ($ident != "")
1277 1277
 		{
1278 1278
 			if (!is_string($ident))
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 		{
1289 1289
 			$limit_array = explode(",", $limit);
1290 1290
 			
1291
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1292
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1291
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1292
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1293 1293
 			
1294 1294
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1295 1295
 			{
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 		$query_values = array();
1329 1329
 		$limit_query = '';
1330 1330
 		$additional_query = '';
1331
-		$filter_query = $this->getFilter($filter,true,true);
1331
+		$filter_query = $this->getFilter($filter, true, true);
1332 1332
 		if ($owner != "")
1333 1333
 		{
1334 1334
 			if (!is_string($owner))
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 		{
1345 1345
 			$limit_array = explode(",", $limit);
1346 1346
 			
1347
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1348
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1347
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1348
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1349 1349
 			
1350 1350
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1351 1351
 			{
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		$query_values = array();
1386 1386
 		$limit_query = '';
1387 1387
 		$additional_query = '';
1388
-		$filter_query = $this->getFilter($filter,true,true);
1388
+		$filter_query = $this->getFilter($filter, true, true);
1389 1389
 		if ($pilot != "")
1390 1390
 		{
1391 1391
 			$additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
@@ -1396,8 +1396,8 @@  discard block
 block discarded – undo
1396 1396
 		{
1397 1397
 			$limit_array = explode(",", $limit);
1398 1398
 			
1399
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1400
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1399
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1400
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1401 1401
 			
1402 1402
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1403 1403
 			{
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 		$query_values = array();
1439 1439
 		$limit_query = '';
1440 1440
 		$additional_query = '';
1441
-		$filter_query = $this->getFilter($filter,true,true);
1441
+		$filter_query = $this->getFilter($filter, true, true);
1442 1442
 		
1443 1443
 		if ($aircraft_type != "")
1444 1444
 		{
@@ -1455,8 +1455,8 @@  discard block
 block discarded – undo
1455 1455
 		{
1456 1456
 			$limit_array = explode(",", $limit);
1457 1457
 			
1458
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1459
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1458
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1459
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1460 1460
 			
1461 1461
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1462 1462
 			{
@@ -1512,8 +1512,8 @@  discard block
 block discarded – undo
1512 1512
 		{
1513 1513
 			$limit_array = explode(",", $limit);
1514 1514
 			
1515
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1516
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1515
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1516
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1517 1517
 			
1518 1518
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1519 1519
 			{
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 		} else {
1530 1530
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1531 1531
 		}
1532
-		$filter_query = $this->getFilter($filter,true,true);
1532
+		$filter_query = $this->getFilter($filter, true, true);
1533 1533
 
1534 1534
 		//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1535 1535
 		$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query;
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	* @return Array the spotter information
1549 1549
 	*
1550 1550
 	*/
1551
-	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1551
+	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '', $filters = array())
1552 1552
 	{
1553 1553
 		global $global_query;
1554 1554
 		
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 		$query_values = array();
1558 1558
 		$limit_query = '';
1559 1559
 		$additional_query = '';
1560
-		$filter_query = $this->getFilter($filters,true,true);
1560
+		$filter_query = $this->getFilter($filters, true, true);
1561 1561
 		
1562 1562
 		if ($airline != "")
1563 1563
 		{
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 		{
1575 1575
 			$limit_array = explode(",", $limit);
1576 1576
 			
1577
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1578
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1577
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1578
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1579 1579
 			
1580 1580
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1581 1581
 			{
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 	* @return Array the spotter information
1606 1606
 	*
1607 1607
 	*/
1608
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1608
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1609 1609
 	{
1610 1610
 		global $global_query;
1611 1611
 		
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 		$query_values = array();
1614 1614
 		$limit_query = '';
1615 1615
 		$additional_query = '';
1616
-		$filter_query = $this->getFilter($filters,true,true);
1616
+		$filter_query = $this->getFilter($filters, true, true);
1617 1617
 		
1618 1618
 		if ($airport != "")
1619 1619
 		{
@@ -1630,8 +1630,8 @@  discard block
 block discarded – undo
1630 1630
 		{
1631 1631
 			$limit_array = explode(",", $limit);
1632 1632
 			
1633
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1634
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1633
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1634
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1635 1635
 			
1636 1636
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1637 1637
 			{
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 	* @return Array the spotter information
1664 1664
 	*
1665 1665
 	*/
1666
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1666
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1667 1667
 	{
1668 1668
 		global $global_query, $globalTimezone, $globalDBdriver;
1669 1669
 		
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 		$limit_query = '';
1672 1672
 		$additional_query = '';
1673 1673
 
1674
-		$filter_query = $this->getFilter($filter,true,true);
1674
+		$filter_query = $this->getFilter($filter, true, true);
1675 1675
 		
1676 1676
 		if ($date != "")
1677 1677
 		{
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 		{
1701 1701
 			$limit_array = explode(",", $limit);
1702 1702
 			
1703
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1704
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1703
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1704
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1705 1705
 			
1706 1706
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1707 1707
 			{
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	* @return Array the spotter information
1732 1732
 	*
1733 1733
 	*/
1734
-	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1734
+	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '', $filters = array())
1735 1735
 	{
1736 1736
 		global $global_query;
1737 1737
 		
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
 		$query_values = array();
1741 1741
 		$limit_query = '';
1742 1742
 		$additional_query = '';
1743
-		$filter_query = $this->getFilter($filters,true,true);
1743
+		$filter_query = $this->getFilter($filters, true, true);
1744 1744
 		if ($country != "")
1745 1745
 		{
1746 1746
 			if (!is_string($country))
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 		{
1758 1758
 			$limit_array = explode(",", $limit);
1759 1759
 			
1760
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1761
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1760
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1761
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1762 1762
 			
1763 1763
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1764 1764
 			{
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
 		$query_values = array();
1799 1799
 		$additional_query = '';
1800 1800
 		$limit_query = '';
1801
-		$filter_query = $this->getFilter($filters,true,true);
1801
+		$filter_query = $this->getFilter($filters, true, true);
1802 1802
 		
1803 1803
 		if ($aircraft_manufacturer != "")
1804 1804
 		{
@@ -1815,8 +1815,8 @@  discard block
 block discarded – undo
1815 1815
 		{
1816 1816
 			$limit_array = explode(",", $limit);
1817 1817
 			
1818
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1819
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1818
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1819
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1820 1820
 			
1821 1821
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1822 1822
 			{
@@ -1858,14 +1858,14 @@  discard block
 block discarded – undo
1858 1858
 		$query_values = array();
1859 1859
 		$additional_query = '';
1860 1860
 		$limit_query = '';
1861
-		$filter_query = $this->getFilter($filters,true,true);
1861
+		$filter_query = $this->getFilter($filters, true, true);
1862 1862
 		if ($departure_airport_icao != "")
1863 1863
 		{
1864 1864
 			if (!is_string($departure_airport_icao))
1865 1865
 			{
1866 1866
 				return false;
1867 1867
 			} else {
1868
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1868
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1869 1869
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1870 1870
 				//$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao";
1871 1871
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
@@ -1878,10 +1878,10 @@  discard block
 block discarded – undo
1878 1878
 			{
1879 1879
 				return false;
1880 1880
 			} else {
1881
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1881
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1882 1882
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1883 1883
 				//$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)";
1884
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1884
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1885 1885
 			}
1886 1886
 		}
1887 1887
 		
@@ -1889,8 +1889,8 @@  discard block
 block discarded – undo
1889 1889
 		{
1890 1890
 			$limit_array = explode(",", $limit);
1891 1891
 			
1892
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1893
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1892
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1893
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1894 1894
 			
1895 1895
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1896 1896
 			{
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
 		global $global_query;
1930 1930
 		
1931 1931
 		date_default_timezone_set('UTC');
1932
-		$filter_query = $this->getFilter($filter,true,true);
1932
+		$filter_query = $this->getFilter($filter, true, true);
1933 1933
 		$limit_query = '';
1934 1934
 		
1935 1935
 		if ($limit != "")
1936 1936
 		{
1937 1937
 			$limit_array = explode(",", $limit);
1938 1938
 			
1939
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1940
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1939
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1940
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1941 1941
 			
1942 1942
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1943 1943
 			{
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1955 1955
 		}
1956 1956
 
1957
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1957
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1958 1958
 
1959 1959
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1960 1960
 
@@ -1967,19 +1967,19 @@  discard block
 block discarded – undo
1967 1967
 	* @return String the highlight text
1968 1968
 	*
1969 1969
 	*/
1970
-	public function getHighlightByRegistration($registration,$filter = array())
1970
+	public function getHighlightByRegistration($registration, $filter = array())
1971 1971
 	{
1972 1972
 		global $global_query;
1973 1973
 		
1974 1974
 		date_default_timezone_set('UTC');
1975
-		$filter_query = $this->getFilter($filter,true,true);
1976
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1975
+		$filter_query = $this->getFilter($filter, true, true);
1976
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1977 1977
 		
1978
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1978
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1979 1979
 		$sth = $this->db->prepare($query);
1980 1980
 		$sth->execute(array(':registration' => $registration));
1981 1981
 
1982
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1982
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1983 1983
 		{
1984 1984
 			$highlight = $row['highlight'];
1985 1985
 		}
@@ -1995,14 +1995,14 @@  discard block
 block discarded – undo
1995 1995
 	* @return String usage
1996 1996
 	*
1997 1997
 	*/
1998
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1998
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1999 1999
 	{
2000 2000
 		
2001
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
2002
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
2001
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
2002
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
2003 2003
 
2004 2004
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
2005
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
2005
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
2006 2006
 		
2007 2007
 		$sth = $this->db->prepare($query);
2008 2008
 		$sth->execute($query_values);
@@ -2024,9 +2024,9 @@  discard block
 block discarded – undo
2024 2024
 	public function getAirportIcao($airport_iata = '')
2025 2025
 	{
2026 2026
 		
2027
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
2027
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
2028 2028
 
2029
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2029
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2030 2030
 		$query_values = array(':airport' => $airport_iata);
2031 2031
 		
2032 2032
 		$sth = $this->db->prepare($query);
@@ -2048,12 +2048,12 @@  discard block
 block discarded – undo
2048 2048
 	* @return Float distance to the airport
2049 2049
 	*
2050 2050
 	*/
2051
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
2051
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
2052 2052
 	{
2053 2053
 		
2054
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
2054
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
2055 2055
 
2056
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2056
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2057 2057
 		$query_values = array(':airport' => $airport_icao);
2058 2058
 		$sth = $this->db->prepare($query);
2059 2059
 		$sth->execute($query_values);
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 			$airport_latitude = $row['latitude'];
2064 2064
 			$airport_longitude = $row['longitude'];
2065 2065
 			$Common = new Common();
2066
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2066
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
2067 2067
 		} else return '';
2068 2068
 	}
2069 2069
 	
@@ -2077,11 +2077,11 @@  discard block
 block discarded – undo
2077 2077
 	public function getAllAirportInfo($airport = '')
2078 2078
 	{
2079 2079
 		
2080
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
2080
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
2081 2081
 
2082 2082
 		$query_values = array();
2083 2083
 		if ($airport == 'NA') {
2084
-			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' => ''));
2084
+			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' => ''));
2085 2085
 		} elseif ($airport == '') {
2086 2086
 			$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";
2087 2087
 		} else {
@@ -2129,14 +2129,14 @@  discard block
 block discarded – undo
2129 2129
 	{
2130 2130
 		$lst_countries = '';
2131 2131
 		foreach ($countries as $country) {
2132
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
2132
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
2133 2133
 			if ($lst_countries == '') {
2134 2134
 				$lst_countries = "'".$country."'";
2135 2135
 			} else {
2136 2136
 				$lst_countries .= ",'".$country."'";
2137 2137
 			}
2138 2138
 		}
2139
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2139
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2140 2140
 		
2141 2141
 		$sth = $this->db->prepare($query);
2142 2142
 		$sth->execute();
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		$airport_array = array();
2145 2145
 		$temp_array = array();
2146 2146
 		
2147
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2147
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2148 2148
 		{
2149 2149
 			$temp_array['name'] = $row['name'];
2150 2150
 			$temp_array['city'] = $row['city'];
@@ -2172,10 +2172,10 @@  discard block
 block discarded – undo
2172 2172
 	{
2173 2173
 		global $globalDBdriver;
2174 2174
 		if (is_array($coord)) {
2175
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2176
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2175
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2176
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2177
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2178
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2179 2179
 		} else return array();
2180 2180
 		if ($globalDBdriver == 'mysql') {
2181 2181
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
     
2188 2188
 		$airport_array = array();
2189 2189
 		
2190
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2190
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2191 2191
 		{
2192 2192
 			$temp_array = $row;
2193 2193
 
@@ -2207,13 +2207,13 @@  discard block
 block discarded – undo
2207 2207
 	public function getAllWaypointsInfobyCoord($coord)
2208 2208
 	{
2209 2209
 		if (is_array($coord)) {
2210
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2211
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2210
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2211
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2212
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2213
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2214 2214
 		} else return array();
2215 2215
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216
-		$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.")";
2216
+		$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.")";
2217 2217
 		//$query  = "SELECT waypoints.* FROM waypoints";
2218 2218
 		//$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";
2219 2219
 		//$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;
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
     
2226 2226
 		$waypoints_array = array();
2227 2227
 		
2228
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2228
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2229 2229
 		{
2230 2230
 			$temp_array = $row;
2231 2231
 
@@ -2247,10 +2247,10 @@  discard block
 block discarded – undo
2247 2247
 	{
2248 2248
 		global $globalUseRealAirlines;
2249 2249
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2250
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2250
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2251 2251
 		if ($airline_icao == 'NA') {
2252 2252
 			$airline_array = array();
2253
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2253
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2254 2254
 			return $airline_array;
2255 2255
 		} else {
2256 2256
 			if (strlen($airline_icao) == 2) {
@@ -2271,7 +2271,7 @@  discard block
 block discarded – undo
2271 2271
 			if ($fromsource === NULL) {
2272 2272
 				$sth->execute(array(':airline_icao' => $airline_icao));
2273 2273
 			} else {
2274
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2274
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2275 2275
 			}
2276 2276
                         /*
2277 2277
 			$airline_array = array();
@@ -2316,13 +2316,13 @@  discard block
 block discarded – undo
2316 2316
 	{
2317 2317
 		global $globalUseRealAirlines;
2318 2318
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2319
-		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320
-		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2319
+		$airline_name = strtolower(filter_var($airline_name, FILTER_SANITIZE_STRING));
2320
+		$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2321
 		$sth = $this->db->prepare($query);
2322 2322
 		if ($fromsource === NULL) {
2323 2323
 			$sth->execute(array(':airline_name' => $airline_name));
2324 2324
 		} else {
2325
-			$sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource));
2325
+			$sth->execute(array(':airline_name' => $airline_name, ':fromsource' => $fromsource));
2326 2326
 		}
2327 2327
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2328 2328
 		if (empty($result) && $fromsource !== NULL) {
@@ -2347,12 +2347,12 @@  discard block
 block discarded – undo
2347 2347
 	*/
2348 2348
 	public function getAllAircraftInfo($aircraft_type)
2349 2349
 	{
2350
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2350
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2351 2351
 
2352 2352
 		if ($aircraft_type == 'NA') {
2353
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2353
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2354 2354
 		}
2355
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type";
2355
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type";
2356 2356
 		
2357 2357
 		$sth = $this->db->prepare($query);
2358 2358
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
 	*/
2385 2385
 	public function getAircraftIcao($aircraft_type)
2386 2386
 	{
2387
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2387
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2388 2388
 		$all_aircraft = array('737-300' => 'B733',
2389 2389
 				'777-200' => 'B772',
2390 2390
 				'777-200ER' => 'B772',
@@ -2396,10 +2396,10 @@  discard block
 block discarded – undo
2396 2396
 				'A380' => 'A388');
2397 2397
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2398 2398
 
2399
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2399
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2400
 		$aircraft_type = strtoupper($aircraft_type);
2401 2401
 		$sth = $this->db->prepare($query);
2402
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2402
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2403 2403
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404 2404
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405 2405
 		else return '';
@@ -2412,10 +2412,10 @@  discard block
 block discarded – undo
2412 2412
 	* @return String aircraft type
2413 2413
 	*
2414 2414
 	*/
2415
-	public function getAllAircraftType($aircraft_modes,$source_type = '')
2415
+	public function getAllAircraftType($aircraft_modes, $source_type = '')
2416 2416
 	{
2417
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2418
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
2417
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2418
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
2419 2419
 
2420 2420
 		if ($source_type == '' || $source_type == 'modes') {
2421 2421
 			$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
@@ -2446,9 +2446,9 @@  discard block
 block discarded – undo
2446 2446
 	*/
2447 2447
 	public function getAllAircraftTypeByRegistration($registration)
2448 2448
 	{
2449
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2449
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2450 2450
 
2451
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2451
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2452 2452
 		
2453 2453
 		$sth = $this->db->prepare($query);
2454 2454
 		$sth->execute(array(':registration' => $registration));
@@ -2469,9 +2469,9 @@  discard block
 block discarded – undo
2469 2469
 	*/
2470 2470
 	public function getAllIDByRegistration($registration)
2471 2471
 	{
2472
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2472
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2473 2473
 
2474
-		$query  = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2474
+		$query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2475 2475
 		
2476 2476
 		$sth = $this->db->prepare($query);
2477 2477
 		$sth->execute(array(':registration' => $registration));
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 		$idarray = array();
2480 2480
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
2481 2481
 			$date = $row['date'];
2482
-			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']);
2482
+			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'], 'spotter_id' => $row['spotter_id']);
2483 2483
 		}
2484 2484
 		return $idarray;
2485 2485
 	}
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	*/
2494 2494
 	public function getOperator($operator)
2495 2495
 	{
2496
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2497
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2496
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2497
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2498 2498
 		
2499 2499
 		$sth = $this->db->prepare($query);
2500 2500
 		$sth->execute(array(':operator' => $operator));
@@ -2515,9 +2515,9 @@  discard block
 block discarded – undo
2515 2515
 	*/
2516 2516
 	public function getRouteInfo($callsign)
2517 2517
 	{
2518
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2518
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2519 2519
                 if ($callsign == '') return array();
2520
-		$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";
2520
+		$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";
2521 2521
 		
2522 2522
 		$sth = $this->db->prepare($query);
2523 2523
 		$sth->execute(array(':callsign' => $callsign));
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
 	*/
2539 2539
 	public function getAircraftInfoByRegistration($registration)
2540 2540
 	{
2541
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2541
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2542 2542
 
2543
-		$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";
2543
+		$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";
2544 2544
 		
2545 2545
 		$sth = $this->db->prepare($query);
2546 2546
 		$sth->execute(array(':registration' => $registration));
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
 		$aircraft_array = array();
2549 2549
 		$temp_array = array();
2550 2550
 		
2551
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2551
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2552 2552
 		{
2553 2553
 			$temp_array['airline_icao'] = $row['airline_icao'];
2554 2554
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
 	*/
2571 2571
 	public function getAircraftOwnerByRegistration($registration)
2572 2572
 	{
2573
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2573
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2574 2574
 		$Connection = new Connection($this->db);
2575 2575
 		if ($Connection->tableExists('aircraft_owner')) {
2576 2576
 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 	public function getAllFlightsforSitemap()
2593 2593
 	{
2594 2594
 		//$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 ";
2595
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2595
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2596 2596
 		
2597 2597
 		$sth = $this->db->prepare($query);
2598 2598
 		$sth->execute();
@@ -2639,7 +2639,7 @@  discard block
 block discarded – undo
2639 2639
 		$manufacturer_array = array();
2640 2640
 		$temp_array = array();
2641 2641
 		
2642
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2642
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2643 2643
 		{
2644 2644
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2645 2645
 
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
 		$aircraft_array = array();
2677 2677
 		$temp_array = array();
2678 2678
 		
2679
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2679
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2680 2680
 		{
2681 2681
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2682 2682
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2697,8 +2697,8 @@  discard block
 block discarded – undo
2697 2697
 	*/
2698 2698
 	public function getAllAircraftRegistrations($filters = array())
2699 2699
 	{
2700
-		$filter_query = $this->getFilter($filters,true,true);
2701
-		$query  = "SELECT DISTINCT spotter_output.registration 
2700
+		$filter_query = $this->getFilter($filters, true, true);
2701
+		$query = "SELECT DISTINCT spotter_output.registration 
2702 2702
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' 
2703 2703
 				ORDER BY spotter_output.registration ASC";
2704 2704
 
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
 		$aircraft_array = array();
2709 2709
 		$temp_array = array();
2710 2710
 		
2711
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2711
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2712 2712
 		{
2713 2713
 			$temp_array['registration'] = $row['registration'];
2714 2714
 
@@ -2725,11 +2725,11 @@  discard block
 block discarded – undo
2725 2725
 	* @return Array list of source name
2726 2726
 	*
2727 2727
 	*/
2728
-	public function getAllSourceName($type = '',$filters = array())
2728
+	public function getAllSourceName($type = '', $filters = array())
2729 2729
 	{
2730
-		$filter_query = $this->getFilter($filters,true,true);
2730
+		$filter_query = $this->getFilter($filters, true, true);
2731 2731
 		$query_values = array();
2732
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2732
+		$query = "SELECT DISTINCT spotter_output.source_name 
2733 2733
 				FROM spotter_output".$filter_query." spotter_output.source_name <> ''";
2734 2734
 		if ($type != '') {
2735 2735
 			$query_values = array(':type' => $type);
@@ -2744,7 +2744,7 @@  discard block
 block discarded – undo
2744 2744
 		$source_array = array();
2745 2745
 		$temp_array = array();
2746 2746
 		
2747
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2747
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2748 2748
 		{
2749 2749
 			$temp_array['source_name'] = $row['source_name'];
2750 2750
 			$source_array[] = $temp_array;
@@ -2760,11 +2760,11 @@  discard block
 block discarded – undo
2760 2760
 	* @return Array list of airline names
2761 2761
 	*
2762 2762
 	*/
2763
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2763
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL, $filters = array())
2764 2764
 	{
2765
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2766
-		$filter_query = $this->getFilter($filters,true,true);
2767
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2765
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2766
+		$filter_query = $this->getFilter($filters, true, true);
2767
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2768 2768
 		if ($airline_type == '' || $airline_type == 'all') {
2769 2769
 			/*
2770 2770
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
 				$query_data = array(':forsource' => $forsource);
2784 2784
 			}
2785 2785
 		} else {
2786
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2786
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2787 2787
 					FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
2788 2788
 					AND spotter_output.airline_type = :airline_type 
2789 2789
 					ORDER BY spotter_output.airline_icao ASC";
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
 		$airline_array = array();
2797 2797
 		$temp_array = array();
2798 2798
 		
2799
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2799
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2800 2800
 		{
2801 2801
 			$temp_array['airline_icao'] = $row['airline_icao'];
2802 2802
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2813,10 +2813,10 @@  discard block
 block discarded – undo
2813 2813
 	* @return Array list of alliance names
2814 2814
 	*
2815 2815
 	*/
2816
-	public function getAllAllianceNames($forsource = NULL,$filters = array())
2816
+	public function getAllAllianceNames($forsource = NULL, $filters = array())
2817 2817
 	{
2818
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819
-		$filter_query = $this->getFilter($filters,true,true);
2818
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2819
+		$filter_query = $this->getFilter($filters, true, true);
2820 2820
 		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821 2821
 		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822 2822
 		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
@@ -2844,8 +2844,8 @@  discard block
 block discarded – undo
2844 2844
 	*/
2845 2845
 	public function getAllAirlineCountries($filters = array())
2846 2846
 	{
2847
-		$filter_query = $this->getFilter($filters,true,true);
2848
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2847
+		$filter_query = $this->getFilter($filters, true, true);
2848
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2849 2849
 				FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
2850 2850
 				ORDER BY spotter_output.airline_country ASC";
2851 2851
 		
@@ -2856,7 +2856,7 @@  discard block
 block discarded – undo
2856 2856
 		$airline_array = array();
2857 2857
 		$temp_array = array();
2858 2858
 		
2859
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2859
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2860 2860
 		{
2861 2861
 			$temp_array['airline_country'] = $row['airline_country'];
2862 2862
 
@@ -2876,9 +2876,9 @@  discard block
 block discarded – undo
2876 2876
 	*/
2877 2877
 	public function getAllAirportNames($filters = array())
2878 2878
 	{
2879
-		$filter_query = $this->getFilter($filters,true,true);
2879
+		$filter_query = $this->getFilter($filters, true, true);
2880 2880
 		$airport_array = array();
2881
-		$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
2881
+		$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
2882 2882
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2883 2883
 				ORDER BY spotter_output.departure_airport_city ASC";
2884 2884
 		
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
 		$sth->execute();
2888 2888
 
2889 2889
 		$temp_array = array();
2890
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2890
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2891 2891
 		{
2892 2892
 			$temp_array['airport_icao'] = $row['airport_icao'];
2893 2893
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2897,14 +2897,14 @@  discard block
 block discarded – undo
2897 2897
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2898 2898
 		}
2899 2899
 
2900
-		$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
2900
+		$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
2901 2901
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2902 2902
 								ORDER BY spotter_output.arrival_airport_city ASC";
2903 2903
 					
2904 2904
 		$sth = $this->db->prepare($query);
2905 2905
 		$sth->execute();
2906 2906
 
2907
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2907
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2908 2908
 			{
2909 2909
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2910 2910
 		//	{
@@ -2928,8 +2928,8 @@  discard block
 block discarded – undo
2928 2928
 	*/
2929 2929
 	public function getAllOwnerNames($filters = array())
2930 2930
 	{
2931
-		$filter_query = $this->getFilter($filters,true,true);
2932
-		$query  = "SELECT DISTINCT spotter_output.owner_name
2931
+		$filter_query = $this->getFilter($filters, true, true);
2932
+		$query = "SELECT DISTINCT spotter_output.owner_name
2933 2933
 				FROM spotter_output".$filter_query." spotter_output.owner_name <> '' 
2934 2934
 				ORDER BY spotter_output.owner_name ASC";
2935 2935
 		
@@ -2946,8 +2946,8 @@  discard block
 block discarded – undo
2946 2946
 	*/
2947 2947
 	public function getAllPilotNames($filters = array())
2948 2948
 	{
2949
-		$filter_query = $this->getFilter($filters,true,true);
2950
-		$query  = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2949
+		$filter_query = $this->getFilter($filters, true, true);
2950
+		$query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2951 2951
 				FROM spotter_output".$filter_query." spotter_output.pilot_name <> '' 
2952 2952
 				ORDER BY spotter_output.pilot_name ASC";
2953 2953
 		
@@ -2980,21 +2980,21 @@  discard block
 block discarded – undo
2980 2980
    
2981 2981
 		$temp_array = array();
2982 2982
 		
2983
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2983
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2984 2984
 		{
2985 2985
 			$temp_array['airport_country'] = $row['airport_country'];
2986 2986
 
2987 2987
 			$airport_array[$row['airport_country']] = $temp_array;
2988 2988
 		}
2989
-		$filter_query = $this->getFilter($filters,true,true);
2990
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2989
+		$filter_query = $this->getFilter($filters, true, true);
2990
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2991 2991
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
2992 2992
 								ORDER BY spotter_output.arrival_airport_country ASC";
2993 2993
 					
2994 2994
 		$sth = $this->db->prepare($query);
2995 2995
 		$sth->execute();
2996 2996
 		
2997
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2997
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2998 2998
 		{
2999 2999
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
3000 3000
 			{
@@ -3017,9 +3017,9 @@  discard block
 block discarded – undo
3017 3017
 	*/
3018 3018
 	public function getAllCountries($filters = array())
3019 3019
 	{
3020
-		$Connection= new Connection($this->db);
3020
+		$Connection = new Connection($this->db);
3021 3021
 		if ($Connection->tableExists('countries')) {
3022
-			$query  = "SELECT countries.name AS airport_country
3022
+			$query = "SELECT countries.name AS airport_country
3023 3023
 				FROM countries
3024 3024
 				ORDER BY countries.name ASC";
3025 3025
 			$sth = $this->db->prepare($query);
@@ -3028,14 +3028,14 @@  discard block
 block discarded – undo
3028 3028
 			$temp_array = array();
3029 3029
 			$country_array = array();
3030 3030
 		
3031
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3031
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3032 3032
 			{
3033 3033
 				$temp_array['country'] = $row['airport_country'];
3034 3034
 				$country_array[$row['airport_country']] = $temp_array;
3035 3035
 			}
3036 3036
 		} else {
3037
-			$filter_query = $this->getFilter($filters,true,true);
3038
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3037
+			$filter_query = $this->getFilter($filters, true, true);
3038
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3039 3039
 								FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' 
3040 3040
 								ORDER BY spotter_output.departure_airport_country ASC";
3041 3041
 
@@ -3044,20 +3044,20 @@  discard block
 block discarded – undo
3044 3044
    
3045 3045
 			$temp_array = array();
3046 3046
 			$country_array = array();
3047
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3047
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3048 3048
 			{
3049 3049
 				$temp_array['country'] = $row['airport_country'];
3050 3050
 				$country_array[$row['airport_country']] = $temp_array;
3051 3051
 			}
3052 3052
 
3053
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3053
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3054 3054
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
3055 3055
 								ORDER BY spotter_output.arrival_airport_country ASC";
3056 3056
 					
3057 3057
 		$sth = $this->db->prepare($query);
3058 3058
 		$sth->execute();
3059 3059
 		
3060
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3060
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3061 3061
 		{
3062 3062
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
3063 3063
 			{
@@ -3067,14 +3067,14 @@  discard block
 block discarded – undo
3067 3067
 			}
3068 3068
 		}
3069 3069
 		
3070
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3070
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3071 3071
 								FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
3072 3072
 								ORDER BY spotter_output.airline_country ASC";
3073 3073
 					
3074 3074
 		$sth = $this->db->prepare($query);
3075 3075
 		$sth->execute();
3076 3076
 		
3077
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3077
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3078 3078
 		{
3079 3079
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
3080 3080
 			{
@@ -3098,8 +3098,8 @@  discard block
 block discarded – undo
3098 3098
 	*/
3099 3099
 	public function getAllIdents($filters = array())
3100 3100
 	{
3101
-		$filter_query = $this->getFilter($filters,true,true);
3102
-		$query  = "SELECT DISTINCT spotter_output.ident
3101
+		$filter_query = $this->getFilter($filters, true, true);
3102
+		$query = "SELECT DISTINCT spotter_output.ident
3103 3103
 								FROM spotter_output".$filter_query." spotter_output.ident <> '' 
3104 3104
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
3105 3105
 
@@ -3109,7 +3109,7 @@  discard block
 block discarded – undo
3109 3109
 		$ident_array = array();
3110 3110
 		$temp_array = array();
3111 3111
 		
3112
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3112
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3113 3113
 		{
3114 3114
 			$temp_array['ident'] = $row['ident'];
3115 3115
 			$ident_array[] = $temp_array;
@@ -3123,9 +3123,9 @@  discard block
 block discarded – undo
3123 3123
 	* @return Array number, icao, name and city of airports
3124 3124
 	*/
3125 3125
 
3126
-	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3126
+	public function getLast7DaysAirportsDeparture($airport_icao = '', $filters = array()) {
3127 3127
 		global $globalTimezone, $globalDBdriver;
3128
-		$filter_query = $this->getFilter($filters,true,true);
3128
+		$filter_query = $this->getFilter($filters, true, true);
3129 3129
 		if ($globalTimezone != '') {
3130 3130
 			date_default_timezone_set($globalTimezone);
3131 3131
 			$datetime = new DateTime();
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
 
3191 3191
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3192 3192
 		global $globalTimezone, $globalDBdriver;
3193
-		$filter_query = $this->getFilter($filters,true,true);
3193
+		$filter_query = $this->getFilter($filters, true, true);
3194 3194
 		if ($globalTimezone != '') {
3195 3195
 			date_default_timezone_set($globalTimezone);
3196 3196
 			$datetime = new DateTime();
@@ -3274,7 +3274,7 @@  discard block
 block discarded – undo
3274 3274
 
3275 3275
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3276 3276
 		global $globalTimezone, $globalDBdriver;
3277
-		$filter_query = $this->getFilter($filters,true,true);
3277
+		$filter_query = $this->getFilter($filters, true, true);
3278 3278
 		if ($globalTimezone != '') {
3279 3279
 			date_default_timezone_set($globalTimezone);
3280 3280
 			$datetime = new DateTime();
@@ -3307,9 +3307,9 @@  discard block
 block discarded – undo
3307 3307
 	* @return Array number, icao, name and city of airports
3308 3308
 	*/
3309 3309
 
3310
-	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3310
+	public function getLast7DaysDetectedAirportsArrival($airport_icao = '', $filters = array()) {
3311 3311
 		global $globalTimezone, $globalDBdriver;
3312
-		$filter_query = $this->getFilter($filters,true,true);
3312
+		$filter_query = $this->getFilter($filters, true, true);
3313 3313
 		if ($globalTimezone != '') {
3314 3314
 			date_default_timezone_set($globalTimezone);
3315 3315
 			$datetime = new DateTime();
@@ -3441,12 +3441,12 @@  discard block
 block discarded – undo
3441 3441
 		} else $offset = '+00:00';
3442 3442
 
3443 3443
 		if ($globalDBdriver == 'mysql') {
3444
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3444
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3445 3445
 								FROM spotter_output
3446 3446
 								WHERE spotter_output.date <> '' 
3447 3447
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3448 3448
 		} else {
3449
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3449
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3450 3450
 								FROM spotter_output
3451 3451
 								WHERE spotter_output.date <> '' 
3452 3452
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3458,7 +3458,7 @@  discard block
 block discarded – undo
3458 3458
 		$date_array = array();
3459 3459
 		$temp_array = array();
3460 3460
 		
3461
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3461
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3462 3462
 		{
3463 3463
 			$temp_array['date'] = $row['date'];
3464 3464
 
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
 	*/
3479 3479
 	public function getAllRoutes()
3480 3480
 	{
3481
-		$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 
3481
+		$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 
3482 3482
 				FROM spotter_output
3483 3483
 				WHERE spotter_output.ident <> '' 
3484 3484
 				GROUP BY route
@@ -3489,7 +3489,7 @@  discard block
 block discarded – undo
3489 3489
 
3490 3490
 		$routes_array = array();
3491 3491
 		$temp_array = array();
3492
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3492
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3493 3493
 		{
3494 3494
 			$temp_array['route'] = $row['route'];
3495 3495
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3508,21 +3508,21 @@  discard block
 block discarded – undo
3508 3508
 	* @return String success or false
3509 3509
 	*
3510 3510
 	*/	
3511
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3511
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3512 3512
 	{
3513 3513
 		if (!is_numeric(substr($ident, 0, 3)))
3514 3514
 		{
3515 3515
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3516
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3516
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3517 3517
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3518
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3518
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3519 3519
 			} else {
3520 3520
 				$airline_array = $this->getAllAirlineInfo("NA");
3521 3521
 			}
3522 3522
 			if (count($airline_array) == 0) {
3523 3523
 				$airline_array = $this->getAllAirlineInfo("NA");
3524 3524
 			}
3525
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3525
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3526 3526
 				$airline_array = $this->getAllAirlineInfo("NA");
3527 3527
 			}
3528 3528
 		} else {
@@ -3535,7 +3535,7 @@  discard block
 block discarded – undo
3535 3535
 
3536 3536
 
3537 3537
 		$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';
3538
-                $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);
3538
+                $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);
3539 3539
 
3540 3540
 		try {
3541 3541
 			$sth = $this->db->prepare($query);
@@ -3556,11 +3556,11 @@  discard block
 block discarded – undo
3556 3556
 	* @return String success or false
3557 3557
 	*
3558 3558
 	*/	
3559
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3559
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
3560 3560
 	{
3561 3561
 		if ($groundspeed == '') $groundspeed = NULL;
3562 3562
 		$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';
3563
-                $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);
3563
+                $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);
3564 3564
 
3565 3565
 		try {
3566 3566
 			$sth = $this->db->prepare($query);
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
 	* @param String $verticalrate vertival rate of flight
3601 3601
 	* @return String success or false
3602 3602
 	*/
3603
-	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '',$source_type = '')
3603
+	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $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 = '', $source_type = '')
3604 3604
 	{
3605 3605
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
3606 3606
 		
@@ -3623,14 +3623,14 @@  discard block
 block discarded – undo
3623 3623
 			} else {
3624 3624
 				if ($ModeS != '') {
3625 3625
 					$timeelapsed = microtime(true);
3626
-					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3626
+					$registration = $this->getAircraftRegistrationBymodeS($ModeS, $source_type);
3627
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3628 3628
 				} else {
3629
-					$myhex = explode('-',$flightaware_id);
3629
+					$myhex = explode('-', $flightaware_id);
3630 3630
 					if (count($myhex) > 0) {
3631 3631
 						$timeelapsed = microtime(true);
3632
-						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3632
+						$registration = $this->getAircraftRegistrationBymodeS($myhex[0], $source_type);
3633
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3634 3634
 					}
3635 3635
 				}
3636 3636
 			}
@@ -3652,24 +3652,24 @@  discard block
 block discarded – undo
3652 3652
 				{
3653 3653
 					$timeelapsed = microtime(true);
3654 3654
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3655
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3655
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3656 3656
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3657
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3657
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3658 3658
 					} else {
3659 3659
 						$airline_array = $this->getAllAirlineInfo("NA");
3660 3660
 					}
3661 3661
 					if (count($airline_array) == 0) {
3662 3662
 						$airline_array = $this->getAllAirlineInfo("NA");
3663 3663
 					}
3664
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3664
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3665 3665
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3666
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3667
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3668 3668
 
3669 3669
 				} else {
3670 3670
 					$timeelapsed = microtime(true);
3671 3671
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3672
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3673 3673
 				}
3674 3674
 			}
3675 3675
 		} else $airline_array = array();
@@ -3686,27 +3686,27 @@  discard block
 block discarded – undo
3686 3686
 				{
3687 3687
 					$timeelapsed = microtime(true);
3688 3688
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3689
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3690 3690
 				} else {
3691 3691
 					$timeelapsed = microtime(true);
3692 3692
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3693
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3694 3694
 				}
3695 3695
 			}
3696 3696
 		} else {
3697 3697
 			if ($ModeS != '') {
3698 3698
 				$timeelapsed = microtime(true);
3699
-				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3699
+				$aircraft_icao = $this->getAllAircraftType($ModeS, $source_type);
3700
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3701 3701
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3702
 				{
3703 3703
 					$timeelapsed = microtime(true);
3704 3704
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3705
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3706 3706
 				} else {
3707 3707
 					$timeelapsed = microtime(true);
3708 3708
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3709
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3710 3710
 				}
3711 3711
 			}
3712 3712
 		}
@@ -3722,7 +3722,7 @@  discard block
 block discarded – undo
3722 3722
 			} else {
3723 3723
 				$timeelapsed = microtime(true);
3724 3724
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3725
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3726 3726
 			}
3727 3727
 		}
3728 3728
 		
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
 			} else {
3738 3738
 				$timeelapsed = microtime(true);
3739 3739
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3740
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3741 3741
 			}
3742 3742
 		}
3743 3743
 
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
 		}
3791 3791
 
3792 3792
     
3793
-		if ($date == "" || strtotime($date) < time()-20*60)
3793
+		if ($date == "" || strtotime($date) < time() - 20*60)
3794 3794
 		{
3795 3795
 			$date = date("Y-m-d H:i:s", time());
3796 3796
 		}
@@ -3800,7 +3800,7 @@  discard block
 block discarded – undo
3800 3800
 		{
3801 3801
 			$timeelapsed = microtime(true);
3802 3802
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3803
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3804 3804
 			if (!isset($image_array[0]['registration']))
3805 3805
 			{
3806 3806
 				//echo "Add image !!!! \n";
@@ -3808,7 +3808,7 @@  discard block
 block discarded – undo
3808 3808
 			}
3809 3809
 			$timeelapsed = microtime(true);
3810 3810
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3811
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3812 3812
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3813 3813
 		}
3814 3814
     
@@ -3816,33 +3816,33 @@  discard block
 block discarded – undo
3816 3816
 		{
3817 3817
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818 3818
             		else $airline_icao = '';
3819
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3819
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3820 3820
 			if (!isset($image_array[0]['registration']))
3821 3821
 			{
3822 3822
 				//echo "Add image !!!! \n";
3823
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3823
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3824 3824
 			}
3825 3825
 		}
3826 3826
     
3827
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3828
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3829
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3830
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3831
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3832
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3833
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3834
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3835
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3836
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3837
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3838
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3839
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3840
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3841
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3842
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3843
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3844
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3845
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3827
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3828
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3829
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3830
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3831
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3832
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3833
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3834
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3835
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3836
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3837
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3838
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3839
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3840
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3841
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3842
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3843
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3844
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3845
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3846 3846
 	
3847 3847
 		if (count($airline_array) == 0) 
3848 3848
 		{
@@ -3870,7 +3870,7 @@  discard block
 block discarded – undo
3870 3870
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871 3871
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872 3872
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
-                $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) 
3873
+                $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) 
3874 3874
                 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)";
3875 3875
 
3876 3876
                 $airline_name = $airline_array[0]['name'];
@@ -3880,7 +3880,7 @@  discard block
 block discarded – undo
3880 3880
 		if ($airline_type == '') {
3881 3881
 			$timeelapsed = microtime(true);
3882 3882
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3883
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3884 3884
 		}
3885 3885
 		if ($airline_type == null) $airline_type = '';
3886 3886
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3892,7 +3892,7 @@  discard block
 block discarded – undo
3892 3892
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3893 3893
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3894 3894
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3895
-                $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);
3895
+                $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);
3896 3896
 
3897 3897
 		try {
3898 3898
 		        
@@ -3918,13 +3918,13 @@  discard block
 block discarded – undo
3918 3918
 	{
3919 3919
 		global $globalDBdriver, $globalTimezone;
3920 3920
 		if ($globalDBdriver == 'mysql') {
3921
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3921
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3922 3922
 								WHERE spotter_output.ident = :ident 
3923 3923
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3924 3924
 								AND spotter_output.date < UTC_TIMESTAMP()";
3925 3925
 			$query_data = array(':ident' => $ident);
3926 3926
 		} else {
3927
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3927
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3928 3928
 								WHERE spotter_output.ident = :ident 
3929 3929
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3930 3930
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3933,8 +3933,8 @@  discard block
 block discarded – undo
3933 3933
 		
3934 3934
 		$sth = $this->db->prepare($query);
3935 3935
 		$sth->execute($query_data);
3936
-    		$ident_result='';
3937
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3936
+    		$ident_result = '';
3937
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3938 3938
 		{
3939 3939
 			$ident_result = $row['ident'];
3940 3940
 		}
@@ -3960,8 +3960,8 @@  discard block
 block discarded – undo
3960 3960
 				return false;
3961 3961
 			} else {
3962 3962
 				$q_array = explode(" ", $q);
3963
-				foreach ($q_array as $q_item){
3964
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3963
+				foreach ($q_array as $q_item) {
3964
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3965 3965
 					$additional_query .= " AND (";
3966 3966
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3967 3967
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3976,11 +3976,11 @@  discard block
 block discarded – undo
3976 3976
 			}
3977 3977
 		}
3978 3978
 		if ($globalDBdriver == 'mysql') {
3979
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3979
+			$query = "SELECT spotter_output.* FROM spotter_output 
3980 3980
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3981 3981
 				AND spotter_output.date < UTC_TIMESTAMP()";
3982 3982
 		} else {
3983
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3983
+			$query = "SELECT spotter_output.* FROM spotter_output 
3984 3984
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3985 3985
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3986 3986
 		}
@@ -3997,11 +3997,11 @@  discard block
 block discarded – undo
3997 3997
 	* @return Array the airline list
3998 3998
 	*
3999 3999
 	*/
4000
-	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
4000
+	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4001 4001
 	{
4002 4002
 		global $globalDBdriver;
4003
-		$filter_query = $this->getFilter($filters,true,true);
4004
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4003
+		$filter_query = $this->getFilter($filters, true, true);
4004
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4005 4005
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'";
4006 4006
 		if ($olderthanmonths > 0) {
4007 4007
 			if ($globalDBdriver == 'mysql') {
@@ -4021,28 +4021,28 @@  discard block
 block discarded – undo
4021 4021
 		if ($year != '') {
4022 4022
 			if ($globalDBdriver == 'mysql') {
4023 4023
 				$query .= " AND YEAR(spotter_output.date) = :year";
4024
-				$query_values = array_merge($query_values,array(':year' => $year));
4024
+				$query_values = array_merge($query_values, array(':year' => $year));
4025 4025
 			} else {
4026 4026
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4027
-				$query_values = array_merge($query_values,array(':year' => $year));
4027
+				$query_values = array_merge($query_values, array(':year' => $year));
4028 4028
 			}
4029 4029
 		}
4030 4030
 		if ($month != '') {
4031 4031
 			if ($globalDBdriver == 'mysql') {
4032 4032
 				$query .= " AND MONTH(spotter_output.date) = :month";
4033
-				$query_values = array_merge($query_values,array(':month' => $month));
4033
+				$query_values = array_merge($query_values, array(':month' => $month));
4034 4034
 			} else {
4035 4035
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4036
-				$query_values = array_merge($query_values,array(':month' => $month));
4036
+				$query_values = array_merge($query_values, array(':month' => $month));
4037 4037
 			}
4038 4038
 		}
4039 4039
 		if ($day != '') {
4040 4040
 			if ($globalDBdriver == 'mysql') {
4041 4041
 				$query .= " AND DAY(spotter_output.date) = :day";
4042
-				$query_values = array_merge($query_values,array(':day' => $day));
4042
+				$query_values = array_merge($query_values, array(':day' => $day));
4043 4043
 			} else {
4044 4044
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4045
-				$query_values = array_merge($query_values,array(':day' => $day));
4045
+				$query_values = array_merge($query_values, array(':day' => $day));
4046 4046
 			}
4047 4047
 		}
4048 4048
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
@@ -4052,7 +4052,7 @@  discard block
 block discarded – undo
4052 4052
 		$sth->execute($query_values);
4053 4053
 		$airline_array = array();
4054 4054
 		$temp_array = array();
4055
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4055
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4056 4056
 		{
4057 4057
 			$temp_array['airline_name'] = $row['airline_name'];
4058 4058
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4069,11 +4069,11 @@  discard block
 block discarded – undo
4069 4069
 	* @return Array the pilots list
4070 4070
 	*
4071 4071
 	*/
4072
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4072
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4073 4073
 	{
4074 4074
 		global $globalDBdriver;
4075
-		$filter_query = $this->getFilter($filters,true,true);
4076
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4075
+		$filter_query = $this->getFilter($filters, true, true);
4076
+		$query = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4077 4077
 			FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''";
4078 4078
                 if ($olderthanmonths > 0) {
4079 4079
             		if ($globalDBdriver == 'mysql') {
@@ -4093,28 +4093,28 @@  discard block
 block discarded – undo
4093 4093
 		if ($year != '') {
4094 4094
 			if ($globalDBdriver == 'mysql') {
4095 4095
 				$query .= " AND YEAR(spotter_output.date) = :year";
4096
-				$query_values = array_merge($query_values,array(':year' => $year));
4096
+				$query_values = array_merge($query_values, array(':year' => $year));
4097 4097
 			} else {
4098 4098
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4099
-				$query_values = array_merge($query_values,array(':year' => $year));
4099
+				$query_values = array_merge($query_values, array(':year' => $year));
4100 4100
 			}
4101 4101
 		}
4102 4102
 		if ($month != '') {
4103 4103
 			if ($globalDBdriver == 'mysql') {
4104 4104
 				$query .= " AND MONTH(spotter_output.date) = :month";
4105
-				$query_values = array_merge($query_values,array(':month' => $month));
4105
+				$query_values = array_merge($query_values, array(':month' => $month));
4106 4106
 			} else {
4107 4107
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4108
-				$query_values = array_merge($query_values,array(':month' => $month));
4108
+				$query_values = array_merge($query_values, array(':month' => $month));
4109 4109
 			}
4110 4110
 		}
4111 4111
 		if ($day != '') {
4112 4112
 			if ($globalDBdriver == 'mysql') {
4113 4113
 				$query .= " AND DAY(spotter_output.date) = :day";
4114
-				$query_values = array_merge($query_values,array(':day' => $day));
4114
+				$query_values = array_merge($query_values, array(':day' => $day));
4115 4115
 			} else {
4116 4116
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4117
-				$query_values = array_merge($query_values,array(':day' => $day));
4117
+				$query_values = array_merge($query_values, array(':day' => $day));
4118 4118
 			}
4119 4119
 		}
4120 4120
 		
@@ -4126,7 +4126,7 @@  discard block
 block discarded – undo
4126 4126
 		$sth->execute($query_values);
4127 4127
 		$airline_array = array();
4128 4128
 		$temp_array = array();
4129
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4129
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4130 4130
 		{
4131 4131
 			$temp_array['pilot_name'] = $row['pilot_name'];
4132 4132
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4146,7 +4146,7 @@  discard block
 block discarded – undo
4146 4146
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4147 4147
 	{
4148 4148
 		global $globalDBdriver;
4149
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4149
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4150 4150
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4151 4151
                 if ($olderthanmonths > 0) {
4152 4152
             		if ($globalDBdriver == 'mysql') {
@@ -4172,7 +4172,7 @@  discard block
 block discarded – undo
4172 4172
 		$airline_array = array();
4173 4173
 		$temp_array = array();
4174 4174
         
4175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4176 4176
 		{
4177 4177
 			$temp_array['pilot_name'] = $row['pilot_name'];
4178 4178
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4190,11 +4190,11 @@  discard block
 block discarded – undo
4190 4190
 	* @return Array the pilots list
4191 4191
 	*
4192 4192
 	*/
4193
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4193
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4194 4194
 	{
4195 4195
 		global $globalDBdriver;
4196
-		$filter_query = $this->getFilter($filters,true,true);
4197
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4196
+		$filter_query = $this->getFilter($filters, true, true);
4197
+		$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4198 4198
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4199 4199
                 if ($olderthanmonths > 0) {
4200 4200
             		if ($globalDBdriver == 'mysql') {
@@ -4214,28 +4214,28 @@  discard block
 block discarded – undo
4214 4214
 		if ($year != '') {
4215 4215
 			if ($globalDBdriver == 'mysql') {
4216 4216
 				$query .= " AND YEAR(spotter_output.date) = :year";
4217
-				$query_values = array_merge($query_values,array(':year' => $year));
4217
+				$query_values = array_merge($query_values, array(':year' => $year));
4218 4218
 			} else {
4219 4219
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4220
-				$query_values = array_merge($query_values,array(':year' => $year));
4220
+				$query_values = array_merge($query_values, array(':year' => $year));
4221 4221
 			}
4222 4222
 		}
4223 4223
 		if ($month != '') {
4224 4224
 			if ($globalDBdriver == 'mysql') {
4225 4225
 				$query .= " AND MONTH(spotter_output.date) = :month";
4226
-				$query_values = array_merge($query_values,array(':month' => $month));
4226
+				$query_values = array_merge($query_values, array(':month' => $month));
4227 4227
 			} else {
4228 4228
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4229
-				$query_values = array_merge($query_values,array(':month' => $month));
4229
+				$query_values = array_merge($query_values, array(':month' => $month));
4230 4230
 			}
4231 4231
 		}
4232 4232
 		if ($day != '') {
4233 4233
 			if ($globalDBdriver == 'mysql') {
4234 4234
 				$query .= " AND DAY(spotter_output.date) = :day";
4235
-				$query_values = array_merge($query_values,array(':day' => $day));
4235
+				$query_values = array_merge($query_values, array(':day' => $day));
4236 4236
 			} else {
4237 4237
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4238
-				$query_values = array_merge($query_values,array(':day' => $day));
4238
+				$query_values = array_merge($query_values, array(':day' => $day));
4239 4239
 			}
4240 4240
 		}
4241 4241
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
@@ -4245,7 +4245,7 @@  discard block
 block discarded – undo
4245 4245
 		$sth->execute($query_values);
4246 4246
 		$airline_array = array();
4247 4247
 		$temp_array = array();
4248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4249 4249
 		{
4250 4250
 			$temp_array['owner_name'] = $row['owner_name'];
4251 4251
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4260,11 +4260,11 @@  discard block
 block discarded – undo
4260 4260
 	* @return Array the pilots list
4261 4261
 	*
4262 4262
 	*/
4263
-	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4263
+	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4264 4264
 	{
4265 4265
 		global $globalDBdriver;
4266
-		$filter_query = $this->getFilter($filters,true,true);
4267
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4266
+		$filter_query = $this->getFilter($filters, true, true);
4267
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4268 4268
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4269 4269
                 if ($olderthanmonths > 0) {
4270 4270
             		if ($globalDBdriver == 'mysql') {
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
 		$airline_array = array();
4291 4291
 		$temp_array = array();
4292 4292
         
4293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4294 4294
 		{
4295 4295
 			$temp_array['owner_name'] = $row['owner_name'];
4296 4296
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4306,11 +4306,11 @@  discard block
 block discarded – undo
4306 4306
 	* @return Array the airline list
4307 4307
 	*
4308 4308
 	*/
4309
-	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4309
+	public function countAllAirlinesByAircraft($aircraft_icao, $filters = array())
4310 4310
 	{
4311
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4312
-		$filter_query = $this->getFilter($filters,true,true);
4313
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4311
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4312
+		$filter_query = $this->getFilter($filters, true, true);
4313
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4314 4314
 		 	    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
4315 4315
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4316 4316
 			    ORDER BY airline_count DESC";
@@ -4322,7 +4322,7 @@  discard block
 block discarded – undo
4322 4322
 		$airline_array = array();
4323 4323
 		$temp_array = array();
4324 4324
         
4325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4326 4326
 		{
4327 4327
 			$temp_array['airline_name'] = $row['airline_name'];
4328 4328
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4342,11 +4342,11 @@  discard block
 block discarded – undo
4342 4342
 	* @return Array the airline country list
4343 4343
 	*
4344 4344
 	*/
4345
-	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4345
+	public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array())
4346 4346
 	{
4347
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4348
-		$filter_query = $this->getFilter($filters,true,true);
4349
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4347
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4348
+		$filter_query = $this->getFilter($filters, true, true);
4349
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4350 4350
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
4351 4351
                     GROUP BY spotter_output.airline_country
4352 4352
 					ORDER BY airline_country_count DESC
@@ -4359,7 +4359,7 @@  discard block
 block discarded – undo
4359 4359
 		$airline_country_array = array();
4360 4360
 		$temp_array = array();
4361 4361
         
4362
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4362
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4363 4363
 		{
4364 4364
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4365 4365
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4378,11 +4378,11 @@  discard block
 block discarded – undo
4378 4378
 	* @return Array the airline list
4379 4379
 	*
4380 4380
 	*/
4381
-	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4381
+	public function countAllAirlinesByAirport($airport_icao, $filters = array())
4382 4382
 	{
4383
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4384
-		$filter_query = $this->getFilter($filters,true,true);
4385
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4383
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4384
+		$filter_query = $this->getFilter($filters, true, true);
4385
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4386 4386
 		    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 ) 
4387 4387
                     GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country
4388 4388
 		    ORDER BY airline_count DESC";
@@ -4394,7 +4394,7 @@  discard block
 block discarded – undo
4394 4394
 		$airline_array = array();
4395 4395
 		$temp_array = array();
4396 4396
         
4397
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4397
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4398 4398
 		{
4399 4399
 			$temp_array['airline_name'] = $row['airline_name'];
4400 4400
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4413,11 +4413,11 @@  discard block
 block discarded – undo
4413 4413
 	* @return Array the airline country list
4414 4414
 	*
4415 4415
 	*/
4416
-	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4416
+	public function countAllAirlineCountriesByAirport($airport_icao, $filters = array())
4417 4417
 	{
4418
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4419
-		$filter_query = $this->getFilter($filters,true,true);
4420
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4418
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4419
+		$filter_query = $this->getFilter($filters, true, true);
4420
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4421 4421
 		 			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 )
4422 4422
 					GROUP BY spotter_output.airline_country
4423 4423
 					ORDER BY airline_country_count DESC
@@ -4430,7 +4430,7 @@  discard block
 block discarded – undo
4430 4430
 		$airline_country_array = array();
4431 4431
 		$temp_array = array();
4432 4432
         
4433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4434 4434
 		{
4435 4435
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4436 4436
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4447,11 +4447,11 @@  discard block
 block discarded – undo
4447 4447
 	* @return Array the airline list
4448 4448
 	*
4449 4449
 	*/
4450
-	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4450
+	public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array())
4451 4451
 	{
4452
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4453
-		$filter_query = $this->getFilter($filters,true,true);
4454
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4452
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4453
+		$filter_query = $this->getFilter($filters, true, true);
4454
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4455 4455
 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4456 4456
 					GROUP BY spotter_output.airline_name
4457 4457
 					ORDER BY airline_count DESC";
@@ -4462,7 +4462,7 @@  discard block
 block discarded – undo
4462 4462
 		$airline_array = array();
4463 4463
 		$temp_array = array();
4464 4464
         
4465
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4465
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4466 4466
 		{
4467 4467
 			$temp_array['airline_name'] = $row['airline_name'];
4468 4468
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4482,11 +4482,11 @@  discard block
 block discarded – undo
4482 4482
 	* @return Array the airline country list
4483 4483
 	*
4484 4484
 	*/
4485
-	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4485
+	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array())
4486 4486
 	{
4487
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4488
-		$filter_query = $this->getFilter($filters,true,true);
4489
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4487
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4488
+		$filter_query = $this->getFilter($filters, true, true);
4489
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4490 4490
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4491 4491
 					GROUP BY spotter_output.airline_country
4492 4492
 					ORDER BY airline_country_count DESC
@@ -4499,7 +4499,7 @@  discard block
 block discarded – undo
4499 4499
 		$airline_country_array = array();
4500 4500
 		$temp_array = array();
4501 4501
         
4502
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4502
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4503 4503
 		{
4504 4504
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4505 4505
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4515,11 +4515,11 @@  discard block
 block discarded – undo
4515 4515
 	* @return Array the airline list
4516 4516
 	*
4517 4517
 	*/
4518
-	public function countAllAirlinesByDate($date,$filters = array())
4518
+	public function countAllAirlinesByDate($date, $filters = array())
4519 4519
 	{
4520 4520
 		global $globalTimezone, $globalDBdriver;
4521
-		$filter_query = $this->getFilter($filters,true,true);
4522
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4521
+		$filter_query = $this->getFilter($filters, true, true);
4522
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4523 4523
 		if ($globalTimezone != '') {
4524 4524
 			date_default_timezone_set($globalTimezone);
4525 4525
 			$datetime = new DateTime($date);
@@ -4527,12 +4527,12 @@  discard block
 block discarded – undo
4527 4527
 		} else $offset = '+00:00';
4528 4528
 
4529 4529
 		if ($globalDBdriver == 'mysql') {
4530
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4530
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4531 4531
 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4532 4532
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country 
4533 4533
 					ORDER BY airline_count DESC";
4534 4534
 		} else {
4535
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4535
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4536 4536
 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4537 4537
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country
4538 4538
 					ORDER BY airline_count DESC";
@@ -4543,7 +4543,7 @@  discard block
 block discarded – undo
4543 4543
 
4544 4544
 		$airline_array = array();
4545 4545
 		$temp_array = array();
4546
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4546
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4547 4547
 		{
4548 4548
 			$temp_array['airline_name'] = $row['airline_name'];
4549 4549
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4563,11 +4563,11 @@  discard block
 block discarded – undo
4563 4563
 	* @return Array the airline country list
4564 4564
 	*
4565 4565
 	*/
4566
-	public function countAllAirlineCountriesByDate($date,$filters = array())
4566
+	public function countAllAirlineCountriesByDate($date, $filters = array())
4567 4567
 	{
4568 4568
 		global $globalTimezone, $globalDBdriver;
4569
-		$filter_query = $this->getFilter($filters,true,true);
4570
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4569
+		$filter_query = $this->getFilter($filters, true, true);
4570
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4571 4571
 		if ($globalTimezone != '') {
4572 4572
 			date_default_timezone_set($globalTimezone);
4573 4573
 			$datetime = new DateTime($date);
@@ -4575,13 +4575,13 @@  discard block
 block discarded – undo
4575 4575
 		} else $offset = '+00:00';
4576 4576
 		
4577 4577
 		if ($globalDBdriver == 'mysql') {
4578
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4578
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4579 4579
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4580 4580
 					GROUP BY spotter_output.airline_country
4581 4581
 					ORDER BY airline_country_count DESC
4582 4582
 					LIMIT 10 OFFSET 0";
4583 4583
 		} else {
4584
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4584
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4585 4585
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4586 4586
 					GROUP BY spotter_output.airline_country
4587 4587
 					ORDER BY airline_country_count DESC
@@ -4593,7 +4593,7 @@  discard block
 block discarded – undo
4593 4593
  
4594 4594
 		$airline_country_array = array();
4595 4595
 		$temp_array = array();
4596
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4596
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4597 4597
 		{
4598 4598
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4599 4599
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4610,11 +4610,11 @@  discard block
 block discarded – undo
4610 4610
 	* @return Array the airline list
4611 4611
 	*
4612 4612
 	*/
4613
-	public function countAllAirlinesByIdent($ident,$filters = array())
4613
+	public function countAllAirlinesByIdent($ident, $filters = array())
4614 4614
 	{
4615
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4616
-		$filter_query = $this->getFilter($filters,true,true);
4617
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4615
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4616
+		$filter_query = $this->getFilter($filters, true, true);
4617
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4618 4618
 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident  
4619 4619
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4620 4620
 				ORDER BY airline_count DESC";
@@ -4631,11 +4631,11 @@  discard block
 block discarded – undo
4631 4631
 	* @return Array the airline list
4632 4632
 	*
4633 4633
 	*/
4634
-	public function countAllAirlinesByOwner($owner,$filters = array())
4634
+	public function countAllAirlinesByOwner($owner, $filters = array())
4635 4635
 	{
4636
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4637
-		$filter_query = $this->getFilter($filters,true,true);
4638
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4636
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4637
+		$filter_query = $this->getFilter($filters, true, true);
4638
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4639 4639
 		 		FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  
4640 4640
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4641 4641
 				ORDER BY airline_count DESC";
@@ -4652,47 +4652,47 @@  discard block
 block discarded – undo
4652 4652
 	* @return String Duration of all flights
4653 4653
 	*
4654 4654
 	*/
4655
-	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4655
+	public function getFlightDurationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
4656 4656
 	{
4657 4657
 		global $globalDBdriver;
4658
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4659
-		$filter_query = $this->getFilter($filters,true,true);
4660
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4658
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4659
+		$filter_query = $this->getFilter($filters, true, true);
4660
+		$query = "SELECT SUM(last_seen - date) AS duration 
4661 4661
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
4662 4662
 				AND last_seen > date";
4663 4663
 		$query_values = array();
4664 4664
 		if ($year != '') {
4665 4665
 			if ($globalDBdriver == 'mysql') {
4666 4666
 				$query .= " AND YEAR(spotter_output.date) = :year";
4667
-				$query_values = array_merge($query_values,array(':year' => $year));
4667
+				$query_values = array_merge($query_values, array(':year' => $year));
4668 4668
 			} else {
4669 4669
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4670
-				$query_values = array_merge($query_values,array(':year' => $year));
4670
+				$query_values = array_merge($query_values, array(':year' => $year));
4671 4671
 			}
4672 4672
 		}
4673 4673
 		if ($month != '') {
4674 4674
 			if ($globalDBdriver == 'mysql') {
4675 4675
 				$query .= " AND MONTH(spotter_output.date) = :month";
4676
-				$query_values = array_merge($query_values,array(':month' => $month));
4676
+				$query_values = array_merge($query_values, array(':month' => $month));
4677 4677
 			} else {
4678 4678
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4679
-				$query_values = array_merge($query_values,array(':month' => $month));
4679
+				$query_values = array_merge($query_values, array(':month' => $month));
4680 4680
 			}
4681 4681
 		}
4682 4682
 		if ($day != '') {
4683 4683
 			if ($globalDBdriver == 'mysql') {
4684 4684
 				$query .= " AND DAY(spotter_output.date) = :day";
4685
-				$query_values = array_merge($query_values,array(':day' => $day));
4685
+				$query_values = array_merge($query_values, array(':day' => $day));
4686 4686
 			} else {
4687 4687
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4688
-				$query_values = array_merge($query_values,array(':day' => $day));
4688
+				$query_values = array_merge($query_values, array(':day' => $day));
4689 4689
 			}
4690 4690
 		}
4691
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4691
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4692 4692
 		$sth = $this->db->prepare($query);
4693 4693
 		$sth->execute($query_values);
4694 4694
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4695
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4695
+		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4696 4696
 		elseif ($result[0]['duration'] == '') return 0;
4697 4697
 		else return $result[0]['duration'];
4698 4698
 	}
@@ -4703,14 +4703,14 @@  discard block
 block discarded – undo
4703 4703
 	* @return String Duration of all flights
4704 4704
 	*
4705 4705
 	*/
4706
-	public function countFlightsByOwner($owner,$filters = array())
4706
+	public function countFlightsByOwner($owner, $filters = array())
4707 4707
 	{
4708
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4709
-		$filter_query = $this->getFilter($filters,true,true);
4710
-		$query  = "SELECT COUNT(*) AS nb 
4708
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4709
+		$filter_query = $this->getFilter($filters, true, true);
4710
+		$query = "SELECT COUNT(*) AS nb 
4711 4711
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
4712 4712
 		$query_values = array();
4713
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4713
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4714 4714
 		$sth = $this->db->prepare($query);
4715 4715
 		$sth->execute($query_values);
4716 4716
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4723,14 +4723,14 @@  discard block
 block discarded – undo
4723 4723
 	* @return String Duration of all flights
4724 4724
 	*
4725 4725
 	*/
4726
-	public function countFlightsByPilot($pilot,$filters = array())
4726
+	public function countFlightsByPilot($pilot, $filters = array())
4727 4727
 	{
4728
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4729
-		$filter_query = $this->getFilter($filters,true,true);
4730
-		$query  = "SELECT COUNT(*) AS nb 
4728
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4729
+		$filter_query = $this->getFilter($filters, true, true);
4730
+		$query = "SELECT COUNT(*) AS nb 
4731 4731
 				FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilod_id = :pilot)";
4732 4732
 		$query_values = array();
4733
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4733
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4734 4734
 		$sth = $this->db->prepare($query);
4735 4735
 		$sth->execute($query_values);
4736 4736
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4743,47 +4743,47 @@  discard block
 block discarded – undo
4743 4743
 	* @return String Duration of all flights
4744 4744
 	*
4745 4745
 	*/
4746
-	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4746
+	public function getFlightDurationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
4747 4747
 	{
4748 4748
 		global $globalDBdriver;
4749
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4750
-		$filter_query = $this->getFilter($filters,true,true);
4751
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4749
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4750
+		$filter_query = $this->getFilter($filters, true, true);
4751
+		$query = "SELECT SUM(last_seen - date) AS duration 
4752 4752
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4753 4753
 		 		AND last_seen > date";
4754 4754
 		$query_values = array();
4755 4755
 		if ($year != '') {
4756 4756
 			if ($globalDBdriver == 'mysql') {
4757 4757
 				$query .= " AND YEAR(spotter_output.date) = :year";
4758
-				$query_values = array_merge($query_values,array(':year' => $year));
4758
+				$query_values = array_merge($query_values, array(':year' => $year));
4759 4759
 			} else {
4760 4760
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4761
-				$query_values = array_merge($query_values,array(':year' => $year));
4761
+				$query_values = array_merge($query_values, array(':year' => $year));
4762 4762
 			}
4763 4763
 		}
4764 4764
 		if ($month != '') {
4765 4765
 			if ($globalDBdriver == 'mysql') {
4766 4766
 				$query .= " AND MONTH(spotter_output.date) = :month";
4767
-				$query_values = array_merge($query_values,array(':month' => $month));
4767
+				$query_values = array_merge($query_values, array(':month' => $month));
4768 4768
 			} else {
4769 4769
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4770
-				$query_values = array_merge($query_values,array(':month' => $month));
4770
+				$query_values = array_merge($query_values, array(':month' => $month));
4771 4771
 			}
4772 4772
 		}
4773 4773
 		if ($day != '') {
4774 4774
 			if ($globalDBdriver == 'mysql') {
4775 4775
 				$query .= " AND DAY(spotter_output.date) = :day";
4776
-				$query_values = array_merge($query_values,array(':day' => $day));
4776
+				$query_values = array_merge($query_values, array(':day' => $day));
4777 4777
 			} else {
4778 4778
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4779
-				$query_values = array_merge($query_values,array(':day' => $day));
4779
+				$query_values = array_merge($query_values, array(':day' => $day));
4780 4780
 			}
4781 4781
 		}
4782
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4782
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4783 4783
 		$sth = $this->db->prepare($query);
4784 4784
 		$sth->execute($query_values);
4785 4785
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4786
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4786
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4787 4787
 		else return $result[0]['duration'];
4788 4788
 	}
4789 4789
 
@@ -4793,11 +4793,11 @@  discard block
 block discarded – undo
4793 4793
 	* @return Array the airline list
4794 4794
 	*
4795 4795
 	*/
4796
-	public function countAllAirlinesByPilot($pilot,$filters = array())
4796
+	public function countAllAirlinesByPilot($pilot, $filters = array())
4797 4797
 	{
4798
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4799
-		$filter_query = $this->getFilter($filters,true,true);
4800
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4798
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4799
+		$filter_query = $this->getFilter($filters, true, true);
4800
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4801 4801
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4802 4802
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4803 4803
 				ORDER BY airline_count DESC";
@@ -4814,25 +4814,25 @@  discard block
 block discarded – undo
4814 4814
 	* @return Array the airline list
4815 4815
 	*
4816 4816
 	*/
4817
-	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4817
+	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4818 4818
 	{
4819
-		$filter_query = $this->getFilter($filters,true,true);
4820
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4821
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4819
+		$filter_query = $this->getFilter($filters, true, true);
4820
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4821
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4822 4822
 
4823
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4823
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4824 4824
 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4825 4825
 					GROUP BY spotter_output.airline_name
4826 4826
 					ORDER BY airline_count DESC";
4827 4827
       
4828 4828
 		
4829 4829
 		$sth = $this->db->prepare($query);
4830
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4830
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4831 4831
       
4832 4832
 		$airline_array = array();
4833 4833
 		$temp_array = array();
4834 4834
         
4835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4836 4836
 		{
4837 4837
 			$temp_array['airline_name'] = $row['airline_name'];
4838 4838
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4850,13 +4850,13 @@  discard block
 block discarded – undo
4850 4850
 	* @return Array the airline country list
4851 4851
 	*
4852 4852
 	*/
4853
-	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4853
+	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4854 4854
 	{
4855
-		$filter_query = $this->getFilter($filters,true,true);
4856
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4857
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4855
+		$filter_query = $this->getFilter($filters, true, true);
4856
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4857
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4858 4858
       
4859
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4859
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4860 4860
 		 		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) 
4861 4861
 				GROUP BY spotter_output.airline_country
4862 4862
 				ORDER BY airline_country_count DESC
@@ -4864,11 +4864,11 @@  discard block
 block discarded – undo
4864 4864
       
4865 4865
 		
4866 4866
 		$sth = $this->db->prepare($query);
4867
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4867
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4868 4868
       
4869 4869
 		$airline_country_array = array();
4870 4870
 		$temp_array = array();
4871
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4871
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4872 4872
 		{
4873 4873
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4874 4874
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4886,11 +4886,11 @@  discard block
 block discarded – undo
4886 4886
 	* @return Array the airline list
4887 4887
 	*
4888 4888
 	*/
4889
-	public function countAllAirlinesByCountry($country,$filters = array())
4889
+	public function countAllAirlinesByCountry($country, $filters = array())
4890 4890
 	{
4891
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4892
-		$filter_query = $this->getFilter($filters,true,true);
4893
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4891
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4892
+		$filter_query = $this->getFilter($filters, true, true);
4893
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4894 4894
 		 	    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4895 4895
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4896 4896
 			    ORDER BY airline_count DESC";
@@ -4901,7 +4901,7 @@  discard block
 block discarded – undo
4901 4901
 
4902 4902
 		$airline_array = array();
4903 4903
 		$temp_array = array();
4904
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4904
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4905 4905
 		{
4906 4906
 			$temp_array['airline_name'] = $row['airline_name'];
4907 4907
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4920,11 +4920,11 @@  discard block
 block discarded – undo
4920 4920
 	* @return Array the airline country list
4921 4921
 	*
4922 4922
 	*/
4923
-	public function countAllAirlineCountriesByCountry($country,$filters = array())
4923
+	public function countAllAirlineCountriesByCountry($country, $filters = array())
4924 4924
 	{
4925
-		$filter_query = $this->getFilter($filters,true,true);
4926
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4927
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4925
+		$filter_query = $this->getFilter($filters, true, true);
4926
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4927
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4928 4928
 		 		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 
4929 4929
 				GROUP BY spotter_output.airline_country
4930 4930
 				ORDER BY airline_country_count DESC
@@ -4936,7 +4936,7 @@  discard block
 block discarded – undo
4936 4936
 
4937 4937
 		$airline_country_array = array();
4938 4938
 		$temp_array = array();
4939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4940 4940
 		{
4941 4941
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4942 4942
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4956,35 +4956,35 @@  discard block
 block discarded – undo
4956 4956
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4957 4957
 	{
4958 4958
 		global $globalDBdriver;
4959
-		$filter_query = $this->getFilter($filters,true,true);
4960
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4959
+		$filter_query = $this->getFilter($filters, true, true);
4960
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4961 4961
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'";
4962 4962
 		$query_values = array();
4963 4963
 		if ($year != '') {
4964 4964
 			if ($globalDBdriver == 'mysql') {
4965 4965
 				$query .= " AND YEAR(spotter_output.date) = :year";
4966
-				$query_values = array_merge($query_values,array(':year' => $year));
4966
+				$query_values = array_merge($query_values, array(':year' => $year));
4967 4967
 			} else {
4968 4968
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4969
-				$query_values = array_merge($query_values,array(':year' => $year));
4969
+				$query_values = array_merge($query_values, array(':year' => $year));
4970 4970
 			}
4971 4971
 		}
4972 4972
 		if ($month != '') {
4973 4973
 			if ($globalDBdriver == 'mysql') {
4974 4974
 				$query .= " AND MONTH(spotter_output.date) = :month";
4975
-				$query_values = array_merge($query_values,array(':month' => $month));
4975
+				$query_values = array_merge($query_values, array(':month' => $month));
4976 4976
 			} else {
4977 4977
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4978
-				$query_values = array_merge($query_values,array(':month' => $month));
4978
+				$query_values = array_merge($query_values, array(':month' => $month));
4979 4979
 			}
4980 4980
 		}
4981 4981
 		if ($day != '') {
4982 4982
 			if ($globalDBdriver == 'mysql') {
4983 4983
 				$query .= " AND DAY(spotter_output.date) = :day";
4984
-				$query_values = array_merge($query_values,array(':day' => $day));
4984
+				$query_values = array_merge($query_values, array(':day' => $day));
4985 4985
 			} else {
4986 4986
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4987
-				$query_values = array_merge($query_values,array(':day' => $day));
4987
+				$query_values = array_merge($query_values, array(':day' => $day));
4988 4988
 			}
4989 4989
 		}
4990 4990
 		$query .= " GROUP BY spotter_output.airline_country
@@ -4996,7 +4996,7 @@  discard block
 block discarded – undo
4996 4996
 
4997 4997
 		$airline_array = array();
4998 4998
 		$temp_array = array();
4999
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4999
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5000 5000
 		{
5001 5001
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
5002 5002
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -5012,11 +5012,11 @@  discard block
 block discarded – undo
5012 5012
 	* @return Array the airline country list
5013 5013
 	*
5014 5014
 	*/
5015
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5015
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5016 5016
 	{
5017 5017
 		global $globalDBdriver;
5018 5018
 		//$filter_query = $this->getFilter($filters,true,true);
5019
-		$Connection= new Connection($this->db);
5019
+		$Connection = new Connection($this->db);
5020 5020
 		if (!$Connection->tableExists('countries')) return array();
5021 5021
 		/*
5022 5022
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -5031,7 +5031,7 @@  discard block
 block discarded – undo
5031 5031
 */
5032 5032
 		require_once('class.SpotterLive.php');
5033 5033
 		$SpotterLive = new SpotterLive();
5034
-		$filter_query = $SpotterLive->getFilter($filters,true,true);
5034
+		$filter_query = $SpotterLive->getFilter($filters, true, true);
5035 5035
 		$filter_query .= ' over_country IS NOT NULL';
5036 5036
                 if ($olderthanmonths > 0) {
5037 5037
 			if ($globalDBdriver == 'mysql') {
@@ -5058,7 +5058,7 @@  discard block
 block discarded – undo
5058 5058
 		$flight_array = array();
5059 5059
 		$temp_array = array();
5060 5060
         
5061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5062 5062
 		{
5063 5063
 			$temp_array['flight_count'] = $row['nb'];
5064 5064
 			$temp_array['flight_country'] = $row['name'];
@@ -5076,11 +5076,11 @@  discard block
 block discarded – undo
5076 5076
 	* @return Array the aircraft list
5077 5077
 	*
5078 5078
 	*/
5079
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5079
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5080 5080
 	{
5081 5081
 		global $globalDBdriver;
5082
-		$filter_query = $this->getFilter($filters,true,true);
5083
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5082
+		$filter_query = $this->getFilter($filters, true, true);
5083
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5084 5084
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
5085 5085
 		if ($olderthanmonths > 0) {
5086 5086
 			if ($globalDBdriver == 'mysql') {
@@ -5100,28 +5100,28 @@  discard block
 block discarded – undo
5100 5100
 		if ($year != '') {
5101 5101
 			if ($globalDBdriver == 'mysql') {
5102 5102
 				$query .= " AND YEAR(spotter_output.date) = :year";
5103
-				$query_values = array_merge($query_values,array(':year' => $year));
5103
+				$query_values = array_merge($query_values, array(':year' => $year));
5104 5104
 			} else {
5105 5105
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5106
-				$query_values = array_merge($query_values,array(':year' => $year));
5106
+				$query_values = array_merge($query_values, array(':year' => $year));
5107 5107
 			}
5108 5108
 		}
5109 5109
 		if ($month != '') {
5110 5110
 			if ($globalDBdriver == 'mysql') {
5111 5111
 				$query .= " AND MONTH(spotter_output.date) = :month";
5112
-				$query_values = array_merge($query_values,array(':month' => $month));
5112
+				$query_values = array_merge($query_values, array(':month' => $month));
5113 5113
 			} else {
5114 5114
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5115
-				$query_values = array_merge($query_values,array(':month' => $month));
5115
+				$query_values = array_merge($query_values, array(':month' => $month));
5116 5116
 			}
5117 5117
 		}
5118 5118
 		if ($day != '') {
5119 5119
 			if ($globalDBdriver == 'mysql') {
5120 5120
 				$query .= " AND DAY(spotter_output.date) = :day";
5121
-				$query_values = array_merge($query_values,array(':day' => $day));
5121
+				$query_values = array_merge($query_values, array(':day' => $day));
5122 5122
 			} else {
5123 5123
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5124
-				$query_values = array_merge($query_values,array(':day' => $day));
5124
+				$query_values = array_merge($query_values, array(':day' => $day));
5125 5125
 			}
5126 5126
 		}
5127 5127
 
@@ -5133,7 +5133,7 @@  discard block
 block discarded – undo
5133 5133
 
5134 5134
 		$aircraft_array = array();
5135 5135
 		$temp_array = array();
5136
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5136
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5137 5137
 		{
5138 5138
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5139 5139
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5150,11 +5150,11 @@  discard block
 block discarded – undo
5150 5150
 	* @return Array the aircraft list
5151 5151
 	*
5152 5152
 	*/
5153
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5153
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5154 5154
 	{
5155 5155
 		global $globalDBdriver;
5156
-		$filter_query = $this->getFilter($filters,true,true);
5157
-		$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 
5156
+		$filter_query = $this->getFilter($filters, true, true);
5157
+		$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 
5158 5158
 		    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'";
5159 5159
 		if ($olderthanmonths > 0) {
5160 5160
 			if ($globalDBdriver == 'mysql') {
@@ -5174,28 +5174,28 @@  discard block
 block discarded – undo
5174 5174
 		if ($year != '') {
5175 5175
 			if ($globalDBdriver == 'mysql') {
5176 5176
 				$query .= " AND YEAR(spotter_output.date) = :year";
5177
-				$query_values = array_merge($query_values,array(':year' => $year));
5177
+				$query_values = array_merge($query_values, array(':year' => $year));
5178 5178
 			} else {
5179 5179
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5180
-				$query_values = array_merge($query_values,array(':year' => $year));
5180
+				$query_values = array_merge($query_values, array(':year' => $year));
5181 5181
 			}
5182 5182
 		}
5183 5183
 		if ($month != '') {
5184 5184
 			if ($globalDBdriver == 'mysql') {
5185 5185
 				$query .= " AND MONTH(spotter_output.date) = :month";
5186
-				$query_values = array_merge($query_values,array(':month' => $month));
5186
+				$query_values = array_merge($query_values, array(':month' => $month));
5187 5187
 			} else {
5188 5188
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5189
-				$query_values = array_merge($query_values,array(':month' => $month));
5189
+				$query_values = array_merge($query_values, array(':month' => $month));
5190 5190
 			}
5191 5191
 		}
5192 5192
 		if ($day != '') {
5193 5193
 			if ($globalDBdriver == 'mysql') {
5194 5194
 				$query .= " AND DAY(spotter_output.date) = :day";
5195
-				$query_values = array_merge($query_values,array(':day' => $day));
5195
+				$query_values = array_merge($query_values, array(':day' => $day));
5196 5196
 			} else {
5197 5197
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5198
-				$query_values = array_merge($query_values,array(':day' => $day));
5198
+				$query_values = array_merge($query_values, array(':day' => $day));
5199 5199
 			}
5200 5200
 		}
5201 5201
 
@@ -5207,7 +5207,7 @@  discard block
 block discarded – undo
5207 5207
 
5208 5208
 		$aircraft_array = array();
5209 5209
 		$temp_array = array();
5210
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5210
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5211 5211
 		{
5212 5212
 			$temp_array['airline_icao'] = $row['airline_icao'];
5213 5213
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5225,11 +5225,11 @@  discard block
 block discarded – undo
5225 5225
 	* @return Array the aircraft list
5226 5226
 	*
5227 5227
 	*/
5228
-	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5228
+	public function countAllAircraftTypesByMonths($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5229 5229
 	{
5230 5230
 		global $globalDBdriver;
5231
-		$filter_query = $this->getFilter($filters,true,true);
5232
-		$query  = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5231
+		$filter_query = $this->getFilter($filters, true, true);
5232
+		$query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5233 5233
 		    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' ";
5234 5234
 		if ($olderthanmonths > 0) {
5235 5235
 			if ($globalDBdriver == 'mysql') {
@@ -5254,7 +5254,7 @@  discard block
 block discarded – undo
5254 5254
 
5255 5255
 		$aircraft_array = array();
5256 5256
 		$temp_array = array();
5257
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5257
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5258 5258
 		{
5259 5259
 			//$temp_array['airline_icao'] = $row['airline_icao'];
5260 5260
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5273,13 +5273,13 @@  discard block
 block discarded – undo
5273 5273
 	* @return Array the aircraft list
5274 5274
 	*
5275 5275
 	*/
5276
-	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5276
+	public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array())
5277 5277
 	{
5278 5278
 		$Image = new Image($this->db);
5279
-		$filter_query = $this->getFilter($filters,true,true);
5280
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5279
+		$filter_query = $this->getFilter($filters, true, true);
5280
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5281 5281
 
5282
-		$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  
5282
+		$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  
5283 5283
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
5284 5284
 				GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5285 5285
 				ORDER BY registration_count DESC";
@@ -5290,14 +5290,14 @@  discard block
 block discarded – undo
5290 5290
 		$aircraft_array = array();
5291 5291
 		$temp_array = array();
5292 5292
         
5293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5294 5294
 		{
5295 5295
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5296 5296
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5297 5297
 			$temp_array['registration'] = $row['registration'];
5298 5298
 			$temp_array['airline_name'] = $row['airline_name'];
5299 5299
 			$temp_array['image_thumbnail'] = "";
5300
-			if($row['registration'] != "")
5300
+			if ($row['registration'] != "")
5301 5301
 			{
5302 5302
 				$image_array = $Image->getSpotterImage($row['registration']);
5303 5303
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5316,11 +5316,11 @@  discard block
 block discarded – undo
5316 5316
 	* @return Array the aircraft list
5317 5317
 	*
5318 5318
 	*/
5319
-	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5319
+	public function countAllAircraftTypesByAirline($airline_icao, $filters = array())
5320 5320
 	{
5321
-		$filter_query = $this->getFilter($filters,true,true);
5322
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5323
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5321
+		$filter_query = $this->getFilter($filters, true, true);
5322
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5323
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5324 5324
 			    FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
5325 5325
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5326 5326
 			    ORDER BY aircraft_icao_count DESC";
@@ -5331,7 +5331,7 @@  discard block
 block discarded – undo
5331 5331
 		$aircraft_array = array();
5332 5332
 		$temp_array = array();
5333 5333
 
5334
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5334
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5335 5335
 		{
5336 5336
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5337 5337
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5349,13 +5349,13 @@  discard block
 block discarded – undo
5349 5349
 	* @return Array the aircraft list
5350 5350
 	*
5351 5351
 	*/
5352
-	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5352
+	public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array())
5353 5353
 	{
5354
-		$filter_query = $this->getFilter($filters,true,true);
5354
+		$filter_query = $this->getFilter($filters, true, true);
5355 5355
 		$Image = new Image($this->db);
5356
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5356
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5357 5357
 
5358
-		$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 
5358
+		$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 
5359 5359
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
5360 5360
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5361 5361
 			    ORDER BY registration_count DESC";
@@ -5365,14 +5365,14 @@  discard block
 block discarded – undo
5365 5365
 
5366 5366
 		$aircraft_array = array();
5367 5367
 		$temp_array = array();
5368
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5368
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5369 5369
 		{
5370 5370
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5371 5371
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5372 5372
 			$temp_array['registration'] = $row['registration'];
5373 5373
 			$temp_array['airline_name'] = $row['airline_name'];
5374 5374
 			$temp_array['image_thumbnail'] = "";
5375
-			if($row['registration'] != "")
5375
+			if ($row['registration'] != "")
5376 5376
 			{
5377 5377
 				$image_array = $Image->getSpotterImage($row['registration']);
5378 5378
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5391,11 +5391,11 @@  discard block
 block discarded – undo
5391 5391
 	* @return Array the aircraft list
5392 5392
 	*
5393 5393
 	*/
5394
-	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5394
+	public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array())
5395 5395
 	{
5396
-		$filter_query = $this->getFilter($filters,true,true);
5397
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5398
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5396
+		$filter_query = $this->getFilter($filters, true, true);
5397
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5398
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5399 5399
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
5400 5400
 				GROUP BY spotter_output.aircraft_manufacturer 
5401 5401
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5406,7 +5406,7 @@  discard block
 block discarded – undo
5406 5406
 		$aircraft_array = array();
5407 5407
 		$temp_array = array();
5408 5408
 
5409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5410 5410
 		{
5411 5411
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5412 5412
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5423,12 +5423,12 @@  discard block
 block discarded – undo
5423 5423
 	* @return Array the aircraft list
5424 5424
 	*
5425 5425
 	*/
5426
-	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5426
+	public function countAllAircraftTypesByAirport($airport_icao, $filters = array())
5427 5427
 	{
5428
-		$filter_query = $this->getFilter($filters,true,true);
5429
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5428
+		$filter_query = $this->getFilter($filters, true, true);
5429
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5430 5430
 
5431
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5431
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5432 5432
 				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) 
5433 5433
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5434 5434
 				ORDER BY aircraft_icao_count DESC";
@@ -5438,7 +5438,7 @@  discard block
 block discarded – undo
5438 5438
 
5439 5439
 		$aircraft_array = array();
5440 5440
 		$temp_array = array();
5441
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5441
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5442 5442
 		{
5443 5443
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5444 5444
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5456,13 +5456,13 @@  discard block
 block discarded – undo
5456 5456
 	* @return Array the aircraft list
5457 5457
 	*
5458 5458
 	*/
5459
-	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5459
+	public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array())
5460 5460
 	{
5461
-		$filter_query = $this->getFilter($filters,true,true);
5461
+		$filter_query = $this->getFilter($filters, true, true);
5462 5462
 		$Image = new Image($this->db);
5463
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5463
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5464 5464
 
5465
-		$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  
5465
+		$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  
5466 5466
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
5467 5467
                     GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5468 5468
 		    ORDER BY registration_count DESC";
@@ -5472,14 +5472,14 @@  discard block
 block discarded – undo
5472 5472
 
5473 5473
 		$aircraft_array = array();
5474 5474
 		$temp_array = array();
5475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5476 5476
 		{
5477 5477
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5478 5478
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5479 5479
 			$temp_array['registration'] = $row['registration'];
5480 5480
 			$temp_array['airline_name'] = $row['airline_name'];
5481 5481
 			$temp_array['image_thumbnail'] = "";
5482
-			if($row['registration'] != "")
5482
+			if ($row['registration'] != "")
5483 5483
 			{
5484 5484
 				$image_array = $Image->getSpotterImage($row['registration']);
5485 5485
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5497,11 +5497,11 @@  discard block
 block discarded – undo
5497 5497
 	* @return Array the aircraft list
5498 5498
 	*
5499 5499
 	*/
5500
-	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5500
+	public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array())
5501 5501
 	{
5502
-		$filter_query = $this->getFilter($filters,true,true);
5503
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5504
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5502
+		$filter_query = $this->getFilter($filters, true, true);
5503
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5504
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5505 5505
                     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)  
5506 5506
                     GROUP BY spotter_output.aircraft_manufacturer 
5507 5507
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5512,7 +5512,7 @@  discard block
 block discarded – undo
5512 5512
 
5513 5513
 		$aircraft_array = array();
5514 5514
 		$temp_array = array();
5515
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5515
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5516 5516
 		{
5517 5517
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5518 5518
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5527,12 +5527,12 @@  discard block
 block discarded – undo
5527 5527
 	* @return Array the aircraft list
5528 5528
 	*
5529 5529
 	*/
5530
-	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5530
+	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array())
5531 5531
 	{
5532
-		$filter_query = $this->getFilter($filters,true,true);
5533
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5532
+		$filter_query = $this->getFilter($filters, true, true);
5533
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5534 5534
 
5535
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5535
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5536 5536
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
5537 5537
                     GROUP BY spotter_output.aircraft_name 
5538 5538
 					ORDER BY aircraft_icao_count DESC";
@@ -5541,7 +5541,7 @@  discard block
 block discarded – undo
5541 5541
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5542 5542
 		$aircraft_array = array();
5543 5543
 		$temp_array = array();
5544
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5544
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5545 5545
 		{
5546 5546
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5547 5547
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5560,11 +5560,11 @@  discard block
 block discarded – undo
5560 5560
 	*/
5561 5561
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5562 5562
 	{
5563
-		$filter_query = $this->getFilter($filters,true,true);
5563
+		$filter_query = $this->getFilter($filters, true, true);
5564 5564
 		$Image = new Image($this->db);
5565
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5565
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5566 5566
 
5567
-		$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   
5567
+		$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   
5568 5568
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
5569 5569
                     GROUP BY spotter_output.registration 
5570 5570
 					ORDER BY registration_count DESC";
@@ -5574,14 +5574,14 @@  discard block
 block discarded – undo
5574 5574
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5575 5575
 		$aircraft_array = array();
5576 5576
 		$temp_array = array();
5577
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5577
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5578 5578
 		{
5579 5579
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5580 5580
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5581 5581
 			$temp_array['registration'] = $row['registration'];
5582 5582
 			$temp_array['airline_name'] = $row['airline_name'];
5583 5583
 			$temp_array['image_thumbnail'] = "";
5584
-			if($row['registration'] != "")
5584
+			if ($row['registration'] != "")
5585 5585
 			{
5586 5586
 				$image_array = $Image->getSpotterImage($row['registration']);
5587 5587
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5598,11 +5598,11 @@  discard block
 block discarded – undo
5598 5598
 	* @return Array the aircraft list
5599 5599
 	*
5600 5600
 	*/
5601
-	public function countAllAircraftTypesByDate($date,$filters = array())
5601
+	public function countAllAircraftTypesByDate($date, $filters = array())
5602 5602
 	{
5603 5603
 		global $globalTimezone, $globalDBdriver;
5604
-		$filter_query = $this->getFilter($filters,true,true);
5605
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5604
+		$filter_query = $this->getFilter($filters, true, true);
5605
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5606 5606
 		if ($globalTimezone != '') {
5607 5607
 			date_default_timezone_set($globalTimezone);
5608 5608
 			$datetime = new DateTime($date);
@@ -5610,12 +5610,12 @@  discard block
 block discarded – undo
5610 5610
 		} else $offset = '+00:00';
5611 5611
 
5612 5612
 		if ($globalDBdriver == 'mysql') {
5613
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5613
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5614 5614
 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
5615 5615
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5616 5616
 					ORDER BY aircraft_icao_count DESC";
5617 5617
 		} else {
5618
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5618
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5619 5619
 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
5620 5620
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5621 5621
 					ORDER BY aircraft_icao_count DESC";
@@ -5626,7 +5626,7 @@  discard block
 block discarded – undo
5626 5626
 
5627 5627
 		$aircraft_array = array();
5628 5628
 		$temp_array = array();
5629
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5629
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5630 5630
 		{
5631 5631
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5632 5632
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5644,12 +5644,12 @@  discard block
 block discarded – undo
5644 5644
 	* @return Array the aircraft list
5645 5645
 	*
5646 5646
 	*/
5647
-	public function countAllAircraftRegistrationByDate($date,$filters = array())
5647
+	public function countAllAircraftRegistrationByDate($date, $filters = array())
5648 5648
 	{
5649 5649
 		global $globalTimezone, $globalDBdriver;
5650
-		$filter_query = $this->getFilter($filters,true,true);
5650
+		$filter_query = $this->getFilter($filters, true, true);
5651 5651
 		$Image = new Image($this->db);
5652
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5652
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5653 5653
 		if ($globalTimezone != '') {
5654 5654
 			date_default_timezone_set($globalTimezone);
5655 5655
 			$datetime = new DateTime($date);
@@ -5657,12 +5657,12 @@  discard block
 block discarded – undo
5657 5657
 		} else $offset = '+00:00';
5658 5658
 
5659 5659
 		if ($globalDBdriver == 'mysql') {
5660
-			$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 
5660
+			$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 
5661 5661
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5662 5662
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5663 5663
 					ORDER BY registration_count DESC";
5664 5664
 		} else {
5665
-			$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    
5665
+			$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    
5666 5666
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5667 5667
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5668 5668
 					ORDER BY registration_count DESC";
@@ -5673,14 +5673,14 @@  discard block
 block discarded – undo
5673 5673
 
5674 5674
 		$aircraft_array = array();
5675 5675
 		$temp_array = array();
5676
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5676
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5677 5677
 		{
5678 5678
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5679 5679
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5680 5680
 			$temp_array['registration'] = $row['registration'];
5681 5681
 			$temp_array['airline_name'] = $row['airline_name'];
5682 5682
 			$temp_array['image_thumbnail'] = "";
5683
-			if($row['registration'] != "")
5683
+			if ($row['registration'] != "")
5684 5684
 			{
5685 5685
 				$image_array = $Image->getSpotterImage($row['registration']);
5686 5686
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5699,11 +5699,11 @@  discard block
 block discarded – undo
5699 5699
 	* @return Array the aircraft manufacturer list
5700 5700
 	*
5701 5701
 	*/
5702
-	public function countAllAircraftManufacturerByDate($date,$filters = array())
5702
+	public function countAllAircraftManufacturerByDate($date, $filters = array())
5703 5703
 	{
5704 5704
 		global $globalTimezone, $globalDBdriver;
5705
-		$filter_query = $this->getFilter($filters,true,true);
5706
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5705
+		$filter_query = $this->getFilter($filters, true, true);
5706
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5707 5707
 		if ($globalTimezone != '') {
5708 5708
 			date_default_timezone_set($globalTimezone);
5709 5709
 			$datetime = new DateTime($date);
@@ -5711,12 +5711,12 @@  discard block
 block discarded – undo
5711 5711
 		} else $offset = '+00:00';
5712 5712
 
5713 5713
 		if ($globalDBdriver == 'mysql') {
5714
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5714
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5715 5715
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5716 5716
 				GROUP BY spotter_output.aircraft_manufacturer 
5717 5717
 				ORDER BY aircraft_manufacturer_count DESC";
5718 5718
 		} else {
5719
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5719
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5720 5720
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5721 5721
 				GROUP BY spotter_output.aircraft_manufacturer 
5722 5722
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5728,7 +5728,7 @@  discard block
 block discarded – undo
5728 5728
 		$aircraft_array = array();
5729 5729
 		$temp_array = array();
5730 5730
 
5731
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5731
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5732 5732
 		{
5733 5733
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5734 5734
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5745,11 +5745,11 @@  discard block
 block discarded – undo
5745 5745
 	* @return Array the aircraft list
5746 5746
 	*
5747 5747
 	*/
5748
-	public function countAllAircraftTypesByIdent($ident,$filters = array())
5748
+	public function countAllAircraftTypesByIdent($ident, $filters = array())
5749 5749
 	{
5750
-		$filter_query = $this->getFilter($filters,true,true);
5751
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5752
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5750
+		$filter_query = $this->getFilter($filters, true, true);
5751
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5752
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5753 5753
 				FROM spotter_output".$filter_query." spotter_output.ident = :ident 
5754 5754
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5755 5755
 				ORDER BY aircraft_icao_count DESC";
@@ -5760,7 +5760,7 @@  discard block
 block discarded – undo
5760 5760
 		$aircraft_array = array();
5761 5761
 		$temp_array = array();
5762 5762
 
5763
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5763
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5764 5764
 		{
5765 5765
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5766 5766
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5777,45 +5777,45 @@  discard block
 block discarded – undo
5777 5777
 	* @return Array the aircraft list
5778 5778
 	*
5779 5779
 	*/
5780
-	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5780
+	public function countAllAircraftTypesByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5781 5781
 	{
5782 5782
 		global $globalDBdriver;
5783
-		$filter_query = $this->getFilter($filters,true,true);
5784
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
5785
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5783
+		$filter_query = $this->getFilter($filters, true, true);
5784
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
5785
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5786 5786
 				FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)";
5787 5787
 		$query_values = array();
5788 5788
 		if ($year != '') {
5789 5789
 			if ($globalDBdriver == 'mysql') {
5790 5790
 				$query .= " AND YEAR(spotter_output.date) = :year";
5791
-				$query_values = array_merge($query_values,array(':year' => $year));
5791
+				$query_values = array_merge($query_values, array(':year' => $year));
5792 5792
 			} else {
5793 5793
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5794
-				$query_values = array_merge($query_values,array(':year' => $year));
5794
+				$query_values = array_merge($query_values, array(':year' => $year));
5795 5795
 			}
5796 5796
 		}
5797 5797
 		if ($month != '') {
5798 5798
 			if ($globalDBdriver == 'mysql') {
5799 5799
 				$query .= " AND MONTH(spotter_output.date) = :month";
5800
-				$query_values = array_merge($query_values,array(':month' => $month));
5800
+				$query_values = array_merge($query_values, array(':month' => $month));
5801 5801
 			} else {
5802 5802
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5803
-				$query_values = array_merge($query_values,array(':month' => $month));
5803
+				$query_values = array_merge($query_values, array(':month' => $month));
5804 5804
 			}
5805 5805
 		}
5806 5806
 		if ($day != '') {
5807 5807
 			if ($globalDBdriver == 'mysql') {
5808 5808
 				$query .= " AND DAY(spotter_output.date) = :day";
5809
-				$query_values = array_merge($query_values,array(':day' => $day));
5809
+				$query_values = array_merge($query_values, array(':day' => $day));
5810 5810
 			} else {
5811 5811
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5812
-				$query_values = array_merge($query_values,array(':day' => $day));
5812
+				$query_values = array_merge($query_values, array(':day' => $day));
5813 5813
 			}
5814 5814
 		}
5815 5815
 
5816 5816
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5817 5817
 				ORDER BY aircraft_icao_count DESC";
5818
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
5818
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
5819 5819
 		$sth = $this->db->prepare($query);
5820 5820
 		$sth->execute($query_values);
5821 5821
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5827,44 +5827,44 @@  discard block
 block discarded – undo
5827 5827
 	* @return Array the aircraft list
5828 5828
 	*
5829 5829
 	*/
5830
-	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5830
+	public function countAllAircraftTypesByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5831 5831
 	{
5832 5832
 		global $globalDBdriver;
5833
-		$filter_query = $this->getFilter($filters,true,true);
5834
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5835
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5833
+		$filter_query = $this->getFilter($filters, true, true);
5834
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5835
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5836 5836
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
5837 5837
 		$query_values = array();
5838 5838
 		if ($year != '') {
5839 5839
 			if ($globalDBdriver == 'mysql') {
5840 5840
 				$query .= " AND YEAR(spotter_output.date) = :year";
5841
-				$query_values = array_merge($query_values,array(':year' => $year));
5841
+				$query_values = array_merge($query_values, array(':year' => $year));
5842 5842
 			} else {
5843 5843
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5844
-				$query_values = array_merge($query_values,array(':year' => $year));
5844
+				$query_values = array_merge($query_values, array(':year' => $year));
5845 5845
 			}
5846 5846
 		}
5847 5847
 		if ($month != '') {
5848 5848
 			if ($globalDBdriver == 'mysql') {
5849 5849
 				$query .= " AND MONTH(spotter_output.date) = :month";
5850
-				$query_values = array_merge($query_values,array(':month' => $month));
5850
+				$query_values = array_merge($query_values, array(':month' => $month));
5851 5851
 			} else {
5852 5852
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5853
-				$query_values = array_merge($query_values,array(':month' => $month));
5853
+				$query_values = array_merge($query_values, array(':month' => $month));
5854 5854
 			}
5855 5855
 		}
5856 5856
 		if ($day != '') {
5857 5857
 			if ($globalDBdriver == 'mysql') {
5858 5858
 				$query .= " AND DAY(spotter_output.date) = :day";
5859
-				$query_values = array_merge($query_values,array(':day' => $day));
5859
+				$query_values = array_merge($query_values, array(':day' => $day));
5860 5860
 			} else {
5861 5861
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5862
-				$query_values = array_merge($query_values,array(':day' => $day));
5862
+				$query_values = array_merge($query_values, array(':day' => $day));
5863 5863
 			}
5864 5864
 		}
5865 5865
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao
5866 5866
 				ORDER BY aircraft_icao_count DESC";
5867
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5867
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5868 5868
 		$sth = $this->db->prepare($query);
5869 5869
 		$sth->execute($query_values);
5870 5870
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5876,13 +5876,13 @@  discard block
 block discarded – undo
5876 5876
 	* @return Array the aircraft list
5877 5877
 	*
5878 5878
 	*/
5879
-	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5879
+	public function countAllAircraftRegistrationByIdent($ident, $filters = array())
5880 5880
 	{
5881
-		$filter_query = $this->getFilter($filters,true,true);
5881
+		$filter_query = $this->getFilter($filters, true, true);
5882 5882
 		$Image = new Image($this->db);
5883
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5883
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5884 5884
 
5885
-		$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  
5885
+		$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  
5886 5886
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident   
5887 5887
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5888 5888
 		    ORDER BY registration_count DESC";
@@ -5894,14 +5894,14 @@  discard block
 block discarded – undo
5894 5894
 		$aircraft_array = array();
5895 5895
 		$temp_array = array();
5896 5896
         
5897
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5897
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5898 5898
 		{
5899 5899
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5900 5900
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5901 5901
 			$temp_array['registration'] = $row['registration'];
5902 5902
 			$temp_array['airline_name'] = $row['airline_name'];
5903 5903
 			$temp_array['image_thumbnail'] = "";
5904
-			if($row['registration'] != "")
5904
+			if ($row['registration'] != "")
5905 5905
 			{
5906 5906
 				$image_array = $Image->getSpotterImage($row['registration']);
5907 5907
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5919,44 +5919,44 @@  discard block
 block discarded – undo
5919 5919
 	* @return Array the aircraft list
5920 5920
 	*
5921 5921
 	*/
5922
-	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5922
+	public function countAllAircraftRegistrationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5923 5923
 	{
5924 5924
 		global $globalDBdriver;
5925
-		$filter_query = $this->getFilter($filters,true,true);
5925
+		$filter_query = $this->getFilter($filters, true, true);
5926 5926
 		$Image = new Image($this->db);
5927
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5927
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5928 5928
 
5929
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
5929
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
5930 5930
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner";
5931 5931
 		$query_values = array();
5932 5932
 		if ($year != '') {
5933 5933
 			if ($globalDBdriver == 'mysql') {
5934 5934
 				$query .= " AND YEAR(spotter_output.date) = :year";
5935
-				$query_values = array_merge($query_values,array(':year' => $year));
5935
+				$query_values = array_merge($query_values, array(':year' => $year));
5936 5936
 			} else {
5937 5937
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5938
-				$query_values = array_merge($query_values,array(':year' => $year));
5938
+				$query_values = array_merge($query_values, array(':year' => $year));
5939 5939
 			}
5940 5940
 		}
5941 5941
 		if ($month != '') {
5942 5942
 			if ($globalDBdriver == 'mysql') {
5943 5943
 				$query .= " AND MONTH(spotter_output.date) = :month";
5944
-				$query_values = array_merge($query_values,array(':month' => $month));
5944
+				$query_values = array_merge($query_values, array(':month' => $month));
5945 5945
 			} else {
5946 5946
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5947
-				$query_values = array_merge($query_values,array(':month' => $month));
5947
+				$query_values = array_merge($query_values, array(':month' => $month));
5948 5948
 			}
5949 5949
 		}
5950 5950
 		if ($day != '') {
5951 5951
 			if ($globalDBdriver == 'mysql') {
5952 5952
 				$query .= " AND DAY(spotter_output.date) = :day";
5953
-				$query_values = array_merge($query_values,array(':day' => $day));
5953
+				$query_values = array_merge($query_values, array(':day' => $day));
5954 5954
 			} else {
5955 5955
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5956
-				$query_values = array_merge($query_values,array(':day' => $day));
5956
+				$query_values = array_merge($query_values, array(':day' => $day));
5957 5957
 			}
5958 5958
 		}
5959
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5959
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5960 5960
 
5961 5961
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
5962 5962
 		    ORDER BY registration_count DESC";
@@ -5968,7 +5968,7 @@  discard block
 block discarded – undo
5968 5968
 		$aircraft_array = array();
5969 5969
 		$temp_array = array();
5970 5970
         
5971
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5971
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5972 5972
 		{
5973 5973
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5974 5974
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5976,7 +5976,7 @@  discard block
 block discarded – undo
5976 5976
 			$temp_array['registration'] = $row['registration'];
5977 5977
 			$temp_array['airline_name'] = $row['airline_name'];
5978 5978
 			$temp_array['image_thumbnail'] = "";
5979
-			if($row['registration'] != "")
5979
+			if ($row['registration'] != "")
5980 5980
 			{
5981 5981
 				$image_array = $Image->getSpotterImage($row['registration']);
5982 5982
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5994,44 +5994,44 @@  discard block
 block discarded – undo
5994 5994
 	* @return Array the aircraft list
5995 5995
 	*
5996 5996
 	*/
5997
-	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5997
+	public function countAllAircraftRegistrationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5998 5998
 	{
5999 5999
 		global $globalDBdriver;
6000
-		$filter_query = $this->getFilter($filters,true,true);
6000
+		$filter_query = $this->getFilter($filters, true, true);
6001 6001
 		$Image = new Image($this->db);
6002
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6002
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6003 6003
 
6004
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
6004
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
6005 6005
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6006 6006
 		$query_values = array();
6007 6007
 		if ($year != '') {
6008 6008
 			if ($globalDBdriver == 'mysql') {
6009 6009
 				$query .= " AND YEAR(spotter_output.date) = :year";
6010
-				$query_values = array_merge($query_values,array(':year' => $year));
6010
+				$query_values = array_merge($query_values, array(':year' => $year));
6011 6011
 			} else {
6012 6012
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6013
-				$query_values = array_merge($query_values,array(':year' => $year));
6013
+				$query_values = array_merge($query_values, array(':year' => $year));
6014 6014
 			}
6015 6015
 		}
6016 6016
 		if ($month != '') {
6017 6017
 			if ($globalDBdriver == 'mysql') {
6018 6018
 				$query .= " AND MONTH(spotter_output.date) = :month";
6019
-				$query_values = array_merge($query_values,array(':month' => $month));
6019
+				$query_values = array_merge($query_values, array(':month' => $month));
6020 6020
 			} else {
6021 6021
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6022
-				$query_values = array_merge($query_values,array(':month' => $month));
6022
+				$query_values = array_merge($query_values, array(':month' => $month));
6023 6023
 			}
6024 6024
 		}
6025 6025
 		if ($day != '') {
6026 6026
 			if ($globalDBdriver == 'mysql') {
6027 6027
 				$query .= " AND DAY(spotter_output.date) = :day";
6028
-				$query_values = array_merge($query_values,array(':day' => $day));
6028
+				$query_values = array_merge($query_values, array(':day' => $day));
6029 6029
 			} else {
6030 6030
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6031
-				$query_values = array_merge($query_values,array(':day' => $day));
6031
+				$query_values = array_merge($query_values, array(':day' => $day));
6032 6032
 			}
6033 6033
 		}
6034
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6034
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6035 6035
 
6036 6036
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
6037 6037
 		    ORDER BY registration_count DESC";
@@ -6043,7 +6043,7 @@  discard block
 block discarded – undo
6043 6043
 		$aircraft_array = array();
6044 6044
 		$temp_array = array();
6045 6045
         
6046
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6046
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6047 6047
 		{
6048 6048
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6049 6049
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6051,7 +6051,7 @@  discard block
 block discarded – undo
6051 6051
 			$temp_array['registration'] = $row['registration'];
6052 6052
 			$temp_array['airline_name'] = $row['airline_name'];
6053 6053
 			$temp_array['image_thumbnail'] = "";
6054
-			if($row['registration'] != "")
6054
+			if ($row['registration'] != "")
6055 6055
 			{
6056 6056
 				$image_array = $Image->getSpotterImage($row['registration']);
6057 6057
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6070,11 +6070,11 @@  discard block
 block discarded – undo
6070 6070
 	* @return Array the aircraft manufacturer list
6071 6071
 	*
6072 6072
 	*/
6073
-	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6073
+	public function countAllAircraftManufacturerByIdent($ident, $filters = array())
6074 6074
 	{
6075
-		$filter_query = $this->getFilter($filters,true,true);
6076
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6077
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6075
+		$filter_query = $this->getFilter($filters, true, true);
6076
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6077
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6078 6078
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
6079 6079
                     GROUP BY spotter_output.aircraft_manufacturer 
6080 6080
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6084,7 +6084,7 @@  discard block
 block discarded – undo
6084 6084
 		$sth->execute(array(':ident' => $ident));
6085 6085
 		$aircraft_array = array();
6086 6086
 		$temp_array = array();
6087
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6087
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6088 6088
 		{
6089 6089
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6090 6090
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6099,42 +6099,42 @@  discard block
 block discarded – undo
6099 6099
 	* @return Array the aircraft manufacturer list
6100 6100
 	*
6101 6101
 	*/
6102
-	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6102
+	public function countAllAircraftManufacturerByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
6103 6103
 	{
6104 6104
 		global $globalDBdriver;
6105
-		$filter_query = $this->getFilter($filters,true,true);
6106
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
6107
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6105
+		$filter_query = $this->getFilter($filters, true, true);
6106
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
6107
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6108 6108
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner";
6109 6109
 		$query_values = array();
6110 6110
 		if ($year != '') {
6111 6111
 			if ($globalDBdriver == 'mysql') {
6112 6112
 				$query .= " AND YEAR(spotter_output.date) = :year";
6113
-				$query_values = array_merge($query_values,array(':year' => $year));
6113
+				$query_values = array_merge($query_values, array(':year' => $year));
6114 6114
 			} else {
6115 6115
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6116
-				$query_values = array_merge($query_values,array(':year' => $year));
6116
+				$query_values = array_merge($query_values, array(':year' => $year));
6117 6117
 			}
6118 6118
 		}
6119 6119
 		if ($month != '') {
6120 6120
 			if ($globalDBdriver == 'mysql') {
6121 6121
 				$query .= " AND MONTH(spotter_output.date) = :month";
6122
-				$query_values = array_merge($query_values,array(':month' => $month));
6122
+				$query_values = array_merge($query_values, array(':month' => $month));
6123 6123
 			} else {
6124 6124
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6125
-				$query_values = array_merge($query_values,array(':month' => $month));
6125
+				$query_values = array_merge($query_values, array(':month' => $month));
6126 6126
 			}
6127 6127
 		}
6128 6128
 		if ($day != '') {
6129 6129
 			if ($globalDBdriver == 'mysql') {
6130 6130
 				$query .= " AND DAY(spotter_output.date) = :day";
6131
-				$query_values = array_merge($query_values,array(':day' => $day));
6131
+				$query_values = array_merge($query_values, array(':day' => $day));
6132 6132
 			} else {
6133 6133
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6134
-				$query_values = array_merge($query_values,array(':day' => $day));
6134
+				$query_values = array_merge($query_values, array(':day' => $day));
6135 6135
 			}
6136 6136
 		}
6137
-		$query_values = array_merge($query_values,array(':owner' => $owner));
6137
+		$query_values = array_merge($query_values, array(':owner' => $owner));
6138 6138
 
6139 6139
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6140 6140
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6151,42 +6151,42 @@  discard block
 block discarded – undo
6151 6151
 	* @return Array the aircraft manufacturer list
6152 6152
 	*
6153 6153
 	*/
6154
-	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6154
+	public function countAllAircraftManufacturerByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
6155 6155
 	{
6156 6156
 		global $globalDBdriver;
6157
-		$filter_query = $this->getFilter($filters,true,true);
6158
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6159
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6157
+		$filter_query = $this->getFilter($filters, true, true);
6158
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6159
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6160 6160
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6161 6161
 		$query_values = array();
6162 6162
 		if ($year != '') {
6163 6163
 			if ($globalDBdriver == 'mysql') {
6164 6164
 				$query .= " AND YEAR(spotter_output.date) = :year";
6165
-				$query_values = array_merge($query_values,array(':year' => $year));
6165
+				$query_values = array_merge($query_values, array(':year' => $year));
6166 6166
 			} else {
6167 6167
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6168
-				$query_values = array_merge($query_values,array(':year' => $year));
6168
+				$query_values = array_merge($query_values, array(':year' => $year));
6169 6169
 			}
6170 6170
 		}
6171 6171
 		if ($month != '') {
6172 6172
 			if ($globalDBdriver == 'mysql') {
6173 6173
 				$query .= " AND MONTH(spotter_output.date) = :month";
6174
-				$query_values = array_merge($query_values,array(':month' => $month));
6174
+				$query_values = array_merge($query_values, array(':month' => $month));
6175 6175
 			} else {
6176 6176
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6177
-				$query_values = array_merge($query_values,array(':month' => $month));
6177
+				$query_values = array_merge($query_values, array(':month' => $month));
6178 6178
 			}
6179 6179
 		}
6180 6180
 		if ($day != '') {
6181 6181
 			if ($globalDBdriver == 'mysql') {
6182 6182
 				$query .= " AND DAY(spotter_output.date) = :day";
6183
-				$query_values = array_merge($query_values,array(':day' => $day));
6183
+				$query_values = array_merge($query_values, array(':day' => $day));
6184 6184
 			} else {
6185 6185
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6186
-				$query_values = array_merge($query_values,array(':day' => $day));
6186
+				$query_values = array_merge($query_values, array(':day' => $day));
6187 6187
 			}
6188 6188
 		}
6189
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6189
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6190 6190
 
6191 6191
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6192 6192
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6204,24 +6204,24 @@  discard block
 block discarded – undo
6204 6204
 	* @return Array the aircraft list
6205 6205
 	*
6206 6206
 	*/
6207
-	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6207
+	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6208 6208
 	{
6209
-		$filter_query = $this->getFilter($filters,true,true);
6210
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6211
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6209
+		$filter_query = $this->getFilter($filters, true, true);
6210
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6211
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6212 6212
 		
6213 6213
 
6214
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6214
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6215 6215
                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
6216 6216
                     GROUP BY spotter_output.aircraft_name 
6217 6217
 					ORDER BY aircraft_icao_count DESC";
6218 6218
  
6219 6219
 		
6220 6220
 		$sth = $this->db->prepare($query);
6221
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6221
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6222 6222
 		$aircraft_array = array();
6223 6223
 		$temp_array = array();
6224
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6224
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6225 6225
 		{
6226 6226
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6227 6227
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6237,33 +6237,33 @@  discard block
 block discarded – undo
6237 6237
 	* @return Array the aircraft list
6238 6238
 	*
6239 6239
 	*/
6240
-	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6240
+	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6241 6241
 	{
6242
-		$filter_query = $this->getFilter($filters,true,true);
6242
+		$filter_query = $this->getFilter($filters, true, true);
6243 6243
 		$Image = new Image($this->db);
6244
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6245
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6244
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6245
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6246 6246
 
6247
-		$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   
6247
+		$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   
6248 6248
                     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)   
6249 6249
                     GROUP BY spotter_output.registration 
6250 6250
 					ORDER BY registration_count DESC";
6251 6251
 
6252 6252
 		
6253 6253
 		$sth = $this->db->prepare($query);
6254
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6254
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6255 6255
       
6256 6256
 		$aircraft_array = array();
6257 6257
 		$temp_array = array();
6258 6258
         
6259
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6259
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6260 6260
 		{
6261 6261
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6262 6262
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6263 6263
 			$temp_array['registration'] = $row['registration'];
6264 6264
 			$temp_array['airline_name'] = $row['airline_name'];
6265 6265
 			$temp_array['image_thumbnail'] = "";
6266
-			if($row['registration'] != "")
6266
+			if ($row['registration'] != "")
6267 6267
 			{
6268 6268
 				$image_array = $Image->getSpotterImage($row['registration']);
6269 6269
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6283,25 +6283,25 @@  discard block
 block discarded – undo
6283 6283
 	* @return Array the aircraft manufacturer list
6284 6284
 	*
6285 6285
 	*/
6286
-	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6286
+	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6287 6287
 	{
6288
-		$filter_query = $this->getFilter($filters,true,true);
6289
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6290
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6288
+		$filter_query = $this->getFilter($filters, true, true);
6289
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6290
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6291 6291
 
6292
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6292
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6293 6293
                     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) 
6294 6294
                     GROUP BY spotter_output.aircraft_manufacturer 
6295 6295
 					ORDER BY aircraft_manufacturer_count DESC";
6296 6296
 
6297 6297
 		
6298 6298
 		$sth = $this->db->prepare($query);
6299
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6299
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6300 6300
       
6301 6301
 		$aircraft_array = array();
6302 6302
 		$temp_array = array();
6303 6303
         
6304
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6304
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6305 6305
 		{
6306 6306
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6307 6307
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6321,11 +6321,11 @@  discard block
 block discarded – undo
6321 6321
 	* @return Array the aircraft list
6322 6322
 	*
6323 6323
 	*/
6324
-	public function countAllAircraftTypesByCountry($country,$filters = array())
6324
+	public function countAllAircraftTypesByCountry($country, $filters = array())
6325 6325
 	{
6326
-		$filter_query = $this->getFilter($filters,true,true);
6327
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6328
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6326
+		$filter_query = $this->getFilter($filters, true, true);
6327
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6328
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6329 6329
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6330 6330
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
6331 6331
 			    ORDER BY aircraft_icao_count DESC";
@@ -6337,7 +6337,7 @@  discard block
 block discarded – undo
6337 6337
 		$aircraft_array = array();
6338 6338
 		$temp_array = array();
6339 6339
         
6340
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6340
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6341 6341
 		{
6342 6342
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6343 6343
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6356,12 +6356,12 @@  discard block
 block discarded – undo
6356 6356
 	* @return Array the aircraft list
6357 6357
 	*
6358 6358
 	*/
6359
-	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6359
+	public function countAllAircraftRegistrationByCountry($country, $filters = array())
6360 6360
 	{
6361
-		$filter_query = $this->getFilter($filters,true,true);
6361
+		$filter_query = $this->getFilter($filters, true, true);
6362 6362
 		$Image = new Image($this->db);
6363
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6364
-		$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 
6363
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6364
+		$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 
6365 6365
 			    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)    
6366 6366
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
6367 6367
 			    ORDER BY registration_count DESC";
@@ -6373,14 +6373,14 @@  discard block
 block discarded – undo
6373 6373
 		$aircraft_array = array();
6374 6374
 		$temp_array = array();
6375 6375
         
6376
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6376
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6377 6377
 		{
6378 6378
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6379 6379
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6380 6380
 			$temp_array['registration'] = $row['registration'];
6381 6381
 			$temp_array['airline_name'] = $row['airline_name'];
6382 6382
 			$temp_array['image_thumbnail'] = "";
6383
-			if($row['registration'] != "")
6383
+			if ($row['registration'] != "")
6384 6384
 			{
6385 6385
 				$image_array = $Image->getSpotterImage($row['registration']);
6386 6386
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6400,11 +6400,11 @@  discard block
 block discarded – undo
6400 6400
 	* @return Array the aircraft manufacturer list
6401 6401
 	*
6402 6402
 	*/
6403
-	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6403
+	public function countAllAircraftManufacturerByCountry($country, $filters = array())
6404 6404
 	{
6405
-		$filter_query = $this->getFilter($filters,true,true);
6406
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6407
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6405
+		$filter_query = $this->getFilter($filters, true, true);
6406
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6407
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6408 6408
                     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) 
6409 6409
                     GROUP BY spotter_output.aircraft_manufacturer 
6410 6410
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6416,7 +6416,7 @@  discard block
 block discarded – undo
6416 6416
 		$aircraft_array = array();
6417 6417
 		$temp_array = array();
6418 6418
         
6419
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6419
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6420 6420
 		{
6421 6421
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6422 6422
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6435,38 +6435,38 @@  discard block
 block discarded – undo
6435 6435
 	* @return Array the aircraft list
6436 6436
 	*
6437 6437
 	*/
6438
-	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6438
+	public function countAllAircraftManufacturers($filters = array(), $year = '', $month = '', $day = '')
6439 6439
 	{
6440 6440
 		global $globalDBdriver;
6441
-		$filter_query = $this->getFilter($filters,true,true);
6442
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6441
+		$filter_query = $this->getFilter($filters, true, true);
6442
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6443 6443
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6444 6444
                 $query_values = array();
6445 6445
 		if ($year != '') {
6446 6446
 			if ($globalDBdriver == 'mysql') {
6447 6447
 				$query .= " AND YEAR(spotter_output.date) = :year";
6448
-				$query_values = array_merge($query_values,array(':year' => $year));
6448
+				$query_values = array_merge($query_values, array(':year' => $year));
6449 6449
 			} else {
6450 6450
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6451
-				$query_values = array_merge($query_values,array(':year' => $year));
6451
+				$query_values = array_merge($query_values, array(':year' => $year));
6452 6452
 			}
6453 6453
 		}
6454 6454
 		if ($month != '') {
6455 6455
 			if ($globalDBdriver == 'mysql') {
6456 6456
 				$query .= " AND MONTH(spotter_output.date) = :month";
6457
-				$query_values = array_merge($query_values,array(':month' => $month));
6457
+				$query_values = array_merge($query_values, array(':month' => $month));
6458 6458
 			} else {
6459 6459
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6460
-				$query_values = array_merge($query_values,array(':month' => $month));
6460
+				$query_values = array_merge($query_values, array(':month' => $month));
6461 6461
 			}
6462 6462
 		}
6463 6463
 		if ($day != '') {
6464 6464
 			if ($globalDBdriver == 'mysql') {
6465 6465
 				$query .= " AND DAY(spotter_output.date) = :day";
6466
-				$query_values = array_merge($query_values,array(':day' => $day));
6466
+				$query_values = array_merge($query_values, array(':day' => $day));
6467 6467
 			} else {
6468 6468
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6469
-				$query_values = array_merge($query_values,array(':day' => $day));
6469
+				$query_values = array_merge($query_values, array(':day' => $day));
6470 6470
 			}
6471 6471
 		}
6472 6472
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer
@@ -6480,7 +6480,7 @@  discard block
 block discarded – undo
6480 6480
 		$manufacturer_array = array();
6481 6481
 		$temp_array = array();
6482 6482
         
6483
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6483
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6484 6484
 		{
6485 6485
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6486 6486
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6499,12 +6499,12 @@  discard block
 block discarded – undo
6499 6499
 	* @return Array the aircraft list
6500 6500
 	*
6501 6501
 	*/
6502
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6502
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6503 6503
 	{
6504 6504
 		global $globalDBdriver;
6505 6505
 		$Image = new Image($this->db);
6506
-		$filter_query = $this->getFilter($filters,true,true);
6507
-		$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    
6506
+		$filter_query = $this->getFilter($filters, true, true);
6507
+		$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    
6508 6508
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6509 6509
                 if ($olderthanmonths > 0) {
6510 6510
             		if ($globalDBdriver == 'mysql') {
@@ -6524,28 +6524,28 @@  discard block
 block discarded – undo
6524 6524
 		if ($year != '') {
6525 6525
 			if ($globalDBdriver == 'mysql') {
6526 6526
 				$query .= " AND YEAR(spotter_output.date) = :year";
6527
-				$query_values = array_merge($query_values,array(':year' => $year));
6527
+				$query_values = array_merge($query_values, array(':year' => $year));
6528 6528
 			} else {
6529 6529
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6530
-				$query_values = array_merge($query_values,array(':year' => $year));
6530
+				$query_values = array_merge($query_values, array(':year' => $year));
6531 6531
 			}
6532 6532
 		}
6533 6533
 		if ($month != '') {
6534 6534
 			if ($globalDBdriver == 'mysql') {
6535 6535
 				$query .= " AND MONTH(spotter_output.date) = :month";
6536
-				$query_values = array_merge($query_values,array(':month' => $month));
6536
+				$query_values = array_merge($query_values, array(':month' => $month));
6537 6537
 			} else {
6538 6538
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6539
-				$query_values = array_merge($query_values,array(':month' => $month));
6539
+				$query_values = array_merge($query_values, array(':month' => $month));
6540 6540
 			}
6541 6541
 		}
6542 6542
 		if ($day != '') {
6543 6543
 			if ($globalDBdriver == 'mysql') {
6544 6544
 				$query .= " AND DAY(spotter_output.date) = :day";
6545
-				$query_values = array_merge($query_values,array(':day' => $day));
6545
+				$query_values = array_merge($query_values, array(':day' => $day));
6546 6546
 			} else {
6547 6547
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6548
-				$query_values = array_merge($query_values,array(':day' => $day));
6548
+				$query_values = array_merge($query_values, array(':day' => $day));
6549 6549
 			}
6550 6550
 		}
6551 6551
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
@@ -6557,7 +6557,7 @@  discard block
 block discarded – undo
6557 6557
 		$aircraft_array = array();
6558 6558
 		$temp_array = array();
6559 6559
         
6560
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6560
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6561 6561
 		{
6562 6562
 			$temp_array['registration'] = $row['registration'];
6563 6563
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6565,7 +6565,7 @@  discard block
 block discarded – undo
6565 6565
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6566 6566
 			$temp_array['airline_name'] = $row['airline_name'];
6567 6567
 			$temp_array['image_thumbnail'] = "";
6568
-			if($row['registration'] != "")
6568
+			if ($row['registration'] != "")
6569 6569
 			{
6570 6570
 				$image_array = $Image->getSpotterImage($row['registration']);
6571 6571
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6584,12 +6584,12 @@  discard block
 block discarded – undo
6584 6584
 	* @return Array the aircraft list
6585 6585
 	*
6586 6586
 	*/
6587
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6587
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6588 6588
 	{
6589 6589
 		global $globalDBdriver;
6590
-		$filter_query = $this->getFilter($filters,true,true);
6590
+		$filter_query = $this->getFilter($filters, true, true);
6591 6591
 		$Image = new Image($this->db);
6592
-		$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    
6592
+		$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    
6593 6593
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6594 6594
                 if ($olderthanmonths > 0) {
6595 6595
             		if ($globalDBdriver == 'mysql') {
@@ -6617,7 +6617,7 @@  discard block
 block discarded – undo
6617 6617
 		$aircraft_array = array();
6618 6618
 		$temp_array = array();
6619 6619
         
6620
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6620
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6621 6621
 		{
6622 6622
 			$temp_array['registration'] = $row['registration'];
6623 6623
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6626,7 +6626,7 @@  discard block
 block discarded – undo
6626 6626
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6627 6627
 			$temp_array['airline_name'] = $row['airline_name'];
6628 6628
 			$temp_array['image_thumbnail'] = "";
6629
-			if($row['registration'] != "")
6629
+			if ($row['registration'] != "")
6630 6630
 			{
6631 6631
 				$image_array = $Image->getSpotterImage($row['registration']);
6632 6632
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6645,11 +6645,11 @@  discard block
 block discarded – undo
6645 6645
 	* @return Array the airport list
6646 6646
 	*
6647 6647
 	*/
6648
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6648
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6649 6649
 	{
6650 6650
 		global $globalDBdriver;
6651
-		$filter_query = $this->getFilter($filters,true,true);
6652
-		$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 
6651
+		$filter_query = $this->getFilter($filters, true, true);
6652
+		$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 
6653 6653
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6654 6654
                 if ($olderthanmonths > 0) {
6655 6655
             		if ($globalDBdriver == 'mysql') {
@@ -6669,28 +6669,28 @@  discard block
 block discarded – undo
6669 6669
 		if ($year != '') {
6670 6670
 			if ($globalDBdriver == 'mysql') {
6671 6671
 				$query .= " AND YEAR(spotter_output.date) = :year";
6672
-				$query_values = array_merge($query_values,array(':year' => $year));
6672
+				$query_values = array_merge($query_values, array(':year' => $year));
6673 6673
 			} else {
6674 6674
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6675
-				$query_values = array_merge($query_values,array(':year' => $year));
6675
+				$query_values = array_merge($query_values, array(':year' => $year));
6676 6676
 			}
6677 6677
 		}
6678 6678
 		if ($month != '') {
6679 6679
 			if ($globalDBdriver == 'mysql') {
6680 6680
 				$query .= " AND MONTH(spotter_output.date) = :month";
6681
-				$query_values = array_merge($query_values,array(':month' => $month));
6681
+				$query_values = array_merge($query_values, array(':month' => $month));
6682 6682
 			} else {
6683 6683
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6684
-				$query_values = array_merge($query_values,array(':month' => $month));
6684
+				$query_values = array_merge($query_values, array(':month' => $month));
6685 6685
 			}
6686 6686
 		}
6687 6687
 		if ($day != '') {
6688 6688
 			if ($globalDBdriver == 'mysql') {
6689 6689
 				$query .= " AND DAY(spotter_output.date) = :day";
6690
-				$query_values = array_merge($query_values,array(':day' => $day));
6690
+				$query_values = array_merge($query_values, array(':day' => $day));
6691 6691
 			} else {
6692 6692
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6693
-				$query_values = array_merge($query_values,array(':day' => $day));
6693
+				$query_values = array_merge($query_values, array(':day' => $day));
6694 6694
 			}
6695 6695
 		}
6696 6696
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -6702,7 +6702,7 @@  discard block
 block discarded – undo
6702 6702
 
6703 6703
 		$airport_array = array();
6704 6704
 		$temp_array = array();
6705
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6705
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6706 6706
 		{
6707 6707
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6708 6708
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6721,11 +6721,11 @@  discard block
 block discarded – undo
6721 6721
 	* @return Array the airport list
6722 6722
 	*
6723 6723
 	*/
6724
-	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6724
+	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6725 6725
 	{
6726 6726
 		global $globalDBdriver;
6727
-		$filter_query = $this->getFilter($filters,true,true);
6728
-		$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 
6727
+		$filter_query = $this->getFilter($filters, true, true);
6728
+		$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 
6729 6729
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' ";
6730 6730
                 if ($olderthanmonths > 0) {
6731 6731
             		if ($globalDBdriver == 'mysql') {
@@ -6754,7 +6754,7 @@  discard block
 block discarded – undo
6754 6754
 		$airport_array = array();
6755 6755
 		$temp_array = array();
6756 6756
         
6757
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6757
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6758 6758
 		{
6759 6759
 			$temp_array['airline_icao'] = $row['airline_icao'];
6760 6760
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6774,11 +6774,11 @@  discard block
 block discarded – undo
6774 6774
 	* @return Array the airport list
6775 6775
 	*
6776 6776
 	*/
6777
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6777
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6778 6778
 	{
6779 6779
 		global $globalDBdriver;
6780
-		$filter_query = $this->getFilter($filters,true,true);
6781
-		$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
6780
+		$filter_query = $this->getFilter($filters, true, true);
6781
+		$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
6782 6782
 				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";
6783 6783
                 if ($olderthanmonths > 0) {
6784 6784
             		if ($globalDBdriver == 'mysql') {
@@ -6798,28 +6798,28 @@  discard block
 block discarded – undo
6798 6798
 		if ($year != '') {
6799 6799
 			if ($globalDBdriver == 'mysql') {
6800 6800
 				$query .= " AND YEAR(spotter_output.date) = :year";
6801
-				$query_values = array_merge($query_values,array(':year' => $year));
6801
+				$query_values = array_merge($query_values, array(':year' => $year));
6802 6802
 			} else {
6803 6803
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6804
-				$query_values = array_merge($query_values,array(':year' => $year));
6804
+				$query_values = array_merge($query_values, array(':year' => $year));
6805 6805
 			}
6806 6806
 		}
6807 6807
 		if ($month != '') {
6808 6808
 			if ($globalDBdriver == 'mysql') {
6809 6809
 				$query .= " AND MONTH(spotter_output.date) = :month";
6810
-				$query_values = array_merge($query_values,array(':month' => $month));
6810
+				$query_values = array_merge($query_values, array(':month' => $month));
6811 6811
 			} else {
6812 6812
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6813
-				$query_values = array_merge($query_values,array(':month' => $month));
6813
+				$query_values = array_merge($query_values, array(':month' => $month));
6814 6814
 			}
6815 6815
 		}
6816 6816
 		if ($day != '') {
6817 6817
 			if ($globalDBdriver == 'mysql') {
6818 6818
 				$query .= " AND DAY(spotter_output.date) = :day";
6819
-				$query_values = array_merge($query_values,array(':day' => $day));
6819
+				$query_values = array_merge($query_values, array(':day' => $day));
6820 6820
 			} else {
6821 6821
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6822
-				$query_values = array_merge($query_values,array(':day' => $day));
6822
+				$query_values = array_merge($query_values, array(':day' => $day));
6823 6823
 			}
6824 6824
 		}
6825 6825
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
@@ -6832,7 +6832,7 @@  discard block
 block discarded – undo
6832 6832
 		$airport_array = array();
6833 6833
 		$temp_array = array();
6834 6834
         
6835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6836 6836
 		{
6837 6837
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6838 6838
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6851,11 +6851,11 @@  discard block
 block discarded – undo
6851 6851
 	* @return Array the airport list
6852 6852
 	*
6853 6853
 	*/
6854
-	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6854
+	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6855 6855
 	{
6856 6856
 		global $globalDBdriver;
6857
-		$filter_query = $this->getFilter($filters,true,true);
6858
-		$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
6857
+		$filter_query = $this->getFilter($filters, true, true);
6858
+		$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
6859 6859
 				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 ";
6860 6860
                 if ($olderthanmonths > 0) {
6861 6861
             		if ($globalDBdriver == 'mysql') {
@@ -6884,7 +6884,7 @@  discard block
 block discarded – undo
6884 6884
 		$airport_array = array();
6885 6885
 		$temp_array = array();
6886 6886
         
6887
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6887
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6888 6888
 		{
6889 6889
 			$temp_array['airline_icao'] = $row['airline_icao'];
6890 6890
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6904,11 +6904,11 @@  discard block
 block discarded – undo
6904 6904
 	* @return Array the airport list
6905 6905
 	*
6906 6906
 	*/
6907
-	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6907
+	public function countAllDepartureAirportsByAirline($airline_icao, $filters = array())
6908 6908
 	{
6909
-		$filter_query = $this->getFilter($filters,true,true);
6910
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6911
-		$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 
6909
+		$filter_query = $this->getFilter($filters, true, true);
6910
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6911
+		$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 
6912 6912
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao AND spotter_output.departure_airport_icao <> '' 
6913 6913
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6914 6914
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6920,7 +6920,7 @@  discard block
 block discarded – undo
6920 6920
 		$airport_array = array();
6921 6921
 		$temp_array = array();
6922 6922
         
6923
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6923
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6924 6924
 		{
6925 6925
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6926 6926
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6942,11 +6942,11 @@  discard block
 block discarded – undo
6942 6942
 	* @return Array the airport list
6943 6943
 	*
6944 6944
 	*/
6945
-	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6945
+	public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array())
6946 6946
 	{
6947
-		$filter_query = $this->getFilter($filters,true,true);
6948
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6949
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6947
+		$filter_query = $this->getFilter($filters, true, true);
6948
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6949
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6950 6950
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6951 6951
                     GROUP BY spotter_output.departure_airport_country
6952 6952
 					ORDER BY airport_departure_country_count DESC";
@@ -6958,7 +6958,7 @@  discard block
 block discarded – undo
6958 6958
 		$airport_array = array();
6959 6959
 		$temp_array = array();
6960 6960
         
6961
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6961
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6962 6962
 		{
6963 6963
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6964 6964
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6977,11 +6977,11 @@  discard block
 block discarded – undo
6977 6977
 	* @return Array the airport list
6978 6978
 	*
6979 6979
 	*/
6980
-	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6980
+	public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array())
6981 6981
 	{
6982
-		$filter_query = $this->getFilter($filters,true,true);
6983
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6984
-		$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 
6982
+		$filter_query = $this->getFilter($filters, true, true);
6983
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6984
+		$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 
6985 6985
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao AND spotter_output.departure_airport_icao <> '' 
6986 6986
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6987 6987
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6993,7 +6993,7 @@  discard block
 block discarded – undo
6993 6993
 		$airport_array = array();
6994 6994
 		$temp_array = array();
6995 6995
         
6996
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6996
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6997 6997
 		{
6998 6998
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6999 6999
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7014,11 +7014,11 @@  discard block
 block discarded – undo
7014 7014
 	* @return Array the airport list
7015 7015
 	*
7016 7016
 	*/
7017
-	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7017
+	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array())
7018 7018
 	{
7019
-		$filter_query = $this->getFilter($filters,true,true);
7020
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7021
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7019
+		$filter_query = $this->getFilter($filters, true, true);
7020
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7021
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7022 7022
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
7023 7023
                     GROUP BY spotter_output.departure_airport_country
7024 7024
 					ORDER BY airport_departure_country_count DESC";
@@ -7030,7 +7030,7 @@  discard block
 block discarded – undo
7030 7030
 		$airport_array = array();
7031 7031
 		$temp_array = array();
7032 7032
         
7033
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7033
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7034 7034
 		{
7035 7035
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7036 7036
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7048,11 +7048,11 @@  discard block
 block discarded – undo
7048 7048
 	* @return Array the airport list
7049 7049
 	*
7050 7050
 	*/
7051
-	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7051
+	public function countAllDepartureAirportsByRegistration($registration, $filters = array())
7052 7052
 	{
7053
-		$filter_query = $this->getFilter($filters,true,true);
7054
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7055
-		$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 
7053
+		$filter_query = $this->getFilter($filters, true, true);
7054
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7055
+		$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 
7056 7056
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration AND spotter_output.departure_airport_icao <> '' 
7057 7057
                     GROUP BY spotter_output.departure_airport_icao
7058 7058
 					ORDER BY airport_departure_icao_count DESC";
@@ -7064,7 +7064,7 @@  discard block
 block discarded – undo
7064 7064
 		$airport_array = array();
7065 7065
 		$temp_array = array();
7066 7066
         
7067
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7067
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7068 7068
 		{
7069 7069
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7070 7070
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7085,11 +7085,11 @@  discard block
 block discarded – undo
7085 7085
 	* @return Array the airport list
7086 7086
 	*
7087 7087
 	*/
7088
-	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7088
+	public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array())
7089 7089
 	{
7090
-		$filter_query = $this->getFilter($filters,true,true);
7091
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7092
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7090
+		$filter_query = $this->getFilter($filters, true, true);
7091
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7092
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7093 7093
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
7094 7094
                     GROUP BY spotter_output.departure_airport_country
7095 7095
 					ORDER BY airport_departure_country_count DESC";
@@ -7101,7 +7101,7 @@  discard block
 block discarded – undo
7101 7101
 		$airport_array = array();
7102 7102
 		$temp_array = array();
7103 7103
         
7104
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7104
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7105 7105
 		{
7106 7106
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7107 7107
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7119,11 +7119,11 @@  discard block
 block discarded – undo
7119 7119
 	* @return Array the airport list
7120 7120
 	*
7121 7121
 	*/
7122
-	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7122
+	public function countAllDepartureAirportsByAirport($airport_icao, $filters = array())
7123 7123
 	{
7124
-		$filter_query = $this->getFilter($filters,true,true);
7125
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7126
-		$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 
7124
+		$filter_query = $this->getFilter($filters, true, true);
7125
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7126
+		$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 
7127 7127
 			    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 AND spotter_output.departure_airport_icao <> '' 
7128 7128
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7129 7129
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7135,7 +7135,7 @@  discard block
 block discarded – undo
7135 7135
 		$airport_array = array();
7136 7136
 		$temp_array = array();
7137 7137
         
7138
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7138
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7139 7139
 		{
7140 7140
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7141 7141
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7156,11 +7156,11 @@  discard block
 block discarded – undo
7156 7156
 	* @return Array the airport list
7157 7157
 	*
7158 7158
 	*/
7159
-	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7159
+	public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array())
7160 7160
 	{
7161
-		$filter_query = $this->getFilter($filters,true,true);
7162
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7163
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7161
+		$filter_query = $this->getFilter($filters, true, true);
7162
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7163
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7164 7164
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
7165 7165
                     GROUP BY spotter_output.departure_airport_country
7166 7166
 					ORDER BY airport_departure_country_count DESC";
@@ -7172,7 +7172,7 @@  discard block
 block discarded – undo
7172 7172
 		$airport_array = array();
7173 7173
 		$temp_array = array();
7174 7174
         
7175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7176 7176
 		{
7177 7177
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7178 7178
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7191,11 +7191,11 @@  discard block
 block discarded – undo
7191 7191
 	* @return Array the airport list
7192 7192
 	*
7193 7193
 	*/
7194
-	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7194
+	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array())
7195 7195
 	{
7196
-		$filter_query = $this->getFilter($filters,true,true);
7197
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7198
-		$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 
7196
+		$filter_query = $this->getFilter($filters, true, true);
7197
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7198
+		$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 
7199 7199
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer AND spotter_output.departure_airport_icao <> '' 
7200 7200
                     GROUP BY spotter_output.departure_airport_icao
7201 7201
 					ORDER BY airport_departure_icao_count DESC";
@@ -7207,7 +7207,7 @@  discard block
 block discarded – undo
7207 7207
 		$airport_array = array();
7208 7208
 		$temp_array = array();
7209 7209
         
7210
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7210
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7211 7211
 		{
7212 7212
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7213 7213
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7228,11 +7228,11 @@  discard block
 block discarded – undo
7228 7228
 	* @return Array the airport list
7229 7229
 	*
7230 7230
 	*/
7231
-	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7231
+	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
7232 7232
 	{
7233
-		$filter_query = $this->getFilter($filters,true,true);
7234
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7235
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7233
+		$filter_query = $this->getFilter($filters, true, true);
7234
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7235
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7236 7236
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
7237 7237
                     GROUP BY spotter_output.departure_airport_country
7238 7238
 					ORDER BY airport_departure_country_count DESC";
@@ -7244,7 +7244,7 @@  discard block
 block discarded – undo
7244 7244
 		$airport_array = array();
7245 7245
 		$temp_array = array();
7246 7246
         
7247
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7247
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7248 7248
 		{
7249 7249
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7250 7250
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7262,11 +7262,11 @@  discard block
 block discarded – undo
7262 7262
 	* @return Array the airport list
7263 7263
 	*
7264 7264
 	*/
7265
-	public function countAllDepartureAirportsByDate($date,$filters = array())
7265
+	public function countAllDepartureAirportsByDate($date, $filters = array())
7266 7266
 	{
7267 7267
 		global $globalTimezone, $globalDBdriver;
7268
-		$filter_query = $this->getFilter($filters,true,true);
7269
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7268
+		$filter_query = $this->getFilter($filters, true, true);
7269
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7270 7270
 		if ($globalTimezone != '') {
7271 7271
 			date_default_timezone_set($globalTimezone);
7272 7272
 			$datetime = new DateTime($date);
@@ -7274,12 +7274,12 @@  discard block
 block discarded – undo
7274 7274
 		} else $offset = '+00:00';
7275 7275
 
7276 7276
 		if ($globalDBdriver == 'mysql') {
7277
-			$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 
7277
+			$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 
7278 7278
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
7279 7279
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7280 7280
 					ORDER BY airport_departure_icao_count DESC";
7281 7281
 		} else {
7282
-			$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 
7282
+			$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 
7283 7283
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
7284 7284
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7285 7285
 					ORDER BY airport_departure_icao_count DESC";
@@ -7291,7 +7291,7 @@  discard block
 block discarded – undo
7291 7291
 		$airport_array = array();
7292 7292
 		$temp_array = array();
7293 7293
         
7294
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7294
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7295 7295
 		{
7296 7296
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7297 7297
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7312,11 +7312,11 @@  discard block
 block discarded – undo
7312 7312
 	* @return Array the airport list
7313 7313
 	*
7314 7314
 	*/
7315
-	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7315
+	public function countAllDepartureAirportCountriesByDate($date, $filters = array())
7316 7316
 	{
7317 7317
 		global $globalTimezone, $globalDBdriver;
7318
-		$filter_query = $this->getFilter($filters,true,true);
7319
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7318
+		$filter_query = $this->getFilter($filters, true, true);
7319
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7320 7320
 		if ($globalTimezone != '') {
7321 7321
 			date_default_timezone_set($globalTimezone);
7322 7322
 			$datetime = new DateTime($date);
@@ -7324,12 +7324,12 @@  discard block
 block discarded – undo
7324 7324
 		} else $offset = '+00:00';
7325 7325
 
7326 7326
 		if ($globalDBdriver == 'mysql') {
7327
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7327
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7328 7328
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
7329 7329
 					GROUP BY spotter_output.departure_airport_country
7330 7330
 					ORDER BY airport_departure_country_count DESC";
7331 7331
 		} else {
7332
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7332
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7333 7333
 					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 
7334 7334
 					GROUP BY spotter_output.departure_airport_country
7335 7335
 					ORDER BY airport_departure_country_count DESC";
@@ -7341,7 +7341,7 @@  discard block
 block discarded – undo
7341 7341
 		$airport_array = array();
7342 7342
 		$temp_array = array();
7343 7343
         
7344
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7344
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7345 7345
 		{
7346 7346
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7347 7347
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7359,11 +7359,11 @@  discard block
 block discarded – undo
7359 7359
 	* @return Array the airport list
7360 7360
 	*
7361 7361
 	*/
7362
-	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7362
+	public function countAllDepartureAirportsByIdent($ident, $filters = array())
7363 7363
 	{
7364
-		$filter_query = $this->getFilter($filters,true,true);
7365
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7366
-		$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 
7364
+		$filter_query = $this->getFilter($filters, true, true);
7365
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7366
+		$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 
7367 7367
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.ident = :ident 
7368 7368
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7369 7369
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7375,7 +7375,7 @@  discard block
 block discarded – undo
7375 7375
 		$airport_array = array();
7376 7376
 		$temp_array = array();
7377 7377
         
7378
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7378
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7379 7379
 		{
7380 7380
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7381 7381
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7395,11 +7395,11 @@  discard block
 block discarded – undo
7395 7395
 	* @return Array the airport list
7396 7396
 	*
7397 7397
 	*/
7398
-	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7398
+	public function countAllDepartureAirportsByOwner($owner, $filters = array())
7399 7399
 	{
7400
-		$filter_query = $this->getFilter($filters,true,true);
7401
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7402
-		$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 
7400
+		$filter_query = $this->getFilter($filters, true, true);
7401
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7402
+		$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 
7403 7403
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.owner_name = :owner 
7404 7404
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7405 7405
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7411,7 +7411,7 @@  discard block
 block discarded – undo
7411 7411
 		$airport_array = array();
7412 7412
 		$temp_array = array();
7413 7413
         
7414
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7414
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7415 7415
 		{
7416 7416
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7417 7417
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7431,11 +7431,11 @@  discard block
 block discarded – undo
7431 7431
 	* @return Array the airport list
7432 7432
 	*
7433 7433
 	*/
7434
-	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7434
+	public function countAllDepartureAirportsByPilot($pilot, $filters = array())
7435 7435
 	{
7436
-		$filter_query = $this->getFilter($filters,true,true);
7437
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7438
-		$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 
7436
+		$filter_query = $this->getFilter($filters, true, true);
7437
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7438
+		$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 
7439 7439
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7440 7440
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7441 7441
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7446,7 +7446,7 @@  discard block
 block discarded – undo
7446 7446
 		$airport_array = array();
7447 7447
 		$temp_array = array();
7448 7448
         
7449
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7449
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7450 7450
 		{
7451 7451
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7452 7452
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7468,11 +7468,11 @@  discard block
 block discarded – undo
7468 7468
 	* @return Array the airport list
7469 7469
 	*
7470 7470
 	*/
7471
-	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7471
+	public function countAllDepartureAirportCountriesByIdent($ident, $filters = array())
7472 7472
 	{
7473
-		$filter_query = $this->getFilter($filters,true,true);
7474
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7475
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7473
+		$filter_query = $this->getFilter($filters, true, true);
7474
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7475
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7476 7476
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
7477 7477
                     GROUP BY spotter_output.departure_airport_country
7478 7478
 					ORDER BY airport_departure_country_count DESC";
@@ -7484,7 +7484,7 @@  discard block
 block discarded – undo
7484 7484
 		$airport_array = array();
7485 7485
 		$temp_array = array();
7486 7486
         
7487
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7487
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7488 7488
 		{
7489 7489
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7490 7490
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7501,11 +7501,11 @@  discard block
 block discarded – undo
7501 7501
 	* @return Array the airport list
7502 7502
 	*
7503 7503
 	*/
7504
-	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7504
+	public function countAllDepartureAirportCountriesByOwner($owner, $filters = array())
7505 7505
 	{
7506
-		$filter_query = $this->getFilter($filters,true,true);
7507
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7508
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7506
+		$filter_query = $this->getFilter($filters, true, true);
7507
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7508
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7509 7509
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner 
7510 7510
 			GROUP BY spotter_output.departure_airport_country
7511 7511
 			ORDER BY airport_departure_country_count DESC";
@@ -7521,11 +7521,11 @@  discard block
 block discarded – undo
7521 7521
 	* @return Array the airport list
7522 7522
 	*
7523 7523
 	*/
7524
-	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7524
+	public function countAllDepartureAirportCountriesByPilot($pilot, $filters = array())
7525 7525
 	{
7526
-		$filter_query = $this->getFilter($filters,true,true);
7527
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7528
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7526
+		$filter_query = $this->getFilter($filters, true, true);
7527
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7528
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7529 7529
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7530 7530
 			GROUP BY spotter_output.departure_airport_country
7531 7531
 			ORDER BY airport_departure_country_count DESC";
@@ -7543,12 +7543,12 @@  discard block
 block discarded – undo
7543 7543
 	* @return Array the airport list
7544 7544
 	*
7545 7545
 	*/
7546
-	public function countAllDepartureAirportsByCountry($country,$filters = array())
7546
+	public function countAllDepartureAirportsByCountry($country, $filters = array())
7547 7547
 	{
7548
-		$filter_query = $this->getFilter($filters,true,true);
7549
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7548
+		$filter_query = $this->getFilter($filters, true, true);
7549
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7550 7550
 
7551
-		$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 
7551
+		$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 
7552 7552
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
7553 7553
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7554 7554
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7560,7 +7560,7 @@  discard block
 block discarded – undo
7560 7560
 		$airport_array = array();
7561 7561
 		$temp_array = array();
7562 7562
         
7563
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7563
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7564 7564
 		{
7565 7565
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7566 7566
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7581,11 +7581,11 @@  discard block
 block discarded – undo
7581 7581
 	* @return Array the airport list
7582 7582
 	*
7583 7583
 	*/
7584
-	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7584
+	public function countAllDepartureAirportCountriesByCountry($country, $filters = array())
7585 7585
 	{
7586
-		$filter_query = $this->getFilter($filters,true,true);
7587
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7588
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7586
+		$filter_query = $this->getFilter($filters, true, true);
7587
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7588
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7589 7589
 			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 
7590 7590
                     GROUP BY spotter_output.departure_airport_country
7591 7591
 					ORDER BY airport_departure_country_count DESC";
@@ -7597,7 +7597,7 @@  discard block
 block discarded – undo
7597 7597
 		$airport_array = array();
7598 7598
 		$temp_array = array();
7599 7599
         
7600
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7600
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7601 7601
 		{
7602 7602
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7603 7603
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7620,11 +7620,11 @@  discard block
 block discarded – undo
7620 7620
 	* @return Array the airport list
7621 7621
 	*
7622 7622
 	*/
7623
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7623
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7624 7624
 	{
7625 7625
 		global $globalDBdriver;
7626
-		$filter_query = $this->getFilter($filters,true,true);
7627
-		$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 
7626
+		$filter_query = $this->getFilter($filters, true, true);
7627
+		$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 
7628 7628
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7629 7629
                 if ($olderthanmonths > 0) {
7630 7630
             		if ($globalDBdriver == 'mysql') {
@@ -7644,28 +7644,28 @@  discard block
 block discarded – undo
7644 7644
 		if ($year != '') {
7645 7645
 			if ($globalDBdriver == 'mysql') {
7646 7646
 				$query .= " AND YEAR(spotter_output.date) = :year";
7647
-				$query_values = array_merge($query_values,array(':year' => $year));
7647
+				$query_values = array_merge($query_values, array(':year' => $year));
7648 7648
 			} else {
7649 7649
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7650
-				$query_values = array_merge($query_values,array(':year' => $year));
7650
+				$query_values = array_merge($query_values, array(':year' => $year));
7651 7651
 			}
7652 7652
 		}
7653 7653
 		if ($month != '') {
7654 7654
 			if ($globalDBdriver == 'mysql') {
7655 7655
 				$query .= " AND MONTH(spotter_output.date) = :month";
7656
-				$query_values = array_merge($query_values,array(':month' => $month));
7656
+				$query_values = array_merge($query_values, array(':month' => $month));
7657 7657
 			} else {
7658 7658
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7659
-				$query_values = array_merge($query_values,array(':month' => $month));
7659
+				$query_values = array_merge($query_values, array(':month' => $month));
7660 7660
 			}
7661 7661
 		}
7662 7662
 		if ($day != '') {
7663 7663
 			if ($globalDBdriver == 'mysql') {
7664 7664
 				$query .= " AND DAY(spotter_output.date) = :day";
7665
-				$query_values = array_merge($query_values,array(':day' => $day));
7665
+				$query_values = array_merge($query_values, array(':day' => $day));
7666 7666
 			} else {
7667 7667
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7668
-				$query_values = array_merge($query_values,array(':day' => $day));
7668
+				$query_values = array_merge($query_values, array(':day' => $day));
7669 7669
 			}
7670 7670
 		}
7671 7671
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -7679,7 +7679,7 @@  discard block
 block discarded – undo
7679 7679
 		$airport_array = array();
7680 7680
 		$temp_array = array();
7681 7681
         
7682
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7682
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7683 7683
 		{
7684 7684
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7685 7685
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7702,11 +7702,11 @@  discard block
 block discarded – undo
7702 7702
 	* @return Array the airport list
7703 7703
 	*
7704 7704
 	*/
7705
-	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7705
+	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7706 7706
 	{
7707 7707
 		global $globalDBdriver;
7708
-		$filter_query = $this->getFilter($filters,true,true);
7709
-		$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 
7708
+		$filter_query = $this->getFilter($filters, true, true);
7709
+		$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 
7710 7710
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7711 7711
                 if ($olderthanmonths > 0) {
7712 7712
             		if ($globalDBdriver == 'mysql') {
@@ -7736,7 +7736,7 @@  discard block
 block discarded – undo
7736 7736
 		$airport_array = array();
7737 7737
 		$temp_array = array();
7738 7738
         
7739
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7739
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7740 7740
 		{
7741 7741
 			$temp_array['airline_icao'] = $row['airline_icao'];
7742 7742
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -7761,11 +7761,11 @@  discard block
 block discarded – undo
7761 7761
 	* @return Array the airport list
7762 7762
 	*
7763 7763
 	*/
7764
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7764
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7765 7765
 	{
7766 7766
 		global $globalDBdriver;
7767
-		$filter_query = $this->getFilter($filters,true,true);
7768
-		$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 
7767
+		$filter_query = $this->getFilter($filters, true, true);
7768
+		$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 
7769 7769
 			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";
7770 7770
                 if ($olderthanmonths > 0) {
7771 7771
             		if ($globalDBdriver == 'mysql') {
@@ -7785,28 +7785,28 @@  discard block
 block discarded – undo
7785 7785
 		if ($year != '') {
7786 7786
 			if ($globalDBdriver == 'mysql') {
7787 7787
 				$query .= " AND YEAR(spotter_output.date) = :year";
7788
-				$query_values = array_merge($query_values,array(':year' => $year));
7788
+				$query_values = array_merge($query_values, array(':year' => $year));
7789 7789
 			} else {
7790 7790
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7791
-				$query_values = array_merge($query_values,array(':year' => $year));
7791
+				$query_values = array_merge($query_values, array(':year' => $year));
7792 7792
 			}
7793 7793
 		}
7794 7794
 		if ($month != '') {
7795 7795
 			if ($globalDBdriver == 'mysql') {
7796 7796
 				$query .= " AND MONTH(spotter_output.date) = :month";
7797
-				$query_values = array_merge($query_values,array(':month' => $month));
7797
+				$query_values = array_merge($query_values, array(':month' => $month));
7798 7798
 			} else {
7799 7799
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7800
-				$query_values = array_merge($query_values,array(':month' => $month));
7800
+				$query_values = array_merge($query_values, array(':month' => $month));
7801 7801
 			}
7802 7802
 		}
7803 7803
 		if ($day != '') {
7804 7804
 			if ($globalDBdriver == 'mysql') {
7805 7805
 				$query .= " AND DAY(spotter_output.date) = :day";
7806
-				$query_values = array_merge($query_values,array(':day' => $day));
7806
+				$query_values = array_merge($query_values, array(':day' => $day));
7807 7807
 			} else {
7808 7808
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7809
-				$query_values = array_merge($query_values,array(':day' => $day));
7809
+				$query_values = array_merge($query_values, array(':day' => $day));
7810 7810
 			}
7811 7811
 		}
7812 7812
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
@@ -7819,7 +7819,7 @@  discard block
 block discarded – undo
7819 7819
       
7820 7820
 		$airport_array = array();
7821 7821
 		$temp_array = array();
7822
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7822
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7823 7823
 		{
7824 7824
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7825 7825
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7842,11 +7842,11 @@  discard block
 block discarded – undo
7842 7842
 	* @return Array the airport list
7843 7843
 	*
7844 7844
 	*/
7845
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7845
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7846 7846
 	{
7847 7847
 		global $globalDBdriver;
7848
-		$filter_query = $this->getFilter($filters,true,true);
7849
-		$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 
7848
+		$filter_query = $this->getFilter($filters, true, true);
7849
+		$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 
7850 7850
 			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 ";
7851 7851
                 if ($olderthanmonths > 0) {
7852 7852
             		if ($globalDBdriver == 'mysql') {
@@ -7876,7 +7876,7 @@  discard block
 block discarded – undo
7876 7876
 		$airport_array = array();
7877 7877
 		$temp_array = array();
7878 7878
         
7879
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7879
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7880 7880
 		{
7881 7881
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7882 7882
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7902,9 +7902,9 @@  discard block
 block discarded – undo
7902 7902
 	*/
7903 7903
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7904 7904
 	{
7905
-		$filter_query = $this->getFilter($filters,true,true);
7906
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7907
-		$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 
7905
+		$filter_query = $this->getFilter($filters, true, true);
7906
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7907
+		$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 
7908 7908
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.airline_icao = :airline_icao 
7909 7909
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7910 7910
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7915,7 +7915,7 @@  discard block
 block discarded – undo
7915 7915
 		$airport_array = array();
7916 7916
 		$temp_array = array();
7917 7917
         
7918
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7918
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7919 7919
 		{
7920 7920
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7921 7921
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7936,12 +7936,12 @@  discard block
 block discarded – undo
7936 7936
 	* @return Array the airport list
7937 7937
 	*
7938 7938
 	*/
7939
-	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7939
+	public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array())
7940 7940
 	{
7941
-		$filter_query = $this->getFilter($filters,true,true);
7942
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7941
+		$filter_query = $this->getFilter($filters, true, true);
7942
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7943 7943
 					
7944
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7944
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7945 7945
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
7946 7946
                     GROUP BY spotter_output.arrival_airport_country
7947 7947
 					ORDER BY airport_arrival_country_count DESC";
@@ -7953,7 +7953,7 @@  discard block
 block discarded – undo
7953 7953
 		$airport_array = array();
7954 7954
 		$temp_array = array();
7955 7955
         
7956
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7956
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7957 7957
 		{
7958 7958
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7959 7959
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7971,11 +7971,11 @@  discard block
 block discarded – undo
7971 7971
 	* @return Array the airport list
7972 7972
 	*
7973 7973
 	*/
7974
-	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7974
+	public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array())
7975 7975
 	{
7976
-		$filter_query = $this->getFilter($filters,true,true);
7977
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7978
-		$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 
7976
+		$filter_query = $this->getFilter($filters, true, true);
7977
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7978
+		$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 
7979 7979
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
7980 7980
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7981 7981
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7987,7 +7987,7 @@  discard block
 block discarded – undo
7987 7987
 		$airport_array = array();
7988 7988
 		$temp_array = array();
7989 7989
         
7990
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7990
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7991 7991
 		{
7992 7992
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7993 7993
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8009,11 +8009,11 @@  discard block
 block discarded – undo
8009 8009
 	* @return Array the airport list
8010 8010
 	*
8011 8011
 	*/
8012
-	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8012
+	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array())
8013 8013
 	{
8014
-		$filter_query = $this->getFilter($filters,true,true);
8015
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8016
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8014
+		$filter_query = $this->getFilter($filters, true, true);
8015
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8016
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8017 8017
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
8018 8018
                     GROUP BY spotter_output.arrival_airport_country
8019 8019
 					ORDER BY airport_arrival_country_count DESC";
@@ -8025,7 +8025,7 @@  discard block
 block discarded – undo
8025 8025
 		$airport_array = array();
8026 8026
 		$temp_array = array();
8027 8027
         
8028
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8028
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8029 8029
 		{
8030 8030
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8031 8031
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8043,12 +8043,12 @@  discard block
 block discarded – undo
8043 8043
 	* @return Array the airport list
8044 8044
 	*
8045 8045
 	*/
8046
-	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8046
+	public function countAllArrivalAirportsByRegistration($registration, $filters = array())
8047 8047
 	{
8048
-		$filter_query = $this->getFilter($filters,true,true);
8049
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8048
+		$filter_query = $this->getFilter($filters, true, true);
8049
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8050 8050
 
8051
-		$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 
8051
+		$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 
8052 8052
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.registration = :registration 
8053 8053
                     GROUP BY spotter_output.arrival_airport_icao
8054 8054
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8060,7 +8060,7 @@  discard block
 block discarded – undo
8060 8060
 		$airport_array = array();
8061 8061
 		$temp_array = array();
8062 8062
         
8063
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8063
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8064 8064
 		{
8065 8065
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8066 8066
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8081,11 +8081,11 @@  discard block
 block discarded – undo
8081 8081
 	* @return Array the airport list
8082 8082
 	*
8083 8083
 	*/
8084
-	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8084
+	public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array())
8085 8085
 	{
8086
-		$filter_query = $this->getFilter($filters,true,true);
8087
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8088
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8086
+		$filter_query = $this->getFilter($filters, true, true);
8087
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8088
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8089 8089
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
8090 8090
                     GROUP BY spotter_output.arrival_airport_country
8091 8091
 					ORDER BY airport_arrival_country_count DESC";
@@ -8097,7 +8097,7 @@  discard block
 block discarded – undo
8097 8097
 		$airport_array = array();
8098 8098
 		$temp_array = array();
8099 8099
         
8100
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8100
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8101 8101
 		{
8102 8102
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8103 8103
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8116,11 +8116,11 @@  discard block
 block discarded – undo
8116 8116
 	* @return Array the airport list
8117 8117
 	*
8118 8118
 	*/
8119
-	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8119
+	public function countAllArrivalAirportsByAirport($airport_icao, $filters = array())
8120 8120
 	{
8121
-		$filter_query = $this->getFilter($filters,true,true);
8122
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8123
-		$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 
8121
+		$filter_query = $this->getFilter($filters, true, true);
8122
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8123
+		$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 
8124 8124
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8125 8125
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8126 8126
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8132,7 +8132,7 @@  discard block
 block discarded – undo
8132 8132
 		$airport_array = array();
8133 8133
 		$temp_array = array();
8134 8134
         
8135
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8135
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8136 8136
 		{
8137 8137
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8138 8138
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8153,11 +8153,11 @@  discard block
 block discarded – undo
8153 8153
 	* @return Array the airport list
8154 8154
 	*
8155 8155
 	*/
8156
-	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8156
+	public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array())
8157 8157
 	{
8158
-		$filter_query = $this->getFilter($filters,true,true);
8159
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8160
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8158
+		$filter_query = $this->getFilter($filters, true, true);
8159
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8160
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8161 8161
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8162 8162
                     GROUP BY spotter_output.arrival_airport_country
8163 8163
 					ORDER BY airport_arrival_country_count DESC";
@@ -8169,7 +8169,7 @@  discard block
 block discarded – undo
8169 8169
 		$airport_array = array();
8170 8170
 		$temp_array = array();
8171 8171
         
8172
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8172
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8173 8173
 		{
8174 8174
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8175 8175
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8187,11 +8187,11 @@  discard block
 block discarded – undo
8187 8187
 	* @return Array the airport list
8188 8188
 	*
8189 8189
 	*/
8190
-	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8190
+	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array())
8191 8191
 	{
8192
-		$filter_query = $this->getFilter($filters,true,true);
8193
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8194
-		$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 
8192
+		$filter_query = $this->getFilter($filters, true, true);
8193
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8194
+		$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 
8195 8195
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8196 8196
                     GROUP BY spotter_output.arrival_airport_icao
8197 8197
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8203,7 +8203,7 @@  discard block
 block discarded – undo
8203 8203
 		$airport_array = array();
8204 8204
 		$temp_array = array();
8205 8205
         
8206
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8206
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8207 8207
 		{
8208 8208
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8209 8209
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8225,11 +8225,11 @@  discard block
 block discarded – undo
8225 8225
 	* @return Array the airport list
8226 8226
 	*
8227 8227
 	*/
8228
-	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8228
+	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
8229 8229
 	{
8230
-		$filter_query = $this->getFilter($filters,true,true);
8231
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8232
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8230
+		$filter_query = $this->getFilter($filters, true, true);
8231
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8232
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8233 8233
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8234 8234
                     GROUP BY spotter_output.arrival_airport_country
8235 8235
 					ORDER BY airport_arrival_country_count DESC";
@@ -8241,7 +8241,7 @@  discard block
 block discarded – undo
8241 8241
 		$airport_array = array();
8242 8242
 		$temp_array = array();
8243 8243
         
8244
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8244
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8245 8245
 		{
8246 8246
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8247 8247
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8260,11 +8260,11 @@  discard block
 block discarded – undo
8260 8260
 	* @return Array the airport list
8261 8261
 	*
8262 8262
 	*/
8263
-	public function countAllArrivalAirportsByDate($date,$filters = array())
8263
+	public function countAllArrivalAirportsByDate($date, $filters = array())
8264 8264
 	{
8265 8265
 		global $globalTimezone, $globalDBdriver;
8266
-		$filter_query = $this->getFilter($filters,true,true);
8267
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8266
+		$filter_query = $this->getFilter($filters, true, true);
8267
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8268 8268
 		if ($globalTimezone != '') {
8269 8269
 			date_default_timezone_set($globalTimezone);
8270 8270
 			$datetime = new DateTime($date);
@@ -8272,12 +8272,12 @@  discard block
 block discarded – undo
8272 8272
 		} else $offset = '+00:00';
8273 8273
 
8274 8274
 		if ($globalDBdriver == 'mysql') {
8275
-			$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 
8275
+			$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 
8276 8276
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
8277 8277
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8278 8278
 					ORDER BY airport_arrival_icao_count DESC";
8279 8279
 		} else {
8280
-			$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 
8280
+			$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 
8281 8281
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
8282 8282
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8283 8283
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8289,7 +8289,7 @@  discard block
 block discarded – undo
8289 8289
 		$airport_array = array();
8290 8290
 		$temp_array = array();
8291 8291
         
8292
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8292
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8293 8293
 		{
8294 8294
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8295 8295
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8313,8 +8313,8 @@  discard block
 block discarded – undo
8313 8313
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8314 8314
 	{
8315 8315
 		global $globalTimezone, $globalDBdriver;
8316
-		$filter_query = $this->getFilter($filters,true,true);
8317
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8316
+		$filter_query = $this->getFilter($filters, true, true);
8317
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8318 8318
 		if ($globalTimezone != '') {
8319 8319
 			date_default_timezone_set($globalTimezone);
8320 8320
 			$datetime = new DateTime($date);
@@ -8322,12 +8322,12 @@  discard block
 block discarded – undo
8322 8322
 		} else $offset = '+00:00';
8323 8323
 
8324 8324
 		if ($globalDBdriver == 'mysql') {
8325
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8325
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8326 8326
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
8327 8327
 					GROUP BY spotter_output.arrival_airport_country
8328 8328
 					ORDER BY airport_arrival_country_count DESC";
8329 8329
 		} else {
8330
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8330
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8331 8331
 					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 
8332 8332
 					GROUP BY spotter_output.arrival_airport_country
8333 8333
 					ORDER BY airport_arrival_country_count DESC";
@@ -8339,7 +8339,7 @@  discard block
 block discarded – undo
8339 8339
 		$airport_array = array();
8340 8340
 		$temp_array = array();
8341 8341
         
8342
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8342
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8343 8343
 		{
8344 8344
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8345 8345
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8357,11 +8357,11 @@  discard block
 block discarded – undo
8357 8357
 	* @return Array the airport list
8358 8358
 	*
8359 8359
 	*/
8360
-	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8360
+	public function countAllArrivalAirportsByIdent($ident, $filters = array())
8361 8361
 	{
8362
-		$filter_query = $this->getFilter($filters,true,true);
8363
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8364
-		$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 
8362
+		$filter_query = $this->getFilter($filters, true, true);
8363
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8364
+		$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 
8365 8365
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.ident = :ident  
8366 8366
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8367 8367
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8373,7 +8373,7 @@  discard block
 block discarded – undo
8373 8373
 		$airport_array = array();
8374 8374
 		$temp_array = array();
8375 8375
         
8376
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8376
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8377 8377
 		{
8378 8378
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8379 8379
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8393,11 +8393,11 @@  discard block
 block discarded – undo
8393 8393
 	* @return Array the airport list
8394 8394
 	*
8395 8395
 	*/
8396
-	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8396
+	public function countAllArrivalAirportsByOwner($owner, $filters = array())
8397 8397
 	{
8398
-		$filter_query = $this->getFilter($filters,true,true);
8399
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8400
-		$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 
8398
+		$filter_query = $this->getFilter($filters, true, true);
8399
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8400
+		$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 
8401 8401
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.owner_name = :owner 
8402 8402
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8403 8403
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8408,7 +8408,7 @@  discard block
 block discarded – undo
8408 8408
 		$airport_array = array();
8409 8409
 		$temp_array = array();
8410 8410
         
8411
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8411
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8412 8412
 		{
8413 8413
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8414 8414
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8428,11 +8428,11 @@  discard block
 block discarded – undo
8428 8428
 	* @return Array the airport list
8429 8429
 	*
8430 8430
 	*/
8431
-	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8431
+	public function countAllArrivalAirportsByPilot($pilot, $filters = array())
8432 8432
 	{
8433
-		$filter_query = $this->getFilter($filters,true,true);
8434
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8435
-		$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 
8433
+		$filter_query = $this->getFilter($filters, true, true);
8434
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8435
+		$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 
8436 8436
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8437 8437
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8438 8438
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8443,7 +8443,7 @@  discard block
 block discarded – undo
8443 8443
 		$airport_array = array();
8444 8444
 		$temp_array = array();
8445 8445
         
8446
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8446
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8447 8447
 		{
8448 8448
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8449 8449
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8465,9 +8465,9 @@  discard block
 block discarded – undo
8465 8465
 	*/
8466 8466
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8467 8467
 	{
8468
-		$filter_query = $this->getFilter($filters,true,true);
8469
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8470
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8468
+		$filter_query = $this->getFilter($filters, true, true);
8469
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8470
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8471 8471
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
8472 8472
                     GROUP BY spotter_output.arrival_airport_country
8473 8473
 					ORDER BY airport_arrival_country_count DESC";
@@ -8479,7 +8479,7 @@  discard block
 block discarded – undo
8479 8479
 		$airport_array = array();
8480 8480
 		$temp_array = array();
8481 8481
         
8482
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8482
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8483 8483
 		{
8484 8484
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8485 8485
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8498,9 +8498,9 @@  discard block
 block discarded – undo
8498 8498
 	*/
8499 8499
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8500 8500
 	{
8501
-		$filter_query = $this->getFilter($filters,true,true);
8502
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8503
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8501
+		$filter_query = $this->getFilter($filters, true, true);
8502
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8503
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8504 8504
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.owner_name = :owner 
8505 8505
                     GROUP BY spotter_output.arrival_airport_country
8506 8506
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8518,9 +8518,9 @@  discard block
 block discarded – undo
8518 8518
 	*/
8519 8519
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8520 8520
 	{
8521
-		$filter_query = $this->getFilter($filters,true,true);
8522
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8523
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8521
+		$filter_query = $this->getFilter($filters, true, true);
8522
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8523
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8524 8524
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8525 8525
                     GROUP BY spotter_output.arrival_airport_country
8526 8526
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8538,11 +8538,11 @@  discard block
 block discarded – undo
8538 8538
 	* @return Array the airport list
8539 8539
 	*
8540 8540
 	*/
8541
-	public function countAllArrivalAirportsByCountry($country,$filters = array())
8541
+	public function countAllArrivalAirportsByCountry($country, $filters = array())
8542 8542
 	{
8543
-		$filter_query = $this->getFilter($filters,true,true);
8544
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8545
-		$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 
8543
+		$filter_query = $this->getFilter($filters, true, true);
8544
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8545
+		$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 
8546 8546
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
8547 8547
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8548 8548
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8554,7 +8554,7 @@  discard block
 block discarded – undo
8554 8554
 		$airport_array = array();
8555 8555
 		$temp_array = array();
8556 8556
         
8557
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8557
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8558 8558
 		{
8559 8559
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8560 8560
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8575,12 +8575,12 @@  discard block
 block discarded – undo
8575 8575
 	* @return Array the airport list
8576 8576
 	*
8577 8577
 	*/
8578
-	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8578
+	public function countAllArrivalAirportCountriesByCountry($country, $filters = array())
8579 8579
 	{
8580 8580
 		global $globalDBdriver;
8581
-		$filter_query = $this->getFilter($filters,true,true);
8582
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8583
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8581
+		$filter_query = $this->getFilter($filters, true, true);
8582
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8583
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8584 8584
 			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 
8585 8585
                     GROUP BY spotter_output.arrival_airport_country
8586 8586
 					ORDER BY airport_arrival_country_count DESC";
@@ -8592,7 +8592,7 @@  discard block
 block discarded – undo
8592 8592
 		$airport_array = array();
8593 8593
 		$temp_array = array();
8594 8594
         
8595
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8595
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8596 8596
 		{
8597 8597
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8598 8598
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8611,38 +8611,38 @@  discard block
 block discarded – undo
8611 8611
 	* @return Array the airport departure list
8612 8612
 	*
8613 8613
 	*/
8614
-	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8614
+	public function countAllDepartureCountries($filters = array(), $year = '', $month = '', $day = '')
8615 8615
 	{
8616 8616
 		global $globalDBdriver;
8617
-		$filter_query = $this->getFilter($filters,true,true);
8618
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
8617
+		$filter_query = $this->getFilter($filters, true, true);
8618
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
8619 8619
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
8620 8620
 		$query_values = array();
8621 8621
 		if ($year != '') {
8622 8622
 			if ($globalDBdriver == 'mysql') {
8623 8623
 				$query .= " AND YEAR(spotter_output.date) = :year";
8624
-				$query_values = array_merge($query_values,array(':year' => $year));
8624
+				$query_values = array_merge($query_values, array(':year' => $year));
8625 8625
 			} else {
8626 8626
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8627
-				$query_values = array_merge($query_values,array(':year' => $year));
8627
+				$query_values = array_merge($query_values, array(':year' => $year));
8628 8628
 			}
8629 8629
 		}
8630 8630
 		if ($month != '') {
8631 8631
 			if ($globalDBdriver == 'mysql') {
8632 8632
 				$query .= " AND MONTH(spotter_output.date) = :month";
8633
-				$query_values = array_merge($query_values,array(':month' => $month));
8633
+				$query_values = array_merge($query_values, array(':month' => $month));
8634 8634
 			} else {
8635 8635
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8636
-				$query_values = array_merge($query_values,array(':month' => $month));
8636
+				$query_values = array_merge($query_values, array(':month' => $month));
8637 8637
 			}
8638 8638
 		}
8639 8639
 		if ($day != '') {
8640 8640
 			if ($globalDBdriver == 'mysql') {
8641 8641
 				$query .= " AND DAY(spotter_output.date) = :day";
8642
-				$query_values = array_merge($query_values,array(':day' => $day));
8642
+				$query_values = array_merge($query_values, array(':day' => $day));
8643 8643
 			} else {
8644 8644
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8645
-				$query_values = array_merge($query_values,array(':day' => $day));
8645
+				$query_values = array_merge($query_values, array(':day' => $day));
8646 8646
 			}
8647 8647
 		}
8648 8648
 		$query .= " GROUP BY spotter_output.departure_airport_country
@@ -8656,7 +8656,7 @@  discard block
 block discarded – undo
8656 8656
 		$airport_array = array();
8657 8657
 		$temp_array = array();
8658 8658
         
8659
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8659
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8660 8660
 		{
8661 8661
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
8662 8662
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -8674,38 +8674,38 @@  discard block
 block discarded – undo
8674 8674
 	* @return Array the airport arrival list
8675 8675
 	*
8676 8676
 	*/
8677
-	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8677
+	public function countAllArrivalCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
8678 8678
 	{
8679 8679
 		global $globalDBdriver;
8680
-		$filter_query = $this->getFilter($filters,true,true);
8681
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8680
+		$filter_query = $this->getFilter($filters, true, true);
8681
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8682 8682
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
8683 8683
 		$query_values = array();
8684 8684
 		if ($year != '') {
8685 8685
 			if ($globalDBdriver == 'mysql') {
8686 8686
 				$query .= " AND YEAR(spotter_output.date) = :year";
8687
-				$query_values = array_merge($query_values,array(':year' => $year));
8687
+				$query_values = array_merge($query_values, array(':year' => $year));
8688 8688
 			} else {
8689 8689
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8690
-				$query_values = array_merge($query_values,array(':year' => $year));
8690
+				$query_values = array_merge($query_values, array(':year' => $year));
8691 8691
 			}
8692 8692
 		}
8693 8693
 		if ($month != '') {
8694 8694
 			if ($globalDBdriver == 'mysql') {
8695 8695
 				$query .= " AND MONTH(spotter_output.date) = :month";
8696
-				$query_values = array_merge($query_values,array(':month' => $month));
8696
+				$query_values = array_merge($query_values, array(':month' => $month));
8697 8697
 			} else {
8698 8698
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8699
-				$query_values = array_merge($query_values,array(':month' => $month));
8699
+				$query_values = array_merge($query_values, array(':month' => $month));
8700 8700
 			}
8701 8701
 		}
8702 8702
 		if ($day != '') {
8703 8703
 			if ($globalDBdriver == 'mysql') {
8704 8704
 				$query .= " AND DAY(spotter_output.date) = :day";
8705
-				$query_values = array_merge($query_values,array(':day' => $day));
8705
+				$query_values = array_merge($query_values, array(':day' => $day));
8706 8706
 			} else {
8707 8707
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8708
-				$query_values = array_merge($query_values,array(':day' => $day));
8708
+				$query_values = array_merge($query_values, array(':day' => $day));
8709 8709
 			}
8710 8710
 		}
8711 8711
 		$query .= " GROUP BY spotter_output.arrival_airport_country
@@ -8719,7 +8719,7 @@  discard block
 block discarded – undo
8719 8719
 		$airport_array = array();
8720 8720
 		$temp_array = array();
8721 8721
         
8722
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8722
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8723 8723
 		{
8724 8724
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
8725 8725
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -8742,8 +8742,8 @@  discard block
 block discarded – undo
8742 8742
 	*/
8743 8743
 	public function countAllRoutes($filters = array())
8744 8744
 	{
8745
-		$filter_query = $this->getFilter($filters,true,true);
8746
-		$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
8745
+		$filter_query = $this->getFilter($filters, true, true);
8746
+		$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
8747 8747
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''
8748 8748
                     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
8749 8749
                     ORDER BY route_count DESC
@@ -8756,7 +8756,7 @@  discard block
 block discarded – undo
8756 8756
 		$routes_array = array();
8757 8757
 		$temp_array = array();
8758 8758
         
8759
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8759
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8760 8760
 		{
8761 8761
 			$temp_array['route_count'] = $row['route_count'];
8762 8762
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8783,11 +8783,11 @@  discard block
 block discarded – undo
8783 8783
 	* @return Array the route list
8784 8784
 	*
8785 8785
 	*/
8786
-	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8786
+	public function countAllRoutesByAircraft($aircraft_icao, $filters = array())
8787 8787
 	{
8788
-		$filter_query = $this->getFilter($filters,true,true);
8789
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8790
-		$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
8788
+		$filter_query = $this->getFilter($filters, true, true);
8789
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8790
+		$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
8791 8791
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
8792 8792
 			    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 
8793 8793
 			    ORDER BY route_count DESC";
@@ -8798,7 +8798,7 @@  discard block
 block discarded – undo
8798 8798
 		$routes_array = array();
8799 8799
 		$temp_array = array();
8800 8800
         
8801
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8801
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8802 8802
 		{
8803 8803
 			$temp_array['route_count'] = $row['route_count'];
8804 8804
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8825,9 +8825,9 @@  discard block
 block discarded – undo
8825 8825
 	*/
8826 8826
 	public function countAllRoutesByRegistration($registration, $filters = array())
8827 8827
 	{
8828
-		$filter_query = $this->getFilter($filters,true,true);
8828
+		$filter_query = $this->getFilter($filters, true, true);
8829 8829
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8830
-		$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
8830
+		$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
8831 8831
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration 
8832 8832
                     GROUP BY route
8833 8833
                     ORDER BY route_count DESC";
@@ -8839,7 +8839,7 @@  discard block
 block discarded – undo
8839 8839
 		$routes_array = array();
8840 8840
 		$temp_array = array();
8841 8841
         
8842
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8842
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8843 8843
 		{
8844 8844
 			$temp_array['route_count'] = $row['route_count'];
8845 8845
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8867,9 +8867,9 @@  discard block
 block discarded – undo
8867 8867
 	*/
8868 8868
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8869 8869
 	{
8870
-		$filter_query = $this->getFilter($filters,true,true);
8871
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8872
-		$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
8870
+		$filter_query = $this->getFilter($filters, true, true);
8871
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8872
+		$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
8873 8873
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
8874 8874
 			    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 
8875 8875
 			    ORDER BY route_count DESC";
@@ -8881,7 +8881,7 @@  discard block
 block discarded – undo
8881 8881
 		$routes_array = array();
8882 8882
 		$temp_array = array();
8883 8883
         
8884
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8884
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8885 8885
 		{
8886 8886
 			$temp_array['route_count'] = $row['route_count'];
8887 8887
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8909,9 +8909,9 @@  discard block
 block discarded – undo
8909 8909
 	*/
8910 8910
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8911 8911
 	{
8912
-		$filter_query = $this->getFilter($filters,true,true);
8913
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8914
-		$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
8912
+		$filter_query = $this->getFilter($filters, true, true);
8913
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8914
+		$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
8915 8915
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8916 8916
 			    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 
8917 8917
 			    ORDER BY route_count DESC";
@@ -8922,7 +8922,7 @@  discard block
 block discarded – undo
8922 8922
 		$routes_array = array();
8923 8923
 		$temp_array = array();
8924 8924
         
8925
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8925
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8926 8926
 		{
8927 8927
 			$temp_array['route_count'] = $row['route_count'];
8928 8928
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8950,9 +8950,9 @@  discard block
 block discarded – undo
8950 8950
 	*/
8951 8951
 	public function countAllRoutesByCountry($country, $filters = array())
8952 8952
 	{
8953
-		$filter_query = $this->getFilter($filters,true,true);
8954
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8955
-		$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
8953
+		$filter_query = $this->getFilter($filters, true, true);
8954
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8955
+		$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
8956 8956
 			    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 
8957 8957
 			    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 
8958 8958
 			    ORDER BY route_count DESC";
@@ -8963,7 +8963,7 @@  discard block
 block discarded – undo
8963 8963
 		$routes_array = array();
8964 8964
 		$temp_array = array();
8965 8965
         
8966
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8966
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8967 8967
 		{
8968 8968
 			$temp_array['route_count'] = $row['route_count'];
8969 8969
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8991,8 +8991,8 @@  discard block
 block discarded – undo
8991 8991
 	public function countAllRoutesByDate($date, $filters = array())
8992 8992
 	{
8993 8993
 		global $globalTimezone, $globalDBdriver;
8994
-		$filter_query = $this->getFilter($filters,true,true);
8995
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8994
+		$filter_query = $this->getFilter($filters, true, true);
8995
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8996 8996
 		if ($globalTimezone != '') {
8997 8997
 			date_default_timezone_set($globalTimezone);
8998 8998
 			$datetime = new DateTime($date);
@@ -9000,12 +9000,12 @@  discard block
 block discarded – undo
9000 9000
 		} else $offset = '+00:00';
9001 9001
 		
9002 9002
 		if ($globalDBdriver == 'mysql') {
9003
-			$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
9003
+			$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
9004 9004
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
9005 9005
 				    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
9006 9006
 				    ORDER BY route_count DESC";
9007 9007
 		} else {
9008
-			$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
9008
+			$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
9009 9009
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
9010 9010
 				    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
9011 9011
 				    ORDER BY route_count DESC";
@@ -9017,7 +9017,7 @@  discard block
 block discarded – undo
9017 9017
 		$routes_array = array();
9018 9018
 		$temp_array = array();
9019 9019
         
9020
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9020
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9021 9021
 		{
9022 9022
 			$temp_array['route_count'] = $row['route_count'];
9023 9023
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9044,9 +9044,9 @@  discard block
 block discarded – undo
9044 9044
 	*/
9045 9045
 	public function countAllRoutesByIdent($ident, $filters = array())
9046 9046
 	{
9047
-		$filter_query = $this->getFilter($filters,true,true);
9048
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
9049
-		$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
9047
+		$filter_query = $this->getFilter($filters, true, true);
9048
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
9049
+		$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
9050 9050
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident   
9051 9051
                     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
9052 9052
                     ORDER BY route_count DESC";
@@ -9058,7 +9058,7 @@  discard block
 block discarded – undo
9058 9058
 		$routes_array = array();
9059 9059
 		$temp_array = array();
9060 9060
         
9061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9062 9062
 		{
9063 9063
 			$temp_array['route_count'] = $row['route_count'];
9064 9064
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9082,11 +9082,11 @@  discard block
 block discarded – undo
9082 9082
 	* @return Array the route list
9083 9083
 	*
9084 9084
 	*/
9085
-	public function countAllRoutesByOwner($owner,$filters = array())
9085
+	public function countAllRoutesByOwner($owner, $filters = array())
9086 9086
 	{
9087
-		$filter_query = $this->getFilter($filters,true,true);
9088
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
9089
-		$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
9087
+		$filter_query = $this->getFilter($filters, true, true);
9088
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
9089
+		$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
9090 9090
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.owner_name = :owner 
9091 9091
                     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
9092 9092
                     ORDER BY route_count DESC";
@@ -9098,7 +9098,7 @@  discard block
 block discarded – undo
9098 9098
 		$routes_array = array();
9099 9099
 		$temp_array = array();
9100 9100
         
9101
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9101
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9102 9102
 		{
9103 9103
 			$temp_array['route_count'] = $row['route_count'];
9104 9104
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9122,11 +9122,11 @@  discard block
 block discarded – undo
9122 9122
 	* @return Array the route list
9123 9123
 	*
9124 9124
 	*/
9125
-	public function countAllRoutesByPilot($pilot,$filters = array())
9125
+	public function countAllRoutesByPilot($pilot, $filters = array())
9126 9126
 	{
9127
-		$filter_query = $this->getFilter($filters,true,true);
9128
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
9129
-		$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
9127
+		$filter_query = $this->getFilter($filters, true, true);
9128
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
9129
+		$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
9130 9130
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
9131 9131
                     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
9132 9132
                     ORDER BY route_count DESC";
@@ -9138,7 +9138,7 @@  discard block
 block discarded – undo
9138 9138
 		$routes_array = array();
9139 9139
 		$temp_array = array();
9140 9140
         
9141
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9141
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9142 9142
 		{
9143 9143
 			$temp_array['route_count'] = $row['route_count'];
9144 9144
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9165,9 +9165,9 @@  discard block
 block discarded – undo
9165 9165
 	*/
9166 9166
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9167 9167
 	{
9168
-		$filter_query = $this->getFilter($filters,true,true);
9169
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
9170
-		$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
9168
+		$filter_query = $this->getFilter($filters, true, true);
9169
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
9170
+		$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
9171 9171
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
9172 9172
                     GROUP BY route
9173 9173
                     ORDER BY route_count DESC";
@@ -9179,7 +9179,7 @@  discard block
 block discarded – undo
9179 9179
 		$routes_array = array();
9180 9180
 		$temp_array = array();
9181 9181
         
9182
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9182
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9183 9183
 		{
9184 9184
 			$temp_array['route_count'] = $row['route_count'];
9185 9185
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9207,8 +9207,8 @@  discard block
 block discarded – undo
9207 9207
 	*/
9208 9208
 	public function countAllRoutesWithWaypoints($filters = array())
9209 9209
 	{
9210
-		$filter_query = $this->getFilter($filters,true,true);
9211
-		$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
9210
+		$filter_query = $this->getFilter($filters, true, true);
9211
+		$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
9212 9212
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
9213 9213
                     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
9214 9214
                     ORDER BY route_count DESC
@@ -9221,7 +9221,7 @@  discard block
 block discarded – undo
9221 9221
 		$routes_array = array();
9222 9222
 		$temp_array = array();
9223 9223
         
9224
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9224
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9225 9225
 		{
9226 9226
 			$temp_array['spotter_id'] = $row['spotter_id'];
9227 9227
 			$temp_array['route_count'] = $row['route_count'];
@@ -9246,11 +9246,11 @@  discard block
 block discarded – undo
9246 9246
 	* @return Array the callsign list
9247 9247
 	*
9248 9248
 	*/
9249
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9249
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
9250 9250
 	{
9251 9251
 		global $globalDBdriver;
9252
-		$filter_query = $this->getFilter($filters,true,true);
9253
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9252
+		$filter_query = $this->getFilter($filters, true, true);
9253
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9254 9254
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9255 9255
 		 if ($olderthanmonths > 0) {
9256 9256
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -9264,28 +9264,28 @@  discard block
 block discarded – undo
9264 9264
 		if ($year != '') {
9265 9265
 			if ($globalDBdriver == 'mysql') {
9266 9266
 				$query .= " AND YEAR(spotter_output.date) = :year";
9267
-				$query_values = array_merge($query_values,array(':year' => $year));
9267
+				$query_values = array_merge($query_values, array(':year' => $year));
9268 9268
 			} else {
9269 9269
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
9270
-				$query_values = array_merge($query_values,array(':year' => $year));
9270
+				$query_values = array_merge($query_values, array(':year' => $year));
9271 9271
 			}
9272 9272
 		}
9273 9273
 		if ($month != '') {
9274 9274
 			if ($globalDBdriver == 'mysql') {
9275 9275
 				$query .= " AND MONTH(spotter_output.date) = :month";
9276
-				$query_values = array_merge($query_values,array(':month' => $month));
9276
+				$query_values = array_merge($query_values, array(':month' => $month));
9277 9277
 			} else {
9278 9278
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
9279
-				$query_values = array_merge($query_values,array(':month' => $month));
9279
+				$query_values = array_merge($query_values, array(':month' => $month));
9280 9280
 			}
9281 9281
 		}
9282 9282
 		if ($day != '') {
9283 9283
 			if ($globalDBdriver == 'mysql') {
9284 9284
 				$query .= " AND DAY(spotter_output.date) = :day";
9285
-				$query_values = array_merge($query_values,array(':day' => $day));
9285
+				$query_values = array_merge($query_values, array(':day' => $day));
9286 9286
 			} else {
9287 9287
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
9288
-				$query_values = array_merge($query_values,array(':day' => $day));
9288
+				$query_values = array_merge($query_values, array(':day' => $day));
9289 9289
 			}
9290 9290
 		}
9291 9291
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
@@ -9297,7 +9297,7 @@  discard block
 block discarded – undo
9297 9297
 		$callsign_array = array();
9298 9298
 		$temp_array = array();
9299 9299
         
9300
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9300
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9301 9301
 		{
9302 9302
 			$temp_array['callsign_icao'] = $row['ident'];
9303 9303
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9319,8 +9319,8 @@  discard block
 block discarded – undo
9319 9319
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9320 9320
 	{
9321 9321
 		global $globalDBdriver;
9322
-		$filter_query = $this->getFilter($filters,true,true);
9323
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9322
+		$filter_query = $this->getFilter($filters, true, true);
9323
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9324 9324
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9325 9325
 		 if ($olderthanmonths > 0) {
9326 9326
 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
@@ -9339,7 +9339,7 @@  discard block
 block discarded – undo
9339 9339
 		$callsign_array = array();
9340 9340
 		$temp_array = array();
9341 9341
         
9342
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9342
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9343 9343
 		{
9344 9344
 			$temp_array['callsign_icao'] = $row['ident'];
9345 9345
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9393,7 +9393,7 @@  discard block
 block discarded – undo
9393 9393
 		$date_array = array();
9394 9394
 		$temp_array = array();
9395 9395
         
9396
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9396
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9397 9397
 		{
9398 9398
 			$temp_array['date_name'] = $row['date_name'];
9399 9399
 			$temp_array['date_count'] = $row['date_count'];
@@ -9418,15 +9418,15 @@  discard block
 block discarded – undo
9418 9418
 			$datetime = new DateTime();
9419 9419
 			$offset = $datetime->format('P');
9420 9420
 		} else $offset = '+00:00';
9421
-		$filter_query = $this->getFilter($filters,true,true);
9421
+		$filter_query = $this->getFilter($filters, true, true);
9422 9422
 		if ($globalDBdriver == 'mysql') {
9423
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9423
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9424 9424
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9425 9425
 								GROUP BY spotter_output.airline_icao, date_name 
9426 9426
 								ORDER BY date_count DESC
9427 9427
 								LIMIT 10 OFFSET 0";
9428 9428
 		} else {
9429
-			$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
9429
+			$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
9430 9430
 								FROM spotter_output 
9431 9431
 								WHERE spotter_output.airline_icao <> '' 
9432 9432
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -9441,7 +9441,7 @@  discard block
 block discarded – undo
9441 9441
 		$date_array = array();
9442 9442
 		$temp_array = array();
9443 9443
         
9444
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9444
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9445 9445
 		{
9446 9446
 			$temp_array['date_name'] = $row['date_name'];
9447 9447
 			$temp_array['date_count'] = $row['date_count'];
@@ -9467,7 +9467,7 @@  discard block
 block discarded – undo
9467 9467
 			$datetime = new DateTime();
9468 9468
 			$offset = $datetime->format('P');
9469 9469
 		} else $offset = '+00:00';
9470
-		$filter_query = $this->getFilter($filters,true,true);
9470
+		$filter_query = $this->getFilter($filters, true, true);
9471 9471
 		if ($globalDBdriver == 'mysql') {
9472 9472
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9473 9473
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -9488,7 +9488,7 @@  discard block
 block discarded – undo
9488 9488
 		$date_array = array();
9489 9489
 		$temp_array = array();
9490 9490
         
9491
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9491
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9492 9492
 		{
9493 9493
 			$temp_array['date_name'] = $row['date_name'];
9494 9494
 			$temp_array['date_count'] = $row['date_count'];
@@ -9513,7 +9513,7 @@  discard block
 block discarded – undo
9513 9513
 			$datetime = new DateTime();
9514 9514
 			$offset = $datetime->format('P');
9515 9515
 		} else $offset = '+00:00';
9516
-		$filter_query = $this->getFilter($filters,true,true);
9516
+		$filter_query = $this->getFilter($filters, true, true);
9517 9517
 		if ($globalDBdriver == 'mysql') {
9518 9518
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9519 9519
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -9534,7 +9534,7 @@  discard block
 block discarded – undo
9534 9534
 		$date_array = array();
9535 9535
 		$temp_array = array();
9536 9536
         
9537
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9537
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9538 9538
 		{
9539 9539
 			$temp_array['date_name'] = $row['date_name'];
9540 9540
 			$temp_array['date_count'] = $row['date_count'];
@@ -9555,7 +9555,7 @@  discard block
 block discarded – undo
9555 9555
 	public function countAllDatesLastMonthByAirlines($filters = array())
9556 9556
 	{
9557 9557
 		global $globalTimezone, $globalDBdriver;
9558
-		$filter_query = $this->getFilter($filters,true,true);
9558
+		$filter_query = $this->getFilter($filters, true, true);
9559 9559
 		if ($globalTimezone != '') {
9560 9560
 			date_default_timezone_set($globalTimezone);
9561 9561
 			$datetime = new DateTime();
@@ -9563,13 +9563,13 @@  discard block
 block discarded – undo
9563 9563
 		} else $offset = '+00:00';
9564 9564
 		
9565 9565
 		if ($globalDBdriver == 'mysql') {
9566
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9566
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9567 9567
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
9568 9568
 								GROUP BY spotter_output.airline_icao, date_name 
9569 9569
 								ORDER BY spotter_output.date ASC";
9570 9570
 			$query_data = array(':offset' => $offset);
9571 9571
 		} else {
9572
-			$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
9572
+			$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
9573 9573
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
9574 9574
 								GROUP BY spotter_output.airline_icao, date_name 
9575 9575
 								ORDER BY date_name ASC";
@@ -9582,7 +9582,7 @@  discard block
 block discarded – undo
9582 9582
 		$date_array = array();
9583 9583
 		$temp_array = array();
9584 9584
         
9585
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9585
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9586 9586
 		{
9587 9587
 			$temp_array['date_name'] = $row['date_name'];
9588 9588
 			$temp_array['date_count'] = $row['date_count'];
@@ -9629,7 +9629,7 @@  discard block
 block discarded – undo
9629 9629
 		$date_array = array();
9630 9630
 		$temp_array = array();
9631 9631
         
9632
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9632
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9633 9633
 		{
9634 9634
 			$temp_array['month_name'] = $row['month_name'];
9635 9635
 			$temp_array['year_name'] = $row['year_name'];
@@ -9650,7 +9650,7 @@  discard block
 block discarded – undo
9650 9650
 	public function countAllMonthsByAirlines($filters = array())
9651 9651
 	{
9652 9652
 		global $globalTimezone, $globalDBdriver;
9653
-		$filter_query = $this->getFilter($filters,true,true);
9653
+		$filter_query = $this->getFilter($filters, true, true);
9654 9654
 		if ($globalTimezone != '') {
9655 9655
 			date_default_timezone_set($globalTimezone);
9656 9656
 			$datetime = new DateTime();
@@ -9658,12 +9658,12 @@  discard block
 block discarded – undo
9658 9658
 		} else $offset = '+00:00';
9659 9659
 
9660 9660
 		if ($globalDBdriver == 'mysql') {
9661
-			$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
9661
+			$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
9662 9662
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9663 9663
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
9664 9664
 								ORDER BY date_count DESC";
9665 9665
 		} else {
9666
-			$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
9666
+			$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
9667 9667
 								FROM spotter_output 
9668 9668
 								WHERE spotter_output.airline_icao <> '' 
9669 9669
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -9677,7 +9677,7 @@  discard block
 block discarded – undo
9677 9677
 		$date_array = array();
9678 9678
 		$temp_array = array();
9679 9679
         
9680
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9680
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9681 9681
 		{
9682 9682
 			$temp_array['month_name'] = $row['month_name'];
9683 9683
 			$temp_array['year_name'] = $row['year_name'];
@@ -9704,14 +9704,14 @@  discard block
 block discarded – undo
9704 9704
 			$datetime = new DateTime();
9705 9705
 			$offset = $datetime->format('P');
9706 9706
 		} else $offset = '+00:00';
9707
-		$filter_query = $this->getFilter($filters,true,true);
9707
+		$filter_query = $this->getFilter($filters, true, true);
9708 9708
 		if ($globalDBdriver == 'mysql') {
9709
-			$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
9709
+			$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
9710 9710
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9711 9711
 								GROUP BY year_name, month_name 
9712 9712
 								ORDER BY date_count DESC";
9713 9713
 		} else {
9714
-			$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
9714
+			$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
9715 9715
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9716 9716
 								GROUP BY year_name, month_name 
9717 9717
 								ORDER BY date_count DESC";
@@ -9723,7 +9723,7 @@  discard block
 block discarded – undo
9723 9723
 		$date_array = array();
9724 9724
 		$temp_array = array();
9725 9725
         
9726
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9726
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9727 9727
 		{
9728 9728
 			$temp_array['month_name'] = $row['month_name'];
9729 9729
 			$temp_array['year_name'] = $row['year_name'];
@@ -9749,15 +9749,15 @@  discard block
 block discarded – undo
9749 9749
 			$datetime = new DateTime();
9750 9750
 			$offset = $datetime->format('P');
9751 9751
 		} else $offset = '+00:00';
9752
-		$filter_query = $this->getFilter($filters,true,true);
9752
+		$filter_query = $this->getFilter($filters, true, true);
9753 9753
 
9754 9754
 		if ($globalDBdriver == 'mysql') {
9755
-			$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
9755
+			$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
9756 9756
 								FROM spotter_output".$filter_query." owner_name <> ''
9757 9757
 								GROUP BY year_name, month_name
9758 9758
 								ORDER BY date_count DESC";
9759 9759
 		} else {
9760
-			$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
9760
+			$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
9761 9761
 								FROM spotter_output".$filter_query." owner_name <> ''
9762 9762
 								GROUP BY year_name, month_name
9763 9763
 								ORDER BY date_count DESC";
@@ -9769,7 +9769,7 @@  discard block
 block discarded – undo
9769 9769
 		$date_array = array();
9770 9770
 		$temp_array = array();
9771 9771
         
9772
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9772
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9773 9773
 		{
9774 9774
 			$temp_array['month_name'] = $row['month_name'];
9775 9775
 			$temp_array['year_name'] = $row['year_name'];
@@ -9790,7 +9790,7 @@  discard block
 block discarded – undo
9790 9790
 	public function countAllMonthsOwnersByAirlines($filters = array())
9791 9791
 	{
9792 9792
 		global $globalTimezone, $globalDBdriver;
9793
-		$filter_query = $this->getFilter($filters,true,true);
9793
+		$filter_query = $this->getFilter($filters, true, true);
9794 9794
 		if ($globalTimezone != '') {
9795 9795
 			date_default_timezone_set($globalTimezone);
9796 9796
 			$datetime = new DateTime();
@@ -9798,12 +9798,12 @@  discard block
 block discarded – undo
9798 9798
 		} else $offset = '+00:00';
9799 9799
 
9800 9800
 		if ($globalDBdriver == 'mysql') {
9801
-			$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
9801
+			$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
9802 9802
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9803 9803
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9804 9804
 								ORDER BY date_count DESC";
9805 9805
 		} else {
9806
-			$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
9806
+			$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
9807 9807
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9808 9808
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9809 9809
 								ORDER BY date_count DESC";
@@ -9815,7 +9815,7 @@  discard block
 block discarded – undo
9815 9815
 		$date_array = array();
9816 9816
 		$temp_array = array();
9817 9817
         
9818
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9818
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9819 9819
 		{
9820 9820
 			$temp_array['month_name'] = $row['month_name'];
9821 9821
 			$temp_array['year_name'] = $row['year_name'];
@@ -9842,15 +9842,15 @@  discard block
 block discarded – undo
9842 9842
 			$datetime = new DateTime();
9843 9843
 			$offset = $datetime->format('P');
9844 9844
 		} else $offset = '+00:00';
9845
-		$filter_query = $this->getFilter($filters,true,true);
9845
+		$filter_query = $this->getFilter($filters, true, true);
9846 9846
 
9847 9847
 		if ($globalDBdriver == 'mysql') {
9848
-			$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
9848
+			$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
9849 9849
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9850 9850
 								GROUP BY year_name, month_name
9851 9851
 								ORDER BY date_count DESC";
9852 9852
 		} else {
9853
-			$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
9853
+			$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
9854 9854
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9855 9855
 								GROUP BY year_name, month_name
9856 9856
 								ORDER BY date_count DESC";
@@ -9862,7 +9862,7 @@  discard block
 block discarded – undo
9862 9862
 		$date_array = array();
9863 9863
 		$temp_array = array();
9864 9864
         
9865
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9865
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9866 9866
 		{
9867 9867
 			$temp_array['month_name'] = $row['month_name'];
9868 9868
 			$temp_array['year_name'] = $row['year_name'];
@@ -9883,7 +9883,7 @@  discard block
 block discarded – undo
9883 9883
 	public function countAllMonthsPilotsByAirlines($filters = array())
9884 9884
 	{
9885 9885
 		global $globalTimezone, $globalDBdriver;
9886
-		$filter_query = $this->getFilter($filters,true,true);
9886
+		$filter_query = $this->getFilter($filters, true, true);
9887 9887
 		if ($globalTimezone != '') {
9888 9888
 			date_default_timezone_set($globalTimezone);
9889 9889
 			$datetime = new DateTime();
@@ -9891,12 +9891,12 @@  discard block
 block discarded – undo
9891 9891
 		} else $offset = '+00:00';
9892 9892
 
9893 9893
 		if ($globalDBdriver == 'mysql') {
9894
-			$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
9894
+			$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
9895 9895
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9896 9896
 								GROUP BY spotter_output.airline_icao,year_name, month_name
9897 9897
 								ORDER BY date_count DESC";
9898 9898
 		} else {
9899
-			$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
9899
+			$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
9900 9900
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9901 9901
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9902 9902
 								ORDER BY date_count DESC";
@@ -9908,7 +9908,7 @@  discard block
 block discarded – undo
9908 9908
 		$date_array = array();
9909 9909
 		$temp_array = array();
9910 9910
         
9911
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9911
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9912 9912
 		{
9913 9913
 			$temp_array['month_name'] = $row['month_name'];
9914 9914
 			$temp_array['year_name'] = $row['year_name'];
@@ -9930,7 +9930,7 @@  discard block
 block discarded – undo
9930 9930
 	public function countAllMonthsAirlines($filters = array())
9931 9931
 	{
9932 9932
 		global $globalTimezone, $globalDBdriver;
9933
-		$filter_query = $this->getFilter($filters,true,true);
9933
+		$filter_query = $this->getFilter($filters, true, true);
9934 9934
 		if ($globalTimezone != '') {
9935 9935
 			date_default_timezone_set($globalTimezone);
9936 9936
 			$datetime = new DateTime();
@@ -9938,12 +9938,12 @@  discard block
 block discarded – undo
9938 9938
 		} else $offset = '+00:00';
9939 9939
 
9940 9940
 		if ($globalDBdriver == 'mysql') {
9941
-			$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
9941
+			$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
9942 9942
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9943 9943
 								GROUP BY year_name, month_name
9944 9944
 								ORDER BY date_count DESC";
9945 9945
 		} else {
9946
-			$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
9946
+			$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
9947 9947
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9948 9948
 								GROUP BY year_name, month_name
9949 9949
 								ORDER BY date_count DESC";
@@ -9955,7 +9955,7 @@  discard block
 block discarded – undo
9955 9955
 		$date_array = array();
9956 9956
 		$temp_array = array();
9957 9957
         
9958
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9958
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9959 9959
 		{
9960 9960
 			$temp_array['month_name'] = $row['month_name'];
9961 9961
 			$temp_array['year_name'] = $row['year_name'];
@@ -9981,15 +9981,15 @@  discard block
 block discarded – undo
9981 9981
 			$datetime = new DateTime();
9982 9982
 			$offset = $datetime->format('P');
9983 9983
 		} else $offset = '+00:00';
9984
-		$filter_query = $this->getFilter($filters,true,true);
9984
+		$filter_query = $this->getFilter($filters, true, true);
9985 9985
 
9986 9986
 		if ($globalDBdriver == 'mysql') {
9987
-			$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
9987
+			$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
9988 9988
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9989 9989
 								GROUP BY year_name, month_name
9990 9990
 								ORDER BY date_count DESC";
9991 9991
 		} else {
9992
-			$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
9992
+			$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
9993 9993
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9994 9994
 								GROUP BY year_name, month_name
9995 9995
 								ORDER BY date_count DESC";
@@ -10001,7 +10001,7 @@  discard block
 block discarded – undo
10001 10001
 		$date_array = array();
10002 10002
 		$temp_array = array();
10003 10003
         
10004
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10004
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10005 10005
 		{
10006 10006
 			$temp_array['month_name'] = $row['month_name'];
10007 10007
 			$temp_array['year_name'] = $row['year_name'];
@@ -10023,7 +10023,7 @@  discard block
 block discarded – undo
10023 10023
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10024 10024
 	{
10025 10025
 		global $globalTimezone, $globalDBdriver;
10026
-		$filter_query = $this->getFilter($filters,true,true);
10026
+		$filter_query = $this->getFilter($filters, true, true);
10027 10027
 		if ($globalTimezone != '') {
10028 10028
 			date_default_timezone_set($globalTimezone);
10029 10029
 			$datetime = new DateTime();
@@ -10031,12 +10031,12 @@  discard block
 block discarded – undo
10031 10031
 		} else $offset = '+00:00';
10032 10032
 
10033 10033
 		if ($globalDBdriver == 'mysql') {
10034
-			$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
10034
+			$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
10035 10035
 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
10036 10036
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10037 10037
 								ORDER BY date_count DESC";
10038 10038
 		} else {
10039
-			$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
10039
+			$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
10040 10040
 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
10041 10041
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10042 10042
 								ORDER BY date_count DESC";
@@ -10048,7 +10048,7 @@  discard block
 block discarded – undo
10048 10048
 		$date_array = array();
10049 10049
 		$temp_array = array();
10050 10050
         
10051
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10051
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10052 10052
 		{
10053 10053
 			$temp_array['month_name'] = $row['month_name'];
10054 10054
 			$temp_array['year_name'] = $row['year_name'];
@@ -10075,15 +10075,15 @@  discard block
 block discarded – undo
10075 10075
 			$datetime = new DateTime();
10076 10076
 			$offset = $datetime->format('P');
10077 10077
 		} else $offset = '+00:00';
10078
-		$filter_query = $this->getFilter($filters,true,true);
10078
+		$filter_query = $this->getFilter($filters, true, true);
10079 10079
 
10080 10080
 		if ($globalDBdriver == 'mysql') {
10081
-			$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
10081
+			$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
10082 10082
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10083 10083
 								GROUP BY year_name, month_name
10084 10084
 								ORDER BY date_count DESC";
10085 10085
 		} else {
10086
-			$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
10086
+			$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
10087 10087
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10088 10088
 								GROUP BY year_name, month_name
10089 10089
 								ORDER BY date_count DESC";
@@ -10095,7 +10095,7 @@  discard block
 block discarded – undo
10095 10095
 		$date_array = array();
10096 10096
 		$temp_array = array();
10097 10097
         
10098
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10098
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10099 10099
 		{
10100 10100
 			$temp_array['month_name'] = $row['month_name'];
10101 10101
 			$temp_array['year_name'] = $row['year_name'];
@@ -10117,7 +10117,7 @@  discard block
 block discarded – undo
10117 10117
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10118 10118
 	{
10119 10119
 		global $globalTimezone, $globalDBdriver;
10120
-		$filter_query = $this->getFilter($filters,true,true);
10120
+		$filter_query = $this->getFilter($filters, true, true);
10121 10121
 		if ($globalTimezone != '') {
10122 10122
 			date_default_timezone_set($globalTimezone);
10123 10123
 			$datetime = new DateTime();
@@ -10125,12 +10125,12 @@  discard block
 block discarded – undo
10125 10125
 		} else $offset = '+00:00';
10126 10126
 
10127 10127
 		if ($globalDBdriver == 'mysql') {
10128
-			$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
10128
+			$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
10129 10129
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10130 10130
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10131 10131
 								ORDER BY date_count DESC";
10132 10132
 		} else {
10133
-			$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
10133
+			$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
10134 10134
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10135 10135
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10136 10136
 								ORDER BY date_count DESC";
@@ -10142,7 +10142,7 @@  discard block
 block discarded – undo
10142 10142
 		$date_array = array();
10143 10143
 		$temp_array = array();
10144 10144
         
10145
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10145
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10146 10146
 		{
10147 10147
 			$temp_array['month_name'] = $row['month_name'];
10148 10148
 			$temp_array['year_name'] = $row['year_name'];
@@ -10170,7 +10170,7 @@  discard block
 block discarded – undo
10170 10170
 			$datetime = new DateTime();
10171 10171
 			$offset = $datetime->format('P');
10172 10172
 		} else $offset = '+00:00';
10173
-		$filter_query = $this->getFilter($filters,true,true);
10173
+		$filter_query = $this->getFilter($filters, true, true);
10174 10174
 		if ($globalDBdriver == 'mysql') {
10175 10175
 			$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
10176 10176
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -10191,7 +10191,7 @@  discard block
 block discarded – undo
10191 10191
 		$date_array = array();
10192 10192
 		$temp_array = array();
10193 10193
         
10194
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10194
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10195 10195
 		{
10196 10196
 			$temp_array['year_name'] = $row['year_name'];
10197 10197
 			$temp_array['month_name'] = $row['month_name'];
@@ -10211,7 +10211,7 @@  discard block
 block discarded – undo
10211 10211
 	* @return Array the hour list
10212 10212
 	*
10213 10213
 	*/
10214
-	public function countAllHours($orderby,$filters = array())
10214
+	public function countAllHours($orderby, $filters = array())
10215 10215
 	{
10216 10216
 		global $globalTimezone, $globalDBdriver;
10217 10217
 		if ($globalTimezone != '') {
@@ -10259,7 +10259,7 @@  discard block
 block discarded – undo
10259 10259
 		$hour_array = array();
10260 10260
 		$temp_array = array();
10261 10261
         
10262
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10262
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10263 10263
 		{
10264 10264
 			$temp_array['hour_name'] = $row['hour_name'];
10265 10265
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10279,7 +10279,7 @@  discard block
 block discarded – undo
10279 10279
 	public function countAllHoursByAirlines($orderby, $filters = array())
10280 10280
 	{
10281 10281
 		global $globalTimezone, $globalDBdriver;
10282
-		$filter_query = $this->getFilter($filters,true,true);
10282
+		$filter_query = $this->getFilter($filters, true, true);
10283 10283
 		if ($globalTimezone != '') {
10284 10284
 			date_default_timezone_set($globalTimezone);
10285 10285
 			$datetime = new DateTime();
@@ -10297,7 +10297,7 @@  discard block
 block discarded – undo
10297 10297
 		}
10298 10298
 		
10299 10299
 		if ($globalDBdriver == 'mysql') {
10300
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10300
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10301 10301
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10302 10302
 								GROUP BY spotter_output.airline_icao, hour_name 
10303 10303
 								".$orderby_sql;
@@ -10310,7 +10310,7 @@  discard block
 block discarded – undo
10310 10310
   */    
10311 10311
 		$query_data = array(':offset' => $offset);
10312 10312
 		} else {
10313
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10313
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10314 10314
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10315 10315
 								GROUP BY spotter_output.airline_icao, hour_name 
10316 10316
 								".$orderby_sql;
@@ -10323,7 +10323,7 @@  discard block
 block discarded – undo
10323 10323
 		$hour_array = array();
10324 10324
 		$temp_array = array();
10325 10325
         
10326
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10326
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10327 10327
 		{
10328 10328
 			$temp_array['hour_name'] = $row['hour_name'];
10329 10329
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10346,34 +10346,34 @@  discard block
 block discarded – undo
10346 10346
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10347 10347
 	{
10348 10348
 		global $globalTimezone, $globalDBdriver;
10349
-		$filter_query = $this->getFilter($filters,true,true);
10349
+		$filter_query = $this->getFilter($filters, true, true);
10350 10350
 		if ($globalTimezone != '') {
10351 10351
 			date_default_timezone_set($globalTimezone);
10352 10352
 			$datetime = new DateTime();
10353 10353
 			$offset = $datetime->format('P');
10354 10354
 		} else $offset = '+00:00';
10355 10355
 
10356
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10356
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
10357 10357
 
10358 10358
 		if ($globalDBdriver == 'mysql') {
10359
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10359
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10360 10360
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10361 10361
 								GROUP BY hour_name 
10362 10362
 								ORDER BY hour_name ASC";
10363 10363
 		} else {
10364
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10364
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10365 10365
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10366 10366
 								GROUP BY hour_name 
10367 10367
 								ORDER BY hour_name ASC";
10368 10368
 		}
10369 10369
 		
10370 10370
 		$sth = $this->db->prepare($query);
10371
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
10371
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
10372 10372
       
10373 10373
 		$hour_array = array();
10374 10374
 		$temp_array = array();
10375 10375
         
10376
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10376
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10377 10377
 		{
10378 10378
 			$temp_array['hour_name'] = $row['hour_name'];
10379 10379
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10396,8 +10396,8 @@  discard block
 block discarded – undo
10396 10396
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10397 10397
 	{
10398 10398
 		global $globalTimezone, $globalDBdriver;
10399
-		$filter_query = $this->getFilter($filters,true,true);
10400
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
10399
+		$filter_query = $this->getFilter($filters, true, true);
10400
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
10401 10401
 		if ($globalTimezone != '') {
10402 10402
 			date_default_timezone_set($globalTimezone);
10403 10403
 			$datetime = new DateTime();
@@ -10405,24 +10405,24 @@  discard block
 block discarded – undo
10405 10405
 		} else $offset = '+00:00';
10406 10406
 
10407 10407
 		if ($globalDBdriver == 'mysql') {
10408
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10408
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10409 10409
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10410 10410
 								GROUP BY hour_name 
10411 10411
 								ORDER BY hour_name ASC";
10412 10412
 		} else {
10413
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10413
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10414 10414
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10415 10415
 								GROUP BY hour_name 
10416 10416
 								ORDER BY hour_name ASC";
10417 10417
 		}
10418 10418
 		
10419 10419
 		$sth = $this->db->prepare($query);
10420
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
10420
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
10421 10421
       
10422 10422
 		$hour_array = array();
10423 10423
 		$temp_array = array();
10424 10424
         
10425
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10425
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10426 10426
 		{
10427 10427
 			$temp_array['hour_name'] = $row['hour_name'];
10428 10428
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10443,8 +10443,8 @@  discard block
 block discarded – undo
10443 10443
 	public function countAllHoursByRegistration($registration, $filters = array())
10444 10444
 	{
10445 10445
 		global $globalTimezone, $globalDBdriver;
10446
-		$filter_query = $this->getFilter($filters,true,true);
10447
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
10446
+		$filter_query = $this->getFilter($filters, true, true);
10447
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
10448 10448
 		if ($globalTimezone != '') {
10449 10449
 			date_default_timezone_set($globalTimezone);
10450 10450
 			$datetime = new DateTime();
@@ -10452,24 +10452,24 @@  discard block
 block discarded – undo
10452 10452
 		} else $offset = '+00:00';
10453 10453
 
10454 10454
 		if ($globalDBdriver == 'mysql') {
10455
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10455
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10456 10456
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10457 10457
 								GROUP BY hour_name 
10458 10458
 								ORDER BY hour_name ASC";
10459 10459
 		} else {
10460
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10460
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10461 10461
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10462 10462
 								GROUP BY hour_name 
10463 10463
 								ORDER BY hour_name ASC";
10464 10464
 		}
10465 10465
 		
10466 10466
 		$sth = $this->db->prepare($query);
10467
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
10467
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
10468 10468
       
10469 10469
 		$hour_array = array();
10470 10470
 		$temp_array = array();
10471 10471
         
10472
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10472
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10473 10473
 		{
10474 10474
 			$temp_array['hour_name'] = $row['hour_name'];
10475 10475
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10490,8 +10490,8 @@  discard block
 block discarded – undo
10490 10490
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10491 10491
 	{
10492 10492
 		global $globalTimezone, $globalDBdriver;
10493
-		$filter_query = $this->getFilter($filters,true,true);
10494
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
10493
+		$filter_query = $this->getFilter($filters, true, true);
10494
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
10495 10495
 		if ($globalTimezone != '') {
10496 10496
 			date_default_timezone_set($globalTimezone);
10497 10497
 			$datetime = new DateTime();
@@ -10499,24 +10499,24 @@  discard block
 block discarded – undo
10499 10499
 		} else $offset = '+00:00';
10500 10500
 
10501 10501
 		if ($globalDBdriver == 'mysql') {
10502
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10502
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10503 10503
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10504 10504
 								GROUP BY hour_name 
10505 10505
 								ORDER BY hour_name ASC";
10506 10506
 		} else {
10507
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10507
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10508 10508
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10509 10509
 								GROUP BY hour_name 
10510 10510
 								ORDER BY hour_name ASC";
10511 10511
 		}
10512 10512
 		
10513 10513
 		$sth = $this->db->prepare($query);
10514
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
10514
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
10515 10515
       
10516 10516
 		$hour_array = array();
10517 10517
 		$temp_array = array();
10518 10518
         
10519
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10519
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10520 10520
 		{
10521 10521
 			$temp_array['hour_name'] = $row['hour_name'];
10522 10522
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10535,11 +10535,11 @@  discard block
 block discarded – undo
10535 10535
 	* @return Array the hour list
10536 10536
 	*
10537 10537
 	*/
10538
-	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10538
+	public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array())
10539 10539
 	{
10540 10540
 		global $globalTimezone, $globalDBdriver;
10541
-		$filter_query = $this->getFilter($filters,true,true);
10542
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
10541
+		$filter_query = $this->getFilter($filters, true, true);
10542
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
10543 10543
 		if ($globalTimezone != '') {
10544 10544
 			date_default_timezone_set($globalTimezone);
10545 10545
 			$datetime = new DateTime();
@@ -10547,24 +10547,24 @@  discard block
 block discarded – undo
10547 10547
 		} else $offset = '+00:00';
10548 10548
 
10549 10549
 		if ($globalDBdriver == 'mysql') {
10550
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10550
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10551 10551
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10552 10552
 								GROUP BY hour_name 
10553 10553
 								ORDER BY hour_name ASC";
10554 10554
 		} else {
10555
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10555
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10556 10556
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10557 10557
 								GROUP BY hour_name 
10558 10558
 								ORDER BY hour_name ASC";
10559 10559
 		}
10560 10560
 		
10561 10561
 		$sth = $this->db->prepare($query);
10562
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
10562
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
10563 10563
       
10564 10564
 		$hour_array = array();
10565 10565
 		$temp_array = array();
10566 10566
         
10567
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10567
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10568 10568
 		{
10569 10569
 			$temp_array['hour_name'] = $row['hour_name'];
10570 10570
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10586,8 +10586,8 @@  discard block
 block discarded – undo
10586 10586
 	public function countAllHoursByDate($date, $filters = array())
10587 10587
 	{
10588 10588
 		global $globalTimezone, $globalDBdriver;
10589
-		$filter_query = $this->getFilter($filters,true,true);
10590
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
10589
+		$filter_query = $this->getFilter($filters, true, true);
10590
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
10591 10591
 		if ($globalTimezone != '') {
10592 10592
 			date_default_timezone_set($globalTimezone);
10593 10593
 			$datetime = new DateTime($date);
@@ -10595,12 +10595,12 @@  discard block
 block discarded – undo
10595 10595
 		} else $offset = '+00:00';
10596 10596
 
10597 10597
 		if ($globalDBdriver == 'mysql') {
10598
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10598
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10599 10599
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
10600 10600
 								GROUP BY hour_name 
10601 10601
 								ORDER BY hour_name ASC";
10602 10602
 		} else {
10603
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10603
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10604 10604
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
10605 10605
 								GROUP BY hour_name 
10606 10606
 								ORDER BY hour_name ASC";
@@ -10612,7 +10612,7 @@  discard block
 block discarded – undo
10612 10612
 		$hour_array = array();
10613 10613
 		$temp_array = array();
10614 10614
         
10615
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10615
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10616 10616
 		{
10617 10617
 			$temp_array['hour_name'] = $row['hour_name'];
10618 10618
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10634,8 +10634,8 @@  discard block
 block discarded – undo
10634 10634
 	public function countAllHoursByIdent($ident, $filters = array())
10635 10635
 	{
10636 10636
 		global $globalTimezone, $globalDBdriver;
10637
-		$filter_query = $this->getFilter($filters,true,true);
10638
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
10637
+		$filter_query = $this->getFilter($filters, true, true);
10638
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
10639 10639
 		if ($globalTimezone != '') {
10640 10640
 			date_default_timezone_set($globalTimezone);
10641 10641
 			$datetime = new DateTime();
@@ -10643,12 +10643,12 @@  discard block
 block discarded – undo
10643 10643
 		} else $offset = '+00:00';
10644 10644
 
10645 10645
 		if ($globalDBdriver == 'mysql') {
10646
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10646
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10647 10647
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10648 10648
 								GROUP BY hour_name 
10649 10649
 								ORDER BY hour_name ASC";
10650 10650
 		} else {
10651
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10651
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10652 10652
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10653 10653
 								GROUP BY hour_name 
10654 10654
 								ORDER BY hour_name ASC";
@@ -10656,12 +10656,12 @@  discard block
 block discarded – undo
10656 10656
       
10657 10657
 		
10658 10658
 		$sth = $this->db->prepare($query);
10659
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
10659
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
10660 10660
       
10661 10661
 		$hour_array = array();
10662 10662
 		$temp_array = array();
10663 10663
         
10664
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10664
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10665 10665
 		{
10666 10666
 			$temp_array['hour_name'] = $row['hour_name'];
10667 10667
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10681,8 +10681,8 @@  discard block
 block discarded – undo
10681 10681
 	public function countAllHoursByOwner($owner, $filters = array())
10682 10682
 	{
10683 10683
 		global $globalTimezone, $globalDBdriver;
10684
-		$filter_query = $this->getFilter($filters,true,true);
10685
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
10684
+		$filter_query = $this->getFilter($filters, true, true);
10685
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
10686 10686
 		if ($globalTimezone != '') {
10687 10687
 			date_default_timezone_set($globalTimezone);
10688 10688
 			$datetime = new DateTime();
@@ -10690,12 +10690,12 @@  discard block
 block discarded – undo
10690 10690
 		} else $offset = '+00:00';
10691 10691
 
10692 10692
 		if ($globalDBdriver == 'mysql') {
10693
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10693
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10694 10694
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10695 10695
 								GROUP BY hour_name 
10696 10696
 								ORDER BY hour_name ASC";
10697 10697
 		} else {
10698
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10698
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10699 10699
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10700 10700
 								GROUP BY hour_name 
10701 10701
 								ORDER BY hour_name ASC";
@@ -10703,12 +10703,12 @@  discard block
 block discarded – undo
10703 10703
       
10704 10704
 		
10705 10705
 		$sth = $this->db->prepare($query);
10706
-		$sth->execute(array(':owner' => $owner,':offset' => $offset));
10706
+		$sth->execute(array(':owner' => $owner, ':offset' => $offset));
10707 10707
       
10708 10708
 		$hour_array = array();
10709 10709
 		$temp_array = array();
10710 10710
         
10711
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10711
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10712 10712
 		{
10713 10713
 			$temp_array['hour_name'] = $row['hour_name'];
10714 10714
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10728,8 +10728,8 @@  discard block
 block discarded – undo
10728 10728
 	public function countAllHoursByPilot($pilot, $filters = array())
10729 10729
 	{
10730 10730
 		global $globalTimezone, $globalDBdriver;
10731
-		$filter_query = $this->getFilter($filters,true,true);
10732
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
10731
+		$filter_query = $this->getFilter($filters, true, true);
10732
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
10733 10733
 		if ($globalTimezone != '') {
10734 10734
 			date_default_timezone_set($globalTimezone);
10735 10735
 			$datetime = new DateTime();
@@ -10737,12 +10737,12 @@  discard block
 block discarded – undo
10737 10737
 		} else $offset = '+00:00';
10738 10738
 
10739 10739
 		if ($globalDBdriver == 'mysql') {
10740
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10740
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10741 10741
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10742 10742
 								GROUP BY hour_name 
10743 10743
 								ORDER BY hour_name ASC";
10744 10744
 		} else {
10745
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10745
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10746 10746
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10747 10747
 								GROUP BY hour_name 
10748 10748
 								ORDER BY hour_name ASC";
@@ -10750,12 +10750,12 @@  discard block
 block discarded – undo
10750 10750
       
10751 10751
 		
10752 10752
 		$sth = $this->db->prepare($query);
10753
-		$sth->execute(array(':pilot' => $pilot,':offset' => $offset));
10753
+		$sth->execute(array(':pilot' => $pilot, ':offset' => $offset));
10754 10754
       
10755 10755
 		$hour_array = array();
10756 10756
 		$temp_array = array();
10757 10757
         
10758
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10758
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10759 10759
 		{
10760 10760
 			$temp_array['hour_name'] = $row['hour_name'];
10761 10761
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10774,12 +10774,12 @@  discard block
 block discarded – undo
10774 10774
 	* @return Array the hour list
10775 10775
 	*
10776 10776
 	*/
10777
-	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10777
+	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
10778 10778
 	{
10779 10779
 		global $globalTimezone, $globalDBdriver;
10780
-		$filter_query = $this->getFilter($filters,true,true);
10781
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
10782
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
10780
+		$filter_query = $this->getFilter($filters, true, true);
10781
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
10782
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
10783 10783
 		if ($globalTimezone != '') {
10784 10784
 			date_default_timezone_set($globalTimezone);
10785 10785
 			$datetime = new DateTime();
@@ -10787,24 +10787,24 @@  discard block
 block discarded – undo
10787 10787
 		} else $offset = '+00:00';
10788 10788
 
10789 10789
 		if ($globalDBdriver == 'mysql') {
10790
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10790
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10791 10791
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10792 10792
 								GROUP BY hour_name 
10793 10793
 								ORDER BY hour_name ASC";
10794 10794
 		} else {
10795
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10795
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10796 10796
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10797 10797
 								GROUP BY hour_name 
10798 10798
 								ORDER BY hour_name ASC";
10799 10799
 		}
10800 10800
 		
10801 10801
 		$sth = $this->db->prepare($query);
10802
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
10802
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
10803 10803
       
10804 10804
 		$hour_array = array();
10805 10805
 		$temp_array = array();
10806 10806
         
10807
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10807
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10808 10808
 		{
10809 10809
 			$temp_array['hour_name'] = $row['hour_name'];
10810 10810
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10825,8 +10825,8 @@  discard block
 block discarded – undo
10825 10825
 	public function countAllHoursByCountry($country, $filters = array())
10826 10826
 	{
10827 10827
 		global $globalTimezone, $globalDBdriver;
10828
-		$filter_query = $this->getFilter($filters,true,true);
10829
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
10828
+		$filter_query = $this->getFilter($filters, true, true);
10829
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
10830 10830
 		if ($globalTimezone != '') {
10831 10831
 			date_default_timezone_set($globalTimezone);
10832 10832
 			$datetime = new DateTime();
@@ -10834,24 +10834,24 @@  discard block
 block discarded – undo
10834 10834
 		} else $offset = '+00:00';
10835 10835
 
10836 10836
 		if ($globalDBdriver == 'mysql') {
10837
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10837
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10838 10838
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10839 10839
 								GROUP BY hour_name 
10840 10840
 								ORDER BY hour_name ASC";
10841 10841
 		} else {
10842
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10842
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10843 10843
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10844 10844
 								GROUP BY hour_name 
10845 10845
 								ORDER BY hour_name ASC";
10846 10846
 		}
10847 10847
 		
10848 10848
 		$sth = $this->db->prepare($query);
10849
-		$sth->execute(array(':country' => $country,':offset' => $offset));
10849
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
10850 10850
       
10851 10851
 		$hour_array = array();
10852 10852
 		$temp_array = array();
10853 10853
         
10854
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10854
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10855 10855
 		{
10856 10856
 			$temp_array['hour_name'] = $row['hour_name'];
10857 10857
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10871,29 +10871,29 @@  discard block
 block discarded – undo
10871 10871
 	* @return Integer the number of aircrafts
10872 10872
 	*
10873 10873
 	*/
10874
-	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10874
+	public function countOverallAircrafts($filters = array(), $year = '', $month = '')
10875 10875
 	{
10876 10876
 		global $globalDBdriver;
10877
-		$filter_query = $this->getFilter($filters,true,true);
10878
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10877
+		$filter_query = $this->getFilter($filters, true, true);
10878
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10879 10879
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
10880 10880
 		$query_values = array();
10881 10881
 		if ($year != '') {
10882 10882
 			if ($globalDBdriver == 'mysql') {
10883 10883
 				$query .= " AND YEAR(spotter_output.date) = :year";
10884
-				$query_values = array_merge($query_values,array(':year' => $year));
10884
+				$query_values = array_merge($query_values, array(':year' => $year));
10885 10885
 			} else {
10886 10886
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10887
-				$query_values = array_merge($query_values,array(':year' => $year));
10887
+				$query_values = array_merge($query_values, array(':year' => $year));
10888 10888
 			}
10889 10889
 		}
10890 10890
 		if ($month != '') {
10891 10891
 			if ($globalDBdriver == 'mysql') {
10892 10892
 				$query .= " AND MONTH(spotter_output.date) = :month";
10893
-				$query_values = array_merge($query_values,array(':month' => $month));
10893
+				$query_values = array_merge($query_values, array(':month' => $month));
10894 10894
 			} else {
10895 10895
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10896
-				$query_values = array_merge($query_values,array(':month' => $month));
10896
+				$query_values = array_merge($query_values, array(':month' => $month));
10897 10897
 			}
10898 10898
 		}
10899 10899
 
@@ -10908,29 +10908,29 @@  discard block
 block discarded – undo
10908 10908
 	* @return Integer the number of aircrafts
10909 10909
 	*
10910 10910
 	*/
10911
-	public function countOverallArrival($filters = array(),$year = '',$month = '')
10911
+	public function countOverallArrival($filters = array(), $year = '', $month = '')
10912 10912
 	{
10913 10913
 		global $globalDBdriver;
10914
-		$filter_query = $this->getFilter($filters,true,true);
10915
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10914
+		$filter_query = $this->getFilter($filters, true, true);
10915
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10916 10916
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
10917 10917
 		$query_values = array();
10918 10918
 		if ($year != '') {
10919 10919
 			if ($globalDBdriver == 'mysql') {
10920 10920
 				$query .= " AND YEAR(spotter_output.date) = :year";
10921
-				$query_values = array_merge($query_values,array(':year' => $year));
10921
+				$query_values = array_merge($query_values, array(':year' => $year));
10922 10922
 			} else {
10923 10923
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10924
-				$query_values = array_merge($query_values,array(':year' => $year));
10924
+				$query_values = array_merge($query_values, array(':year' => $year));
10925 10925
 			}
10926 10926
 		}
10927 10927
 		if ($month != '') {
10928 10928
 			if ($globalDBdriver == 'mysql') {
10929 10929
 				$query .= " AND MONTH(spotter_output.date) = :month";
10930
-				$query_values = array_merge($query_values,array(':month' => $month));
10930
+				$query_values = array_merge($query_values, array(':month' => $month));
10931 10931
 			} else {
10932 10932
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10933
-				$query_values = array_merge($query_values,array(':month' => $month));
10933
+				$query_values = array_merge($query_values, array(':month' => $month));
10934 10934
 			}
10935 10935
 		}
10936 10936
 		
@@ -10945,29 +10945,29 @@  discard block
 block discarded – undo
10945 10945
 	* @return Integer the number of pilots
10946 10946
 	*
10947 10947
 	*/
10948
-	public function countOverallPilots($filters = array(),$year = '',$month = '')
10948
+	public function countOverallPilots($filters = array(), $year = '', $month = '')
10949 10949
 	{
10950 10950
 		global $globalDBdriver;
10951
-		$filter_query = $this->getFilter($filters,true,true);
10952
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10951
+		$filter_query = $this->getFilter($filters, true, true);
10952
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10953 10953
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
10954 10954
 		$query_values = array();
10955 10955
 		if ($year != '') {
10956 10956
 			if ($globalDBdriver == 'mysql') {
10957 10957
 				$query .= " AND YEAR(spotter_output.date) = :year";
10958
-				$query_values = array_merge($query_values,array(':year' => $year));
10958
+				$query_values = array_merge($query_values, array(':year' => $year));
10959 10959
 			} else {
10960 10960
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10961
-				$query_values = array_merge($query_values,array(':year' => $year));
10961
+				$query_values = array_merge($query_values, array(':year' => $year));
10962 10962
 			}
10963 10963
 		}
10964 10964
 		if ($month != '') {
10965 10965
 			if ($globalDBdriver == 'mysql') {
10966 10966
 				$query .= " AND MONTH(spotter_output.date) = :month";
10967
-				$query_values = array_merge($query_values,array(':month' => $month));
10967
+				$query_values = array_merge($query_values, array(':month' => $month));
10968 10968
 			} else {
10969 10969
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10970
-				$query_values = array_merge($query_values,array(':month' => $month));
10970
+				$query_values = array_merge($query_values, array(':month' => $month));
10971 10971
 			}
10972 10972
 		}
10973 10973
 		$sth = $this->db->prepare($query);
@@ -10981,29 +10981,29 @@  discard block
 block discarded – undo
10981 10981
 	* @return Integer the number of owners
10982 10982
 	*
10983 10983
 	*/
10984
-	public function countOverallOwners($filters = array(),$year = '',$month = '')
10984
+	public function countOverallOwners($filters = array(), $year = '', $month = '')
10985 10985
 	{
10986 10986
 		global $globalDBdriver;
10987
-		$filter_query = $this->getFilter($filters,true,true);
10988
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10987
+		$filter_query = $this->getFilter($filters, true, true);
10988
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10989 10989
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
10990 10990
 		$query_values = array();
10991 10991
 		if ($year != '') {
10992 10992
 			if ($globalDBdriver == 'mysql') {
10993 10993
 				$query .= " AND YEAR(spotter_output.date) = :year";
10994
-				$query_values = array_merge($query_values,array(':year' => $year));
10994
+				$query_values = array_merge($query_values, array(':year' => $year));
10995 10995
 			} else {
10996 10996
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10997
-				$query_values = array_merge($query_values,array(':year' => $year));
10997
+				$query_values = array_merge($query_values, array(':year' => $year));
10998 10998
 			}
10999 10999
 		}
11000 11000
 		if ($month != '') {
11001 11001
 			if ($globalDBdriver == 'mysql') {
11002 11002
 				$query .= " AND MONTH(spotter_output.date) = :month";
11003
-				$query_values = array_merge($query_values,array(':month' => $month));
11003
+				$query_values = array_merge($query_values, array(':month' => $month));
11004 11004
 			} else {
11005 11005
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11006
-				$query_values = array_merge($query_values,array(':month' => $month));
11006
+				$query_values = array_merge($query_values, array(':month' => $month));
11007 11007
 			}
11008 11008
 		}
11009 11009
 		$sth = $this->db->prepare($query);
@@ -11018,32 +11018,32 @@  discard block
 block discarded – undo
11018 11018
 	* @return Integer the number of flights
11019 11019
 	*
11020 11020
 	*/
11021
-	public function countOverallFlights($filters = array(),$year = '',$month = '')
11021
+	public function countOverallFlights($filters = array(), $year = '', $month = '')
11022 11022
 	{
11023 11023
 		global $globalDBdriver;
11024
-		$queryi  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11024
+		$queryi = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11025 11025
 		$query_values = array();
11026 11026
 		$query = '';
11027 11027
 		if ($year != '') {
11028 11028
 			if ($globalDBdriver == 'mysql') {
11029 11029
 				$query .= " AND YEAR(spotter_output.date) = :year";
11030
-				$query_values = array_merge($query_values,array(':year' => $year));
11030
+				$query_values = array_merge($query_values, array(':year' => $year));
11031 11031
 			} else {
11032 11032
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11033
-				$query_values = array_merge($query_values,array(':year' => $year));
11033
+				$query_values = array_merge($query_values, array(':year' => $year));
11034 11034
 			}
11035 11035
 		}
11036 11036
 		if ($month != '') {
11037 11037
 			if ($globalDBdriver == 'mysql') {
11038 11038
 				$query .= " AND MONTH(spotter_output.date) = :month";
11039
-				$query_values = array_merge($query_values,array(':month' => $month));
11039
+				$query_values = array_merge($query_values, array(':month' => $month));
11040 11040
 			} else {
11041 11041
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11042
-				$query_values = array_merge($query_values,array(':month' => $month));
11042
+				$query_values = array_merge($query_values, array(':month' => $month));
11043 11043
 			}
11044 11044
 		}
11045 11045
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11046
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11046
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11047 11047
 		
11048 11048
 		$sth = $this->db->prepare($queryi);
11049 11049
 		$sth->execute($query_values);
@@ -11056,29 +11056,29 @@  discard block
 block discarded – undo
11056 11056
 	* @return Integer the number of flights
11057 11057
 	*
11058 11058
 	*/
11059
-	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11059
+	public function countOverallMilitaryFlights($filters = array(), $year = '', $month = '')
11060 11060
 	{
11061 11061
 		global $globalDBdriver;
11062
-		$filter_query = $this->getFilter($filters,true,true);
11063
-		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11062
+		$filter_query = $this->getFilter($filters, true, true);
11063
+		$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11064 11064
                     FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'";
11065 11065
 		$query_values = array();
11066 11066
 		if ($year != '') {
11067 11067
 			if ($globalDBdriver == 'mysql') {
11068 11068
 				$query .= " AND YEAR(spotter_output.date) = :year";
11069
-				$query_values = array_merge($query_values,array(':year' => $year));
11069
+				$query_values = array_merge($query_values, array(':year' => $year));
11070 11070
 			} else {
11071 11071
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11072
-				$query_values = array_merge($query_values,array(':year' => $year));
11072
+				$query_values = array_merge($query_values, array(':year' => $year));
11073 11073
 			}
11074 11074
 		}
11075 11075
 		if ($month != '') {
11076 11076
 			if ($globalDBdriver == 'mysql') {
11077 11077
 				$query .= " AND MONTH(spotter_output.date) = :month";
11078
-				$query_values = array_merge($query_values,array(':month' => $month));
11078
+				$query_values = array_merge($query_values, array(':month' => $month));
11079 11079
 			} else {
11080 11080
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11081
-				$query_values = array_merge($query_values,array(':month' => $month));
11081
+				$query_values = array_merge($query_values, array(':month' => $month));
11082 11082
 			}
11083 11083
 		}
11084 11084
       
@@ -11095,10 +11095,10 @@  discard block
 block discarded – undo
11095 11095
 	* @return Integer the number of airlines
11096 11096
 	*
11097 11097
 	*/
11098
-	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11098
+	public function countOverallAirlines($filters = array(), $year = '', $month = '')
11099 11099
 	{
11100 11100
 		global $globalDBdriver;
11101
-		$queryi  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11101
+		$queryi = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11102 11102
 							FROM spotter_output";
11103 11103
       
11104 11104
 		$query_values = array();
@@ -11106,23 +11106,23 @@  discard block
 block discarded – undo
11106 11106
 		if ($year != '') {
11107 11107
 			if ($globalDBdriver == 'mysql') {
11108 11108
 				$query .= " AND YEAR(spotter_output.date) = :year";
11109
-				$query_values = array_merge($query_values,array(':year' => $year));
11109
+				$query_values = array_merge($query_values, array(':year' => $year));
11110 11110
 			} else {
11111 11111
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11112
-				$query_values = array_merge($query_values,array(':year' => $year));
11112
+				$query_values = array_merge($query_values, array(':year' => $year));
11113 11113
 			}
11114 11114
 		}
11115 11115
 		if ($month != '') {
11116 11116
 			if ($globalDBdriver == 'mysql') {
11117 11117
 				$query .= " AND MONTH(spotter_output.date) = :month";
11118
-				$query_values = array_merge($query_values,array(':month' => $month));
11118
+				$query_values = array_merge($query_values, array(':month' => $month));
11119 11119
 			} else {
11120 11120
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11121
-				$query_values = array_merge($query_values,array(':month' => $month));
11121
+				$query_values = array_merge($query_values, array(':month' => $month));
11122 11122
 			}
11123 11123
 		}
11124 11124
                 if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11125
+                else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11126 11126
 
11127 11127
 
11128 11128
 		$sth = $this->db->prepare($queryi);
@@ -11140,7 +11140,7 @@  discard block
 block discarded – undo
11140 11140
 	public function countAllHoursFromToday($filters = array())
11141 11141
 	{
11142 11142
 		global $globalTimezone, $globalDBdriver;
11143
-		$filter_query = $this->getFilter($filters,true,true);
11143
+		$filter_query = $this->getFilter($filters, true, true);
11144 11144
 		if ($globalTimezone != '') {
11145 11145
 			date_default_timezone_set($globalTimezone);
11146 11146
 			$datetime = new DateTime();
@@ -11148,12 +11148,12 @@  discard block
 block discarded – undo
11148 11148
 		} else $offset = '+00:00';
11149 11149
 
11150 11150
 		if ($globalDBdriver == 'mysql') {
11151
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11151
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11152 11152
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
11153 11153
 								GROUP BY hour_name 
11154 11154
 								ORDER BY hour_name ASC";
11155 11155
 		} else {
11156
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11156
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11157 11157
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
11158 11158
 								GROUP BY hour_name 
11159 11159
 								ORDER BY hour_name ASC";
@@ -11165,7 +11165,7 @@  discard block
 block discarded – undo
11165 11165
 		$hour_array = array();
11166 11166
 		$temp_array = array();
11167 11167
         
11168
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11168
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11169 11169
 		{
11170 11170
 			$temp_array['hour_name'] = $row['hour_name'];
11171 11171
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -11184,14 +11184,14 @@  discard block
 block discarded – undo
11184 11184
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11185 11185
 	{
11186 11186
 		global $global_query, $globalDBdriver, $globalTimezone;
11187
-		$filter_query = $this->getFilter($filters,true,true);
11187
+		$filter_query = $this->getFilter($filters, true, true);
11188 11188
 		date_default_timezone_set('UTC');
11189 11189
 		$limit_query = '';
11190 11190
 		if ($limit != "")
11191 11191
 		{
11192 11192
 			$limit_array = explode(",", $limit);
11193
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
11194
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
11193
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
11194
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
11195 11195
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
11196 11196
 			{
11197 11197
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -11244,7 +11244,7 @@  discard block
 block discarded – undo
11244 11244
 			    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')
11245 11245
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
11246 11246
 			//echo $query;
11247
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
11247
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
11248 11248
 			/*
11249 11249
 			$sth = $this->db->prepare($query);
11250 11250
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -11263,9 +11263,9 @@  discard block
 block discarded – undo
11263 11263
 	*/
11264 11264
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11265 11265
 	{
11266
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
11266
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
11267 11267
 
11268
-		$query  = "SELECT spotter_output.spotter_id
11268
+		$query = "SELECT spotter_output.spotter_id
11269 11269
 								FROM spotter_output 
11270 11270
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
11271 11271
         
@@ -11273,7 +11273,7 @@  discard block
 block discarded – undo
11273 11273
 		$sth = $this->db->prepare($query);
11274 11274
 		$sth->execute();
11275 11275
 
11276
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11276
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11277 11277
 		{
11278 11278
 			return $row['spotter_id'];
11279 11279
 		}
@@ -11298,23 +11298,23 @@  discard block
 block discarded – undo
11298 11298
 		}
11299 11299
 		
11300 11300
 		$current_date = date("Y-m-d H:i:s");
11301
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
11301
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
11302 11302
 		
11303 11303
 		$diff = abs(strtotime($current_date) - strtotime($date));
11304 11304
 
11305
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
11305
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
11306 11306
 		$years = $time_array['years'];
11307 11307
 		
11308
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
11308
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
11309 11309
 		$months = $time_array['months'];
11310 11310
 		
11311
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
11311
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
11312 11312
 		$days = $time_array['days'];
11313
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
11313
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
11314 11314
 		$hours = $time_array['hours'];
11315
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
11315
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
11316 11316
 		$minutes = $time_array['minutes'];
11317
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11317
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11318 11318
 		
11319 11319
 		return $time_array;	
11320 11320
 	}	
@@ -11340,63 +11340,63 @@  discard block
 block discarded – undo
11340 11340
 			$temp_array['direction_degree'] = $direction;
11341 11341
 			$temp_array['direction_shortname'] = "N";
11342 11342
 			$temp_array['direction_fullname'] = "North";
11343
-		} elseif ($direction >= 22.5 && $direction < 45){
11343
+		} elseif ($direction >= 22.5 && $direction < 45) {
11344 11344
 			$temp_array['direction_degree'] = $direction;
11345 11345
 			$temp_array['direction_shortname'] = "NNE";
11346 11346
 			$temp_array['direction_fullname'] = "North-Northeast";
11347
-		} elseif ($direction >= 45 && $direction < 67.5){
11347
+		} elseif ($direction >= 45 && $direction < 67.5) {
11348 11348
 			$temp_array['direction_degree'] = $direction;
11349 11349
 			$temp_array['direction_shortname'] = "NE";
11350 11350
 			$temp_array['direction_fullname'] = "Northeast";
11351
-		} elseif ($direction >= 67.5 && $direction < 90){
11351
+		} elseif ($direction >= 67.5 && $direction < 90) {
11352 11352
 			$temp_array['direction_degree'] = $direction;
11353 11353
 			$temp_array['direction_shortname'] = "ENE";
11354 11354
 			$temp_array['direction_fullname'] = "East-Northeast";
11355
-		} elseif ($direction >= 90 && $direction < 112.5){
11355
+		} elseif ($direction >= 90 && $direction < 112.5) {
11356 11356
 			$temp_array['direction_degree'] = $direction;
11357 11357
 			$temp_array['direction_shortname'] = "E";
11358 11358
 			$temp_array['direction_fullname'] = "East";
11359
-		} elseif ($direction >= 112.5 && $direction < 135){
11359
+		} elseif ($direction >= 112.5 && $direction < 135) {
11360 11360
 			$temp_array['direction_degree'] = $direction;
11361 11361
 			$temp_array['direction_shortname'] = "ESE";
11362 11362
 			$temp_array['direction_fullname'] = "East-Southeast";
11363
-		} elseif ($direction >= 135 && $direction < 157.5){
11363
+		} elseif ($direction >= 135 && $direction < 157.5) {
11364 11364
 			$temp_array['direction_degree'] = $direction;
11365 11365
 			$temp_array['direction_shortname'] = "SE";
11366 11366
 			$temp_array['direction_fullname'] = "Southeast";
11367
-		} elseif ($direction >= 157.5 && $direction < 180){
11367
+		} elseif ($direction >= 157.5 && $direction < 180) {
11368 11368
 			$temp_array['direction_degree'] = $direction;
11369 11369
 			$temp_array['direction_shortname'] = "SSE";
11370 11370
 			$temp_array['direction_fullname'] = "South-Southeast";
11371
-		} elseif ($direction >= 180 && $direction < 202.5){
11371
+		} elseif ($direction >= 180 && $direction < 202.5) {
11372 11372
 			$temp_array['direction_degree'] = $direction;
11373 11373
 			$temp_array['direction_shortname'] = "S";
11374 11374
 			$temp_array['direction_fullname'] = "South";
11375
-		} elseif ($direction >= 202.5 && $direction < 225){
11375
+		} elseif ($direction >= 202.5 && $direction < 225) {
11376 11376
 			$temp_array['direction_degree'] = $direction;
11377 11377
 			$temp_array['direction_shortname'] = "SSW";
11378 11378
 			$temp_array['direction_fullname'] = "South-Southwest";
11379
-		} elseif ($direction >= 225 && $direction < 247.5){
11379
+		} elseif ($direction >= 225 && $direction < 247.5) {
11380 11380
 			$temp_array['direction_degree'] = $direction;
11381 11381
 			$temp_array['direction_shortname'] = "SW";
11382 11382
 			$temp_array['direction_fullname'] = "Southwest";
11383
-		} elseif ($direction >= 247.5 && $direction < 270){
11383
+		} elseif ($direction >= 247.5 && $direction < 270) {
11384 11384
 			$temp_array['direction_degree'] = $direction;
11385 11385
 			$temp_array['direction_shortname'] = "WSW";
11386 11386
 			$temp_array['direction_fullname'] = "West-Southwest";
11387
-		} elseif ($direction >= 270 && $direction < 292.5){
11387
+		} elseif ($direction >= 270 && $direction < 292.5) {
11388 11388
 			$temp_array['direction_degree'] = $direction;
11389 11389
 			$temp_array['direction_shortname'] = "W";
11390 11390
 			$temp_array['direction_fullname'] = "West";
11391
-		} elseif ($direction >= 292.5 && $direction < 315){
11391
+		} elseif ($direction >= 292.5 && $direction < 315) {
11392 11392
 			$temp_array['direction_degree'] = $direction;
11393 11393
 			$temp_array['direction_shortname'] = "WNW";
11394 11394
 			$temp_array['direction_fullname'] = "West-Northwest";
11395
-		} elseif ($direction >= 315 && $direction < 337.5){
11395
+		} elseif ($direction >= 315 && $direction < 337.5) {
11396 11396
 			$temp_array['direction_degree'] = $direction;
11397 11397
 			$temp_array['direction_shortname'] = "NW";
11398 11398
 			$temp_array['direction_fullname'] = "Northwest";
11399
-		} elseif ($direction >= 337.5 && $direction < 360){
11399
+		} elseif ($direction >= 337.5 && $direction < 360) {
11400 11400
 			$temp_array['direction_degree'] = $direction;
11401 11401
 			$temp_array['direction_shortname'] = "NNW";
11402 11402
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -11449,8 +11449,8 @@  discard block
 block discarded – undo
11449 11449
 	*/
11450 11450
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11451 11451
 	{
11452
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11453
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
11452
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11453
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
11454 11454
 		if ($source_type == '' || $source_type == 'modes') {
11455 11455
 			$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
11456 11456
 		} else {
@@ -11477,10 +11477,10 @@  discard block
 block discarded – undo
11477 11477
 	* @return String the aircraft type
11478 11478
 	*
11479 11479
 	*/
11480
-	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11480
+	public function getAircraftTypeBymodeS($aircraft_modes, $source_type = '')
11481 11481
 	{
11482
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11483
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
11482
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11483
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
11484 11484
 		if ($source_type == '' || $source_type == 'modes') {
11485 11485
 			$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
11486 11486
 		} else {
@@ -11508,11 +11508,11 @@  discard block
 block discarded – undo
11508 11508
 	* @param Float $longitude longitute of the flight
11509 11509
 	* @return String the countrie
11510 11510
 	*/
11511
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11511
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
11512 11512
 	{
11513 11513
 		global $globalDBdriver, $globalDebug;
11514
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11515
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11514
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11515
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11516 11516
 	
11517 11517
 		$Connection = new Connection($this->db);
11518 11518
 		if (!$Connection->tableExists('countries')) return '';
@@ -11552,7 +11552,7 @@  discard block
 block discarded – undo
11552 11552
 	public function getCountryFromISO2($iso2)
11553 11553
 	{
11554 11554
 		global $globalDBdriver, $globalDebug;
11555
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11555
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
11556 11556
 	
11557 11557
 		$Connection = new Connection($this->db);
11558 11558
 		if (!$Connection->tableExists('countries')) return '';
@@ -11584,19 +11584,19 @@  discard block
 block discarded – undo
11584 11584
 	*/
11585 11585
 	public function convertAircraftRegistration($registration)
11586 11586
 	{
11587
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11587
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11588 11588
 		$registration_prefix = '';
11589 11589
 		$registration_1 = substr($registration, 0, 1);
11590 11590
 		$registration_2 = substr($registration, 0, 2);
11591 11591
 
11592 11592
 		//first get the prefix based on two characters
11593
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11593
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11594 11594
       
11595 11595
 		
11596 11596
 		$sth = $this->db->prepare($query);
11597 11597
 		$sth->execute(array(':registration_2' => $registration_2));
11598 11598
         
11599
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11599
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11600 11600
 		{
11601 11601
 			$registration_prefix = $row['registration_prefix'];
11602 11602
 		}
@@ -11604,11 +11604,11 @@  discard block
 block discarded – undo
11604 11604
 		//if we didn't find a two chracter prefix lets just search the one with one character
11605 11605
 		if ($registration_prefix == '')
11606 11606
 		{
11607
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11607
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11608 11608
 			$sth = $this->db->prepare($query);
11609 11609
 			$sth->execute(array(':registration_1' => $registration_1));
11610 11610
 	        
11611
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11611
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11612 11612
 			{
11613 11613
 				$registration_prefix = $row['registration_prefix'];
11614 11614
 			}
@@ -11622,7 +11622,7 @@  discard block
 block discarded – undo
11622 11622
 			} else {
11623 11623
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
11624 11624
 			}
11625
-		} else if(strlen($registration_prefix) == 2){
11625
+		} else if (strlen($registration_prefix) == 2) {
11626 11626
 			if (0 === strpos($registration, 'N')) {
11627 11627
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
11628 11628
 			} else {
@@ -11641,17 +11641,17 @@  discard block
 block discarded – undo
11641 11641
 	*/
11642 11642
 	public function countryFromAircraftRegistration($registration)
11643 11643
 	{
11644
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11644
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11645 11645
 		
11646 11646
 		$registration_prefix = '';
11647
-		$registration_test = explode('-',$registration);
11647
+		$registration_test = explode('-', $registration);
11648 11648
 		$country = '';
11649 11649
 		if ($registration_test[0] != $registration) {
11650 11650
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11651 11651
 	      
11652 11652
 			$sth = $this->db->prepare($query);
11653 11653
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11654
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11654
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11655 11655
 			{
11656 11656
 				//$registration_prefix = $row['registration_prefix'];
11657 11657
 				$country = $row['country'];
@@ -11662,13 +11662,13 @@  discard block
 block discarded – undo
11662 11662
 
11663 11663
 			$country = '';
11664 11664
 			//first get the prefix based on two characters
11665
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11665
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11666 11666
       
11667 11667
 			
11668 11668
 			$sth = $this->db->prepare($query);
11669 11669
 			$sth->execute(array(':registration_2' => $registration_2));
11670 11670
         
11671
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11671
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11672 11672
 			{
11673 11673
 				$registration_prefix = $row['registration_prefix'];
11674 11674
 				$country = $row['country'];
@@ -11677,12 +11677,12 @@  discard block
 block discarded – undo
11677 11677
 			//if we didn't find a two chracter prefix lets just search the one with one character
11678 11678
 			if ($registration_prefix == "")
11679 11679
 			{
11680
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11680
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11681 11681
 	      
11682 11682
 				$sth = $this->db->prepare($query);
11683 11683
 				$sth->execute(array(':registration_1' => $registration_1));
11684 11684
 	        
11685
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11685
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11686 11686
 				{
11687 11687
 					//$registration_prefix = $row['registration_prefix'];
11688 11688
 					$country = $row['country'];
@@ -11702,17 +11702,17 @@  discard block
 block discarded – undo
11702 11702
 	*/
11703 11703
 	public function registrationPrefixFromAircraftRegistration($registration)
11704 11704
 	{
11705
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11705
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11706 11706
 		
11707 11707
 		$registration_prefix = '';
11708
-		$registration_test = explode('-',$registration);
11708
+		$registration_test = explode('-', $registration);
11709 11709
 		//$country = '';
11710 11710
 		if ($registration_test[0] != $registration) {
11711
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11711
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11712 11712
 	      
11713 11713
 			$sth = $this->db->prepare($query);
11714 11714
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11715
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11715
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11716 11716
 			{
11717 11717
 				$registration_prefix = $row['registration_prefix'];
11718 11718
 				//$country = $row['country'];
@@ -11722,13 +11722,13 @@  discard block
 block discarded – undo
11722 11722
 		        $registration_2 = substr($registration, 0, 2);
11723 11723
 
11724 11724
 			//first get the prefix based on two characters
11725
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11725
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11726 11726
       
11727 11727
 			
11728 11728
 			$sth = $this->db->prepare($query);
11729 11729
 			$sth->execute(array(':registration_2' => $registration_2));
11730 11730
         
11731
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11731
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11732 11732
 			{
11733 11733
 				$registration_prefix = $row['registration_prefix'];
11734 11734
 				//$country = $row['country'];
@@ -11737,12 +11737,12 @@  discard block
 block discarded – undo
11737 11737
 			//if we didn't find a two chracter prefix lets just search the one with one character
11738 11738
 			if ($registration_prefix == "")
11739 11739
 			{
11740
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11740
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11741 11741
 	      
11742 11742
 				$sth = $this->db->prepare($query);
11743 11743
 				$sth->execute(array(':registration_1' => $registration_1));
11744 11744
 	        
11745
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11745
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11746 11746
 				{
11747 11747
 					$registration_prefix = $row['registration_prefix'];
11748 11748
 					//$country = $row['country'];
@@ -11763,13 +11763,13 @@  discard block
 block discarded – undo
11763 11763
 	*/
11764 11764
 	public function countryFromAircraftRegistrationCode($registration)
11765 11765
 	{
11766
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11766
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11767 11767
 		
11768 11768
 		$country = '';
11769
-		$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11769
+		$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11770 11770
 		$sth = $this->db->prepare($query);
11771 11771
 		$sth->execute(array(':registration' => $registration));
11772
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11772
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11773 11773
 		{
11774 11774
 			$country = $row['country'];
11775 11775
 		}
@@ -11782,9 +11782,9 @@  discard block
 block discarded – undo
11782 11782
 	* @param String $flightaware_id flightaware_id from spotter_output table
11783 11783
 	* @param String $highlight New highlight value
11784 11784
 	*/
11785
-	public function setHighlightFlight($flightaware_id,$highlight) {
11785
+	public function setHighlightFlight($flightaware_id, $highlight) {
11786 11786
 		
11787
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11787
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11788 11788
 		$sth = $this->db->prepare($query);
11789 11789
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
11790 11790
 	}
@@ -11796,13 +11796,13 @@  discard block
 block discarded – undo
11796 11796
 	* @param String $date Date of spotted aircraft
11797 11797
 	* @param String $highlight New highlight value
11798 11798
 	*/
11799
-	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11799
+	public function setHighlightFlightByRegistration($registration, $highlight, $date = '') {
11800 11800
 		if ($date == '') {
11801 11801
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
11802 11802
 			$query_values = array(':registration' => $registration, ':highlight' => $highlight);
11803 11803
 		} else {
11804 11804
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE registration = :registration AND date(date) = :date";
11805
-			$query_values = array(':registration' => $registration, ':highlight' => $highlight,':date' => $date);
11805
+			$query_values = array(':registration' => $registration, ':highlight' => $highlight, ':date' => $date);
11806 11806
 		}
11807 11807
 		$sth = $this->db->prepare($query);
11808 11808
 		$sth->execute($query_values);
@@ -11832,7 +11832,7 @@  discard block
 block discarded – undo
11832 11832
 		
11833 11833
 		$bitly_data = json_decode($bitly_data);
11834 11834
 		$bitly_url = '';
11835
-		if ($bitly_data->status_txt = "OK"){
11835
+		if ($bitly_data->status_txt = "OK") {
11836 11836
 			$bitly_url = $bitly_data->data->url;
11837 11837
 		}
11838 11838
 
@@ -11842,7 +11842,7 @@  discard block
 block discarded – undo
11842 11842
 
11843 11843
 	public function getOrderBy()
11844 11844
 	{
11845
-		$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"));
11845
+		$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"));
11846 11846
 		
11847 11847
 		return $orderby;
11848 11848
 		
@@ -11976,14 +11976,14 @@  discard block
 block discarded – undo
11976 11976
 		}
11977 11977
 		$sth = $this->db->prepare($query);
11978 11978
 		$sth->execute();
11979
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11979
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11980 11980
 		{
11981 11981
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
11982 11982
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
11983 11983
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
11984
-				$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";
11984
+				$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";
11985 11985
 				$sthu = $this->db->prepare($update_query);
11986
-				$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']));
11986
+				$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']));
11987 11987
 			}
11988 11988
 		}
11989 11989
 		
@@ -11996,7 +11996,7 @@  discard block
 block discarded – undo
11996 11996
 		}
11997 11997
 		$sth = $this->db->prepare($query);
11998 11998
 		$sth->execute();
11999
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11999
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12000 12000
 		{
12001 12001
 			if (is_numeric(substr($row['ident'], -1, 1)))
12002 12002
 			{
@@ -12005,11 +12005,11 @@  discard block
 block discarded – undo
12005 12005
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12006 12006
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12007 12007
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12008
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12008
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
12009 12009
 				if (isset($airline_array[0]['name'])) {
12010
-					$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";
12010
+					$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";
12011 12011
 					$sthu = $this->db->prepare($update_query);
12012
-					$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']));
12012
+					$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']));
12013 12013
 				}
12014 12014
 			}
12015 12015
 		}
@@ -12029,18 +12029,18 @@  discard block
 block discarded – undo
12029 12029
 		}
12030 12030
 		$sth = $this->db->prepare($query);
12031 12031
 		$sth->execute();
12032
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12032
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12033 12033
 		{
12034 12034
 			if ($row['aircraft_icao'] != '') {
12035 12035
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
12036
-				if ($row['registration'] != ""){
12036
+				if ($row['registration'] != "") {
12037 12037
 					$image_array = $Image->getSpotterImage($row['registration']);
12038 12038
 					if (!isset($image_array[0]['registration'])) {
12039 12039
 						$Image->addSpotterImage($row['registration']);
12040 12040
 					}
12041 12041
 				}
12042 12042
 				if (count($aircraft_name) > 0) {
12043
-					$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";
12043
+					$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";
12044 12044
 					$sthu = $this->db->prepare($update_query);
12045 12045
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
12046 12046
 				}
@@ -12055,10 +12055,10 @@  discard block
 block discarded – undo
12055 12055
 		$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";
12056 12056
 		$sth = $this->db->prepare($query);
12057 12057
 		$sth->execute();
12058
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12058
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12059 12059
 		{
12060 12060
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
12061
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
12061
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
12062 12062
 				$airport_icao = '';
12063 12063
 				 if (isset($closestAirports[0])) {
12064 12064
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -12072,7 +12072,7 @@  discard block
 block discarded – undo
12072 12072
 								break;
12073 12073
 							}
12074 12074
 						}
12075
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12075
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
12076 12076
 						$airport_icao = $closestAirports[0]['icao'];
12077 12077
 						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";
12078 12078
 					} else {
@@ -12083,28 +12083,28 @@  discard block
 block discarded – undo
12083 12083
 				}
12084 12084
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12085 12085
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12086
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12086
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12087 12087
 					$sthu = $this->db->prepare($update_query);
12088
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
12088
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
12089 12089
 				}
12090 12090
 			}
12091 12091
 		}
12092 12092
 	}
12093 12093
 	
12094
-	public function closestAirports($origLat,$origLon,$dist = 10) {
12094
+	public function closestAirports($origLat, $origLon, $dist = 10) {
12095 12095
 		global $globalDBdriver;
12096
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
12096
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
12097 12097
 /*
12098 12098
 		$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 
12099 12099
                       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)) 
12100 12100
                       having distance < $dist ORDER BY distance limit 100;";
12101 12101
 */
12102 12102
 		if ($globalDBdriver == 'mysql') {
12103
-			$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 
12103
+			$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 
12104 12104
 	                      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)) 
12105 12105
 	                      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;";
12106 12106
                 } else {
12107
-			$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 
12107
+			$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 
12108 12108
 	                      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)) 
12109 12109
 	                      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;";
12110 12110
     		}
Please login to merge, or discard this patch.