Completed
Push — master ( c1d943...56b04e )
by Yannick
07:43
created
require/class.APRS.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -84,6 +84,10 @@
 block discarded – undo
84 84
 	'y' => 'Yagi At QTH');
85 85
 	
86 86
 
87
+    /**
88
+     * @param integer $n
89
+     * @param integer $s
90
+     */
87 91
     private function urshift($n, $s) {
88 92
 	return ($n >= 0) ? ($n >> $s) :
89 93
     	    (($n & 0x7fffffff) >> $s) | 
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3
-    protected $symbols = array('!' => 'Police',
3
+	protected $symbols = array('!' => 'Police',
4 4
 	'#' => 'DIGI',
5 5
 	'$' => 'Phone',
6 6
 	'%' => 'DX Cluster',
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 	'y' => 'Yagi At QTH');
85 85
 	
86 86
 
87
-    private function urshift($n, $s) {
87
+	private function urshift($n, $s) {
88 88
 	return ($n >= 0) ? ($n >> $s) :
89
-    	    (($n & 0x7fffffff) >> $s) | 
90
-        	(0x40000000 >> ($s - 1));
91
-    }
89
+			(($n & 0x7fffffff) >> $s) | 
90
+			(0x40000000 >> ($s - 1));
91
+	}
92 92
 
93
-    public function parse($input) {
93
+	public function parse($input) {
94 94
 	global $globalDebug;
95 95
 	$debug = false;
96 96
 	$result = array();
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
106
-	    return false;
105
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
106
+		return false;
107 107
 	}
108 108
 	
109 109
 	/* Save header and body. */
@@ -116,22 +116,22 @@  discard block
 block discarded – undo
116 116
 	/* Parse source, target and path. */
117 117
 	//FLRDF0A52>APRS,qAS,LSTB
118 118
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119
-	    $ident = $matches[1];
120
-	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
122
-	    $result['ident'] = $ident;
119
+		$ident = $matches[1];
120
+		$all_elements = $matches[2];
121
+		if ($debug) echo 'ident : '.$ident."\n";
122
+		$result['ident'] = $ident;
123 123
 	} else return false;
124 124
 	$elements = explode(',',$all_elements);
125 125
 	$source = end($elements);
126 126
 	$result['source'] = $source;
127 127
 	foreach ($elements as $element) {
128
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129
-	        //echo "ok";
130
-	        if ($element == 'TCPIP*') return false;
131
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
128
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129
+			//echo "ok";
130
+			if ($element == 'TCPIP*') return false;
131
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
132 132
 		return false;
133
-	    }
134
-	    /*
133
+		}
134
+		/*
135 135
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
136 136
 		//echo "ok";
137 137
 	    } else {
@@ -144,42 +144,42 @@  discard block
 block discarded – undo
144 144
 	$body_parse = substr($body,1);
145 145
 	//echo 'Body : '.$body."\n";
146 146
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
147
-	    $body_parse = substr($body_parse,10);
148
-	    $find = true;
149
-	    //echo $body_parse."\n";
147
+		$body_parse = substr($body_parse,10);
148
+		$find = true;
149
+		//echo $body_parse."\n";
150 150
 	}
151 151
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
152
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
153
-	    $find = true;
154
-	    //echo $body_parse."\n";
152
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
153
+		$find = true;
154
+		//echo $body_parse."\n";
155 155
 	}
156 156
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
157
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
158
-	    $find = true;
159
-	    //echo $body_parse."\n";
157
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
158
+		$find = true;
159
+		//echo $body_parse."\n";
160 160
 	}
161 161
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
162
-	    $find = true;
163
-	    //print_r($matches);
164
-	    $timestamp = $matches[0];
165
-	    if ($matches[4] == 'h') {
162
+		$find = true;
163
+		//print_r($matches);
164
+		$timestamp = $matches[0];
165
+		if ($matches[4] == 'h') {
166 166
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
167 167
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
168 168
 		/*
169 169
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
170 170
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
171 171
 		*/
172
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
172
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
173 173
 		// This work or not ?
174 174
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
175
-	    }
176
-	    $body_parse = substr($body_parse,7);
177
-	    $result['timestamp'] = $timestamp;
178
-	    //echo date('Ymd H:i:s',$timestamp);
175
+		}
176
+		$body_parse = substr($body_parse,7);
177
+		$result['timestamp'] = $timestamp;
178
+		//echo date('Ymd H:i:s',$timestamp);
179 179
 	}
180 180
 	//if (strlen($body_parse) > 19) {
181
-	    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)) {
182
-	    $find = true;
181
+		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)) {
182
+		$find = true;
183 183
 		// 4658.70N/00707.78Ez
184 184
 		//print_r(str_split($body_parse));
185 185
 		
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		$lon = intval($lon_deg);
197 197
 		if ($lat > 89 || $lon > 179) return false;
198 198
 	    
199
-	    /*
199
+		/*
200 200
 	    $tmp_5b = str_replace('.','',$lat_min);
201 201
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
202 202
 	        print_r($matches);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 		$result['longitude'] = $longitude;
211 211
 		$body_parse = substr($body_parse,18);
212 212
 		$body_parse_len = strlen($body_parse);
213
-	    }
214
-	    if ($body_len > 0) {
213
+		}
214
+		if ($body_len > 0) {
215 215
 		/*
216 216
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
217 217
 			$body_split = str_split($body);
@@ -237,60 +237,60 @@  discard block
 block discarded – undo
237 237
 		$result['symbol_code'] = $symbol_code;
238 238
 		if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
239 239
 		if ($symbol_code != '_') {
240
-		    //$body_parse = substr($body_parse,1);
241
-		    //$body_parse = trim($body_parse);
242
-		    //$body_parse_len = strlen($body_parse);
243
-		    if ($body_parse_len >= 7) {
240
+			//$body_parse = substr($body_parse,1);
241
+			//$body_parse = trim($body_parse);
242
+			//$body_parse_len = strlen($body_parse);
243
+			if ($body_parse_len >= 7) {
244 244
 			
245
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
246
-		    	    $course = substr($body_parse,0,3);
247
-		    	    $tmp_s = intval($course);
248
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
249
-		    	    $speed = substr($body_parse,4,3);
250
-		    	    $result['speed'] = round($speed*1.852);
251
-		    	    $body_parse = substr($body_parse,7);
252
-		        }
253
-		        // Check PHGR, PHG, RNG
254
-		    } 
255
-		    /*
245
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
246
+					$course = substr($body_parse,0,3);
247
+					$tmp_s = intval($course);
248
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
249
+					$speed = substr($body_parse,4,3);
250
+					$result['speed'] = round($speed*1.852);
251
+					$body_parse = substr($body_parse,7);
252
+				}
253
+				// Check PHGR, PHG, RNG
254
+			} 
255
+			/*
256 256
 		    else if ($body_parse_len > 0) {
257 257
 			$rest = $body_parse;
258 258
 		    }
259 259
 		    */
260
-		    if (strlen($body_parse) > 0) {
261
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
262
-		            $altitude = intval($matches[1]);
263
-		            //$result['altitude'] = round($altitude*0.3048);
264
-		            $result['altitude'] = $altitude;
265
-		            $body_parse = trim(substr($body_parse,strlen($matches[0])));
266
-		        }
267
-		    }
260
+			if (strlen($body_parse) > 0) {
261
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
262
+					$altitude = intval($matches[1]);
263
+					//$result['altitude'] = round($altitude*0.3048);
264
+					$result['altitude'] = $altitude;
265
+					$body_parse = trim(substr($body_parse,strlen($matches[0])));
266
+				}
267
+			}
268 268
 		    
269
-		    // Telemetry
270
-		    /*
269
+			// Telemetry
270
+			/*
271 271
 		    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)) {
272 272
 		        // Nothing yet...
273 273
 		    }
274 274
 		    */
275
-		    // DAO
276
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
277
-			    $dao = $matches[1];
278
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
275
+			// DAO
276
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
277
+				$dao = $matches[1];
278
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
279 279
 				$dao_split = str_split($dao);
280
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
281
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
280
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
281
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
282 282
 			    
283 283
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
284 284
 				else $result['latitude'] += $lat_off;
285 285
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
286 286
 				else $result['longitude'] += $lon_off;
287
-			    }
288
-		            $body_parse = substr($body_parse,6);
289
-		    }
287
+				}
288
+					$body_parse = substr($body_parse,6);
289
+			}
290 290
 		    
291
-		    // OGN comment
291
+			// OGN comment
292 292
 		   // echo "Before OGN : ".$body_parse."\n";
293
-		    if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
293
+			if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
294 294
 			$id = $matches[1];
295 295
 			//$mode = substr($id,0,2);
296 296
 			$address = substr($id,2);
@@ -320,49 +320,49 @@  discard block
 block discarded – undo
320 320
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
321 321
 			$result['stealth'] = $stealth;
322 322
 			$result['address'] = $address;
323
-		    }
323
+			}
324 324
 		    
325
-		    //Comment
326
-		    $result['comment'] = trim($body_parse);
325
+			//Comment
326
+			$result['comment'] = trim($body_parse);
327 327
 		} else {
328
-		    // parse weather
329
-		    //$body_parse = substr($body_parse,1);
330
-		    //$body_parse_len = strlen($body_parse);
328
+			// parse weather
329
+			//$body_parse = substr($body_parse,1);
330
+			//$body_parse_len = strlen($body_parse);
331 331
 
332
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
333
-			    $result['wind_dir'] = intval($matches[1]);
334
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
335
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
336
-			    $result['temp'] = round(5/9*(($matches[4])-32),1);
337
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
338
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
332
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
333
+				$result['wind_dir'] = intval($matches[1]);
334
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
335
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
336
+				$result['temp'] = round(5/9*(($matches[4])-32),1);
337
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
338
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
339 339
 			$result['wind_dir'] = intval($matches[1]);
340 340
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
341 341
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
342 342
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
343
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
344
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
343
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
344
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
345 345
 			$result['wind_dir'] = intval($matches[1]);
346 346
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
347 347
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
348
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
349
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
348
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
349
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
350 350
 			$result['wind_dir'] = intval($matches[1]);
351 351
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
352 352
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
353
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
354
-		    }
355
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
353
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
354
+			}
355
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
356 356
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
357
-		    }
357
+			}
358
+		}
358 359
 		}
359
-	    }
360 360
 	//}
361 361
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
362 362
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
363 363
 	//print_r($result);
364 364
 	return $result;
365
-    }
365
+	}
366 366
 }
367 367
 /*
368 368
 $aprs = new aprs();
Please login to merge, or discard this patch.
Spacing   +60 added lines, -61 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 
87 87
     private function urshift($n, $s) {
88
-	return ($n >= 0) ? ($n >> $s) :
89
-    	    (($n & 0x7fffffff) >> $s) | 
88
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
90 89
         	(0x40000000 >> ($s - 1));
91 90
     }
92 91
 
@@ -98,7 +97,7 @@  discard block
 block discarded – undo
98 97
 	//$split_input = str_split($input);
99 98
 
100 99
 	/* Find the end of header checking for NULL bytes while doing it. */
101
-	$splitpos = strpos($input,':');
100
+	$splitpos = strpos($input, ':');
102 101
 	
103 102
 	/* Check that end was found and body has at least one byte. */
104 103
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -107,28 +106,28 @@  discard block
 block discarded – undo
107 106
 	}
108 107
 	
109 108
 	/* Save header and body. */
110
-	$body = substr($input,$splitpos+1,$input_len);
109
+	$body = substr($input, $splitpos + 1, $input_len);
111 110
 	$body_len = strlen($body);
112
-	$header = substr($input,0,$splitpos);
111
+	$header = substr($input, 0, $splitpos);
113 112
 	//$header_len = strlen($header);
114 113
 	if ($debug) echo 'header : '.$header."\n";
115 114
 	
116 115
 	/* Parse source, target and path. */
117 116
 	//FLRDF0A52>APRS,qAS,LSTB
118
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
117
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
119 118
 	    $ident = $matches[1];
120 119
 	    $all_elements = $matches[2];
121 120
 	    if ($debug) echo 'ident : '.$ident."\n";
122 121
 	    $result['ident'] = $ident;
123 122
 	} else return false;
124
-	$elements = explode(',',$all_elements);
123
+	$elements = explode(',', $all_elements);
125 124
 	$source = end($elements);
126 125
 	$result['source'] = $source;
127 126
 	foreach ($elements as $element) {
128
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
127
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
129 128
 	        //echo "ok";
130 129
 	        if ($element == 'TCPIP*') return false;
131
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
130
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
132 131
 		return false;
133 132
 	    }
134 133
 	    /*
@@ -141,24 +140,24 @@  discard block
 block discarded – undo
141 140
 	}
142 141
 	// Check for Timestamp
143 142
 	$find = false;
144
-	$body_parse = substr($body,1);
143
+	$body_parse = substr($body, 1);
145 144
 	//echo 'Body : '.$body."\n";
146
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
147
-	    $body_parse = substr($body_parse,10);
145
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
146
+	    $body_parse = substr($body_parse, 10);
148 147
 	    $find = true;
149 148
 	    //echo $body_parse."\n";
150 149
 	}
151
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
152
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
150
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
151
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
153 152
 	    $find = true;
154 153
 	    //echo $body_parse."\n";
155 154
 	}
156
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
157
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
155
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
156
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
158 157
 	    $find = true;
159 158
 	    //echo $body_parse."\n";
160 159
 	}
161
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
160
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
162 161
 	    $find = true;
163 162
 	    //print_r($matches);
164 163
 	    $timestamp = $matches[0];
@@ -173,12 +172,12 @@  discard block
 block discarded – undo
173 172
 		// This work or not ?
174 173
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
175 174
 	    }
176
-	    $body_parse = substr($body_parse,7);
175
+	    $body_parse = substr($body_parse, 7);
177 176
 	    $result['timestamp'] = $timestamp;
178 177
 	    //echo date('Ymd H:i:s',$timestamp);
179 178
 	}
180 179
 	//if (strlen($body_parse) > 19) {
181
-	    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)) {
180
+	    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)) {
182 181
 	    $find = true;
183 182
 		// 4658.70N/00707.78Ez
184 183
 		//print_r(str_split($body_parse));
@@ -204,11 +203,11 @@  discard block
 block discarded – undo
204 203
 	    */
205 204
 		$latitude = $lat + floatval($lat_min)/60;
206 205
 		$longitude = $lon + floatval($lon_min)/60;
207
-		if ($sind == 'S') $latitude = 0-$latitude;
208
-		if ($wind == 'W') $longitude = 0-$longitude;
206
+		if ($sind == 'S') $latitude = 0 - $latitude;
207
+		if ($wind == 'W') $longitude = 0 - $longitude;
209 208
 		$result['latitude'] = $latitude;
210 209
 		$result['longitude'] = $longitude;
211
-		$body_parse = substr($body_parse,18);
210
+		$body_parse = substr($body_parse, 18);
212 211
 		$body_parse_len = strlen($body_parse);
213 212
 	    }
214 213
 	    if ($body_len > 0) {
@@ -230,7 +229,7 @@  discard block
 block discarded – undo
230 229
 		*/
231 230
 			$body_split = str_split($body_parse);
232 231
 			$symbol_code = $body_split[0];
233
-			$body_parse = substr($body_parse,1);
232
+			$body_parse = substr($body_parse, 1);
234 233
 			$body_parse_len = strlen($body_parse);
235 234
 		//}
236 235
 		//echo $body_parse;
@@ -242,13 +241,13 @@  discard block
 block discarded – undo
242 241
 		    //$body_parse_len = strlen($body_parse);
243 242
 		    if ($body_parse_len >= 7) {
244 243
 			
245
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
246
-		    	    $course = substr($body_parse,0,3);
244
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
245
+		    	    $course = substr($body_parse, 0, 3);
247 246
 		    	    $tmp_s = intval($course);
248 247
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
249
-		    	    $speed = substr($body_parse,4,3);
248
+		    	    $speed = substr($body_parse, 4, 3);
250 249
 		    	    $result['speed'] = round($speed*1.852);
251
-		    	    $body_parse = substr($body_parse,7);
250
+		    	    $body_parse = substr($body_parse, 7);
252 251
 		        }
253 252
 		        // Check PHGR, PHG, RNG
254 253
 		    } 
@@ -258,11 +257,11 @@  discard block
 block discarded – undo
258 257
 		    }
259 258
 		    */
260 259
 		    if (strlen($body_parse) > 0) {
261
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
260
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
262 261
 		            $altitude = intval($matches[1]);
263 262
 		            //$result['altitude'] = round($altitude*0.3048);
264 263
 		            $result['altitude'] = $altitude;
265
-		            $body_parse = trim(substr($body_parse,strlen($matches[0])));
264
+		            $body_parse = trim(substr($body_parse, strlen($matches[0])));
266 265
 		        }
267 266
 		    }
268 267
 		    
@@ -273,34 +272,34 @@  discard block
 block discarded – undo
273 272
 		    }
274 273
 		    */
275 274
 		    // DAO
276
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
275
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
277 276
 			    $dao = $matches[1];
278
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
277
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
279 278
 				$dao_split = str_split($dao);
280
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
281
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
279
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
280
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
282 281
 			    
283 282
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
284 283
 				else $result['latitude'] += $lat_off;
285 284
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
286 285
 				else $result['longitude'] += $lon_off;
287 286
 			    }
288
-		            $body_parse = substr($body_parse,6);
287
+		            $body_parse = substr($body_parse, 6);
289 288
 		    }
290 289
 		    
291 290
 		    // OGN comment
292 291
 		   // echo "Before OGN : ".$body_parse."\n";
293
-		    if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
292
+		    if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/', $body_parse, $matches)) {
294 293
 			$id = $matches[1];
295 294
 			//$mode = substr($id,0,2);
296
-			$address = substr($id,2);
295
+			$address = substr($id, 2);
297 296
 			//print_r($matches);
298
-			$addressType = (intval(substr($id,0,2),16))&3;
297
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
299 298
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
300 299
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
301 300
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
302 301
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
303
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
302
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
304 303
 			$result['aircrafttype_code'] = $aircraftType;
305 304
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
306 305
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -317,7 +316,7 @@  discard block
 block discarded – undo
317 316
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
318 317
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
319 318
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
320
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
319
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
321 320
 			$result['stealth'] = $stealth;
322 321
 			$result['address'] = $address;
323 322
 		    }
@@ -329,37 +328,37 @@  discard block
 block discarded – undo
329 328
 		    //$body_parse = substr($body_parse,1);
330 329
 		    //$body_parse_len = strlen($body_parse);
331 330
 
332
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
331
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
333 332
 			    $result['wind_dir'] = intval($matches[1]);
334
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
335
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
336
-			    $result['temp'] = round(5/9*(($matches[4])-32),1);
337
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
338
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
333
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
334
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
335
+			    $result['temp'] = round(5/9*(($matches[4]) - 32), 1);
336
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
337
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
339 338
 			$result['wind_dir'] = intval($matches[1]);
340
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
341
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
342
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
343
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
344
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
339
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
340
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
341
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
342
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
343
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
345 344
 			$result['wind_dir'] = intval($matches[1]);
346
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
347
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
348
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
349
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
345
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
346
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
347
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
348
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
350 349
 			$result['wind_dir'] = intval($matches[1]);
351
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
352
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
353
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
350
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
351
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
352
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
354 353
 		    }
355
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
356
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
354
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
355
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
357 356
 		    }
358 357
 		}
359 358
 	    }
360 359
 	//}
361
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
362
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
360
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
361
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
363 362
 	//print_r($result);
364 363
 	return $result;
365 364
     }
Please login to merge, or discard this patch.
Braces   +86 added lines, -35 removed lines patch added patch discarded remove patch
@@ -102,7 +102,9 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
105
+	    if ($globalDebug) {
106
+	    	echo '!!! APRS invalid : '.$input."\n";
107
+	    }
106 108
 	    return false;
107 109
 	}
108 110
 	
@@ -111,23 +113,31 @@  discard block
 block discarded – undo
111 113
 	$body_len = strlen($body);
112 114
 	$header = substr($input,0,$splitpos);
113 115
 	//$header_len = strlen($header);
114
-	if ($debug) echo 'header : '.$header."\n";
116
+	if ($debug) {
117
+		echo 'header : '.$header."\n";
118
+	}
115 119
 	
116 120
 	/* Parse source, target and path. */
117 121
 	//FLRDF0A52>APRS,qAS,LSTB
118 122
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119 123
 	    $ident = $matches[1];
120 124
 	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
125
+	    if ($debug) {
126
+	    	echo 'ident : '.$ident."\n";
127
+	    }
122 128
 	    $result['ident'] = $ident;
123
-	} else return false;
129
+	} else {
130
+		return false;
131
+	}
124 132
 	$elements = explode(',',$all_elements);
125 133
 	$source = end($elements);
126 134
 	$result['source'] = $source;
127 135
 	foreach ($elements as $element) {
128 136
 	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129 137
 	        //echo "ok";
130
-	        if ($element == 'TCPIP*') return false;
138
+	        if ($element == 'TCPIP*') {
139
+	        	return false;
140
+	        }
131 141
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
132 142
 		return false;
133 143
 	    }
@@ -194,7 +204,9 @@  discard block
 block discarded – undo
194 204
 		//$symbol_table = $matches[4];
195 205
 		$lat = intval($lat_deg);
196 206
 		$lon = intval($lon_deg);
197
-		if ($lat > 89 || $lon > 179) return false;
207
+		if ($lat > 89 || $lon > 179) {
208
+			return false;
209
+		}
198 210
 	    
199 211
 	    /*
200 212
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -204,8 +216,12 @@  discard block
 block discarded – undo
204 216
 	    */
205 217
 		$latitude = $lat + floatval($lat_min)/60;
206 218
 		$longitude = $lon + floatval($lon_min)/60;
207
-		if ($sind == 'S') $latitude = 0-$latitude;
208
-		if ($wind == 'W') $longitude = 0-$longitude;
219
+		if ($sind == 'S') {
220
+			$latitude = 0-$latitude;
221
+		}
222
+		if ($wind == 'W') {
223
+			$longitude = 0-$longitude;
224
+		}
209 225
 		$result['latitude'] = $latitude;
210 226
 		$result['longitude'] = $longitude;
211 227
 		$body_parse = substr($body_parse,18);
@@ -235,7 +251,9 @@  discard block
 block discarded – undo
235 251
 		//}
236 252
 		//echo $body_parse;
237 253
 		$result['symbol_code'] = $symbol_code;
238
-		if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
254
+		if (isset($this->symbols[$symbol_code])) {
255
+			$result['symbol'] = $this->symbols[$symbol_code];
256
+		}
239 257
 		if ($symbol_code != '_') {
240 258
 		    //$body_parse = substr($body_parse,1);
241 259
 		    //$body_parse = trim($body_parse);
@@ -245,7 +263,9 @@  discard block
 block discarded – undo
245 263
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
246 264
 		    	    $course = substr($body_parse,0,3);
247 265
 		    	    $tmp_s = intval($course);
248
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
266
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
267
+		    	    	$result['heading'] = intval($course);
268
+		    	    }
249 269
 		    	    $speed = substr($body_parse,4,3);
250 270
 		    	    $result['speed'] = round($speed*1.852);
251 271
 		    	    $body_parse = substr($body_parse,7);
@@ -280,10 +300,16 @@  discard block
 block discarded – undo
280 300
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
281 301
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
282 302
 			    
283
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
284
-				else $result['latitude'] += $lat_off;
285
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
286
-				else $result['longitude'] += $lon_off;
303
+				if ($result['latitude'] < 0) {
304
+					$result['latitude'] -= $lat_off;
305
+				} else {
306
+					$result['latitude'] += $lat_off;
307
+				}
308
+				if ($result['longitude'] < 0) {
309
+					$result['longitude'] -= $lon_off;
310
+				} else {
311
+					$result['longitude'] += $lon_off;
312
+				}
287 313
 			    }
288 314
 		            $body_parse = substr($body_parse,6);
289 315
 		    }
@@ -296,27 +322,48 @@  discard block
 block discarded – undo
296 322
 			$address = substr($id,2);
297 323
 			//print_r($matches);
298 324
 			$addressType = (intval(substr($id,0,2),16))&3;
299
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
300
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
301
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
302
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
325
+			if ($addressType == 0) {
326
+				$result['addresstype'] = "RANDOM";
327
+			} elseif ($addressType == 1) {
328
+				$result['addresstype'] = "ICAO";
329
+			} elseif ($addressType == 2) {
330
+				$result['addresstype'] = "FLARM";
331
+			} elseif ($addressType == 3) {
332
+				$result['addresstype'] = "OGN";
333
+			}
303 334
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
304 335
 			$result['aircrafttype_code'] = $aircraftType;
305
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
306
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
307
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
308
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
309
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
310
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
311
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
312
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
313
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
314
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
315
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
316
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
317
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
318
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
319
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
336
+			if ($aircraftType == 0) {
337
+				$result['aircrafttype'] = "UNKNOWN";
338
+			} elseif ($aircraftType == 1) {
339
+				$result['aircrafttype'] = "GLIDER";
340
+			} elseif ($aircraftType == 2) {
341
+				$result['aircrafttype'] = "TOW_PLANE";
342
+			} elseif ($aircraftType == 3) {
343
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
344
+			} elseif ($aircraftType == 4) {
345
+				$result['aircrafttype'] = "PARACHUTE";
346
+			} elseif ($aircraftType == 5) {
347
+				$result['aircrafttype'] = "DROP_PLANE";
348
+			} elseif ($aircraftType == 6) {
349
+				$result['aircrafttype'] = "HANG_GLIDER";
350
+			} elseif ($aircraftType == 7) {
351
+				$result['aircrafttype'] = "PARA_GLIDER";
352
+			} elseif ($aircraftType == 8) {
353
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
354
+			} elseif ($aircraftType == 9) {
355
+				$result['aircrafttype'] = "JET_AIRCRAFT";
356
+			} elseif ($aircraftType == 10) {
357
+				$result['aircrafttype'] = "UFO";
358
+			} elseif ($aircraftType == 11) {
359
+				$result['aircrafttype'] = "BALLOON";
360
+			} elseif ($aircraftType == 12) {
361
+				$result['aircrafttype'] = "AIRSHIP";
362
+			} elseif ($aircraftType == 13) {
363
+				$result['aircrafttype'] = "UAV";
364
+			} elseif ($aircraftType == 15) {
365
+				$result['aircrafttype'] = "STATIC_OBJECT";
366
+			}
320 367
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
321 368
 			$result['stealth'] = $stealth;
322 369
 			$result['address'] = $address;
@@ -358,8 +405,12 @@  discard block
 block discarded – undo
358 405
 		}
359 406
 	    }
360 407
 	//}
361
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
362
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
408
+	if (isset($result['latitude'])) {
409
+		$result['latitude'] = round($result['latitude'],4);
410
+	}
411
+	if (isset($result['longitude'])) {
412
+		$result['longitude'] = round($result['longitude'],4);
413
+	}
363 414
 	//print_r($result);
364 415
 	return $result;
365 416
     }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +695 added lines, -695 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
26
+	echo "This script MUST be called from console, not a web browser.";
27 27
 //    exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -84,162 +84,162 @@  discard block
 block discarded – undo
84 84
 $reset = 0;
85 85
 
86 86
 function create_socket($host, $port, &$errno, &$errstr) {
87
-    $ip = gethostbyname($host);
88
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
89
-    $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
-        return $s;
93
-    }
94
-    $errno = socket_last_error($s);
95
-    $errstr = socket_strerror($errno);
96
-    socket_close($s);
97
-    return false;
87
+	$ip = gethostbyname($host);
88
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
89
+	$r = @socket_connect($s, $ip, $port);
90
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
+		return $s;
93
+	}
94
+	$errno = socket_last_error($s);
95
+	$errstr = socket_strerror($errno);
96
+	socket_close($s);
97
+	return false;
98 98
 }
99 99
 
100 100
 function create_socket_udp($host, $port, &$errno, &$errstr) {
101
-    echo "Create an UDP socket...\n";
102
-    $ip = gethostbyname($host);
103
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
-    $r = @socket_bind($s, $ip, $port);
105
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
-        return $s;
107
-    }
108
-    $errno = socket_last_error($s);
109
-    $errstr = socket_strerror($errno);
110
-    socket_close($s);
111
-    return false;
101
+	echo "Create an UDP socket...\n";
102
+	$ip = gethostbyname($host);
103
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
+	$r = @socket_bind($s, $ip, $port);
105
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
+		return $s;
107
+	}
108
+	$errno = socket_last_error($s);
109
+	$errstr = socket_strerror($errno);
110
+	socket_close($s);
111
+	return false;
112 112
 }
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
-        	//$formats[$id] = 'radarvirtueljson';
146
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
147
-        	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
-        	    exit(0);
152
-        	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
-        	//$formats[$id] = 'planeupdatefaa';
155
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
156
-        	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
-        	    exit(0);
161
-        	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'phpvmacars';
165
-        	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
-        	//$formats[$id] = 'phpvmacars';
169
-        	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
172
-        	//$formats[$id] = 'whazzup';
173
-        	$globalSources[$id]['format'] = 'whazzup';
174
-        	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
177
-        	//$formats[$id] = 'pirepsjson';
178
-        	$globalSources[$id]['format'] = 'pirepsjson';
179
-        	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
-        	//$formats[$id] = 'fr24json';
183
-        	$globalSources[$id]['format'] = 'fr24json';
184
-        	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
-        	    exit(0);
189
-        	}
190
-            //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
-        	//$formats[$id] = 'tsv';
193
-        	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
-            }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
200
-	    if (isset($hostport[1])) {
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
+			//$formats[$id] = 'radarvirtueljson';
146
+			$globalSources[$id]['format'] = 'radarvirtueljson';
147
+			//$last_exec['radarvirtueljson'] = 0;
148
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
+				exit(0);
152
+			}
153
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+			//$formats[$id] = 'planeupdatefaa';
155
+			$globalSources[$id]['format'] = 'planeupdatefaa';
156
+			//$last_exec['planeupdatefaa'] = 0;
157
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
+				exit(0);
161
+			}
162
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'phpvmacars';
165
+			//$last_exec['phpvmacars'] = 0;
166
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
168
+			//$formats[$id] = 'phpvmacars';
169
+			$globalSources[$id]['format'] = 'vam';
170
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
+			} else if (preg_match('/whazzup/i',$host)) {
172
+			//$formats[$id] = 'whazzup';
173
+			$globalSources[$id]['format'] = 'whazzup';
174
+			//$last_exec['whazzup'] = 0;
175
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
+			} else if (preg_match('/recentpireps/i',$host)) {
177
+			//$formats[$id] = 'pirepsjson';
178
+			$globalSources[$id]['format'] = 'pirepsjson';
179
+			//$last_exec['pirepsjson'] = 0;
180
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+			//$formats[$id] = 'fr24json';
183
+			$globalSources[$id]['format'] = 'fr24json';
184
+			//$last_exec['fr24json'] = 0;
185
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
+				exit(0);
189
+			}
190
+			//} else if (preg_match('/10001/',$host)) {
191
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
+			//$formats[$id] = 'tsv';
193
+			$globalSources[$id]['format'] = 'tsv';
194
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
+			}
196
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
+		$hostport = explode(':',$host);
200
+		if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
203
-	    } else {
203
+		} else {
204 204
 		$port = $globalSources[$id]['port'];
205 205
 		$hostn = $globalSources[$id]['host'];
206
-	    }
207
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
209
-    	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
-	    }
212
-	    if ($s) {
213
-    	        $sockets[$id] = $s;
214
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
206
+		}
207
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
+			$s = create_socket($hostn,$port, $errno, $errstr);
209
+			} else {
210
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
+		}
212
+		if ($s) {
213
+				$sockets[$id] = $s;
214
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
+			if (preg_match('/aprs/',$hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
219 219
 			//$use_aprs = true;
220
-    		    } elseif ($port == '10001') {
221
-        		//$formats[$id] = 'tsv';
222
-        		$globalSources[$id]['format'] = 'tsv';
223
-		    } elseif ($port == '30002') {
224
-        		//$formats[$id] = 'raw';
225
-        		$globalSources[$id]['format'] = 'raw';
226
-		    } elseif ($port == '5001') {
227
-        		//$formats[$id] = 'raw';
228
-        		$globalSources[$id]['format'] = 'flightgearmp';
229
-		    } elseif ($port == '30005') {
220
+				} elseif ($port == '10001') {
221
+				//$formats[$id] = 'tsv';
222
+				$globalSources[$id]['format'] = 'tsv';
223
+			} elseif ($port == '30002') {
224
+				//$formats[$id] = 'raw';
225
+				$globalSources[$id]['format'] = 'raw';
226
+			} elseif ($port == '5001') {
227
+				//$formats[$id] = 'raw';
228
+				$globalSources[$id]['format'] = 'flightgearmp';
229
+			} elseif ($port == '30005') {
230 230
 			// Not yet supported
231
-        		//$formats[$id] = 'beast';
232
-        		$globalSources[$id]['format'] = 'beast';
233
-		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
235
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231
+				//$formats[$id] = 'beast';
232
+				$globalSources[$id]['format'] = 'beast';
233
+			//} else $formats[$id] = 'sbs';
234
+			} else $globalSources[$id]['format'] = 'sbs';
235
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 236
 		}
237 237
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
238
-            } else {
238
+			} else {
239 239
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
240
-    	    }
241
-        }
242
-    }
240
+			}
241
+		}
242
+	}
243 243
 }
244 244
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
245 245
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	die;
267 267
 }
268 268
 foreach ($globalSources as $key => $source) {
269
-    if (!isset($source['format'])) {
270
-        $globalSources[$key]['format'] = 'auto';
271
-    }
269
+	if (!isset($source['format'])) {
270
+		$globalSources[$key]['format'] = 'auto';
271
+	}
272 272
 }
273 273
 connect_all($globalSources);
274 274
 foreach ($globalSources as $key => $source) {
275
-    if (isset($source['format']) && $source['format'] == 'aprs') {
275
+	if (isset($source['format']) && $source['format'] == 'aprs') {
276 276
 	$aprs_connect = 0;
277 277
 	$use_aprs = true;
278 278
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
279 279
 	break;
280
-    }
280
+	}
281 281
 }
282 282
 
283 283
 if ($use_aprs) {
@@ -316,70 +316,70 @@  discard block
 block discarded – undo
316 316
 
317 317
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 318
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
320
-    // Delete old ATC
321
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
319
+	if (!$globalDaemon) $i = $endtime-time();
320
+	// Delete old ATC
321
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322 322
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
323
-        $ATC->deleteOldATC();
324
-    }
323
+		$ATC->deleteOldATC();
324
+	}
325 325
     
326
-    if (count($last_exec) > 0) {
326
+	if (count($last_exec) > 0) {
327 327
 	$max = $globalMinFetch;
328 328
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
329
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
330 330
 	}
331 331
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
333
-	    sleep($globalMinFetch-$max+2);
332
+		if ($globalDebug) echo 'Sleeping...'."\n";
333
+		sleep($globalMinFetch-$max+2);
334
+	}
334 335
 	}
335
-    }
336 336
 
337 337
     
338
-    //foreach ($formats as $id => $value) {
339
-    foreach ($globalSources as $id => $value) {
338
+	//foreach ($formats as $id => $value) {
339
+	foreach ($globalSources as $id => $value) {
340 340
 	date_default_timezone_set('UTC');
341 341
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
342 342
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343
-	    //$buffer = $Common->getData($hosts[$id]);
344
-	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
348
-	    foreach ($buffer as $line) {
349
-    		if ($line != '' && count($line) > 7) {
350
-    		    $line = explode(',', $line);
351
-	            $data = array();
352
-	            $data['hex'] = $line[1]; // hex
353
-	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
-	            $data['verticalrate'] = ''; // vertical rate
360
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
-	            $data['emergency'] = ''; // emergency
362
-		    $data['datetime'] = date('Y-m-d H:i:s');
363
-		    $data['format_source'] = 'deltadbtxt';
364
-    		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
-    		    $SI->add($data);
368
-		    unset($data);
369
-    		}
370
-    	    }
371
-    	    $last_exec[$id]['last'] = time();
343
+		//$buffer = $Common->getData($hosts[$id]);
344
+		$buffer = $Common->getData($value['host']);
345
+		if ($buffer != '') $reset = 0;
346
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
+		$buffer = explode('\n',$buffer);
348
+		foreach ($buffer as $line) {
349
+			if ($line != '' && count($line) > 7) {
350
+				$line = explode(',', $line);
351
+				$data = array();
352
+				$data['hex'] = $line[1]; // hex
353
+				$data['ident'] = $line[2]; // ident
354
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
+				$data['verticalrate'] = ''; // vertical rate
360
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
+				$data['emergency'] = ''; // emergency
362
+			$data['datetime'] = date('Y-m-d H:i:s');
363
+			$data['format_source'] = 'deltadbtxt';
364
+				$data['id_source'] = $id_source;
365
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
+				$SI->add($data);
368
+			unset($data);
369
+			}
370
+			}
371
+			$last_exec[$id]['last'] = time();
372 372
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374
-	    //$buffer = $Common->getData($hosts[$id]);
375
-	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    $reset = 0;
379
-	    foreach ($buffer as $line) {
380
-    		if ($line != '') {
381
-    		    $line = explode(':', $line);
382
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
374
+		//$buffer = $Common->getData($hosts[$id]);
375
+		$buffer = $Common->getData($value['host']);
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		$reset = 0;
379
+		foreach ($buffer as $line) {
380
+			if ($line != '') {
381
+				$line = explode(':', $line);
382
+				if (count($line) > 30 && $line[0] != 'callsign') {
383 383
 			$data = array();
384 384
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385 385
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -392,36 +392,36 @@  discard block
 block discarded – undo
392 392
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393 393
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
394 394
 			$data['latitude'] = $line[5]; // lat
395
-	        	$data['longitude'] = $line[6]; // long
396
-	        	$data['verticalrate'] = ''; // vertical rate
397
-	        	$data['squawk'] = ''; // squawk
398
-	        	$data['emergency'] = ''; // emergency
399
-	        	$data['waypoints'] = $line[30];
395
+				$data['longitude'] = $line[6]; // long
396
+				$data['verticalrate'] = ''; // vertical rate
397
+				$data['squawk'] = ''; // squawk
398
+				$data['emergency'] = ''; // emergency
399
+				$data['waypoints'] = $line[30];
400 400
 			$data['datetime'] = date('Y-m-d H:i:s');
401 401
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
402 402
 			//if (isset($line[37])) $data['last_update'] = $line[37];
403
-		        $data['departure_airport_icao'] = $line[11];
404
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
-		        $data['arrival_airport_icao'] = $line[13];
403
+				$data['departure_airport_icao'] = $line[11];
404
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
+				$data['arrival_airport_icao'] = $line[13];
406 406
 			$data['frequency'] = $line[4];
407 407
 			$data['type'] = $line[18];
408 408
 			$data['range'] = $line[19];
409 409
 			if (isset($line[35])) $data['info'] = $line[35];
410
-    			$data['id_source'] = $id_source;
411
-	    		//$data['arrival_airport_time'] = ;
412
-	    		if ($line[9] != '') {
413
-	    		    $aircraft_data = explode('/',$line[9]);
414
-	    		    if (isset($aircraft_data[1])) {
415
-	    			$data['aircraft_icao'] = $aircraft_data[1];
416
-	    		    }
417
-        		}
418
-	    		/*
410
+				$data['id_source'] = $id_source;
411
+				//$data['arrival_airport_time'] = ;
412
+				if ($line[9] != '') {
413
+					$aircraft_data = explode('/',$line[9]);
414
+					if (isset($aircraft_data[1])) {
415
+					$data['aircraft_icao'] = $aircraft_data[1];
416
+					}
417
+				}
418
+				/*
419 419
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
420 420
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 421
 	    		*/
422
-	    		$data['format_source'] = $value['format'];
422
+				$data['format_source'] = $value['format'];
423 423
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
424
+				if ($line[3] == 'PILOT') $SI->add($data);
425 425
 			elseif ($line[3] == 'ATC') {
426 426
 				//print_r($data);
427 427
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -439,247 +439,247 @@  discard block
 block discarded – undo
439 439
 				if (!isset($data['source_name'])) $data['source_name'] = '';
440 440
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
441 441
 			}
442
-    			unset($data);
443
-    		    }
444
-    		}
445
-    	    }
446
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
447
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
448
-    	    $last_exec[$id]['last'] = time();
449
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
452
-	    if ($buffer != '') {
453
-	    $all_data = json_decode($buffer,true);
454
-	    if (isset($all_data['acList'])) {
442
+				unset($data);
443
+				}
444
+			}
445
+			}
446
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
447
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
448
+			$last_exec[$id]['last'] = time();
449
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
452
+		if ($buffer != '') {
453
+		$all_data = json_decode($buffer,true);
454
+		if (isset($all_data['acList'])) {
455 455
 		$reset = 0;
456 456
 		foreach ($all_data['acList'] as $line) {
457
-		    $data = array();
458
-		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
465
-		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
467
-		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
469
-		    /*
457
+			$data = array();
458
+			$data['hex'] = $line['Icao']; // hex
459
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
465
+			//$data['verticalrate'] = $line['']; // verticale rate
466
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
467
+			$data['emergency'] = ''; // emergency
468
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
469
+			/*
470 470
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 471
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 472
 		    */
473
-		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
475
-	    	    $data['format_source'] = 'aircraftlistjson';
476
-		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
479
-		    unset($data);
473
+			$data['datetime'] = date('Y-m-d H:i:s');
474
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
475
+				$data['format_source'] = 'aircraftlistjson';
476
+			$data['id_source'] = $id_source;
477
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
+			if (isset($data['datetime'])) $SI->add($data);
479
+			unset($data);
480 480
 		}
481
-	    } else {
481
+		} else {
482 482
 		$reset = 0;
483 483
 		foreach ($all_data as $line) {
484
-		    $data = array();
485
-		    $data['hex'] = $line['hex']; // hex
486
-		    $data['ident'] = $line['flight']; // ident
487
-		    $data['altitude'] = $line['altitude']; // altitude
488
-		    $data['speed'] = $line['speed']; // speed
489
-		    $data['heading'] = $line['track']; // heading
490
-		    $data['latitude'] = $line['lat']; // lat
491
-		    $data['longitude'] = $line['lon']; // long
492
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
493
-		    $data['squawk'] = $line['squawk']; // squawk
494
-		    $data['emergency'] = ''; // emergency
495
-		    $data['datetime'] = date('Y-m-d H:i:s');
496
-	    	    $data['format_source'] = 'aircraftlistjson';
497
-    		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
499
-		    $SI->add($data);
500
-		    unset($data);
484
+			$data = array();
485
+			$data['hex'] = $line['hex']; // hex
486
+			$data['ident'] = $line['flight']; // ident
487
+			$data['altitude'] = $line['altitude']; // altitude
488
+			$data['speed'] = $line['speed']; // speed
489
+			$data['heading'] = $line['track']; // heading
490
+			$data['latitude'] = $line['lat']; // lat
491
+			$data['longitude'] = $line['lon']; // long
492
+			$data['verticalrate'] = $line['vrt']; // verticale rate
493
+			$data['squawk'] = $line['squawk']; // squawk
494
+			$data['emergency'] = ''; // emergency
495
+			$data['datetime'] = date('Y-m-d H:i:s');
496
+				$data['format_source'] = 'aircraftlistjson';
497
+				$data['id_source'] = $id_source;
498
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
499
+			$SI->add($data);
500
+			unset($data);
501
+		}
501 502
 		}
502
-	    }
503
-	    }
504
-    	    //$last_exec['aircraftlistjson'] = time();
505
-    	    $last_exec[$id]['last'] = time();
506
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508
-	    $buffer = $Common->getData($value['host']);
509
-	    $all_data = json_decode($buffer,true);
510
-	    if (isset($all_data['planes'])) {
503
+		}
504
+			//$last_exec['aircraftlistjson'] = time();
505
+			$last_exec[$id]['last'] = time();
506
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508
+		$buffer = $Common->getData($value['host']);
509
+		$all_data = json_decode($buffer,true);
510
+		if (isset($all_data['planes'])) {
511 511
 		$reset = 0;
512 512
 		foreach ($all_data['planes'] as $key => $line) {
513
-		    $data = array();
514
-		    $data['hex'] = $key; // hex
515
-		    $data['ident'] = $line[3]; // ident
516
-		    $data['altitude'] = $line[6]; // altitude
517
-		    $data['speed'] = $line[8]; // speed
518
-		    $data['heading'] = $line[7]; // heading
519
-		    $data['latitude'] = $line[4]; // lat
520
-		    $data['longitude'] = $line[5]; // long
521
-		    //$data['verticalrate'] = $line[]; // verticale rate
522
-		    $data['squawk'] = $line[10]; // squawk
523
-		    $data['emergency'] = ''; // emergency
524
-		    $data['registration'] = $line[2];
525
-		    $data['aircraft_icao'] = $line[0];
526
-		    $deparr = explode('-',$line[1]);
527
-		    if (count($deparr) == 2) {
513
+			$data = array();
514
+			$data['hex'] = $key; // hex
515
+			$data['ident'] = $line[3]; // ident
516
+			$data['altitude'] = $line[6]; // altitude
517
+			$data['speed'] = $line[8]; // speed
518
+			$data['heading'] = $line[7]; // heading
519
+			$data['latitude'] = $line[4]; // lat
520
+			$data['longitude'] = $line[5]; // long
521
+			//$data['verticalrate'] = $line[]; // verticale rate
522
+			$data['squawk'] = $line[10]; // squawk
523
+			$data['emergency'] = ''; // emergency
524
+			$data['registration'] = $line[2];
525
+			$data['aircraft_icao'] = $line[0];
526
+			$deparr = explode('-',$line[1]);
527
+			if (count($deparr) == 2) {
528 528
 			$data['departure_airport_icao'] = $deparr[0];
529 529
 			$data['arrival_airport_icao'] = $deparr[1];
530
-		    }
531
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
-	    	    $data['format_source'] = 'planeupdatefaa';
533
-    		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
535
-		    $SI->add($data);
536
-		    unset($data);
530
+			}
531
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
+				$data['format_source'] = 'planeupdatefaa';
533
+				$data['id_source'] = $id_source;
534
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
535
+			$SI->add($data);
536
+			unset($data);
537
+		}
537 538
 		}
538
-	    }
539
-    	    //$last_exec['planeupdatefaa'] = time();
540
-    	    $last_exec[$id]['last'] = time();
541
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542
-	    $buffer = $Common->getData($value['host']);
543
-	    $all_data = json_decode($buffer,true);
544
-	    if (isset($all_data['states'])) {
539
+			//$last_exec['planeupdatefaa'] = time();
540
+			$last_exec[$id]['last'] = time();
541
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542
+		$buffer = $Common->getData($value['host']);
543
+		$all_data = json_decode($buffer,true);
544
+		if (isset($all_data['states'])) {
545 545
 		$reset = 0;
546 546
 		foreach ($all_data['states'] as $key => $line) {
547
-		    $data = array();
548
-		    $data['hex'] = $line[0]; // hex
549
-		    $data['ident'] = trim($line[1]); // ident
550
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
551
-		    $data['speed'] = round($line[9]*1.94384); // speed
552
-		    $data['heading'] = round($line[10]); // heading
553
-		    $data['latitude'] = $line[5]; // lat
554
-		    $data['longitude'] = $line[6]; // long
555
-		    $data['verticalrate'] = $line[11]; // verticale rate
556
-		    //$data['squawk'] = $line[10]; // squawk
557
-		    //$data['emergency'] = ''; // emergency
558
-		    //$data['registration'] = $line[2];
559
-		    //$data['aircraft_icao'] = $line[0];
560
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
-	    	    $data['format_source'] = 'opensky';
562
-    		    $data['id_source'] = $id_source;
563
-		    $SI->add($data);
564
-		    unset($data);
547
+			$data = array();
548
+			$data['hex'] = $line[0]; // hex
549
+			$data['ident'] = trim($line[1]); // ident
550
+			$data['altitude'] = round($line[7]*3.28084); // altitude
551
+			$data['speed'] = round($line[9]*1.94384); // speed
552
+			$data['heading'] = round($line[10]); // heading
553
+			$data['latitude'] = $line[5]; // lat
554
+			$data['longitude'] = $line[6]; // long
555
+			$data['verticalrate'] = $line[11]; // verticale rate
556
+			//$data['squawk'] = $line[10]; // squawk
557
+			//$data['emergency'] = ''; // emergency
558
+			//$data['registration'] = $line[2];
559
+			//$data['aircraft_icao'] = $line[0];
560
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
+				$data['format_source'] = 'opensky';
562
+				$data['id_source'] = $id_source;
563
+			$SI->add($data);
564
+			unset($data);
565
+		}
565 566
 		}
566
-	    }
567
-    	    //$last_exec['planeupdatefaa'] = time();
568
-    	    $last_exec[$id]['last'] = time();
569
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
570
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571
-	    //$buffer = $Common->getData($hosts[$id]);
572
-	    $buffer = $Common->getData($value['host']);
573
-	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
575
-	    foreach ($all_data as $key => $line) {
567
+			//$last_exec['planeupdatefaa'] = time();
568
+			$last_exec[$id]['last'] = time();
569
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
570
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571
+		//$buffer = $Common->getData($hosts[$id]);
572
+		$buffer = $Common->getData($value['host']);
573
+		$all_data = json_decode($buffer,true);
574
+		if (!empty($all_data)) $reset = 0;
575
+		foreach ($all_data as $key => $line) {
576 576
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577
-		    $data = array();
578
-		    $data['hex'] = $line[0];
579
-		    $data['ident'] = $line[16]; //$line[13]
580
-	    	    $data['altitude'] = $line[4]; // altitude
581
-	    	    $data['speed'] = $line[5]; // speed
582
-	    	    $data['heading'] = $line[3]; // heading
583
-	    	    $data['latitude'] = $line[1]; // lat
584
-	    	    $data['longitude'] = $line[2]; // long
585
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
586
-	    	    $data['squawk'] = $line[6]; // squawk
587
-	    	    $data['aircraft_icao'] = $line[8];
588
-	    	    $data['registration'] = $line[9];
589
-		    $data['departure_airport_iata'] = $line[11];
590
-		    $data['arrival_airport_iata'] = $line[12];
591
-	    	    $data['emergency'] = ''; // emergency
592
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593
-	    	    $data['format_source'] = 'fr24json';
594
-    		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
596
-		    $SI->add($data);
597
-		    unset($data);
577
+			$data = array();
578
+			$data['hex'] = $line[0];
579
+			$data['ident'] = $line[16]; //$line[13]
580
+				$data['altitude'] = $line[4]; // altitude
581
+				$data['speed'] = $line[5]; // speed
582
+				$data['heading'] = $line[3]; // heading
583
+				$data['latitude'] = $line[1]; // lat
584
+				$data['longitude'] = $line[2]; // long
585
+				$data['verticalrate'] = $line[15]; // verticale rate
586
+				$data['squawk'] = $line[6]; // squawk
587
+				$data['aircraft_icao'] = $line[8];
588
+				$data['registration'] = $line[9];
589
+			$data['departure_airport_iata'] = $line[11];
590
+			$data['arrival_airport_iata'] = $line[12];
591
+				$data['emergency'] = ''; // emergency
592
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593
+				$data['format_source'] = 'fr24json';
594
+				$data['id_source'] = $id_source;
595
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
596
+			$SI->add($data);
597
+			unset($data);
598
+		}
598 599
 		}
599
-	    }
600
-    	    //$last_exec['fr24json'] = time();
601
-    	    $last_exec[$id]['last'] = time();
602
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
606
-	    //echo $buffer;
607
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
608
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
-	    $all_data = json_decode($buffer,true);
610
-	    if (json_last_error() != JSON_ERROR_NONE) {
600
+			//$last_exec['fr24json'] = time();
601
+			$last_exec[$id]['last'] = time();
602
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
606
+		//echo $buffer;
607
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
608
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
+		$all_data = json_decode($buffer,true);
610
+		if (json_last_error() != JSON_ERROR_NONE) {
611 611
 		die(json_last_error_msg());
612
-	    }
613
-	    if (isset($all_data['mrkrs'])) {
612
+		}
613
+		if (isset($all_data['mrkrs'])) {
614 614
 		$reset = 0;
615 615
 		foreach ($all_data['mrkrs'] as $key => $line) {
616
-		    if (isset($line['inf'])) {
616
+			if (isset($line['inf'])) {
617 617
 			$data = array();
618 618
 			$data['hex'] = $line['inf']['ia'];
619 619
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
620
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
623
-	    		$data['latitude'] = $line['pt'][0]; // lat
624
-	    		$data['longitude'] = $line['pt'][1]; // long
625
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
627
-	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
620
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
623
+				$data['latitude'] = $line['pt'][0]; // lat
624
+				$data['longitude'] = $line['pt'][1]; // long
625
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
627
+				//$data['aircraft_icao'] = $line[8];
628
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
629 629
 			//$data['departure_airport_iata'] = $line[11];
630 630
 			//$data['arrival_airport_iata'] = $line[12];
631
-	    		//$data['emergency'] = ''; // emergency
631
+				//$data['emergency'] = ''; // emergency
632 632
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633
-	    		$data['format_source'] = 'radarvirtueljson';
634
-    			$data['id_source'] = $id_source;
633
+				$data['format_source'] = 'radarvirtueljson';
634
+				$data['id_source'] = $id_source;
635 635
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
636 636
 			$SI->add($data);
637 637
 			unset($data);
638
-		    }
638
+			}
639
+		}
639 640
 		}
640
-	    }
641
-    	    //$last_exec['radarvirtueljson'] = time();
642
-    	    $last_exec[$id]['last'] = time();
643
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
644
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645
-	    //$buffer = $Common->getData($hosts[$id]);
646
-	    $buffer = $Common->getData($value['host'].'?'.time());
647
-	    $all_data = json_decode(utf8_encode($buffer),true);
641
+			//$last_exec['radarvirtueljson'] = time();
642
+			$last_exec[$id]['last'] = time();
643
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
644
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645
+		//$buffer = $Common->getData($hosts[$id]);
646
+		$buffer = $Common->getData($value['host'].'?'.time());
647
+		$all_data = json_decode(utf8_encode($buffer),true);
648 648
 	    
649
-	    if (isset($all_data['pireps'])) {
649
+		if (isset($all_data['pireps'])) {
650 650
 		$reset = 0;
651
-	        foreach ($all_data['pireps'] as $line) {
652
-		    $data = array();
653
-		    $data['id'] = $line['id'];
654
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
-		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
662
-		    $data['latitude'] = $line['lat']; // lat
663
-		    $data['longitude'] = $line['lon']; // long
664
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665
-		    //$data['squawk'] = $line['squawk']; // squawk
666
-		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
670
-		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
675
-		    $data['format_source'] = 'pireps';
676
-    		    $data['id_source'] = $id_source;
677
-		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
-		    if ($line['icon'] == 'plane') {
651
+			foreach ($all_data['pireps'] as $line) {
652
+			$data = array();
653
+			$data['id'] = $line['id'];
654
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
+			$data['ident'] = $line['callsign']; // ident
656
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
662
+			$data['latitude'] = $line['lat']; // lat
663
+			$data['longitude'] = $line['lon']; // long
664
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
665
+			//$data['squawk'] = $line['squawk']; // squawk
666
+			//$data['emergency'] = ''; // emergency
667
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
670
+			//$data['arrival_airport_time'] = $line['arrtime'];
671
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
674
+			else $data['info'] = '';
675
+			$data['format_source'] = 'pireps';
676
+				$data['id_source'] = $id_source;
677
+			$data['datetime'] = date('Y-m-d H:i:s');
678
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
+			if ($line['icon'] == 'plane') {
680 680
 			$SI->add($data);
681
-		    //    print_r($data);
682
-    		    } elseif ($line['icon'] == 'ct') {
681
+			//    print_r($data);
682
+				} elseif ($line['icon'] == 'ct') {
683 683
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
684 684
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 685
 			$typec = substr($data['ident'],-3);
@@ -694,163 +694,163 @@  discard block
 block discarded – undo
694 694
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695 695
 			else $data['type'] = 'Observer';
696 696
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
697
-		    }
698
-		    unset($data);
697
+			}
698
+			unset($data);
699
+		}
699 700
 		}
700
-	    }
701
-    	    //$last_exec['pirepsjson'] = time();
702
-    	    $last_exec[$id]['last'] = time();
703
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
-	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
707
-	    $buffer = $Common->getData($value['host']);
708
-	    $all_data = json_decode($buffer,true);
709
-	    if ($buffer != '' && is_array($all_data)) {
701
+			//$last_exec['pirepsjson'] = time();
702
+			$last_exec[$id]['last'] = time();
703
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
+		//$buffer = $Common->getData($hosts[$id]);
706
+		if ($globalDebug) echo 'Get Data...'."\n";
707
+		$buffer = $Common->getData($value['host']);
708
+		$all_data = json_decode($buffer,true);
709
+		if ($buffer != '' && is_array($all_data)) {
710 710
 		$reset = 0;
711 711
 		foreach ($all_data as $line) {
712
-	    	    $data = array();
713
-	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718
-	    	    $data['ident'] = $line['flightnum']; // ident
719
-	    	    $data['altitude'] = $line['alt']; // altitude
720
-	    	    $data['speed'] = $line['gs']; // speed
721
-	    	    $data['heading'] = $line['heading']; // heading
722
-	    	    $data['latitude'] = $line['lat']; // lat
723
-	    	    $data['longitude'] = $line['lng']; // long
724
-	    	    $data['verticalrate'] = ''; // verticale rate
725
-	    	    $data['squawk'] = ''; // squawk
726
-	    	    $data['emergency'] = ''; // emergency
727
-	    	    //$data['datetime'] = $line['lastupdate'];
728
-	    	    $data['last_update'] = $line['lastupdate'];
729
-		    $data['datetime'] = date('Y-m-d H:i:s');
730
-	    	    $data['departure_airport_icao'] = $line['depicao'];
731
-	    	    $data['departure_airport_time'] = $line['deptime'];
732
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
733
-    		    $data['arrival_airport_time'] = $line['arrtime'];
734
-    		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736
-		    if (isset($line['aircraftname'])) {
712
+				$data = array();
713
+				//$data['id'] = $line['id']; // id not usable
714
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718
+				$data['ident'] = $line['flightnum']; // ident
719
+				$data['altitude'] = $line['alt']; // altitude
720
+				$data['speed'] = $line['gs']; // speed
721
+				$data['heading'] = $line['heading']; // heading
722
+				$data['latitude'] = $line['lat']; // lat
723
+				$data['longitude'] = $line['lng']; // long
724
+				$data['verticalrate'] = ''; // verticale rate
725
+				$data['squawk'] = ''; // squawk
726
+				$data['emergency'] = ''; // emergency
727
+				//$data['datetime'] = $line['lastupdate'];
728
+				$data['last_update'] = $line['lastupdate'];
729
+			$data['datetime'] = date('Y-m-d H:i:s');
730
+				$data['departure_airport_icao'] = $line['depicao'];
731
+				$data['departure_airport_time'] = $line['deptime'];
732
+				$data['arrival_airport_icao'] = $line['arricao'];
733
+				$data['arrival_airport_time'] = $line['arrtime'];
734
+				$data['registration'] = $line['aircraft'];
735
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736
+			if (isset($line['aircraftname'])) {
737 737
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 738
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739
-	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
743
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
746
-	    		}
747
-	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
749
-    		    $data['id_source'] = $id_source;
750
-	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
752
-		    $SI->add($data);
753
-		    unset($data);
739
+				$aircraft_data = explode('-',$line['aircraftname']);
740
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
+				else {
743
+					$aircraft_data = explode(' ',$line['aircraftname']);
744
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
+					else $data['aircraft_icao'] = $line['aircraftname'];
746
+				}
747
+				}
748
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
749
+				$data['id_source'] = $id_source;
750
+				$data['format_source'] = 'phpvmacars';
751
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
752
+			$SI->add($data);
753
+			unset($data);
754 754
 		}
755 755
 		if ($globalDebug) echo 'No more data...'."\n";
756 756
 		unset($buffer);
757 757
 		unset($all_data);
758
-	    }
759
-    	    //$last_exec['phpvmacars'] = time();
760
-    	    $last_exec[$id]['last'] = time();
761
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762
-	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
764
-	    $buffer = $Common->getData($value['host']);
765
-	    $all_data = json_decode($buffer,true);
766
-	    if ($buffer != '' && is_array($all_data)) {
758
+		}
759
+			//$last_exec['phpvmacars'] = time();
760
+			$last_exec[$id]['last'] = time();
761
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762
+		//$buffer = $Common->getData($hosts[$id]);
763
+		if ($globalDebug) echo 'Get Data...'."\n";
764
+		$buffer = $Common->getData($value['host']);
765
+		$all_data = json_decode($buffer,true);
766
+		if ($buffer != '' && is_array($all_data)) {
767 767
 		$reset = 0;
768 768
 		foreach ($all_data as $line) {
769
-	    	    $data = array();
770
-	    	    //$data['id'] = $line['id']; // id not usable
771
-	    	    $data['id'] = trim($line['flight_id']);
772
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
-	    	    $data['pilot_name'] = $line['pilot_name'];
774
-	    	    $data['pilot_id'] = $line['pilot_id'];
775
-	    	    $data['ident'] = trim($line['callsign']); // ident
776
-	    	    $data['altitude'] = $line['altitude']; // altitude
777
-	    	    $data['speed'] = $line['gs']; // speed
778
-	    	    $data['heading'] = $line['heading']; // heading
779
-	    	    $data['latitude'] = $line['latitude']; // lat
780
-	    	    $data['longitude'] = $line['longitude']; // long
781
-	    	    $data['verticalrate'] = ''; // verticale rate
782
-	    	    $data['squawk'] = ''; // squawk
783
-	    	    $data['emergency'] = ''; // emergency
784
-	    	    //$data['datetime'] = $line['lastupdate'];
785
-	    	    $data['last_update'] = $line['last_update'];
786
-		    $data['datetime'] = date('Y-m-d H:i:s');
787
-	    	    $data['departure_airport_icao'] = $line['departure'];
788
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
789
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
790
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
791
-    		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
793
-	    	    $data['aircraft_icao'] = $line['plane_type'];
794
-    		    $data['id_source'] = $id_source;
795
-	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
-		    $SI->add($data);
798
-		    unset($data);
769
+				$data = array();
770
+				//$data['id'] = $line['id']; // id not usable
771
+				$data['id'] = trim($line['flight_id']);
772
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
+				$data['pilot_name'] = $line['pilot_name'];
774
+				$data['pilot_id'] = $line['pilot_id'];
775
+				$data['ident'] = trim($line['callsign']); // ident
776
+				$data['altitude'] = $line['altitude']; // altitude
777
+				$data['speed'] = $line['gs']; // speed
778
+				$data['heading'] = $line['heading']; // heading
779
+				$data['latitude'] = $line['latitude']; // lat
780
+				$data['longitude'] = $line['longitude']; // long
781
+				$data['verticalrate'] = ''; // verticale rate
782
+				$data['squawk'] = ''; // squawk
783
+				$data['emergency'] = ''; // emergency
784
+				//$data['datetime'] = $line['lastupdate'];
785
+				$data['last_update'] = $line['last_update'];
786
+			$data['datetime'] = date('Y-m-d H:i:s');
787
+				$data['departure_airport_icao'] = $line['departure'];
788
+				//$data['departure_airport_time'] = $line['departure_time'];
789
+				$data['arrival_airport_icao'] = $line['arrival'];
790
+				//$data['arrival_airport_time'] = $line['arrival_time'];
791
+				//$data['registration'] = $line['aircraft'];
792
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
793
+				$data['aircraft_icao'] = $line['plane_type'];
794
+				$data['id_source'] = $id_source;
795
+				$data['format_source'] = 'vam';
796
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
+			$SI->add($data);
798
+			unset($data);
799 799
 		}
800 800
 		if ($globalDebug) echo 'No more data...'."\n";
801 801
 		unset($buffer);
802 802
 		unset($all_data);
803
-	    }
804
-    	    //$last_exec['phpvmacars'] = time();
805
-    	    $last_exec[$id]['last'] = time();
803
+		}
804
+			//$last_exec['phpvmacars'] = time();
805
+			$last_exec[$id]['last'] = time();
806 806
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 807
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
809
-    	    //$last_exec[$id]['last'] = time();
808
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
809
+			//$last_exec[$id]['last'] = time();
810 810
 
811
-	    //$read = array( $sockets[$id] );
812
-	    $read = $sockets;
813
-	    $write = NULL;
814
-	    $e = NULL;
815
-	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
817
-	    if ($n > 0) {
811
+		//$read = array( $sockets[$id] );
812
+		$read = $sockets;
813
+		$write = NULL;
814
+		$e = NULL;
815
+		$n = socket_select($read, $write, $e, $timeout);
816
+		if ($e != NULL) var_dump($e);
817
+		if ($n > 0) {
818 818
 		$reset = 0;
819 819
 		foreach ($read as $nb => $r) {
820
-		    //$value = $formats[$nb];
821
-		    $format = $globalSources[$nb]['format'];
822
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
-        	    } else {
825
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
-	    	    }
827
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828
-        	    //echo $buffer."\n";
829
-		    // lets play nice and handle signals such as ctrl-c/kill properly
830
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831
-		    $error = false;
832
-		    //$SI::del();
833
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
-		    // SBS format is CSV format
835
-		    if ($buffer != '') {
820
+			//$value = $formats[$nb];
821
+			$format = $globalSources[$nb]['format'];
822
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
+				} else {
825
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
+				}
827
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828
+				//echo $buffer."\n";
829
+			// lets play nice and handle signals such as ctrl-c/kill properly
830
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831
+			$error = false;
832
+			//$SI::del();
833
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
+			// SBS format is CSV format
835
+			if ($buffer != '') {
836 836
 			$tt[$format] = 0;
837 837
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
839
-			    $ACARS->add(trim($buffer));
840
-			    $ACARS->deleteLiveAcarsData();
838
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
839
+				$ACARS->add(trim($buffer));
840
+				$ACARS->deleteLiveAcarsData();
841 841
 			} elseif ($format == 'raw') {
842
-			    // AVR format
843
-			    $data = $SBS->parse($buffer);
844
-			    if (is_array($data)) {
842
+				// AVR format
843
+				$data = $SBS->parse($buffer);
844
+				if (is_array($data)) {
845 845
 				$data['datetime'] = date('Y-m-d H:i:s');
846 846
 				$data['format_source'] = 'raw';
847 847
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
850
-                            }
851
-                        } elseif ($format == 'flightgearsp') {
852
-                    	    //echo $buffer."\n";
853
-                    	    if (strlen($buffer) > 5) {
848
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
850
+							}
851
+						} elseif ($format == 'flightgearsp') {
852
+							//echo $buffer."\n";
853
+							if (strlen($buffer) > 5) {
854 854
 				$line = explode(',',$buffer);
855 855
 				$data = array();
856 856
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -866,122 +866,122 @@  discard block
 block discarded – undo
866 866
 				$data['format_source'] = 'flightgearsp';
867 867
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
868 868
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869
-			    }
870
-                        } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872
-			    $ACARS->add(trim($buffer));
873
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
-			    $ACARS->deleteLiveAcarsData();
869
+				}
870
+						} elseif ($format == 'acars') {
871
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872
+				$ACARS->add(trim($buffer));
873
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
+				$ACARS->deleteLiveAcarsData();
875 875
 			} elseif ($format == 'flightgearmp') {
876
-			    if (substr($buffer,0,1) != '#') {
876
+				if (substr($buffer,0,1) != '#') {
877 877
 				$data = array();
878 878
 				//echo $buffer."\n";
879 879
 				$line = explode(' ',$buffer);
880 880
 				if (count($line) == 11) {
881
-				    $userserver = explode('@',$line[0]);
882
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
883
-				    $data['ident'] = $userserver[0];
884
-				    $data['registration'] = $userserver[0];
885
-				    $data['latitude'] = $line[4];
886
-				    $data['longitude'] = $line[5];
887
-				    $data['altitude'] = $line[6];
888
-				    $data['datetime'] = date('Y-m-d H:i:s');
889
-				    $aircraft_type = $line[10];
890
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
891
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
881
+					$userserver = explode('@',$line[0]);
882
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
883
+					$data['ident'] = $userserver[0];
884
+					$data['registration'] = $userserver[0];
885
+					$data['latitude'] = $line[4];
886
+					$data['longitude'] = $line[5];
887
+					$data['altitude'] = $line[6];
888
+					$data['datetime'] = date('Y-m-d H:i:s');
889
+					$aircraft_type = $line[10];
890
+					$aircraft_type = preg_split(':/:',$aircraft_type);
891
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
893
+				}
893 894
 				}
894
-			    }
895 895
 			} elseif ($format == 'beast') {
896
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897
-			    die;
896
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897
+				die;
898 898
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
899
-			    $line = explode("\t", $buffer);
900
-			    for($k = 0; $k < count($line); $k=$k+2) {
899
+				$line = explode("\t", $buffer);
900
+				for($k = 0; $k < count($line); $k=$k+2) {
901 901
 				$key = $line[$k];
902
-			        $lined[$key] = $line[$k+1];
903
-			    }
904
-    			    if (count($lined) > 3) {
905
-    				$data['hex'] = $lined['hexid'];
906
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
-    				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
915
-    				$data['id_source'] = $id_source;
916
-    				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
920
-    				unset($lined);
921
-    				unset($data);
922
-    			    } else $error = true;
902
+					$lined[$key] = $line[$k+1];
903
+				}
904
+					if (count($lined) > 3) {
905
+					$data['hex'] = $lined['hexid'];
906
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
+					$data['datetime'] = date('Y-m-d H:i:s');;
908
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
915
+					$data['id_source'] = $id_source;
916
+					$data['format_source'] = 'tsv';
917
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
920
+					unset($lined);
921
+					unset($data);
922
+					} else $error = true;
923 923
 			} elseif ($format == 'aprs' && $use_aprs) {
924
-			    if ($aprs_connect == 0) {
924
+				if ($aprs_connect == 0) {
925 925
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
926 926
 				$aprs_connect = 1;
927
-			    }
927
+				}
928 928
 			    
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932 932
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
933
-			    }
933
+				}
934 934
 			    
935
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
-			    $buffer = str_replace('APRS <- ','',$buffer);
937
-			    $buffer = str_replace('APRS -> ','',$buffer);
938
-			    //echo $buffer."\n";
939
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
935
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
+				$buffer = str_replace('APRS <- ','',$buffer);
937
+				$buffer = str_replace('APRS -> ','',$buffer);
938
+				//echo $buffer."\n";
939
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
940 940
 				$line = $APRS->parse($buffer);
941 941
 				//print_r($line);
942 942
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
943
-				    $aprs_last_tx = time();
944
-				    $data = array();
945
-				    //print_r($line);
946
-				    $data['hex'] = $line['address'];
947
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
-				    //$data['datetime'] = date('Y-m-d H:i:s');
949
-				    $data['ident'] = $line['ident'];
950
-				    $data['latitude'] = $line['latitude'];
951
-				    $data['longitude'] = $line['longitude'];
952
-				    //$data['verticalrate'] = $line[16];
953
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
954
-				    else $data['speed'] = 0;
955
-				    $data['altitude'] = $line['altitude'];
956
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
957
-				    //else $data['heading'] = 0;
958
-				    $data['aircraft_type'] = $line['stealth'];
959
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
960
-    				    $data['id_source'] = $id_source;
961
-				    $data['format_source'] = 'aprs';
962
-				    $data['source_name'] = $line['source'];
963
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
964
-				    $currentdate = date('Y-m-d H:i:s');
965
-				    $aprsdate = strtotime($data['datetime']);
966
-				    // Accept data if time <= system time + 20s
967
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
968
-				    else {
943
+					$aprs_last_tx = time();
944
+					$data = array();
945
+					//print_r($line);
946
+					$data['hex'] = $line['address'];
947
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
+					//$data['datetime'] = date('Y-m-d H:i:s');
949
+					$data['ident'] = $line['ident'];
950
+					$data['latitude'] = $line['latitude'];
951
+					$data['longitude'] = $line['longitude'];
952
+					//$data['verticalrate'] = $line[16];
953
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
954
+					else $data['speed'] = 0;
955
+					$data['altitude'] = $line['altitude'];
956
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
957
+					//else $data['heading'] = 0;
958
+					$data['aircraft_type'] = $line['stealth'];
959
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
960
+						$data['id_source'] = $id_source;
961
+					$data['format_source'] = 'aprs';
962
+					$data['source_name'] = $line['source'];
963
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
964
+					$currentdate = date('Y-m-d H:i:s');
965
+					$aprsdate = strtotime($data['datetime']);
966
+					// Accept data if time <= system time + 20s
967
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
968
+					else {
969 969
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
970 970
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
971
-				    }
972
-				    unset($data);
971
+					}
972
+					unset($data);
973 973
 				} 
974 974
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
975 975
 					echo '!! Weather Station not yet supported'."\n";
976 976
 				}
977 977
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
978 978
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
979
-			    }
979
+				}
980 980
 			} else {
981
-			    $line = explode(',', $buffer);
982
-    			    if (count($line) > 20) {
983
-    			    	$data['hex'] = $line[4];
984
-    				/*
981
+				$line = explode(',', $buffer);
982
+					if (count($line) > 20) {
983
+						$data['hex'] = $line[4];
984
+					/*
985 985
     				$data['datetime'] = $line[6].' '.$line[7];
986 986
     					date_default_timezone_set($globalTimezone);
987 987
     					$datetime = new DateTime($data['datetime']);
@@ -989,29 +989,29 @@  discard block
 block discarded – undo
989 989
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
990 990
     					date_default_timezone_set('UTC');
991 991
     				*/
992
-    				// Force datetime to current UTC datetime
993
-    				date_default_timezone_set('UTC');
994
-    				$data['datetime'] = date('Y-m-d H:i:s');
995
-    				$data['ident'] = trim($line[10]);
996
-    				$data['latitude'] = $line[14];
997
-    				$data['longitude'] = $line[15];
998
-    				$data['verticalrate'] = $line[16];
999
-    				$data['emergency'] = $line[20];
1000
-    				$data['speed'] = $line[12];
1001
-    				$data['squawk'] = $line[17];
1002
-    				$data['altitude'] = $line[11];
1003
-    				$data['heading'] = $line[13];
1004
-    				$data['ground'] = $line[21];
1005
-    				$data['emergency'] = $line[19];
1006
-    				$data['format_source'] = 'sbs';
992
+					// Force datetime to current UTC datetime
993
+					date_default_timezone_set('UTC');
994
+					$data['datetime'] = date('Y-m-d H:i:s');
995
+					$data['ident'] = trim($line[10]);
996
+					$data['latitude'] = $line[14];
997
+					$data['longitude'] = $line[15];
998
+					$data['verticalrate'] = $line[16];
999
+					$data['emergency'] = $line[20];
1000
+					$data['speed'] = $line[12];
1001
+					$data['squawk'] = $line[17];
1002
+					$data['altitude'] = $line[11];
1003
+					$data['heading'] = $line[13];
1004
+					$data['ground'] = $line[21];
1005
+					$data['emergency'] = $line[19];
1006
+					$data['format_source'] = 'sbs';
1007 1007
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1008
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1009
-    				$data['id_source'] = $id_source;
1010
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1011
-    				else $error = true;
1012
-    				unset($data);
1013
-    			    } else $error = true;
1014
-			    if ($error) {
1008
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1009
+					$data['id_source'] = $id_source;
1010
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1011
+					else $error = true;
1012
+					unset($data);
1013
+					} else $error = true;
1014
+				if ($error) {
1015 1015
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1016 1016
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1017 1017
 				} else {
@@ -1027,13 +1027,13 @@  discard block
 block discarded – undo
1027 1027
 					connect_all($sourceer);
1028 1028
 					$sourceer = array();
1029 1029
 				}
1030
-			    }
1030
+				}
1031 1031
 			}
1032 1032
 			// Sleep for xxx microseconds
1033 1033
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1034
-		    } else {
1034
+			} else {
1035 1035
 			if ($format == 'flightgearmp') {
1036
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1036
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1037 1037
 				//@socket_close($r);
1038 1038
 				sleep($globalMinFetch);
1039 1039
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1042,9 +1042,9 @@  discard block
 block discarded – undo
1042 1042
 				break;
1043 1043
 				
1044 1044
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1045
-			    if (isset($tt[$format])) $tt[$format]++;
1046
-			    else $tt[$format] = 0;
1047
-			    if ($tt[$format] > 30) {
1045
+				if (isset($tt[$format])) $tt[$format]++;
1046
+				else $tt[$format] = 0;
1047
+				if ($tt[$format] > 30) {
1048 1048
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1049 1049
 				//@socket_close($r);
1050 1050
 				sleep(2);
@@ -1055,23 +1055,23 @@  discard block
 block discarded – undo
1055 1055
 				//connect_all($globalSources);
1056 1056
 				$tt[$format]=0;
1057 1057
 				break;
1058
-			    }
1058
+				}
1059
+			}
1059 1060
 			}
1060
-		    }
1061 1061
 		}
1062
-	    } else {
1062
+		} else {
1063 1063
 		$error = socket_strerror(socket_last_error());
1064 1064
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1065 1065
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1066 1066
 			if (isset($globalDebug)) echo "Restarting...\n";
1067 1067
 			// Restart the script if possible
1068 1068
 			if (is_array($sockets)) {
1069
-			    if ($globalDebug) echo "Shutdown all sockets...";
1069
+				if ($globalDebug) echo "Shutdown all sockets...";
1070 1070
 			    
1071
-			    foreach ($sockets as $sock) {
1071
+				foreach ($sockets as $sock) {
1072 1072
 				@socket_shutdown($sock,2);
1073 1073
 				@socket_close($sock);
1074
-			    }
1074
+				}
1075 1075
 			    
1076 1076
 			}
1077 1077
 			if ($globalDebug) echo "Restart all connections...";
@@ -1082,13 +1082,13 @@  discard block
 block discarded – undo
1082 1082
 			if ($reset > 40) exit('Too many attempts...');
1083 1083
 			connect_all($globalSources);
1084 1084
 		}
1085
-	    }
1085
+		}
1086 1086
 	}
1087 1087
 	if ($globalDaemon === false) {
1088
-	    if ($globalDebug) echo 'Check all...'."\n";
1089
-	    $SI->checkAll();
1088
+		if ($globalDebug) echo 'Check all...'."\n";
1089
+		$SI->checkAll();
1090
+	}
1090 1091
 	}
1091
-    }
1092 1092
 }
1093 1093
 
1094 1094
 ?>
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -113,35 +113,35 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
116
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
143 143
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
144
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
146 146
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 147
         	//$last_exec['radarvirtueljson'] = 0;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 151
         	    exit(0);
152 152
         	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
153
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
154 154
         	//$formats[$id] = 'planeupdatefaa';
155 155
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 156
         	//$last_exec['planeupdatefaa'] = 0;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 160
         	    exit(0);
161 161
         	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
162
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'phpvmacars';
165 165
         	//$last_exec['phpvmacars'] = 0;
166 166
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
167
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
168 168
         	//$formats[$id] = 'phpvmacars';
169 169
         	$globalSources[$id]['format'] = 'vam';
170 170
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
171
+            } else if (preg_match('/whazzup/i', $host)) {
172 172
         	//$formats[$id] = 'whazzup';
173 173
         	$globalSources[$id]['format'] = 'whazzup';
174 174
         	//$last_exec['whazzup'] = 0;
175 175
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
176
+            } else if (preg_match('/recentpireps/i', $host)) {
177 177
         	//$formats[$id] = 'pirepsjson';
178 178
         	$globalSources[$id]['format'] = 'pirepsjson';
179 179
         	//$last_exec['pirepsjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
181
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
182 182
         	//$formats[$id] = 'fr24json';
183 183
         	$globalSources[$id]['format'] = 'fr24json';
184 184
         	//$last_exec['fr24json'] = 0;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
             //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 192
         	//$formats[$id] = 'tsv';
193 193
         	$globalSources[$id]['format'] = 'tsv';
194 194
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195 195
             }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
197 197
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
198
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
199
+	    $hostport = explode(':', $host);
200 200
 	    if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 		$hostn = $globalSources[$id]['host'];
206 206
 	    }
207 207
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket($hostn, $port, $errno, $errstr);
209 209
     	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
210
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
211 211
 	    }
212 212
 	    if ($s) {
213 213
     	        $sockets[$id] = $s;
214 214
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
215
+		    if (preg_match('/aprs/', $hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254 254
 else $timeout = 20;
255 255
 $errno = '';
256
-$errstr='';
256
+$errstr = '';
257 257
 
258 258
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
259 259
 /* Initiate connections to all the hosts simultaneously */
@@ -282,16 +282,16 @@  discard block
 block discarded – undo
282 282
 
283 283
 if ($use_aprs) {
284 284
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
285
-	$APRS=new APRS();
285
+	$APRS = new APRS();
286 286
 	$aprs_connect = 0;
287 287
 	$aprs_keep = 120;
288 288
 	$aprs_last_tx = time();
289 289
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
290
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
291 291
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
292
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
293 293
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
294
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295 295
 	if ($aprs_full) $aprs_filter = '';
296 296
 
297 297
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 sleep(1);
304 304
 if ($globalDebug) echo "SCAN MODE \n\n";
305 305
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
306
-$endtime = time()+$globalCronEnd;
306
+$endtime = time() + $globalCronEnd;
307 307
 $i = 1;
308 308
 $tt = array();
309 309
 // Delete all ATC
310 310
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
311
-	$ATC=new ATC($Connection->db);
311
+	$ATC = new ATC($Connection->db);
312 312
 }
313 313
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
314 314
 	$ATC->deleteAll();
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 318
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
319
+    if (!$globalDaemon) $i = $endtime - time();
320 320
     // Delete old ATC
321 321
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322 322
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	}
331 331
 	if ($max != $globalMinFetch) {
332 332
 	    if ($globalDebug) echo 'Sleeping...'."\n";
333
-	    sleep($globalMinFetch-$max+2);
333
+	    sleep($globalMinFetch - $max + 2);
334 334
 	}
335 335
     }
336 336
 
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	    //$buffer = $Common->getData($hosts[$id]);
344 344
 	    $buffer = $Common->getData($value['host']);
345 345
 	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
346
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
347
+	    $buffer = explode('\n', $buffer);
348 348
 	    foreach ($buffer as $line) {
349 349
     		if ($line != '' && count($line) > 7) {
350 350
     		    $line = explode(',', $line);
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374 374
 	    //$buffer = $Common->getData($hosts[$id]);
375 375
 	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    $reset = 0;
379 379
 	    foreach ($buffer as $line) {
380 380
     		if ($line != '') {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
386 386
 			$data['pilot_id'] = $line[1];
387 387
 			$data['pilot_name'] = $line[2];
388
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
388
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
389 389
 			$data['ident'] = $line[0]; // ident
390 390
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
391 391
 			$data['speed'] = $line[8]; // speed
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
402 402
 			//if (isset($line[37])) $data['last_update'] = $line[37];
403 403
 		        $data['departure_airport_icao'] = $line[11];
404
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
405 405
 		        $data['arrival_airport_icao'] = $line[13];
406 406
 			$data['frequency'] = $line[4];
407 407
 			$data['type'] = $line[18];
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     			$data['id_source'] = $id_source;
411 411
 	    		//$data['arrival_airport_time'] = ;
412 412
 	    		if ($line[9] != '') {
413
-	    		    $aircraft_data = explode('/',$line[9]);
413
+	    		    $aircraft_data = explode('/', $line[9]);
414 414
 	    		    if (isset($aircraft_data[1])) {
415 415
 	    			$data['aircraft_icao'] = $aircraft_data[1];
416 416
 	    		    }
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
     			if ($line[3] == 'PILOT') $SI->add($data);
425 425
 			elseif ($line[3] == 'ATC') {
426 426
 				//print_r($data);
427
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429
-				$typec = substr($data['ident'],-3);
427
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
428
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
429
+				$typec = substr($data['ident'], -3);
430 430
 				if ($typec == 'APP') $data['type'] = 'Approach';
431 431
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432 432
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438 438
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
439 439
 				if (!isset($data['source_name'])) $data['source_name'] = '';
440
-				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
440
+				echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
441 441
 			}
442 442
     			unset($data);
443 443
     		    }
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
     	    $last_exec[$id]['last'] = time();
449 449
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450 450
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
451
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
452 452
 	    if ($buffer != '') {
453
-	    $all_data = json_decode($buffer,true);
453
+	    $all_data = json_decode($buffer, true);
454 454
 	    if (isset($all_data['acList'])) {
455 455
 		$reset = 0;
456 456
 		foreach ($all_data['acList'] as $line) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507 507
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508 508
 	    $buffer = $Common->getData($value['host']);
509
-	    $all_data = json_decode($buffer,true);
509
+	    $all_data = json_decode($buffer, true);
510 510
 	    if (isset($all_data['planes'])) {
511 511
 		$reset = 0;
512 512
 		foreach ($all_data['planes'] as $key => $line) {
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 		    $data['emergency'] = ''; // emergency
524 524
 		    $data['registration'] = $line[2];
525 525
 		    $data['aircraft_icao'] = $line[0];
526
-		    $deparr = explode('-',$line[1]);
526
+		    $deparr = explode('-', $line[1]);
527 527
 		    if (count($deparr) == 2) {
528 528
 			$data['departure_airport_icao'] = $deparr[0];
529 529
 			$data['arrival_airport_icao'] = $deparr[1];
530 530
 		    }
531
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
532 532
 	    	    $data['format_source'] = 'planeupdatefaa';
533 533
     		    $data['id_source'] = $id_source;
534 534
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     	    $last_exec[$id]['last'] = time();
541 541
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542 542
 	    $buffer = $Common->getData($value['host']);
543
-	    $all_data = json_decode($buffer,true);
543
+	    $all_data = json_decode($buffer, true);
544 544
 	    if (isset($all_data['states'])) {
545 545
 		$reset = 0;
546 546
 		foreach ($all_data['states'] as $key => $line) {
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		    //$data['emergency'] = ''; // emergency
558 558
 		    //$data['registration'] = $line[2];
559 559
 		    //$data['aircraft_icao'] = $line[0];
560
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
561 561
 	    	    $data['format_source'] = 'opensky';
562 562
     		    $data['id_source'] = $id_source;
563 563
 		    $SI->add($data);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571 571
 	    //$buffer = $Common->getData($hosts[$id]);
572 572
 	    $buffer = $Common->getData($value['host']);
573
-	    $all_data = json_decode($buffer,true);
573
+	    $all_data = json_decode($buffer, true);
574 574
 	    if (!empty($all_data)) $reset = 0;
575 575
 	    foreach ($all_data as $key => $line) {
576 576
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603 603
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604 604
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
605
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
606 606
 	    //echo $buffer;
607
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
608
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
-	    $all_data = json_decode($buffer,true);
607
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
608
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
609
+	    $all_data = json_decode($buffer, true);
610 610
 	    if (json_last_error() != JSON_ERROR_NONE) {
611 611
 		die(json_last_error_msg());
612 612
 	    }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			//$data['departure_airport_iata'] = $line[11];
630 630
 			//$data['arrival_airport_iata'] = $line[12];
631 631
 	    		//$data['emergency'] = ''; // emergency
632
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
632
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
633 633
 	    		$data['format_source'] = 'radarvirtueljson';
634 634
     			$data['id_source'] = $id_source;
635 635
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645 645
 	    //$buffer = $Common->getData($hosts[$id]);
646 646
 	    $buffer = $Common->getData($value['host'].'?'.time());
647
-	    $all_data = json_decode(utf8_encode($buffer),true);
647
+	    $all_data = json_decode(utf8_encode($buffer), true);
648 648
 	    
649 649
 	    if (isset($all_data['pireps'])) {
650 650
 		$reset = 0;
651 651
 	        foreach ($all_data['pireps'] as $line) {
652 652
 		    $data = array();
653 653
 		    $data['id'] = $line['id'];
654
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
655 655
 		    $data['ident'] = $line['callsign']; // ident
656 656
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657 657
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
 			$SI->add($data);
681 681
 		    //    print_r($data);
682 682
     		    } elseif ($line['icon'] == 'ct') {
683
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
684
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685
-			$typec = substr($data['ident'],-3);
683
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
684
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
685
+			$typec = substr($data['ident'], -3);
686 686
 			$data['type'] = '';
687 687
 			if ($typec == 'APP') $data['type'] = 'Approach';
688 688
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694 694
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695 695
 			else $data['type'] = 'Observer';
696
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
696
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
697 697
 		    }
698 698
 		    unset($data);
699 699
 		}
@@ -705,14 +705,14 @@  discard block
 block discarded – undo
705 705
 	    //$buffer = $Common->getData($hosts[$id]);
706 706
 	    if ($globalDebug) echo 'Get Data...'."\n";
707 707
 	    $buffer = $Common->getData($value['host']);
708
-	    $all_data = json_decode($buffer,true);
708
+	    $all_data = json_decode($buffer, true);
709 709
 	    if ($buffer != '' && is_array($all_data)) {
710 710
 		$reset = 0;
711 711
 		foreach ($all_data as $line) {
712 712
 	    	    $data = array();
713 713
 	    	    //$data['id'] = $line['id']; // id not usable
714 714
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
716 716
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717 717
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718 718
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -735,12 +735,12 @@  discard block
 block discarded – undo
735 735
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736 736
 		    if (isset($line['aircraftname'])) {
737 737
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739
-	    		$aircraft_data = explode('-',$line['aircraftname']);
738
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
739
+	    		$aircraft_data = explode('-', $line['aircraftname']);
740 740
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741 741
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742 742
 	    		else {
743
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
743
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
744 744
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745 745
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
746 746
 	    		}
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
 	    //$buffer = $Common->getData($hosts[$id]);
763 763
 	    if ($globalDebug) echo 'Get Data...'."\n";
764 764
 	    $buffer = $Common->getData($value['host']);
765
-	    $all_data = json_decode($buffer,true);
765
+	    $all_data = json_decode($buffer, true);
766 766
 	    if ($buffer != '' && is_array($all_data)) {
767 767
 		$reset = 0;
768 768
 		foreach ($all_data as $line) {
769 769
 	    	    $data = array();
770 770
 	    	    //$data['id'] = $line['id']; // id not usable
771 771
 	    	    $data['id'] = trim($line['flight_id']);
772
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
773 773
 	    	    $data['pilot_name'] = $line['pilot_name'];
774 774
 	    	    $data['pilot_id'] = $line['pilot_id'];
775 775
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -820,9 +820,9 @@  discard block
 block discarded – undo
820 820
 		    //$value = $formats[$nb];
821 821
 		    $format = $globalSources[$nb]['format'];
822 822
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
824 824
         	    } else {
825
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
826 826
 	    	    }
827 827
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828 828
         	    //echo $buffer."\n";
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831 831
 		    $error = false;
832 832
 		    //$SI::del();
833
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
834 834
 		    // SBS format is CSV format
835 835
 		    if ($buffer != '') {
836 836
 			$tt[$format] = 0;
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
                         } elseif ($format == 'flightgearsp') {
852 852
                     	    //echo $buffer."\n";
853 853
                     	    if (strlen($buffer) > 5) {
854
-				$line = explode(',',$buffer);
854
+				$line = explode(',', $buffer);
855 855
 				$data = array();
856 856
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
857
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
857
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
858 858
 				$data['ident'] = $line[6];
859 859
 				$data['aircraft_name'] = $line[7];
860 860
 				$data['longitude'] = $line[1];
@@ -865,21 +865,21 @@  discard block
 block discarded – undo
865 865
 				$data['datetime'] = date('Y-m-d H:i:s');
866 866
 				$data['format_source'] = 'flightgearsp';
867 867
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
868
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
868
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
869 869
 			    }
870 870
                         } elseif ($format == 'acars') {
871 871
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872 872
 			    $ACARS->add(trim($buffer));
873
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
874 874
 			    $ACARS->deleteLiveAcarsData();
875 875
 			} elseif ($format == 'flightgearmp') {
876
-			    if (substr($buffer,0,1) != '#') {
876
+			    if (substr($buffer, 0, 1) != '#') {
877 877
 				$data = array();
878 878
 				//echo $buffer."\n";
879
-				$line = explode(' ',$buffer);
879
+				$line = explode(' ', $buffer);
880 880
 				if (count($line) == 11) {
881
-				    $userserver = explode('@',$line[0]);
882
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
881
+				    $userserver = explode('@', $line[0]);
882
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
883 883
 				    $data['ident'] = $userserver[0];
884 884
 				    $data['registration'] = $userserver[0];
885 885
 				    $data['latitude'] = $line[4];
@@ -887,24 +887,24 @@  discard block
 block discarded – undo
887 887
 				    $data['altitude'] = $line[6];
888 888
 				    $data['datetime'] = date('Y-m-d H:i:s');
889 889
 				    $aircraft_type = $line[10];
890
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
891
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
890
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
891
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
892 892
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
893 893
 				}
894 894
 			    }
895 895
 			} elseif ($format == 'beast') {
896 896
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897 897
 			    die;
898
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
898
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
899 899
 			    $line = explode("\t", $buffer);
900
-			    for($k = 0; $k < count($line); $k=$k+2) {
900
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
901 901
 				$key = $line[$k];
902
-			        $lined[$key] = $line[$k+1];
902
+			        $lined[$key] = $line[$k + 1];
903 903
 			    }
904 904
     			    if (count($lined) > 3) {
905 905
     				$data['hex'] = $lined['hexid'];
906 906
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
-    				$data['datetime'] = date('Y-m-d H:i:s');;
907
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
908 908
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909 909
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910 910
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -922,21 +922,21 @@  discard block
 block discarded – undo
922 922
     			    } else $error = true;
923 923
 			} elseif ($format == 'aprs' && $use_aprs) {
924 924
 			    if ($aprs_connect == 0) {
925
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
925
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
926 926
 				$aprs_connect = 1;
927 927
 			    }
928 928
 			    
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
932
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
933 933
 			    }
934 934
 			    
935 935
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
-			    $buffer = str_replace('APRS <- ','',$buffer);
937
-			    $buffer = str_replace('APRS -> ','',$buffer);
936
+			    $buffer = str_replace('APRS <- ', '', $buffer);
937
+			    $buffer = str_replace('APRS -> ', '', $buffer);
938 938
 			    //echo $buffer."\n";
939
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
939
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
940 940
 				$line = $APRS->parse($buffer);
941 941
 				//print_r($line);
942 942
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 				    $data = array();
945 945
 				    //print_r($line);
946 946
 				    $data['hex'] = $line['address'];
947
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
947
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
948 948
 				    //$data['datetime'] = date('Y-m-d H:i:s');
949 949
 				    $data['ident'] = $line['ident'];
950 950
 				    $data['latitude'] = $line['latitude'];
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 				    $currentdate = date('Y-m-d H:i:s');
965 965
 				    $aprsdate = strtotime($data['datetime']);
966 966
 				    // Accept data if time <= system time + 20s
967
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
967
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
968 968
 				    else {
969 969
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
970 970
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 				connect_all($sourceee);
1054 1054
 				$sourceee = array();
1055 1055
 				//connect_all($globalSources);
1056
-				$tt[$format]=0;
1056
+				$tt[$format] = 0;
1057 1057
 				break;
1058 1058
 			    }
1059 1059
 			}
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 		}
1062 1062
 	    } else {
1063 1063
 		$error = socket_strerror(socket_last_error());
1064
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1064
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1065 1065
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1066 1066
 			if (isset($globalDebug)) echo "Restarting...\n";
1067 1067
 			// Restart the script if possible
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 			    if ($globalDebug) echo "Shutdown all sockets...";
1070 1070
 			    
1071 1071
 			    foreach ($sockets as $sock) {
1072
-				@socket_shutdown($sock,2);
1072
+				@socket_shutdown($sock, 2);
1073 1073
 				@socket_close($sock);
1074 1074
 			    }
1075 1075
 			    
Please login to merge, or discard this patch.
Braces   +547 added lines, -189 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -54,13 +56,22 @@  discard block
 block discarded – undo
54 56
     $globalSources = array();
55 57
     $globalSources[] = array('host' => $options['source']);
56 58
 }
57
-if (isset($options['server'])) $globalServer = TRUE;
58
-if (isset($options['idsource'])) $id_source = $options['idsource'];
59
-else $id_source = 1;
59
+if (isset($options['server'])) {
60
+	$globalServer = TRUE;
61
+}
62
+if (isset($options['idsource'])) {
63
+	$id_source = $options['idsource'];
64
+} else {
65
+	$id_source = 1;
66
+}
60 67
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
68
+    if ($globalDebug) {
69
+    	echo "Using Server Mode\n";
70
+    }
62 71
     $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
72
+} else {
73
+	$SI=new SpotterImport($Connection->db);
74
+}
64 75
 //$APRS=new APRS($Connection->db);
65 76
 $SBS=new SBS();
66 77
 $ACARS=new ACARS($Connection->db);
@@ -78,7 +89,9 @@  discard block
 block discarded – undo
78 89
 }
79 90
 
80 91
 // let's try and connect
81
-if ($globalDebug) echo "Connecting...\n";
92
+if ($globalDebug) {
93
+	echo "Connecting...\n";
94
+}
82 95
 $use_aprs = false;
83 96
 $aprs_full = false;
84 97
 $reset = 0;
@@ -87,7 +100,9 @@  discard block
 block discarded – undo
87 100
     $ip = gethostbyname($host);
88 101
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
89 102
     $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
103
+    if (!socket_set_nonblock($s)) {
104
+    	echo "Unable to set nonblock on socket\n";
105
+    }
91 106
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92 107
         return $s;
93 108
     }
@@ -115,7 +130,9 @@  discard block
 block discarded – undo
115 130
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 131
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117 132
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
133
+    if ($globalDebug) {
134
+    	echo 'Connect to all...'."\n";
135
+    }
119 136
     foreach ($hosts as $id => $value) {
120 137
 	$host = $value['host'];
121 138
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,27 +142,37 @@  discard block
 block discarded – undo
125 142
         	//$formats[$id] = 'deltadbtxt';
126 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 144
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
145
+        	if ($globalDebug) {
146
+        		echo "Connect to deltadb source (".$host.")...\n";
147
+        	}
129 148
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 149
         	//$formats[$id] = 'vatsimtxt';
131 150
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 151
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
152
+        	if ($globalDebug) {
153
+        		echo "Connect to vatsim source (".$host.")...\n";
154
+        	}
134 155
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 156
         	//$formats[$id] = 'aircraftlistjson';
136 157
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 158
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
161
+        	}
139 162
     	    } else if (preg_match('/opensky/i',$host)) {
140 163
         	//$formats[$id] = 'aircraftlistjson';
141 164
         	$globalSources[$id]['format'] = 'opensky';
142 165
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to opensky source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145 170
         	//$formats[$id] = 'radarvirtueljson';
146 171
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 172
         	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
175
+        	}
149 176
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 178
         	    exit(0);
@@ -154,7 +181,9 @@  discard block
 block discarded – undo
154 181
         	//$formats[$id] = 'planeupdatefaa';
155 182
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 183
         	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
186
+        	}
158 187
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 189
         	    exit(0);
@@ -163,26 +192,36 @@  discard block
 block discarded – undo
163 192
         	//$formats[$id] = 'phpvmacars';
164 193
         	$globalSources[$id]['format'] = 'phpvmacars';
165 194
         	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	if ($globalDebug) {
196
+        		echo "Connect to phpvmacars source (".$host.")...\n";
197
+        	}
167 198
             } else if (preg_match('/VAM-json.php$/i',$host)) {
168 199
         	//$formats[$id] = 'phpvmacars';
169 200
         	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to Vam source (".$host.")...\n";
203
+        	}
171 204
             } else if (preg_match('/whazzup/i',$host)) {
172 205
         	//$formats[$id] = 'whazzup';
173 206
         	$globalSources[$id]['format'] = 'whazzup';
174 207
         	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to whazzup source (".$host.")...\n";
210
+        	}
176 211
             } else if (preg_match('/recentpireps/i',$host)) {
177 212
         	//$formats[$id] = 'pirepsjson';
178 213
         	$globalSources[$id]['format'] = 'pirepsjson';
179 214
         	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to pirepsjson source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182 219
         	//$formats[$id] = 'fr24json';
183 220
         	$globalSources[$id]['format'] = 'fr24json';
184 221
         	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to fr24 source (".$host.")...\n";
224
+        	}
186 225
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187 226
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188 227
         	    exit(0);
@@ -191,10 +230,14 @@  discard block
 block discarded – undo
191 230
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 231
         	//$formats[$id] = 'tsv';
193 232
         	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to tsv source (".$host.")...\n";
235
+        	}
195 236
             }
196 237
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+        	}
198 241
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199 242
 	    $hostport = explode(':',$host);
200 243
 	    if (isset($hostport[1])) {
@@ -231,17 +274,25 @@  discard block
 block discarded – undo
231 274
         		//$formats[$id] = 'beast';
232 275
         		$globalSources[$id]['format'] = 'beast';
233 276
 		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
277
+		    } else {
278
+		    	$globalSources[$id]['format'] = 'sbs';
279
+		    }
235 280
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 281
 		}
237
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
282
+		if ($globalDebug) {
283
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
284
+		}
238 285
             } else {
239
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
286
+		if ($globalDebug) {
287
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
288
+		}
240 289
     	    }
241 290
         }
242 291
     }
243 292
 }
244
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
293
+if (!isset($globalMinFetch)) {
294
+	$globalMinFetch = 15;
295
+}
245 296
 
246 297
 // Initialize all
247 298
 $status = array();
@@ -249,13 +300,19 @@  discard block
 block discarded – undo
249 300
 $formats = array();
250 301
 $last_exec = array();
251 302
 $time = time();
252
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
253
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254
-else $timeout = 20;
303
+if (isset($globalSourcesTimeout)) {
304
+	$timeout = $globalSourcesTimeOut;
305
+} else if (isset($globalSBS1TimeOut)) {
306
+	$timeout = $globalSBS1TimeOut;
307
+} else {
308
+	$timeout = 20;
309
+}
255 310
 $errno = '';
256 311
 $errstr='';
257 312
 
258
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
313
+if (!isset($globalDaemon)) {
314
+	$globalDaemon = TRUE;
315
+}
259 316
 /* Initiate connections to all the hosts simultaneously */
260 317
 //connect_all($hosts);
261 318
 //connect_all($globalSources);
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
     if (isset($source['format']) && $source['format'] == 'aprs') {
276 333
 	$aprs_connect = 0;
277 334
 	$use_aprs = true;
278
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
335
+	if (isset($source['port']) && $source['port'] == '10152') {
336
+		$aprs_full = true;
337
+	}
279 338
 	break;
280 339
     }
281 340
 }
@@ -286,23 +345,43 @@  discard block
 block discarded – undo
286 345
 	$aprs_connect = 0;
287 346
 	$aprs_keep = 120;
288 347
 	$aprs_last_tx = time();
289
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
291
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
293
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295
-	if ($aprs_full) $aprs_filter = '';
348
+	if (isset($globalAPRSversion)) {
349
+		$aprs_version = $globalAPRSversion;
350
+	} else {
351
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
352
+	}
353
+	if (isset($globalAPRSssid)) {
354
+		$aprs_ssid = $globalAPRSssid;
355
+	} else {
356
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
357
+	}
358
+	if (isset($globalAPRSfilter)) {
359
+		$aprs_filter = $globalAPRSfilter;
360
+	} else {
361
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
362
+	}
363
+	if ($aprs_full) {
364
+		$aprs_filter = '';
365
+	}
296 366
 
297
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
298
-	else $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
299
-}
367
+	if ($aprs_filter != '') {
368
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
369
+	} else {
370
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
371
+	}
372
+	}
300 373
 
301 374
 // connected - lets do some work
302
-if ($globalDebug) echo "Connected!\n";
375
+if ($globalDebug) {
376
+	echo "Connected!\n";
377
+}
303 378
 sleep(1);
304
-if ($globalDebug) echo "SCAN MODE \n\n";
305
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
379
+if ($globalDebug) {
380
+	echo "SCAN MODE \n\n";
381
+}
382
+if (!isset($globalCronEnd)) {
383
+	$globalCronEnd = 60;
384
+}
306 385
 $endtime = time()+$globalCronEnd;
307 386
 $i = 1;
308 387
 $tt = array();
@@ -316,20 +395,28 @@  discard block
 block discarded – undo
316 395
 
317 396
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 397
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
398
+    if (!$globalDaemon) {
399
+    	$i = $endtime-time();
400
+    }
320 401
     // Delete old ATC
321 402
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
403
+	if ($globalDebug) {
404
+		echo 'Delete old ATC...'."\n";
405
+	}
323 406
         $ATC->deleteOldATC();
324 407
     }
325 408
     
326 409
     if (count($last_exec) > 0) {
327 410
 	$max = $globalMinFetch;
328 411
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
412
+	    if ((time() - $last['last']) < $max) {
413
+	    	$max = time() - $last['last'];
414
+	    }
330 415
 	}
331 416
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
417
+	    if ($globalDebug) {
418
+	    	echo 'Sleeping...'."\n";
419
+	    }
333 420
 	    sleep($globalMinFetch-$max+2);
334 421
 	}
335 422
     }
@@ -338,11 +425,15 @@  discard block
 block discarded – undo
338 425
     //foreach ($formats as $id => $value) {
339 426
     foreach ($globalSources as $id => $value) {
340 427
 	date_default_timezone_set('UTC');
341
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
428
+	if (!isset($last_exec[$id]['last'])) {
429
+		$last_exec[$id]['last'] = 0;
430
+	}
342 431
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343 432
 	    //$buffer = $Common->getData($hosts[$id]);
344 433
 	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
434
+	    if ($buffer != '') {
435
+	    	$reset = 0;
436
+	    }
346 437
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347 438
 	    $buffer = explode('\n',$buffer);
348 439
 	    foreach ($buffer as $line) {
@@ -351,19 +442,38 @@  discard block
 block discarded – undo
351 442
 	            $data = array();
352 443
 	            $data['hex'] = $line[1]; // hex
353 444
 	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
445
+	            if (isset($line[3])) {
446
+	            	$data['altitude'] = $line[3];
447
+	            }
448
+	            // altitude
449
+	            if (isset($line[4])) {
450
+	            	$data['speed'] = $line[4];
451
+	            }
452
+	            // speed
453
+	            if (isset($line[5])) {
454
+	            	$data['heading'] = $line[5];
455
+	            }
456
+	            // heading
457
+	            if (isset($line[6])) {
458
+	            	$data['latitude'] = $line[6];
459
+	            }
460
+	            // lat
461
+	            if (isset($line[7])) {
462
+	            	$data['longitude'] = $line[7];
463
+	            }
464
+	            // long
359 465
 	            $data['verticalrate'] = ''; // vertical rate
360 466
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361 467
 	            $data['emergency'] = ''; // emergency
362 468
 		    $data['datetime'] = date('Y-m-d H:i:s');
363 469
 		    $data['format_source'] = 'deltadbtxt';
364 470
     		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
471
+		    if (isset($value['name']) && $value['name'] != '') {
472
+		    	$data['source_name'] = $value['name'];
473
+		    }
474
+		    if (isset($value['sourcestats'])) {
475
+		    	$data['sourcestats'] = $value['sourcestats'];
476
+		    }
367 477
     		    $SI->add($data);
368 478
 		    unset($data);
369 479
     		}
@@ -381,16 +491,28 @@  discard block
 block discarded – undo
381 491
     		    $line = explode(':', $line);
382 492
     		    if (count($line) > 30 && $line[0] != 'callsign') {
383 493
 			$data = array();
384
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
494
+			if (isset($line[37]) && $line[37] != '') {
495
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
496
+			} else {
497
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
498
+			}
386 499
 			$data['pilot_id'] = $line[1];
387 500
 			$data['pilot_name'] = $line[2];
388 501
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
389 502
 			$data['ident'] = $line[0]; // ident
390
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
503
+			if ($line[7] != '' && $line[7] != 0) {
504
+				$data['altitude'] = $line[7];
505
+			}
506
+			// altitude
391 507
 			$data['speed'] = $line[8]; // speed
392
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
508
+			if (isset($line[45])) {
509
+				$data['heading'] = $line[45];
510
+			}
511
+			// heading
512
+			elseif (isset($line[38])) {
513
+				$data['heading'] = $line[38];
514
+			}
515
+			// heading
394 516
 			$data['latitude'] = $line[5]; // lat
395 517
 	        	$data['longitude'] = $line[6]; // long
396 518
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -406,7 +528,9 @@  discard block
 block discarded – undo
406 528
 			$data['frequency'] = $line[4];
407 529
 			$data['type'] = $line[18];
408 530
 			$data['range'] = $line[19];
409
-			if (isset($line[35])) $data['info'] = $line[35];
531
+			if (isset($line[35])) {
532
+				$data['info'] = $line[35];
533
+			}
410 534
     			$data['id_source'] = $id_source;
411 535
 	    		//$data['arrival_airport_time'] = ;
412 536
 	    		if ($line[9] != '') {
@@ -420,23 +544,38 @@  discard block
 block discarded – undo
420 544
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 545
 	    		*/
422 546
 	    		$data['format_source'] = $value['format'];
423
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
425
-			elseif ($line[3] == 'ATC') {
547
+			if (isset($value['name']) && $value['name'] != '') {
548
+				$data['source_name'] = $value['name'];
549
+			}
550
+    			if ($line[3] == 'PILOT') {
551
+    				$SI->add($data);
552
+    			} elseif ($line[3] == 'ATC') {
426 553
 				//print_r($data);
427 554
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428 555
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429 556
 				$typec = substr($data['ident'],-3);
430
-				if ($typec == 'APP') $data['type'] = 'Approach';
431
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
433
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
434
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
435
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
436
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
437
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
439
-				if (!isset($data['source_name'])) $data['source_name'] = '';
557
+				if ($typec == 'APP') {
558
+					$data['type'] = 'Approach';
559
+				} elseif ($typec == 'TWR') {
560
+					$data['type'] = 'Tower';
561
+				} elseif ($typec == 'OBS') {
562
+					$data['type'] = 'Observer';
563
+				} elseif ($typec == 'GND') {
564
+					$data['type'] = 'Ground';
565
+				} elseif ($typec == 'DEL') {
566
+					$data['type'] = 'Delivery';
567
+				} elseif ($typec == 'DEP') {
568
+					$data['type'] = 'Departure';
569
+				} elseif ($typec == 'FSS') {
570
+					$data['type'] = 'Flight Service Station';
571
+				} elseif ($typec == 'CTR') {
572
+					$data['type'] = 'Control Radar or Centre';
573
+				} elseif ($data['type'] == '') {
574
+					$data['type'] = 'Observer';
575
+				}
576
+				if (!isset($data['source_name'])) {
577
+					$data['source_name'] = '';
578
+				}
440 579
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
441 580
 			}
442 581
     			unset($data);
@@ -456,26 +595,55 @@  discard block
 block discarded – undo
456 595
 		foreach ($all_data['acList'] as $line) {
457 596
 		    $data = array();
458 597
 		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
598
+		    if (isset($line['Call'])) {
599
+		    	$data['ident'] = $line['Call'];
600
+		    }
601
+		    // ident
602
+		    if (isset($line['Alt'])) {
603
+		    	$data['altitude'] = $line['Alt'];
604
+		    }
605
+		    // altitude
606
+		    if (isset($line['Spd'])) {
607
+		    	$data['speed'] = $line['Spd'];
608
+		    }
609
+		    // speed
610
+		    if (isset($line['Trak'])) {
611
+		    	$data['heading'] = $line['Trak'];
612
+		    }
613
+		    // heading
614
+		    if (isset($line['Lat'])) {
615
+		    	$data['latitude'] = $line['Lat'];
616
+		    }
617
+		    // lat
618
+		    if (isset($line['Long'])) {
619
+		    	$data['longitude'] = $line['Long'];
620
+		    }
621
+		    // long
465 622
 		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
623
+		    if (isset($line['Sqk'])) {
624
+		    	$data['squawk'] = $line['Sqk'];
625
+		    }
626
+		    // squawk
467 627
 		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
628
+		    if (isset($line['Reg'])) {
629
+		    	$data['registration'] = $line['Reg'];
630
+		    }
469 631
 		    /*
470 632
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 633
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 634
 		    */
473 635
 		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
636
+		    if (isset($line['Type'])) {
637
+		    	$data['aircraft_icao'] = $line['Type'];
638
+		    }
475 639
 	    	    $data['format_source'] = 'aircraftlistjson';
476 640
 		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
641
+		    if (isset($value['name']) && $value['name'] != '') {
642
+		    	$data['source_name'] = $value['name'];
643
+		    }
644
+		    if (isset($data['datetime'])) {
645
+		    	$SI->add($data);
646
+		    }
479 647
 		    unset($data);
480 648
 		}
481 649
 	    } else {
@@ -495,7 +663,9 @@  discard block
 block discarded – undo
495 663
 		    $data['datetime'] = date('Y-m-d H:i:s');
496 664
 	    	    $data['format_source'] = 'aircraftlistjson';
497 665
     		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
666
+		    if (isset($value['name']) && $value['name'] != '') {
667
+		    	$data['source_name'] = $value['name'];
668
+		    }
499 669
 		    $SI->add($data);
500 670
 		    unset($data);
501 671
 		}
@@ -531,7 +701,9 @@  discard block
 block discarded – undo
531 701
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532 702
 	    	    $data['format_source'] = 'planeupdatefaa';
533 703
     		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
704
+		    if (isset($value['name']) && $value['name'] != '') {
705
+		    	$data['source_name'] = $value['name'];
706
+		    }
535 707
 		    $SI->add($data);
536 708
 		    unset($data);
537 709
 		}
@@ -571,7 +743,9 @@  discard block
 block discarded – undo
571 743
 	    //$buffer = $Common->getData($hosts[$id]);
572 744
 	    $buffer = $Common->getData($value['host']);
573 745
 	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
746
+	    if (!empty($all_data)) {
747
+	    	$reset = 0;
748
+	    }
575 749
 	    foreach ($all_data as $key => $line) {
576 750
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577 751
 		    $data = array();
@@ -592,7 +766,9 @@  discard block
 block discarded – undo
592 766
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593 767
 	    	    $data['format_source'] = 'fr24json';
594 768
     		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
769
+		    if (isset($value['name']) && $value['name'] != '') {
770
+		    	$data['source_name'] = $value['name'];
771
+		    }
596 772
 		    $SI->add($data);
597 773
 		    unset($data);
598 774
 		}
@@ -616,23 +792,39 @@  discard block
 block discarded – undo
616 792
 		    if (isset($line['inf'])) {
617 793
 			$data = array();
618 794
 			$data['hex'] = $line['inf']['ia'];
619
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
795
+			if (isset($line['inf']['cs'])) {
796
+				$data['ident'] = $line['inf']['cs'];
797
+			}
798
+			//$line[13]
620 799
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
800
+	    		if (isset($line['inf']['gs'])) {
801
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
802
+	    		}
803
+	    		// speed
804
+	    		if (isset($line['inf']['tr'])) {
805
+	    			$data['heading'] = $line['inf']['tr'];
806
+	    		}
807
+	    		// heading
623 808
 	    		$data['latitude'] = $line['pt'][0]; // lat
624 809
 	    		$data['longitude'] = $line['pt'][1]; // long
625 810
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
811
+	    		if (isset($line['inf']['sq'])) {
812
+	    			$data['squawk'] = $line['inf']['sq'];
813
+	    		}
814
+	    		// squawk
627 815
 	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
816
+	    		if (isset($line['inf']['rc'])) {
817
+	    			$data['registration'] = $line['inf']['rc'];
818
+	    		}
629 819
 			//$data['departure_airport_iata'] = $line[11];
630 820
 			//$data['arrival_airport_iata'] = $line[12];
631 821
 	    		//$data['emergency'] = ''; // emergency
632 822
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633 823
 	    		$data['format_source'] = 'radarvirtueljson';
634 824
     			$data['id_source'] = $id_source;
635
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
825
+			if (isset($value['name']) && $value['name'] != '') {
826
+				$data['source_name'] = $value['name'];
827
+			}
636 828
 			$SI->add($data);
637 829
 			unset($data);
638 830
 		    }
@@ -653,29 +845,62 @@  discard block
 block discarded – undo
653 845
 		    $data['id'] = $line['id'];
654 846
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655 847
 		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
848
+		    if (isset($line['pilotid'])) {
849
+		    	$data['pilot_id'] = $line['pilotid'];
850
+		    }
851
+		    // pilot id
852
+		    if (isset($line['name'])) {
853
+		    	$data['pilot_name'] = $line['name'];
854
+		    }
855
+		    // pilot name
856
+		    if (isset($line['alt'])) {
857
+		    	$data['altitude'] = $line['alt'];
858
+		    }
859
+		    // altitude
860
+		    if (isset($line['gs'])) {
861
+		    	$data['speed'] = $line['gs'];
862
+		    }
863
+		    // speed
864
+		    if (isset($line['heading'])) {
865
+		    	$data['heading'] = $line['heading'];
866
+		    }
867
+		    // heading
868
+		    if (isset($line['route'])) {
869
+		    	$data['waypoints'] = $line['route'];
870
+		    }
871
+		    // route
662 872
 		    $data['latitude'] = $line['lat']; // lat
663 873
 		    $data['longitude'] = $line['lon']; // long
664 874
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665 875
 		    //$data['squawk'] = $line['squawk']; // squawk
666 876
 		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
877
+		    if (isset($line['depicao'])) {
878
+		    	$data['departure_airport_icao'] = $line['depicao'];
879
+		    }
880
+		    if (isset($line['deptime'])) {
881
+		    	$data['departure_airport_time'] = $line['deptime'];
882
+		    }
883
+		    if (isset($line['arricao'])) {
884
+		    	$data['arrival_airport_icao'] = $line['arricao'];
885
+		    }
670 886
 		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
887
+		    if (isset($line['aircraft'])) {
888
+		    	$data['aircraft_icao'] = $line['aircraft'];
889
+		    }
890
+		    if (isset($line['transponder'])) {
891
+		    	$data['squawk'] = $line['transponder'];
892
+		    }
893
+		    if (isset($line['atis'])) {
894
+		    	$data['info'] = $line['atis'];
895
+		    } else {
896
+		    	$data['info'] = '';
897
+		    }
675 898
 		    $data['format_source'] = 'pireps';
676 899
     		    $data['id_source'] = $id_source;
677 900
 		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
901
+		    if (isset($value['name']) && $value['name'] != '') {
902
+		    	$data['source_name'] = $value['name'];
903
+		    }
679 904
 		    if ($line['icon'] == 'plane') {
680 905
 			$SI->add($data);
681 906
 		    //    print_r($data);
@@ -684,15 +909,25 @@  discard block
 block discarded – undo
684 909
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 910
 			$typec = substr($data['ident'],-3);
686 911
 			$data['type'] = '';
687
-			if ($typec == 'APP') $data['type'] = 'Approach';
688
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
689
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
690
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
691
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
692
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
693
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695
-			else $data['type'] = 'Observer';
912
+			if ($typec == 'APP') {
913
+				$data['type'] = 'Approach';
914
+			} elseif ($typec == 'TWR') {
915
+				$data['type'] = 'Tower';
916
+			} elseif ($typec == 'OBS') {
917
+				$data['type'] = 'Observer';
918
+			} elseif ($typec == 'GND') {
919
+				$data['type'] = 'Ground';
920
+			} elseif ($typec == 'DEL') {
921
+				$data['type'] = 'Delivery';
922
+			} elseif ($typec == 'DEP') {
923
+				$data['type'] = 'Departure';
924
+			} elseif ($typec == 'FSS') {
925
+				$data['type'] = 'Flight Service Station';
926
+			} elseif ($typec == 'CTR') {
927
+				$data['type'] = 'Control Radar or Centre';
928
+			} else {
929
+				$data['type'] = 'Observer';
930
+			}
696 931
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
697 932
 		    }
698 933
 		    unset($data);
@@ -703,7 +938,9 @@  discard block
 block discarded – undo
703 938
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704 939
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705 940
 	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
941
+	    if ($globalDebug) {
942
+	    	echo 'Get Data...'."\n";
943
+	    }
707 944
 	    $buffer = $Common->getData($value['host']);
708 945
 	    $all_data = json_decode($buffer,true);
709 946
 	    if ($buffer != '' && is_array($all_data)) {
@@ -711,10 +948,16 @@  discard block
 block discarded – undo
711 948
 		foreach ($all_data as $line) {
712 949
 	    	    $data = array();
713 950
 	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
951
+	    	    if (isset($line['pilotid'])) {
952
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
953
+	    	    }
715 954
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
955
+	    	    if (isset($line['pilotname'])) {
956
+	    	    	$data['pilot_name'] = $line['pilotname'];
957
+	    	    }
958
+	    	    if (isset($line['pilotid'])) {
959
+	    	    	$data['pilot_id'] = $line['pilotid'];
960
+	    	    }
718 961
 	    	    $data['ident'] = $line['flightnum']; // ident
719 962
 	    	    $data['altitude'] = $line['alt']; // altitude
720 963
 	    	    $data['speed'] = $line['gs']; // speed
@@ -732,27 +975,41 @@  discard block
 block discarded – undo
732 975
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
733 976
     		    $data['arrival_airport_time'] = $line['arrtime'];
734 977
     		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
978
+		    if (isset($line['route'])) {
979
+		    	$data['waypoints'] = $line['route'];
980
+		    }
981
+		    // route
736 982
 		    if (isset($line['aircraftname'])) {
737 983
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 984
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739 985
 	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
986
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
987
+	    			$data['aircraft_icao'] = $aircraft_data[0];
988
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
989
+	    			$data['aircraft_icao'] = $aircraft_data[1];
990
+	    		} else {
743 991
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
992
+	    		    if (isset($aircraft_data[1])) {
993
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
994
+	    		    } else {
995
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
996
+	    		    }
746 997
 	    		}
747 998
 	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
999
+    		    if (isset($line['route'])) {
1000
+    		    	$data['waypoints'] = $line['route'];
1001
+    		    }
749 1002
     		    $data['id_source'] = $id_source;
750 1003
 	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1004
+		    if (isset($value['name']) && $value['name'] != '') {
1005
+		    	$data['source_name'] = $value['name'];
1006
+		    }
752 1007
 		    $SI->add($data);
753 1008
 		    unset($data);
754 1009
 		}
755
-		if ($globalDebug) echo 'No more data...'."\n";
1010
+		if ($globalDebug) {
1011
+			echo 'No more data...'."\n";
1012
+		}
756 1013
 		unset($buffer);
757 1014
 		unset($all_data);
758 1015
 	    }
@@ -760,7 +1017,9 @@  discard block
 block discarded – undo
760 1017
     	    $last_exec[$id]['last'] = time();
761 1018
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762 1019
 	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
1020
+	    if ($globalDebug) {
1021
+	    	echo 'Get Data...'."\n";
1022
+	    }
764 1023
 	    $buffer = $Common->getData($value['host']);
765 1024
 	    $all_data = json_decode($buffer,true);
766 1025
 	    if ($buffer != '' && is_array($all_data)) {
@@ -789,15 +1048,22 @@  discard block
 block discarded – undo
789 1048
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
790 1049
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
791 1050
     		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1051
+		    if (isset($line['route'])) {
1052
+		    	$data['waypoints'] = $line['route'];
1053
+		    }
1054
+		    // route
793 1055
 	    	    $data['aircraft_icao'] = $line['plane_type'];
794 1056
     		    $data['id_source'] = $id_source;
795 1057
 	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1058
+		    if (isset($value['name']) && $value['name'] != '') {
1059
+		    	$data['source_name'] = $value['name'];
1060
+		    }
797 1061
 		    $SI->add($data);
798 1062
 		    unset($data);
799 1063
 		}
800
-		if ($globalDebug) echo 'No more data...'."\n";
1064
+		if ($globalDebug) {
1065
+			echo 'No more data...'."\n";
1066
+		}
801 1067
 		unset($buffer);
802 1068
 		unset($all_data);
803 1069
 	    }
@@ -805,7 +1071,9 @@  discard block
 block discarded – undo
805 1071
     	    $last_exec[$id]['last'] = time();
806 1072
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 1073
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1074
+	    if (function_exists('pcntl_fork')) {
1075
+	    	pcntl_signal_dispatch();
1076
+	    }
809 1077
     	    //$last_exec[$id]['last'] = time();
810 1078
 
811 1079
 	    //$read = array( $sockets[$id] );
@@ -813,7 +1081,9 @@  discard block
 block discarded – undo
813 1081
 	    $write = NULL;
814 1082
 	    $e = NULL;
815 1083
 	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
1084
+	    if ($e != NULL) {
1085
+	    	var_dump($e);
1086
+	    }
817 1087
 	    if ($n > 0) {
818 1088
 		$reset = 0;
819 1089
 		foreach ($read as $nb => $r) {
@@ -835,7 +1105,9 @@  discard block
 block discarded – undo
835 1105
 		    if ($buffer != '') {
836 1106
 			$tt[$format] = 0;
837 1107
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1108
+                    	    if ($globalDebug) {
1109
+                    	    	echo 'ACARS : '.$buffer."\n";
1110
+                    	    }
839 1111
 			    $ACARS->add(trim($buffer));
840 1112
 			    $ACARS->deleteLiveAcarsData();
841 1113
 			} elseif ($format == 'raw') {
@@ -844,9 +1116,15 @@  discard block
 block discarded – undo
844 1116
 			    if (is_array($data)) {
845 1117
 				$data['datetime'] = date('Y-m-d H:i:s');
846 1118
 				$data['format_source'] = 'raw';
847
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1119
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1120
+					$data['source_name'] = $globalSources[$nb]['name'];
1121
+				}
1122
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1123
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1124
+    				}
1125
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1126
+                                	$SI->add($data);
1127
+                                }
850 1128
                             }
851 1129
                         } elseif ($format == 'flightgearsp') {
852 1130
                     	    //echo $buffer."\n";
@@ -864,11 +1142,15 @@  discard block
 block discarded – undo
864 1142
 				$data['speed'] = round($line[5]*1.94384);
865 1143
 				$data['datetime'] = date('Y-m-d H:i:s');
866 1144
 				$data['format_source'] = 'flightgearsp';
867
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1145
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1146
+					$SI->add($data);
1147
+				}
868 1148
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869 1149
 			    }
870 1150
                         } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1151
+                    	    if ($globalDebug) {
1152
+                    	    	echo 'ACARS : '.$buffer."\n";
1153
+                    	    }
872 1154
 			    $ACARS->add(trim($buffer));
873 1155
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874 1156
 			    $ACARS->deleteLiveAcarsData();
@@ -889,7 +1171,9 @@  discard block
 block discarded – undo
889 1171
 				    $aircraft_type = $line[10];
890 1172
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
891 1173
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1174
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1175
+				    	$SI->add($data);
1176
+				    }
893 1177
 				}
894 1178
 			    }
895 1179
 			} elseif ($format == 'beast') {
@@ -905,21 +1189,43 @@  discard block
 block discarded – undo
905 1189
     				$data['hex'] = $lined['hexid'];
906 1190
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907 1191
     				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1192
+    				if (isset($lined['ident'])) {
1193
+    					$data['ident'] = $lined['ident'];
1194
+    				}
1195
+    				if (isset($lined['lat'])) {
1196
+    					$data['latitude'] = $lined['lat'];
1197
+    				}
1198
+    				if (isset($lined['lon'])) {
1199
+    					$data['longitude'] = $lined['lon'];
1200
+    				}
1201
+    				if (isset($lined['speed'])) {
1202
+    					$data['speed'] = $lined['speed'];
1203
+    				}
1204
+    				if (isset($lined['squawk'])) {
1205
+    					$data['squawk'] = $lined['squawk'];
1206
+    				}
1207
+    				if (isset($lined['alt'])) {
1208
+    					$data['altitude'] = $lined['alt'];
1209
+    				}
1210
+    				if (isset($lined['heading'])) {
1211
+    					$data['heading'] = $lined['heading'];
1212
+    				}
915 1213
     				$data['id_source'] = $id_source;
916 1214
     				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1215
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1216
+    					$data['source_name'] = $globalSources[$nb]['name'];
1217
+    				}
1218
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1219
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1220
+    				}
1221
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1222
+    					$SI->add($data);
1223
+    				}
920 1224
     				unset($lined);
921 1225
     				unset($data);
922
-    			    } else $error = true;
1226
+    			    } else {
1227
+    			    	$error = true;
1228
+    			    }
923 1229
 			} elseif ($format == 'aprs' && $use_aprs) {
924 1230
 			    if ($aprs_connect == 0) {
925 1231
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -950,32 +1256,46 @@  discard block
 block discarded – undo
950 1256
 				    $data['latitude'] = $line['latitude'];
951 1257
 				    $data['longitude'] = $line['longitude'];
952 1258
 				    //$data['verticalrate'] = $line[16];
953
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
954
-				    else $data['speed'] = 0;
1259
+				    if (isset($line['speed'])) {
1260
+				    	$data['speed'] = $line['speed'];
1261
+				    } else {
1262
+				    	$data['speed'] = 0;
1263
+				    }
955 1264
 				    $data['altitude'] = $line['altitude'];
956
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1265
+				    if (isset($line['heading'])) {
1266
+				    	$data['heading'] = $line['heading'];
1267
+				    }
957 1268
 				    //else $data['heading'] = 0;
958 1269
 				    $data['aircraft_type'] = $line['stealth'];
959
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1270
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1271
+				    	$data['noarchive'] = true;
1272
+				    }
960 1273
     				    $data['id_source'] = $id_source;
961 1274
 				    $data['format_source'] = 'aprs';
962 1275
 				    $data['source_name'] = $line['source'];
963
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1277
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1278
+    				    }
964 1279
 				    $currentdate = date('Y-m-d H:i:s');
965 1280
 				    $aprsdate = strtotime($data['datetime']);
966 1281
 				    // Accept data if time <= system time + 20s
967
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
968
-				    else {
969
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
970
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1282
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1283
+				    	$send = $SI->add($data);
1284
+				    } else {
1285
+					if ($line['stealth'] != 0) {
1286
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1287
+					} else {
1288
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1289
+					}
971 1290
 				    }
972 1291
 				    unset($data);
973
-				} 
974
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1292
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
975 1293
 					echo '!! Weather Station not yet supported'."\n";
976 1294
 				}
977 1295
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
978
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1296
+				elseif ($line == true && $globalDebug) {
1297
+					echo '!! Failed : '.$buffer."!!\n";
1298
+				}
979 1299
 			    }
980 1300
 			} else {
981 1301
 			    $line = explode(',', $buffer);
@@ -1004,25 +1324,42 @@  discard block
 block discarded – undo
1004 1324
     				$data['ground'] = $line[21];
1005 1325
     				$data['emergency'] = $line[19];
1006 1326
     				$data['format_source'] = 'sbs';
1007
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1008
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1327
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1328
+					$data['source_name'] = $globalSources[$nb]['name'];
1329
+				}
1330
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1331
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1332
+    				}
1009 1333
     				$data['id_source'] = $id_source;
1010
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1011
-    				else $error = true;
1334
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1335
+    					$send = $SI->add($data);
1336
+    				} else {
1337
+    					$error = true;
1338
+    				}
1012 1339
     				unset($data);
1013
-    			    } else $error = true;
1340
+    			    } else {
1341
+    			    	$error = true;
1342
+    			    }
1014 1343
 			    if ($error) {
1015 1344
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1016
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1345
+					if ($globalDebug) {
1346
+						echo "Not a message. Ignoring... \n";
1347
+					}
1017 1348
 				} else {
1018
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1349
+					if ($globalDebug) {
1350
+						echo "Wrong line format. Ignoring... \n";
1351
+					}
1019 1352
 					if ($globalDebug) {
1020 1353
 						echo $buffer;
1021 1354
 						print_r($line);
1022 1355
 					}
1023 1356
 					//socket_close($r);
1024
-					if ($globalDebug) echo "Reconnect after an error...\n";
1025
-					if ($format == 'aprs') $aprs_connect = 0;
1357
+					if ($globalDebug) {
1358
+						echo "Reconnect after an error...\n";
1359
+					}
1360
+					if ($format == 'aprs') {
1361
+						$aprs_connect = 0;
1362
+					}
1026 1363
 					$sourceer[$nb] = $globalSources[$nb];
1027 1364
 					connect_all($sourceer);
1028 1365
 					$sourceer = array();
@@ -1030,10 +1367,14 @@  discard block
 block discarded – undo
1030 1367
 			    }
1031 1368
 			}
1032 1369
 			// Sleep for xxx microseconds
1033
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1370
+			if (isset($globalSBSSleep)) {
1371
+				usleep($globalSBSSleep);
1372
+			}
1034 1373
 		    } else {
1035 1374
 			if ($format == 'flightgearmp') {
1036
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1375
+			    	if ($globalDebug) {
1376
+			    		echo "Reconnect FlightGear MP...";
1377
+			    	}
1037 1378
 				//@socket_close($r);
1038 1379
 				sleep($globalMinFetch);
1039 1380
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1042,10 +1383,15 @@  discard block
 block discarded – undo
1042 1383
 				break;
1043 1384
 				
1044 1385
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1045
-			    if (isset($tt[$format])) $tt[$format]++;
1046
-			    else $tt[$format] = 0;
1386
+			    if (isset($tt[$format])) {
1387
+			    	$tt[$format]++;
1388
+			    } else {
1389
+			    	$tt[$format] = 0;
1390
+			    }
1047 1391
 			    if ($tt[$format] > 30) {
1048
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1392
+				if ($globalDebug) {
1393
+					echo "ERROR : Reconnect ".$format."...";
1394
+				}
1049 1395
 				//@socket_close($r);
1050 1396
 				sleep(2);
1051 1397
 				$aprs_connect = 0;
@@ -1061,12 +1407,18 @@  discard block
 block discarded – undo
1061 1407
 		}
1062 1408
 	    } else {
1063 1409
 		$error = socket_strerror(socket_last_error());
1064
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1410
+		if ($globalDebug) {
1411
+			echo "ERROR : socket_select give this error ".$error . "\n";
1412
+		}
1065 1413
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1066
-			if (isset($globalDebug)) echo "Restarting...\n";
1414
+			if (isset($globalDebug)) {
1415
+				echo "Restarting...\n";
1416
+			}
1067 1417
 			// Restart the script if possible
1068 1418
 			if (is_array($sockets)) {
1069
-			    if ($globalDebug) echo "Shutdown all sockets...";
1419
+			    if ($globalDebug) {
1420
+			    	echo "Shutdown all sockets...";
1421
+			    }
1070 1422
 			    
1071 1423
 			    foreach ($sockets as $sock) {
1072 1424
 				@socket_shutdown($sock,2);
@@ -1074,18 +1426,24 @@  discard block
 block discarded – undo
1074 1426
 			    }
1075 1427
 			    
1076 1428
 			}
1077
-			if ($globalDebug) echo "Restart all connections...";
1429
+			if ($globalDebug) {
1430
+				echo "Restart all connections...";
1431
+			}
1078 1432
 			sleep(2);
1079 1433
 			$time = time();
1080 1434
 			//connect_all($hosts);
1081 1435
 			$aprs_connect = 0;
1082
-			if ($reset > 40) exit('Too many attempts...');
1436
+			if ($reset > 40) {
1437
+				exit('Too many attempts...');
1438
+			}
1083 1439
 			connect_all($globalSources);
1084 1440
 		}
1085 1441
 	    }
1086 1442
 	}
1087 1443
 	if ($globalDaemon === false) {
1088
-	    if ($globalDebug) echo 'Check all...'."\n";
1444
+	    if ($globalDebug) {
1445
+	    	echo 'Check all...'."\n";
1446
+	    }
1089 1447
 	    $SI->checkAll();
1090 1448
 	}
1091 1449
     }
Please login to merge, or discard this patch.
require/class.Spotter.php 1 patch
Spacing   +1345 added lines, -1345 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,52 +59,52 @@  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
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
72
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
73 73
 		$filter_query_join = '';
74 74
 		$filter_query_where = '';
75
-		foreach($filters as $flt) {
75
+		foreach ($filters as $flt) {
76 76
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
77 77
 				if ($flt['airlines'][0] != '') {
78 78
 					if (isset($flt['source'])) {
79
-						$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";
79
+						$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";
80 80
 					} else {
81
-						$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";
81
+						$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";
82 82
 					}
83 83
 				}
84 84
 			}
85 85
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
86 86
 				if (isset($flt['source'])) {
87
-					$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";
87
+					$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";
88 88
 				} else {
89
-					$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";
89
+					$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";
90 90
 				}
91 91
 			}
92 92
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
93 93
 				if (isset($flt['source'])) {
94
-					$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";
94
+					$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";
95 95
 				} else {
96
-					$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";
96
+					$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";
97 97
 				}
98 98
 			}
99 99
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
100 100
 				if (isset($flt['source'])) {
101
-					$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";
101
+					$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";
102 102
 				}
103 103
 			}
104 104
 		}
105 105
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
106 106
 			if ($filter['airlines'][0] != '') {
107
-					$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";
107
+					$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";
108 108
 			}
109 109
 		}
110 110
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 			$filter_query_join .= " INNER JOIN (SELECT icao FROM airlines WHERE alliance = '".$filter['alliance']."') sal ON sal.icao = spotter_output.airline_icao ";
115 115
 		}
116 116
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
117
-				$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";
117
+				$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";
118 118
 			}
119 119
 		if (isset($filter['source']) && !empty($filter['source'])) {
120
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
120
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
121 121
 		}
122 122
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
123 123
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
124 124
 		}
125 125
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
126
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
126
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
127 127
 		}
128 128
 		if (isset($filter['year']) && $filter['year'] != '') {
129 129
 			if ($globalDBdriver == 'mysql') {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
150 150
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
151 151
 		if ($filter_query_where != '') {
152
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
152
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
153 153
 		}
154 154
 		$filter_query = $filter_query_join.$filter_query_where;
155 155
 		return $filter_query;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	* @return Array the spotter information
165 165
 	*
166 166
 	*/
167
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
167
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
168 168
 	{
169 169
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
170 170
 		$Image = new Image($this->db);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 			$sth = $this->db->prepare($query.$limitQuery);
195 195
 			$sth->execute($params);
196 196
 		} catch (PDOException $e) {
197
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
197
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
198 198
 			exit();
199 199
 		}
200 200
 		
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		$spotter_array = array();
205 205
 		
206 206
 
207
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
207
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
208 208
 		{
209 209
 			$num_rows++;
210 210
 			$temp_array = array();
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
249 249
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
250 250
 				$temp_array['route_stop'] = $row['route_stop'];
251
-				$allroute = explode(' ',$row['route_stop']);
251
+				$allroute = explode(' ', $row['route_stop']);
252 252
 				foreach ($allroute as $route) {
253 253
 					$route_airport_array = $this->getAllAirportInfo($route);
254 254
 					if (isset($route_airport_array[0]['name'])) {
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
 				{
302 302
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
303 303
 				} else {
304
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
304
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
305 305
 				}
306 306
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
307
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
308
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
307
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
308
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
309 309
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
310 310
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
311 311
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
312 312
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
313
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
314
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
313
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
314
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
315 315
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
316 316
 					}
317 317
 				}
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
348 348
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
349 349
 					if (is_numeric(substr($row['ident'], 2, 1))) {
350
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
350
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
351 351
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
352
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
352
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
353 353
 					} else {
354 354
 						$airline_array = $this->getAllAirlineInfo('NA');
355 355
 					}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 				}
387 387
 			}
388 388
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
389
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
389
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
390 390
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
391 391
 				if (count($acars_array) > 0) {
392 392
 					$temp_array['acars'] = $acars_array;
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
404 404
 			}
405 405
 
406
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
406
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
407 407
 			{
408 408
 				if ($globalIVAO) {
409
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
410
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
409
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
410
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
411 411
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
412 412
 				if (count($image_array) > 0) {
413 413
 					$temp_array['image'] = $image_array[0]['image'];
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
432 432
 			}
433 433
 			
434
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
434
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
435 435
 				if ($schedules === true) {
436 436
 					$schedule_array = $Schedule->getSchedule($temp_array['ident']);
437 437
 					//print_r($schedule_array);
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
 			if (isset($row['squawk'])) {
514 514
 				$temp_array['squawk'] = $row['squawk'];
515 515
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
516
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
517
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
516
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
517
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
518 518
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
519
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
520
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
521
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
519
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
520
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
521
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
522 522
 			}
523 523
     			
524 524
 			$temp_array['query_number_rows'] = $num_rows;
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	* @return Array the spotter information
538 538
 	*
539 539
 	*/
540
-	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())
540
+	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())
541 541
 	{
542 542
 		global $globalTimezone, $globalDBdriver;
543 543
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 
548 548
 		$query_values = array();
549 549
 		$additional_query = '';
550
-		$filter_query = $this->getFilter($filters,true,true);
550
+		$filter_query = $this->getFilter($filters, true, true);
551 551
 		if ($q != "")
552 552
 		{
553 553
 			if (!is_string($q))
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 				return false;
556 556
 			} else {
557 557
 				$q_array = explode(" ", $q);
558
-				foreach ($q_array as $q_item){
559
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
558
+				foreach ($q_array as $q_item) {
559
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
560 560
 					$additional_query .= " AND (";
561 561
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
562 562
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -588,37 +588,37 @@  discard block
 block discarded – undo
588 588
 
589 589
 		if ($registration != "")
590 590
 		{
591
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
591
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
592 592
 			if (!is_string($registration))
593 593
 			{
594 594
 				return false;
595 595
 			} else {
596 596
 				$additional_query .= " AND spotter_output.registration = :registration";
597
-				$query_values = array_merge($query_values,array(':registration' => $registration));
597
+				$query_values = array_merge($query_values, array(':registration' => $registration));
598 598
 			}
599 599
 		}
600 600
 
601 601
 		if ($aircraft_icao != "")
602 602
 		{
603
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
603
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
604 604
 			if (!is_string($aircraft_icao))
605 605
 			{
606 606
 				return false;
607 607
 			} else {
608 608
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
609
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
609
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
610 610
 			}
611 611
 		}
612 612
 
613 613
 		if ($aircraft_manufacturer != "")
614 614
 		{
615
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
615
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
616 616
 			if (!is_string($aircraft_manufacturer))
617 617
 			{
618 618
 				return false;
619 619
 			} else {
620 620
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
621
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
621
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
622 622
 			}
623 623
 		}
624 624
 
@@ -634,25 +634,25 @@  discard block
 block discarded – undo
634 634
 
635 635
 		if ($airline_icao != "")
636 636
 		{
637
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
637
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
638 638
 			if (!is_string($airline_icao))
639 639
 			{
640 640
 				return false;
641 641
 			} else {
642 642
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
643
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
643
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
644 644
 			}
645 645
 		}
646 646
 
647 647
 		if ($airline_country != "")
648 648
 		{
649
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
649
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
650 650
 			if (!is_string($airline_country))
651 651
 			{
652 652
 				return false;
653 653
 			} else {
654 654
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
655
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
655
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
656 656
 			}
657 657
 		}
658 658
 
@@ -679,31 +679,31 @@  discard block
 block discarded – undo
679 679
 
680 680
 		if ($airport != "")
681 681
 		{
682
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
682
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
683 683
 			if (!is_string($airport))
684 684
 			{
685 685
 				return false;
686 686
 			} else {
687 687
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
688
-				$query_values = array_merge($query_values,array(':airport' => $airport));
688
+				$query_values = array_merge($query_values, array(':airport' => $airport));
689 689
 			}
690 690
 		}
691 691
 
692 692
 		if ($airport_country != "")
693 693
 		{
694
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
694
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
695 695
 			if (!is_string($airport_country))
696 696
 			{
697 697
 				return false;
698 698
 			} else {
699 699
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
700
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
700
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
701 701
 			}
702 702
 		}
703 703
     
704 704
 		if ($callsign != "")
705 705
 		{
706
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
706
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
707 707
 			if (!is_string($callsign))
708 708
 			{
709 709
 				return false;
@@ -711,79 +711,79 @@  discard block
 block discarded – undo
711 711
 				$translate = $Translation->ident2icao($callsign);
712 712
 				if ($translate != $callsign) {
713 713
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
714
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
714
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
715 715
 				} else {
716 716
 					$additional_query .= " AND spotter_output.ident = :callsign";
717
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
717
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
718 718
 				}
719 719
 			}
720 720
 		}
721 721
 
722 722
 		if ($owner != "")
723 723
 		{
724
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
724
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
725 725
 			if (!is_string($owner))
726 726
 			{
727 727
 				return false;
728 728
 			} else {
729 729
 				$additional_query .= " AND spotter_output.owner_name = :owner";
730
-				$query_values = array_merge($query_values,array(':owner' => $owner));
730
+				$query_values = array_merge($query_values, array(':owner' => $owner));
731 731
 			}
732 732
 		}
733 733
 
734 734
 		if ($pilot_name != "")
735 735
 		{
736
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
736
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
737 737
 			if (!is_string($pilot_name))
738 738
 			{
739 739
 				return false;
740 740
 			} else {
741 741
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
742
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
742
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
743 743
 			}
744 744
 		}
745 745
 
746 746
 		if ($pilot_id != "")
747 747
 		{
748
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
748
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
749 749
 			if (!is_string($pilot_id))
750 750
 			{
751 751
 				return false;
752 752
 			} else {
753 753
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
754
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
754
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
755 755
 			}
756 756
 		}
757 757
 
758 758
 		if ($departure_airport_route != "")
759 759
 		{
760
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
760
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
761 761
 			if (!is_string($departure_airport_route))
762 762
 			{
763 763
 				return false;
764 764
 			} else {
765 765
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
766
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
766
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
767 767
 			}
768 768
 		}
769 769
 
770 770
 		if ($arrival_airport_route != "")
771 771
 		{
772
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
772
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
773 773
 			if (!is_string($arrival_airport_route))
774 774
 			{
775 775
 				return false;
776 776
 			} else {
777 777
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
778
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
778
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
779 779
 			}
780 780
 		}
781 781
 
782 782
 		if ($altitude != "")
783 783
 		{
784 784
 			$altitude_array = explode(",", $altitude);
785
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
786
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
785
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
786
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
787 787
 
788 788
 			if ($altitude_array[1] != "")
789 789
 			{                
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 		if ($date_posted != "")
800 800
 		{
801 801
 			$date_array = explode(",", $date_posted);
802
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
803
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
802
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
803
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
804 804
 
805 805
 			if ($globalTimezone != '') {
806 806
 				date_default_timezone_set($globalTimezone);
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
 		{
832 832
 			$limit_array = explode(",", $limit);
833 833
 			
834
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
835
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
834
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
835
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
836 836
 			
837 837
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
838 838
 			{
@@ -861,23 +861,23 @@  discard block
 block discarded – undo
861 861
 
862 862
 
863 863
 		if ($origLat != "" && $origLon != "" && $dist != "") {
864
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
864
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
865 865
 
866 866
 			if ($globalDBdriver == 'mysql') {
867
-				$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 
867
+				$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 
868 868
 						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)) 
869 869
 						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;
870 870
 			} else {
871
-				$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 
871
+				$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 
872 872
 						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)) 
873 873
 						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;
874 874
 			}
875 875
 		} else {		
876
-			$query  = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
876
+			$query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
877 877
 					".$additional_query."
878 878
 					".$orderby_query;
879 879
 		}
880
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
880
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
881 881
 		return $spotter_array;
882 882
 	}
883 883
 	
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
 		{
901 901
 			$limit_array = explode(",", $limit);
902 902
 			
903
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
904
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
903
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
904
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
905 905
 			
906 906
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
907 907
 			{
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
 			$orderby_query = " ORDER BY spotter_output.date DESC";
919 919
 		}
920 920
 
921
-		$query  = $global_query.$filter_query." ".$orderby_query;
921
+		$query = $global_query.$filter_query." ".$orderby_query;
922 922
 
923
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
923
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
924 924
 
925 925
 		return $spotter_array;
926 926
 	}
@@ -966,34 +966,34 @@  discard block
 block discarded – undo
966 966
 			{
967 967
 				return false;
968 968
 			} else {
969
-				if ($interval == "30m"){
969
+				if ($interval == "30m") {
970 970
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
971
-				} else if ($interval == "1h"){
971
+				} else if ($interval == "1h") {
972 972
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
973
-				} else if ($interval == "3h"){
973
+				} else if ($interval == "3h") {
974 974
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
975
-				} else if ($interval == "6h"){
975
+				} else if ($interval == "6h") {
976 976
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
977
-				} else if ($interval == "12h"){
977
+				} else if ($interval == "12h") {
978 978
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
979
-				} else if ($interval == "24h"){
979
+				} else if ($interval == "24h") {
980 980
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
981
-				} else if ($interval == "7d"){
981
+				} else if ($interval == "7d") {
982 982
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
983
-				} else if ($interval == "30d"){
983
+				} else if ($interval == "30d") {
984 984
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
985 985
 				} 
986 986
 			}
987 987
 		}
988 988
 
989
-		$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 
989
+		$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 
990 990
                    WHERE spotter_output.latitude <> '' 
991 991
 				   AND spotter_output.longitude <> '' 
992 992
                    ".$additional_query."
993 993
                    HAVING distance < :radius  
994 994
 				   ORDER BY distance";
995 995
 
996
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
996
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
997 997
 
998 998
 		return $spotter_array;
999 999
 	}
@@ -1005,21 +1005,21 @@  discard block
 block discarded – undo
1005 1005
 	* @return Array the spotter information
1006 1006
 	*
1007 1007
 	*/
1008
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1008
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
1009 1009
 	{
1010 1010
 		global $global_query;
1011 1011
 		
1012 1012
 		date_default_timezone_set('UTC');
1013 1013
 
1014
-		$filter_query = $this->getFilter($filter,true,true);
1014
+		$filter_query = $this->getFilter($filter, true, true);
1015 1015
 
1016 1016
 		$limit_query = '';
1017 1017
 		if ($limit != "")
1018 1018
 		{
1019 1019
 			$limit_array = explode(",", $limit);
1020 1020
 			
1021
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1022
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1021
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1022
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1023 1023
 			
1024 1024
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1025 1025
 			{
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1037 1037
 		}
1038 1038
 
1039
-		$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;
1039
+		$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;
1040 1040
 
1041 1041
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1042 1042
 
@@ -1055,15 +1055,15 @@  discard block
 block discarded – undo
1055 1055
 		global $global_query;
1056 1056
 		
1057 1057
 		date_default_timezone_set('UTC');
1058
-		$filter_query = $this->getFilter($filter,true,true);
1058
+		$filter_query = $this->getFilter($filter, true, true);
1059 1059
 
1060 1060
 		$limit_query = '';
1061 1061
 		if ($limit != "")
1062 1062
 		{
1063 1063
 			$limit_array = explode(",", $limit);
1064 1064
 			
1065
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1066
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1065
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1066
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1067 1067
 			
1068 1068
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1069 1069
 			{
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1081 1081
 		}
1082 1082
 
1083
-		$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;
1083
+		$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;
1084 1084
 
1085 1085
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1086 1086
 
@@ -1094,20 +1094,20 @@  discard block
 block discarded – undo
1094 1094
 	* @return Array the spotter information
1095 1095
 	*
1096 1096
 	*/
1097
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1097
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
1098 1098
 	{
1099 1099
 		global $global_query;
1100 1100
 		
1101 1101
 		date_default_timezone_set('UTC');
1102
-		$filter_query = $this->getFilter($filter,true,true);
1102
+		$filter_query = $this->getFilter($filter, true, true);
1103 1103
 		
1104 1104
 		$limit_query = '';
1105 1105
 		if ($limit != "")
1106 1106
 		{
1107 1107
 			$limit_array = explode(",", $limit);
1108 1108
 			
1109
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1110
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1109
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1110
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1111 1111
 			
1112 1112
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1113 1113
 			{
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1125 1125
 		}
1126 1126
 
1127
-		$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;
1127
+		$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;
1128 1128
 
1129 1129
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1130 1130
 
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 		
1145 1145
 		date_default_timezone_set('UTC');
1146 1146
 		
1147
-		$filter_query = $this->getFilter($filter,true,true);
1147
+		$filter_query = $this->getFilter($filter, true, true);
1148 1148
 		
1149 1149
 		$limit_query = '';
1150 1150
 		
@@ -1152,8 +1152,8 @@  discard block
 block discarded – undo
1152 1152
 		{
1153 1153
 			$limit_array = explode(",", $limit);
1154 1154
 			
1155
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1156
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1155
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1156
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1157 1157
 			
1158 1158
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1159 1159
 			{
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1171 1171
 		}
1172 1172
 
1173
-		$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;
1173
+		$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;
1174 1174
 
1175 1175
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1176 1176
 
@@ -1189,14 +1189,14 @@  discard block
 block discarded – undo
1189 1189
 		global $global_query;
1190 1190
 		
1191 1191
 		date_default_timezone_set('UTC');
1192
-		$filter_query = $this->getFilter($filter,true,true);
1192
+		$filter_query = $this->getFilter($filter, true, true);
1193 1193
 		$limit_query = '';
1194 1194
 		if ($limit != "")
1195 1195
 		{
1196 1196
 			$limit_array = explode(",", $limit);
1197 1197
 			
1198
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1199
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1198
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1199
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1200 1200
 			
1201 1201
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1202 1202
 			{
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1214 1214
 		}
1215 1215
 
1216
-		$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;
1216
+		$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;
1217 1217
 
1218 1218
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1219 1219
 
@@ -1237,9 +1237,9 @@  discard block
 block discarded – undo
1237 1237
 		$query_values = array(':id' => $id);
1238 1238
 
1239 1239
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1240
-		$query  = $global_query." WHERE ".$additional_query." ";
1240
+		$query = $global_query." WHERE ".$additional_query." ";
1241 1241
 
1242
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1242
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1243 1243
 
1244 1244
 		return $spotter_array;
1245 1245
 	}
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 		$query_values = array();
1263 1263
 		$limit_query = '';
1264 1264
 		$additional_query = '';
1265
-		$filter_query = $this->getFilter($filter,true,true);
1265
+		$filter_query = $this->getFilter($filter, true, true);
1266 1266
 		if ($ident != "")
1267 1267
 		{
1268 1268
 			if (!is_string($ident))
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 		{
1279 1279
 			$limit_array = explode(",", $limit);
1280 1280
 			
1281
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1282
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1281
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1282
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1283 1283
 			
1284 1284
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1285 1285
 			{
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
 		$query_values = array();
1319 1319
 		$limit_query = '';
1320 1320
 		$additional_query = '';
1321
-		$filter_query = $this->getFilter($filter,true,true);
1321
+		$filter_query = $this->getFilter($filter, true, true);
1322 1322
 		if ($owner != "")
1323 1323
 		{
1324 1324
 			if (!is_string($owner))
@@ -1334,8 +1334,8 @@  discard block
 block discarded – undo
1334 1334
 		{
1335 1335
 			$limit_array = explode(",", $limit);
1336 1336
 			
1337
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1338
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1337
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1338
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1339 1339
 			
1340 1340
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1341 1341
 			{
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 		$query_values = array();
1376 1376
 		$limit_query = '';
1377 1377
 		$additional_query = '';
1378
-		$filter_query = $this->getFilter($filter,true,true);
1378
+		$filter_query = $this->getFilter($filter, true, true);
1379 1379
 		if ($pilot != "")
1380 1380
 		{
1381 1381
 			$additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
 		{
1387 1387
 			$limit_array = explode(",", $limit);
1388 1388
 			
1389
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1390
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1389
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1390
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1391 1391
 			
1392 1392
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1393 1393
 			{
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 		$query_values = array();
1429 1429
 		$limit_query = '';
1430 1430
 		$additional_query = '';
1431
-		$filter_query = $this->getFilter($filter,true,true);
1431
+		$filter_query = $this->getFilter($filter, true, true);
1432 1432
 		
1433 1433
 		if ($aircraft_type != "")
1434 1434
 		{
@@ -1445,8 +1445,8 @@  discard block
 block discarded – undo
1445 1445
 		{
1446 1446
 			$limit_array = explode(",", $limit);
1447 1447
 			
1448
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1449
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1448
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1449
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1450 1450
 			
1451 1451
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1452 1452
 			{
@@ -1502,8 +1502,8 @@  discard block
 block discarded – undo
1502 1502
 		{
1503 1503
 			$limit_array = explode(",", $limit);
1504 1504
 			
1505
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1506
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1505
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1506
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1507 1507
 			
1508 1508
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1509 1509
 			{
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 		} else {
1520 1520
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1521 1521
 		}
1522
-		$filter_query = $this->getFilter($filter,true,true);
1522
+		$filter_query = $this->getFilter($filter, true, true);
1523 1523
 
1524 1524
 		//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1525 1525
 		$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query;
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
 	* @return Array the spotter information
1539 1539
 	*
1540 1540
 	*/
1541
-	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1541
+	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '', $filters = array())
1542 1542
 	{
1543 1543
 		global $global_query;
1544 1544
 		
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 		$query_values = array();
1548 1548
 		$limit_query = '';
1549 1549
 		$additional_query = '';
1550
-		$filter_query = $this->getFilter($filters,true,true);
1550
+		$filter_query = $this->getFilter($filters, true, true);
1551 1551
 		
1552 1552
 		if ($airline != "")
1553 1553
 		{
@@ -1564,8 +1564,8 @@  discard block
 block discarded – undo
1564 1564
 		{
1565 1565
 			$limit_array = explode(",", $limit);
1566 1566
 			
1567
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1568
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1567
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1568
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1569 1569
 			
1570 1570
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1571 1571
 			{
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
 	* @return Array the spotter information
1596 1596
 	*
1597 1597
 	*/
1598
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1598
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1599 1599
 	{
1600 1600
 		global $global_query;
1601 1601
 		
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 		$query_values = array();
1604 1604
 		$limit_query = '';
1605 1605
 		$additional_query = '';
1606
-		$filter_query = $this->getFilter($filters,true,true);
1606
+		$filter_query = $this->getFilter($filters, true, true);
1607 1607
 		
1608 1608
 		if ($airport != "")
1609 1609
 		{
@@ -1620,8 +1620,8 @@  discard block
 block discarded – undo
1620 1620
 		{
1621 1621
 			$limit_array = explode(",", $limit);
1622 1622
 			
1623
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1624
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1623
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1624
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1625 1625
 			
1626 1626
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1627 1627
 			{
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
 	* @return Array the spotter information
1654 1654
 	*
1655 1655
 	*/
1656
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1656
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1657 1657
 	{
1658 1658
 		global $global_query, $globalTimezone, $globalDBdriver;
1659 1659
 		
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
 		$limit_query = '';
1662 1662
 		$additional_query = '';
1663 1663
 
1664
-		$filter_query = $this->getFilter($filter,true,true);
1664
+		$filter_query = $this->getFilter($filter, true, true);
1665 1665
 		
1666 1666
 		if ($date != "")
1667 1667
 		{
@@ -1690,8 +1690,8 @@  discard block
 block discarded – undo
1690 1690
 		{
1691 1691
 			$limit_array = explode(",", $limit);
1692 1692
 			
1693
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1694
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1693
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1694
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1695 1695
 			
1696 1696
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1697 1697
 			{
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 	* @return Array the spotter information
1722 1722
 	*
1723 1723
 	*/
1724
-	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1724
+	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '', $filters = array())
1725 1725
 	{
1726 1726
 		global $global_query;
1727 1727
 		
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
 		$query_values = array();
1731 1731
 		$limit_query = '';
1732 1732
 		$additional_query = '';
1733
-		$filter_query = $this->getFilter($filters,true,true);
1733
+		$filter_query = $this->getFilter($filters, true, true);
1734 1734
 		if ($country != "")
1735 1735
 		{
1736 1736
 			if (!is_string($country))
@@ -1747,8 +1747,8 @@  discard block
 block discarded – undo
1747 1747
 		{
1748 1748
 			$limit_array = explode(",", $limit);
1749 1749
 			
1750
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1751
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1750
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1751
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1752 1752
 			
1753 1753
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1754 1754
 			{
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 		$query_values = array();
1789 1789
 		$additional_query = '';
1790 1790
 		$limit_query = '';
1791
-		$filter_query = $this->getFilter($filters,true,true);
1791
+		$filter_query = $this->getFilter($filters, true, true);
1792 1792
 		
1793 1793
 		if ($aircraft_manufacturer != "")
1794 1794
 		{
@@ -1805,8 +1805,8 @@  discard block
 block discarded – undo
1805 1805
 		{
1806 1806
 			$limit_array = explode(",", $limit);
1807 1807
 			
1808
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1809
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1808
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1809
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1810 1810
 			
1811 1811
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1812 1812
 			{
@@ -1848,14 +1848,14 @@  discard block
 block discarded – undo
1848 1848
 		$query_values = array();
1849 1849
 		$additional_query = '';
1850 1850
 		$limit_query = '';
1851
-		$filter_query = $this->getFilter($filters,true,true);
1851
+		$filter_query = $this->getFilter($filters, true, true);
1852 1852
 		if ($departure_airport_icao != "")
1853 1853
 		{
1854 1854
 			if (!is_string($departure_airport_icao))
1855 1855
 			{
1856 1856
 				return false;
1857 1857
 			} else {
1858
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1858
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1859 1859
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1860 1860
 				//$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";
1861 1861
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
@@ -1868,10 +1868,10 @@  discard block
 block discarded – undo
1868 1868
 			{
1869 1869
 				return false;
1870 1870
 			} else {
1871
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1871
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1872 1872
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1873 1873
 				//$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)";
1874
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1874
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1875 1875
 			}
1876 1876
 		}
1877 1877
 		
@@ -1879,8 +1879,8 @@  discard block
 block discarded – undo
1879 1879
 		{
1880 1880
 			$limit_array = explode(",", $limit);
1881 1881
 			
1882
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1883
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1882
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1883
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1884 1884
 			
1885 1885
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1886 1886
 			{
@@ -1919,15 +1919,15 @@  discard block
 block discarded – undo
1919 1919
 		global $global_query;
1920 1920
 		
1921 1921
 		date_default_timezone_set('UTC');
1922
-		$filter_query = $this->getFilter($filter,true,true);
1922
+		$filter_query = $this->getFilter($filter, true, true);
1923 1923
 		$limit_query = '';
1924 1924
 		
1925 1925
 		if ($limit != "")
1926 1926
 		{
1927 1927
 			$limit_array = explode(",", $limit);
1928 1928
 			
1929
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1930
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1929
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1930
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1931 1931
 			
1932 1932
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1933 1933
 			{
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1945 1945
 		}
1946 1946
 
1947
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1947
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1948 1948
 
1949 1949
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1950 1950
 
@@ -1957,19 +1957,19 @@  discard block
 block discarded – undo
1957 1957
 	* @return String the highlight text
1958 1958
 	*
1959 1959
 	*/
1960
-	public function getHighlightByRegistration($registration,$filter = array())
1960
+	public function getHighlightByRegistration($registration, $filter = array())
1961 1961
 	{
1962 1962
 		global $global_query;
1963 1963
 		
1964 1964
 		date_default_timezone_set('UTC');
1965
-		$filter_query = $this->getFilter($filter,true,true);
1966
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1965
+		$filter_query = $this->getFilter($filter, true, true);
1966
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1967 1967
 		
1968
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1968
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1969 1969
 		$sth = $this->db->prepare($query);
1970 1970
 		$sth->execute(array(':registration' => $registration));
1971 1971
 
1972
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1972
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1973 1973
 		{
1974 1974
 			$highlight = $row['highlight'];
1975 1975
 		}
@@ -1985,14 +1985,14 @@  discard block
 block discarded – undo
1985 1985
 	* @return String usage
1986 1986
 	*
1987 1987
 	*/
1988
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1988
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1989 1989
 	{
1990 1990
 		
1991
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
1992
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
1991
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
1992
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
1993 1993
 
1994 1994
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
1995
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
1995
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
1996 1996
 		
1997 1997
 		$sth = $this->db->prepare($query);
1998 1998
 		$sth->execute($query_values);
@@ -2014,9 +2014,9 @@  discard block
 block discarded – undo
2014 2014
 	public function getAirportIcao($airport_iata = '')
2015 2015
 	{
2016 2016
 		
2017
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
2017
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
2018 2018
 
2019
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2019
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2020 2020
 		$query_values = array(':airport' => $airport_iata);
2021 2021
 		
2022 2022
 		$sth = $this->db->prepare($query);
@@ -2038,12 +2038,12 @@  discard block
 block discarded – undo
2038 2038
 	* @return Float distance to the airport
2039 2039
 	*
2040 2040
 	*/
2041
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
2041
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
2042 2042
 	{
2043 2043
 		
2044
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
2044
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
2045 2045
 
2046
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2046
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2047 2047
 		$query_values = array(':airport' => $airport_icao);
2048 2048
 		$sth = $this->db->prepare($query);
2049 2049
 		$sth->execute($query_values);
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
 			$airport_latitude = $row['latitude'];
2054 2054
 			$airport_longitude = $row['longitude'];
2055 2055
 			$Common = new Common();
2056
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2056
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
2057 2057
 		} else return '';
2058 2058
 	}
2059 2059
 	
@@ -2067,11 +2067,11 @@  discard block
 block discarded – undo
2067 2067
 	public function getAllAirportInfo($airport = '')
2068 2068
 	{
2069 2069
 		
2070
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
2070
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
2071 2071
 
2072 2072
 		$query_values = array();
2073 2073
 		if ($airport == 'NA') {
2074
-			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' => ''));
2074
+			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' => ''));
2075 2075
 		} elseif ($airport == '') {
2076 2076
 			$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";
2077 2077
 		} else {
@@ -2119,14 +2119,14 @@  discard block
 block discarded – undo
2119 2119
 	{
2120 2120
 		$lst_countries = '';
2121 2121
 		foreach ($countries as $country) {
2122
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
2122
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
2123 2123
 			if ($lst_countries == '') {
2124 2124
 				$lst_countries = "'".$country."'";
2125 2125
 			} else {
2126 2126
 				$lst_countries .= ",'".$country."'";
2127 2127
 			}
2128 2128
 		}
2129
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2129
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2130 2130
 		
2131 2131
 		$sth = $this->db->prepare($query);
2132 2132
 		$sth->execute();
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
 		$airport_array = array();
2135 2135
 		$temp_array = array();
2136 2136
 		
2137
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2137
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2138 2138
 		{
2139 2139
 			$temp_array['name'] = $row['name'];
2140 2140
 			$temp_array['city'] = $row['city'];
@@ -2162,10 +2162,10 @@  discard block
 block discarded – undo
2162 2162
 	{
2163 2163
 		global $globalDBdriver;
2164 2164
 		if (is_array($coord)) {
2165
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2166
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2167
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2168
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2165
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2166
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2167
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2168
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2169 2169
 		} else return array();
2170 2170
 		if ($globalDBdriver == 'mysql') {
2171 2171
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
     
2178 2178
 		$airport_array = array();
2179 2179
 		
2180
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2180
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2181 2181
 		{
2182 2182
 			$temp_array = $row;
2183 2183
 
@@ -2197,13 +2197,13 @@  discard block
 block discarded – undo
2197 2197
 	public function getAllWaypointsInfobyCoord($coord)
2198 2198
 	{
2199 2199
 		if (is_array($coord)) {
2200
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2201
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2202
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2203
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2200
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2201
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2202
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2203
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2204 2204
 		} else return array();
2205 2205
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2206
-		$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.")";
2206
+		$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.")";
2207 2207
 		//$query  = "SELECT waypoints.* FROM waypoints";
2208 2208
 		//$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";
2209 2209
 		//$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;
@@ -2215,7 +2215,7 @@  discard block
 block discarded – undo
2215 2215
     
2216 2216
 		$waypoints_array = array();
2217 2217
 		
2218
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2218
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2219 2219
 		{
2220 2220
 			$temp_array = $row;
2221 2221
 
@@ -2237,10 +2237,10 @@  discard block
 block discarded – undo
2237 2237
 	{
2238 2238
 		global $globalUseRealAirlines;
2239 2239
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2240
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2240
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2241 2241
 		if ($airline_icao == 'NA') {
2242 2242
 			$airline_array = array();
2243
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2243
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2244 2244
 			return $airline_array;
2245 2245
 		} else {
2246 2246
 			if (strlen($airline_icao) == 2) {
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
 			if ($fromsource === NULL) {
2262 2262
 				$sth->execute(array(':airline_icao' => $airline_icao));
2263 2263
 			} else {
2264
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2264
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2265 2265
 			}
2266 2266
                         /*
2267 2267
 			$airline_array = array();
@@ -2306,13 +2306,13 @@  discard block
 block discarded – undo
2306 2306
 	{
2307 2307
 		global $globalUseRealAirlines;
2308 2308
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2309
-		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2310
-		$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";
2309
+		$airline_name = strtolower(filter_var($airline_name, FILTER_SANITIZE_STRING));
2310
+		$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";
2311 2311
 		$sth = $this->db->prepare($query);
2312 2312
 		if ($fromsource === NULL) {
2313 2313
 			$sth->execute(array(':airline_name' => $airline_name));
2314 2314
 		} else {
2315
-			$sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource));
2315
+			$sth->execute(array(':airline_name' => $airline_name, ':fromsource' => $fromsource));
2316 2316
 		}
2317 2317
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2318 2318
 		if (empty($result) && $fromsource !== NULL) {
@@ -2337,12 +2337,12 @@  discard block
 block discarded – undo
2337 2337
 	*/
2338 2338
 	public function getAllAircraftInfo($aircraft_type)
2339 2339
 	{
2340
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2340
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2341 2341
 
2342 2342
 		if ($aircraft_type == 'NA') {
2343
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2343
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2344 2344
 		}
2345
-		$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";
2345
+		$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";
2346 2346
 		
2347 2347
 		$sth = $this->db->prepare($query);
2348 2348
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 	*/
2375 2375
 	public function getAircraftIcao($aircraft_type)
2376 2376
 	{
2377
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2377
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2378 2378
 		$all_aircraft = array('737-300' => 'B733',
2379 2379
 				'777-200' => 'B772',
2380 2380
 				'777-200ER' => 'B772',
@@ -2386,10 +2386,10 @@  discard block
 block discarded – undo
2386 2386
 				'A380' => 'A388');
2387 2387
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2388 2388
 
2389
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2389
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2390 2390
 		$aircraft_type = strtoupper($aircraft_type);
2391 2391
 		$sth = $this->db->prepare($query);
2392
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2392
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2393 2393
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2394 2394
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2395 2395
 		else return '';
@@ -2404,9 +2404,9 @@  discard block
 block discarded – undo
2404 2404
 	*/
2405 2405
 	public function getAllAircraftType($aircraft_modes)
2406 2406
 	{
2407
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2407
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2408 2408
 
2409
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1";
2409
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1";
2410 2410
 		
2411 2411
 		$sth = $this->db->prepare($query);
2412 2412
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -2429,9 +2429,9 @@  discard block
 block discarded – undo
2429 2429
 	*/
2430 2430
 	public function getAllAircraftTypeByRegistration($registration)
2431 2431
 	{
2432
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2432
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2433 2433
 
2434
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2434
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2435 2435
 		
2436 2436
 		$sth = $this->db->prepare($query);
2437 2437
 		$sth->execute(array(':registration' => $registration));
@@ -2452,9 +2452,9 @@  discard block
 block discarded – undo
2452 2452
 	*/
2453 2453
 	public function getAllIDByRegistration($registration)
2454 2454
 	{
2455
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2455
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2456 2456
 
2457
-		$query  = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2457
+		$query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2458 2458
 		
2459 2459
 		$sth = $this->db->prepare($query);
2460 2460
 		$sth->execute(array(':registration' => $registration));
@@ -2462,7 +2462,7 @@  discard block
 block discarded – undo
2462 2462
 		$idarray = array();
2463 2463
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
2464 2464
 			$date = $row['date'];
2465
-			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']);
2465
+			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'], 'spotter_id' => $row['spotter_id']);
2466 2466
 		}
2467 2467
 		return $idarray;
2468 2468
 	}
@@ -2476,8 +2476,8 @@  discard block
 block discarded – undo
2476 2476
 	*/
2477 2477
 	public function getOperator($operator)
2478 2478
 	{
2479
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2480
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2479
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2480
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2481 2481
 		
2482 2482
 		$sth = $this->db->prepare($query);
2483 2483
 		$sth->execute(array(':operator' => $operator));
@@ -2498,9 +2498,9 @@  discard block
 block discarded – undo
2498 2498
 	*/
2499 2499
 	public function getRouteInfo($callsign)
2500 2500
 	{
2501
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2501
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2502 2502
                 if ($callsign == '') return array();
2503
-		$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";
2503
+		$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";
2504 2504
 		
2505 2505
 		$sth = $this->db->prepare($query);
2506 2506
 		$sth->execute(array(':callsign' => $callsign));
@@ -2521,9 +2521,9 @@  discard block
 block discarded – undo
2521 2521
 	*/
2522 2522
 	public function getAircraftInfoByRegistration($registration)
2523 2523
 	{
2524
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2524
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2525 2525
 
2526
-		$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";
2526
+		$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";
2527 2527
 		
2528 2528
 		$sth = $this->db->prepare($query);
2529 2529
 		$sth->execute(array(':registration' => $registration));
@@ -2531,7 +2531,7 @@  discard block
 block discarded – undo
2531 2531
 		$aircraft_array = array();
2532 2532
 		$temp_array = array();
2533 2533
 		
2534
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2534
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2535 2535
 		{
2536 2536
 			$temp_array['airline_icao'] = $row['airline_icao'];
2537 2537
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2553,7 +2553,7 @@  discard block
 block discarded – undo
2553 2553
 	*/
2554 2554
 	public function getAircraftOwnerByRegistration($registration)
2555 2555
 	{
2556
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2556
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2557 2557
 		$Connection = new Connection($this->db);
2558 2558
 		if ($Connection->tableExists('aircraft_owner')) {
2559 2559
 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
@@ -2575,7 +2575,7 @@  discard block
 block discarded – undo
2575 2575
 	public function getAllFlightsforSitemap()
2576 2576
 	{
2577 2577
 		//$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 ";
2578
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2578
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2579 2579
 		
2580 2580
 		$sth = $this->db->prepare($query);
2581 2581
 		$sth->execute();
@@ -2622,7 +2622,7 @@  discard block
 block discarded – undo
2622 2622
 		$manufacturer_array = array();
2623 2623
 		$temp_array = array();
2624 2624
 		
2625
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2625
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2626 2626
 		{
2627 2627
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2628 2628
 
@@ -2659,7 +2659,7 @@  discard block
 block discarded – undo
2659 2659
 		$aircraft_array = array();
2660 2660
 		$temp_array = array();
2661 2661
 		
2662
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2662
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2663 2663
 		{
2664 2664
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2665 2665
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2680,8 +2680,8 @@  discard block
 block discarded – undo
2680 2680
 	*/
2681 2681
 	public function getAllAircraftRegistrations($filters = array())
2682 2682
 	{
2683
-		$filter_query = $this->getFilter($filters,true,true);
2684
-		$query  = "SELECT DISTINCT spotter_output.registration 
2683
+		$filter_query = $this->getFilter($filters, true, true);
2684
+		$query = "SELECT DISTINCT spotter_output.registration 
2685 2685
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' 
2686 2686
 				ORDER BY spotter_output.registration ASC";
2687 2687
 
@@ -2691,7 +2691,7 @@  discard block
 block discarded – undo
2691 2691
 		$aircraft_array = array();
2692 2692
 		$temp_array = array();
2693 2693
 		
2694
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2694
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2695 2695
 		{
2696 2696
 			$temp_array['registration'] = $row['registration'];
2697 2697
 
@@ -2708,11 +2708,11 @@  discard block
 block discarded – undo
2708 2708
 	* @return Array list of source name
2709 2709
 	*
2710 2710
 	*/
2711
-	public function getAllSourceName($type = '',$filters = array())
2711
+	public function getAllSourceName($type = '', $filters = array())
2712 2712
 	{
2713
-		$filter_query = $this->getFilter($filters,true,true);
2713
+		$filter_query = $this->getFilter($filters, true, true);
2714 2714
 		$query_values = array();
2715
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2715
+		$query = "SELECT DISTINCT spotter_output.source_name 
2716 2716
 				FROM spotter_output".$filter_query." spotter_output.source_name <> ''";
2717 2717
 		if ($type != '') {
2718 2718
 			$query_values = array(':type' => $type);
@@ -2727,7 +2727,7 @@  discard block
 block discarded – undo
2727 2727
 		$source_array = array();
2728 2728
 		$temp_array = array();
2729 2729
 		
2730
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2730
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2731 2731
 		{
2732 2732
 			$temp_array['source_name'] = $row['source_name'];
2733 2733
 			$source_array[] = $temp_array;
@@ -2743,11 +2743,11 @@  discard block
 block discarded – undo
2743 2743
 	* @return Array list of airline names
2744 2744
 	*
2745 2745
 	*/
2746
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2746
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL, $filters = array())
2747 2747
 	{
2748
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2749
-		$filter_query = $this->getFilter($filters,true,true);
2750
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2748
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2749
+		$filter_query = $this->getFilter($filters, true, true);
2750
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2751 2751
 		if ($airline_type == '' || $airline_type == 'all') {
2752 2752
 			/*
2753 2753
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2766,7 +2766,7 @@  discard block
 block discarded – undo
2766 2766
 				$query_data = array(':forsource' => $forsource);
2767 2767
 			}
2768 2768
 		} else {
2769
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2769
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2770 2770
 					FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
2771 2771
 					AND spotter_output.airline_type = :airline_type 
2772 2772
 					ORDER BY spotter_output.airline_icao ASC";
@@ -2779,7 +2779,7 @@  discard block
 block discarded – undo
2779 2779
 		$airline_array = array();
2780 2780
 		$temp_array = array();
2781 2781
 		
2782
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2782
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2783 2783
 		{
2784 2784
 			$temp_array['airline_icao'] = $row['airline_icao'];
2785 2785
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2796,10 +2796,10 @@  discard block
 block discarded – undo
2796 2796
 	* @return Array list of alliance names
2797 2797
 	*
2798 2798
 	*/
2799
-	public function getAllAllianceNames($forsource = NULL,$filters = array())
2799
+	public function getAllAllianceNames($forsource = NULL, $filters = array())
2800 2800
 	{
2801
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2802
-		$filter_query = $this->getFilter($filters,true,true);
2801
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2802
+		$filter_query = $this->getFilter($filters, true, true);
2803 2803
 		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2804 2804
 		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2805 2805
 		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
@@ -2827,8 +2827,8 @@  discard block
 block discarded – undo
2827 2827
 	*/
2828 2828
 	public function getAllAirlineCountries($filters = array())
2829 2829
 	{
2830
-		$filter_query = $this->getFilter($filters,true,true);
2831
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2830
+		$filter_query = $this->getFilter($filters, true, true);
2831
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2832 2832
 				FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
2833 2833
 				ORDER BY spotter_output.airline_country ASC";
2834 2834
 		
@@ -2839,7 +2839,7 @@  discard block
 block discarded – undo
2839 2839
 		$airline_array = array();
2840 2840
 		$temp_array = array();
2841 2841
 		
2842
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2842
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2843 2843
 		{
2844 2844
 			$temp_array['airline_country'] = $row['airline_country'];
2845 2845
 
@@ -2859,9 +2859,9 @@  discard block
 block discarded – undo
2859 2859
 	*/
2860 2860
 	public function getAllAirportNames($filters = array())
2861 2861
 	{
2862
-		$filter_query = $this->getFilter($filters,true,true);
2862
+		$filter_query = $this->getFilter($filters, true, true);
2863 2863
 		$airport_array = array();
2864
-		$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
2864
+		$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
2865 2865
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2866 2866
 				ORDER BY spotter_output.departure_airport_city ASC";
2867 2867
 		
@@ -2870,7 +2870,7 @@  discard block
 block discarded – undo
2870 2870
 		$sth->execute();
2871 2871
 
2872 2872
 		$temp_array = array();
2873
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2873
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2874 2874
 		{
2875 2875
 			$temp_array['airport_icao'] = $row['airport_icao'];
2876 2876
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2880,14 +2880,14 @@  discard block
 block discarded – undo
2880 2880
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2881 2881
 		}
2882 2882
 
2883
-		$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
2883
+		$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
2884 2884
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2885 2885
 								ORDER BY spotter_output.arrival_airport_city ASC";
2886 2886
 					
2887 2887
 		$sth = $this->db->prepare($query);
2888 2888
 		$sth->execute();
2889 2889
 
2890
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2890
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2891 2891
 			{
2892 2892
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2893 2893
 		//	{
@@ -2911,8 +2911,8 @@  discard block
 block discarded – undo
2911 2911
 	*/
2912 2912
 	public function getAllOwnerNames($filters = array())
2913 2913
 	{
2914
-		$filter_query = $this->getFilter($filters,true,true);
2915
-		$query  = "SELECT DISTINCT spotter_output.owner_name
2914
+		$filter_query = $this->getFilter($filters, true, true);
2915
+		$query = "SELECT DISTINCT spotter_output.owner_name
2916 2916
 				FROM spotter_output".$filter_query." spotter_output.owner_name <> '' 
2917 2917
 				ORDER BY spotter_output.owner_name ASC";
2918 2918
 		
@@ -2929,8 +2929,8 @@  discard block
 block discarded – undo
2929 2929
 	*/
2930 2930
 	public function getAllPilotNames($filters = array())
2931 2931
 	{
2932
-		$filter_query = $this->getFilter($filters,true,true);
2933
-		$query  = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2932
+		$filter_query = $this->getFilter($filters, true, true);
2933
+		$query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2934 2934
 				FROM spotter_output".$filter_query." spotter_output.pilot_name <> '' 
2935 2935
 				ORDER BY spotter_output.pilot_name ASC";
2936 2936
 		
@@ -2963,21 +2963,21 @@  discard block
 block discarded – undo
2963 2963
    
2964 2964
 		$temp_array = array();
2965 2965
 		
2966
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2966
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2967 2967
 		{
2968 2968
 			$temp_array['airport_country'] = $row['airport_country'];
2969 2969
 
2970 2970
 			$airport_array[$row['airport_country']] = $temp_array;
2971 2971
 		}
2972
-		$filter_query = $this->getFilter($filters,true,true);
2973
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2972
+		$filter_query = $this->getFilter($filters, true, true);
2973
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2974 2974
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
2975 2975
 								ORDER BY spotter_output.arrival_airport_country ASC";
2976 2976
 					
2977 2977
 		$sth = $this->db->prepare($query);
2978 2978
 		$sth->execute();
2979 2979
 		
2980
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2980
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2981 2981
 		{
2982 2982
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
2983 2983
 			{
@@ -3000,9 +3000,9 @@  discard block
 block discarded – undo
3000 3000
 	*/
3001 3001
 	public function getAllCountries($filters = array())
3002 3002
 	{
3003
-		$Connection= new Connection($this->db);
3003
+		$Connection = new Connection($this->db);
3004 3004
 		if ($Connection->tableExists('countries')) {
3005
-			$query  = "SELECT countries.name AS airport_country
3005
+			$query = "SELECT countries.name AS airport_country
3006 3006
 				FROM countries
3007 3007
 				ORDER BY countries.name ASC";
3008 3008
 			$sth = $this->db->prepare($query);
@@ -3011,14 +3011,14 @@  discard block
 block discarded – undo
3011 3011
 			$temp_array = array();
3012 3012
 			$country_array = array();
3013 3013
 		
3014
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3014
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3015 3015
 			{
3016 3016
 				$temp_array['country'] = $row['airport_country'];
3017 3017
 				$country_array[$row['airport_country']] = $temp_array;
3018 3018
 			}
3019 3019
 		} else {
3020
-			$filter_query = $this->getFilter($filters,true,true);
3021
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3020
+			$filter_query = $this->getFilter($filters, true, true);
3021
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3022 3022
 								FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' 
3023 3023
 								ORDER BY spotter_output.departure_airport_country ASC";
3024 3024
 
@@ -3027,20 +3027,20 @@  discard block
 block discarded – undo
3027 3027
    
3028 3028
 			$temp_array = array();
3029 3029
 			$country_array = array();
3030
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3030
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3031 3031
 			{
3032 3032
 				$temp_array['country'] = $row['airport_country'];
3033 3033
 				$country_array[$row['airport_country']] = $temp_array;
3034 3034
 			}
3035 3035
 
3036
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3036
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3037 3037
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
3038 3038
 								ORDER BY spotter_output.arrival_airport_country ASC";
3039 3039
 					
3040 3040
 		$sth = $this->db->prepare($query);
3041 3041
 		$sth->execute();
3042 3042
 		
3043
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3043
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3044 3044
 		{
3045 3045
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
3046 3046
 			{
@@ -3050,14 +3050,14 @@  discard block
 block discarded – undo
3050 3050
 			}
3051 3051
 		}
3052 3052
 		
3053
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3053
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3054 3054
 								FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
3055 3055
 								ORDER BY spotter_output.airline_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 (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
3063 3063
 			{
@@ -3081,8 +3081,8 @@  discard block
 block discarded – undo
3081 3081
 	*/
3082 3082
 	public function getAllIdents($filters = array())
3083 3083
 	{
3084
-		$filter_query = $this->getFilter($filters,true,true);
3085
-		$query  = "SELECT DISTINCT spotter_output.ident
3084
+		$filter_query = $this->getFilter($filters, true, true);
3085
+		$query = "SELECT DISTINCT spotter_output.ident
3086 3086
 								FROM spotter_output".$filter_query." spotter_output.ident <> '' 
3087 3087
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
3088 3088
 
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
 		$ident_array = array();
3093 3093
 		$temp_array = array();
3094 3094
 		
3095
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3095
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3096 3096
 		{
3097 3097
 			$temp_array['ident'] = $row['ident'];
3098 3098
 			$ident_array[] = $temp_array;
@@ -3106,9 +3106,9 @@  discard block
 block discarded – undo
3106 3106
 	* @return Array number, icao, name and city of airports
3107 3107
 	*/
3108 3108
 
3109
-	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3109
+	public function getLast7DaysAirportsDeparture($airport_icao = '', $filters = array()) {
3110 3110
 		global $globalTimezone, $globalDBdriver;
3111
-		$filter_query = $this->getFilter($filters,true,true);
3111
+		$filter_query = $this->getFilter($filters, true, true);
3112 3112
 		if ($globalTimezone != '') {
3113 3113
 			date_default_timezone_set($globalTimezone);
3114 3114
 			$datetime = new DateTime();
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
 
3174 3174
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3175 3175
 		global $globalTimezone, $globalDBdriver;
3176
-		$filter_query = $this->getFilter($filters,true,true);
3176
+		$filter_query = $this->getFilter($filters, true, true);
3177 3177
 		if ($globalTimezone != '') {
3178 3178
 			date_default_timezone_set($globalTimezone);
3179 3179
 			$datetime = new DateTime();
@@ -3257,7 +3257,7 @@  discard block
 block discarded – undo
3257 3257
 
3258 3258
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3259 3259
 		global $globalTimezone, $globalDBdriver;
3260
-		$filter_query = $this->getFilter($filters,true,true);
3260
+		$filter_query = $this->getFilter($filters, true, true);
3261 3261
 		if ($globalTimezone != '') {
3262 3262
 			date_default_timezone_set($globalTimezone);
3263 3263
 			$datetime = new DateTime();
@@ -3290,9 +3290,9 @@  discard block
 block discarded – undo
3290 3290
 	* @return Array number, icao, name and city of airports
3291 3291
 	*/
3292 3292
 
3293
-	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3293
+	public function getLast7DaysDetectedAirportsArrival($airport_icao = '', $filters = array()) {
3294 3294
 		global $globalTimezone, $globalDBdriver;
3295
-		$filter_query = $this->getFilter($filters,true,true);
3295
+		$filter_query = $this->getFilter($filters, true, true);
3296 3296
 		if ($globalTimezone != '') {
3297 3297
 			date_default_timezone_set($globalTimezone);
3298 3298
 			$datetime = new DateTime();
@@ -3424,12 +3424,12 @@  discard block
 block discarded – undo
3424 3424
 		} else $offset = '+00:00';
3425 3425
 
3426 3426
 		if ($globalDBdriver == 'mysql') {
3427
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3427
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3428 3428
 								FROM spotter_output
3429 3429
 								WHERE spotter_output.date <> '' 
3430 3430
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3431 3431
 		} else {
3432
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3432
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3433 3433
 								FROM spotter_output
3434 3434
 								WHERE spotter_output.date <> '' 
3435 3435
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
 		$date_array = array();
3442 3442
 		$temp_array = array();
3443 3443
 		
3444
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3444
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3445 3445
 		{
3446 3446
 			$temp_array['date'] = $row['date'];
3447 3447
 
@@ -3461,7 +3461,7 @@  discard block
 block discarded – undo
3461 3461
 	*/
3462 3462
 	public function getAllRoutes()
3463 3463
 	{
3464
-		$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 
3464
+		$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 
3465 3465
 				FROM spotter_output
3466 3466
 				WHERE spotter_output.ident <> '' 
3467 3467
 				GROUP BY route
@@ -3472,7 +3472,7 @@  discard block
 block discarded – undo
3472 3472
 
3473 3473
 		$routes_array = array();
3474 3474
 		$temp_array = array();
3475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3476 3476
 		{
3477 3477
 			$temp_array['route'] = $row['route'];
3478 3478
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3491,21 +3491,21 @@  discard block
 block discarded – undo
3491 3491
 	* @return String success or false
3492 3492
 	*
3493 3493
 	*/	
3494
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3494
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3495 3495
 	{
3496 3496
 		if (!is_numeric(substr($ident, 0, 3)))
3497 3497
 		{
3498 3498
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3499
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3499
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3500 3500
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3501
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3501
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3502 3502
 			} else {
3503 3503
 				$airline_array = $this->getAllAirlineInfo("NA");
3504 3504
 			}
3505 3505
 			if (count($airline_array) == 0) {
3506 3506
 				$airline_array = $this->getAllAirlineInfo("NA");
3507 3507
 			}
3508
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3508
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3509 3509
 				$airline_array = $this->getAllAirlineInfo("NA");
3510 3510
 			}
3511 3511
 		} else {
@@ -3518,7 +3518,7 @@  discard block
 block discarded – undo
3518 3518
 
3519 3519
 
3520 3520
 		$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';
3521
-                $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);
3521
+                $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);
3522 3522
 
3523 3523
 		try {
3524 3524
 			$sth = $this->db->prepare($query);
@@ -3539,11 +3539,11 @@  discard block
 block discarded – undo
3539 3539
 	* @return String success or false
3540 3540
 	*
3541 3541
 	*/	
3542
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3542
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
3543 3543
 	{
3544 3544
 		if ($groundspeed == '') $groundspeed = NULL;
3545 3545
 		$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';
3546
-                $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);
3546
+                $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);
3547 3547
 
3548 3548
 		try {
3549 3549
 			$sth = $this->db->prepare($query);
@@ -3583,7 +3583,7 @@  discard block
 block discarded – undo
3583 3583
 	* @param String $verticalrate vertival rate of flight
3584 3584
 	* @return String success or false
3585 3585
 	*/
3586
-	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '')
3586
+	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false, $format_source = '', $source_name = '')
3587 3587
 	{
3588 3588
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
3589 3589
 		
@@ -3607,13 +3607,13 @@  discard block
 block discarded – undo
3607 3607
 				if ($ModeS != '') {
3608 3608
 					$timeelapsed = microtime(true);
3609 3609
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3610
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3610
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3611 3611
 				} else {
3612
-					$myhex = explode('-',$flightaware_id);
3612
+					$myhex = explode('-', $flightaware_id);
3613 3613
 					if (count($myhex) > 0) {
3614 3614
 						$timeelapsed = microtime(true);
3615 3615
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3616
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3616
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3617 3617
 					}
3618 3618
 				}
3619 3619
 			}
@@ -3635,24 +3635,24 @@  discard block
 block discarded – undo
3635 3635
 				{
3636 3636
 					$timeelapsed = microtime(true);
3637 3637
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3638
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3638
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3639 3639
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3640
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3640
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3641 3641
 					} else {
3642 3642
 						$airline_array = $this->getAllAirlineInfo("NA");
3643 3643
 					}
3644 3644
 					if (count($airline_array) == 0) {
3645 3645
 						$airline_array = $this->getAllAirlineInfo("NA");
3646 3646
 					}
3647
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3647
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3648 3648
 						$airline_array = $this->getAllAirlineInfo("NA");
3649 3649
 					}
3650
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3650
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3651 3651
 
3652 3652
 				} else {
3653 3653
 					$timeelapsed = microtime(true);
3654 3654
 					$airline_array = $this->getAllAirlineInfo("NA");
3655
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3655
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3656 3656
 				}
3657 3657
 			}
3658 3658
 		} else $airline_array = array();
@@ -3669,27 +3669,27 @@  discard block
 block discarded – undo
3669 3669
 				{
3670 3670
 					$timeelapsed = microtime(true);
3671 3671
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3672
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3673 3673
 				} else {
3674 3674
 					$timeelapsed = microtime(true);
3675 3675
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3676
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3676
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3677 3677
 				}
3678 3678
 			}
3679 3679
 		} else {
3680 3680
 			if ($ModeS != '') {
3681 3681
 				$timeelapsed = microtime(true);
3682 3682
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3683
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3683
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3684 3684
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3685 3685
 				{
3686 3686
 					$timeelapsed = microtime(true);
3687 3687
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3688
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3688
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3689 3689
 				} else {
3690 3690
 					$timeelapsed = microtime(true);
3691 3691
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3692
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3692
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3693 3693
 				}
3694 3694
 			}
3695 3695
 		}
@@ -3705,7 +3705,7 @@  discard block
 block discarded – undo
3705 3705
 			} else {
3706 3706
 				$timeelapsed = microtime(true);
3707 3707
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3708
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3708
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3709 3709
 			}
3710 3710
 		}
3711 3711
 		
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
 			} else {
3721 3721
 				$timeelapsed = microtime(true);
3722 3722
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3723
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3723
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3724 3724
 			}
3725 3725
 		}
3726 3726
 
@@ -3773,7 +3773,7 @@  discard block
 block discarded – undo
3773 3773
 		}
3774 3774
 
3775 3775
     
3776
-		if ($date == "" || strtotime($date) < time()-20*60)
3776
+		if ($date == "" || strtotime($date) < time() - 20*60)
3777 3777
 		{
3778 3778
 			$date = date("Y-m-d H:i:s", time());
3779 3779
 		}
@@ -3783,7 +3783,7 @@  discard block
 block discarded – undo
3783 3783
 		{
3784 3784
 			$timeelapsed = microtime(true);
3785 3785
 			$image_array = $Image->getSpotterImage($registration);
3786
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3786
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3787 3787
 			if (!isset($image_array[0]['registration']))
3788 3788
 			{
3789 3789
 				//echo "Add image !!!! \n";
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
 			}
3792 3792
 			$timeelapsed = microtime(true);
3793 3793
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3794
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3794
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3795 3795
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3796 3796
 		}
3797 3797
     
@@ -3799,33 +3799,33 @@  discard block
 block discarded – undo
3799 3799
 		{
3800 3800
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3801 3801
             		else $airline_icao = '';
3802
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3802
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3803 3803
 			if (!isset($image_array[0]['registration']))
3804 3804
 			{
3805 3805
 				//echo "Add image !!!! \n";
3806
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3806
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3807 3807
 			}
3808 3808
 		}
3809 3809
     
3810
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3811
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3812
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3813
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3814
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3815
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3816
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3817
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3818
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3819
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3820
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3821
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3822
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3823
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3824
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3825
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3826
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3827
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3828
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3810
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3811
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3812
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3813
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3814
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3815
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3816
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3817
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3818
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3819
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3820
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3821
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3822
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3823
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3824
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3825
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3826
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3827
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3828
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3829 3829
 	
3830 3830
 		if (count($airline_array) == 0) 
3831 3831
 		{
@@ -3853,7 +3853,7 @@  discard block
 block discarded – undo
3853 3853
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3854 3854
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3855 3855
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3856
-                $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) 
3856
+                $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) 
3857 3857
                 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)";
3858 3858
 
3859 3859
                 $airline_name = $airline_array[0]['name'];
@@ -3863,7 +3863,7 @@  discard block
 block discarded – undo
3863 3863
 		if ($airline_type == '') {
3864 3864
 			$timeelapsed = microtime(true);
3865 3865
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3866
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3866
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3867 3867
 		}
3868 3868
 		if ($airline_type == null) $airline_type = '';
3869 3869
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3875,7 +3875,7 @@  discard block
 block discarded – undo
3875 3875
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3876 3876
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3877 3877
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3878
-                $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);
3878
+                $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);
3879 3879
 
3880 3880
 		try {
3881 3881
 		        
@@ -3901,13 +3901,13 @@  discard block
 block discarded – undo
3901 3901
 	{
3902 3902
 		global $globalDBdriver, $globalTimezone;
3903 3903
 		if ($globalDBdriver == 'mysql') {
3904
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3904
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3905 3905
 								WHERE spotter_output.ident = :ident 
3906 3906
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3907 3907
 								AND spotter_output.date < UTC_TIMESTAMP()";
3908 3908
 			$query_data = array(':ident' => $ident);
3909 3909
 		} else {
3910
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3910
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3911 3911
 								WHERE spotter_output.ident = :ident 
3912 3912
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3913 3913
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3916,8 +3916,8 @@  discard block
 block discarded – undo
3916 3916
 		
3917 3917
 		$sth = $this->db->prepare($query);
3918 3918
 		$sth->execute($query_data);
3919
-    		$ident_result='';
3920
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3919
+    		$ident_result = '';
3920
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3921 3921
 		{
3922 3922
 			$ident_result = $row['ident'];
3923 3923
 		}
@@ -3943,8 +3943,8 @@  discard block
 block discarded – undo
3943 3943
 				return false;
3944 3944
 			} else {
3945 3945
 				$q_array = explode(" ", $q);
3946
-				foreach ($q_array as $q_item){
3947
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3946
+				foreach ($q_array as $q_item) {
3947
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3948 3948
 					$additional_query .= " AND (";
3949 3949
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3950 3950
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3959,11 +3959,11 @@  discard block
 block discarded – undo
3959 3959
 			}
3960 3960
 		}
3961 3961
 		if ($globalDBdriver == 'mysql') {
3962
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3962
+			$query = "SELECT spotter_output.* FROM spotter_output 
3963 3963
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3964 3964
 				AND spotter_output.date < UTC_TIMESTAMP()";
3965 3965
 		} else {
3966
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3966
+			$query = "SELECT spotter_output.* FROM spotter_output 
3967 3967
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3968 3968
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3969 3969
 		}
@@ -3980,11 +3980,11 @@  discard block
 block discarded – undo
3980 3980
 	* @return Array the airline list
3981 3981
 	*
3982 3982
 	*/
3983
-	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
3983
+	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
3984 3984
 	{
3985 3985
 		global $globalDBdriver;
3986
-		$filter_query = $this->getFilter($filters,true,true);
3987
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3986
+		$filter_query = $this->getFilter($filters, true, true);
3987
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3988 3988
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'";
3989 3989
 		if ($olderthanmonths > 0) {
3990 3990
 			if ($globalDBdriver == 'mysql') {
@@ -4004,28 +4004,28 @@  discard block
 block discarded – undo
4004 4004
 		if ($year != '') {
4005 4005
 			if ($globalDBdriver == 'mysql') {
4006 4006
 				$query .= " AND YEAR(spotter_output.date) = :year";
4007
-				$query_values = array_merge($query_values,array(':year' => $year));
4007
+				$query_values = array_merge($query_values, array(':year' => $year));
4008 4008
 			} else {
4009 4009
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4010
-				$query_values = array_merge($query_values,array(':year' => $year));
4010
+				$query_values = array_merge($query_values, array(':year' => $year));
4011 4011
 			}
4012 4012
 		}
4013 4013
 		if ($month != '') {
4014 4014
 			if ($globalDBdriver == 'mysql') {
4015 4015
 				$query .= " AND MONTH(spotter_output.date) = :month";
4016
-				$query_values = array_merge($query_values,array(':month' => $month));
4016
+				$query_values = array_merge($query_values, array(':month' => $month));
4017 4017
 			} else {
4018 4018
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4019
-				$query_values = array_merge($query_values,array(':month' => $month));
4019
+				$query_values = array_merge($query_values, array(':month' => $month));
4020 4020
 			}
4021 4021
 		}
4022 4022
 		if ($day != '') {
4023 4023
 			if ($globalDBdriver == 'mysql') {
4024 4024
 				$query .= " AND DAY(spotter_output.date) = :day";
4025
-				$query_values = array_merge($query_values,array(':day' => $day));
4025
+				$query_values = array_merge($query_values, array(':day' => $day));
4026 4026
 			} else {
4027 4027
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4028
-				$query_values = array_merge($query_values,array(':day' => $day));
4028
+				$query_values = array_merge($query_values, array(':day' => $day));
4029 4029
 			}
4030 4030
 		}
4031 4031
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
@@ -4035,7 +4035,7 @@  discard block
 block discarded – undo
4035 4035
 		$sth->execute($query_values);
4036 4036
 		$airline_array = array();
4037 4037
 		$temp_array = array();
4038
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4038
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4039 4039
 		{
4040 4040
 			$temp_array['airline_name'] = $row['airline_name'];
4041 4041
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4052,11 +4052,11 @@  discard block
 block discarded – undo
4052 4052
 	* @return Array the pilots list
4053 4053
 	*
4054 4054
 	*/
4055
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4055
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4056 4056
 	{
4057 4057
 		global $globalDBdriver;
4058
-		$filter_query = $this->getFilter($filters,true,true);
4059
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4058
+		$filter_query = $this->getFilter($filters, true, true);
4059
+		$query = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4060 4060
 			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 <> ''";
4061 4061
                 if ($olderthanmonths > 0) {
4062 4062
             		if ($globalDBdriver == 'mysql') {
@@ -4076,28 +4076,28 @@  discard block
 block discarded – undo
4076 4076
 		if ($year != '') {
4077 4077
 			if ($globalDBdriver == 'mysql') {
4078 4078
 				$query .= " AND YEAR(spotter_output.date) = :year";
4079
-				$query_values = array_merge($query_values,array(':year' => $year));
4079
+				$query_values = array_merge($query_values, array(':year' => $year));
4080 4080
 			} else {
4081 4081
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4082
-				$query_values = array_merge($query_values,array(':year' => $year));
4082
+				$query_values = array_merge($query_values, array(':year' => $year));
4083 4083
 			}
4084 4084
 		}
4085 4085
 		if ($month != '') {
4086 4086
 			if ($globalDBdriver == 'mysql') {
4087 4087
 				$query .= " AND MONTH(spotter_output.date) = :month";
4088
-				$query_values = array_merge($query_values,array(':month' => $month));
4088
+				$query_values = array_merge($query_values, array(':month' => $month));
4089 4089
 			} else {
4090 4090
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4091
-				$query_values = array_merge($query_values,array(':month' => $month));
4091
+				$query_values = array_merge($query_values, array(':month' => $month));
4092 4092
 			}
4093 4093
 		}
4094 4094
 		if ($day != '') {
4095 4095
 			if ($globalDBdriver == 'mysql') {
4096 4096
 				$query .= " AND DAY(spotter_output.date) = :day";
4097
-				$query_values = array_merge($query_values,array(':day' => $day));
4097
+				$query_values = array_merge($query_values, array(':day' => $day));
4098 4098
 			} else {
4099 4099
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4100
-				$query_values = array_merge($query_values,array(':day' => $day));
4100
+				$query_values = array_merge($query_values, array(':day' => $day));
4101 4101
 			}
4102 4102
 		}
4103 4103
 		
@@ -4109,7 +4109,7 @@  discard block
 block discarded – undo
4109 4109
 		$sth->execute($query_values);
4110 4110
 		$airline_array = array();
4111 4111
 		$temp_array = array();
4112
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4112
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4113 4113
 		{
4114 4114
 			$temp_array['pilot_name'] = $row['pilot_name'];
4115 4115
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4129,7 +4129,7 @@  discard block
 block discarded – undo
4129 4129
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4130 4130
 	{
4131 4131
 		global $globalDBdriver;
4132
-		$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
4132
+		$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
4133 4133
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4134 4134
                 if ($olderthanmonths > 0) {
4135 4135
             		if ($globalDBdriver == 'mysql') {
@@ -4155,7 +4155,7 @@  discard block
 block discarded – undo
4155 4155
 		$airline_array = array();
4156 4156
 		$temp_array = array();
4157 4157
         
4158
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4158
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4159 4159
 		{
4160 4160
 			$temp_array['pilot_name'] = $row['pilot_name'];
4161 4161
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4173,11 +4173,11 @@  discard block
 block discarded – undo
4173 4173
 	* @return Array the pilots list
4174 4174
 	*
4175 4175
 	*/
4176
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4176
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4177 4177
 	{
4178 4178
 		global $globalDBdriver;
4179
-		$filter_query = $this->getFilter($filters,true,true);
4180
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4179
+		$filter_query = $this->getFilter($filters, true, true);
4180
+		$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4181 4181
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4182 4182
                 if ($olderthanmonths > 0) {
4183 4183
             		if ($globalDBdriver == 'mysql') {
@@ -4197,28 +4197,28 @@  discard block
 block discarded – undo
4197 4197
 		if ($year != '') {
4198 4198
 			if ($globalDBdriver == 'mysql') {
4199 4199
 				$query .= " AND YEAR(spotter_output.date) = :year";
4200
-				$query_values = array_merge($query_values,array(':year' => $year));
4200
+				$query_values = array_merge($query_values, array(':year' => $year));
4201 4201
 			} else {
4202 4202
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4203
-				$query_values = array_merge($query_values,array(':year' => $year));
4203
+				$query_values = array_merge($query_values, array(':year' => $year));
4204 4204
 			}
4205 4205
 		}
4206 4206
 		if ($month != '') {
4207 4207
 			if ($globalDBdriver == 'mysql') {
4208 4208
 				$query .= " AND MONTH(spotter_output.date) = :month";
4209
-				$query_values = array_merge($query_values,array(':month' => $month));
4209
+				$query_values = array_merge($query_values, array(':month' => $month));
4210 4210
 			} else {
4211 4211
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4212
-				$query_values = array_merge($query_values,array(':month' => $month));
4212
+				$query_values = array_merge($query_values, array(':month' => $month));
4213 4213
 			}
4214 4214
 		}
4215 4215
 		if ($day != '') {
4216 4216
 			if ($globalDBdriver == 'mysql') {
4217 4217
 				$query .= " AND DAY(spotter_output.date) = :day";
4218
-				$query_values = array_merge($query_values,array(':day' => $day));
4218
+				$query_values = array_merge($query_values, array(':day' => $day));
4219 4219
 			} else {
4220 4220
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4221
-				$query_values = array_merge($query_values,array(':day' => $day));
4221
+				$query_values = array_merge($query_values, array(':day' => $day));
4222 4222
 			}
4223 4223
 		}
4224 4224
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
@@ -4228,7 +4228,7 @@  discard block
 block discarded – undo
4228 4228
 		$sth->execute($query_values);
4229 4229
 		$airline_array = array();
4230 4230
 		$temp_array = array();
4231
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4231
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4232 4232
 		{
4233 4233
 			$temp_array['owner_name'] = $row['owner_name'];
4234 4234
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4243,11 +4243,11 @@  discard block
 block discarded – undo
4243 4243
 	* @return Array the pilots list
4244 4244
 	*
4245 4245
 	*/
4246
-	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4246
+	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4247 4247
 	{
4248 4248
 		global $globalDBdriver;
4249
-		$filter_query = $this->getFilter($filters,true,true);
4250
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4249
+		$filter_query = $this->getFilter($filters, true, true);
4250
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4251 4251
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4252 4252
                 if ($olderthanmonths > 0) {
4253 4253
             		if ($globalDBdriver == 'mysql') {
@@ -4273,7 +4273,7 @@  discard block
 block discarded – undo
4273 4273
 		$airline_array = array();
4274 4274
 		$temp_array = array();
4275 4275
         
4276
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4276
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4277 4277
 		{
4278 4278
 			$temp_array['owner_name'] = $row['owner_name'];
4279 4279
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4289,11 +4289,11 @@  discard block
 block discarded – undo
4289 4289
 	* @return Array the airline list
4290 4290
 	*
4291 4291
 	*/
4292
-	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4292
+	public function countAllAirlinesByAircraft($aircraft_icao, $filters = array())
4293 4293
 	{
4294
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4295
-		$filter_query = $this->getFilter($filters,true,true);
4296
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4294
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4295
+		$filter_query = $this->getFilter($filters, true, true);
4296
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4297 4297
 		 	    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
4298 4298
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4299 4299
 			    ORDER BY airline_count DESC";
@@ -4305,7 +4305,7 @@  discard block
 block discarded – undo
4305 4305
 		$airline_array = array();
4306 4306
 		$temp_array = array();
4307 4307
         
4308
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4308
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4309 4309
 		{
4310 4310
 			$temp_array['airline_name'] = $row['airline_name'];
4311 4311
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4325,11 +4325,11 @@  discard block
 block discarded – undo
4325 4325
 	* @return Array the airline country list
4326 4326
 	*
4327 4327
 	*/
4328
-	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4328
+	public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array())
4329 4329
 	{
4330
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4331
-		$filter_query = $this->getFilter($filters,true,true);
4332
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4330
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4331
+		$filter_query = $this->getFilter($filters, true, true);
4332
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4333 4333
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
4334 4334
                     GROUP BY spotter_output.airline_country
4335 4335
 					ORDER BY airline_country_count DESC
@@ -4342,7 +4342,7 @@  discard block
 block discarded – undo
4342 4342
 		$airline_country_array = array();
4343 4343
 		$temp_array = array();
4344 4344
         
4345
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4345
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4346 4346
 		{
4347 4347
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4348 4348
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4361,11 +4361,11 @@  discard block
 block discarded – undo
4361 4361
 	* @return Array the airline list
4362 4362
 	*
4363 4363
 	*/
4364
-	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4364
+	public function countAllAirlinesByAirport($airport_icao, $filters = array())
4365 4365
 	{
4366
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4367
-		$filter_query = $this->getFilter($filters,true,true);
4368
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4366
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4367
+		$filter_query = $this->getFilter($filters, true, true);
4368
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4369 4369
 		    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 ) 
4370 4370
                     GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country
4371 4371
 		    ORDER BY airline_count DESC";
@@ -4377,7 +4377,7 @@  discard block
 block discarded – undo
4377 4377
 		$airline_array = array();
4378 4378
 		$temp_array = array();
4379 4379
         
4380
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4380
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4381 4381
 		{
4382 4382
 			$temp_array['airline_name'] = $row['airline_name'];
4383 4383
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4396,11 +4396,11 @@  discard block
 block discarded – undo
4396 4396
 	* @return Array the airline country list
4397 4397
 	*
4398 4398
 	*/
4399
-	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4399
+	public function countAllAirlineCountriesByAirport($airport_icao, $filters = array())
4400 4400
 	{
4401
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4402
-		$filter_query = $this->getFilter($filters,true,true);
4403
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4401
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4402
+		$filter_query = $this->getFilter($filters, true, true);
4403
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4404 4404
 		 			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 )
4405 4405
 					GROUP BY spotter_output.airline_country
4406 4406
 					ORDER BY airline_country_count DESC
@@ -4413,7 +4413,7 @@  discard block
 block discarded – undo
4413 4413
 		$airline_country_array = array();
4414 4414
 		$temp_array = array();
4415 4415
         
4416
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4416
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4417 4417
 		{
4418 4418
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4419 4419
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4430,11 +4430,11 @@  discard block
 block discarded – undo
4430 4430
 	* @return Array the airline list
4431 4431
 	*
4432 4432
 	*/
4433
-	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4433
+	public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array())
4434 4434
 	{
4435
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4436
-		$filter_query = $this->getFilter($filters,true,true);
4437
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4435
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4436
+		$filter_query = $this->getFilter($filters, true, true);
4437
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4438 4438
 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4439 4439
 					GROUP BY spotter_output.airline_name
4440 4440
 					ORDER BY airline_count DESC";
@@ -4445,7 +4445,7 @@  discard block
 block discarded – undo
4445 4445
 		$airline_array = array();
4446 4446
 		$temp_array = array();
4447 4447
         
4448
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4448
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4449 4449
 		{
4450 4450
 			$temp_array['airline_name'] = $row['airline_name'];
4451 4451
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4465,11 +4465,11 @@  discard block
 block discarded – undo
4465 4465
 	* @return Array the airline country list
4466 4466
 	*
4467 4467
 	*/
4468
-	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4468
+	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array())
4469 4469
 	{
4470
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4471
-		$filter_query = $this->getFilter($filters,true,true);
4472
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4470
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4471
+		$filter_query = $this->getFilter($filters, true, true);
4472
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4473 4473
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4474 4474
 					GROUP BY spotter_output.airline_country
4475 4475
 					ORDER BY airline_country_count DESC
@@ -4482,7 +4482,7 @@  discard block
 block discarded – undo
4482 4482
 		$airline_country_array = array();
4483 4483
 		$temp_array = array();
4484 4484
         
4485
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4485
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4486 4486
 		{
4487 4487
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4488 4488
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4498,11 +4498,11 @@  discard block
 block discarded – undo
4498 4498
 	* @return Array the airline list
4499 4499
 	*
4500 4500
 	*/
4501
-	public function countAllAirlinesByDate($date,$filters = array())
4501
+	public function countAllAirlinesByDate($date, $filters = array())
4502 4502
 	{
4503 4503
 		global $globalTimezone, $globalDBdriver;
4504
-		$filter_query = $this->getFilter($filters,true,true);
4505
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4504
+		$filter_query = $this->getFilter($filters, true, true);
4505
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4506 4506
 		if ($globalTimezone != '') {
4507 4507
 			date_default_timezone_set($globalTimezone);
4508 4508
 			$datetime = new DateTime($date);
@@ -4510,12 +4510,12 @@  discard block
 block discarded – undo
4510 4510
 		} else $offset = '+00:00';
4511 4511
 
4512 4512
 		if ($globalDBdriver == 'mysql') {
4513
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4513
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4514 4514
 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4515 4515
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country 
4516 4516
 					ORDER BY airline_count DESC";
4517 4517
 		} else {
4518
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4518
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4519 4519
 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4520 4520
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country
4521 4521
 					ORDER BY airline_count DESC";
@@ -4526,7 +4526,7 @@  discard block
 block discarded – undo
4526 4526
 
4527 4527
 		$airline_array = array();
4528 4528
 		$temp_array = array();
4529
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4529
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4530 4530
 		{
4531 4531
 			$temp_array['airline_name'] = $row['airline_name'];
4532 4532
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4546,11 +4546,11 @@  discard block
 block discarded – undo
4546 4546
 	* @return Array the airline country list
4547 4547
 	*
4548 4548
 	*/
4549
-	public function countAllAirlineCountriesByDate($date,$filters = array())
4549
+	public function countAllAirlineCountriesByDate($date, $filters = array())
4550 4550
 	{
4551 4551
 		global $globalTimezone, $globalDBdriver;
4552
-		$filter_query = $this->getFilter($filters,true,true);
4553
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4552
+		$filter_query = $this->getFilter($filters, true, true);
4553
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4554 4554
 		if ($globalTimezone != '') {
4555 4555
 			date_default_timezone_set($globalTimezone);
4556 4556
 			$datetime = new DateTime($date);
@@ -4558,13 +4558,13 @@  discard block
 block discarded – undo
4558 4558
 		} else $offset = '+00:00';
4559 4559
 		
4560 4560
 		if ($globalDBdriver == 'mysql') {
4561
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4561
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4562 4562
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4563 4563
 					GROUP BY spotter_output.airline_country
4564 4564
 					ORDER BY airline_country_count DESC
4565 4565
 					LIMIT 10 OFFSET 0";
4566 4566
 		} else {
4567
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4567
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4568 4568
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4569 4569
 					GROUP BY spotter_output.airline_country
4570 4570
 					ORDER BY airline_country_count DESC
@@ -4576,7 +4576,7 @@  discard block
 block discarded – undo
4576 4576
  
4577 4577
 		$airline_country_array = array();
4578 4578
 		$temp_array = array();
4579
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4579
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4580 4580
 		{
4581 4581
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4582 4582
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4593,11 +4593,11 @@  discard block
 block discarded – undo
4593 4593
 	* @return Array the airline list
4594 4594
 	*
4595 4595
 	*/
4596
-	public function countAllAirlinesByIdent($ident,$filters = array())
4596
+	public function countAllAirlinesByIdent($ident, $filters = array())
4597 4597
 	{
4598
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4599
-		$filter_query = $this->getFilter($filters,true,true);
4600
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4598
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4599
+		$filter_query = $this->getFilter($filters, true, true);
4600
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4601 4601
 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident  
4602 4602
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4603 4603
 				ORDER BY airline_count DESC";
@@ -4614,11 +4614,11 @@  discard block
 block discarded – undo
4614 4614
 	* @return Array the airline list
4615 4615
 	*
4616 4616
 	*/
4617
-	public function countAllAirlinesByOwner($owner,$filters = array())
4617
+	public function countAllAirlinesByOwner($owner, $filters = array())
4618 4618
 	{
4619
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4620
-		$filter_query = $this->getFilter($filters,true,true);
4621
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4619
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4620
+		$filter_query = $this->getFilter($filters, true, true);
4621
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4622 4622
 		 		FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  
4623 4623
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4624 4624
 				ORDER BY airline_count DESC";
@@ -4635,47 +4635,47 @@  discard block
 block discarded – undo
4635 4635
 	* @return String Duration of all flights
4636 4636
 	*
4637 4637
 	*/
4638
-	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4638
+	public function getFlightDurationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
4639 4639
 	{
4640 4640
 		global $globalDBdriver;
4641
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4642
-		$filter_query = $this->getFilter($filters,true,true);
4643
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4641
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4642
+		$filter_query = $this->getFilter($filters, true, true);
4643
+		$query = "SELECT SUM(last_seen - date) AS duration 
4644 4644
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
4645 4645
 				AND last_seen > date";
4646 4646
 		$query_values = array();
4647 4647
 		if ($year != '') {
4648 4648
 			if ($globalDBdriver == 'mysql') {
4649 4649
 				$query .= " AND YEAR(spotter_output.date) = :year";
4650
-				$query_values = array_merge($query_values,array(':year' => $year));
4650
+				$query_values = array_merge($query_values, array(':year' => $year));
4651 4651
 			} else {
4652 4652
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4653
-				$query_values = array_merge($query_values,array(':year' => $year));
4653
+				$query_values = array_merge($query_values, array(':year' => $year));
4654 4654
 			}
4655 4655
 		}
4656 4656
 		if ($month != '') {
4657 4657
 			if ($globalDBdriver == 'mysql') {
4658 4658
 				$query .= " AND MONTH(spotter_output.date) = :month";
4659
-				$query_values = array_merge($query_values,array(':month' => $month));
4659
+				$query_values = array_merge($query_values, array(':month' => $month));
4660 4660
 			} else {
4661 4661
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4662
-				$query_values = array_merge($query_values,array(':month' => $month));
4662
+				$query_values = array_merge($query_values, array(':month' => $month));
4663 4663
 			}
4664 4664
 		}
4665 4665
 		if ($day != '') {
4666 4666
 			if ($globalDBdriver == 'mysql') {
4667 4667
 				$query .= " AND DAY(spotter_output.date) = :day";
4668
-				$query_values = array_merge($query_values,array(':day' => $day));
4668
+				$query_values = array_merge($query_values, array(':day' => $day));
4669 4669
 			} else {
4670 4670
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4671
-				$query_values = array_merge($query_values,array(':day' => $day));
4671
+				$query_values = array_merge($query_values, array(':day' => $day));
4672 4672
 			}
4673 4673
 		}
4674
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4674
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4675 4675
 		$sth = $this->db->prepare($query);
4676 4676
 		$sth->execute($query_values);
4677 4677
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4678
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4678
+		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4679 4679
 		elseif ($result[0]['duration'] == '') return 0;
4680 4680
 		else return $result[0]['duration'];
4681 4681
 	}
@@ -4686,14 +4686,14 @@  discard block
 block discarded – undo
4686 4686
 	* @return String Duration of all flights
4687 4687
 	*
4688 4688
 	*/
4689
-	public function countFlightsByOwner($owner,$filters = array())
4689
+	public function countFlightsByOwner($owner, $filters = array())
4690 4690
 	{
4691
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4692
-		$filter_query = $this->getFilter($filters,true,true);
4693
-		$query  = "SELECT COUNT(*) AS nb 
4691
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4692
+		$filter_query = $this->getFilter($filters, true, true);
4693
+		$query = "SELECT COUNT(*) AS nb 
4694 4694
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
4695 4695
 		$query_values = array();
4696
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4696
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4697 4697
 		$sth = $this->db->prepare($query);
4698 4698
 		$sth->execute($query_values);
4699 4699
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4706,14 +4706,14 @@  discard block
 block discarded – undo
4706 4706
 	* @return String Duration of all flights
4707 4707
 	*
4708 4708
 	*/
4709
-	public function countFlightsByPilot($pilot,$filters = array())
4709
+	public function countFlightsByPilot($pilot, $filters = array())
4710 4710
 	{
4711
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4712
-		$filter_query = $this->getFilter($filters,true,true);
4713
-		$query  = "SELECT COUNT(*) AS nb 
4711
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4712
+		$filter_query = $this->getFilter($filters, true, true);
4713
+		$query = "SELECT COUNT(*) AS nb 
4714 4714
 				FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilod_id = :pilot)";
4715 4715
 		$query_values = array();
4716
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4716
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4717 4717
 		$sth = $this->db->prepare($query);
4718 4718
 		$sth->execute($query_values);
4719 4719
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4726,47 +4726,47 @@  discard block
 block discarded – undo
4726 4726
 	* @return String Duration of all flights
4727 4727
 	*
4728 4728
 	*/
4729
-	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4729
+	public function getFlightDurationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
4730 4730
 	{
4731 4731
 		global $globalDBdriver;
4732
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4733
-		$filter_query = $this->getFilter($filters,true,true);
4734
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4732
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4733
+		$filter_query = $this->getFilter($filters, true, true);
4734
+		$query = "SELECT SUM(last_seen - date) AS duration 
4735 4735
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4736 4736
 		 		AND last_seen > date";
4737 4737
 		$query_values = array();
4738 4738
 		if ($year != '') {
4739 4739
 			if ($globalDBdriver == 'mysql') {
4740 4740
 				$query .= " AND YEAR(spotter_output.date) = :year";
4741
-				$query_values = array_merge($query_values,array(':year' => $year));
4741
+				$query_values = array_merge($query_values, array(':year' => $year));
4742 4742
 			} else {
4743 4743
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4744
-				$query_values = array_merge($query_values,array(':year' => $year));
4744
+				$query_values = array_merge($query_values, array(':year' => $year));
4745 4745
 			}
4746 4746
 		}
4747 4747
 		if ($month != '') {
4748 4748
 			if ($globalDBdriver == 'mysql') {
4749 4749
 				$query .= " AND MONTH(spotter_output.date) = :month";
4750
-				$query_values = array_merge($query_values,array(':month' => $month));
4750
+				$query_values = array_merge($query_values, array(':month' => $month));
4751 4751
 			} else {
4752 4752
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4753
-				$query_values = array_merge($query_values,array(':month' => $month));
4753
+				$query_values = array_merge($query_values, array(':month' => $month));
4754 4754
 			}
4755 4755
 		}
4756 4756
 		if ($day != '') {
4757 4757
 			if ($globalDBdriver == 'mysql') {
4758 4758
 				$query .= " AND DAY(spotter_output.date) = :day";
4759
-				$query_values = array_merge($query_values,array(':day' => $day));
4759
+				$query_values = array_merge($query_values, array(':day' => $day));
4760 4760
 			} else {
4761 4761
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4762
-				$query_values = array_merge($query_values,array(':day' => $day));
4762
+				$query_values = array_merge($query_values, array(':day' => $day));
4763 4763
 			}
4764 4764
 		}
4765
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4765
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4766 4766
 		$sth = $this->db->prepare($query);
4767 4767
 		$sth->execute($query_values);
4768 4768
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4769
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4769
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4770 4770
 		else return $result[0]['duration'];
4771 4771
 	}
4772 4772
 
@@ -4776,11 +4776,11 @@  discard block
 block discarded – undo
4776 4776
 	* @return Array the airline list
4777 4777
 	*
4778 4778
 	*/
4779
-	public function countAllAirlinesByPilot($pilot,$filters = array())
4779
+	public function countAllAirlinesByPilot($pilot, $filters = array())
4780 4780
 	{
4781
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4782
-		$filter_query = $this->getFilter($filters,true,true);
4783
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4781
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4782
+		$filter_query = $this->getFilter($filters, true, true);
4783
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4784 4784
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4785 4785
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4786 4786
 				ORDER BY airline_count DESC";
@@ -4797,25 +4797,25 @@  discard block
 block discarded – undo
4797 4797
 	* @return Array the airline list
4798 4798
 	*
4799 4799
 	*/
4800
-	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4800
+	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4801 4801
 	{
4802
-		$filter_query = $this->getFilter($filters,true,true);
4803
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4804
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4802
+		$filter_query = $this->getFilter($filters, true, true);
4803
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4804
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4805 4805
 
4806
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4806
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4807 4807
 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4808 4808
 					GROUP BY spotter_output.airline_name
4809 4809
 					ORDER BY airline_count DESC";
4810 4810
       
4811 4811
 		
4812 4812
 		$sth = $this->db->prepare($query);
4813
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4813
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4814 4814
       
4815 4815
 		$airline_array = array();
4816 4816
 		$temp_array = array();
4817 4817
         
4818
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4818
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4819 4819
 		{
4820 4820
 			$temp_array['airline_name'] = $row['airline_name'];
4821 4821
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4833,13 +4833,13 @@  discard block
 block discarded – undo
4833 4833
 	* @return Array the airline country list
4834 4834
 	*
4835 4835
 	*/
4836
-	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4836
+	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4837 4837
 	{
4838
-		$filter_query = $this->getFilter($filters,true,true);
4839
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4840
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4838
+		$filter_query = $this->getFilter($filters, true, true);
4839
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4840
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4841 4841
       
4842
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4842
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4843 4843
 		 		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) 
4844 4844
 				GROUP BY spotter_output.airline_country
4845 4845
 				ORDER BY airline_country_count DESC
@@ -4847,11 +4847,11 @@  discard block
 block discarded – undo
4847 4847
       
4848 4848
 		
4849 4849
 		$sth = $this->db->prepare($query);
4850
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4850
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4851 4851
       
4852 4852
 		$airline_country_array = array();
4853 4853
 		$temp_array = array();
4854
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4854
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4855 4855
 		{
4856 4856
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4857 4857
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4869,11 +4869,11 @@  discard block
 block discarded – undo
4869 4869
 	* @return Array the airline list
4870 4870
 	*
4871 4871
 	*/
4872
-	public function countAllAirlinesByCountry($country,$filters = array())
4872
+	public function countAllAirlinesByCountry($country, $filters = array())
4873 4873
 	{
4874
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4875
-		$filter_query = $this->getFilter($filters,true,true);
4876
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4874
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4875
+		$filter_query = $this->getFilter($filters, true, true);
4876
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4877 4877
 		 	    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4878 4878
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4879 4879
 			    ORDER BY airline_count DESC";
@@ -4884,7 +4884,7 @@  discard block
 block discarded – undo
4884 4884
 
4885 4885
 		$airline_array = array();
4886 4886
 		$temp_array = array();
4887
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4887
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4888 4888
 		{
4889 4889
 			$temp_array['airline_name'] = $row['airline_name'];
4890 4890
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4903,11 +4903,11 @@  discard block
 block discarded – undo
4903 4903
 	* @return Array the airline country list
4904 4904
 	*
4905 4905
 	*/
4906
-	public function countAllAirlineCountriesByCountry($country,$filters = array())
4906
+	public function countAllAirlineCountriesByCountry($country, $filters = array())
4907 4907
 	{
4908
-		$filter_query = $this->getFilter($filters,true,true);
4909
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4910
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4908
+		$filter_query = $this->getFilter($filters, true, true);
4909
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4910
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4911 4911
 		 		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 
4912 4912
 				GROUP BY spotter_output.airline_country
4913 4913
 				ORDER BY airline_country_count DESC
@@ -4919,7 +4919,7 @@  discard block
 block discarded – undo
4919 4919
 
4920 4920
 		$airline_country_array = array();
4921 4921
 		$temp_array = array();
4922
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4922
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4923 4923
 		{
4924 4924
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4925 4925
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4939,35 +4939,35 @@  discard block
 block discarded – undo
4939 4939
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4940 4940
 	{
4941 4941
 		global $globalDBdriver;
4942
-		$filter_query = $this->getFilter($filters,true,true);
4943
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4942
+		$filter_query = $this->getFilter($filters, true, true);
4943
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4944 4944
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'";
4945 4945
 		$query_values = array();
4946 4946
 		if ($year != '') {
4947 4947
 			if ($globalDBdriver == 'mysql') {
4948 4948
 				$query .= " AND YEAR(spotter_output.date) = :year";
4949
-				$query_values = array_merge($query_values,array(':year' => $year));
4949
+				$query_values = array_merge($query_values, array(':year' => $year));
4950 4950
 			} else {
4951 4951
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4952
-				$query_values = array_merge($query_values,array(':year' => $year));
4952
+				$query_values = array_merge($query_values, array(':year' => $year));
4953 4953
 			}
4954 4954
 		}
4955 4955
 		if ($month != '') {
4956 4956
 			if ($globalDBdriver == 'mysql') {
4957 4957
 				$query .= " AND MONTH(spotter_output.date) = :month";
4958
-				$query_values = array_merge($query_values,array(':month' => $month));
4958
+				$query_values = array_merge($query_values, array(':month' => $month));
4959 4959
 			} else {
4960 4960
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4961
-				$query_values = array_merge($query_values,array(':month' => $month));
4961
+				$query_values = array_merge($query_values, array(':month' => $month));
4962 4962
 			}
4963 4963
 		}
4964 4964
 		if ($day != '') {
4965 4965
 			if ($globalDBdriver == 'mysql') {
4966 4966
 				$query .= " AND DAY(spotter_output.date) = :day";
4967
-				$query_values = array_merge($query_values,array(':day' => $day));
4967
+				$query_values = array_merge($query_values, array(':day' => $day));
4968 4968
 			} else {
4969 4969
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4970
-				$query_values = array_merge($query_values,array(':day' => $day));
4970
+				$query_values = array_merge($query_values, array(':day' => $day));
4971 4971
 			}
4972 4972
 		}
4973 4973
 		$query .= " GROUP BY spotter_output.airline_country
@@ -4979,7 +4979,7 @@  discard block
 block discarded – undo
4979 4979
 
4980 4980
 		$airline_array = array();
4981 4981
 		$temp_array = array();
4982
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4982
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4983 4983
 		{
4984 4984
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4985 4985
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4995,11 +4995,11 @@  discard block
 block discarded – undo
4995 4995
 	* @return Array the airline country list
4996 4996
 	*
4997 4997
 	*/
4998
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4998
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4999 4999
 	{
5000 5000
 		global $globalDBdriver;
5001 5001
 		//$filter_query = $this->getFilter($filters,true,true);
5002
-		$Connection= new Connection($this->db);
5002
+		$Connection = new Connection($this->db);
5003 5003
 		if (!$Connection->tableExists('countries')) return array();
5004 5004
 		/*
5005 5005
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -5014,7 +5014,7 @@  discard block
 block discarded – undo
5014 5014
 */
5015 5015
 		require_once('class.SpotterLive.php');
5016 5016
 		$SpotterLive = new SpotterLive();
5017
-		$filter_query = $SpotterLive->getFilter($filters,true,true);
5017
+		$filter_query = $SpotterLive->getFilter($filters, true, true);
5018 5018
 		$filter_query .= ' over_country IS NOT NULL';
5019 5019
                 if ($olderthanmonths > 0) {
5020 5020
 			if ($globalDBdriver == 'mysql') {
@@ -5041,7 +5041,7 @@  discard block
 block discarded – undo
5041 5041
 		$flight_array = array();
5042 5042
 		$temp_array = array();
5043 5043
         
5044
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5044
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5045 5045
 		{
5046 5046
 			$temp_array['flight_count'] = $row['nb'];
5047 5047
 			$temp_array['flight_country'] = $row['name'];
@@ -5059,11 +5059,11 @@  discard block
 block discarded – undo
5059 5059
 	* @return Array the aircraft list
5060 5060
 	*
5061 5061
 	*/
5062
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5062
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5063 5063
 	{
5064 5064
 		global $globalDBdriver;
5065
-		$filter_query = $this->getFilter($filters,true,true);
5066
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5065
+		$filter_query = $this->getFilter($filters, true, true);
5066
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5067 5067
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
5068 5068
 		if ($olderthanmonths > 0) {
5069 5069
 			if ($globalDBdriver == 'mysql') {
@@ -5083,28 +5083,28 @@  discard block
 block discarded – undo
5083 5083
 		if ($year != '') {
5084 5084
 			if ($globalDBdriver == 'mysql') {
5085 5085
 				$query .= " AND YEAR(spotter_output.date) = :year";
5086
-				$query_values = array_merge($query_values,array(':year' => $year));
5086
+				$query_values = array_merge($query_values, array(':year' => $year));
5087 5087
 			} else {
5088 5088
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5089
-				$query_values = array_merge($query_values,array(':year' => $year));
5089
+				$query_values = array_merge($query_values, array(':year' => $year));
5090 5090
 			}
5091 5091
 		}
5092 5092
 		if ($month != '') {
5093 5093
 			if ($globalDBdriver == 'mysql') {
5094 5094
 				$query .= " AND MONTH(spotter_output.date) = :month";
5095
-				$query_values = array_merge($query_values,array(':month' => $month));
5095
+				$query_values = array_merge($query_values, array(':month' => $month));
5096 5096
 			} else {
5097 5097
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5098
-				$query_values = array_merge($query_values,array(':month' => $month));
5098
+				$query_values = array_merge($query_values, array(':month' => $month));
5099 5099
 			}
5100 5100
 		}
5101 5101
 		if ($day != '') {
5102 5102
 			if ($globalDBdriver == 'mysql') {
5103 5103
 				$query .= " AND DAY(spotter_output.date) = :day";
5104
-				$query_values = array_merge($query_values,array(':day' => $day));
5104
+				$query_values = array_merge($query_values, array(':day' => $day));
5105 5105
 			} else {
5106 5106
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5107
-				$query_values = array_merge($query_values,array(':day' => $day));
5107
+				$query_values = array_merge($query_values, array(':day' => $day));
5108 5108
 			}
5109 5109
 		}
5110 5110
 
@@ -5116,7 +5116,7 @@  discard block
 block discarded – undo
5116 5116
 
5117 5117
 		$aircraft_array = array();
5118 5118
 		$temp_array = array();
5119
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5119
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5120 5120
 		{
5121 5121
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5122 5122
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5133,11 +5133,11 @@  discard block
 block discarded – undo
5133 5133
 	* @return Array the aircraft list
5134 5134
 	*
5135 5135
 	*/
5136
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5136
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5137 5137
 	{
5138 5138
 		global $globalDBdriver;
5139
-		$filter_query = $this->getFilter($filters,true,true);
5140
-		$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 
5139
+		$filter_query = $this->getFilter($filters, true, true);
5140
+		$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 
5141 5141
 		    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'";
5142 5142
 		if ($olderthanmonths > 0) {
5143 5143
 			if ($globalDBdriver == 'mysql') {
@@ -5157,28 +5157,28 @@  discard block
 block discarded – undo
5157 5157
 		if ($year != '') {
5158 5158
 			if ($globalDBdriver == 'mysql') {
5159 5159
 				$query .= " AND YEAR(spotter_output.date) = :year";
5160
-				$query_values = array_merge($query_values,array(':year' => $year));
5160
+				$query_values = array_merge($query_values, array(':year' => $year));
5161 5161
 			} else {
5162 5162
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5163
-				$query_values = array_merge($query_values,array(':year' => $year));
5163
+				$query_values = array_merge($query_values, array(':year' => $year));
5164 5164
 			}
5165 5165
 		}
5166 5166
 		if ($month != '') {
5167 5167
 			if ($globalDBdriver == 'mysql') {
5168 5168
 				$query .= " AND MONTH(spotter_output.date) = :month";
5169
-				$query_values = array_merge($query_values,array(':month' => $month));
5169
+				$query_values = array_merge($query_values, array(':month' => $month));
5170 5170
 			} else {
5171 5171
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5172
-				$query_values = array_merge($query_values,array(':month' => $month));
5172
+				$query_values = array_merge($query_values, array(':month' => $month));
5173 5173
 			}
5174 5174
 		}
5175 5175
 		if ($day != '') {
5176 5176
 			if ($globalDBdriver == 'mysql') {
5177 5177
 				$query .= " AND DAY(spotter_output.date) = :day";
5178
-				$query_values = array_merge($query_values,array(':day' => $day));
5178
+				$query_values = array_merge($query_values, array(':day' => $day));
5179 5179
 			} else {
5180 5180
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5181
-				$query_values = array_merge($query_values,array(':day' => $day));
5181
+				$query_values = array_merge($query_values, array(':day' => $day));
5182 5182
 			}
5183 5183
 		}
5184 5184
 
@@ -5190,7 +5190,7 @@  discard block
 block discarded – undo
5190 5190
 
5191 5191
 		$aircraft_array = array();
5192 5192
 		$temp_array = array();
5193
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5193
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5194 5194
 		{
5195 5195
 			$temp_array['airline_icao'] = $row['airline_icao'];
5196 5196
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5208,11 +5208,11 @@  discard block
 block discarded – undo
5208 5208
 	* @return Array the aircraft list
5209 5209
 	*
5210 5210
 	*/
5211
-	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5211
+	public function countAllAircraftTypesByMonths($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5212 5212
 	{
5213 5213
 		global $globalDBdriver;
5214
-		$filter_query = $this->getFilter($filters,true,true);
5215
-		$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 
5214
+		$filter_query = $this->getFilter($filters, true, true);
5215
+		$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 
5216 5216
 		    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' ";
5217 5217
 		if ($olderthanmonths > 0) {
5218 5218
 			if ($globalDBdriver == 'mysql') {
@@ -5237,7 +5237,7 @@  discard block
 block discarded – undo
5237 5237
 
5238 5238
 		$aircraft_array = array();
5239 5239
 		$temp_array = array();
5240
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5240
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5241 5241
 		{
5242 5242
 			//$temp_array['airline_icao'] = $row['airline_icao'];
5243 5243
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5256,13 +5256,13 @@  discard block
 block discarded – undo
5256 5256
 	* @return Array the aircraft list
5257 5257
 	*
5258 5258
 	*/
5259
-	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5259
+	public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array())
5260 5260
 	{
5261 5261
 		$Image = new Image($this->db);
5262
-		$filter_query = $this->getFilter($filters,true,true);
5263
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5262
+		$filter_query = $this->getFilter($filters, true, true);
5263
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5264 5264
 
5265
-		$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  
5265
+		$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  
5266 5266
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
5267 5267
 				GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5268 5268
 				ORDER BY registration_count DESC";
@@ -5273,14 +5273,14 @@  discard block
 block discarded – undo
5273 5273
 		$aircraft_array = array();
5274 5274
 		$temp_array = array();
5275 5275
         
5276
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5276
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5277 5277
 		{
5278 5278
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5279 5279
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5280 5280
 			$temp_array['registration'] = $row['registration'];
5281 5281
 			$temp_array['airline_name'] = $row['airline_name'];
5282 5282
 			$temp_array['image_thumbnail'] = "";
5283
-			if($row['registration'] != "")
5283
+			if ($row['registration'] != "")
5284 5284
 			{
5285 5285
 				$image_array = $Image->getSpotterImage($row['registration']);
5286 5286
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5299,11 +5299,11 @@  discard block
 block discarded – undo
5299 5299
 	* @return Array the aircraft list
5300 5300
 	*
5301 5301
 	*/
5302
-	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5302
+	public function countAllAircraftTypesByAirline($airline_icao, $filters = array())
5303 5303
 	{
5304
-		$filter_query = $this->getFilter($filters,true,true);
5305
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5306
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5304
+		$filter_query = $this->getFilter($filters, true, true);
5305
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5306
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5307 5307
 			    FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
5308 5308
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5309 5309
 			    ORDER BY aircraft_icao_count DESC";
@@ -5314,7 +5314,7 @@  discard block
 block discarded – undo
5314 5314
 		$aircraft_array = array();
5315 5315
 		$temp_array = array();
5316 5316
 
5317
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5317
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5318 5318
 		{
5319 5319
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5320 5320
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5332,13 +5332,13 @@  discard block
 block discarded – undo
5332 5332
 	* @return Array the aircraft list
5333 5333
 	*
5334 5334
 	*/
5335
-	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5335
+	public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array())
5336 5336
 	{
5337
-		$filter_query = $this->getFilter($filters,true,true);
5337
+		$filter_query = $this->getFilter($filters, true, true);
5338 5338
 		$Image = new Image($this->db);
5339
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5339
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5340 5340
 
5341
-		$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 
5341
+		$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 
5342 5342
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
5343 5343
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5344 5344
 			    ORDER BY registration_count DESC";
@@ -5348,14 +5348,14 @@  discard block
 block discarded – undo
5348 5348
 
5349 5349
 		$aircraft_array = array();
5350 5350
 		$temp_array = array();
5351
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5351
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5352 5352
 		{
5353 5353
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5354 5354
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5355 5355
 			$temp_array['registration'] = $row['registration'];
5356 5356
 			$temp_array['airline_name'] = $row['airline_name'];
5357 5357
 			$temp_array['image_thumbnail'] = "";
5358
-			if($row['registration'] != "")
5358
+			if ($row['registration'] != "")
5359 5359
 			{
5360 5360
 				$image_array = $Image->getSpotterImage($row['registration']);
5361 5361
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5374,11 +5374,11 @@  discard block
 block discarded – undo
5374 5374
 	* @return Array the aircraft list
5375 5375
 	*
5376 5376
 	*/
5377
-	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5377
+	public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array())
5378 5378
 	{
5379
-		$filter_query = $this->getFilter($filters,true,true);
5380
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5381
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5379
+		$filter_query = $this->getFilter($filters, true, true);
5380
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5381
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5382 5382
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
5383 5383
 				GROUP BY spotter_output.aircraft_manufacturer 
5384 5384
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5389,7 +5389,7 @@  discard block
 block discarded – undo
5389 5389
 		$aircraft_array = array();
5390 5390
 		$temp_array = array();
5391 5391
 
5392
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5392
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5393 5393
 		{
5394 5394
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5395 5395
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5406,12 +5406,12 @@  discard block
 block discarded – undo
5406 5406
 	* @return Array the aircraft list
5407 5407
 	*
5408 5408
 	*/
5409
-	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5409
+	public function countAllAircraftTypesByAirport($airport_icao, $filters = array())
5410 5410
 	{
5411
-		$filter_query = $this->getFilter($filters,true,true);
5412
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5411
+		$filter_query = $this->getFilter($filters, true, true);
5412
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5413 5413
 
5414
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5414
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5415 5415
 				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) 
5416 5416
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5417 5417
 				ORDER BY aircraft_icao_count DESC";
@@ -5421,7 +5421,7 @@  discard block
 block discarded – undo
5421 5421
 
5422 5422
 		$aircraft_array = array();
5423 5423
 		$temp_array = array();
5424
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5424
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5425 5425
 		{
5426 5426
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5427 5427
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5439,13 +5439,13 @@  discard block
 block discarded – undo
5439 5439
 	* @return Array the aircraft list
5440 5440
 	*
5441 5441
 	*/
5442
-	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5442
+	public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array())
5443 5443
 	{
5444
-		$filter_query = $this->getFilter($filters,true,true);
5444
+		$filter_query = $this->getFilter($filters, true, true);
5445 5445
 		$Image = new Image($this->db);
5446
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5446
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5447 5447
 
5448
-		$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  
5448
+		$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  
5449 5449
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
5450 5450
                     GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5451 5451
 		    ORDER BY registration_count DESC";
@@ -5455,14 +5455,14 @@  discard block
 block discarded – undo
5455 5455
 
5456 5456
 		$aircraft_array = array();
5457 5457
 		$temp_array = array();
5458
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5458
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5459 5459
 		{
5460 5460
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5461 5461
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5462 5462
 			$temp_array['registration'] = $row['registration'];
5463 5463
 			$temp_array['airline_name'] = $row['airline_name'];
5464 5464
 			$temp_array['image_thumbnail'] = "";
5465
-			if($row['registration'] != "")
5465
+			if ($row['registration'] != "")
5466 5466
 			{
5467 5467
 				$image_array = $Image->getSpotterImage($row['registration']);
5468 5468
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5480,11 +5480,11 @@  discard block
 block discarded – undo
5480 5480
 	* @return Array the aircraft list
5481 5481
 	*
5482 5482
 	*/
5483
-	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5483
+	public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array())
5484 5484
 	{
5485
-		$filter_query = $this->getFilter($filters,true,true);
5486
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5487
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5485
+		$filter_query = $this->getFilter($filters, true, true);
5486
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5487
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5488 5488
                     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)  
5489 5489
                     GROUP BY spotter_output.aircraft_manufacturer 
5490 5490
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5495,7 +5495,7 @@  discard block
 block discarded – undo
5495 5495
 
5496 5496
 		$aircraft_array = array();
5497 5497
 		$temp_array = array();
5498
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5498
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5499 5499
 		{
5500 5500
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5501 5501
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5510,12 +5510,12 @@  discard block
 block discarded – undo
5510 5510
 	* @return Array the aircraft list
5511 5511
 	*
5512 5512
 	*/
5513
-	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5513
+	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array())
5514 5514
 	{
5515
-		$filter_query = $this->getFilter($filters,true,true);
5516
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5515
+		$filter_query = $this->getFilter($filters, true, true);
5516
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5517 5517
 
5518
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5518
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5519 5519
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
5520 5520
                     GROUP BY spotter_output.aircraft_name 
5521 5521
 					ORDER BY aircraft_icao_count DESC";
@@ -5524,7 +5524,7 @@  discard block
 block discarded – undo
5524 5524
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5525 5525
 		$aircraft_array = array();
5526 5526
 		$temp_array = array();
5527
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5527
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5528 5528
 		{
5529 5529
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5530 5530
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5543,11 +5543,11 @@  discard block
 block discarded – undo
5543 5543
 	*/
5544 5544
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5545 5545
 	{
5546
-		$filter_query = $this->getFilter($filters,true,true);
5546
+		$filter_query = $this->getFilter($filters, true, true);
5547 5547
 		$Image = new Image($this->db);
5548
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5548
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5549 5549
 
5550
-		$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   
5550
+		$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   
5551 5551
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
5552 5552
                     GROUP BY spotter_output.registration 
5553 5553
 					ORDER BY registration_count DESC";
@@ -5557,14 +5557,14 @@  discard block
 block discarded – undo
5557 5557
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5558 5558
 		$aircraft_array = array();
5559 5559
 		$temp_array = array();
5560
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5560
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5561 5561
 		{
5562 5562
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5563 5563
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5564 5564
 			$temp_array['registration'] = $row['registration'];
5565 5565
 			$temp_array['airline_name'] = $row['airline_name'];
5566 5566
 			$temp_array['image_thumbnail'] = "";
5567
-			if($row['registration'] != "")
5567
+			if ($row['registration'] != "")
5568 5568
 			{
5569 5569
 				$image_array = $Image->getSpotterImage($row['registration']);
5570 5570
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5581,11 +5581,11 @@  discard block
 block discarded – undo
5581 5581
 	* @return Array the aircraft list
5582 5582
 	*
5583 5583
 	*/
5584
-	public function countAllAircraftTypesByDate($date,$filters = array())
5584
+	public function countAllAircraftTypesByDate($date, $filters = array())
5585 5585
 	{
5586 5586
 		global $globalTimezone, $globalDBdriver;
5587
-		$filter_query = $this->getFilter($filters,true,true);
5588
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5587
+		$filter_query = $this->getFilter($filters, true, true);
5588
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5589 5589
 		if ($globalTimezone != '') {
5590 5590
 			date_default_timezone_set($globalTimezone);
5591 5591
 			$datetime = new DateTime($date);
@@ -5593,12 +5593,12 @@  discard block
 block discarded – undo
5593 5593
 		} else $offset = '+00:00';
5594 5594
 
5595 5595
 		if ($globalDBdriver == 'mysql') {
5596
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5596
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5597 5597
 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
5598 5598
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5599 5599
 					ORDER BY aircraft_icao_count DESC";
5600 5600
 		} else {
5601
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5601
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5602 5602
 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
5603 5603
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5604 5604
 					ORDER BY aircraft_icao_count DESC";
@@ -5609,7 +5609,7 @@  discard block
 block discarded – undo
5609 5609
 
5610 5610
 		$aircraft_array = array();
5611 5611
 		$temp_array = array();
5612
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5612
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5613 5613
 		{
5614 5614
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5615 5615
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5627,12 +5627,12 @@  discard block
 block discarded – undo
5627 5627
 	* @return Array the aircraft list
5628 5628
 	*
5629 5629
 	*/
5630
-	public function countAllAircraftRegistrationByDate($date,$filters = array())
5630
+	public function countAllAircraftRegistrationByDate($date, $filters = array())
5631 5631
 	{
5632 5632
 		global $globalTimezone, $globalDBdriver;
5633
-		$filter_query = $this->getFilter($filters,true,true);
5633
+		$filter_query = $this->getFilter($filters, true, true);
5634 5634
 		$Image = new Image($this->db);
5635
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5635
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5636 5636
 		if ($globalTimezone != '') {
5637 5637
 			date_default_timezone_set($globalTimezone);
5638 5638
 			$datetime = new DateTime($date);
@@ -5640,12 +5640,12 @@  discard block
 block discarded – undo
5640 5640
 		} else $offset = '+00:00';
5641 5641
 
5642 5642
 		if ($globalDBdriver == 'mysql') {
5643
-			$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 
5643
+			$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 
5644 5644
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5645 5645
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5646 5646
 					ORDER BY registration_count DESC";
5647 5647
 		} else {
5648
-			$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    
5648
+			$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    
5649 5649
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5650 5650
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5651 5651
 					ORDER BY registration_count DESC";
@@ -5656,14 +5656,14 @@  discard block
 block discarded – undo
5656 5656
 
5657 5657
 		$aircraft_array = array();
5658 5658
 		$temp_array = array();
5659
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5659
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5660 5660
 		{
5661 5661
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5662 5662
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5663 5663
 			$temp_array['registration'] = $row['registration'];
5664 5664
 			$temp_array['airline_name'] = $row['airline_name'];
5665 5665
 			$temp_array['image_thumbnail'] = "";
5666
-			if($row['registration'] != "")
5666
+			if ($row['registration'] != "")
5667 5667
 			{
5668 5668
 				$image_array = $Image->getSpotterImage($row['registration']);
5669 5669
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5682,11 +5682,11 @@  discard block
 block discarded – undo
5682 5682
 	* @return Array the aircraft manufacturer list
5683 5683
 	*
5684 5684
 	*/
5685
-	public function countAllAircraftManufacturerByDate($date,$filters = array())
5685
+	public function countAllAircraftManufacturerByDate($date, $filters = array())
5686 5686
 	{
5687 5687
 		global $globalTimezone, $globalDBdriver;
5688
-		$filter_query = $this->getFilter($filters,true,true);
5689
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5688
+		$filter_query = $this->getFilter($filters, true, true);
5689
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5690 5690
 		if ($globalTimezone != '') {
5691 5691
 			date_default_timezone_set($globalTimezone);
5692 5692
 			$datetime = new DateTime($date);
@@ -5694,12 +5694,12 @@  discard block
 block discarded – undo
5694 5694
 		} else $offset = '+00:00';
5695 5695
 
5696 5696
 		if ($globalDBdriver == 'mysql') {
5697
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5697
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5698 5698
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5699 5699
 				GROUP BY spotter_output.aircraft_manufacturer 
5700 5700
 				ORDER BY aircraft_manufacturer_count DESC";
5701 5701
 		} else {
5702
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5702
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5703 5703
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5704 5704
 				GROUP BY spotter_output.aircraft_manufacturer 
5705 5705
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5711,7 +5711,7 @@  discard block
 block discarded – undo
5711 5711
 		$aircraft_array = array();
5712 5712
 		$temp_array = array();
5713 5713
 
5714
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5714
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5715 5715
 		{
5716 5716
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5717 5717
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5728,11 +5728,11 @@  discard block
 block discarded – undo
5728 5728
 	* @return Array the aircraft list
5729 5729
 	*
5730 5730
 	*/
5731
-	public function countAllAircraftTypesByIdent($ident,$filters = array())
5731
+	public function countAllAircraftTypesByIdent($ident, $filters = array())
5732 5732
 	{
5733
-		$filter_query = $this->getFilter($filters,true,true);
5734
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5735
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5733
+		$filter_query = $this->getFilter($filters, true, true);
5734
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5735
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5736 5736
 				FROM spotter_output".$filter_query." spotter_output.ident = :ident 
5737 5737
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5738 5738
 				ORDER BY aircraft_icao_count DESC";
@@ -5743,7 +5743,7 @@  discard block
 block discarded – undo
5743 5743
 		$aircraft_array = array();
5744 5744
 		$temp_array = array();
5745 5745
 
5746
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5746
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5747 5747
 		{
5748 5748
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5749 5749
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5760,45 +5760,45 @@  discard block
 block discarded – undo
5760 5760
 	* @return Array the aircraft list
5761 5761
 	*
5762 5762
 	*/
5763
-	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5763
+	public function countAllAircraftTypesByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5764 5764
 	{
5765 5765
 		global $globalDBdriver;
5766
-		$filter_query = $this->getFilter($filters,true,true);
5767
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
5768
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5766
+		$filter_query = $this->getFilter($filters, true, true);
5767
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
5768
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5769 5769
 				FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)";
5770 5770
 		$query_values = array();
5771 5771
 		if ($year != '') {
5772 5772
 			if ($globalDBdriver == 'mysql') {
5773 5773
 				$query .= " AND YEAR(spotter_output.date) = :year";
5774
-				$query_values = array_merge($query_values,array(':year' => $year));
5774
+				$query_values = array_merge($query_values, array(':year' => $year));
5775 5775
 			} else {
5776 5776
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5777
-				$query_values = array_merge($query_values,array(':year' => $year));
5777
+				$query_values = array_merge($query_values, array(':year' => $year));
5778 5778
 			}
5779 5779
 		}
5780 5780
 		if ($month != '') {
5781 5781
 			if ($globalDBdriver == 'mysql') {
5782 5782
 				$query .= " AND MONTH(spotter_output.date) = :month";
5783
-				$query_values = array_merge($query_values,array(':month' => $month));
5783
+				$query_values = array_merge($query_values, array(':month' => $month));
5784 5784
 			} else {
5785 5785
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5786
-				$query_values = array_merge($query_values,array(':month' => $month));
5786
+				$query_values = array_merge($query_values, array(':month' => $month));
5787 5787
 			}
5788 5788
 		}
5789 5789
 		if ($day != '') {
5790 5790
 			if ($globalDBdriver == 'mysql') {
5791 5791
 				$query .= " AND DAY(spotter_output.date) = :day";
5792
-				$query_values = array_merge($query_values,array(':day' => $day));
5792
+				$query_values = array_merge($query_values, array(':day' => $day));
5793 5793
 			} else {
5794 5794
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5795
-				$query_values = array_merge($query_values,array(':day' => $day));
5795
+				$query_values = array_merge($query_values, array(':day' => $day));
5796 5796
 			}
5797 5797
 		}
5798 5798
 
5799 5799
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5800 5800
 				ORDER BY aircraft_icao_count DESC";
5801
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
5801
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
5802 5802
 		$sth = $this->db->prepare($query);
5803 5803
 		$sth->execute($query_values);
5804 5804
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5810,44 +5810,44 @@  discard block
 block discarded – undo
5810 5810
 	* @return Array the aircraft list
5811 5811
 	*
5812 5812
 	*/
5813
-	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5813
+	public function countAllAircraftTypesByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5814 5814
 	{
5815 5815
 		global $globalDBdriver;
5816
-		$filter_query = $this->getFilter($filters,true,true);
5817
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5818
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5816
+		$filter_query = $this->getFilter($filters, true, true);
5817
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5818
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5819 5819
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
5820 5820
 		$query_values = array();
5821 5821
 		if ($year != '') {
5822 5822
 			if ($globalDBdriver == 'mysql') {
5823 5823
 				$query .= " AND YEAR(spotter_output.date) = :year";
5824
-				$query_values = array_merge($query_values,array(':year' => $year));
5824
+				$query_values = array_merge($query_values, array(':year' => $year));
5825 5825
 			} else {
5826 5826
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5827
-				$query_values = array_merge($query_values,array(':year' => $year));
5827
+				$query_values = array_merge($query_values, array(':year' => $year));
5828 5828
 			}
5829 5829
 		}
5830 5830
 		if ($month != '') {
5831 5831
 			if ($globalDBdriver == 'mysql') {
5832 5832
 				$query .= " AND MONTH(spotter_output.date) = :month";
5833
-				$query_values = array_merge($query_values,array(':month' => $month));
5833
+				$query_values = array_merge($query_values, array(':month' => $month));
5834 5834
 			} else {
5835 5835
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5836
-				$query_values = array_merge($query_values,array(':month' => $month));
5836
+				$query_values = array_merge($query_values, array(':month' => $month));
5837 5837
 			}
5838 5838
 		}
5839 5839
 		if ($day != '') {
5840 5840
 			if ($globalDBdriver == 'mysql') {
5841 5841
 				$query .= " AND DAY(spotter_output.date) = :day";
5842
-				$query_values = array_merge($query_values,array(':day' => $day));
5842
+				$query_values = array_merge($query_values, array(':day' => $day));
5843 5843
 			} else {
5844 5844
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5845
-				$query_values = array_merge($query_values,array(':day' => $day));
5845
+				$query_values = array_merge($query_values, array(':day' => $day));
5846 5846
 			}
5847 5847
 		}
5848 5848
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao
5849 5849
 				ORDER BY aircraft_icao_count DESC";
5850
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5850
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5851 5851
 		$sth = $this->db->prepare($query);
5852 5852
 		$sth->execute($query_values);
5853 5853
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5859,13 +5859,13 @@  discard block
 block discarded – undo
5859 5859
 	* @return Array the aircraft list
5860 5860
 	*
5861 5861
 	*/
5862
-	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5862
+	public function countAllAircraftRegistrationByIdent($ident, $filters = array())
5863 5863
 	{
5864
-		$filter_query = $this->getFilter($filters,true,true);
5864
+		$filter_query = $this->getFilter($filters, true, true);
5865 5865
 		$Image = new Image($this->db);
5866
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5866
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5867 5867
 
5868
-		$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  
5868
+		$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  
5869 5869
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident   
5870 5870
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5871 5871
 		    ORDER BY registration_count DESC";
@@ -5877,14 +5877,14 @@  discard block
 block discarded – undo
5877 5877
 		$aircraft_array = array();
5878 5878
 		$temp_array = array();
5879 5879
         
5880
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5880
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5881 5881
 		{
5882 5882
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5883 5883
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5884 5884
 			$temp_array['registration'] = $row['registration'];
5885 5885
 			$temp_array['airline_name'] = $row['airline_name'];
5886 5886
 			$temp_array['image_thumbnail'] = "";
5887
-			if($row['registration'] != "")
5887
+			if ($row['registration'] != "")
5888 5888
 			{
5889 5889
 				$image_array = $Image->getSpotterImage($row['registration']);
5890 5890
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5902,44 +5902,44 @@  discard block
 block discarded – undo
5902 5902
 	* @return Array the aircraft list
5903 5903
 	*
5904 5904
 	*/
5905
-	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5905
+	public function countAllAircraftRegistrationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5906 5906
 	{
5907 5907
 		global $globalDBdriver;
5908
-		$filter_query = $this->getFilter($filters,true,true);
5908
+		$filter_query = $this->getFilter($filters, true, true);
5909 5909
 		$Image = new Image($this->db);
5910
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5910
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5911 5911
 
5912
-		$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  
5912
+		$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  
5913 5913
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner";
5914 5914
 		$query_values = array();
5915 5915
 		if ($year != '') {
5916 5916
 			if ($globalDBdriver == 'mysql') {
5917 5917
 				$query .= " AND YEAR(spotter_output.date) = :year";
5918
-				$query_values = array_merge($query_values,array(':year' => $year));
5918
+				$query_values = array_merge($query_values, array(':year' => $year));
5919 5919
 			} else {
5920 5920
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5921
-				$query_values = array_merge($query_values,array(':year' => $year));
5921
+				$query_values = array_merge($query_values, array(':year' => $year));
5922 5922
 			}
5923 5923
 		}
5924 5924
 		if ($month != '') {
5925 5925
 			if ($globalDBdriver == 'mysql') {
5926 5926
 				$query .= " AND MONTH(spotter_output.date) = :month";
5927
-				$query_values = array_merge($query_values,array(':month' => $month));
5927
+				$query_values = array_merge($query_values, array(':month' => $month));
5928 5928
 			} else {
5929 5929
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5930
-				$query_values = array_merge($query_values,array(':month' => $month));
5930
+				$query_values = array_merge($query_values, array(':month' => $month));
5931 5931
 			}
5932 5932
 		}
5933 5933
 		if ($day != '') {
5934 5934
 			if ($globalDBdriver == 'mysql') {
5935 5935
 				$query .= " AND DAY(spotter_output.date) = :day";
5936
-				$query_values = array_merge($query_values,array(':day' => $day));
5936
+				$query_values = array_merge($query_values, array(':day' => $day));
5937 5937
 			} else {
5938 5938
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5939
-				$query_values = array_merge($query_values,array(':day' => $day));
5939
+				$query_values = array_merge($query_values, array(':day' => $day));
5940 5940
 			}
5941 5941
 		}
5942
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5942
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5943 5943
 
5944 5944
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
5945 5945
 		    ORDER BY registration_count DESC";
@@ -5951,7 +5951,7 @@  discard block
 block discarded – undo
5951 5951
 		$aircraft_array = array();
5952 5952
 		$temp_array = array();
5953 5953
         
5954
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5954
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5955 5955
 		{
5956 5956
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5957 5957
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5959,7 +5959,7 @@  discard block
 block discarded – undo
5959 5959
 			$temp_array['registration'] = $row['registration'];
5960 5960
 			$temp_array['airline_name'] = $row['airline_name'];
5961 5961
 			$temp_array['image_thumbnail'] = "";
5962
-			if($row['registration'] != "")
5962
+			if ($row['registration'] != "")
5963 5963
 			{
5964 5964
 				$image_array = $Image->getSpotterImage($row['registration']);
5965 5965
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5977,44 +5977,44 @@  discard block
 block discarded – undo
5977 5977
 	* @return Array the aircraft list
5978 5978
 	*
5979 5979
 	*/
5980
-	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5980
+	public function countAllAircraftRegistrationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5981 5981
 	{
5982 5982
 		global $globalDBdriver;
5983
-		$filter_query = $this->getFilter($filters,true,true);
5983
+		$filter_query = $this->getFilter($filters, true, true);
5984 5984
 		$Image = new Image($this->db);
5985
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
5985
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
5986 5986
 
5987
-		$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  
5987
+		$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  
5988 5988
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
5989 5989
 		$query_values = array();
5990 5990
 		if ($year != '') {
5991 5991
 			if ($globalDBdriver == 'mysql') {
5992 5992
 				$query .= " AND YEAR(spotter_output.date) = :year";
5993
-				$query_values = array_merge($query_values,array(':year' => $year));
5993
+				$query_values = array_merge($query_values, array(':year' => $year));
5994 5994
 			} else {
5995 5995
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5996
-				$query_values = array_merge($query_values,array(':year' => $year));
5996
+				$query_values = array_merge($query_values, array(':year' => $year));
5997 5997
 			}
5998 5998
 		}
5999 5999
 		if ($month != '') {
6000 6000
 			if ($globalDBdriver == 'mysql') {
6001 6001
 				$query .= " AND MONTH(spotter_output.date) = :month";
6002
-				$query_values = array_merge($query_values,array(':month' => $month));
6002
+				$query_values = array_merge($query_values, array(':month' => $month));
6003 6003
 			} else {
6004 6004
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6005
-				$query_values = array_merge($query_values,array(':month' => $month));
6005
+				$query_values = array_merge($query_values, array(':month' => $month));
6006 6006
 			}
6007 6007
 		}
6008 6008
 		if ($day != '') {
6009 6009
 			if ($globalDBdriver == 'mysql') {
6010 6010
 				$query .= " AND DAY(spotter_output.date) = :day";
6011
-				$query_values = array_merge($query_values,array(':day' => $day));
6011
+				$query_values = array_merge($query_values, array(':day' => $day));
6012 6012
 			} else {
6013 6013
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6014
-				$query_values = array_merge($query_values,array(':day' => $day));
6014
+				$query_values = array_merge($query_values, array(':day' => $day));
6015 6015
 			}
6016 6016
 		}
6017
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6017
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6018 6018
 
6019 6019
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
6020 6020
 		    ORDER BY registration_count DESC";
@@ -6026,7 +6026,7 @@  discard block
 block discarded – undo
6026 6026
 		$aircraft_array = array();
6027 6027
 		$temp_array = array();
6028 6028
         
6029
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6029
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6030 6030
 		{
6031 6031
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6032 6032
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6034,7 +6034,7 @@  discard block
 block discarded – undo
6034 6034
 			$temp_array['registration'] = $row['registration'];
6035 6035
 			$temp_array['airline_name'] = $row['airline_name'];
6036 6036
 			$temp_array['image_thumbnail'] = "";
6037
-			if($row['registration'] != "")
6037
+			if ($row['registration'] != "")
6038 6038
 			{
6039 6039
 				$image_array = $Image->getSpotterImage($row['registration']);
6040 6040
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6053,11 +6053,11 @@  discard block
 block discarded – undo
6053 6053
 	* @return Array the aircraft manufacturer list
6054 6054
 	*
6055 6055
 	*/
6056
-	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6056
+	public function countAllAircraftManufacturerByIdent($ident, $filters = array())
6057 6057
 	{
6058
-		$filter_query = $this->getFilter($filters,true,true);
6059
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6060
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6058
+		$filter_query = $this->getFilter($filters, true, true);
6059
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6060
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6061 6061
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
6062 6062
                     GROUP BY spotter_output.aircraft_manufacturer 
6063 6063
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6067,7 +6067,7 @@  discard block
 block discarded – undo
6067 6067
 		$sth->execute(array(':ident' => $ident));
6068 6068
 		$aircraft_array = array();
6069 6069
 		$temp_array = array();
6070
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6070
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6071 6071
 		{
6072 6072
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6073 6073
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6082,42 +6082,42 @@  discard block
 block discarded – undo
6082 6082
 	* @return Array the aircraft manufacturer list
6083 6083
 	*
6084 6084
 	*/
6085
-	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6085
+	public function countAllAircraftManufacturerByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
6086 6086
 	{
6087 6087
 		global $globalDBdriver;
6088
-		$filter_query = $this->getFilter($filters,true,true);
6089
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
6090
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6088
+		$filter_query = $this->getFilter($filters, true, true);
6089
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
6090
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6091 6091
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner";
6092 6092
 		$query_values = array();
6093 6093
 		if ($year != '') {
6094 6094
 			if ($globalDBdriver == 'mysql') {
6095 6095
 				$query .= " AND YEAR(spotter_output.date) = :year";
6096
-				$query_values = array_merge($query_values,array(':year' => $year));
6096
+				$query_values = array_merge($query_values, array(':year' => $year));
6097 6097
 			} else {
6098 6098
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6099
-				$query_values = array_merge($query_values,array(':year' => $year));
6099
+				$query_values = array_merge($query_values, array(':year' => $year));
6100 6100
 			}
6101 6101
 		}
6102 6102
 		if ($month != '') {
6103 6103
 			if ($globalDBdriver == 'mysql') {
6104 6104
 				$query .= " AND MONTH(spotter_output.date) = :month";
6105
-				$query_values = array_merge($query_values,array(':month' => $month));
6105
+				$query_values = array_merge($query_values, array(':month' => $month));
6106 6106
 			} else {
6107 6107
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6108
-				$query_values = array_merge($query_values,array(':month' => $month));
6108
+				$query_values = array_merge($query_values, array(':month' => $month));
6109 6109
 			}
6110 6110
 		}
6111 6111
 		if ($day != '') {
6112 6112
 			if ($globalDBdriver == 'mysql') {
6113 6113
 				$query .= " AND DAY(spotter_output.date) = :day";
6114
-				$query_values = array_merge($query_values,array(':day' => $day));
6114
+				$query_values = array_merge($query_values, array(':day' => $day));
6115 6115
 			} else {
6116 6116
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6117
-				$query_values = array_merge($query_values,array(':day' => $day));
6117
+				$query_values = array_merge($query_values, array(':day' => $day));
6118 6118
 			}
6119 6119
 		}
6120
-		$query_values = array_merge($query_values,array(':owner' => $owner));
6120
+		$query_values = array_merge($query_values, array(':owner' => $owner));
6121 6121
 
6122 6122
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6123 6123
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6134,42 +6134,42 @@  discard block
 block discarded – undo
6134 6134
 	* @return Array the aircraft manufacturer list
6135 6135
 	*
6136 6136
 	*/
6137
-	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6137
+	public function countAllAircraftManufacturerByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
6138 6138
 	{
6139 6139
 		global $globalDBdriver;
6140
-		$filter_query = $this->getFilter($filters,true,true);
6141
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6142
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6140
+		$filter_query = $this->getFilter($filters, true, true);
6141
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6142
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6143 6143
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6144 6144
 		$query_values = array();
6145 6145
 		if ($year != '') {
6146 6146
 			if ($globalDBdriver == 'mysql') {
6147 6147
 				$query .= " AND YEAR(spotter_output.date) = :year";
6148
-				$query_values = array_merge($query_values,array(':year' => $year));
6148
+				$query_values = array_merge($query_values, array(':year' => $year));
6149 6149
 			} else {
6150 6150
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6151
-				$query_values = array_merge($query_values,array(':year' => $year));
6151
+				$query_values = array_merge($query_values, array(':year' => $year));
6152 6152
 			}
6153 6153
 		}
6154 6154
 		if ($month != '') {
6155 6155
 			if ($globalDBdriver == 'mysql') {
6156 6156
 				$query .= " AND MONTH(spotter_output.date) = :month";
6157
-				$query_values = array_merge($query_values,array(':month' => $month));
6157
+				$query_values = array_merge($query_values, array(':month' => $month));
6158 6158
 			} else {
6159 6159
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6160
-				$query_values = array_merge($query_values,array(':month' => $month));
6160
+				$query_values = array_merge($query_values, array(':month' => $month));
6161 6161
 			}
6162 6162
 		}
6163 6163
 		if ($day != '') {
6164 6164
 			if ($globalDBdriver == 'mysql') {
6165 6165
 				$query .= " AND DAY(spotter_output.date) = :day";
6166
-				$query_values = array_merge($query_values,array(':day' => $day));
6166
+				$query_values = array_merge($query_values, array(':day' => $day));
6167 6167
 			} else {
6168 6168
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6169
-				$query_values = array_merge($query_values,array(':day' => $day));
6169
+				$query_values = array_merge($query_values, array(':day' => $day));
6170 6170
 			}
6171 6171
 		}
6172
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6172
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6173 6173
 
6174 6174
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6175 6175
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6187,24 +6187,24 @@  discard block
 block discarded – undo
6187 6187
 	* @return Array the aircraft list
6188 6188
 	*
6189 6189
 	*/
6190
-	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6190
+	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6191 6191
 	{
6192
-		$filter_query = $this->getFilter($filters,true,true);
6193
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6194
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6192
+		$filter_query = $this->getFilter($filters, true, true);
6193
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6194
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6195 6195
 		
6196 6196
 
6197
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6197
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6198 6198
                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
6199 6199
                     GROUP BY spotter_output.aircraft_name 
6200 6200
 					ORDER BY aircraft_icao_count DESC";
6201 6201
  
6202 6202
 		
6203 6203
 		$sth = $this->db->prepare($query);
6204
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6204
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6205 6205
 		$aircraft_array = array();
6206 6206
 		$temp_array = array();
6207
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6207
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6208 6208
 		{
6209 6209
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6210 6210
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6220,33 +6220,33 @@  discard block
 block discarded – undo
6220 6220
 	* @return Array the aircraft list
6221 6221
 	*
6222 6222
 	*/
6223
-	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6223
+	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6224 6224
 	{
6225
-		$filter_query = $this->getFilter($filters,true,true);
6225
+		$filter_query = $this->getFilter($filters, true, true);
6226 6226
 		$Image = new Image($this->db);
6227
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6228
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6227
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6228
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6229 6229
 
6230
-		$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   
6230
+		$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   
6231 6231
                     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)   
6232 6232
                     GROUP BY spotter_output.registration 
6233 6233
 					ORDER BY registration_count DESC";
6234 6234
 
6235 6235
 		
6236 6236
 		$sth = $this->db->prepare($query);
6237
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6237
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6238 6238
       
6239 6239
 		$aircraft_array = array();
6240 6240
 		$temp_array = array();
6241 6241
         
6242
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6242
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6243 6243
 		{
6244 6244
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6245 6245
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6246 6246
 			$temp_array['registration'] = $row['registration'];
6247 6247
 			$temp_array['airline_name'] = $row['airline_name'];
6248 6248
 			$temp_array['image_thumbnail'] = "";
6249
-			if($row['registration'] != "")
6249
+			if ($row['registration'] != "")
6250 6250
 			{
6251 6251
 				$image_array = $Image->getSpotterImage($row['registration']);
6252 6252
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6266,25 +6266,25 @@  discard block
 block discarded – undo
6266 6266
 	* @return Array the aircraft manufacturer list
6267 6267
 	*
6268 6268
 	*/
6269
-	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6269
+	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6270 6270
 	{
6271
-		$filter_query = $this->getFilter($filters,true,true);
6272
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6273
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6271
+		$filter_query = $this->getFilter($filters, true, true);
6272
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6273
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6274 6274
 
6275
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6275
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6276 6276
                     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) 
6277 6277
                     GROUP BY spotter_output.aircraft_manufacturer 
6278 6278
 					ORDER BY aircraft_manufacturer_count DESC";
6279 6279
 
6280 6280
 		
6281 6281
 		$sth = $this->db->prepare($query);
6282
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6282
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6283 6283
       
6284 6284
 		$aircraft_array = array();
6285 6285
 		$temp_array = array();
6286 6286
         
6287
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6287
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6288 6288
 		{
6289 6289
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6290 6290
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6304,11 +6304,11 @@  discard block
 block discarded – undo
6304 6304
 	* @return Array the aircraft list
6305 6305
 	*
6306 6306
 	*/
6307
-	public function countAllAircraftTypesByCountry($country,$filters = array())
6307
+	public function countAllAircraftTypesByCountry($country, $filters = array())
6308 6308
 	{
6309
-		$filter_query = $this->getFilter($filters,true,true);
6310
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6311
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6309
+		$filter_query = $this->getFilter($filters, true, true);
6310
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6311
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6312 6312
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6313 6313
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
6314 6314
 			    ORDER BY aircraft_icao_count DESC";
@@ -6320,7 +6320,7 @@  discard block
 block discarded – undo
6320 6320
 		$aircraft_array = array();
6321 6321
 		$temp_array = array();
6322 6322
         
6323
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6323
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6324 6324
 		{
6325 6325
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6326 6326
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6339,12 +6339,12 @@  discard block
 block discarded – undo
6339 6339
 	* @return Array the aircraft list
6340 6340
 	*
6341 6341
 	*/
6342
-	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6342
+	public function countAllAircraftRegistrationByCountry($country, $filters = array())
6343 6343
 	{
6344
-		$filter_query = $this->getFilter($filters,true,true);
6344
+		$filter_query = $this->getFilter($filters, true, true);
6345 6345
 		$Image = new Image($this->db);
6346
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6347
-		$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 
6346
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6347
+		$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 
6348 6348
 			    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)    
6349 6349
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
6350 6350
 			    ORDER BY registration_count DESC";
@@ -6356,14 +6356,14 @@  discard block
 block discarded – undo
6356 6356
 		$aircraft_array = array();
6357 6357
 		$temp_array = array();
6358 6358
         
6359
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6359
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6360 6360
 		{
6361 6361
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6362 6362
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6363 6363
 			$temp_array['registration'] = $row['registration'];
6364 6364
 			$temp_array['airline_name'] = $row['airline_name'];
6365 6365
 			$temp_array['image_thumbnail'] = "";
6366
-			if($row['registration'] != "")
6366
+			if ($row['registration'] != "")
6367 6367
 			{
6368 6368
 				$image_array = $Image->getSpotterImage($row['registration']);
6369 6369
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6383,11 +6383,11 @@  discard block
 block discarded – undo
6383 6383
 	* @return Array the aircraft manufacturer list
6384 6384
 	*
6385 6385
 	*/
6386
-	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6386
+	public function countAllAircraftManufacturerByCountry($country, $filters = array())
6387 6387
 	{
6388
-		$filter_query = $this->getFilter($filters,true,true);
6389
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6390
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6388
+		$filter_query = $this->getFilter($filters, true, true);
6389
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6390
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6391 6391
                     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) 
6392 6392
                     GROUP BY spotter_output.aircraft_manufacturer 
6393 6393
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6399,7 +6399,7 @@  discard block
 block discarded – undo
6399 6399
 		$aircraft_array = array();
6400 6400
 		$temp_array = array();
6401 6401
         
6402
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6402
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6403 6403
 		{
6404 6404
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6405 6405
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6418,38 +6418,38 @@  discard block
 block discarded – undo
6418 6418
 	* @return Array the aircraft list
6419 6419
 	*
6420 6420
 	*/
6421
-	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6421
+	public function countAllAircraftManufacturers($filters = array(), $year = '', $month = '', $day = '')
6422 6422
 	{
6423 6423
 		global $globalDBdriver;
6424
-		$filter_query = $this->getFilter($filters,true,true);
6425
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6424
+		$filter_query = $this->getFilter($filters, true, true);
6425
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6426 6426
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6427 6427
                 $query_values = array();
6428 6428
 		if ($year != '') {
6429 6429
 			if ($globalDBdriver == 'mysql') {
6430 6430
 				$query .= " AND YEAR(spotter_output.date) = :year";
6431
-				$query_values = array_merge($query_values,array(':year' => $year));
6431
+				$query_values = array_merge($query_values, array(':year' => $year));
6432 6432
 			} else {
6433 6433
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6434
-				$query_values = array_merge($query_values,array(':year' => $year));
6434
+				$query_values = array_merge($query_values, array(':year' => $year));
6435 6435
 			}
6436 6436
 		}
6437 6437
 		if ($month != '') {
6438 6438
 			if ($globalDBdriver == 'mysql') {
6439 6439
 				$query .= " AND MONTH(spotter_output.date) = :month";
6440
-				$query_values = array_merge($query_values,array(':month' => $month));
6440
+				$query_values = array_merge($query_values, array(':month' => $month));
6441 6441
 			} else {
6442 6442
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6443
-				$query_values = array_merge($query_values,array(':month' => $month));
6443
+				$query_values = array_merge($query_values, array(':month' => $month));
6444 6444
 			}
6445 6445
 		}
6446 6446
 		if ($day != '') {
6447 6447
 			if ($globalDBdriver == 'mysql') {
6448 6448
 				$query .= " AND DAY(spotter_output.date) = :day";
6449
-				$query_values = array_merge($query_values,array(':day' => $day));
6449
+				$query_values = array_merge($query_values, array(':day' => $day));
6450 6450
 			} else {
6451 6451
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6452
-				$query_values = array_merge($query_values,array(':day' => $day));
6452
+				$query_values = array_merge($query_values, array(':day' => $day));
6453 6453
 			}
6454 6454
 		}
6455 6455
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer
@@ -6463,7 +6463,7 @@  discard block
 block discarded – undo
6463 6463
 		$manufacturer_array = array();
6464 6464
 		$temp_array = array();
6465 6465
         
6466
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6466
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6467 6467
 		{
6468 6468
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6469 6469
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6482,12 +6482,12 @@  discard block
 block discarded – undo
6482 6482
 	* @return Array the aircraft list
6483 6483
 	*
6484 6484
 	*/
6485
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6485
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6486 6486
 	{
6487 6487
 		global $globalDBdriver;
6488 6488
 		$Image = new Image($this->db);
6489
-		$filter_query = $this->getFilter($filters,true,true);
6490
-		$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    
6489
+		$filter_query = $this->getFilter($filters, true, true);
6490
+		$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    
6491 6491
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6492 6492
                 if ($olderthanmonths > 0) {
6493 6493
             		if ($globalDBdriver == 'mysql') {
@@ -6507,28 +6507,28 @@  discard block
 block discarded – undo
6507 6507
 		if ($year != '') {
6508 6508
 			if ($globalDBdriver == 'mysql') {
6509 6509
 				$query .= " AND YEAR(spotter_output.date) = :year";
6510
-				$query_values = array_merge($query_values,array(':year' => $year));
6510
+				$query_values = array_merge($query_values, array(':year' => $year));
6511 6511
 			} else {
6512 6512
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6513
-				$query_values = array_merge($query_values,array(':year' => $year));
6513
+				$query_values = array_merge($query_values, array(':year' => $year));
6514 6514
 			}
6515 6515
 		}
6516 6516
 		if ($month != '') {
6517 6517
 			if ($globalDBdriver == 'mysql') {
6518 6518
 				$query .= " AND MONTH(spotter_output.date) = :month";
6519
-				$query_values = array_merge($query_values,array(':month' => $month));
6519
+				$query_values = array_merge($query_values, array(':month' => $month));
6520 6520
 			} else {
6521 6521
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6522
-				$query_values = array_merge($query_values,array(':month' => $month));
6522
+				$query_values = array_merge($query_values, array(':month' => $month));
6523 6523
 			}
6524 6524
 		}
6525 6525
 		if ($day != '') {
6526 6526
 			if ($globalDBdriver == 'mysql') {
6527 6527
 				$query .= " AND DAY(spotter_output.date) = :day";
6528
-				$query_values = array_merge($query_values,array(':day' => $day));
6528
+				$query_values = array_merge($query_values, array(':day' => $day));
6529 6529
 			} else {
6530 6530
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6531
-				$query_values = array_merge($query_values,array(':day' => $day));
6531
+				$query_values = array_merge($query_values, array(':day' => $day));
6532 6532
 			}
6533 6533
 		}
6534 6534
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
@@ -6540,7 +6540,7 @@  discard block
 block discarded – undo
6540 6540
 		$aircraft_array = array();
6541 6541
 		$temp_array = array();
6542 6542
         
6543
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6543
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6544 6544
 		{
6545 6545
 			$temp_array['registration'] = $row['registration'];
6546 6546
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6548,7 +6548,7 @@  discard block
 block discarded – undo
6548 6548
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6549 6549
 			$temp_array['airline_name'] = $row['airline_name'];
6550 6550
 			$temp_array['image_thumbnail'] = "";
6551
-			if($row['registration'] != "")
6551
+			if ($row['registration'] != "")
6552 6552
 			{
6553 6553
 				$image_array = $Image->getSpotterImage($row['registration']);
6554 6554
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6567,12 +6567,12 @@  discard block
 block discarded – undo
6567 6567
 	* @return Array the aircraft list
6568 6568
 	*
6569 6569
 	*/
6570
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6570
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6571 6571
 	{
6572 6572
 		global $globalDBdriver;
6573
-		$filter_query = $this->getFilter($filters,true,true);
6573
+		$filter_query = $this->getFilter($filters, true, true);
6574 6574
 		$Image = new Image($this->db);
6575
-		$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    
6575
+		$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    
6576 6576
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6577 6577
                 if ($olderthanmonths > 0) {
6578 6578
             		if ($globalDBdriver == 'mysql') {
@@ -6600,7 +6600,7 @@  discard block
 block discarded – undo
6600 6600
 		$aircraft_array = array();
6601 6601
 		$temp_array = array();
6602 6602
         
6603
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6603
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6604 6604
 		{
6605 6605
 			$temp_array['registration'] = $row['registration'];
6606 6606
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6609,7 +6609,7 @@  discard block
 block discarded – undo
6609 6609
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6610 6610
 			$temp_array['airline_name'] = $row['airline_name'];
6611 6611
 			$temp_array['image_thumbnail'] = "";
6612
-			if($row['registration'] != "")
6612
+			if ($row['registration'] != "")
6613 6613
 			{
6614 6614
 				$image_array = $Image->getSpotterImage($row['registration']);
6615 6615
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6628,11 +6628,11 @@  discard block
 block discarded – undo
6628 6628
 	* @return Array the airport list
6629 6629
 	*
6630 6630
 	*/
6631
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6631
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6632 6632
 	{
6633 6633
 		global $globalDBdriver;
6634
-		$filter_query = $this->getFilter($filters,true,true);
6635
-		$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 
6634
+		$filter_query = $this->getFilter($filters, true, true);
6635
+		$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 
6636 6636
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6637 6637
                 if ($olderthanmonths > 0) {
6638 6638
             		if ($globalDBdriver == 'mysql') {
@@ -6652,28 +6652,28 @@  discard block
 block discarded – undo
6652 6652
 		if ($year != '') {
6653 6653
 			if ($globalDBdriver == 'mysql') {
6654 6654
 				$query .= " AND YEAR(spotter_output.date) = :year";
6655
-				$query_values = array_merge($query_values,array(':year' => $year));
6655
+				$query_values = array_merge($query_values, array(':year' => $year));
6656 6656
 			} else {
6657 6657
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6658
-				$query_values = array_merge($query_values,array(':year' => $year));
6658
+				$query_values = array_merge($query_values, array(':year' => $year));
6659 6659
 			}
6660 6660
 		}
6661 6661
 		if ($month != '') {
6662 6662
 			if ($globalDBdriver == 'mysql') {
6663 6663
 				$query .= " AND MONTH(spotter_output.date) = :month";
6664
-				$query_values = array_merge($query_values,array(':month' => $month));
6664
+				$query_values = array_merge($query_values, array(':month' => $month));
6665 6665
 			} else {
6666 6666
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6667
-				$query_values = array_merge($query_values,array(':month' => $month));
6667
+				$query_values = array_merge($query_values, array(':month' => $month));
6668 6668
 			}
6669 6669
 		}
6670 6670
 		if ($day != '') {
6671 6671
 			if ($globalDBdriver == 'mysql') {
6672 6672
 				$query .= " AND DAY(spotter_output.date) = :day";
6673
-				$query_values = array_merge($query_values,array(':day' => $day));
6673
+				$query_values = array_merge($query_values, array(':day' => $day));
6674 6674
 			} else {
6675 6675
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6676
-				$query_values = array_merge($query_values,array(':day' => $day));
6676
+				$query_values = array_merge($query_values, array(':day' => $day));
6677 6677
 			}
6678 6678
 		}
6679 6679
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -6685,7 +6685,7 @@  discard block
 block discarded – undo
6685 6685
 
6686 6686
 		$airport_array = array();
6687 6687
 		$temp_array = array();
6688
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6688
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6689 6689
 		{
6690 6690
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6691 6691
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6704,11 +6704,11 @@  discard block
 block discarded – undo
6704 6704
 	* @return Array the airport list
6705 6705
 	*
6706 6706
 	*/
6707
-	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6707
+	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6708 6708
 	{
6709 6709
 		global $globalDBdriver;
6710
-		$filter_query = $this->getFilter($filters,true,true);
6711
-		$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 
6710
+		$filter_query = $this->getFilter($filters, true, true);
6711
+		$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 
6712 6712
 			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 <> '' ";
6713 6713
                 if ($olderthanmonths > 0) {
6714 6714
             		if ($globalDBdriver == 'mysql') {
@@ -6737,7 +6737,7 @@  discard block
 block discarded – undo
6737 6737
 		$airport_array = array();
6738 6738
 		$temp_array = array();
6739 6739
         
6740
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6740
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6741 6741
 		{
6742 6742
 			$temp_array['airline_icao'] = $row['airline_icao'];
6743 6743
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6757,11 +6757,11 @@  discard block
 block discarded – undo
6757 6757
 	* @return Array the airport list
6758 6758
 	*
6759 6759
 	*/
6760
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6760
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6761 6761
 	{
6762 6762
 		global $globalDBdriver;
6763
-		$filter_query = $this->getFilter($filters,true,true);
6764
-		$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
6763
+		$filter_query = $this->getFilter($filters, true, true);
6764
+		$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
6765 6765
 				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";
6766 6766
                 if ($olderthanmonths > 0) {
6767 6767
             		if ($globalDBdriver == 'mysql') {
@@ -6781,28 +6781,28 @@  discard block
 block discarded – undo
6781 6781
 		if ($year != '') {
6782 6782
 			if ($globalDBdriver == 'mysql') {
6783 6783
 				$query .= " AND YEAR(spotter_output.date) = :year";
6784
-				$query_values = array_merge($query_values,array(':year' => $year));
6784
+				$query_values = array_merge($query_values, array(':year' => $year));
6785 6785
 			} else {
6786 6786
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6787
-				$query_values = array_merge($query_values,array(':year' => $year));
6787
+				$query_values = array_merge($query_values, array(':year' => $year));
6788 6788
 			}
6789 6789
 		}
6790 6790
 		if ($month != '') {
6791 6791
 			if ($globalDBdriver == 'mysql') {
6792 6792
 				$query .= " AND MONTH(spotter_output.date) = :month";
6793
-				$query_values = array_merge($query_values,array(':month' => $month));
6793
+				$query_values = array_merge($query_values, array(':month' => $month));
6794 6794
 			} else {
6795 6795
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6796
-				$query_values = array_merge($query_values,array(':month' => $month));
6796
+				$query_values = array_merge($query_values, array(':month' => $month));
6797 6797
 			}
6798 6798
 		}
6799 6799
 		if ($day != '') {
6800 6800
 			if ($globalDBdriver == 'mysql') {
6801 6801
 				$query .= " AND DAY(spotter_output.date) = :day";
6802
-				$query_values = array_merge($query_values,array(':day' => $day));
6802
+				$query_values = array_merge($query_values, array(':day' => $day));
6803 6803
 			} else {
6804 6804
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6805
-				$query_values = array_merge($query_values,array(':day' => $day));
6805
+				$query_values = array_merge($query_values, array(':day' => $day));
6806 6806
 			}
6807 6807
 		}
6808 6808
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
@@ -6815,7 +6815,7 @@  discard block
 block discarded – undo
6815 6815
 		$airport_array = array();
6816 6816
 		$temp_array = array();
6817 6817
         
6818
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6818
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6819 6819
 		{
6820 6820
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6821 6821
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6834,11 +6834,11 @@  discard block
 block discarded – undo
6834 6834
 	* @return Array the airport list
6835 6835
 	*
6836 6836
 	*/
6837
-	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6837
+	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6838 6838
 	{
6839 6839
 		global $globalDBdriver;
6840
-		$filter_query = $this->getFilter($filters,true,true);
6841
-		$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
6840
+		$filter_query = $this->getFilter($filters, true, true);
6841
+		$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
6842 6842
 				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 ";
6843 6843
                 if ($olderthanmonths > 0) {
6844 6844
             		if ($globalDBdriver == 'mysql') {
@@ -6867,7 +6867,7 @@  discard block
 block discarded – undo
6867 6867
 		$airport_array = array();
6868 6868
 		$temp_array = array();
6869 6869
         
6870
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6870
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6871 6871
 		{
6872 6872
 			$temp_array['airline_icao'] = $row['airline_icao'];
6873 6873
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6887,11 +6887,11 @@  discard block
 block discarded – undo
6887 6887
 	* @return Array the airport list
6888 6888
 	*
6889 6889
 	*/
6890
-	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6890
+	public function countAllDepartureAirportsByAirline($airline_icao, $filters = array())
6891 6891
 	{
6892
-		$filter_query = $this->getFilter($filters,true,true);
6893
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6894
-		$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 
6892
+		$filter_query = $this->getFilter($filters, true, true);
6893
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6894
+		$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 
6895 6895
 			    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 <> '' 
6896 6896
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6897 6897
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6903,7 +6903,7 @@  discard block
 block discarded – undo
6903 6903
 		$airport_array = array();
6904 6904
 		$temp_array = array();
6905 6905
         
6906
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6906
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6907 6907
 		{
6908 6908
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6909 6909
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6925,11 +6925,11 @@  discard block
 block discarded – undo
6925 6925
 	* @return Array the airport list
6926 6926
 	*
6927 6927
 	*/
6928
-	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6928
+	public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array())
6929 6929
 	{
6930
-		$filter_query = $this->getFilter($filters,true,true);
6931
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6932
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6930
+		$filter_query = $this->getFilter($filters, true, true);
6931
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6932
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6933 6933
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6934 6934
                     GROUP BY spotter_output.departure_airport_country
6935 6935
 					ORDER BY airport_departure_country_count DESC";
@@ -6941,7 +6941,7 @@  discard block
 block discarded – undo
6941 6941
 		$airport_array = array();
6942 6942
 		$temp_array = array();
6943 6943
         
6944
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6944
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6945 6945
 		{
6946 6946
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6947 6947
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6960,11 +6960,11 @@  discard block
 block discarded – undo
6960 6960
 	* @return Array the airport list
6961 6961
 	*
6962 6962
 	*/
6963
-	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6963
+	public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array())
6964 6964
 	{
6965
-		$filter_query = $this->getFilter($filters,true,true);
6966
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6967
-		$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 
6965
+		$filter_query = $this->getFilter($filters, true, true);
6966
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6967
+		$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 
6968 6968
 			    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 <> '' 
6969 6969
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6970 6970
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6976,7 +6976,7 @@  discard block
 block discarded – undo
6976 6976
 		$airport_array = array();
6977 6977
 		$temp_array = array();
6978 6978
         
6979
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6979
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6980 6980
 		{
6981 6981
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6982 6982
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6997,11 +6997,11 @@  discard block
 block discarded – undo
6997 6997
 	* @return Array the airport list
6998 6998
 	*
6999 6999
 	*/
7000
-	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7000
+	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array())
7001 7001
 	{
7002
-		$filter_query = $this->getFilter($filters,true,true);
7003
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7004
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7002
+		$filter_query = $this->getFilter($filters, true, true);
7003
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7004
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7005 7005
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
7006 7006
                     GROUP BY spotter_output.departure_airport_country
7007 7007
 					ORDER BY airport_departure_country_count DESC";
@@ -7013,7 +7013,7 @@  discard block
 block discarded – undo
7013 7013
 		$airport_array = array();
7014 7014
 		$temp_array = array();
7015 7015
         
7016
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7016
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7017 7017
 		{
7018 7018
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7019 7019
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7031,11 +7031,11 @@  discard block
 block discarded – undo
7031 7031
 	* @return Array the airport list
7032 7032
 	*
7033 7033
 	*/
7034
-	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7034
+	public function countAllDepartureAirportsByRegistration($registration, $filters = array())
7035 7035
 	{
7036
-		$filter_query = $this->getFilter($filters,true,true);
7037
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7038
-		$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 
7036
+		$filter_query = $this->getFilter($filters, true, true);
7037
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7038
+		$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 
7039 7039
 			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 <> '' 
7040 7040
                     GROUP BY spotter_output.departure_airport_icao
7041 7041
 					ORDER BY airport_departure_icao_count DESC";
@@ -7047,7 +7047,7 @@  discard block
 block discarded – undo
7047 7047
 		$airport_array = array();
7048 7048
 		$temp_array = array();
7049 7049
         
7050
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7050
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7051 7051
 		{
7052 7052
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7053 7053
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7068,11 +7068,11 @@  discard block
 block discarded – undo
7068 7068
 	* @return Array the airport list
7069 7069
 	*
7070 7070
 	*/
7071
-	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7071
+	public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array())
7072 7072
 	{
7073
-		$filter_query = $this->getFilter($filters,true,true);
7074
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7075
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7073
+		$filter_query = $this->getFilter($filters, true, true);
7074
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7075
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7076 7076
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
7077 7077
                     GROUP BY spotter_output.departure_airport_country
7078 7078
 					ORDER BY airport_departure_country_count DESC";
@@ -7084,7 +7084,7 @@  discard block
 block discarded – undo
7084 7084
 		$airport_array = array();
7085 7085
 		$temp_array = array();
7086 7086
         
7087
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7087
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7088 7088
 		{
7089 7089
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7090 7090
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7102,11 +7102,11 @@  discard block
 block discarded – undo
7102 7102
 	* @return Array the airport list
7103 7103
 	*
7104 7104
 	*/
7105
-	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7105
+	public function countAllDepartureAirportsByAirport($airport_icao, $filters = array())
7106 7106
 	{
7107
-		$filter_query = $this->getFilter($filters,true,true);
7108
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7109
-		$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 
7107
+		$filter_query = $this->getFilter($filters, true, true);
7108
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7109
+		$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 
7110 7110
 			    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 <> '' 
7111 7111
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7112 7112
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7118,7 +7118,7 @@  discard block
 block discarded – undo
7118 7118
 		$airport_array = array();
7119 7119
 		$temp_array = array();
7120 7120
         
7121
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7121
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7122 7122
 		{
7123 7123
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7124 7124
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7139,11 +7139,11 @@  discard block
 block discarded – undo
7139 7139
 	* @return Array the airport list
7140 7140
 	*
7141 7141
 	*/
7142
-	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7142
+	public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array())
7143 7143
 	{
7144
-		$filter_query = $this->getFilter($filters,true,true);
7145
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7146
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7144
+		$filter_query = $this->getFilter($filters, true, true);
7145
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7146
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7147 7147
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
7148 7148
                     GROUP BY spotter_output.departure_airport_country
7149 7149
 					ORDER BY airport_departure_country_count DESC";
@@ -7155,7 +7155,7 @@  discard block
 block discarded – undo
7155 7155
 		$airport_array = array();
7156 7156
 		$temp_array = array();
7157 7157
         
7158
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7158
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7159 7159
 		{
7160 7160
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7161 7161
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7174,11 +7174,11 @@  discard block
 block discarded – undo
7174 7174
 	* @return Array the airport list
7175 7175
 	*
7176 7176
 	*/
7177
-	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7177
+	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array())
7178 7178
 	{
7179
-		$filter_query = $this->getFilter($filters,true,true);
7180
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7181
-		$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 
7179
+		$filter_query = $this->getFilter($filters, true, true);
7180
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7181
+		$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 
7182 7182
 			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 <> '' 
7183 7183
                     GROUP BY spotter_output.departure_airport_icao
7184 7184
 					ORDER BY airport_departure_icao_count DESC";
@@ -7190,7 +7190,7 @@  discard block
 block discarded – undo
7190 7190
 		$airport_array = array();
7191 7191
 		$temp_array = array();
7192 7192
         
7193
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7193
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7194 7194
 		{
7195 7195
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7196 7196
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7211,11 +7211,11 @@  discard block
 block discarded – undo
7211 7211
 	* @return Array the airport list
7212 7212
 	*
7213 7213
 	*/
7214
-	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7214
+	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
7215 7215
 	{
7216
-		$filter_query = $this->getFilter($filters,true,true);
7217
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7218
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7216
+		$filter_query = $this->getFilter($filters, true, true);
7217
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7218
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7219 7219
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
7220 7220
                     GROUP BY spotter_output.departure_airport_country
7221 7221
 					ORDER BY airport_departure_country_count DESC";
@@ -7227,7 +7227,7 @@  discard block
 block discarded – undo
7227 7227
 		$airport_array = array();
7228 7228
 		$temp_array = array();
7229 7229
         
7230
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7230
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7231 7231
 		{
7232 7232
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7233 7233
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7245,11 +7245,11 @@  discard block
 block discarded – undo
7245 7245
 	* @return Array the airport list
7246 7246
 	*
7247 7247
 	*/
7248
-	public function countAllDepartureAirportsByDate($date,$filters = array())
7248
+	public function countAllDepartureAirportsByDate($date, $filters = array())
7249 7249
 	{
7250 7250
 		global $globalTimezone, $globalDBdriver;
7251
-		$filter_query = $this->getFilter($filters,true,true);
7252
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7251
+		$filter_query = $this->getFilter($filters, true, true);
7252
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7253 7253
 		if ($globalTimezone != '') {
7254 7254
 			date_default_timezone_set($globalTimezone);
7255 7255
 			$datetime = new DateTime($date);
@@ -7257,12 +7257,12 @@  discard block
 block discarded – undo
7257 7257
 		} else $offset = '+00:00';
7258 7258
 
7259 7259
 		if ($globalDBdriver == 'mysql') {
7260
-			$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 
7260
+			$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 
7261 7261
 					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
7262 7262
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7263 7263
 					ORDER BY airport_departure_icao_count DESC";
7264 7264
 		} else {
7265
-			$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 
7265
+			$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 
7266 7266
 					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
7267 7267
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7268 7268
 					ORDER BY airport_departure_icao_count DESC";
@@ -7274,7 +7274,7 @@  discard block
 block discarded – undo
7274 7274
 		$airport_array = array();
7275 7275
 		$temp_array = array();
7276 7276
         
7277
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7277
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7278 7278
 		{
7279 7279
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7280 7280
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7295,11 +7295,11 @@  discard block
 block discarded – undo
7295 7295
 	* @return Array the airport list
7296 7296
 	*
7297 7297
 	*/
7298
-	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7298
+	public function countAllDepartureAirportCountriesByDate($date, $filters = array())
7299 7299
 	{
7300 7300
 		global $globalTimezone, $globalDBdriver;
7301
-		$filter_query = $this->getFilter($filters,true,true);
7302
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7301
+		$filter_query = $this->getFilter($filters, true, true);
7302
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7303 7303
 		if ($globalTimezone != '') {
7304 7304
 			date_default_timezone_set($globalTimezone);
7305 7305
 			$datetime = new DateTime($date);
@@ -7307,12 +7307,12 @@  discard block
 block discarded – undo
7307 7307
 		} else $offset = '+00:00';
7308 7308
 
7309 7309
 		if ($globalDBdriver == 'mysql') {
7310
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7310
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7311 7311
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
7312 7312
 					GROUP BY spotter_output.departure_airport_country
7313 7313
 					ORDER BY airport_departure_country_count DESC";
7314 7314
 		} else {
7315
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7315
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7316 7316
 					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 
7317 7317
 					GROUP BY spotter_output.departure_airport_country
7318 7318
 					ORDER BY airport_departure_country_count DESC";
@@ -7324,7 +7324,7 @@  discard block
 block discarded – undo
7324 7324
 		$airport_array = array();
7325 7325
 		$temp_array = array();
7326 7326
         
7327
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7327
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7328 7328
 		{
7329 7329
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7330 7330
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7342,11 +7342,11 @@  discard block
 block discarded – undo
7342 7342
 	* @return Array the airport list
7343 7343
 	*
7344 7344
 	*/
7345
-	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7345
+	public function countAllDepartureAirportsByIdent($ident, $filters = array())
7346 7346
 	{
7347
-		$filter_query = $this->getFilter($filters,true,true);
7348
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7349
-		$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 
7347
+		$filter_query = $this->getFilter($filters, true, true);
7348
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7349
+		$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 
7350 7350
 		    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 
7351 7351
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7352 7352
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7358,7 +7358,7 @@  discard block
 block discarded – undo
7358 7358
 		$airport_array = array();
7359 7359
 		$temp_array = array();
7360 7360
         
7361
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7361
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7362 7362
 		{
7363 7363
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7364 7364
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7378,11 +7378,11 @@  discard block
 block discarded – undo
7378 7378
 	* @return Array the airport list
7379 7379
 	*
7380 7380
 	*/
7381
-	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7381
+	public function countAllDepartureAirportsByOwner($owner, $filters = array())
7382 7382
 	{
7383
-		$filter_query = $this->getFilter($filters,true,true);
7384
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7385
-		$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 
7383
+		$filter_query = $this->getFilter($filters, true, true);
7384
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7385
+		$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 
7386 7386
 		    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 
7387 7387
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7388 7388
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7394,7 +7394,7 @@  discard block
 block discarded – undo
7394 7394
 		$airport_array = array();
7395 7395
 		$temp_array = array();
7396 7396
         
7397
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7397
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7398 7398
 		{
7399 7399
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7400 7400
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7414,11 +7414,11 @@  discard block
 block discarded – undo
7414 7414
 	* @return Array the airport list
7415 7415
 	*
7416 7416
 	*/
7417
-	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7417
+	public function countAllDepartureAirportsByPilot($pilot, $filters = array())
7418 7418
 	{
7419
-		$filter_query = $this->getFilter($filters,true,true);
7420
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7421
-		$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 
7419
+		$filter_query = $this->getFilter($filters, true, true);
7420
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7421
+		$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 
7422 7422
 		    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) 
7423 7423
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7424 7424
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7429,7 +7429,7 @@  discard block
 block discarded – undo
7429 7429
 		$airport_array = array();
7430 7430
 		$temp_array = array();
7431 7431
         
7432
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7432
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7433 7433
 		{
7434 7434
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7435 7435
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7451,11 +7451,11 @@  discard block
 block discarded – undo
7451 7451
 	* @return Array the airport list
7452 7452
 	*
7453 7453
 	*/
7454
-	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7454
+	public function countAllDepartureAirportCountriesByIdent($ident, $filters = array())
7455 7455
 	{
7456
-		$filter_query = $this->getFilter($filters,true,true);
7457
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7458
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7456
+		$filter_query = $this->getFilter($filters, true, true);
7457
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7458
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7459 7459
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
7460 7460
                     GROUP BY spotter_output.departure_airport_country
7461 7461
 					ORDER BY airport_departure_country_count DESC";
@@ -7467,7 +7467,7 @@  discard block
 block discarded – undo
7467 7467
 		$airport_array = array();
7468 7468
 		$temp_array = array();
7469 7469
         
7470
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7470
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7471 7471
 		{
7472 7472
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7473 7473
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7484,11 +7484,11 @@  discard block
 block discarded – undo
7484 7484
 	* @return Array the airport list
7485 7485
 	*
7486 7486
 	*/
7487
-	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7487
+	public function countAllDepartureAirportCountriesByOwner($owner, $filters = array())
7488 7488
 	{
7489
-		$filter_query = $this->getFilter($filters,true,true);
7490
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7491
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7489
+		$filter_query = $this->getFilter($filters, true, true);
7490
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7491
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7492 7492
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner 
7493 7493
 			GROUP BY spotter_output.departure_airport_country
7494 7494
 			ORDER BY airport_departure_country_count DESC";
@@ -7504,11 +7504,11 @@  discard block
 block discarded – undo
7504 7504
 	* @return Array the airport list
7505 7505
 	*
7506 7506
 	*/
7507
-	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7507
+	public function countAllDepartureAirportCountriesByPilot($pilot, $filters = array())
7508 7508
 	{
7509
-		$filter_query = $this->getFilter($filters,true,true);
7510
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7511
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7509
+		$filter_query = $this->getFilter($filters, true, true);
7510
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7511
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7512 7512
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7513 7513
 			GROUP BY spotter_output.departure_airport_country
7514 7514
 			ORDER BY airport_departure_country_count DESC";
@@ -7526,12 +7526,12 @@  discard block
 block discarded – undo
7526 7526
 	* @return Array the airport list
7527 7527
 	*
7528 7528
 	*/
7529
-	public function countAllDepartureAirportsByCountry($country,$filters = array())
7529
+	public function countAllDepartureAirportsByCountry($country, $filters = array())
7530 7530
 	{
7531
-		$filter_query = $this->getFilter($filters,true,true);
7532
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7531
+		$filter_query = $this->getFilter($filters, true, true);
7532
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7533 7533
 
7534
-		$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 
7534
+		$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 
7535 7535
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
7536 7536
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7537 7537
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7543,7 +7543,7 @@  discard block
 block discarded – undo
7543 7543
 		$airport_array = array();
7544 7544
 		$temp_array = array();
7545 7545
         
7546
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7546
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7547 7547
 		{
7548 7548
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7549 7549
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7564,11 +7564,11 @@  discard block
 block discarded – undo
7564 7564
 	* @return Array the airport list
7565 7565
 	*
7566 7566
 	*/
7567
-	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7567
+	public function countAllDepartureAirportCountriesByCountry($country, $filters = array())
7568 7568
 	{
7569
-		$filter_query = $this->getFilter($filters,true,true);
7570
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7571
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7569
+		$filter_query = $this->getFilter($filters, true, true);
7570
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7571
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7572 7572
 			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 
7573 7573
                     GROUP BY spotter_output.departure_airport_country
7574 7574
 					ORDER BY airport_departure_country_count DESC";
@@ -7580,7 +7580,7 @@  discard block
 block discarded – undo
7580 7580
 		$airport_array = array();
7581 7581
 		$temp_array = array();
7582 7582
         
7583
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7583
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7584 7584
 		{
7585 7585
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7586 7586
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7603,11 +7603,11 @@  discard block
 block discarded – undo
7603 7603
 	* @return Array the airport list
7604 7604
 	*
7605 7605
 	*/
7606
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7606
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7607 7607
 	{
7608 7608
 		global $globalDBdriver;
7609
-		$filter_query = $this->getFilter($filters,true,true);
7610
-		$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 
7609
+		$filter_query = $this->getFilter($filters, true, true);
7610
+		$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 
7611 7611
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7612 7612
                 if ($olderthanmonths > 0) {
7613 7613
             		if ($globalDBdriver == 'mysql') {
@@ -7627,28 +7627,28 @@  discard block
 block discarded – undo
7627 7627
 		if ($year != '') {
7628 7628
 			if ($globalDBdriver == 'mysql') {
7629 7629
 				$query .= " AND YEAR(spotter_output.date) = :year";
7630
-				$query_values = array_merge($query_values,array(':year' => $year));
7630
+				$query_values = array_merge($query_values, array(':year' => $year));
7631 7631
 			} else {
7632 7632
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7633
-				$query_values = array_merge($query_values,array(':year' => $year));
7633
+				$query_values = array_merge($query_values, array(':year' => $year));
7634 7634
 			}
7635 7635
 		}
7636 7636
 		if ($month != '') {
7637 7637
 			if ($globalDBdriver == 'mysql') {
7638 7638
 				$query .= " AND MONTH(spotter_output.date) = :month";
7639
-				$query_values = array_merge($query_values,array(':month' => $month));
7639
+				$query_values = array_merge($query_values, array(':month' => $month));
7640 7640
 			} else {
7641 7641
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7642
-				$query_values = array_merge($query_values,array(':month' => $month));
7642
+				$query_values = array_merge($query_values, array(':month' => $month));
7643 7643
 			}
7644 7644
 		}
7645 7645
 		if ($day != '') {
7646 7646
 			if ($globalDBdriver == 'mysql') {
7647 7647
 				$query .= " AND DAY(spotter_output.date) = :day";
7648
-				$query_values = array_merge($query_values,array(':day' => $day));
7648
+				$query_values = array_merge($query_values, array(':day' => $day));
7649 7649
 			} else {
7650 7650
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7651
-				$query_values = array_merge($query_values,array(':day' => $day));
7651
+				$query_values = array_merge($query_values, array(':day' => $day));
7652 7652
 			}
7653 7653
 		}
7654 7654
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -7662,7 +7662,7 @@  discard block
 block discarded – undo
7662 7662
 		$airport_array = array();
7663 7663
 		$temp_array = array();
7664 7664
         
7665
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7665
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7666 7666
 		{
7667 7667
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7668 7668
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7685,11 +7685,11 @@  discard block
 block discarded – undo
7685 7685
 	* @return Array the airport list
7686 7686
 	*
7687 7687
 	*/
7688
-	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7688
+	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7689 7689
 	{
7690 7690
 		global $globalDBdriver;
7691
-		$filter_query = $this->getFilter($filters,true,true);
7692
-		$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 
7691
+		$filter_query = $this->getFilter($filters, true, true);
7692
+		$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 
7693 7693
 			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 <> '' ";
7694 7694
                 if ($olderthanmonths > 0) {
7695 7695
             		if ($globalDBdriver == 'mysql') {
@@ -7719,7 +7719,7 @@  discard block
 block discarded – undo
7719 7719
 		$airport_array = array();
7720 7720
 		$temp_array = array();
7721 7721
         
7722
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7722
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7723 7723
 		{
7724 7724
 			$temp_array['airline_icao'] = $row['airline_icao'];
7725 7725
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -7744,11 +7744,11 @@  discard block
 block discarded – undo
7744 7744
 	* @return Array the airport list
7745 7745
 	*
7746 7746
 	*/
7747
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7747
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7748 7748
 	{
7749 7749
 		global $globalDBdriver;
7750
-		$filter_query = $this->getFilter($filters,true,true);
7751
-		$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 
7750
+		$filter_query = $this->getFilter($filters, true, true);
7751
+		$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 
7752 7752
 			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";
7753 7753
                 if ($olderthanmonths > 0) {
7754 7754
             		if ($globalDBdriver == 'mysql') {
@@ -7768,28 +7768,28 @@  discard block
 block discarded – undo
7768 7768
 		if ($year != '') {
7769 7769
 			if ($globalDBdriver == 'mysql') {
7770 7770
 				$query .= " AND YEAR(spotter_output.date) = :year";
7771
-				$query_values = array_merge($query_values,array(':year' => $year));
7771
+				$query_values = array_merge($query_values, array(':year' => $year));
7772 7772
 			} else {
7773 7773
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7774
-				$query_values = array_merge($query_values,array(':year' => $year));
7774
+				$query_values = array_merge($query_values, array(':year' => $year));
7775 7775
 			}
7776 7776
 		}
7777 7777
 		if ($month != '') {
7778 7778
 			if ($globalDBdriver == 'mysql') {
7779 7779
 				$query .= " AND MONTH(spotter_output.date) = :month";
7780
-				$query_values = array_merge($query_values,array(':month' => $month));
7780
+				$query_values = array_merge($query_values, array(':month' => $month));
7781 7781
 			} else {
7782 7782
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7783
-				$query_values = array_merge($query_values,array(':month' => $month));
7783
+				$query_values = array_merge($query_values, array(':month' => $month));
7784 7784
 			}
7785 7785
 		}
7786 7786
 		if ($day != '') {
7787 7787
 			if ($globalDBdriver == 'mysql') {
7788 7788
 				$query .= " AND DAY(spotter_output.date) = :day";
7789
-				$query_values = array_merge($query_values,array(':day' => $day));
7789
+				$query_values = array_merge($query_values, array(':day' => $day));
7790 7790
 			} else {
7791 7791
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7792
-				$query_values = array_merge($query_values,array(':day' => $day));
7792
+				$query_values = array_merge($query_values, array(':day' => $day));
7793 7793
 			}
7794 7794
 		}
7795 7795
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
@@ -7802,7 +7802,7 @@  discard block
 block discarded – undo
7802 7802
       
7803 7803
 		$airport_array = array();
7804 7804
 		$temp_array = array();
7805
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7805
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7806 7806
 		{
7807 7807
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7808 7808
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7825,11 +7825,11 @@  discard block
 block discarded – undo
7825 7825
 	* @return Array the airport list
7826 7826
 	*
7827 7827
 	*/
7828
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7828
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7829 7829
 	{
7830 7830
 		global $globalDBdriver;
7831
-		$filter_query = $this->getFilter($filters,true,true);
7832
-		$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 
7831
+		$filter_query = $this->getFilter($filters, true, true);
7832
+		$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 
7833 7833
 			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 ";
7834 7834
                 if ($olderthanmonths > 0) {
7835 7835
             		if ($globalDBdriver == 'mysql') {
@@ -7859,7 +7859,7 @@  discard block
 block discarded – undo
7859 7859
 		$airport_array = array();
7860 7860
 		$temp_array = array();
7861 7861
         
7862
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7862
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7863 7863
 		{
7864 7864
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7865 7865
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7885,9 +7885,9 @@  discard block
 block discarded – undo
7885 7885
 	*/
7886 7886
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7887 7887
 	{
7888
-		$filter_query = $this->getFilter($filters,true,true);
7889
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7890
-		$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 
7888
+		$filter_query = $this->getFilter($filters, true, true);
7889
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7890
+		$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 
7891 7891
 			    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 
7892 7892
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7893 7893
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7898,7 +7898,7 @@  discard block
 block discarded – undo
7898 7898
 		$airport_array = array();
7899 7899
 		$temp_array = array();
7900 7900
         
7901
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7901
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7902 7902
 		{
7903 7903
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7904 7904
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7919,12 +7919,12 @@  discard block
 block discarded – undo
7919 7919
 	* @return Array the airport list
7920 7920
 	*
7921 7921
 	*/
7922
-	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7922
+	public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array())
7923 7923
 	{
7924
-		$filter_query = $this->getFilter($filters,true,true);
7925
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7924
+		$filter_query = $this->getFilter($filters, true, true);
7925
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7926 7926
 					
7927
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7927
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7928 7928
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
7929 7929
                     GROUP BY spotter_output.arrival_airport_country
7930 7930
 					ORDER BY airport_arrival_country_count DESC";
@@ -7936,7 +7936,7 @@  discard block
 block discarded – undo
7936 7936
 		$airport_array = array();
7937 7937
 		$temp_array = array();
7938 7938
         
7939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7940 7940
 		{
7941 7941
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7942 7942
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7954,11 +7954,11 @@  discard block
 block discarded – undo
7954 7954
 	* @return Array the airport list
7955 7955
 	*
7956 7956
 	*/
7957
-	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7957
+	public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array())
7958 7958
 	{
7959
-		$filter_query = $this->getFilter($filters,true,true);
7960
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7961
-		$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 
7959
+		$filter_query = $this->getFilter($filters, true, true);
7960
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7961
+		$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 
7962 7962
 			    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 
7963 7963
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7964 7964
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7970,7 +7970,7 @@  discard block
 block discarded – undo
7970 7970
 		$airport_array = array();
7971 7971
 		$temp_array = array();
7972 7972
         
7973
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7973
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7974 7974
 		{
7975 7975
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7976 7976
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7992,11 +7992,11 @@  discard block
 block discarded – undo
7992 7992
 	* @return Array the airport list
7993 7993
 	*
7994 7994
 	*/
7995
-	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
7995
+	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array())
7996 7996
 	{
7997
-		$filter_query = $this->getFilter($filters,true,true);
7998
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7999
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7997
+		$filter_query = $this->getFilter($filters, true, true);
7998
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7999
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8000 8000
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
8001 8001
                     GROUP BY spotter_output.arrival_airport_country
8002 8002
 					ORDER BY airport_arrival_country_count DESC";
@@ -8008,7 +8008,7 @@  discard block
 block discarded – undo
8008 8008
 		$airport_array = array();
8009 8009
 		$temp_array = array();
8010 8010
         
8011
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8011
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8012 8012
 		{
8013 8013
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8014 8014
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8026,12 +8026,12 @@  discard block
 block discarded – undo
8026 8026
 	* @return Array the airport list
8027 8027
 	*
8028 8028
 	*/
8029
-	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8029
+	public function countAllArrivalAirportsByRegistration($registration, $filters = array())
8030 8030
 	{
8031
-		$filter_query = $this->getFilter($filters,true,true);
8032
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8031
+		$filter_query = $this->getFilter($filters, true, true);
8032
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8033 8033
 
8034
-		$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 
8034
+		$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 
8035 8035
 			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 
8036 8036
                     GROUP BY spotter_output.arrival_airport_icao
8037 8037
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8043,7 +8043,7 @@  discard block
 block discarded – undo
8043 8043
 		$airport_array = array();
8044 8044
 		$temp_array = array();
8045 8045
         
8046
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8046
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8047 8047
 		{
8048 8048
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8049 8049
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8064,11 +8064,11 @@  discard block
 block discarded – undo
8064 8064
 	* @return Array the airport list
8065 8065
 	*
8066 8066
 	*/
8067
-	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8067
+	public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array())
8068 8068
 	{
8069
-		$filter_query = $this->getFilter($filters,true,true);
8070
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8071
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8069
+		$filter_query = $this->getFilter($filters, true, true);
8070
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8071
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8072 8072
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
8073 8073
                     GROUP BY spotter_output.arrival_airport_country
8074 8074
 					ORDER BY airport_arrival_country_count DESC";
@@ -8080,7 +8080,7 @@  discard block
 block discarded – undo
8080 8080
 		$airport_array = array();
8081 8081
 		$temp_array = array();
8082 8082
         
8083
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8083
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8084 8084
 		{
8085 8085
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8086 8086
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8099,11 +8099,11 @@  discard block
 block discarded – undo
8099 8099
 	* @return Array the airport list
8100 8100
 	*
8101 8101
 	*/
8102
-	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8102
+	public function countAllArrivalAirportsByAirport($airport_icao, $filters = array())
8103 8103
 	{
8104
-		$filter_query = $this->getFilter($filters,true,true);
8105
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8106
-		$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 
8104
+		$filter_query = $this->getFilter($filters, true, true);
8105
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8106
+		$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 
8107 8107
 			    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 
8108 8108
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8109 8109
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8115,7 +8115,7 @@  discard block
 block discarded – undo
8115 8115
 		$airport_array = array();
8116 8116
 		$temp_array = array();
8117 8117
         
8118
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8118
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8119 8119
 		{
8120 8120
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8121 8121
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8136,11 +8136,11 @@  discard block
 block discarded – undo
8136 8136
 	* @return Array the airport list
8137 8137
 	*
8138 8138
 	*/
8139
-	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8139
+	public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array())
8140 8140
 	{
8141
-		$filter_query = $this->getFilter($filters,true,true);
8142
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8143
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8141
+		$filter_query = $this->getFilter($filters, true, true);
8142
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8143
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8144 8144
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8145 8145
                     GROUP BY spotter_output.arrival_airport_country
8146 8146
 					ORDER BY airport_arrival_country_count DESC";
@@ -8152,7 +8152,7 @@  discard block
 block discarded – undo
8152 8152
 		$airport_array = array();
8153 8153
 		$temp_array = array();
8154 8154
         
8155
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8155
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8156 8156
 		{
8157 8157
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8158 8158
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8170,11 +8170,11 @@  discard block
 block discarded – undo
8170 8170
 	* @return Array the airport list
8171 8171
 	*
8172 8172
 	*/
8173
-	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8173
+	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array())
8174 8174
 	{
8175
-		$filter_query = $this->getFilter($filters,true,true);
8176
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8177
-		$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 
8175
+		$filter_query = $this->getFilter($filters, true, true);
8176
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8177
+		$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 
8178 8178
 			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 
8179 8179
                     GROUP BY spotter_output.arrival_airport_icao
8180 8180
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8186,7 +8186,7 @@  discard block
 block discarded – undo
8186 8186
 		$airport_array = array();
8187 8187
 		$temp_array = array();
8188 8188
         
8189
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8189
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8190 8190
 		{
8191 8191
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8192 8192
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8208,11 +8208,11 @@  discard block
 block discarded – undo
8208 8208
 	* @return Array the airport list
8209 8209
 	*
8210 8210
 	*/
8211
-	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8211
+	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
8212 8212
 	{
8213
-		$filter_query = $this->getFilter($filters,true,true);
8214
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8215
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8213
+		$filter_query = $this->getFilter($filters, true, true);
8214
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8215
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8216 8216
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8217 8217
                     GROUP BY spotter_output.arrival_airport_country
8218 8218
 					ORDER BY airport_arrival_country_count DESC";
@@ -8224,7 +8224,7 @@  discard block
 block discarded – undo
8224 8224
 		$airport_array = array();
8225 8225
 		$temp_array = array();
8226 8226
         
8227
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8227
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8228 8228
 		{
8229 8229
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8230 8230
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8243,11 +8243,11 @@  discard block
 block discarded – undo
8243 8243
 	* @return Array the airport list
8244 8244
 	*
8245 8245
 	*/
8246
-	public function countAllArrivalAirportsByDate($date,$filters = array())
8246
+	public function countAllArrivalAirportsByDate($date, $filters = array())
8247 8247
 	{
8248 8248
 		global $globalTimezone, $globalDBdriver;
8249
-		$filter_query = $this->getFilter($filters,true,true);
8250
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8249
+		$filter_query = $this->getFilter($filters, true, true);
8250
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8251 8251
 		if ($globalTimezone != '') {
8252 8252
 			date_default_timezone_set($globalTimezone);
8253 8253
 			$datetime = new DateTime($date);
@@ -8255,12 +8255,12 @@  discard block
 block discarded – undo
8255 8255
 		} else $offset = '+00:00';
8256 8256
 
8257 8257
 		if ($globalDBdriver == 'mysql') {
8258
-			$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 
8258
+			$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 
8259 8259
 					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  
8260 8260
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8261 8261
 					ORDER BY airport_arrival_icao_count DESC";
8262 8262
 		} else {
8263
-			$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 
8263
+			$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 
8264 8264
 					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  
8265 8265
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8266 8266
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8272,7 +8272,7 @@  discard block
 block discarded – undo
8272 8272
 		$airport_array = array();
8273 8273
 		$temp_array = array();
8274 8274
         
8275
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8275
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8276 8276
 		{
8277 8277
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8278 8278
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8296,8 +8296,8 @@  discard block
 block discarded – undo
8296 8296
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8297 8297
 	{
8298 8298
 		global $globalTimezone, $globalDBdriver;
8299
-		$filter_query = $this->getFilter($filters,true,true);
8300
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8299
+		$filter_query = $this->getFilter($filters, true, true);
8300
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8301 8301
 		if ($globalTimezone != '') {
8302 8302
 			date_default_timezone_set($globalTimezone);
8303 8303
 			$datetime = new DateTime($date);
@@ -8305,12 +8305,12 @@  discard block
 block discarded – undo
8305 8305
 		} else $offset = '+00:00';
8306 8306
 
8307 8307
 		if ($globalDBdriver == 'mysql') {
8308
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8308
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8309 8309
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
8310 8310
 					GROUP BY spotter_output.arrival_airport_country
8311 8311
 					ORDER BY airport_arrival_country_count DESC";
8312 8312
 		} else {
8313
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8313
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8314 8314
 					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 
8315 8315
 					GROUP BY spotter_output.arrival_airport_country
8316 8316
 					ORDER BY airport_arrival_country_count DESC";
@@ -8322,7 +8322,7 @@  discard block
 block discarded – undo
8322 8322
 		$airport_array = array();
8323 8323
 		$temp_array = array();
8324 8324
         
8325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8326 8326
 		{
8327 8327
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8328 8328
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8340,11 +8340,11 @@  discard block
 block discarded – undo
8340 8340
 	* @return Array the airport list
8341 8341
 	*
8342 8342
 	*/
8343
-	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8343
+	public function countAllArrivalAirportsByIdent($ident, $filters = array())
8344 8344
 	{
8345
-		$filter_query = $this->getFilter($filters,true,true);
8346
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8347
-		$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 
8345
+		$filter_query = $this->getFilter($filters, true, true);
8346
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8347
+		$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 
8348 8348
 		    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  
8349 8349
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8350 8350
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8356,7 +8356,7 @@  discard block
 block discarded – undo
8356 8356
 		$airport_array = array();
8357 8357
 		$temp_array = array();
8358 8358
         
8359
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8359
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8360 8360
 		{
8361 8361
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8362 8362
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8376,11 +8376,11 @@  discard block
 block discarded – undo
8376 8376
 	* @return Array the airport list
8377 8377
 	*
8378 8378
 	*/
8379
-	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8379
+	public function countAllArrivalAirportsByOwner($owner, $filters = array())
8380 8380
 	{
8381
-		$filter_query = $this->getFilter($filters,true,true);
8382
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8383
-		$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 
8381
+		$filter_query = $this->getFilter($filters, true, true);
8382
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8383
+		$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 
8384 8384
 		    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 
8385 8385
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8386 8386
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8391,7 +8391,7 @@  discard block
 block discarded – undo
8391 8391
 		$airport_array = array();
8392 8392
 		$temp_array = array();
8393 8393
         
8394
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8394
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8395 8395
 		{
8396 8396
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8397 8397
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8411,11 +8411,11 @@  discard block
 block discarded – undo
8411 8411
 	* @return Array the airport list
8412 8412
 	*
8413 8413
 	*/
8414
-	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8414
+	public function countAllArrivalAirportsByPilot($pilot, $filters = array())
8415 8415
 	{
8416
-		$filter_query = $this->getFilter($filters,true,true);
8417
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8418
-		$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 
8416
+		$filter_query = $this->getFilter($filters, true, true);
8417
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8418
+		$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 
8419 8419
 		    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) 
8420 8420
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8421 8421
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8426,7 +8426,7 @@  discard block
 block discarded – undo
8426 8426
 		$airport_array = array();
8427 8427
 		$temp_array = array();
8428 8428
         
8429
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8429
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8430 8430
 		{
8431 8431
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8432 8432
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8448,9 +8448,9 @@  discard block
 block discarded – undo
8448 8448
 	*/
8449 8449
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8450 8450
 	{
8451
-		$filter_query = $this->getFilter($filters,true,true);
8452
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8453
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8451
+		$filter_query = $this->getFilter($filters, true, true);
8452
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8453
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8454 8454
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
8455 8455
                     GROUP BY spotter_output.arrival_airport_country
8456 8456
 					ORDER BY airport_arrival_country_count DESC";
@@ -8462,7 +8462,7 @@  discard block
 block discarded – undo
8462 8462
 		$airport_array = array();
8463 8463
 		$temp_array = array();
8464 8464
         
8465
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8465
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8466 8466
 		{
8467 8467
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8468 8468
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8481,9 +8481,9 @@  discard block
 block discarded – undo
8481 8481
 	*/
8482 8482
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8483 8483
 	{
8484
-		$filter_query = $this->getFilter($filters,true,true);
8485
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8486
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8484
+		$filter_query = $this->getFilter($filters, true, true);
8485
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8486
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8487 8487
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.owner_name = :owner 
8488 8488
                     GROUP BY spotter_output.arrival_airport_country
8489 8489
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8501,9 +8501,9 @@  discard block
 block discarded – undo
8501 8501
 	*/
8502 8502
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8503 8503
 	{
8504
-		$filter_query = $this->getFilter($filters,true,true);
8505
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8506
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8504
+		$filter_query = $this->getFilter($filters, true, true);
8505
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8506
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8507 8507
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8508 8508
                     GROUP BY spotter_output.arrival_airport_country
8509 8509
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8521,11 +8521,11 @@  discard block
 block discarded – undo
8521 8521
 	* @return Array the airport list
8522 8522
 	*
8523 8523
 	*/
8524
-	public function countAllArrivalAirportsByCountry($country,$filters = array())
8524
+	public function countAllArrivalAirportsByCountry($country, $filters = array())
8525 8525
 	{
8526
-		$filter_query = $this->getFilter($filters,true,true);
8527
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8528
-		$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 
8526
+		$filter_query = $this->getFilter($filters, true, true);
8527
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8528
+		$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 
8529 8529
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
8530 8530
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8531 8531
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8537,7 +8537,7 @@  discard block
 block discarded – undo
8537 8537
 		$airport_array = array();
8538 8538
 		$temp_array = array();
8539 8539
         
8540
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8540
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8541 8541
 		{
8542 8542
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8543 8543
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8558,12 +8558,12 @@  discard block
 block discarded – undo
8558 8558
 	* @return Array the airport list
8559 8559
 	*
8560 8560
 	*/
8561
-	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8561
+	public function countAllArrivalAirportCountriesByCountry($country, $filters = array())
8562 8562
 	{
8563 8563
 		global $globalDBdriver;
8564
-		$filter_query = $this->getFilter($filters,true,true);
8565
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8566
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8564
+		$filter_query = $this->getFilter($filters, true, true);
8565
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8566
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8567 8567
 			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 
8568 8568
                     GROUP BY spotter_output.arrival_airport_country
8569 8569
 					ORDER BY airport_arrival_country_count DESC";
@@ -8575,7 +8575,7 @@  discard block
 block discarded – undo
8575 8575
 		$airport_array = array();
8576 8576
 		$temp_array = array();
8577 8577
         
8578
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8578
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8579 8579
 		{
8580 8580
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8581 8581
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8594,38 +8594,38 @@  discard block
 block discarded – undo
8594 8594
 	* @return Array the airport departure list
8595 8595
 	*
8596 8596
 	*/
8597
-	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8597
+	public function countAllDepartureCountries($filters = array(), $year = '', $month = '', $day = '')
8598 8598
 	{
8599 8599
 		global $globalDBdriver;
8600
-		$filter_query = $this->getFilter($filters,true,true);
8601
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
8600
+		$filter_query = $this->getFilter($filters, true, true);
8601
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
8602 8602
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
8603 8603
 		$query_values = array();
8604 8604
 		if ($year != '') {
8605 8605
 			if ($globalDBdriver == 'mysql') {
8606 8606
 				$query .= " AND YEAR(spotter_output.date) = :year";
8607
-				$query_values = array_merge($query_values,array(':year' => $year));
8607
+				$query_values = array_merge($query_values, array(':year' => $year));
8608 8608
 			} else {
8609 8609
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8610
-				$query_values = array_merge($query_values,array(':year' => $year));
8610
+				$query_values = array_merge($query_values, array(':year' => $year));
8611 8611
 			}
8612 8612
 		}
8613 8613
 		if ($month != '') {
8614 8614
 			if ($globalDBdriver == 'mysql') {
8615 8615
 				$query .= " AND MONTH(spotter_output.date) = :month";
8616
-				$query_values = array_merge($query_values,array(':month' => $month));
8616
+				$query_values = array_merge($query_values, array(':month' => $month));
8617 8617
 			} else {
8618 8618
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8619
-				$query_values = array_merge($query_values,array(':month' => $month));
8619
+				$query_values = array_merge($query_values, array(':month' => $month));
8620 8620
 			}
8621 8621
 		}
8622 8622
 		if ($day != '') {
8623 8623
 			if ($globalDBdriver == 'mysql') {
8624 8624
 				$query .= " AND DAY(spotter_output.date) = :day";
8625
-				$query_values = array_merge($query_values,array(':day' => $day));
8625
+				$query_values = array_merge($query_values, array(':day' => $day));
8626 8626
 			} else {
8627 8627
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8628
-				$query_values = array_merge($query_values,array(':day' => $day));
8628
+				$query_values = array_merge($query_values, array(':day' => $day));
8629 8629
 			}
8630 8630
 		}
8631 8631
 		$query .= " GROUP BY spotter_output.departure_airport_country
@@ -8639,7 +8639,7 @@  discard block
 block discarded – undo
8639 8639
 		$airport_array = array();
8640 8640
 		$temp_array = array();
8641 8641
         
8642
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8642
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8643 8643
 		{
8644 8644
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
8645 8645
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -8657,38 +8657,38 @@  discard block
 block discarded – undo
8657 8657
 	* @return Array the airport arrival list
8658 8658
 	*
8659 8659
 	*/
8660
-	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8660
+	public function countAllArrivalCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
8661 8661
 	{
8662 8662
 		global $globalDBdriver;
8663
-		$filter_query = $this->getFilter($filters,true,true);
8664
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8663
+		$filter_query = $this->getFilter($filters, true, true);
8664
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8665 8665
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
8666 8666
 		$query_values = array();
8667 8667
 		if ($year != '') {
8668 8668
 			if ($globalDBdriver == 'mysql') {
8669 8669
 				$query .= " AND YEAR(spotter_output.date) = :year";
8670
-				$query_values = array_merge($query_values,array(':year' => $year));
8670
+				$query_values = array_merge($query_values, array(':year' => $year));
8671 8671
 			} else {
8672 8672
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8673
-				$query_values = array_merge($query_values,array(':year' => $year));
8673
+				$query_values = array_merge($query_values, array(':year' => $year));
8674 8674
 			}
8675 8675
 		}
8676 8676
 		if ($month != '') {
8677 8677
 			if ($globalDBdriver == 'mysql') {
8678 8678
 				$query .= " AND MONTH(spotter_output.date) = :month";
8679
-				$query_values = array_merge($query_values,array(':month' => $month));
8679
+				$query_values = array_merge($query_values, array(':month' => $month));
8680 8680
 			} else {
8681 8681
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8682
-				$query_values = array_merge($query_values,array(':month' => $month));
8682
+				$query_values = array_merge($query_values, array(':month' => $month));
8683 8683
 			}
8684 8684
 		}
8685 8685
 		if ($day != '') {
8686 8686
 			if ($globalDBdriver == 'mysql') {
8687 8687
 				$query .= " AND DAY(spotter_output.date) = :day";
8688
-				$query_values = array_merge($query_values,array(':day' => $day));
8688
+				$query_values = array_merge($query_values, array(':day' => $day));
8689 8689
 			} else {
8690 8690
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8691
-				$query_values = array_merge($query_values,array(':day' => $day));
8691
+				$query_values = array_merge($query_values, array(':day' => $day));
8692 8692
 			}
8693 8693
 		}
8694 8694
 		$query .= " GROUP BY spotter_output.arrival_airport_country
@@ -8702,7 +8702,7 @@  discard block
 block discarded – undo
8702 8702
 		$airport_array = array();
8703 8703
 		$temp_array = array();
8704 8704
         
8705
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8705
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8706 8706
 		{
8707 8707
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
8708 8708
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -8725,8 +8725,8 @@  discard block
 block discarded – undo
8725 8725
 	*/
8726 8726
 	public function countAllRoutes($filters = array())
8727 8727
 	{
8728
-		$filter_query = $this->getFilter($filters,true,true);
8729
-		$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
8728
+		$filter_query = $this->getFilter($filters, true, true);
8729
+		$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
8730 8730
 		    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 <> ''
8731 8731
                     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
8732 8732
                     ORDER BY route_count DESC
@@ -8739,7 +8739,7 @@  discard block
 block discarded – undo
8739 8739
 		$routes_array = array();
8740 8740
 		$temp_array = array();
8741 8741
         
8742
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8742
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8743 8743
 		{
8744 8744
 			$temp_array['route_count'] = $row['route_count'];
8745 8745
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8766,11 +8766,11 @@  discard block
 block discarded – undo
8766 8766
 	* @return Array the route list
8767 8767
 	*
8768 8768
 	*/
8769
-	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8769
+	public function countAllRoutesByAircraft($aircraft_icao, $filters = array())
8770 8770
 	{
8771
-		$filter_query = $this->getFilter($filters,true,true);
8772
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8773
-		$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
8771
+		$filter_query = $this->getFilter($filters, true, true);
8772
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8773
+		$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
8774 8774
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
8775 8775
 			    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 
8776 8776
 			    ORDER BY route_count DESC";
@@ -8781,7 +8781,7 @@  discard block
 block discarded – undo
8781 8781
 		$routes_array = array();
8782 8782
 		$temp_array = array();
8783 8783
         
8784
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8784
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8785 8785
 		{
8786 8786
 			$temp_array['route_count'] = $row['route_count'];
8787 8787
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8808,9 +8808,9 @@  discard block
 block discarded – undo
8808 8808
 	*/
8809 8809
 	public function countAllRoutesByRegistration($registration, $filters = array())
8810 8810
 	{
8811
-		$filter_query = $this->getFilter($filters,true,true);
8811
+		$filter_query = $this->getFilter($filters, true, true);
8812 8812
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8813
-		$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
8813
+		$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
8814 8814
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration 
8815 8815
                     GROUP BY route
8816 8816
                     ORDER BY route_count DESC";
@@ -8822,7 +8822,7 @@  discard block
 block discarded – undo
8822 8822
 		$routes_array = array();
8823 8823
 		$temp_array = array();
8824 8824
         
8825
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8825
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8826 8826
 		{
8827 8827
 			$temp_array['route_count'] = $row['route_count'];
8828 8828
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8850,9 +8850,9 @@  discard block
 block discarded – undo
8850 8850
 	*/
8851 8851
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8852 8852
 	{
8853
-		$filter_query = $this->getFilter($filters,true,true);
8854
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8855
-		$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
8853
+		$filter_query = $this->getFilter($filters, true, true);
8854
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8855
+		$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
8856 8856
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
8857 8857
 			    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 
8858 8858
 			    ORDER BY route_count DESC";
@@ -8864,7 +8864,7 @@  discard block
 block discarded – undo
8864 8864
 		$routes_array = array();
8865 8865
 		$temp_array = array();
8866 8866
         
8867
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8867
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8868 8868
 		{
8869 8869
 			$temp_array['route_count'] = $row['route_count'];
8870 8870
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8892,9 +8892,9 @@  discard block
 block discarded – undo
8892 8892
 	*/
8893 8893
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8894 8894
 	{
8895
-		$filter_query = $this->getFilter($filters,true,true);
8896
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8897
-		$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
8895
+		$filter_query = $this->getFilter($filters, true, true);
8896
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8897
+		$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
8898 8898
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8899 8899
 			    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 
8900 8900
 			    ORDER BY route_count DESC";
@@ -8905,7 +8905,7 @@  discard block
 block discarded – undo
8905 8905
 		$routes_array = array();
8906 8906
 		$temp_array = array();
8907 8907
         
8908
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8908
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8909 8909
 		{
8910 8910
 			$temp_array['route_count'] = $row['route_count'];
8911 8911
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8933,9 +8933,9 @@  discard block
 block discarded – undo
8933 8933
 	*/
8934 8934
 	public function countAllRoutesByCountry($country, $filters = array())
8935 8935
 	{
8936
-		$filter_query = $this->getFilter($filters,true,true);
8937
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8938
-		$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
8936
+		$filter_query = $this->getFilter($filters, true, true);
8937
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8938
+		$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
8939 8939
 			    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 
8940 8940
 			    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 
8941 8941
 			    ORDER BY route_count DESC";
@@ -8946,7 +8946,7 @@  discard block
 block discarded – undo
8946 8946
 		$routes_array = array();
8947 8947
 		$temp_array = array();
8948 8948
         
8949
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8949
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8950 8950
 		{
8951 8951
 			$temp_array['route_count'] = $row['route_count'];
8952 8952
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8974,8 +8974,8 @@  discard block
 block discarded – undo
8974 8974
 	public function countAllRoutesByDate($date, $filters = array())
8975 8975
 	{
8976 8976
 		global $globalTimezone, $globalDBdriver;
8977
-		$filter_query = $this->getFilter($filters,true,true);
8978
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8977
+		$filter_query = $this->getFilter($filters, true, true);
8978
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8979 8979
 		if ($globalTimezone != '') {
8980 8980
 			date_default_timezone_set($globalTimezone);
8981 8981
 			$datetime = new DateTime($date);
@@ -8983,12 +8983,12 @@  discard block
 block discarded – undo
8983 8983
 		} else $offset = '+00:00';
8984 8984
 		
8985 8985
 		if ($globalDBdriver == 'mysql') {
8986
-			$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
8986
+			$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
8987 8987
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
8988 8988
 				    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
8989 8989
 				    ORDER BY route_count DESC";
8990 8990
 		} else {
8991
-			$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
8991
+			$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
8992 8992
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
8993 8993
 				    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
8994 8994
 				    ORDER BY route_count DESC";
@@ -9000,7 +9000,7 @@  discard block
 block discarded – undo
9000 9000
 		$routes_array = array();
9001 9001
 		$temp_array = array();
9002 9002
         
9003
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9003
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9004 9004
 		{
9005 9005
 			$temp_array['route_count'] = $row['route_count'];
9006 9006
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9027,9 +9027,9 @@  discard block
 block discarded – undo
9027 9027
 	*/
9028 9028
 	public function countAllRoutesByIdent($ident, $filters = array())
9029 9029
 	{
9030
-		$filter_query = $this->getFilter($filters,true,true);
9031
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
9032
-		$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
9030
+		$filter_query = $this->getFilter($filters, true, true);
9031
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
9032
+		$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
9033 9033
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident   
9034 9034
                     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
9035 9035
                     ORDER BY route_count DESC";
@@ -9041,7 +9041,7 @@  discard block
 block discarded – undo
9041 9041
 		$routes_array = array();
9042 9042
 		$temp_array = array();
9043 9043
         
9044
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9044
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9045 9045
 		{
9046 9046
 			$temp_array['route_count'] = $row['route_count'];
9047 9047
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9065,11 +9065,11 @@  discard block
 block discarded – undo
9065 9065
 	* @return Array the route list
9066 9066
 	*
9067 9067
 	*/
9068
-	public function countAllRoutesByOwner($owner,$filters = array())
9068
+	public function countAllRoutesByOwner($owner, $filters = array())
9069 9069
 	{
9070
-		$filter_query = $this->getFilter($filters,true,true);
9071
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
9072
-		$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
9070
+		$filter_query = $this->getFilter($filters, true, true);
9071
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
9072
+		$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
9073 9073
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.owner_name = :owner 
9074 9074
                     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
9075 9075
                     ORDER BY route_count DESC";
@@ -9081,7 +9081,7 @@  discard block
 block discarded – undo
9081 9081
 		$routes_array = array();
9082 9082
 		$temp_array = array();
9083 9083
         
9084
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9084
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9085 9085
 		{
9086 9086
 			$temp_array['route_count'] = $row['route_count'];
9087 9087
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9105,11 +9105,11 @@  discard block
 block discarded – undo
9105 9105
 	* @return Array the route list
9106 9106
 	*
9107 9107
 	*/
9108
-	public function countAllRoutesByPilot($pilot,$filters = array())
9108
+	public function countAllRoutesByPilot($pilot, $filters = array())
9109 9109
 	{
9110
-		$filter_query = $this->getFilter($filters,true,true);
9111
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
9112
-		$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
9110
+		$filter_query = $this->getFilter($filters, true, true);
9111
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
9112
+		$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
9113 9113
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
9114 9114
                     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
9115 9115
                     ORDER BY route_count DESC";
@@ -9121,7 +9121,7 @@  discard block
 block discarded – undo
9121 9121
 		$routes_array = array();
9122 9122
 		$temp_array = array();
9123 9123
         
9124
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9124
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9125 9125
 		{
9126 9126
 			$temp_array['route_count'] = $row['route_count'];
9127 9127
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9148,9 +9148,9 @@  discard block
 block discarded – undo
9148 9148
 	*/
9149 9149
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9150 9150
 	{
9151
-		$filter_query = $this->getFilter($filters,true,true);
9152
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
9153
-		$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
9151
+		$filter_query = $this->getFilter($filters, true, true);
9152
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
9153
+		$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
9154 9154
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
9155 9155
                     GROUP BY route
9156 9156
                     ORDER BY route_count DESC";
@@ -9162,7 +9162,7 @@  discard block
 block discarded – undo
9162 9162
 		$routes_array = array();
9163 9163
 		$temp_array = array();
9164 9164
         
9165
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9165
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9166 9166
 		{
9167 9167
 			$temp_array['route_count'] = $row['route_count'];
9168 9168
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9190,8 +9190,8 @@  discard block
 block discarded – undo
9190 9190
 	*/
9191 9191
 	public function countAllRoutesWithWaypoints($filters = array())
9192 9192
 	{
9193
-		$filter_query = $this->getFilter($filters,true,true);
9194
-		$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
9193
+		$filter_query = $this->getFilter($filters, true, true);
9194
+		$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
9195 9195
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
9196 9196
                     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
9197 9197
                     ORDER BY route_count DESC
@@ -9204,7 +9204,7 @@  discard block
 block discarded – undo
9204 9204
 		$routes_array = array();
9205 9205
 		$temp_array = array();
9206 9206
         
9207
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9207
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9208 9208
 		{
9209 9209
 			$temp_array['spotter_id'] = $row['spotter_id'];
9210 9210
 			$temp_array['route_count'] = $row['route_count'];
@@ -9229,11 +9229,11 @@  discard block
 block discarded – undo
9229 9229
 	* @return Array the callsign list
9230 9230
 	*
9231 9231
 	*/
9232
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9232
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
9233 9233
 	{
9234 9234
 		global $globalDBdriver;
9235
-		$filter_query = $this->getFilter($filters,true,true);
9236
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9235
+		$filter_query = $this->getFilter($filters, true, true);
9236
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9237 9237
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9238 9238
 		 if ($olderthanmonths > 0) {
9239 9239
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -9247,28 +9247,28 @@  discard block
 block discarded – undo
9247 9247
 		if ($year != '') {
9248 9248
 			if ($globalDBdriver == 'mysql') {
9249 9249
 				$query .= " AND YEAR(spotter_output.date) = :year";
9250
-				$query_values = array_merge($query_values,array(':year' => $year));
9250
+				$query_values = array_merge($query_values, array(':year' => $year));
9251 9251
 			} else {
9252 9252
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
9253
-				$query_values = array_merge($query_values,array(':year' => $year));
9253
+				$query_values = array_merge($query_values, array(':year' => $year));
9254 9254
 			}
9255 9255
 		}
9256 9256
 		if ($month != '') {
9257 9257
 			if ($globalDBdriver == 'mysql') {
9258 9258
 				$query .= " AND MONTH(spotter_output.date) = :month";
9259
-				$query_values = array_merge($query_values,array(':month' => $month));
9259
+				$query_values = array_merge($query_values, array(':month' => $month));
9260 9260
 			} else {
9261 9261
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
9262
-				$query_values = array_merge($query_values,array(':month' => $month));
9262
+				$query_values = array_merge($query_values, array(':month' => $month));
9263 9263
 			}
9264 9264
 		}
9265 9265
 		if ($day != '') {
9266 9266
 			if ($globalDBdriver == 'mysql') {
9267 9267
 				$query .= " AND DAY(spotter_output.date) = :day";
9268
-				$query_values = array_merge($query_values,array(':day' => $day));
9268
+				$query_values = array_merge($query_values, array(':day' => $day));
9269 9269
 			} else {
9270 9270
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
9271
-				$query_values = array_merge($query_values,array(':day' => $day));
9271
+				$query_values = array_merge($query_values, array(':day' => $day));
9272 9272
 			}
9273 9273
 		}
9274 9274
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
@@ -9280,7 +9280,7 @@  discard block
 block discarded – undo
9280 9280
 		$callsign_array = array();
9281 9281
 		$temp_array = array();
9282 9282
         
9283
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9283
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9284 9284
 		{
9285 9285
 			$temp_array['callsign_icao'] = $row['ident'];
9286 9286
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9302,8 +9302,8 @@  discard block
 block discarded – undo
9302 9302
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9303 9303
 	{
9304 9304
 		global $globalDBdriver;
9305
-		$filter_query = $this->getFilter($filters,true,true);
9306
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9305
+		$filter_query = $this->getFilter($filters, true, true);
9306
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9307 9307
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9308 9308
 		 if ($olderthanmonths > 0) {
9309 9309
 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
@@ -9322,7 +9322,7 @@  discard block
 block discarded – undo
9322 9322
 		$callsign_array = array();
9323 9323
 		$temp_array = array();
9324 9324
         
9325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9326 9326
 		{
9327 9327
 			$temp_array['callsign_icao'] = $row['ident'];
9328 9328
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9376,7 +9376,7 @@  discard block
 block discarded – undo
9376 9376
 		$date_array = array();
9377 9377
 		$temp_array = array();
9378 9378
         
9379
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9379
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9380 9380
 		{
9381 9381
 			$temp_array['date_name'] = $row['date_name'];
9382 9382
 			$temp_array['date_count'] = $row['date_count'];
@@ -9401,15 +9401,15 @@  discard block
 block discarded – undo
9401 9401
 			$datetime = new DateTime();
9402 9402
 			$offset = $datetime->format('P');
9403 9403
 		} else $offset = '+00:00';
9404
-		$filter_query = $this->getFilter($filters,true,true);
9404
+		$filter_query = $this->getFilter($filters, true, true);
9405 9405
 		if ($globalDBdriver == 'mysql') {
9406
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9406
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9407 9407
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9408 9408
 								GROUP BY spotter_output.airline_icao, date_name 
9409 9409
 								ORDER BY date_count DESC
9410 9410
 								LIMIT 10 OFFSET 0";
9411 9411
 		} else {
9412
-			$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
9412
+			$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
9413 9413
 								FROM spotter_output 
9414 9414
 								WHERE spotter_output.airline_icao <> '' 
9415 9415
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -9424,7 +9424,7 @@  discard block
 block discarded – undo
9424 9424
 		$date_array = array();
9425 9425
 		$temp_array = array();
9426 9426
         
9427
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9427
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9428 9428
 		{
9429 9429
 			$temp_array['date_name'] = $row['date_name'];
9430 9430
 			$temp_array['date_count'] = $row['date_count'];
@@ -9450,7 +9450,7 @@  discard block
 block discarded – undo
9450 9450
 			$datetime = new DateTime();
9451 9451
 			$offset = $datetime->format('P');
9452 9452
 		} else $offset = '+00:00';
9453
-		$filter_query = $this->getFilter($filters,true,true);
9453
+		$filter_query = $this->getFilter($filters, true, true);
9454 9454
 		if ($globalDBdriver == 'mysql') {
9455 9455
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9456 9456
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -9471,7 +9471,7 @@  discard block
 block discarded – undo
9471 9471
 		$date_array = array();
9472 9472
 		$temp_array = array();
9473 9473
         
9474
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9474
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9475 9475
 		{
9476 9476
 			$temp_array['date_name'] = $row['date_name'];
9477 9477
 			$temp_array['date_count'] = $row['date_count'];
@@ -9496,7 +9496,7 @@  discard block
 block discarded – undo
9496 9496
 			$datetime = new DateTime();
9497 9497
 			$offset = $datetime->format('P');
9498 9498
 		} else $offset = '+00:00';
9499
-		$filter_query = $this->getFilter($filters,true,true);
9499
+		$filter_query = $this->getFilter($filters, true, true);
9500 9500
 		if ($globalDBdriver == 'mysql') {
9501 9501
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9502 9502
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -9517,7 +9517,7 @@  discard block
 block discarded – undo
9517 9517
 		$date_array = array();
9518 9518
 		$temp_array = array();
9519 9519
         
9520
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9520
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9521 9521
 		{
9522 9522
 			$temp_array['date_name'] = $row['date_name'];
9523 9523
 			$temp_array['date_count'] = $row['date_count'];
@@ -9538,7 +9538,7 @@  discard block
 block discarded – undo
9538 9538
 	public function countAllDatesLastMonthByAirlines($filters = array())
9539 9539
 	{
9540 9540
 		global $globalTimezone, $globalDBdriver;
9541
-		$filter_query = $this->getFilter($filters,true,true);
9541
+		$filter_query = $this->getFilter($filters, true, true);
9542 9542
 		if ($globalTimezone != '') {
9543 9543
 			date_default_timezone_set($globalTimezone);
9544 9544
 			$datetime = new DateTime();
@@ -9546,13 +9546,13 @@  discard block
 block discarded – undo
9546 9546
 		} else $offset = '+00:00';
9547 9547
 		
9548 9548
 		if ($globalDBdriver == 'mysql') {
9549
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9549
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9550 9550
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
9551 9551
 								GROUP BY spotter_output.airline_icao, date_name 
9552 9552
 								ORDER BY spotter_output.date ASC";
9553 9553
 			$query_data = array(':offset' => $offset);
9554 9554
 		} else {
9555
-			$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
9555
+			$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
9556 9556
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
9557 9557
 								GROUP BY spotter_output.airline_icao, date_name 
9558 9558
 								ORDER BY date_name ASC";
@@ -9565,7 +9565,7 @@  discard block
 block discarded – undo
9565 9565
 		$date_array = array();
9566 9566
 		$temp_array = array();
9567 9567
         
9568
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9568
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9569 9569
 		{
9570 9570
 			$temp_array['date_name'] = $row['date_name'];
9571 9571
 			$temp_array['date_count'] = $row['date_count'];
@@ -9612,7 +9612,7 @@  discard block
 block discarded – undo
9612 9612
 		$date_array = array();
9613 9613
 		$temp_array = array();
9614 9614
         
9615
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9615
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9616 9616
 		{
9617 9617
 			$temp_array['month_name'] = $row['month_name'];
9618 9618
 			$temp_array['year_name'] = $row['year_name'];
@@ -9633,7 +9633,7 @@  discard block
 block discarded – undo
9633 9633
 	public function countAllMonthsByAirlines($filters = array())
9634 9634
 	{
9635 9635
 		global $globalTimezone, $globalDBdriver;
9636
-		$filter_query = $this->getFilter($filters,true,true);
9636
+		$filter_query = $this->getFilter($filters, true, true);
9637 9637
 		if ($globalTimezone != '') {
9638 9638
 			date_default_timezone_set($globalTimezone);
9639 9639
 			$datetime = new DateTime();
@@ -9641,12 +9641,12 @@  discard block
 block discarded – undo
9641 9641
 		} else $offset = '+00:00';
9642 9642
 
9643 9643
 		if ($globalDBdriver == 'mysql') {
9644
-			$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
9644
+			$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
9645 9645
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9646 9646
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
9647 9647
 								ORDER BY date_count DESC";
9648 9648
 		} else {
9649
-			$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
9649
+			$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
9650 9650
 								FROM spotter_output 
9651 9651
 								WHERE spotter_output.airline_icao <> '' 
9652 9652
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -9660,7 +9660,7 @@  discard block
 block discarded – undo
9660 9660
 		$date_array = array();
9661 9661
 		$temp_array = array();
9662 9662
         
9663
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9663
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9664 9664
 		{
9665 9665
 			$temp_array['month_name'] = $row['month_name'];
9666 9666
 			$temp_array['year_name'] = $row['year_name'];
@@ -9687,14 +9687,14 @@  discard block
 block discarded – undo
9687 9687
 			$datetime = new DateTime();
9688 9688
 			$offset = $datetime->format('P');
9689 9689
 		} else $offset = '+00:00';
9690
-		$filter_query = $this->getFilter($filters,true,true);
9690
+		$filter_query = $this->getFilter($filters, true, true);
9691 9691
 		if ($globalDBdriver == 'mysql') {
9692
-			$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
9692
+			$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
9693 9693
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9694 9694
 								GROUP BY year_name, month_name 
9695 9695
 								ORDER BY date_count DESC";
9696 9696
 		} else {
9697
-			$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
9697
+			$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
9698 9698
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9699 9699
 								GROUP BY year_name, month_name 
9700 9700
 								ORDER BY date_count DESC";
@@ -9706,7 +9706,7 @@  discard block
 block discarded – undo
9706 9706
 		$date_array = array();
9707 9707
 		$temp_array = array();
9708 9708
         
9709
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9709
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9710 9710
 		{
9711 9711
 			$temp_array['month_name'] = $row['month_name'];
9712 9712
 			$temp_array['year_name'] = $row['year_name'];
@@ -9732,15 +9732,15 @@  discard block
 block discarded – undo
9732 9732
 			$datetime = new DateTime();
9733 9733
 			$offset = $datetime->format('P');
9734 9734
 		} else $offset = '+00:00';
9735
-		$filter_query = $this->getFilter($filters,true,true);
9735
+		$filter_query = $this->getFilter($filters, true, true);
9736 9736
 
9737 9737
 		if ($globalDBdriver == 'mysql') {
9738
-			$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
9738
+			$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
9739 9739
 								FROM spotter_output".$filter_query." owner_name <> ''
9740 9740
 								GROUP BY year_name, month_name
9741 9741
 								ORDER BY date_count DESC";
9742 9742
 		} else {
9743
-			$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
9743
+			$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
9744 9744
 								FROM spotter_output".$filter_query." owner_name <> ''
9745 9745
 								GROUP BY year_name, month_name
9746 9746
 								ORDER BY date_count DESC";
@@ -9752,7 +9752,7 @@  discard block
 block discarded – undo
9752 9752
 		$date_array = array();
9753 9753
 		$temp_array = array();
9754 9754
         
9755
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9755
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9756 9756
 		{
9757 9757
 			$temp_array['month_name'] = $row['month_name'];
9758 9758
 			$temp_array['year_name'] = $row['year_name'];
@@ -9773,7 +9773,7 @@  discard block
 block discarded – undo
9773 9773
 	public function countAllMonthsOwnersByAirlines($filters = array())
9774 9774
 	{
9775 9775
 		global $globalTimezone, $globalDBdriver;
9776
-		$filter_query = $this->getFilter($filters,true,true);
9776
+		$filter_query = $this->getFilter($filters, true, true);
9777 9777
 		if ($globalTimezone != '') {
9778 9778
 			date_default_timezone_set($globalTimezone);
9779 9779
 			$datetime = new DateTime();
@@ -9781,12 +9781,12 @@  discard block
 block discarded – undo
9781 9781
 		} else $offset = '+00:00';
9782 9782
 
9783 9783
 		if ($globalDBdriver == 'mysql') {
9784
-			$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
9784
+			$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
9785 9785
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9786 9786
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9787 9787
 								ORDER BY date_count DESC";
9788 9788
 		} else {
9789
-			$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
9789
+			$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
9790 9790
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9791 9791
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9792 9792
 								ORDER BY date_count DESC";
@@ -9798,7 +9798,7 @@  discard block
 block discarded – undo
9798 9798
 		$date_array = array();
9799 9799
 		$temp_array = array();
9800 9800
         
9801
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9801
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9802 9802
 		{
9803 9803
 			$temp_array['month_name'] = $row['month_name'];
9804 9804
 			$temp_array['year_name'] = $row['year_name'];
@@ -9825,15 +9825,15 @@  discard block
 block discarded – undo
9825 9825
 			$datetime = new DateTime();
9826 9826
 			$offset = $datetime->format('P');
9827 9827
 		} else $offset = '+00:00';
9828
-		$filter_query = $this->getFilter($filters,true,true);
9828
+		$filter_query = $this->getFilter($filters, true, true);
9829 9829
 
9830 9830
 		if ($globalDBdriver == 'mysql') {
9831
-			$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
9831
+			$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
9832 9832
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9833 9833
 								GROUP BY year_name, month_name
9834 9834
 								ORDER BY date_count DESC";
9835 9835
 		} else {
9836
-			$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
9836
+			$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
9837 9837
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9838 9838
 								GROUP BY year_name, month_name
9839 9839
 								ORDER BY date_count DESC";
@@ -9845,7 +9845,7 @@  discard block
 block discarded – undo
9845 9845
 		$date_array = array();
9846 9846
 		$temp_array = array();
9847 9847
         
9848
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9848
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9849 9849
 		{
9850 9850
 			$temp_array['month_name'] = $row['month_name'];
9851 9851
 			$temp_array['year_name'] = $row['year_name'];
@@ -9866,7 +9866,7 @@  discard block
 block discarded – undo
9866 9866
 	public function countAllMonthsPilotsByAirlines($filters = array())
9867 9867
 	{
9868 9868
 		global $globalTimezone, $globalDBdriver;
9869
-		$filter_query = $this->getFilter($filters,true,true);
9869
+		$filter_query = $this->getFilter($filters, true, true);
9870 9870
 		if ($globalTimezone != '') {
9871 9871
 			date_default_timezone_set($globalTimezone);
9872 9872
 			$datetime = new DateTime();
@@ -9874,12 +9874,12 @@  discard block
 block discarded – undo
9874 9874
 		} else $offset = '+00:00';
9875 9875
 
9876 9876
 		if ($globalDBdriver == 'mysql') {
9877
-			$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
9877
+			$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
9878 9878
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9879 9879
 								GROUP BY spotter_output.airline_icao,year_name, month_name
9880 9880
 								ORDER BY date_count DESC";
9881 9881
 		} else {
9882
-			$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
9882
+			$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
9883 9883
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9884 9884
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9885 9885
 								ORDER BY date_count DESC";
@@ -9891,7 +9891,7 @@  discard block
 block discarded – undo
9891 9891
 		$date_array = array();
9892 9892
 		$temp_array = array();
9893 9893
         
9894
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9894
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9895 9895
 		{
9896 9896
 			$temp_array['month_name'] = $row['month_name'];
9897 9897
 			$temp_array['year_name'] = $row['year_name'];
@@ -9913,7 +9913,7 @@  discard block
 block discarded – undo
9913 9913
 	public function countAllMonthsAirlines($filters = array())
9914 9914
 	{
9915 9915
 		global $globalTimezone, $globalDBdriver;
9916
-		$filter_query = $this->getFilter($filters,true,true);
9916
+		$filter_query = $this->getFilter($filters, true, true);
9917 9917
 		if ($globalTimezone != '') {
9918 9918
 			date_default_timezone_set($globalTimezone);
9919 9919
 			$datetime = new DateTime();
@@ -9921,12 +9921,12 @@  discard block
 block discarded – undo
9921 9921
 		} else $offset = '+00:00';
9922 9922
 
9923 9923
 		if ($globalDBdriver == 'mysql') {
9924
-			$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
9924
+			$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
9925 9925
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9926 9926
 								GROUP BY year_name, month_name
9927 9927
 								ORDER BY date_count DESC";
9928 9928
 		} else {
9929
-			$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
9929
+			$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
9930 9930
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9931 9931
 								GROUP BY year_name, month_name
9932 9932
 								ORDER BY date_count DESC";
@@ -9938,7 +9938,7 @@  discard block
 block discarded – undo
9938 9938
 		$date_array = array();
9939 9939
 		$temp_array = array();
9940 9940
         
9941
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9941
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9942 9942
 		{
9943 9943
 			$temp_array['month_name'] = $row['month_name'];
9944 9944
 			$temp_array['year_name'] = $row['year_name'];
@@ -9964,15 +9964,15 @@  discard block
 block discarded – undo
9964 9964
 			$datetime = new DateTime();
9965 9965
 			$offset = $datetime->format('P');
9966 9966
 		} else $offset = '+00:00';
9967
-		$filter_query = $this->getFilter($filters,true,true);
9967
+		$filter_query = $this->getFilter($filters, true, true);
9968 9968
 
9969 9969
 		if ($globalDBdriver == 'mysql') {
9970
-			$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
9970
+			$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
9971 9971
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9972 9972
 								GROUP BY year_name, month_name
9973 9973
 								ORDER BY date_count DESC";
9974 9974
 		} else {
9975
-			$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
9975
+			$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
9976 9976
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9977 9977
 								GROUP BY year_name, month_name
9978 9978
 								ORDER BY date_count DESC";
@@ -9984,7 +9984,7 @@  discard block
 block discarded – undo
9984 9984
 		$date_array = array();
9985 9985
 		$temp_array = array();
9986 9986
         
9987
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9987
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9988 9988
 		{
9989 9989
 			$temp_array['month_name'] = $row['month_name'];
9990 9990
 			$temp_array['year_name'] = $row['year_name'];
@@ -10006,7 +10006,7 @@  discard block
 block discarded – undo
10006 10006
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10007 10007
 	{
10008 10008
 		global $globalTimezone, $globalDBdriver;
10009
-		$filter_query = $this->getFilter($filters,true,true);
10009
+		$filter_query = $this->getFilter($filters, true, true);
10010 10010
 		if ($globalTimezone != '') {
10011 10011
 			date_default_timezone_set($globalTimezone);
10012 10012
 			$datetime = new DateTime();
@@ -10014,12 +10014,12 @@  discard block
 block discarded – undo
10014 10014
 		} else $offset = '+00:00';
10015 10015
 
10016 10016
 		if ($globalDBdriver == 'mysql') {
10017
-			$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
10017
+			$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
10018 10018
 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
10019 10019
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10020 10020
 								ORDER BY date_count DESC";
10021 10021
 		} else {
10022
-			$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
10022
+			$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
10023 10023
 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
10024 10024
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10025 10025
 								ORDER BY date_count DESC";
@@ -10031,7 +10031,7 @@  discard block
 block discarded – undo
10031 10031
 		$date_array = array();
10032 10032
 		$temp_array = array();
10033 10033
         
10034
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10034
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10035 10035
 		{
10036 10036
 			$temp_array['month_name'] = $row['month_name'];
10037 10037
 			$temp_array['year_name'] = $row['year_name'];
@@ -10058,15 +10058,15 @@  discard block
 block discarded – undo
10058 10058
 			$datetime = new DateTime();
10059 10059
 			$offset = $datetime->format('P');
10060 10060
 		} else $offset = '+00:00';
10061
-		$filter_query = $this->getFilter($filters,true,true);
10061
+		$filter_query = $this->getFilter($filters, true, true);
10062 10062
 
10063 10063
 		if ($globalDBdriver == 'mysql') {
10064
-			$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
10064
+			$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
10065 10065
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10066 10066
 								GROUP BY year_name, month_name
10067 10067
 								ORDER BY date_count DESC";
10068 10068
 		} else {
10069
-			$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
10069
+			$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
10070 10070
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10071 10071
 								GROUP BY year_name, month_name
10072 10072
 								ORDER BY date_count DESC";
@@ -10078,7 +10078,7 @@  discard block
 block discarded – undo
10078 10078
 		$date_array = array();
10079 10079
 		$temp_array = array();
10080 10080
         
10081
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10081
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10082 10082
 		{
10083 10083
 			$temp_array['month_name'] = $row['month_name'];
10084 10084
 			$temp_array['year_name'] = $row['year_name'];
@@ -10100,7 +10100,7 @@  discard block
 block discarded – undo
10100 10100
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10101 10101
 	{
10102 10102
 		global $globalTimezone, $globalDBdriver;
10103
-		$filter_query = $this->getFilter($filters,true,true);
10103
+		$filter_query = $this->getFilter($filters, true, true);
10104 10104
 		if ($globalTimezone != '') {
10105 10105
 			date_default_timezone_set($globalTimezone);
10106 10106
 			$datetime = new DateTime();
@@ -10108,12 +10108,12 @@  discard block
 block discarded – undo
10108 10108
 		} else $offset = '+00:00';
10109 10109
 
10110 10110
 		if ($globalDBdriver == 'mysql') {
10111
-			$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
10111
+			$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
10112 10112
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10113 10113
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10114 10114
 								ORDER BY date_count DESC";
10115 10115
 		} else {
10116
-			$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
10116
+			$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
10117 10117
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10118 10118
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10119 10119
 								ORDER BY date_count DESC";
@@ -10125,7 +10125,7 @@  discard block
 block discarded – undo
10125 10125
 		$date_array = array();
10126 10126
 		$temp_array = array();
10127 10127
         
10128
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10128
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10129 10129
 		{
10130 10130
 			$temp_array['month_name'] = $row['month_name'];
10131 10131
 			$temp_array['year_name'] = $row['year_name'];
@@ -10153,7 +10153,7 @@  discard block
 block discarded – undo
10153 10153
 			$datetime = new DateTime();
10154 10154
 			$offset = $datetime->format('P');
10155 10155
 		} else $offset = '+00:00';
10156
-		$filter_query = $this->getFilter($filters,true,true);
10156
+		$filter_query = $this->getFilter($filters, true, true);
10157 10157
 		if ($globalDBdriver == 'mysql') {
10158 10158
 			$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
10159 10159
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -10174,7 +10174,7 @@  discard block
 block discarded – undo
10174 10174
 		$date_array = array();
10175 10175
 		$temp_array = array();
10176 10176
         
10177
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10177
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10178 10178
 		{
10179 10179
 			$temp_array['year_name'] = $row['year_name'];
10180 10180
 			$temp_array['month_name'] = $row['month_name'];
@@ -10194,7 +10194,7 @@  discard block
 block discarded – undo
10194 10194
 	* @return Array the hour list
10195 10195
 	*
10196 10196
 	*/
10197
-	public function countAllHours($orderby,$filters = array())
10197
+	public function countAllHours($orderby, $filters = array())
10198 10198
 	{
10199 10199
 		global $globalTimezone, $globalDBdriver;
10200 10200
 		if ($globalTimezone != '') {
@@ -10242,7 +10242,7 @@  discard block
 block discarded – undo
10242 10242
 		$hour_array = array();
10243 10243
 		$temp_array = array();
10244 10244
         
10245
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10245
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10246 10246
 		{
10247 10247
 			$temp_array['hour_name'] = $row['hour_name'];
10248 10248
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10262,7 +10262,7 @@  discard block
 block discarded – undo
10262 10262
 	public function countAllHoursByAirlines($orderby, $filters = array())
10263 10263
 	{
10264 10264
 		global $globalTimezone, $globalDBdriver;
10265
-		$filter_query = $this->getFilter($filters,true,true);
10265
+		$filter_query = $this->getFilter($filters, true, true);
10266 10266
 		if ($globalTimezone != '') {
10267 10267
 			date_default_timezone_set($globalTimezone);
10268 10268
 			$datetime = new DateTime();
@@ -10280,7 +10280,7 @@  discard block
 block discarded – undo
10280 10280
 		}
10281 10281
 		
10282 10282
 		if ($globalDBdriver == 'mysql') {
10283
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10283
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10284 10284
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10285 10285
 								GROUP BY spotter_output.airline_icao, hour_name 
10286 10286
 								".$orderby_sql;
@@ -10293,7 +10293,7 @@  discard block
 block discarded – undo
10293 10293
   */    
10294 10294
 		$query_data = array(':offset' => $offset);
10295 10295
 		} else {
10296
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10296
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10297 10297
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10298 10298
 								GROUP BY spotter_output.airline_icao, hour_name 
10299 10299
 								".$orderby_sql;
@@ -10306,7 +10306,7 @@  discard block
 block discarded – undo
10306 10306
 		$hour_array = array();
10307 10307
 		$temp_array = array();
10308 10308
         
10309
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10309
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10310 10310
 		{
10311 10311
 			$temp_array['hour_name'] = $row['hour_name'];
10312 10312
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10329,34 +10329,34 @@  discard block
 block discarded – undo
10329 10329
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10330 10330
 	{
10331 10331
 		global $globalTimezone, $globalDBdriver;
10332
-		$filter_query = $this->getFilter($filters,true,true);
10332
+		$filter_query = $this->getFilter($filters, true, true);
10333 10333
 		if ($globalTimezone != '') {
10334 10334
 			date_default_timezone_set($globalTimezone);
10335 10335
 			$datetime = new DateTime();
10336 10336
 			$offset = $datetime->format('P');
10337 10337
 		} else $offset = '+00:00';
10338 10338
 
10339
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10339
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
10340 10340
 
10341 10341
 		if ($globalDBdriver == 'mysql') {
10342
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10342
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10343 10343
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10344 10344
 								GROUP BY hour_name 
10345 10345
 								ORDER BY hour_name ASC";
10346 10346
 		} else {
10347
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10347
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10348 10348
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10349 10349
 								GROUP BY hour_name 
10350 10350
 								ORDER BY hour_name ASC";
10351 10351
 		}
10352 10352
 		
10353 10353
 		$sth = $this->db->prepare($query);
10354
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
10354
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
10355 10355
       
10356 10356
 		$hour_array = array();
10357 10357
 		$temp_array = array();
10358 10358
         
10359
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10359
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10360 10360
 		{
10361 10361
 			$temp_array['hour_name'] = $row['hour_name'];
10362 10362
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10379,8 +10379,8 @@  discard block
 block discarded – undo
10379 10379
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10380 10380
 	{
10381 10381
 		global $globalTimezone, $globalDBdriver;
10382
-		$filter_query = $this->getFilter($filters,true,true);
10383
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
10382
+		$filter_query = $this->getFilter($filters, true, true);
10383
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
10384 10384
 		if ($globalTimezone != '') {
10385 10385
 			date_default_timezone_set($globalTimezone);
10386 10386
 			$datetime = new DateTime();
@@ -10388,24 +10388,24 @@  discard block
 block discarded – undo
10388 10388
 		} else $offset = '+00:00';
10389 10389
 
10390 10390
 		if ($globalDBdriver == 'mysql') {
10391
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10391
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10392 10392
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10393 10393
 								GROUP BY hour_name 
10394 10394
 								ORDER BY hour_name ASC";
10395 10395
 		} else {
10396
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10396
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10397 10397
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10398 10398
 								GROUP BY hour_name 
10399 10399
 								ORDER BY hour_name ASC";
10400 10400
 		}
10401 10401
 		
10402 10402
 		$sth = $this->db->prepare($query);
10403
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
10403
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
10404 10404
       
10405 10405
 		$hour_array = array();
10406 10406
 		$temp_array = array();
10407 10407
         
10408
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10408
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10409 10409
 		{
10410 10410
 			$temp_array['hour_name'] = $row['hour_name'];
10411 10411
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10426,8 +10426,8 @@  discard block
 block discarded – undo
10426 10426
 	public function countAllHoursByRegistration($registration, $filters = array())
10427 10427
 	{
10428 10428
 		global $globalTimezone, $globalDBdriver;
10429
-		$filter_query = $this->getFilter($filters,true,true);
10430
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
10429
+		$filter_query = $this->getFilter($filters, true, true);
10430
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
10431 10431
 		if ($globalTimezone != '') {
10432 10432
 			date_default_timezone_set($globalTimezone);
10433 10433
 			$datetime = new DateTime();
@@ -10435,24 +10435,24 @@  discard block
 block discarded – undo
10435 10435
 		} else $offset = '+00:00';
10436 10436
 
10437 10437
 		if ($globalDBdriver == 'mysql') {
10438
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10438
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10439 10439
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10440 10440
 								GROUP BY hour_name 
10441 10441
 								ORDER BY hour_name ASC";
10442 10442
 		} else {
10443
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10443
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10444 10444
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10445 10445
 								GROUP BY hour_name 
10446 10446
 								ORDER BY hour_name ASC";
10447 10447
 		}
10448 10448
 		
10449 10449
 		$sth = $this->db->prepare($query);
10450
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
10450
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
10451 10451
       
10452 10452
 		$hour_array = array();
10453 10453
 		$temp_array = array();
10454 10454
         
10455
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10455
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10456 10456
 		{
10457 10457
 			$temp_array['hour_name'] = $row['hour_name'];
10458 10458
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10473,8 +10473,8 @@  discard block
 block discarded – undo
10473 10473
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10474 10474
 	{
10475 10475
 		global $globalTimezone, $globalDBdriver;
10476
-		$filter_query = $this->getFilter($filters,true,true);
10477
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
10476
+		$filter_query = $this->getFilter($filters, true, true);
10477
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
10478 10478
 		if ($globalTimezone != '') {
10479 10479
 			date_default_timezone_set($globalTimezone);
10480 10480
 			$datetime = new DateTime();
@@ -10482,24 +10482,24 @@  discard block
 block discarded – undo
10482 10482
 		} else $offset = '+00:00';
10483 10483
 
10484 10484
 		if ($globalDBdriver == 'mysql') {
10485
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10485
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10486 10486
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10487 10487
 								GROUP BY hour_name 
10488 10488
 								ORDER BY hour_name ASC";
10489 10489
 		} else {
10490
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10490
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10491 10491
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10492 10492
 								GROUP BY hour_name 
10493 10493
 								ORDER BY hour_name ASC";
10494 10494
 		}
10495 10495
 		
10496 10496
 		$sth = $this->db->prepare($query);
10497
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
10497
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
10498 10498
       
10499 10499
 		$hour_array = array();
10500 10500
 		$temp_array = array();
10501 10501
         
10502
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10502
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10503 10503
 		{
10504 10504
 			$temp_array['hour_name'] = $row['hour_name'];
10505 10505
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10518,11 +10518,11 @@  discard block
 block discarded – undo
10518 10518
 	* @return Array the hour list
10519 10519
 	*
10520 10520
 	*/
10521
-	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10521
+	public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array())
10522 10522
 	{
10523 10523
 		global $globalTimezone, $globalDBdriver;
10524
-		$filter_query = $this->getFilter($filters,true,true);
10525
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
10524
+		$filter_query = $this->getFilter($filters, true, true);
10525
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
10526 10526
 		if ($globalTimezone != '') {
10527 10527
 			date_default_timezone_set($globalTimezone);
10528 10528
 			$datetime = new DateTime();
@@ -10530,24 +10530,24 @@  discard block
 block discarded – undo
10530 10530
 		} else $offset = '+00:00';
10531 10531
 
10532 10532
 		if ($globalDBdriver == 'mysql') {
10533
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10533
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10534 10534
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10535 10535
 								GROUP BY hour_name 
10536 10536
 								ORDER BY hour_name ASC";
10537 10537
 		} else {
10538
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10538
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10539 10539
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10540 10540
 								GROUP BY hour_name 
10541 10541
 								ORDER BY hour_name ASC";
10542 10542
 		}
10543 10543
 		
10544 10544
 		$sth = $this->db->prepare($query);
10545
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
10545
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
10546 10546
       
10547 10547
 		$hour_array = array();
10548 10548
 		$temp_array = array();
10549 10549
         
10550
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10550
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10551 10551
 		{
10552 10552
 			$temp_array['hour_name'] = $row['hour_name'];
10553 10553
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10569,8 +10569,8 @@  discard block
 block discarded – undo
10569 10569
 	public function countAllHoursByDate($date, $filters = array())
10570 10570
 	{
10571 10571
 		global $globalTimezone, $globalDBdriver;
10572
-		$filter_query = $this->getFilter($filters,true,true);
10573
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
10572
+		$filter_query = $this->getFilter($filters, true, true);
10573
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
10574 10574
 		if ($globalTimezone != '') {
10575 10575
 			date_default_timezone_set($globalTimezone);
10576 10576
 			$datetime = new DateTime($date);
@@ -10578,12 +10578,12 @@  discard block
 block discarded – undo
10578 10578
 		} else $offset = '+00:00';
10579 10579
 
10580 10580
 		if ($globalDBdriver == 'mysql') {
10581
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10581
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10582 10582
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
10583 10583
 								GROUP BY hour_name 
10584 10584
 								ORDER BY hour_name ASC";
10585 10585
 		} else {
10586
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10586
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10587 10587
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
10588 10588
 								GROUP BY hour_name 
10589 10589
 								ORDER BY hour_name ASC";
@@ -10595,7 +10595,7 @@  discard block
 block discarded – undo
10595 10595
 		$hour_array = array();
10596 10596
 		$temp_array = array();
10597 10597
         
10598
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10598
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10599 10599
 		{
10600 10600
 			$temp_array['hour_name'] = $row['hour_name'];
10601 10601
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10617,8 +10617,8 @@  discard block
 block discarded – undo
10617 10617
 	public function countAllHoursByIdent($ident, $filters = array())
10618 10618
 	{
10619 10619
 		global $globalTimezone, $globalDBdriver;
10620
-		$filter_query = $this->getFilter($filters,true,true);
10621
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
10620
+		$filter_query = $this->getFilter($filters, true, true);
10621
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
10622 10622
 		if ($globalTimezone != '') {
10623 10623
 			date_default_timezone_set($globalTimezone);
10624 10624
 			$datetime = new DateTime();
@@ -10626,12 +10626,12 @@  discard block
 block discarded – undo
10626 10626
 		} else $offset = '+00:00';
10627 10627
 
10628 10628
 		if ($globalDBdriver == 'mysql') {
10629
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10629
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10630 10630
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10631 10631
 								GROUP BY hour_name 
10632 10632
 								ORDER BY hour_name ASC";
10633 10633
 		} else {
10634
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10634
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10635 10635
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10636 10636
 								GROUP BY hour_name 
10637 10637
 								ORDER BY hour_name ASC";
@@ -10639,12 +10639,12 @@  discard block
 block discarded – undo
10639 10639
       
10640 10640
 		
10641 10641
 		$sth = $this->db->prepare($query);
10642
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
10642
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
10643 10643
       
10644 10644
 		$hour_array = array();
10645 10645
 		$temp_array = array();
10646 10646
         
10647
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10647
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10648 10648
 		{
10649 10649
 			$temp_array['hour_name'] = $row['hour_name'];
10650 10650
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10664,8 +10664,8 @@  discard block
 block discarded – undo
10664 10664
 	public function countAllHoursByOwner($owner, $filters = array())
10665 10665
 	{
10666 10666
 		global $globalTimezone, $globalDBdriver;
10667
-		$filter_query = $this->getFilter($filters,true,true);
10668
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
10667
+		$filter_query = $this->getFilter($filters, true, true);
10668
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
10669 10669
 		if ($globalTimezone != '') {
10670 10670
 			date_default_timezone_set($globalTimezone);
10671 10671
 			$datetime = new DateTime();
@@ -10673,12 +10673,12 @@  discard block
 block discarded – undo
10673 10673
 		} else $offset = '+00:00';
10674 10674
 
10675 10675
 		if ($globalDBdriver == 'mysql') {
10676
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10676
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10677 10677
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10678 10678
 								GROUP BY hour_name 
10679 10679
 								ORDER BY hour_name ASC";
10680 10680
 		} else {
10681
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10681
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10682 10682
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10683 10683
 								GROUP BY hour_name 
10684 10684
 								ORDER BY hour_name ASC";
@@ -10686,12 +10686,12 @@  discard block
 block discarded – undo
10686 10686
       
10687 10687
 		
10688 10688
 		$sth = $this->db->prepare($query);
10689
-		$sth->execute(array(':owner' => $owner,':offset' => $offset));
10689
+		$sth->execute(array(':owner' => $owner, ':offset' => $offset));
10690 10690
       
10691 10691
 		$hour_array = array();
10692 10692
 		$temp_array = array();
10693 10693
         
10694
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10694
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10695 10695
 		{
10696 10696
 			$temp_array['hour_name'] = $row['hour_name'];
10697 10697
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10711,8 +10711,8 @@  discard block
 block discarded – undo
10711 10711
 	public function countAllHoursByPilot($pilot, $filters = array())
10712 10712
 	{
10713 10713
 		global $globalTimezone, $globalDBdriver;
10714
-		$filter_query = $this->getFilter($filters,true,true);
10715
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
10714
+		$filter_query = $this->getFilter($filters, true, true);
10715
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
10716 10716
 		if ($globalTimezone != '') {
10717 10717
 			date_default_timezone_set($globalTimezone);
10718 10718
 			$datetime = new DateTime();
@@ -10720,12 +10720,12 @@  discard block
 block discarded – undo
10720 10720
 		} else $offset = '+00:00';
10721 10721
 
10722 10722
 		if ($globalDBdriver == 'mysql') {
10723
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10723
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10724 10724
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10725 10725
 								GROUP BY hour_name 
10726 10726
 								ORDER BY hour_name ASC";
10727 10727
 		} else {
10728
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10728
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10729 10729
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10730 10730
 								GROUP BY hour_name 
10731 10731
 								ORDER BY hour_name ASC";
@@ -10733,12 +10733,12 @@  discard block
 block discarded – undo
10733 10733
       
10734 10734
 		
10735 10735
 		$sth = $this->db->prepare($query);
10736
-		$sth->execute(array(':pilot' => $pilot,':offset' => $offset));
10736
+		$sth->execute(array(':pilot' => $pilot, ':offset' => $offset));
10737 10737
       
10738 10738
 		$hour_array = array();
10739 10739
 		$temp_array = array();
10740 10740
         
10741
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10741
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10742 10742
 		{
10743 10743
 			$temp_array['hour_name'] = $row['hour_name'];
10744 10744
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10757,12 +10757,12 @@  discard block
 block discarded – undo
10757 10757
 	* @return Array the hour list
10758 10758
 	*
10759 10759
 	*/
10760
-	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10760
+	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
10761 10761
 	{
10762 10762
 		global $globalTimezone, $globalDBdriver;
10763
-		$filter_query = $this->getFilter($filters,true,true);
10764
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
10765
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
10763
+		$filter_query = $this->getFilter($filters, true, true);
10764
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
10765
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
10766 10766
 		if ($globalTimezone != '') {
10767 10767
 			date_default_timezone_set($globalTimezone);
10768 10768
 			$datetime = new DateTime();
@@ -10770,24 +10770,24 @@  discard block
 block discarded – undo
10770 10770
 		} else $offset = '+00:00';
10771 10771
 
10772 10772
 		if ($globalDBdriver == 'mysql') {
10773
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10773
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10774 10774
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10775 10775
 								GROUP BY hour_name 
10776 10776
 								ORDER BY hour_name ASC";
10777 10777
 		} else {
10778
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10778
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10779 10779
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10780 10780
 								GROUP BY hour_name 
10781 10781
 								ORDER BY hour_name ASC";
10782 10782
 		}
10783 10783
 		
10784 10784
 		$sth = $this->db->prepare($query);
10785
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
10785
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
10786 10786
       
10787 10787
 		$hour_array = array();
10788 10788
 		$temp_array = array();
10789 10789
         
10790
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10790
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10791 10791
 		{
10792 10792
 			$temp_array['hour_name'] = $row['hour_name'];
10793 10793
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10808,8 +10808,8 @@  discard block
 block discarded – undo
10808 10808
 	public function countAllHoursByCountry($country, $filters = array())
10809 10809
 	{
10810 10810
 		global $globalTimezone, $globalDBdriver;
10811
-		$filter_query = $this->getFilter($filters,true,true);
10812
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
10811
+		$filter_query = $this->getFilter($filters, true, true);
10812
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
10813 10813
 		if ($globalTimezone != '') {
10814 10814
 			date_default_timezone_set($globalTimezone);
10815 10815
 			$datetime = new DateTime();
@@ -10817,24 +10817,24 @@  discard block
 block discarded – undo
10817 10817
 		} else $offset = '+00:00';
10818 10818
 
10819 10819
 		if ($globalDBdriver == 'mysql') {
10820
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10820
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10821 10821
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10822 10822
 								GROUP BY hour_name 
10823 10823
 								ORDER BY hour_name ASC";
10824 10824
 		} else {
10825
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10825
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10826 10826
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10827 10827
 								GROUP BY hour_name 
10828 10828
 								ORDER BY hour_name ASC";
10829 10829
 		}
10830 10830
 		
10831 10831
 		$sth = $this->db->prepare($query);
10832
-		$sth->execute(array(':country' => $country,':offset' => $offset));
10832
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
10833 10833
       
10834 10834
 		$hour_array = array();
10835 10835
 		$temp_array = array();
10836 10836
         
10837
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10837
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10838 10838
 		{
10839 10839
 			$temp_array['hour_name'] = $row['hour_name'];
10840 10840
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10854,29 +10854,29 @@  discard block
 block discarded – undo
10854 10854
 	* @return Integer the number of aircrafts
10855 10855
 	*
10856 10856
 	*/
10857
-	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10857
+	public function countOverallAircrafts($filters = array(), $year = '', $month = '')
10858 10858
 	{
10859 10859
 		global $globalDBdriver;
10860
-		$filter_query = $this->getFilter($filters,true,true);
10861
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10860
+		$filter_query = $this->getFilter($filters, true, true);
10861
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10862 10862
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
10863 10863
 		$query_values = array();
10864 10864
 		if ($year != '') {
10865 10865
 			if ($globalDBdriver == 'mysql') {
10866 10866
 				$query .= " AND YEAR(spotter_output.date) = :year";
10867
-				$query_values = array_merge($query_values,array(':year' => $year));
10867
+				$query_values = array_merge($query_values, array(':year' => $year));
10868 10868
 			} else {
10869 10869
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10870
-				$query_values = array_merge($query_values,array(':year' => $year));
10870
+				$query_values = array_merge($query_values, array(':year' => $year));
10871 10871
 			}
10872 10872
 		}
10873 10873
 		if ($month != '') {
10874 10874
 			if ($globalDBdriver == 'mysql') {
10875 10875
 				$query .= " AND MONTH(spotter_output.date) = :month";
10876
-				$query_values = array_merge($query_values,array(':month' => $month));
10876
+				$query_values = array_merge($query_values, array(':month' => $month));
10877 10877
 			} else {
10878 10878
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10879
-				$query_values = array_merge($query_values,array(':month' => $month));
10879
+				$query_values = array_merge($query_values, array(':month' => $month));
10880 10880
 			}
10881 10881
 		}
10882 10882
 
@@ -10891,29 +10891,29 @@  discard block
 block discarded – undo
10891 10891
 	* @return Integer the number of aircrafts
10892 10892
 	*
10893 10893
 	*/
10894
-	public function countOverallArrival($filters = array(),$year = '',$month = '')
10894
+	public function countOverallArrival($filters = array(), $year = '', $month = '')
10895 10895
 	{
10896 10896
 		global $globalDBdriver;
10897
-		$filter_query = $this->getFilter($filters,true,true);
10898
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10897
+		$filter_query = $this->getFilter($filters, true, true);
10898
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10899 10899
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
10900 10900
 		$query_values = array();
10901 10901
 		if ($year != '') {
10902 10902
 			if ($globalDBdriver == 'mysql') {
10903 10903
 				$query .= " AND YEAR(spotter_output.date) = :year";
10904
-				$query_values = array_merge($query_values,array(':year' => $year));
10904
+				$query_values = array_merge($query_values, array(':year' => $year));
10905 10905
 			} else {
10906 10906
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10907
-				$query_values = array_merge($query_values,array(':year' => $year));
10907
+				$query_values = array_merge($query_values, array(':year' => $year));
10908 10908
 			}
10909 10909
 		}
10910 10910
 		if ($month != '') {
10911 10911
 			if ($globalDBdriver == 'mysql') {
10912 10912
 				$query .= " AND MONTH(spotter_output.date) = :month";
10913
-				$query_values = array_merge($query_values,array(':month' => $month));
10913
+				$query_values = array_merge($query_values, array(':month' => $month));
10914 10914
 			} else {
10915 10915
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10916
-				$query_values = array_merge($query_values,array(':month' => $month));
10916
+				$query_values = array_merge($query_values, array(':month' => $month));
10917 10917
 			}
10918 10918
 		}
10919 10919
 		
@@ -10928,29 +10928,29 @@  discard block
 block discarded – undo
10928 10928
 	* @return Integer the number of pilots
10929 10929
 	*
10930 10930
 	*/
10931
-	public function countOverallPilots($filters = array(),$year = '',$month = '')
10931
+	public function countOverallPilots($filters = array(), $year = '', $month = '')
10932 10932
 	{
10933 10933
 		global $globalDBdriver;
10934
-		$filter_query = $this->getFilter($filters,true,true);
10935
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10934
+		$filter_query = $this->getFilter($filters, true, true);
10935
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10936 10936
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
10937 10937
 		$query_values = array();
10938 10938
 		if ($year != '') {
10939 10939
 			if ($globalDBdriver == 'mysql') {
10940 10940
 				$query .= " AND YEAR(spotter_output.date) = :year";
10941
-				$query_values = array_merge($query_values,array(':year' => $year));
10941
+				$query_values = array_merge($query_values, array(':year' => $year));
10942 10942
 			} else {
10943 10943
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10944
-				$query_values = array_merge($query_values,array(':year' => $year));
10944
+				$query_values = array_merge($query_values, array(':year' => $year));
10945 10945
 			}
10946 10946
 		}
10947 10947
 		if ($month != '') {
10948 10948
 			if ($globalDBdriver == 'mysql') {
10949 10949
 				$query .= " AND MONTH(spotter_output.date) = :month";
10950
-				$query_values = array_merge($query_values,array(':month' => $month));
10950
+				$query_values = array_merge($query_values, array(':month' => $month));
10951 10951
 			} else {
10952 10952
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10953
-				$query_values = array_merge($query_values,array(':month' => $month));
10953
+				$query_values = array_merge($query_values, array(':month' => $month));
10954 10954
 			}
10955 10955
 		}
10956 10956
 		$sth = $this->db->prepare($query);
@@ -10964,29 +10964,29 @@  discard block
 block discarded – undo
10964 10964
 	* @return Integer the number of owners
10965 10965
 	*
10966 10966
 	*/
10967
-	public function countOverallOwners($filters = array(),$year = '',$month = '')
10967
+	public function countOverallOwners($filters = array(), $year = '', $month = '')
10968 10968
 	{
10969 10969
 		global $globalDBdriver;
10970
-		$filter_query = $this->getFilter($filters,true,true);
10971
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10970
+		$filter_query = $this->getFilter($filters, true, true);
10971
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10972 10972
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
10973 10973
 		$query_values = array();
10974 10974
 		if ($year != '') {
10975 10975
 			if ($globalDBdriver == 'mysql') {
10976 10976
 				$query .= " AND YEAR(spotter_output.date) = :year";
10977
-				$query_values = array_merge($query_values,array(':year' => $year));
10977
+				$query_values = array_merge($query_values, array(':year' => $year));
10978 10978
 			} else {
10979 10979
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10980
-				$query_values = array_merge($query_values,array(':year' => $year));
10980
+				$query_values = array_merge($query_values, array(':year' => $year));
10981 10981
 			}
10982 10982
 		}
10983 10983
 		if ($month != '') {
10984 10984
 			if ($globalDBdriver == 'mysql') {
10985 10985
 				$query .= " AND MONTH(spotter_output.date) = :month";
10986
-				$query_values = array_merge($query_values,array(':month' => $month));
10986
+				$query_values = array_merge($query_values, array(':month' => $month));
10987 10987
 			} else {
10988 10988
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10989
-				$query_values = array_merge($query_values,array(':month' => $month));
10989
+				$query_values = array_merge($query_values, array(':month' => $month));
10990 10990
 			}
10991 10991
 		}
10992 10992
 		$sth = $this->db->prepare($query);
@@ -11001,32 +11001,32 @@  discard block
 block discarded – undo
11001 11001
 	* @return Integer the number of flights
11002 11002
 	*
11003 11003
 	*/
11004
-	public function countOverallFlights($filters = array(),$year = '',$month = '')
11004
+	public function countOverallFlights($filters = array(), $year = '', $month = '')
11005 11005
 	{
11006 11006
 		global $globalDBdriver;
11007
-		$queryi  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11007
+		$queryi = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11008 11008
 		$query_values = array();
11009 11009
 		$query = '';
11010 11010
 		if ($year != '') {
11011 11011
 			if ($globalDBdriver == 'mysql') {
11012 11012
 				$query .= " AND YEAR(spotter_output.date) = :year";
11013
-				$query_values = array_merge($query_values,array(':year' => $year));
11013
+				$query_values = array_merge($query_values, array(':year' => $year));
11014 11014
 			} else {
11015 11015
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11016
-				$query_values = array_merge($query_values,array(':year' => $year));
11016
+				$query_values = array_merge($query_values, array(':year' => $year));
11017 11017
 			}
11018 11018
 		}
11019 11019
 		if ($month != '') {
11020 11020
 			if ($globalDBdriver == 'mysql') {
11021 11021
 				$query .= " AND MONTH(spotter_output.date) = :month";
11022
-				$query_values = array_merge($query_values,array(':month' => $month));
11022
+				$query_values = array_merge($query_values, array(':month' => $month));
11023 11023
 			} else {
11024 11024
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11025
-				$query_values = array_merge($query_values,array(':month' => $month));
11025
+				$query_values = array_merge($query_values, array(':month' => $month));
11026 11026
 			}
11027 11027
 		}
11028 11028
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11029
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11029
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11030 11030
 		
11031 11031
 		$sth = $this->db->prepare($queryi);
11032 11032
 		$sth->execute($query_values);
@@ -11039,29 +11039,29 @@  discard block
 block discarded – undo
11039 11039
 	* @return Integer the number of flights
11040 11040
 	*
11041 11041
 	*/
11042
-	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11042
+	public function countOverallMilitaryFlights($filters = array(), $year = '', $month = '')
11043 11043
 	{
11044 11044
 		global $globalDBdriver;
11045
-		$filter_query = $this->getFilter($filters,true,true);
11046
-		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11045
+		$filter_query = $this->getFilter($filters, true, true);
11046
+		$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11047 11047
                     FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'";
11048 11048
 		$query_values = array();
11049 11049
 		if ($year != '') {
11050 11050
 			if ($globalDBdriver == 'mysql') {
11051 11051
 				$query .= " AND YEAR(spotter_output.date) = :year";
11052
-				$query_values = array_merge($query_values,array(':year' => $year));
11052
+				$query_values = array_merge($query_values, array(':year' => $year));
11053 11053
 			} else {
11054 11054
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11055
-				$query_values = array_merge($query_values,array(':year' => $year));
11055
+				$query_values = array_merge($query_values, array(':year' => $year));
11056 11056
 			}
11057 11057
 		}
11058 11058
 		if ($month != '') {
11059 11059
 			if ($globalDBdriver == 'mysql') {
11060 11060
 				$query .= " AND MONTH(spotter_output.date) = :month";
11061
-				$query_values = array_merge($query_values,array(':month' => $month));
11061
+				$query_values = array_merge($query_values, array(':month' => $month));
11062 11062
 			} else {
11063 11063
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11064
-				$query_values = array_merge($query_values,array(':month' => $month));
11064
+				$query_values = array_merge($query_values, array(':month' => $month));
11065 11065
 			}
11066 11066
 		}
11067 11067
       
@@ -11078,10 +11078,10 @@  discard block
 block discarded – undo
11078 11078
 	* @return Integer the number of airlines
11079 11079
 	*
11080 11080
 	*/
11081
-	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11081
+	public function countOverallAirlines($filters = array(), $year = '', $month = '')
11082 11082
 	{
11083 11083
 		global $globalDBdriver;
11084
-		$queryi  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11084
+		$queryi = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11085 11085
 							FROM spotter_output";
11086 11086
       
11087 11087
 		$query_values = array();
@@ -11089,23 +11089,23 @@  discard block
 block discarded – undo
11089 11089
 		if ($year != '') {
11090 11090
 			if ($globalDBdriver == 'mysql') {
11091 11091
 				$query .= " AND YEAR(spotter_output.date) = :year";
11092
-				$query_values = array_merge($query_values,array(':year' => $year));
11092
+				$query_values = array_merge($query_values, array(':year' => $year));
11093 11093
 			} else {
11094 11094
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11095
-				$query_values = array_merge($query_values,array(':year' => $year));
11095
+				$query_values = array_merge($query_values, array(':year' => $year));
11096 11096
 			}
11097 11097
 		}
11098 11098
 		if ($month != '') {
11099 11099
 			if ($globalDBdriver == 'mysql') {
11100 11100
 				$query .= " AND MONTH(spotter_output.date) = :month";
11101
-				$query_values = array_merge($query_values,array(':month' => $month));
11101
+				$query_values = array_merge($query_values, array(':month' => $month));
11102 11102
 			} else {
11103 11103
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11104
-				$query_values = array_merge($query_values,array(':month' => $month));
11104
+				$query_values = array_merge($query_values, array(':month' => $month));
11105 11105
 			}
11106 11106
 		}
11107 11107
                 if ($query == '') $queryi .= $this->getFilter($filters);
11108
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11108
+                else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11109 11109
 
11110 11110
 
11111 11111
 		$sth = $this->db->prepare($queryi);
@@ -11123,7 +11123,7 @@  discard block
 block discarded – undo
11123 11123
 	public function countAllHoursFromToday($filters = array())
11124 11124
 	{
11125 11125
 		global $globalTimezone, $globalDBdriver;
11126
-		$filter_query = $this->getFilter($filters,true,true);
11126
+		$filter_query = $this->getFilter($filters, true, true);
11127 11127
 		if ($globalTimezone != '') {
11128 11128
 			date_default_timezone_set($globalTimezone);
11129 11129
 			$datetime = new DateTime();
@@ -11131,12 +11131,12 @@  discard block
 block discarded – undo
11131 11131
 		} else $offset = '+00:00';
11132 11132
 
11133 11133
 		if ($globalDBdriver == 'mysql') {
11134
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11134
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11135 11135
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
11136 11136
 								GROUP BY hour_name 
11137 11137
 								ORDER BY hour_name ASC";
11138 11138
 		} else {
11139
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11139
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11140 11140
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
11141 11141
 								GROUP BY hour_name 
11142 11142
 								ORDER BY hour_name ASC";
@@ -11148,7 +11148,7 @@  discard block
 block discarded – undo
11148 11148
 		$hour_array = array();
11149 11149
 		$temp_array = array();
11150 11150
         
11151
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11151
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11152 11152
 		{
11153 11153
 			$temp_array['hour_name'] = $row['hour_name'];
11154 11154
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -11167,14 +11167,14 @@  discard block
 block discarded – undo
11167 11167
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11168 11168
 	{
11169 11169
 		global $global_query, $globalDBdriver, $globalTimezone;
11170
-		$filter_query = $this->getFilter($filters,true,true);
11170
+		$filter_query = $this->getFilter($filters, true, true);
11171 11171
 		date_default_timezone_set('UTC');
11172 11172
 		$limit_query = '';
11173 11173
 		if ($limit != "")
11174 11174
 		{
11175 11175
 			$limit_array = explode(",", $limit);
11176
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
11177
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
11176
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
11177
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
11178 11178
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
11179 11179
 			{
11180 11180
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -11227,7 +11227,7 @@  discard block
 block discarded – undo
11227 11227
 			    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')
11228 11228
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
11229 11229
 			//echo $query;
11230
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
11230
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
11231 11231
 			/*
11232 11232
 			$sth = $this->db->prepare($query);
11233 11233
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -11246,9 +11246,9 @@  discard block
 block discarded – undo
11246 11246
 	*/
11247 11247
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11248 11248
 	{
11249
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
11249
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
11250 11250
 
11251
-		$query  = "SELECT spotter_output.spotter_id
11251
+		$query = "SELECT spotter_output.spotter_id
11252 11252
 								FROM spotter_output 
11253 11253
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
11254 11254
         
@@ -11256,7 +11256,7 @@  discard block
 block discarded – undo
11256 11256
 		$sth = $this->db->prepare($query);
11257 11257
 		$sth->execute();
11258 11258
 
11259
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11259
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11260 11260
 		{
11261 11261
 			return $row['spotter_id'];
11262 11262
 		}
@@ -11281,23 +11281,23 @@  discard block
 block discarded – undo
11281 11281
 		}
11282 11282
 		
11283 11283
 		$current_date = date("Y-m-d H:i:s");
11284
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
11284
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
11285 11285
 		
11286 11286
 		$diff = abs(strtotime($current_date) - strtotime($date));
11287 11287
 
11288
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
11288
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
11289 11289
 		$years = $time_array['years'];
11290 11290
 		
11291
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
11291
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
11292 11292
 		$months = $time_array['months'];
11293 11293
 		
11294
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
11294
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
11295 11295
 		$days = $time_array['days'];
11296
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
11296
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
11297 11297
 		$hours = $time_array['hours'];
11298
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
11298
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
11299 11299
 		$minutes = $time_array['minutes'];
11300
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11300
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11301 11301
 		
11302 11302
 		return $time_array;	
11303 11303
 	}	
@@ -11323,63 +11323,63 @@  discard block
 block discarded – undo
11323 11323
 			$temp_array['direction_degree'] = $direction;
11324 11324
 			$temp_array['direction_shortname'] = "N";
11325 11325
 			$temp_array['direction_fullname'] = "North";
11326
-		} elseif ($direction >= 22.5 && $direction < 45){
11326
+		} elseif ($direction >= 22.5 && $direction < 45) {
11327 11327
 			$temp_array['direction_degree'] = $direction;
11328 11328
 			$temp_array['direction_shortname'] = "NNE";
11329 11329
 			$temp_array['direction_fullname'] = "North-Northeast";
11330
-		} elseif ($direction >= 45 && $direction < 67.5){
11330
+		} elseif ($direction >= 45 && $direction < 67.5) {
11331 11331
 			$temp_array['direction_degree'] = $direction;
11332 11332
 			$temp_array['direction_shortname'] = "NE";
11333 11333
 			$temp_array['direction_fullname'] = "Northeast";
11334
-		} elseif ($direction >= 67.5 && $direction < 90){
11334
+		} elseif ($direction >= 67.5 && $direction < 90) {
11335 11335
 			$temp_array['direction_degree'] = $direction;
11336 11336
 			$temp_array['direction_shortname'] = "ENE";
11337 11337
 			$temp_array['direction_fullname'] = "East-Northeast";
11338
-		} elseif ($direction >= 90 && $direction < 112.5){
11338
+		} elseif ($direction >= 90 && $direction < 112.5) {
11339 11339
 			$temp_array['direction_degree'] = $direction;
11340 11340
 			$temp_array['direction_shortname'] = "E";
11341 11341
 			$temp_array['direction_fullname'] = "East";
11342
-		} elseif ($direction >= 112.5 && $direction < 135){
11342
+		} elseif ($direction >= 112.5 && $direction < 135) {
11343 11343
 			$temp_array['direction_degree'] = $direction;
11344 11344
 			$temp_array['direction_shortname'] = "ESE";
11345 11345
 			$temp_array['direction_fullname'] = "East-Southeast";
11346
-		} elseif ($direction >= 135 && $direction < 157.5){
11346
+		} elseif ($direction >= 135 && $direction < 157.5) {
11347 11347
 			$temp_array['direction_degree'] = $direction;
11348 11348
 			$temp_array['direction_shortname'] = "SE";
11349 11349
 			$temp_array['direction_fullname'] = "Southeast";
11350
-		} elseif ($direction >= 157.5 && $direction < 180){
11350
+		} elseif ($direction >= 157.5 && $direction < 180) {
11351 11351
 			$temp_array['direction_degree'] = $direction;
11352 11352
 			$temp_array['direction_shortname'] = "SSE";
11353 11353
 			$temp_array['direction_fullname'] = "South-Southeast";
11354
-		} elseif ($direction >= 180 && $direction < 202.5){
11354
+		} elseif ($direction >= 180 && $direction < 202.5) {
11355 11355
 			$temp_array['direction_degree'] = $direction;
11356 11356
 			$temp_array['direction_shortname'] = "S";
11357 11357
 			$temp_array['direction_fullname'] = "South";
11358
-		} elseif ($direction >= 202.5 && $direction < 225){
11358
+		} elseif ($direction >= 202.5 && $direction < 225) {
11359 11359
 			$temp_array['direction_degree'] = $direction;
11360 11360
 			$temp_array['direction_shortname'] = "SSW";
11361 11361
 			$temp_array['direction_fullname'] = "South-Southwest";
11362
-		} elseif ($direction >= 225 && $direction < 247.5){
11362
+		} elseif ($direction >= 225 && $direction < 247.5) {
11363 11363
 			$temp_array['direction_degree'] = $direction;
11364 11364
 			$temp_array['direction_shortname'] = "SW";
11365 11365
 			$temp_array['direction_fullname'] = "Southwest";
11366
-		} elseif ($direction >= 247.5 && $direction < 270){
11366
+		} elseif ($direction >= 247.5 && $direction < 270) {
11367 11367
 			$temp_array['direction_degree'] = $direction;
11368 11368
 			$temp_array['direction_shortname'] = "WSW";
11369 11369
 			$temp_array['direction_fullname'] = "West-Southwest";
11370
-		} elseif ($direction >= 270 && $direction < 292.5){
11370
+		} elseif ($direction >= 270 && $direction < 292.5) {
11371 11371
 			$temp_array['direction_degree'] = $direction;
11372 11372
 			$temp_array['direction_shortname'] = "W";
11373 11373
 			$temp_array['direction_fullname'] = "West";
11374
-		} elseif ($direction >= 292.5 && $direction < 315){
11374
+		} elseif ($direction >= 292.5 && $direction < 315) {
11375 11375
 			$temp_array['direction_degree'] = $direction;
11376 11376
 			$temp_array['direction_shortname'] = "WNW";
11377 11377
 			$temp_array['direction_fullname'] = "West-Northwest";
11378
-		} elseif ($direction >= 315 && $direction < 337.5){
11378
+		} elseif ($direction >= 315 && $direction < 337.5) {
11379 11379
 			$temp_array['direction_degree'] = $direction;
11380 11380
 			$temp_array['direction_shortname'] = "NW";
11381 11381
 			$temp_array['direction_fullname'] = "Northwest";
11382
-		} elseif ($direction >= 337.5 && $direction < 360){
11382
+		} elseif ($direction >= 337.5 && $direction < 360) {
11383 11383
 			$temp_array['direction_degree'] = $direction;
11384 11384
 			$temp_array['direction_shortname'] = "NNW";
11385 11385
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -11432,9 +11432,9 @@  discard block
 block discarded – undo
11432 11432
 	*/
11433 11433
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
11434 11434
 	{
11435
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11435
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11436 11436
 	
11437
-		$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1";
11437
+		$query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1";
11438 11438
 		
11439 11439
 		$sth = $this->db->prepare($query);
11440 11440
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -11457,9 +11457,9 @@  discard block
 block discarded – undo
11457 11457
 	*/
11458 11458
 	public function getAircraftTypeBymodeS($aircraft_modes)
11459 11459
 	{
11460
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11460
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11461 11461
 	
11462
-		$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1";
11462
+		$query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1";
11463 11463
 		
11464 11464
 		$sth = $this->db->prepare($query);
11465 11465
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -11480,11 +11480,11 @@  discard block
 block discarded – undo
11480 11480
 	* @param Float $longitude longitute of the flight
11481 11481
 	* @return String the countrie
11482 11482
 	*/
11483
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11483
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
11484 11484
 	{
11485 11485
 		global $globalDBdriver, $globalDebug;
11486
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11487
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11486
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11487
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11488 11488
 	
11489 11489
 		$Connection = new Connection($this->db);
11490 11490
 		if (!$Connection->tableExists('countries')) return '';
@@ -11524,7 +11524,7 @@  discard block
 block discarded – undo
11524 11524
 	public function getCountryFromISO2($iso2)
11525 11525
 	{
11526 11526
 		global $globalDBdriver, $globalDebug;
11527
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11527
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
11528 11528
 	
11529 11529
 		$Connection = new Connection($this->db);
11530 11530
 		if (!$Connection->tableExists('countries')) return '';
@@ -11556,19 +11556,19 @@  discard block
 block discarded – undo
11556 11556
 	*/
11557 11557
 	public function convertAircraftRegistration($registration)
11558 11558
 	{
11559
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11559
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11560 11560
 		$registration_prefix = '';
11561 11561
 		$registration_1 = substr($registration, 0, 1);
11562 11562
 		$registration_2 = substr($registration, 0, 2);
11563 11563
 
11564 11564
 		//first get the prefix based on two characters
11565
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11565
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11566 11566
       
11567 11567
 		
11568 11568
 		$sth = $this->db->prepare($query);
11569 11569
 		$sth->execute(array(':registration_2' => $registration_2));
11570 11570
         
11571
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11571
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11572 11572
 		{
11573 11573
 			$registration_prefix = $row['registration_prefix'];
11574 11574
 		}
@@ -11576,11 +11576,11 @@  discard block
 block discarded – undo
11576 11576
 		//if we didn't find a two chracter prefix lets just search the one with one character
11577 11577
 		if ($registration_prefix == '')
11578 11578
 		{
11579
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11579
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11580 11580
 			$sth = $this->db->prepare($query);
11581 11581
 			$sth->execute(array(':registration_1' => $registration_1));
11582 11582
 	        
11583
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11583
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11584 11584
 			{
11585 11585
 				$registration_prefix = $row['registration_prefix'];
11586 11586
 			}
@@ -11594,7 +11594,7 @@  discard block
 block discarded – undo
11594 11594
 			} else {
11595 11595
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
11596 11596
 			}
11597
-		} else if(strlen($registration_prefix) == 2){
11597
+		} else if (strlen($registration_prefix) == 2) {
11598 11598
 			if (0 === strpos($registration, 'N')) {
11599 11599
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
11600 11600
 			} else {
@@ -11613,17 +11613,17 @@  discard block
 block discarded – undo
11613 11613
 	*/
11614 11614
 	public function countryFromAircraftRegistration($registration)
11615 11615
 	{
11616
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11616
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11617 11617
 		
11618 11618
 		$registration_prefix = '';
11619
-		$registration_test = explode('-',$registration);
11619
+		$registration_test = explode('-', $registration);
11620 11620
 		$country = '';
11621 11621
 		if ($registration_test[0] != $registration) {
11622 11622
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11623 11623
 	      
11624 11624
 			$sth = $this->db->prepare($query);
11625 11625
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11626
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11626
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11627 11627
 			{
11628 11628
 				//$registration_prefix = $row['registration_prefix'];
11629 11629
 				$country = $row['country'];
@@ -11634,13 +11634,13 @@  discard block
 block discarded – undo
11634 11634
 
11635 11635
 			$country = '';
11636 11636
 			//first get the prefix based on two characters
11637
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11637
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11638 11638
       
11639 11639
 			
11640 11640
 			$sth = $this->db->prepare($query);
11641 11641
 			$sth->execute(array(':registration_2' => $registration_2));
11642 11642
         
11643
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11643
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11644 11644
 			{
11645 11645
 				$registration_prefix = $row['registration_prefix'];
11646 11646
 				$country = $row['country'];
@@ -11649,12 +11649,12 @@  discard block
 block discarded – undo
11649 11649
 			//if we didn't find a two chracter prefix lets just search the one with one character
11650 11650
 			if ($registration_prefix == "")
11651 11651
 			{
11652
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11652
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11653 11653
 	      
11654 11654
 				$sth = $this->db->prepare($query);
11655 11655
 				$sth->execute(array(':registration_1' => $registration_1));
11656 11656
 	        
11657
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11657
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11658 11658
 				{
11659 11659
 					//$registration_prefix = $row['registration_prefix'];
11660 11660
 					$country = $row['country'];
@@ -11674,17 +11674,17 @@  discard block
 block discarded – undo
11674 11674
 	*/
11675 11675
 	public function registrationPrefixFromAircraftRegistration($registration)
11676 11676
 	{
11677
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11677
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11678 11678
 		
11679 11679
 		$registration_prefix = '';
11680
-		$registration_test = explode('-',$registration);
11680
+		$registration_test = explode('-', $registration);
11681 11681
 		//$country = '';
11682 11682
 		if ($registration_test[0] != $registration) {
11683
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11683
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11684 11684
 	      
11685 11685
 			$sth = $this->db->prepare($query);
11686 11686
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11687
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11687
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11688 11688
 			{
11689 11689
 				$registration_prefix = $row['registration_prefix'];
11690 11690
 				//$country = $row['country'];
@@ -11694,13 +11694,13 @@  discard block
 block discarded – undo
11694 11694
 		        $registration_2 = substr($registration, 0, 2);
11695 11695
 
11696 11696
 			//first get the prefix based on two characters
11697
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11697
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11698 11698
       
11699 11699
 			
11700 11700
 			$sth = $this->db->prepare($query);
11701 11701
 			$sth->execute(array(':registration_2' => $registration_2));
11702 11702
         
11703
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11703
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11704 11704
 			{
11705 11705
 				$registration_prefix = $row['registration_prefix'];
11706 11706
 				//$country = $row['country'];
@@ -11709,12 +11709,12 @@  discard block
 block discarded – undo
11709 11709
 			//if we didn't find a two chracter prefix lets just search the one with one character
11710 11710
 			if ($registration_prefix == "")
11711 11711
 			{
11712
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11712
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11713 11713
 	      
11714 11714
 				$sth = $this->db->prepare($query);
11715 11715
 				$sth->execute(array(':registration_1' => $registration_1));
11716 11716
 	        
11717
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11717
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11718 11718
 				{
11719 11719
 					$registration_prefix = $row['registration_prefix'];
11720 11720
 					//$country = $row['country'];
@@ -11735,13 +11735,13 @@  discard block
 block discarded – undo
11735 11735
 	*/
11736 11736
 	public function countryFromAircraftRegistrationCode($registration)
11737 11737
 	{
11738
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11738
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11739 11739
 		
11740 11740
 		$country = '';
11741
-		$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11741
+		$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11742 11742
 		$sth = $this->db->prepare($query);
11743 11743
 		$sth->execute(array(':registration' => $registration));
11744
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11744
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11745 11745
 		{
11746 11746
 			$country = $row['country'];
11747 11747
 		}
@@ -11754,9 +11754,9 @@  discard block
 block discarded – undo
11754 11754
 	* @param String $flightaware_id flightaware_id from spotter_output table
11755 11755
 	* @param String $highlight New highlight value
11756 11756
 	*/
11757
-	public function setHighlightFlight($flightaware_id,$highlight) {
11757
+	public function setHighlightFlight($flightaware_id, $highlight) {
11758 11758
 		
11759
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11759
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11760 11760
 		$sth = $this->db->prepare($query);
11761 11761
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
11762 11762
 	}
@@ -11768,13 +11768,13 @@  discard block
 block discarded – undo
11768 11768
 	* @param String $date Date of spotted aircraft
11769 11769
 	* @param String $highlight New highlight value
11770 11770
 	*/
11771
-	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11771
+	public function setHighlightFlightByRegistration($registration, $highlight, $date = '') {
11772 11772
 		if ($date == '') {
11773 11773
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
11774 11774
 			$query_values = array(':registration' => $registration, ':highlight' => $highlight);
11775 11775
 		} else {
11776 11776
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE registration = :registration AND date(date) = :date";
11777
-			$query_values = array(':registration' => $registration, ':highlight' => $highlight,':date' => $date);
11777
+			$query_values = array(':registration' => $registration, ':highlight' => $highlight, ':date' => $date);
11778 11778
 		}
11779 11779
 		$sth = $this->db->prepare($query);
11780 11780
 		$sth->execute($query_values);
@@ -11804,7 +11804,7 @@  discard block
 block discarded – undo
11804 11804
 		
11805 11805
 		$bitly_data = json_decode($bitly_data);
11806 11806
 		$bitly_url = '';
11807
-		if ($bitly_data->status_txt = "OK"){
11807
+		if ($bitly_data->status_txt = "OK") {
11808 11808
 			$bitly_url = $bitly_data->data->url;
11809 11809
 		}
11810 11810
 
@@ -11814,7 +11814,7 @@  discard block
 block discarded – undo
11814 11814
 
11815 11815
 	public function getOrderBy()
11816 11816
 	{
11817
-		$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"));
11817
+		$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"));
11818 11818
 		
11819 11819
 		return $orderby;
11820 11820
 		
@@ -11948,14 +11948,14 @@  discard block
 block discarded – undo
11948 11948
 		}
11949 11949
 		$sth = $this->db->prepare($query);
11950 11950
 		$sth->execute();
11951
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11951
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11952 11952
 		{
11953 11953
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
11954 11954
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
11955 11955
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
11956
-				$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";
11956
+				$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";
11957 11957
 				$sthu = $this->db->prepare($update_query);
11958
-				$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']));
11958
+				$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']));
11959 11959
 			}
11960 11960
 		}
11961 11961
 		
@@ -11968,7 +11968,7 @@  discard block
 block discarded – undo
11968 11968
 		}
11969 11969
 		$sth = $this->db->prepare($query);
11970 11970
 		$sth->execute();
11971
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11971
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11972 11972
 		{
11973 11973
 			if (is_numeric(substr($row['ident'], -1, 1)))
11974 11974
 			{
@@ -11977,11 +11977,11 @@  discard block
 block discarded – undo
11977 11977
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
11978 11978
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
11979 11979
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
11980
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
11980
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
11981 11981
 				if (isset($airline_array[0]['name'])) {
11982
-					$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";
11982
+					$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";
11983 11983
 					$sthu = $this->db->prepare($update_query);
11984
-					$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']));
11984
+					$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']));
11985 11985
 				}
11986 11986
 			}
11987 11987
 		}
@@ -12001,18 +12001,18 @@  discard block
 block discarded – undo
12001 12001
 		}
12002 12002
 		$sth = $this->db->prepare($query);
12003 12003
 		$sth->execute();
12004
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12004
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12005 12005
 		{
12006 12006
 			if ($row['aircraft_icao'] != '') {
12007 12007
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
12008
-				if ($row['registration'] != ""){
12008
+				if ($row['registration'] != "") {
12009 12009
 					$image_array = $Image->getSpotterImage($row['registration']);
12010 12010
 					if (!isset($image_array[0]['registration'])) {
12011 12011
 						$Image->addSpotterImage($row['registration']);
12012 12012
 					}
12013 12013
 				}
12014 12014
 				if (count($aircraft_name) > 0) {
12015
-					$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";
12015
+					$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";
12016 12016
 					$sthu = $this->db->prepare($update_query);
12017 12017
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
12018 12018
 				}
@@ -12027,10 +12027,10 @@  discard block
 block discarded – undo
12027 12027
 		$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";
12028 12028
 		$sth = $this->db->prepare($query);
12029 12029
 		$sth->execute();
12030
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12030
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12031 12031
 		{
12032 12032
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
12033
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
12033
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
12034 12034
 				$airport_icao = '';
12035 12035
 				 if (isset($closestAirports[0])) {
12036 12036
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -12044,7 +12044,7 @@  discard block
 block discarded – undo
12044 12044
 								break;
12045 12045
 							}
12046 12046
 						}
12047
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12047
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
12048 12048
 						$airport_icao = $closestAirports[0]['icao'];
12049 12049
 						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";
12050 12050
 					} else {
@@ -12055,28 +12055,28 @@  discard block
 block discarded – undo
12055 12055
 				}
12056 12056
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12057 12057
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12058
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12058
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12059 12059
 					$sthu = $this->db->prepare($update_query);
12060
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
12060
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
12061 12061
 				}
12062 12062
 			}
12063 12063
 		}
12064 12064
 	}
12065 12065
 	
12066
-	public function closestAirports($origLat,$origLon,$dist = 10) {
12066
+	public function closestAirports($origLat, $origLon, $dist = 10) {
12067 12067
 		global $globalDBdriver;
12068
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
12068
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
12069 12069
 /*
12070 12070
 		$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 
12071 12071
                       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)) 
12072 12072
                       having distance < $dist ORDER BY distance limit 100;";
12073 12073
 */
12074 12074
 		if ($globalDBdriver == 'mysql') {
12075
-			$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 
12075
+			$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 
12076 12076
 	                      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)) 
12077 12077
 	                      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;";
12078 12078
                 } else {
12079
-			$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 
12079
+			$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 
12080 12080
 	                      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)) 
12081 12081
 	                      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;";
12082 12082
     		}
Please login to merge, or discard this patch.
require/class.NOTAM.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		try {
983 983
 			$sth = $this->db->prepare($query);
984 984
 			$sth->execute($query_values);
985
-		} catch(PDOException $e) {
985
+		} catch (PDOException $e) {
986 986
 			echo "error : ".$e->getMessage();
987 987
 		}
988 988
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1000,19 +1000,19 @@  discard block
 block discarded – undo
1000 1000
 		try {
1001 1001
 			$sth = $this->db->prepare($query);
1002 1002
 			$sth->execute($query_values);
1003
-		} catch(PDOException $e) {
1003
+		} catch (PDOException $e) {
1004 1004
 			echo "error : ".$e->getMessage();
1005 1005
 		}
1006 1006
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1007 1007
 		return $all;
1008 1008
 	}
1009 1009
 	public function getAllNOTAMtext() {
1010
-		$query  = 'SELECT full_notam FROM notam';
1010
+		$query = 'SELECT full_notam FROM notam';
1011 1011
 		$query_values = array();
1012 1012
 		try {
1013 1013
 			$sth = $this->db->prepare($query);
1014 1014
 			$sth->execute($query_values);
1015
-		} catch(PDOException $e) {
1015
+		} catch (PDOException $e) {
1016 1016
 			echo "error : ".$e->getMessage();
1017 1017
 		}
1018 1018
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
 	public function createNOTAMtextFile($filename) {
1022 1022
 		$allnotam_result = $this->getAllNOTAMtext();
1023 1023
 		$notamtext = '';
1024
-		foreach($allnotam_result as $notam) {
1024
+		foreach ($allnotam_result as $notam) {
1025 1025
 			$notamtext .= '%%'."\n";
1026 1026
 			$notamtext .= $notam['full_notam'];
1027 1027
 			$notamtext .= "\n".'%%'."\n";
1028 1028
 		}
1029 1029
 		//$allnotam = implode('\n%%%%\n',$allnotam_result);
1030
-		file_put_contents($filename,$notamtext);
1030
+		file_put_contents($filename, $notamtext);
1031 1031
 	}
1032 1032
 	public function parseNOTAMtextFile($filename) {
1033 1033
 		$data = file_get_contents($filename);
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 		try {
1049 1049
 			$sth = $this->db->prepare($query);
1050 1050
 			$sth->execute($query_values);
1051
-		} catch(PDOException $e) {
1051
+		} catch (PDOException $e) {
1052 1052
 			echo "error : ".$e->getMessage();
1053 1053
 		}
1054 1054
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1057,10 +1057,10 @@  discard block
 block discarded – undo
1057 1057
 	public function getAllNOTAMbyCoord($coord) {
1058 1058
 		global $globalDBdriver;
1059 1059
 		if (is_array($coord)) {
1060
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1061
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1062
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1060
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1061
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1062
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1064 1064
 			if ($minlat > $maxlat) {
1065 1065
 				$tmplat = $minlat;
1066 1066
 				$minlat = $maxlat;
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 		try {
1083 1083
 			$sth = $this->db->prepare($query);
1084 1084
 			$sth->execute($query_values);
1085
-		} catch(PDOException $e) {
1085
+		} catch (PDOException $e) {
1086 1086
 			echo "error : ".$e->getMessage();
1087 1087
 		}
1088 1088
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1089 1089
 		return $all;
1090 1090
 	}
1091
-	public function getAllNOTAMbyCoordScope($coord,$scope) {
1091
+	public function getAllNOTAMbyCoordScope($coord, $scope) {
1092 1092
 		global $globalDBdriver;
1093 1093
 		if (is_array($coord)) {
1094
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1095
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1096
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1097
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1094
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1095
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1096
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1097
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1098 1098
 		} else return array();
1099 1099
 		if ($globalDBdriver == 'mysql') {
1100 1100
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		try {
1107 1107
 			$sth = $this->db->prepare($query);
1108 1108
 			$sth->execute($query_values);
1109
-		} catch(PDOException $e) {
1109
+		} catch (PDOException $e) {
1110 1110
 			echo "error : ".$e->getMessage();
1111 1111
 		}
1112 1112
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		try {
1119 1119
 			$sth = $this->db->prepare($query);
1120 1120
 			$sth->execute($query_values);
1121
-		} catch(PDOException $e) {
1121
+		} catch (PDOException $e) {
1122 1122
 			return "error : ".$e->getMessage();
1123 1123
 		}
1124 1124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1126,13 +1126,13 @@  discard block
 block discarded – undo
1126 1126
 		else return array();
1127 1127
 	}
1128 1128
 
1129
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1129
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
1130 1130
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1131
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1131
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
1132 1132
 		try {
1133 1133
 			$sth = $this->db->prepare($query);
1134 1134
 			$sth->execute($query_values);
1135
-		} catch(PDOException $e) {
1135
+		} catch (PDOException $e) {
1136 1136
 			return "error : ".$e->getMessage();
1137 1137
 		}
1138 1138
 	}
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		try {
1144 1144
 			$sth = $this->db->prepare($query);
1145 1145
 			$sth->execute($query_values);
1146
-		} catch(PDOException $e) {
1146
+		} catch (PDOException $e) {
1147 1147
 			return "error : ".$e->getMessage();
1148 1148
 		}
1149 1149
 	}
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$sth = $this->db->prepare($query);
1160 1160
 			$sth->execute($query_values);
1161
-		} catch(PDOException $e) {
1161
+		} catch (PDOException $e) {
1162 1162
 			return "error : ".$e->getMessage();
1163 1163
 		}
1164 1164
 	}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 		try {
1169 1169
 			$sth = $this->db->prepare($query);
1170 1170
 			$sth->execute($query_values);
1171
-		} catch(PDOException $e) {
1171
+		} catch (PDOException $e) {
1172 1172
 			return "error : ".$e->getMessage();
1173 1173
 		}
1174 1174
 	}
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		try {
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute();
1180
-		} catch(PDOException $e) {
1180
+		} catch (PDOException $e) {
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
1183 1183
 	}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute();
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			return "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 	}
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 	public function updateNOTAM() {
1195 1195
 		global $globalNOTAMAirports;
1196 1196
 		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1197
-			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1198
-				$airport_icao = implode(',',$airport);
1197
+			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) {
1198
+				$airport_icao = implode(',', $airport);
1199 1199
 				$alldata = $this->downloadNOTAM($airport_icao);
1200 1200
 				if (count($alldata) > 0) {
1201 1201
 					foreach ($alldata as $initial_data) {
1202 1202
 						$data = $this->parse($initial_data);
1203 1203
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1204
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1204
+						if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1205 1205
 					}
1206 1206
 				}
1207 1207
 			}
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
 			foreach ($alldata as $initial_data) {
1215 1215
 				$data = $this->parse($initial_data);
1216 1216
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1217
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1217
+				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1218 1218
 			}
1219 1219
 		}
1220 1220
 	}
@@ -1223,12 +1223,12 @@  discard block
 block discarded – undo
1223 1223
 		global $globalTransaction;
1224 1224
 		$Spotter = new Spotter();
1225 1225
 		$allairports = $Spotter->getAllAirportInfo();
1226
-		foreach (array_chunk($allairports,20) as $airport) {
1226
+		foreach (array_chunk($allairports, 20) as $airport) {
1227 1227
 			$airports_icao = array();
1228
-			foreach($airport as $icao) {
1228
+			foreach ($airport as $icao) {
1229 1229
 				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1230 1230
 			}
1231
-			$airport_icao = implode(',',$airports_icao);
1231
+			$airport_icao = implode(',', $airports_icao);
1232 1232
 			$alldata = $this->downloadNOTAM($airport_icao);
1233 1233
 			if ($globalTransaction) $this->db->beginTransaction();
1234 1234
 			if (count($alldata) > 0) {
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 						if (count($notamref) == 0) {
1242 1242
 							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1243 1243
 							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1244
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1244
+							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1245 1245
 						}
1246 1246
 					}
1247 1247
 				}
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		date_default_timezone_set("UTC");
1256 1256
 		$Common = new Common();
1257 1257
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1258
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1258
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1259 1259
 		$data = $Common->getData($url);
1260 1260
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1261 1261
 		//print_r($matches);
@@ -1267,14 +1267,14 @@  discard block
 block discarded – undo
1267 1267
 		$Common = new Common();
1268 1268
 		$result = array();
1269 1269
 		$result['full_notam'] = $data;
1270
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1271
-		$data = preg_split('#(?=([A-Z]\)\s))#',$data);
1270
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
1271
+		$data = preg_split('#(?=([A-Z]\)\s))#', $data);
1272 1272
 		//print_r($data);
1273 1273
 		foreach ($data as $line) {
1274 1274
 			$line = trim($line);
1275
-			if (preg_match('#Q\) (.*)#',$line,$matches)) {
1276
-				$line = str_replace(' ','',$line);
1277
-				if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1275
+			if (preg_match('#Q\) (.*)#', $line, $matches)) {
1276
+				$line = str_replace(' ', '', $line);
1277
+				if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#', $line, $matches)) {
1278 1278
 				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1279 1279
 					//print_r($matches);
1280 1280
 					$result['fir'] = $matches[1];
@@ -1320,30 +1320,30 @@  discard block
 block discarded – undo
1320 1320
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1321 1321
 					$result['lower_limit'] = $matches[6];
1322 1322
 					$result['upper_limit'] = $matches[7];
1323
-					$latitude = $Common->convertDec($matches[8],'latitude');
1323
+					$latitude = $Common->convertDec($matches[8], 'latitude');
1324 1324
 					if ($matches[9] == 'S') $latitude = -$latitude;
1325
-					$longitude = $Common->convertDec($matches[10],'longitude');
1325
+					$longitude = $Common->convertDec($matches[10], 'longitude');
1326 1326
 					if ($matches[11] == 'W') $longitude = -$longitude;
1327 1327
 					$result['latitude'] = $latitude;
1328 1328
 					$result['longitude'] = $longitude;
1329 1329
 					$result['radius'] = intval($matches[12]);
1330 1330
 				} else echo 'ERROR : '.$line."\n";
1331 1331
 			}
1332
-			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
1332
+			elseif (preg_match('#A\) (.*)#', $line, $matches)) {
1333 1333
 				$result['icao'] = $matches[1];
1334 1334
 			}
1335
-			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
1335
+			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches)) {
1336 1336
 				if ($matches[1] > 50) $year = '19'.$matches[1];
1337 1337
 				else $year = '20'.$matches[1];
1338 1338
 				$result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1339 1339
 			}
1340
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
1340
+			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches)) {
1341 1341
 				if ($matches[1] > 50) $year = '19'.$matches[1];
1342 1342
 				else $year = '20'.$matches[1];
1343 1343
 				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1344 1344
 				$result['permanent'] = 0;
1345 1345
 			}
1346
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
1346
+			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches)) {
1347 1347
 				if ($matches[1] > 50) $year = '19'.$matches[1];
1348 1348
 				else $year = '20'.$matches[1];
1349 1349
 				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
@@ -1352,26 +1352,26 @@  discard block
 block discarded – undo
1352 1352
 				if ($matches[6] == 'PERM') $result['permanent'] = 1;
1353 1353
 				else $result['permanent'] = 0;
1354 1354
 			}
1355
-			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) {
1355
+			elseif (preg_match('#C\) (EST|PERM)$#', $line, $matches)) {
1356 1356
 				$result['date_end'] = '2030/12/20 12:00';
1357 1357
 				if ($matches[1] == 'EST') $result['estimated'] = 1;
1358 1358
 				else $result['estimated'] = 0;
1359 1359
 				if ($matches[1] == 'PERM') $result['permanent'] = 1;
1360 1360
 				else $result['permanent'] = 0;
1361 1361
 			}
1362
-			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
1362
+			elseif (preg_match('#E\) (.*)#', $line, $matches)) {
1363 1363
 				$rtext = array();
1364
-				$text = explode(' ',$matches[1]);
1364
+				$text = explode(' ', $matches[1]);
1365 1365
 				foreach ($text as $word) {
1366 1366
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1367
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1367
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
1368 1368
 					else $rtext[] = $word;
1369 1369
 				}
1370
-				$result['text'] = implode(' ',$rtext);
1370
+				$result['text'] = implode(' ', $rtext);
1371 1371
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1372 1372
 			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1373
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1374
-				$text = explode(' ',$line);
1373
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) {
1374
+				$text = explode(' ', $line);
1375 1375
 				$result['ref'] = $text[0];
1376 1376
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1377 1377
 				if ($matches[1] == 'NOTAMC') {
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -16,52 +16,52 @@  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
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32
-		foreach($filters as $flt) {
32
+		foreach ($filters as $flt) {
33 33
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 				if ($flt['airlines'][0] != '') {
35 35
 					if (isset($flt['source'])) {
36
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
36
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
37 37
 					} else {
38
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
38
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
39 39
 					}
40 40
 				}
41 41
 			}
42 42
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 				if (isset($flt['source'])) {
44
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
44
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
45 45
 				} else {
46
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
46
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
47 47
 				}
48 48
 			}
49 49
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 				if (isset($flt['source'])) {
51
-					$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";
51
+					$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";
52 52
 				} else {
53
-					$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";
53
+					$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";
54 54
 				}
55 55
 			}
56 56
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
57 57
 				if (isset($flt['source'])) {
58
-					$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";
58
+					$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";
59 59
 				}
60 60
 			}
61 61
 		}
62 62
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
63 63
 			if ($filter['airlines'][0] != '') {
64
-				$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";
64
+				$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";
65 65
 			}
66 66
 		}
67 67
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 			$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 ";
72 72
 		}
73 73
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
74
-			$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";
74
+			$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";
75 75
 		}
76 76
 		if (isset($filter['source']) && !empty($filter['source'])) {
77
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
77
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
78 78
 		}
79 79
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
80 80
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
104 104
 				}
105 105
 			}
106
-			$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";
106
+			$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";
107 107
 		}
108 108
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
109
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
109
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
110 110
 		}
111 111
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
112 112
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
113 113
 		if ($filter_query_where != '') {
114
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
114
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
115 115
 		}
116 116
 		$filter_query = $filter_query_join.$filter_query_where;
117 117
 		return $filter_query;
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		if ($limit != '')
135 135
 		{
136 136
 			$limit_array = explode(',', $limit);
137
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
138
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
137
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
138
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
139 139
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
140 140
 			{
141 141
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		} else {
159 159
 			$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;
160 160
 		}
161
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
161
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
162 162
 
163 163
 		return $spotter_array;
164 164
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		global $globalDBdriver, $globalLiveInterval;
175 175
 		date_default_timezone_set('UTC');
176 176
 
177
-		$filter_query = $this->getFilter($filter,true,true);
177
+		$filter_query = $this->getFilter($filter, true, true);
178 178
 
179 179
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
180 180
 		if ($globalDBdriver == 'mysql') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			$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 
186 186
 			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";
187 187
 */
188
-			$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 
188
+			$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 
189 189
 			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";
190 190
 
191 191
 //			$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;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			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'";
201 201
 */
202 202
 
203
-			$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 
203
+			$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 
204 204
 			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'";
205 205
 
206 206
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		try {
212 212
 			$sth = $this->db->prepare($query);
213 213
 			$sth->execute();
214
-		} catch(PDOException $e) {
214
+		} catch (PDOException $e) {
215 215
 			echo $e->getMessage();
216 216
 			die;
217 217
 		}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		global $globalDBdriver, $globalLiveInterval;
232 232
 		date_default_timezone_set('UTC');
233 233
 
234
-		$filter_query = $this->getFilter($filter,true,true);
234
+		$filter_query = $this->getFilter($filter, true, true);
235 235
 
236 236
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
237 237
 		if ($globalDBdriver == 'mysql') {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			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' 
241 241
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
242 242
 */
243
-			$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 
243
+			$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 
244 244
 			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' 
245 245
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
246 246
                 } else {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			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' 
250 250
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
251 251
 */
252
-			$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 
252
+			$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 253
 			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' 
254 254
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
255 255
 //			echo $query;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     		try {
259 259
 			$sth = $this->db->prepare($query);
260 260
 			$sth->execute();
261
-		} catch(PDOException $e) {
261
+		} catch (PDOException $e) {
262 262
 			echo $e->getMessage();
263 263
 			die;
264 264
 		}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	public function getLiveSpotterCount($filter = array())
276 276
 	{
277 277
 		global $globalDBdriver, $globalLiveInterval;
278
-		$filter_query = $this->getFilter($filter,true,true);
278
+		$filter_query = $this->getFilter($filter, true, true);
279 279
 
280 280
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
281 281
 		if ($globalDBdriver == 'mysql') {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		try {
289 289
 			$sth = $this->db->prepare($query);
290 290
 			$sth->execute();
291
-		} catch(PDOException $e) {
291
+		} catch (PDOException $e) {
292 292
 			echo $e->getMessage();
293 293
 			die;
294 294
 		}
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 		$filter_query = $this->getFilter($filter);
312 312
 
313 313
 		if (is_array($coord)) {
314
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
315
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
316
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
317
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
315
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
316
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
317
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
318 318
 		} else return array();
319 319
 		if ($globalDBdriver == 'mysql') {
320 320
 			//$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.")";
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
                 if ($interval == '1m')
368 368
                 {
369 369
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
370
-                } else if ($interval == '15m'){
370
+                } else if ($interval == '15m') {
371 371
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
372 372
                 } 
373 373
             }
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
376 376
         }
377 377
 
378
-                $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 
378
+                $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 
379 379
                    WHERE spotter_live.latitude <> '' 
380 380
                                    AND spotter_live.longitude <> '' 
381 381
                    ".$additional_query."
382 382
                    HAVING distance < :radius  
383 383
                                    ORDER BY distance";
384 384
 
385
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
385
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
386 386
 
387 387
                 return $spotter_array;
388 388
         }
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 		date_default_timezone_set('UTC');
401 401
 
402 402
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
403
-                $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';
403
+                $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';
404 404
 
405
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
405
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
406 406
 
407 407
 		return $spotter_array;
408 408
 	}
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 	* @return Array the spotter information
414 414
 	*
415 415
 	*/
416
-	public function getDateLiveSpotterDataByIdent($ident,$date)
416
+	public function getDateLiveSpotterDataByIdent($ident, $date)
417 417
 	{
418 418
 		$Spotter = new Spotter($this->db);
419 419
 		date_default_timezone_set('UTC');
420 420
 
421 421
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
422
-                $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';
422
+                $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';
423 423
 
424
-                $date = date('c',$date);
425
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
424
+                $date = date('c', $date);
425
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
426 426
 
427 427
 		return $spotter_array;
428 428
 	}
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 		date_default_timezone_set('UTC');
440 440
 
441 441
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
442
-                $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';
442
+                $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';
443 443
 
444
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
444
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
445 445
 
446 446
 		return $spotter_array;
447 447
 	}
@@ -452,15 +452,15 @@  discard block
 block discarded – undo
452 452
 	* @return Array the spotter information
453 453
 	*
454 454
 	*/
455
-	public function getDateLiveSpotterDataById($id,$date)
455
+	public function getDateLiveSpotterDataById($id, $date)
456 456
 	{
457 457
 		$Spotter = new Spotter($this->db);
458 458
 		date_default_timezone_set('UTC');
459 459
 
460 460
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
461
-                $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';
462
-                $date = date('c',$date);
463
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
461
+                $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';
462
+                $date = date('c', $date);
463
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
464 464
 
465 465
 		return $spotter_array;
466 466
 	}
@@ -477,13 +477,13 @@  discard block
 block discarded – undo
477 477
 		date_default_timezone_set('UTC');
478 478
 
479 479
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
480
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
480
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
481 481
 
482 482
     		try {
483 483
 			
484 484
 			$sth = $this->db->prepare($query);
485 485
 			$sth->execute(array(':ident' => $ident));
486
-		} catch(PDOException $e) {
486
+		} catch (PDOException $e) {
487 487
 			echo $e->getMessage();
488 488
 			die;
489 489
 		}
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 	* @return Array the spotter information
499 499
 	*
500 500
 	*/
501
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
501
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
502 502
 	{
503 503
 		global $globalDBdriver, $globalLiveInterval;
504 504
 		date_default_timezone_set('UTC');
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		try {
518 518
 			$sth = $this->db->prepare($query);
519 519
 			$sth->execute(array(':id' => $id));
520
-		} catch(PDOException $e) {
520
+		} catch (PDOException $e) {
521 521
 			echo $e->getMessage();
522 522
 			die;
523 523
 		}
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
 	{
536 536
 		date_default_timezone_set('UTC');
537 537
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
538
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
538
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
539 539
     		try {
540 540
 			
541 541
 			$sth = $this->db->prepare($query);
542 542
 			$sth->execute(array(':ident' => $ident));
543
-		} catch(PDOException $e) {
543
+		} catch (PDOException $e) {
544 544
 			echo $e->getMessage();
545 545
 			die;
546 546
 		}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 			
571 571
 			$sth = $this->db->prepare($query);
572 572
 			$sth->execute();
573
-		} catch(PDOException $e) {
573
+		} catch (PDOException $e) {
574 574
 			return "error";
575 575
 		}
576 576
 
@@ -593,14 +593,14 @@  discard block
 block discarded – undo
593 593
 				
594 594
 				$sth = $this->db->prepare($query);
595 595
 				$sth->execute();
596
-			} catch(PDOException $e) {
596
+			} catch (PDOException $e) {
597 597
 				return "error";
598 598
 			}
599 599
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
600 600
                         $i = 0;
601
-                        $j =0;
601
+                        $j = 0;
602 602
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
603
-			foreach($all as $row)
603
+			foreach ($all as $row)
604 604
 			{
605 605
 				$i++;
606 606
 				$j++;
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
 					if ($globalDebug) echo ".";
609 609
 				    	try {
610 610
 						
611
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
611
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
612 612
 						$sth->execute();
613
-					} catch(PDOException $e) {
613
+					} catch (PDOException $e) {
614 614
 						return "error";
615 615
 					}
616 616
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 			if ($i > 0) {
622 622
     				try {
623 623
 					
624
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
624
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
625 625
 					$sth->execute();
626
-				} catch(PDOException $e) {
626
+				} catch (PDOException $e) {
627 627
 					return "error";
628 628
 				}
629 629
 			}
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 				
637 637
 				$sth = $this->db->prepare($query);
638 638
 				$sth->execute();
639
-			} catch(PDOException $e) {
639
+			} catch (PDOException $e) {
640 640
 				return "error";
641 641
 			}
642 642
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
 	public function deleteLiveSpotterDataByIdent($ident)
685 685
 	{
686 686
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
687
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
687
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
688 688
         
689 689
     		try {
690 690
 			
691 691
 			$sth = $this->db->prepare($query);
692 692
 			$sth->execute(array(':ident' => $ident));
693
-		} catch(PDOException $e) {
693
+		} catch (PDOException $e) {
694 694
 			return "error";
695 695
 		}
696 696
 
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
 	public function deleteLiveSpotterDataById($id)
707 707
 	{
708 708
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
709
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
709
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
710 710
         
711 711
     		try {
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute(array(':id' => $id));
715
-		} catch(PDOException $e) {
715
+		} catch (PDOException $e) {
716 716
 			return "error";
717 717
 		}
718 718
 
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
 	{
731 731
 		global $globalDBdriver, $globalTimezone;
732 732
 		if ($globalDBdriver == 'mysql') {
733
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
733
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
734 734
 				WHERE spotter_live.ident = :ident 
735 735
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
736 736
 				AND spotter_live.date < UTC_TIMESTAMP()';
737 737
 			$query_data = array(':ident' => $ident);
738 738
 		} else {
739
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
739
+			$query = "SELECT spotter_live.ident FROM spotter_live 
740 740
 				WHERE spotter_live.ident = :ident 
741 741
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
742 742
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 		
746 746
 		$sth = $this->db->prepare($query);
747 747
 		$sth->execute($query_data);
748
-		$ident_result='';
749
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
748
+		$ident_result = '';
749
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
750 750
 		{
751 751
 			$ident_result = $row['ident'];
752 752
 		}
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 	{
764 764
 		global $globalDBdriver, $globalTimezone;
765 765
 		if ($globalDBdriver == 'mysql') {
766
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
766
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
767 767
 				WHERE spotter_live.ident = :ident 
768 768
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
769 769
 //				AND spotter_live.date < UTC_TIMESTAMP()";
770 770
 			$query_data = array(':ident' => $ident);
771 771
 		} else {
772
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
772
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
773 773
 				WHERE spotter_live.ident = :ident 
774 774
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
775 775
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -778,8 +778,8 @@  discard block
 block discarded – undo
778 778
 		
779 779
 		$sth = $this->db->prepare($query);
780 780
 		$sth->execute($query_data);
781
-		$ident_result='';
782
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
781
+		$ident_result = '';
782
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
783 783
 		{
784 784
 			$ident_result = $row['flightaware_id'];
785 785
 		}
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 	{
797 797
 		global $globalDBdriver, $globalTimezone;
798 798
 		if ($globalDBdriver == 'mysql') {
799
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
799
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
800 800
 				WHERE spotter_live.flightaware_id = :id 
801 801
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
802 802
 //				AND spotter_live.date < UTC_TIMESTAMP()";
803 803
 			$query_data = array(':id' => $id);
804 804
 		} else {
805
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
805
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
806 806
 				WHERE spotter_live.flightaware_id = :id 
807 807
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
808 808
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 		
812 812
 		$sth = $this->db->prepare($query);
813 813
 		$sth->execute($query_data);
814
-		$ident_result='';
815
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
814
+		$ident_result = '';
815
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
816 816
 		{
817 817
 			$ident_result = $row['flightaware_id'];
818 818
 		}
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
 	{
830 830
 		global $globalDBdriver, $globalTimezone;
831 831
 		if ($globalDBdriver == 'mysql') {
832
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
832
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
833 833
 				WHERE spotter_live.ModeS = :modes 
834 834
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
835 835
 //				AND spotter_live.date < UTC_TIMESTAMP()";
836 836
 			$query_data = array(':modes' => $modes);
837 837
 		} else {
838
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
838
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
839 839
 				WHERE spotter_live.ModeS = :modes 
840 840
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
841 841
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 		
845 845
 		$sth = $this->db->prepare($query);
846 846
 		$sth->execute($query_data);
847
-		$ident_result='';
848
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
847
+		$ident_result = '';
848
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
849 849
 		{
850 850
 			//$ident_result = $row['spotter_live_id'];
851 851
 			$ident_result = $row['flightaware_id'];
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	* @return String success or false
865 865
 	*
866 866
 	*/
867
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
867
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
868 868
 	{
869 869
 		global $globalURL, $globalArchive, $globalDebug;
870 870
 		$Common = new Common();
@@ -957,26 +957,26 @@  discard block
 block discarded – undo
957 957
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
958 958
 
959 959
         
960
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
961
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
962
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
963
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
964
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
965
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
966
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
967
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
968
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
969
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
970
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
971
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
972
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
973
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
974
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
975
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
976
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
977
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
978
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
979
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
960
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
961
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
962
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
963
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
964
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
965
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
966
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
967
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
968
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
969
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
970
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
971
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
972
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
973
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
974
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
975
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
976
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
977
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
978
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
979
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
980 980
 
981 981
 		$airline_name = '';
982 982
 		$airline_icao = '';
@@ -998,26 +998,26 @@  discard block
 block discarded – undo
998 998
 		$arrival_airport_country = '';
999 999
 		
1000 1000
             	
1001
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1002
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1003
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1004
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1001
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1002
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1003
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1004
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1005 1005
             	
1006
-		$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) 
1006
+		$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) 
1007 1007
 		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)';
1008 1008
 
1009
-		$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);
1009
+		$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);
1010 1010
 		try {
1011 1011
 			
1012 1012
 			$sth = $this->db->prepare($query);
1013 1013
 			$sth->execute($query_values);
1014
-                } catch(PDOException $e) {
1014
+                } catch (PDOException $e) {
1015 1015
                 	return "error : ".$e->getMessage();
1016 1016
                 }
1017 1017
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1018 1018
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1019 1019
 		    $SpotterArchive = new SpotterArchive($this->db);
1020
-		    $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);
1020
+		    $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);
1021 1021
 		    if ($globalDebug) echo $result.')';
1022 1022
 		}
1023 1023
 		return "success";
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 
1027 1027
 	public function getOrderBy()
1028 1028
 	{
1029
-		$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"));
1029
+		$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"));
1030 1030
 		return $orderby;
1031 1031
 	}
1032 1032
 
Please login to merge, or discard this patch.
require/class.Stats.php 3 patches
Indentation   +788 added lines, -788 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,109 +50,109 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
62
-        	if ($filter_name == '') {
63
-        		$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-        	} else {
65
-        		$query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'";
66
-        	}
67
-                 try {
68
-                        $sth = $this->db->prepare($query);
69
-                        $sth->execute();
70
-                } catch(PDOException $e) {
71
-                        return "error : ".$e->getMessage();
72
-                }
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62
+			if ($filter_name == '') {
63
+				$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+			} else {
65
+				$query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'";
66
+			}
67
+				 try {
68
+						$sth = $this->db->prepare($query);
69
+						$sth->execute();
70
+				} catch(PDOException $e) {
71
+						return "error : ".$e->getMessage();
72
+				}
73 73
                 
74
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
75
-                 try {
76
-                        $sth = $this->db->prepare($query);
77
-                        $sth->execute(array(':filter_name' => $filter_name));
78
-                } catch(PDOException $e) {
79
-                        return "error : ".$e->getMessage();
80
-                }
81
-        }
74
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
75
+				 try {
76
+						$sth = $this->db->prepare($query);
77
+						$sth->execute(array(':filter_name' => $filter_name));
78
+				} catch(PDOException $e) {
79
+						return "error : ".$e->getMessage();
80
+				}
81
+		}
82 82
 	public function getAllAirlineNames($filter_name = '') {
83 83
 		if ($filter_name == '') $filter_name = $this->filter_name;
84
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
85
-                 try {
86
-                        $sth = $this->db->prepare($query);
87
-                        $sth->execute(array(':filter_name' => $filter_name));
88
-                } catch(PDOException $e) {
89
-                        echo "error : ".$e->getMessage();
90
-                }
91
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
92
-                return $all;
93
-        }
84
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
85
+				 try {
86
+						$sth = $this->db->prepare($query);
87
+						$sth->execute(array(':filter_name' => $filter_name));
88
+				} catch(PDOException $e) {
89
+						echo "error : ".$e->getMessage();
90
+				}
91
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
92
+				return $all;
93
+		}
94 94
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
95 95
 		if ($filter_name == '') $filter_name = $this->filter_name;
96
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
97
-                 try {
98
-                        $sth = $this->db->prepare($query);
99
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
100
-                } catch(PDOException $e) {
101
-                        echo "error : ".$e->getMessage();
102
-                }
103
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
104
-                return $all;
105
-        }
96
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
97
+				 try {
98
+						$sth = $this->db->prepare($query);
99
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
100
+				} catch(PDOException $e) {
101
+						echo "error : ".$e->getMessage();
102
+				}
103
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
104
+				return $all;
105
+		}
106 106
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
107 107
 		if ($filter_name == '') $filter_name = $this->filter_name;
108
-                $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
109
-                 try {
110
-                        $sth = $this->db->prepare($query);
111
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
112
-                } catch(PDOException $e) {
113
-                        echo "error : ".$e->getMessage();
114
-                }
115
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
116
-                return $all;
117
-        }
108
+				$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
109
+				 try {
110
+						$sth = $this->db->prepare($query);
111
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
112
+				} catch(PDOException $e) {
113
+						echo "error : ".$e->getMessage();
114
+				}
115
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
116
+				return $all;
117
+		}
118 118
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
119 119
 		if ($filter_name == '') $filter_name = $this->filter_name;
120
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
121
-                 try {
122
-                        $sth = $this->db->prepare($query);
123
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
124
-                } catch(PDOException $e) {
125
-                        echo "error : ".$e->getMessage();
126
-                }
127
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
128
-                return $all;
129
-        }
120
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
121
+				 try {
122
+						$sth = $this->db->prepare($query);
123
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
124
+				} catch(PDOException $e) {
125
+						echo "error : ".$e->getMessage();
126
+				}
127
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
128
+				return $all;
129
+		}
130 130
 
131 131
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
132 132
 		if ($filter_name == '') $filter_name = $this->filter_name;
133
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
134
-                 try {
135
-                        $sth = $this->db->prepare($query);
136
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
-                } catch(PDOException $e) {
138
-                        echo "error : ".$e->getMessage();
139
-                }
140
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
141
-                return $all;
142
-        }
133
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
134
+				 try {
135
+						$sth = $this->db->prepare($query);
136
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
+				} catch(PDOException $e) {
138
+						echo "error : ".$e->getMessage();
139
+				}
140
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
141
+				return $all;
142
+		}
143 143
 
144 144
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
145 145
 		if ($filter_name == '') $filter_name = $this->filter_name;
146
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
147
-                 try {
148
-                        $sth = $this->db->prepare($query);
149
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
150
-                } catch(PDOException $e) {
151
-                        echo "error : ".$e->getMessage();
152
-                }
153
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
154
-                return $all;
155
-        }
146
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
147
+				 try {
148
+						$sth = $this->db->prepare($query);
149
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
150
+				} catch(PDOException $e) {
151
+						echo "error : ".$e->getMessage();
152
+				}
153
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
154
+				return $all;
155
+		}
156 156
 
157 157
 
158 158
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 			}
170 170
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
171 171
 		} else $all = array();
172
-                if (empty($all)) {
173
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174
-            	    if ($filter_name != '') {
175
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
176
-            	    }
177
-            	    $Spotter = new Spotter($this->db);
178
-            	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
179
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
180
-                }
181
-                return $all;
172
+				if (empty($all)) {
173
+					$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174
+					if ($filter_name != '') {
175
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
176
+					}
177
+					$Spotter = new Spotter($this->db);
178
+					//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
179
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
180
+				}
181
+				return $all;
182 182
 	}
183 183
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
184 184
 		global $globalStatsFilters;
@@ -194,17 +194,17 @@  discard block
 block discarded – undo
194 194
 			}
195 195
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
196 196
 		} else $all = array();
197
-                if (empty($all)) {
198
-            		$Spotter = new Spotter($this->db);
199
-            		$filters = array();
200
-            		$filters = array('year' => $year,'month' => $month);
201
-            		if ($filter_name != '') {
202
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
203
-			}
204
-            		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
205
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
206
-                }
207
-                return $all;
197
+				if (empty($all)) {
198
+					$Spotter = new Spotter($this->db);
199
+					$filters = array();
200
+					$filters = array('year' => $year,'month' => $month);
201
+					if ($filter_name != '') {
202
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
203
+			}
204
+					//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
205
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
206
+				}
207
+				return $all;
208 208
 	}
209 209
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
210 210
 		global $globalStatsFilters;
@@ -246,39 +246,39 @@  discard block
 block discarded – undo
246 246
 			}
247 247
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
248 248
 		} else $all = array();
249
-                if (empty($all)) {
249
+				if (empty($all)) {
250 250
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
251 251
 			if ($filter_name != '') {
252
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
252
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253 253
 			}
254 254
 			$Spotter = new Spotter($this->db);
255 255
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
256 256
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
257
-                }
258
-                return $all;
257
+				}
258
+				return $all;
259 259
 	}
260 260
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
261 261
 		global $globalStatsFilters;
262 262
 		if ($filter_name == '') $filter_name = $this->filter_name;
263 263
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
264 264
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
265
-                 try {
266
-                        $sth = $this->db->prepare($query);
267
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
268
-                } catch(PDOException $e) {
269
-                        echo "error : ".$e->getMessage();
270
-                }
271
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
272
-                if (empty($all)) {
265
+				 try {
266
+						$sth = $this->db->prepare($query);
267
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
268
+				} catch(PDOException $e) {
269
+						echo "error : ".$e->getMessage();
270
+				}
271
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
272
+				if (empty($all)) {
273 273
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
274 274
 			if ($filter_name != '') {
275
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
275
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
276 276
 			}
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
279 279
 			$all = $Spotter->countAllDepartureCountries($filters);
280
-                }
281
-                return $all;
280
+				}
281
+				return $all;
282 282
 	}
283 283
 
284 284
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
 			}
305 305
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
306 306
 		} else $all = array();
307
-                if (empty($all)) {
308
-	                $Spotter = new Spotter($this->db);
309
-            		$filters = array();
307
+				if (empty($all)) {
308
+					$Spotter = new Spotter($this->db);
309
+					$filters = array();
310 310
 			$filters = array('year' => $year,'month' => $month);
311
-            		if ($filter_name != '') {
312
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
311
+					if ($filter_name != '') {
312
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313 313
 			}
314 314
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
315
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
316
-                }
317
-                return $all;
315
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
316
+				}
317
+				return $all;
318 318
 	}
319 319
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
320 320
 		global $globalStatsFilters;
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
 			}
331 331
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
332 332
 		} else $all = array();
333
-                if (empty($all)) {
333
+				if (empty($all)) {
334 334
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335 335
 			if ($filter_name != '') {
336 336
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
337 337
 			}
338
-	                $Spotter = new Spotter($this->db);
339
-    		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
340
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
341
-                }
342
-                return $all;
338
+					$Spotter = new Spotter($this->db);
339
+					//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
340
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
341
+				}
342
+				return $all;
343 343
 	}
344 344
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
345 345
 		global $globalStatsFilters;
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 					echo "error : ".$e->getMessage();
381 381
 				}
382 382
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
383
-                /*
383
+				/*
384 384
                 if (empty($all)) {
385 385
 	                $Spotter = new Spotter($this->db);
386 386
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -432,16 +432,16 @@  discard block
 block discarded – undo
432 432
 			}
433 433
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434 434
 		} else $all = array();
435
-                if (empty($all)) {
435
+				if (empty($all)) {
436 436
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
437 437
 			if ($filter_name != '') {
438 438
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
439 439
 			}
440
-            		$Spotter = new Spotter($this->db);
441
-            		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
442
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
443
-                }
444
-                return $all;
440
+					$Spotter = new Spotter($this->db);
441
+					//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
442
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
443
+				}
444
+				return $all;
445 445
 	}
446 446
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447 447
 		global $globalStatsFilters;
@@ -457,35 +457,35 @@  discard block
 block discarded – undo
457 457
 			}
458 458
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
459 459
 		} else $all = array();
460
-                if (empty($all)) {
460
+				if (empty($all)) {
461 461
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
462
-            		if ($filter_name != '') {
463
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
462
+					if ($filter_name != '') {
463
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
464 464
 			}
465
-            		$Spotter = new Spotter($this->db);
465
+					$Spotter = new Spotter($this->db);
466 466
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
467 467
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
468
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
469
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
470
-        		$all = array();
471
-        		foreach ($pall as $value) {
472
-        			$icao = $value['airport_departure_icao'];
473
-        			$all[$icao] = $value;
474
-        		}
468
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
469
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
470
+				$all = array();
471
+				foreach ($pall as $value) {
472
+					$icao = $value['airport_departure_icao'];
473
+					$all[$icao] = $value;
474
+				}
475 475
         		
476
-        		foreach ($dall as $value) {
477
-        			$icao = $value['airport_departure_icao'];
478
-        			if (isset($all[$icao])) {
479
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
480
-        			} else $all[$icao] = $value;
481
-        		}
482
-        		$count = array();
483
-        		foreach ($all as $key => $row) {
484
-        			$count[$key] = $row['airport_departure_icao_count'];
485
-        		}
486
-        		array_multisort($count,SORT_DESC,$all);
487
-                }
488
-                return $all;
476
+				foreach ($dall as $value) {
477
+					$icao = $value['airport_departure_icao'];
478
+					if (isset($all[$icao])) {
479
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
480
+					} else $all[$icao] = $value;
481
+				}
482
+				$count = array();
483
+				foreach ($all as $key => $row) {
484
+					$count[$key] = $row['airport_departure_icao_count'];
485
+				}
486
+				array_multisort($count,SORT_DESC,$all);
487
+				}
488
+				return $all;
489 489
 	}
490 490
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
491 491
 		global $globalStatsFilters;
@@ -511,26 +511,26 @@  discard block
 block discarded – undo
511 511
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
512 512
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
513 513
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
514
-        		$all = array();
515
-        		foreach ($pall as $value) {
516
-        			$icao = $value['airport_arrival_icao'];
517
-        			$all[$icao] = $value;
518
-        		}
514
+				$all = array();
515
+				foreach ($pall as $value) {
516
+					$icao = $value['airport_arrival_icao'];
517
+					$all[$icao] = $value;
518
+				}
519 519
         		
520
-        		foreach ($dall as $value) {
521
-        			$icao = $value['airport_arrival_icao'];
522
-        			if (isset($all[$icao])) {
523
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
524
-        			} else $all[$icao] = $value;
525
-        		}
526
-        		$count = array();
527
-        		foreach ($all as $key => $row) {
528
-        			$count[$key] = $row['airport_arrival_icao_count'];
529
-        		}
530
-        		array_multisort($count,SORT_DESC,$all);
531
-                }
520
+				foreach ($dall as $value) {
521
+					$icao = $value['airport_arrival_icao'];
522
+					if (isset($all[$icao])) {
523
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
524
+					} else $all[$icao] = $value;
525
+				}
526
+				$count = array();
527
+				foreach ($all as $key => $row) {
528
+					$count[$key] = $row['airport_arrival_icao_count'];
529
+				}
530
+				array_multisort($count,SORT_DESC,$all);
531
+				}
532 532
  
533
-                return $all;
533
+				return $all;
534 534
 	}
535 535
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
536 536
 		global $globalDBdriver, $globalStatsFilters;
@@ -543,23 +543,23 @@  discard block
 block discarded – undo
543 543
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
544 544
 		}
545 545
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
546
-                 try {
547
-                        $sth = $this->db->prepare($query);
548
-                        $sth->execute($query_data);
549
-                } catch(PDOException $e) {
550
-                        echo "error : ".$e->getMessage();
551
-                }
552
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
553
-                if (empty($all)) {
546
+				 try {
547
+						$sth = $this->db->prepare($query);
548
+						$sth->execute($query_data);
549
+				} catch(PDOException $e) {
550
+						echo "error : ".$e->getMessage();
551
+				}
552
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
553
+				if (empty($all)) {
554 554
 			$filters = array('airlines' => array($stats_airline));
555 555
 			if ($filter_name != '') {
556 556
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
557 557
 			}
558
-            		$Spotter = new Spotter($this->db);
559
-            		$all = $Spotter->countAllMonthsLastYear($filters);
560
-                }
558
+					$Spotter = new Spotter($this->db);
559
+					$all = $Spotter->countAllMonthsLastYear($filters);
560
+				}
561 561
                 
562
-                return $all;
562
+				return $all;
563 563
 	}
564 564
 	
565 565
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -567,22 +567,22 @@  discard block
 block discarded – undo
567 567
 		if ($filter_name == '') $filter_name = $this->filter_name;
568 568
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
569 569
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
570
-                 try {
571
-                        $sth = $this->db->prepare($query);
572
-                        $sth->execute($query_data);
573
-                } catch(PDOException $e) {
574
-                        echo "error : ".$e->getMessage();
575
-                }
576
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
577
-                if (empty($all)) {
570
+				 try {
571
+						$sth = $this->db->prepare($query);
572
+						$sth->execute($query_data);
573
+				} catch(PDOException $e) {
574
+						echo "error : ".$e->getMessage();
575
+				}
576
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
577
+				if (empty($all)) {
578 578
 			$filters = array('airlines' => array($stats_airline));
579 579
 			if ($filter_name != '') {
580 580
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
581 581
 			}
582
-            		$Spotter = new Spotter($this->db);
583
-            		$all = $Spotter->countAllDatesLastMonth($filters);
584
-                }
585
-                return $all;
582
+					$Spotter = new Spotter($this->db);
583
+					$all = $Spotter->countAllDatesLastMonth($filters);
584
+				}
585
+				return $all;
586 586
 	}
587 587
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
588 588
 		global $globalDBdriver, $globalStatsFilters;
@@ -593,110 +593,110 @@  discard block
 block discarded – undo
593 593
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
594 594
 		}
595 595
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
596
-                 try {
597
-                        $sth = $this->db->prepare($query);
598
-                        $sth->execute($query_data);
599
-                } catch(PDOException $e) {
600
-                        echo "error : ".$e->getMessage();
601
-                }
602
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
603
-                if (empty($all)) {
596
+				 try {
597
+						$sth = $this->db->prepare($query);
598
+						$sth->execute($query_data);
599
+				} catch(PDOException $e) {
600
+						echo "error : ".$e->getMessage();
601
+				}
602
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
603
+				if (empty($all)) {
604 604
 			$filters = array('airlines' => array($stats_airline));
605 605
 			if ($filter_name != '') {
606 606
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
607 607
 			}
608
-            		$Spotter = new Spotter($this->db);
609
-            		$all = $Spotter->countAllDatesLast7Days($filters);
610
-                }
611
-                return $all;
608
+					$Spotter = new Spotter($this->db);
609
+					$all = $Spotter->countAllDatesLast7Days($filters);
610
+				}
611
+				return $all;
612 612
 	}
613 613
 	public function countAllDates($stats_airline = '',$filter_name = '') {
614 614
 		global $globalStatsFilters;
615 615
 		if ($filter_name == '') $filter_name = $this->filter_name;
616 616
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
617 617
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
618
-                 try {
619
-                        $sth = $this->db->prepare($query);
620
-                        $sth->execute($query_data);
621
-                } catch(PDOException $e) {
622
-                        echo "error : ".$e->getMessage();
623
-                }
624
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
625
-                if (empty($all)) {
618
+				 try {
619
+						$sth = $this->db->prepare($query);
620
+						$sth->execute($query_data);
621
+				} catch(PDOException $e) {
622
+						echo "error : ".$e->getMessage();
623
+				}
624
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
625
+				if (empty($all)) {
626 626
 			$filters = array('airlines' => array($stats_airline));
627 627
 			if ($filter_name != '') {
628
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
628
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
629 629
 			}
630
-            		$Spotter = new Spotter($this->db);
631
-            		$all = $Spotter->countAllDates($filters);
632
-                }
633
-                return $all;
630
+					$Spotter = new Spotter($this->db);
631
+					$all = $Spotter->countAllDates($filters);
632
+				}
633
+				return $all;
634 634
 	}
635 635
 	public function countAllDatesByAirlines($filter_name = '') {
636 636
 		global $globalStatsFilters;
637 637
 		if ($filter_name == '') $filter_name = $this->filter_name;
638 638
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
639 639
 		$query_data = array('filter_name' => $filter_name);
640
-                 try {
641
-                        $sth = $this->db->prepare($query);
642
-                        $sth->execute($query_data);
643
-                } catch(PDOException $e) {
644
-                        echo "error : ".$e->getMessage();
645
-                }
646
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
647
-                if (empty($all)) {
648
-            		$filters = array();
649
-            		if ($filter_name != '') {
650
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
640
+				 try {
641
+						$sth = $this->db->prepare($query);
642
+						$sth->execute($query_data);
643
+				} catch(PDOException $e) {
644
+						echo "error : ".$e->getMessage();
645
+				}
646
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
647
+				if (empty($all)) {
648
+					$filters = array();
649
+					if ($filter_name != '') {
650
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
651 651
 			}
652
-            		$Spotter = new Spotter($this->db);
653
-            		$all = $Spotter->countAllDatesByAirlines($filters);
654
-                }
655
-                return $all;
652
+					$Spotter = new Spotter($this->db);
653
+					$all = $Spotter->countAllDatesByAirlines($filters);
654
+				}
655
+				return $all;
656 656
 	}
657 657
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
658 658
 		global $globalStatsFilters;
659 659
 		if ($filter_name == '') $filter_name = $this->filter_name;
660
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661
-                 try {
662
-                        $sth = $this->db->prepare($query);
663
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
664
-                } catch(PDOException $e) {
665
-                        echo "error : ".$e->getMessage();
666
-                }
667
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
660
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661
+				 try {
662
+						$sth = $this->db->prepare($query);
663
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
664
+				} catch(PDOException $e) {
665
+						echo "error : ".$e->getMessage();
666
+				}
667
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
668 668
                 
669
-                if (empty($all)) {
669
+				if (empty($all)) {
670 670
 			$filters = array('airlines' => array($stats_airline));
671 671
 			if ($filter_name != '') {
672 672
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
673 673
 			}
674
-            		$Spotter = new Spotter($this->db);
675
-            		$all = $Spotter->countAllMonths($filters);
676
-                }
674
+					$Spotter = new Spotter($this->db);
675
+					$all = $Spotter->countAllMonths($filters);
676
+				}
677 677
                 
678
-                return $all;
678
+				return $all;
679 679
 	}
680 680
 	public function countAllMilitaryMonths($filter_name = '') {
681 681
 		global $globalStatsFilters;
682 682
 		if ($filter_name == '') $filter_name = $this->filter_name;
683
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
684
-                 try {
685
-                        $sth = $this->db->prepare($query);
686
-                        $sth->execute(array(':filter_name' => $filter_name));
687
-                } catch(PDOException $e) {
688
-                        echo "error : ".$e->getMessage();
689
-                }
690
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
691
-                if (empty($all)) {
692
-            		$filters = array();
693
-            		if ($filter_name != '') {
694
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
683
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
684
+				 try {
685
+						$sth = $this->db->prepare($query);
686
+						$sth->execute(array(':filter_name' => $filter_name));
687
+				} catch(PDOException $e) {
688
+						echo "error : ".$e->getMessage();
689
+				}
690
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
691
+				if (empty($all)) {
692
+					$filters = array();
693
+					if ($filter_name != '') {
694
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
695 695
 			}
696
-            		$Spotter = new Spotter($this->db);
697
-            		$all = $Spotter->countAllMilitaryMonths($filters);
698
-                }
699
-                return $all;
696
+					$Spotter = new Spotter($this->db);
697
+					$all = $Spotter->countAllMilitaryMonths($filters);
698
+				}
699
+				return $all;
700 700
 	}
701 701
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
702 702
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -712,22 +712,22 @@  discard block
 block discarded – undo
712 712
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
713 713
 		}
714 714
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
715
-                 try {
716
-                        $sth = $this->db->prepare($query);
717
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
718
-                } catch(PDOException $e) {
719
-                        echo "error : ".$e->getMessage();
720
-                }
721
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
722
-                if (empty($all)) {
715
+				 try {
716
+						$sth = $this->db->prepare($query);
717
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
718
+				} catch(PDOException $e) {
719
+						echo "error : ".$e->getMessage();
720
+				}
721
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
722
+				if (empty($all)) {
723 723
 			$filters = array('airlines' => array($stats_airline));
724 724
 			if ($filter_name != '') {
725
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
725
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
726 726
 			}
727
-            		$Spotter = new Spotter($this->db);
728
-            		$all = $Spotter->countAllHours($orderby,$filters);
729
-                }
730
-                return $all;
727
+					$Spotter = new Spotter($this->db);
728
+					$all = $Spotter->countAllHours($orderby,$filters);
729
+				}
730
+				return $all;
731 731
 	}
732 732
 	
733 733
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -752,10 +752,10 @@  discard block
 block discarded – undo
752 752
 		if ($year == '') $year = date('Y');
753 753
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
754 754
 		if (empty($all)) {
755
-		        $filters = array();
755
+				$filters = array();
756 756
 			$filters = array('year' => $year,'month' => $month);
757
-            		if ($filter_name != '') {
758
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
757
+					if ($filter_name != '') {
758
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
759 759
 			}
760 760
 			$Spotter = new Spotter($this->db);
761 761
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -819,10 +819,10 @@  discard block
 block discarded – undo
819 819
 			$all = $result[0]['nb_airline'];
820 820
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
821 821
 		if (empty($all)) {
822
-            		$filters = array();
822
+					$filters = array();
823 823
 			$filters = array('year' => $year,'month' => $month);
824
-            		if ($filter_name != '') {
825
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
824
+					if ($filter_name != '') {
825
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
826 826
 			}
827 827
 			$Spotter = new Spotter($this->db);
828 828
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -892,33 +892,33 @@  discard block
 block discarded – undo
892 892
 		if ($filter_name == '') $filter_name = $this->filter_name;
893 893
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
894 894
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
895
-                 try {
896
-                        $sth = $this->db->prepare($query);
897
-                        $sth->execute($query_values);
898
-                } catch(PDOException $e) {
899
-                        echo "error : ".$e->getMessage();
900
-                }
901
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
902
-                return $all;
895
+				 try {
896
+						$sth = $this->db->prepare($query);
897
+						$sth->execute($query_values);
898
+				} catch(PDOException $e) {
899
+						echo "error : ".$e->getMessage();
900
+				}
901
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
902
+				return $all;
903 903
 	}
904 904
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
905 905
 		if ($filter_name == '') $filter_name = $this->filter_name;
906
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
907
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
908
-                 try {
909
-                        $sth = $this->db->prepare($query);
910
-                        $sth->execute($query_values);
911
-                } catch(PDOException $e) {
912
-                        echo "error : ".$e->getMessage();
913
-                }
914
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
915
-                return $all;
916
-        }
906
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
907
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
908
+				 try {
909
+						$sth = $this->db->prepare($query);
910
+						$sth->execute($query_values);
911
+				} catch(PDOException $e) {
912
+						echo "error : ".$e->getMessage();
913
+				}
914
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
915
+				return $all;
916
+		}
917 917
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
918 918
 		if ($filter_name == '') $filter_name = $this->filter_name;
919
-    		global $globalArchiveMonths, $globalDBdriver;
920
-    		if ($globalDBdriver == 'mysql') {
921
-    			if ($month == '') {
919
+			global $globalArchiveMonths, $globalDBdriver;
920
+			if ($globalDBdriver == 'mysql') {
921
+				if ($month == '') {
922 922
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
923 923
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
924 924
 			} else {
@@ -933,165 +933,165 @@  discard block
 block discarded – undo
933 933
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
934 934
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
935 935
 			}
936
-                }
937
-                 try {
938
-                        $sth = $this->db->prepare($query);
939
-                        $sth->execute($query_values);
940
-                } catch(PDOException $e) {
941
-                        echo "error : ".$e->getMessage();
942
-                }
943
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
944
-                return $all[0]['total'];
945
-        }
936
+				}
937
+				 try {
938
+						$sth = $this->db->prepare($query);
939
+						$sth->execute($query_values);
940
+				} catch(PDOException $e) {
941
+						echo "error : ".$e->getMessage();
942
+				}
943
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
944
+				return $all[0]['total'];
945
+		}
946 946
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
947
-    		global $globalArchiveMonths, $globalDBdriver;
947
+			global $globalArchiveMonths, $globalDBdriver;
948 948
 		if ($filter_name == '') $filter_name = $this->filter_name;
949
-    		if ($globalDBdriver == 'mysql') {
949
+			if ($globalDBdriver == 'mysql') {
950 950
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
951 951
 		} else {
952 952
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
953
-                }
954
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
955
-                 try {
956
-                        $sth = $this->db->prepare($query);
957
-                        $sth->execute($query_values);
958
-                } catch(PDOException $e) {
959
-                        echo "error : ".$e->getMessage();
960
-                }
961
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962
-                return $all[0]['total'];
963
-        }
953
+				}
954
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
955
+				 try {
956
+						$sth = $this->db->prepare($query);
957
+						$sth->execute($query_values);
958
+				} catch(PDOException $e) {
959
+						echo "error : ".$e->getMessage();
960
+				}
961
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
962
+				return $all[0]['total'];
963
+		}
964 964
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
965
-    		global $globalArchiveMonths, $globalDBdriver;
965
+			global $globalArchiveMonths, $globalDBdriver;
966 966
 		if ($filter_name == '') $filter_name = $this->filter_name;
967
-    		if ($globalDBdriver == 'mysql') {
967
+			if ($globalDBdriver == 'mysql') {
968 968
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
969
-                } else {
969
+				} else {
970 970
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
971
-                }
972
-                 try {
973
-                        $sth = $this->db->prepare($query);
974
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
975
-                } catch(PDOException $e) {
976
-                        echo "error : ".$e->getMessage();
977
-                }
978
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
979
-                return $all[0]['total'];
980
-        }
971
+				}
972
+				 try {
973
+						$sth = $this->db->prepare($query);
974
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
975
+				} catch(PDOException $e) {
976
+						echo "error : ".$e->getMessage();
977
+				}
978
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
979
+				return $all[0]['total'];
980
+		}
981 981
 	public function getStatsAirlineTotal($filter_name = '') {
982
-    		global $globalArchiveMonths, $globalDBdriver;
982
+			global $globalArchiveMonths, $globalDBdriver;
983 983
 		if ($filter_name == '') $filter_name = $this->filter_name;
984
-    		if ($globalDBdriver == 'mysql') {
984
+			if ($globalDBdriver == 'mysql') {
985 985
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
986
-                } else {
986
+				} else {
987 987
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
988
-                }
989
-                 try {
990
-                        $sth = $this->db->prepare($query);
991
-                        $sth->execute(array(':filter_name' => $filter_name));
992
-                } catch(PDOException $e) {
993
-                        echo "error : ".$e->getMessage();
994
-                }
995
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
996
-                return $all[0]['total'];
997
-        }
988
+				}
989
+				 try {
990
+						$sth = $this->db->prepare($query);
991
+						$sth->execute(array(':filter_name' => $filter_name));
992
+				} catch(PDOException $e) {
993
+						echo "error : ".$e->getMessage();
994
+				}
995
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
996
+				return $all[0]['total'];
997
+		}
998 998
 	public function getStatsOwnerTotal($filter_name = '') {
999
-    		global $globalArchiveMonths, $globalDBdriver;
999
+			global $globalArchiveMonths, $globalDBdriver;
1000 1000
 		if ($filter_name == '') $filter_name = $this->filter_name;
1001
-    		if ($globalDBdriver == 'mysql') {
1001
+			if ($globalDBdriver == 'mysql') {
1002 1002
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1003 1003
 		} else {
1004 1004
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1005
-                }
1006
-                 try {
1007
-                        $sth = $this->db->prepare($query);
1008
-                        $sth->execute(array(':filter_name' => $filter_name));
1009
-                } catch(PDOException $e) {
1010
-                        echo "error : ".$e->getMessage();
1011
-                }
1012
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1013
-                return $all[0]['total'];
1014
-        }
1005
+				}
1006
+				 try {
1007
+						$sth = $this->db->prepare($query);
1008
+						$sth->execute(array(':filter_name' => $filter_name));
1009
+				} catch(PDOException $e) {
1010
+						echo "error : ".$e->getMessage();
1011
+				}
1012
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1013
+				return $all[0]['total'];
1014
+		}
1015 1015
 	public function getStatsOwner($owner_name,$filter_name = '') {
1016
-    		global $globalArchiveMonths, $globalDBdriver;
1016
+			global $globalArchiveMonths, $globalDBdriver;
1017 1017
 		if ($filter_name == '') $filter_name = $this->filter_name;
1018 1018
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1019
-                 try {
1020
-                        $sth = $this->db->prepare($query);
1021
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1022
-                } catch(PDOException $e) {
1023
-                        echo "error : ".$e->getMessage();
1024
-                }
1025
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1026
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1027
-                else return 0;
1028
-        }
1019
+				 try {
1020
+						$sth = $this->db->prepare($query);
1021
+						$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1022
+				} catch(PDOException $e) {
1023
+						echo "error : ".$e->getMessage();
1024
+				}
1025
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1026
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1027
+				else return 0;
1028
+		}
1029 1029
 	public function getStatsPilotTotal($filter_name = '') {
1030
-    		global $globalArchiveMonths, $globalDBdriver;
1030
+			global $globalArchiveMonths, $globalDBdriver;
1031 1031
 		if ($filter_name == '') $filter_name = $this->filter_name;
1032
-    		if ($globalDBdriver == 'mysql') {
1033
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1034
-            	} else {
1035
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1036
-            	}
1037
-                 try {
1038
-                        $sth = $this->db->prepare($query);
1039
-                        $sth->execute(array(':filter_name' => $filter_name));
1040
-                } catch(PDOException $e) {
1041
-                        echo "error : ".$e->getMessage();
1042
-                }
1043
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1044
-                return $all[0]['total'];
1045
-        }
1032
+			if ($globalDBdriver == 'mysql') {
1033
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1034
+				} else {
1035
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1036
+				}
1037
+				 try {
1038
+						$sth = $this->db->prepare($query);
1039
+						$sth->execute(array(':filter_name' => $filter_name));
1040
+				} catch(PDOException $e) {
1041
+						echo "error : ".$e->getMessage();
1042
+				}
1043
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1044
+				return $all[0]['total'];
1045
+		}
1046 1046
 	public function getStatsPilot($pilot,$filter_name = '') {
1047
-    		global $globalArchiveMonths, $globalDBdriver;
1047
+			global $globalArchiveMonths, $globalDBdriver;
1048 1048
 		if ($filter_name == '') $filter_name = $this->filter_name;
1049 1049
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1050
-                 try {
1051
-                        $sth = $this->db->prepare($query);
1052
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1053
-                } catch(PDOException $e) {
1054
-                        echo "error : ".$e->getMessage();
1055
-                }
1056
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1057
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1058
-                else return 0;
1059
-        }
1050
+				 try {
1051
+						$sth = $this->db->prepare($query);
1052
+						$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1053
+				} catch(PDOException $e) {
1054
+						echo "error : ".$e->getMessage();
1055
+				}
1056
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1057
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1058
+				else return 0;
1059
+		}
1060 1060
 
1061 1061
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1062 1062
 		global $globalDBdriver;
1063 1063
 		if ($filter_name == '') $filter_name = $this->filter_name;
1064 1064
 		if ($globalDBdriver == 'mysql') {
1065 1065
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1066
-                } else {
1066
+				} else {
1067 1067
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1068 1068
 		}
1069
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1070
-                 try {
1071
-                        $sth = $this->db->prepare($query);
1072
-                        $sth->execute($query_values);
1073
-                } catch(PDOException $e) {
1074
-                        return "error : ".$e->getMessage();
1075
-                }
1076
-        }
1069
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1070
+				 try {
1071
+						$sth = $this->db->prepare($query);
1072
+						$sth->execute($query_values);
1073
+				} catch(PDOException $e) {
1074
+						return "error : ".$e->getMessage();
1075
+				}
1076
+		}
1077 1077
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1078 1078
 		global $globalDBdriver;
1079 1079
 		if ($filter_name == '') $filter_name = $this->filter_name;
1080 1080
 		if ($globalDBdriver == 'mysql') {
1081 1081
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1082 1082
 		} else {
1083
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1083
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1084 1084
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1085
-                }
1086
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1087
-                 try {
1088
-                        $sth = $this->db->prepare($query);
1089
-                        $sth->execute($query_values);
1090
-                } catch(PDOException $e) {
1091
-                        return "error : ".$e->getMessage();
1092
-                }
1093
-        }
1094
-        /*
1085
+				}
1086
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1087
+				 try {
1088
+						$sth = $this->db->prepare($query);
1089
+						$sth->execute($query_values);
1090
+				} catch(PDOException $e) {
1091
+						return "error : ".$e->getMessage();
1092
+				}
1093
+		}
1094
+		/*
1095 1095
 	public function getStatsSource($date,$stats_type = '') {
1096 1096
 		if ($stats_type == '') {
1097 1097
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1160,25 +1160,25 @@  discard block
 block discarded – undo
1160 1160
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1161 1161
 		} else {
1162 1162
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1163
-                }
1164
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1165
-                 try {
1166
-                        $sth = $this->db->prepare($query);
1167
-                        $sth->execute($query_values);
1168
-                } catch(PDOException $e) {
1169
-                        return "error : ".$e->getMessage();
1170
-                }
1171
-        }
1172
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1173
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1174
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1175
-                 try {
1176
-                        $sth = $this->db->prepare($query);
1177
-                        $sth->execute($query_values);
1178
-                } catch(PDOException $e) {
1179
-                        return "error : ".$e->getMessage();
1180
-                }
1181
-        }
1163
+				}
1164
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1165
+				 try {
1166
+						$sth = $this->db->prepare($query);
1167
+						$sth->execute($query_values);
1168
+				} catch(PDOException $e) {
1169
+						return "error : ".$e->getMessage();
1170
+				}
1171
+		}
1172
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1173
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1174
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1175
+				 try {
1176
+						$sth = $this->db->prepare($query);
1177
+						$sth->execute($query_values);
1178
+				} catch(PDOException $e) {
1179
+						return "error : ".$e->getMessage();
1180
+				}
1181
+		}
1182 1182
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1183 1183
 		global $globalDBdriver;
1184 1184
 		if ($globalDBdriver == 'mysql') {
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1195 1195
 			}
1196 1196
 		}
1197
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1198
-                 try {
1199
-                        $sth = $this->db->prepare($query);
1200
-                        $sth->execute($query_values);
1201
-                } catch(PDOException $e) {
1202
-                        return "error : ".$e->getMessage();
1203
-                }
1204
-        }
1197
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1198
+				 try {
1199
+						$sth = $this->db->prepare($query);
1200
+						$sth->execute($query_values);
1201
+				} catch(PDOException $e) {
1202
+						return "error : ".$e->getMessage();
1203
+				}
1204
+		}
1205 1205
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1206 1206
 		global $globalDBdriver;
1207 1207
 		if ($globalDBdriver == 'mysql') {
@@ -1217,14 +1217,14 @@  discard block
 block discarded – undo
1217 1217
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1218 1218
 			}
1219 1219
 		}
1220
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1221
-                 try {
1222
-                        $sth = $this->db->prepare($query);
1223
-                        $sth->execute($query_values);
1224
-                } catch(PDOException $e) {
1225
-                        return "error : ".$e->getMessage();
1226
-                }
1227
-        }
1220
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1221
+				 try {
1222
+						$sth = $this->db->prepare($query);
1223
+						$sth->execute($query_values);
1224
+				} catch(PDOException $e) {
1225
+						return "error : ".$e->getMessage();
1226
+				}
1227
+		}
1228 1228
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1229 1229
 		global $globalDBdriver;
1230 1230
 		if ($globalDBdriver == 'mysql') {
@@ -1240,14 +1240,14 @@  discard block
 block discarded – undo
1240 1240
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1241 1241
 			}
1242 1242
 		}
1243
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1244
-                 try {
1245
-                        $sth = $this->db->prepare($query);
1246
-                        $sth->execute($query_values);
1247
-                } catch(PDOException $e) {
1248
-                        return "error : ".$e->getMessage();
1249
-                }
1250
-        }
1243
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1244
+				 try {
1245
+						$sth = $this->db->prepare($query);
1246
+						$sth->execute($query_values);
1247
+				} catch(PDOException $e) {
1248
+						return "error : ".$e->getMessage();
1249
+				}
1250
+		}
1251 1251
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1252 1252
 		global $globalDBdriver;
1253 1253
 		if ($globalDBdriver == 'mysql') {
@@ -1263,14 +1263,14 @@  discard block
 block discarded – undo
1263 1263
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1264 1264
 			}
1265 1265
 		}
1266
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1267
-                 try {
1268
-                        $sth = $this->db->prepare($query);
1269
-                        $sth->execute($query_values);
1270
-                } catch(PDOException $e) {
1271
-                        return "error : ".$e->getMessage();
1272
-                }
1273
-        }
1266
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1267
+				 try {
1268
+						$sth = $this->db->prepare($query);
1269
+						$sth->execute($query_values);
1270
+				} catch(PDOException $e) {
1271
+						return "error : ".$e->getMessage();
1272
+				}
1273
+		}
1274 1274
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1275 1275
 		global $globalDBdriver;
1276 1276
 		if ($globalDBdriver == 'mysql') {
@@ -1286,14 +1286,14 @@  discard block
 block discarded – undo
1286 1286
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1287 1287
 			}
1288 1288
 		}
1289
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1290
-                 try {
1291
-                        $sth = $this->db->prepare($query);
1292
-                        $sth->execute($query_values);
1293
-                } catch(PDOException $e) {
1294
-                        return "error : ".$e->getMessage();
1295
-                }
1296
-        }
1289
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1290
+				 try {
1291
+						$sth = $this->db->prepare($query);
1292
+						$sth->execute($query_values);
1293
+				} catch(PDOException $e) {
1294
+						return "error : ".$e->getMessage();
1295
+				}
1296
+		}
1297 1297
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1298 1298
 		global $globalDBdriver;
1299 1299
 		if ($globalDBdriver == 'mysql') {
@@ -1309,14 +1309,14 @@  discard block
 block discarded – undo
1309 1309
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1310 1310
 			}
1311 1311
 		}
1312
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1313
-                 try {
1314
-                        $sth = $this->db->prepare($query);
1315
-                        $sth->execute($query_values);
1316
-                } catch(PDOException $e) {
1317
-                        return "error : ".$e->getMessage();
1318
-                }
1319
-        }
1312
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1313
+				 try {
1314
+						$sth = $this->db->prepare($query);
1315
+						$sth->execute($query_values);
1316
+				} catch(PDOException $e) {
1317
+						return "error : ".$e->getMessage();
1318
+				}
1319
+		}
1320 1320
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1321 1321
 		global $globalDBdriver;
1322 1322
 		if ($globalDBdriver == 'mysql') {
@@ -1332,14 +1332,14 @@  discard block
 block discarded – undo
1332 1332
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1333 1333
 			}
1334 1334
 		}
1335
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1336
-                 try {
1337
-                        $sth = $this->db->prepare($query);
1338
-                        $sth->execute($query_values);
1339
-                } catch(PDOException $e) {
1340
-                        return "error : ".$e->getMessage();
1341
-                }
1342
-        }
1335
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1336
+				 try {
1337
+						$sth = $this->db->prepare($query);
1338
+						$sth->execute($query_values);
1339
+				} catch(PDOException $e) {
1340
+						return "error : ".$e->getMessage();
1341
+				}
1342
+		}
1343 1343
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1344 1344
 		global $globalDBdriver;
1345 1345
 		if ($airport_icao != '') {
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
 			} catch(PDOException $e) {
1364 1364
 				return "error : ".$e->getMessage();
1365 1365
 			}
1366
-                }
1367
-        }
1366
+				}
1367
+		}
1368 1368
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1369 1369
 		global $globalDBdriver;
1370 1370
 		if ($airport_icao != '') {
@@ -1380,8 +1380,8 @@  discard block
 block discarded – undo
1380 1380
 			} catch(PDOException $e) {
1381 1381
 				return "error : ".$e->getMessage();
1382 1382
 			}
1383
-                }
1384
-        }
1383
+				}
1384
+		}
1385 1385
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1386 1386
 		global $globalDBdriver;
1387 1387
 		if ($airport_icao != '') {
@@ -1398,15 +1398,15 @@  discard block
 block discarded – undo
1398 1398
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1399 1399
 				}
1400 1400
 			}
1401
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1401
+					$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1402 1402
 			 try {
1403
-                    		$sth = $this->db->prepare($query);
1404
-	                        $sth->execute($query_values);
1405
-    		        } catch(PDOException $e) {
1406
-            		        return "error : ".$e->getMessage();
1407
-	                }
1408
-	        }
1409
-        }
1403
+							$sth = $this->db->prepare($query);
1404
+							$sth->execute($query_values);
1405
+					} catch(PDOException $e) {
1406
+							return "error : ".$e->getMessage();
1407
+					}
1408
+			}
1409
+		}
1410 1410
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1411 1411
 		global $globalDBdriver;
1412 1412
 		if ($airport_icao != '') {
@@ -1422,46 +1422,46 @@  discard block
 block discarded – undo
1422 1422
 			} catch(PDOException $e) {
1423 1423
 				return "error : ".$e->getMessage();
1424 1424
 			}
1425
-                }
1426
-        }
1425
+				}
1426
+		}
1427 1427
 
1428 1428
 	public function deleteStat($id) {
1429
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1430
-                $query_values = array(':id' => $id);
1431
-                 try {
1432
-                        $sth = $this->db->prepare($query);
1433
-                        $sth->execute($query_values);
1434
-                } catch(PDOException $e) {
1435
-                        return "error : ".$e->getMessage();
1436
-                }
1437
-        }
1429
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1430
+				$query_values = array(':id' => $id);
1431
+				 try {
1432
+						$sth = $this->db->prepare($query);
1433
+						$sth->execute($query_values);
1434
+				} catch(PDOException $e) {
1435
+						return "error : ".$e->getMessage();
1436
+				}
1437
+		}
1438 1438
 	public function deleteStatFlight($type) {
1439
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1440
-                $query_values = array(':type' => $type);
1441
-                 try {
1442
-                        $sth = $this->db->prepare($query);
1443
-                        $sth->execute($query_values);
1444
-                } catch(PDOException $e) {
1445
-                        return "error : ".$e->getMessage();
1446
-                }
1447
-        }
1439
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1440
+				$query_values = array(':type' => $type);
1441
+				 try {
1442
+						$sth = $this->db->prepare($query);
1443
+						$sth->execute($query_values);
1444
+				} catch(PDOException $e) {
1445
+						return "error : ".$e->getMessage();
1446
+				}
1447
+		}
1448 1448
 	public function deleteStatAirport($type) {
1449
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1450
-                $query_values = array(':type' => $type);
1451
-                 try {
1452
-                        $sth = $this->db->prepare($query);
1453
-                        $sth->execute($query_values);
1454
-                } catch(PDOException $e) {
1455
-                        return "error : ".$e->getMessage();
1456
-                }
1457
-        }
1449
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1450
+				$query_values = array(':type' => $type);
1451
+				 try {
1452
+						$sth = $this->db->prepare($query);
1453
+						$sth->execute($query_values);
1454
+				} catch(PDOException $e) {
1455
+						return "error : ".$e->getMessage();
1456
+				}
1457
+		}
1458 1458
         
1459
-        public function addOldStats() {
1460
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1461
-    		$Common = new Common();
1462
-    		$Connection = new Connection();
1463
-    		date_default_timezone_set('UTC');
1464
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1459
+		public function addOldStats() {
1460
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1461
+			$Common = new Common();
1462
+			$Connection = new Connection();
1463
+			date_default_timezone_set('UTC');
1464
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1465 1465
 			if ($globalDebug) echo 'Update stats !'."\n";
1466 1466
 			if (isset($last_update[0]['value'])) {
1467 1467
 				$last_update_day = $last_update[0]['value'];
@@ -1508,24 +1508,24 @@  discard block
 block discarded – undo
1508 1508
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1509 1509
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1510 1510
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1511
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1511
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1512 1512
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1513
-	        	$alldata = array();
1513
+				$alldata = array();
1514 1514
 	        	
1515
-    			foreach ($pall as $value) {
1516
-	        		$icao = $value['airport_departure_icao'];
1517
-    				$alldata[$icao] = $value;
1518
-	        	}
1519
-	        	foreach ($dall as $value) {
1520
-    				$icao = $value['airport_departure_icao'];
1521
-        			if (isset($alldata[$icao])) {
1522
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1523
-        			} else $alldata[$icao] = $value;
1524
-			}
1525
-    			$count = array();
1526
-    			foreach ($alldata as $key => $row) {
1527
-    				$count[$key] = $row['airport_departure_icao_count'];
1528
-        		}
1515
+				foreach ($pall as $value) {
1516
+					$icao = $value['airport_departure_icao'];
1517
+					$alldata[$icao] = $value;
1518
+				}
1519
+				foreach ($dall as $value) {
1520
+					$icao = $value['airport_departure_icao'];
1521
+					if (isset($alldata[$icao])) {
1522
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1523
+					} else $alldata[$icao] = $value;
1524
+			}
1525
+				$count = array();
1526
+				foreach ($alldata as $key => $row) {
1527
+					$count[$key] = $row['airport_departure_icao_count'];
1528
+				}
1529 1529
 			array_multisort($count,SORT_DESC,$alldata);
1530 1530
 			foreach ($alldata as $number) {
1531 1531
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
@@ -1533,25 +1533,25 @@  discard block
 block discarded – undo
1533 1533
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1534 1534
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1535 1535
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1536
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1536
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1537 1537
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1538
-	        	$alldata = array();
1539
-    			foreach ($pall as $value) {
1540
-	        		$icao = $value['airport_arrival_icao'];
1541
-    				$alldata[$icao] = $value;
1542
-	        	}
1543
-	        	foreach ($dall as $value) {
1544
-    				$icao = $value['airport_arrival_icao'];
1545
-        			if (isset($alldata[$icao])) {
1546
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1547
-	        		} else $alldata[$icao] = $value;
1548
-    			}
1549
-        		$count = array();
1550
-        		foreach ($alldata as $key => $row) {
1551
-        			$count[$key] = $row['airport_arrival_icao_count'];
1552
-	        	}
1553
-    			array_multisort($count,SORT_DESC,$alldata);
1554
-                        foreach ($alldata as $number) {
1538
+				$alldata = array();
1539
+				foreach ($pall as $value) {
1540
+					$icao = $value['airport_arrival_icao'];
1541
+					$alldata[$icao] = $value;
1542
+				}
1543
+				foreach ($dall as $value) {
1544
+					$icao = $value['airport_arrival_icao'];
1545
+					if (isset($alldata[$icao])) {
1546
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1547
+					} else $alldata[$icao] = $value;
1548
+				}
1549
+				$count = array();
1550
+				foreach ($alldata as $key => $row) {
1551
+					$count[$key] = $row['airport_arrival_icao_count'];
1552
+				}
1553
+				array_multisort($count,SORT_DESC,$alldata);
1554
+						foreach ($alldata as $number) {
1555 1555
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1556 1556
 			}
1557 1557
 			if ($Connection->tableExists('countries')) {
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1612 1612
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1613 1613
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1614
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1615
-        		/*
1614
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1615
+				/*
1616 1616
 	        	$alldata = array();
1617 1617
     			foreach ($pall as $value) {
1618 1618
 	        		$icao = $value['departure_airport_icao'];
@@ -1631,29 +1631,29 @@  discard block
 block discarded – undo
1631 1631
 	        	}
1632 1632
     			array_multisort($count,SORT_DESC,$alldata);
1633 1633
     			*/
1634
-    			foreach ($dall as $value) {
1635
-    				$icao = $value['departure_airport_icao'];
1636
-    				$ddate = $value['date'];
1637
-    				$find = false;
1638
-    				foreach ($pall as $pvalue) {
1639
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1640
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1641
-    						$find = true;
1642
-    						break;
1643
-    					}
1644
-    				}
1645
-    				if ($find === false) {
1646
-    					$pall[] = $value;
1647
-    				}
1648
-    			}
1649
-    			$alldata = $pall;
1634
+				foreach ($dall as $value) {
1635
+					$icao = $value['departure_airport_icao'];
1636
+					$ddate = $value['date'];
1637
+					$find = false;
1638
+					foreach ($pall as $pvalue) {
1639
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1640
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1641
+							$find = true;
1642
+							break;
1643
+						}
1644
+					}
1645
+					if ($find === false) {
1646
+						$pall[] = $value;
1647
+					}
1648
+				}
1649
+				$alldata = $pall;
1650 1650
 			foreach ($alldata as $number) {
1651 1651
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1652 1652
 			}
1653 1653
 			echo '...Arrival'."\n";
1654 1654
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1655
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1656
-        		/*
1655
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1656
+				/*
1657 1657
 	        	$alldata = array();
1658 1658
     			foreach ($pall as $value) {
1659 1659
 	        		$icao = $value['arrival_airport_icao'];
@@ -1673,22 +1673,22 @@  discard block
 block discarded – undo
1673 1673
     			*/
1674 1674
 
1675 1675
 
1676
-    			foreach ($dall as $value) {
1677
-    				$icao = $value['arrival_airport_icao'];
1678
-    				$ddate = $value['date'];
1679
-    				$find = false;
1680
-    				foreach ($pall as $pvalue) {
1681
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1682
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1683
-    						$find = true;
1684
-    						break;
1685
-    					}
1686
-    				}
1687
-    				if ($find === false) {
1688
-    					$pall[] = $value;
1689
-    				}
1690
-    			}
1691
-    			$alldata = $pall;
1676
+				foreach ($dall as $value) {
1677
+					$icao = $value['arrival_airport_icao'];
1678
+					$ddate = $value['date'];
1679
+					$find = false;
1680
+					foreach ($pall as $pvalue) {
1681
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1682
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1683
+							$find = true;
1684
+							break;
1685
+						}
1686
+					}
1687
+					if ($find === false) {
1688
+						$pall[] = $value;
1689
+					}
1690
+				}
1691
+				$alldata = $pall;
1692 1692
 			foreach ($alldata as $number) {
1693 1693
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1694 1694
 			}
@@ -1763,51 +1763,51 @@  discard block
 block discarded – undo
1763 1763
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1764 1764
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1765 1765
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1766
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1766
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1767 1767
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1768
-	        	//$alldata = array();
1769
-    			foreach ($dall as $value) {
1770
-    				$icao = $value['airport_departure_icao'];
1771
-    				$dicao = $value['airline_icao'];
1772
-    				$find = false;
1773
-    				foreach ($pall as $pvalue) {
1774
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1775
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1776
-    						$find = true;
1777
-    						break;
1778
-    					}
1779
-    				}
1780
-    				if ($find === false) {
1781
-    					$pall[] = $value;
1782
-    				}
1783
-    			}
1784
-    			$alldata = $pall;
1768
+				//$alldata = array();
1769
+				foreach ($dall as $value) {
1770
+					$icao = $value['airport_departure_icao'];
1771
+					$dicao = $value['airline_icao'];
1772
+					$find = false;
1773
+					foreach ($pall as $pvalue) {
1774
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1775
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1776
+							$find = true;
1777
+							break;
1778
+						}
1779
+					}
1780
+					if ($find === false) {
1781
+						$pall[] = $value;
1782
+					}
1783
+				}
1784
+				$alldata = $pall;
1785 1785
 			foreach ($alldata as $number) {
1786 1786
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1787 1787
 			}
1788 1788
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1789 1789
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1790 1790
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1791
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1791
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1792 1792
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1793
-	        	//$alldata = array();
1794
-    			foreach ($dall as $value) {
1795
-    				$icao = $value['airport_arrival_icao'];
1796
-    				$dicao = $value['airline_icao'];
1797
-    				$find = false;
1798
-    				foreach ($pall as $pvalue) {
1799
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1800
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1801
-    						$find = true;
1802
-    						break;
1803
-    					}
1804
-    				}
1805
-    				if ($find === false) {
1806
-    					$pall[] = $value;
1807
-    				}
1808
-    			}
1809
-    			$alldata = $pall;
1810
-                        foreach ($alldata as $number) {
1793
+				//$alldata = array();
1794
+				foreach ($dall as $value) {
1795
+					$icao = $value['airport_arrival_icao'];
1796
+					$dicao = $value['airline_icao'];
1797
+					$find = false;
1798
+					foreach ($pall as $pvalue) {
1799
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1800
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1801
+							$find = true;
1802
+							break;
1803
+						}
1804
+					}
1805
+					if ($find === false) {
1806
+						$pall[] = $value;
1807
+					}
1808
+				}
1809
+				$alldata = $pall;
1810
+						foreach ($alldata as $number) {
1811 1811
 				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1812 1812
 			}
1813 1813
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1840,47 +1840,47 @@  discard block
 block discarded – undo
1840 1840
 			}
1841 1841
 			if ($globalDebug) echo '...Departure'."\n";
1842 1842
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1843
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1844
-    			foreach ($dall as $value) {
1845
-    				$icao = $value['departure_airport_icao'];
1846
-    				$airline = $value['airline_icao'];
1847
-    				$ddate = $value['date'];
1848
-    				$find = false;
1849
-    				foreach ($pall as $pvalue) {
1850
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1851
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1852
-    						$find = true;
1853
-    						break;
1854
-    					}
1855
-    				}
1856
-    				if ($find === false) {
1857
-    					$pall[] = $value;
1858
-    				}
1859
-    			}
1860
-    			$alldata = $pall;
1843
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1844
+				foreach ($dall as $value) {
1845
+					$icao = $value['departure_airport_icao'];
1846
+					$airline = $value['airline_icao'];
1847
+					$ddate = $value['date'];
1848
+					$find = false;
1849
+					foreach ($pall as $pvalue) {
1850
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1851
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1852
+							$find = true;
1853
+							break;
1854
+						}
1855
+					}
1856
+					if ($find === false) {
1857
+						$pall[] = $value;
1858
+					}
1859
+				}
1860
+				$alldata = $pall;
1861 1861
 			foreach ($alldata as $number) {
1862 1862
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1863 1863
 			}
1864 1864
 			if ($globalDebug) echo '...Arrival'."\n";
1865 1865
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1866
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1867
-    			foreach ($dall as $value) {
1868
-    				$icao = $value['arrival_airport_icao'];
1869
-    				$airline = $value['airline_icao'];
1870
-    				$ddate = $value['date'];
1871
-    				$find = false;
1872
-    				foreach ($pall as $pvalue) {
1873
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1874
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1875
-    						$find = true;
1876
-    						break;
1877
-    					}
1878
-    				}
1879
-    				if ($find === false) {
1880
-    					$pall[] = $value;
1881
-    				}
1882
-    			}
1883
-    			$alldata = $pall;
1866
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1867
+				foreach ($dall as $value) {
1868
+					$icao = $value['arrival_airport_icao'];
1869
+					$airline = $value['airline_icao'];
1870
+					$ddate = $value['date'];
1871
+					$find = false;
1872
+					foreach ($pall as $pvalue) {
1873
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1874
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1875
+							$find = true;
1876
+							break;
1877
+						}
1878
+					}
1879
+					if ($find === false) {
1880
+						$pall[] = $value;
1881
+					}
1882
+				}
1883
+				$alldata = $pall;
1884 1884
 			foreach ($alldata as $number) {
1885 1885
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1886 1886
 			}
@@ -1963,44 +1963,44 @@  discard block
 block discarded – undo
1963 1963
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1964 1964
 				}
1965 1965
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1966
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1967
-		        	$alldata = array();
1968
-	    			foreach ($pall as $value) {
1969
-		        		$icao = $value['airport_departure_icao'];
1970
-    					$alldata[$icao] = $value;
1971
-	    			}
1972
-		        	foreach ($dall as $value) {
1973
-	    				$icao = $value['airport_departure_icao'];
1974
-        				if (isset($alldata[$icao])) {
1975
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1976
-        				} else $alldata[$icao] = $value;
1977
-				}
1978
-	    			$count = array();
1979
-    				foreach ($alldata as $key => $row) {
1980
-    					$count[$key] = $row['airport_departure_icao_count'];
1981
-    				}
1966
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1967
+					$alldata = array();
1968
+					foreach ($pall as $value) {
1969
+						$icao = $value['airport_departure_icao'];
1970
+						$alldata[$icao] = $value;
1971
+					}
1972
+					foreach ($dall as $value) {
1973
+						$icao = $value['airport_departure_icao'];
1974
+						if (isset($alldata[$icao])) {
1975
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1976
+						} else $alldata[$icao] = $value;
1977
+				}
1978
+					$count = array();
1979
+					foreach ($alldata as $key => $row) {
1980
+						$count[$key] = $row['airport_departure_icao_count'];
1981
+					}
1982 1982
 				array_multisort($count,SORT_DESC,$alldata);
1983 1983
 				foreach ($alldata as $number) {
1984
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1984
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1985 1985
 				}
1986 1986
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1987
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1987
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1988 1988
 				$alldata = array();
1989
-    				foreach ($pall as $value) {
1990
-		        		$icao = $value['airport_arrival_icao'];
1991
-    					$alldata[$icao] = $value;
1992
-	    			}
1993
-		        	foreach ($dall as $value) {
1994
-	    				$icao = $value['airport_arrival_icao'];
1995
-        				if (isset($alldata[$icao])) {
1996
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1997
-		        		} else $alldata[$icao] = $value;
1998
-	    			}
1999
-        			$count = array();
2000
-        			foreach ($alldata as $key => $row) {
2001
-    					$count[$key] = $row['airport_arrival_icao_count'];
2002
-		        	}
2003
-        			array_multisort($count,SORT_DESC,$alldata);
1989
+					foreach ($pall as $value) {
1990
+						$icao = $value['airport_arrival_icao'];
1991
+						$alldata[$icao] = $value;
1992
+					}
1993
+					foreach ($dall as $value) {
1994
+						$icao = $value['airport_arrival_icao'];
1995
+						if (isset($alldata[$icao])) {
1996
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1997
+						} else $alldata[$icao] = $value;
1998
+					}
1999
+					$count = array();
2000
+					foreach ($alldata as $key => $row) {
2001
+						$count[$key] = $row['airport_arrival_icao_count'];
2002
+					}
2003
+					array_multisort($count,SORT_DESC,$alldata);
2004 2004
 				foreach ($alldata as $number) {
2005 2005
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2006 2006
 				}
@@ -2033,45 +2033,45 @@  discard block
 block discarded – undo
2033 2033
 				}
2034 2034
 				echo '...Departure'."\n";
2035 2035
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2036
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2036
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2037 2037
 				foreach ($dall as $value) {
2038
-    					$icao = $value['departure_airport_icao'];
2039
-    					$ddate = $value['date'];
2040
-    					$find = false;
2041
-    					foreach ($pall as $pvalue) {
2042
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2043
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
2044
-	    						$find = true;
2045
-    							break;
2046
-    						}
2047
-    					}
2048
-    					if ($find === false) {
2049
-    						$pall[] = $value;
2050
-	    				}
2051
-    				}
2052
-	    			$alldata = $pall;
2038
+						$icao = $value['departure_airport_icao'];
2039
+						$ddate = $value['date'];
2040
+						$find = false;
2041
+						foreach ($pall as $pvalue) {
2042
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2043
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
2044
+								$find = true;
2045
+								break;
2046
+							}
2047
+						}
2048
+						if ($find === false) {
2049
+							$pall[] = $value;
2050
+						}
2051
+					}
2052
+					$alldata = $pall;
2053 2053
 				foreach ($alldata as $number) {
2054 2054
 					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2055 2055
 				}
2056 2056
 				echo '...Arrival'."\n";
2057 2057
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2058
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2058
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2059 2059
 				foreach ($dall as $value) {
2060 2060
 					$icao = $value['arrival_airport_icao'];
2061 2061
 					$ddate = $value['date'];
2062
-    					$find = false;
2062
+						$find = false;
2063 2063
 					foreach ($pall as $pvalue) {
2064
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2065
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2066
-    							$find = true;
2067
-    							break;
2068
-	    					}
2069
-    					}
2070
-    					if ($find === false) {
2071
-    						$pall[] = $value;
2072
-	    				}
2073
-    				}
2074
-    				$alldata = $pall;
2064
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2065
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2066
+								$find = true;
2067
+								break;
2068
+							}
2069
+						}
2070
+						if ($find === false) {
2071
+							$pall[] = $value;
2072
+						}
2073
+					}
2074
+					$alldata = $pall;
2075 2075
 				foreach ($alldata as $number) {
2076 2076
 					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2077 2077
 				}
Please login to merge, or discard this patch.
Spacing   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                  try {
68 68
                         $sth = $this->db->prepare($query);
69 69
                         $sth->execute();
70
-                } catch(PDOException $e) {
70
+                } catch (PDOException $e) {
71 71
                         return "error : ".$e->getMessage();
72 72
                 }
73 73
                 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                  try {
76 76
                         $sth = $this->db->prepare($query);
77 77
                         $sth->execute(array(':filter_name' => $filter_name));
78
-                } catch(PDOException $e) {
78
+                } catch (PDOException $e) {
79 79
                         return "error : ".$e->getMessage();
80 80
                 }
81 81
         }
@@ -85,69 +85,69 @@  discard block
 block discarded – undo
85 85
                  try {
86 86
                         $sth = $this->db->prepare($query);
87 87
                         $sth->execute(array(':filter_name' => $filter_name));
88
-                } catch(PDOException $e) {
88
+                } catch (PDOException $e) {
89 89
                         echo "error : ".$e->getMessage();
90 90
                 }
91 91
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
92 92
                 return $all;
93 93
         }
94
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
94
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
95 95
 		if ($filter_name == '') $filter_name = $this->filter_name;
96 96
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
97 97
                  try {
98 98
                         $sth = $this->db->prepare($query);
99
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
100
-                } catch(PDOException $e) {
99
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
100
+                } catch (PDOException $e) {
101 101
                         echo "error : ".$e->getMessage();
102 102
                 }
103 103
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
104 104
                 return $all;
105 105
         }
106
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
106
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
107 107
 		if ($filter_name == '') $filter_name = $this->filter_name;
108 108
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
109 109
                  try {
110 110
                         $sth = $this->db->prepare($query);
111
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
112
-                } catch(PDOException $e) {
111
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
112
+                } catch (PDOException $e) {
113 113
                         echo "error : ".$e->getMessage();
114 114
                 }
115 115
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
116 116
                 return $all;
117 117
         }
118
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
118
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
119 119
 		if ($filter_name == '') $filter_name = $this->filter_name;
120 120
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
121 121
                  try {
122 122
                         $sth = $this->db->prepare($query);
123
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
124
-                } catch(PDOException $e) {
123
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
124
+                } catch (PDOException $e) {
125 125
                         echo "error : ".$e->getMessage();
126 126
                 }
127 127
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
128 128
                 return $all;
129 129
         }
130 130
 
131
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
131
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
132 132
 		if ($filter_name == '') $filter_name = $this->filter_name;
133 133
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
134 134
                  try {
135 135
                         $sth = $this->db->prepare($query);
136
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
-                } catch(PDOException $e) {
136
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
137
+                } catch (PDOException $e) {
138 138
                         echo "error : ".$e->getMessage();
139 139
                 }
140 140
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
141 141
                 return $all;
142 142
         }
143 143
 
144
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
144
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
145 145
 		if ($filter_name == '') $filter_name = $this->filter_name;
146 146
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
147 147
                  try {
148 148
                         $sth = $this->db->prepare($query);
149
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
150
-                } catch(PDOException $e) {
149
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
150
+                } catch (PDOException $e) {
151 151
                         echo "error : ".$e->getMessage();
152 152
                 }
153 153
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         }
156 156
 
157 157
 
158
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
158
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
159 159
 		global $globalStatsFilters;
160 160
 		if ($filter_name == '') $filter_name = $this->filter_name;
161 161
 		if ($year == '' && $month == '') {
@@ -163,24 +163,24 @@  discard block
 block discarded – undo
163 163
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
164 164
 			try {
165 165
 				$sth = $this->db->prepare($query);
166
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
167
-			} catch(PDOException $e) {
166
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
167
+			} catch (PDOException $e) {
168 168
 				echo "error : ".$e->getMessage();
169 169
 			}
170 170
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
171 171
 		} else $all = array();
172 172
                 if (empty($all)) {
173
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
173
+            	    $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
174 174
             	    if ($filter_name != '') {
175
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
175
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
176 176
             	    }
177 177
             	    $Spotter = new Spotter($this->db);
178 178
             	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
179
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
179
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
180 180
                 }
181 181
                 return $all;
182 182
 	}
183
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
183
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
184 184
 		global $globalStatsFilters;
185 185
 		if ($filter_name == '') $filter_name = $this->filter_name;
186 186
 		if ($year == '' && $month == '') {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			try {
190 190
 				$sth = $this->db->prepare($query);
191 191
 				$sth->execute(array(':filter_name' => $filter_name));
192
-			} catch(PDOException $e) {
192
+			} catch (PDOException $e) {
193 193
 				echo "error : ".$e->getMessage();
194 194
 			}
195 195
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
                 if (empty($all)) {
198 198
             		$Spotter = new Spotter($this->db);
199 199
             		$filters = array();
200
-            		$filters = array('year' => $year,'month' => $month);
200
+            		$filters = array('year' => $year, 'month' => $month);
201 201
             		if ($filter_name != '') {
202
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
202
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
203 203
 			}
204 204
             		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
205
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
205
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
206 206
                 }
207 207
                 return $all;
208 208
 	}
209
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
209
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
210 210
 		global $globalStatsFilters;
211 211
 		if ($filter_name == '') $filter_name = $this->filter_name;
212 212
 		if ($year == '' && $month == '') {
@@ -214,16 +214,16 @@  discard block
 block discarded – undo
214 214
 			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
215 215
 			try {
216 216
 				$sth = $this->db->prepare($query);
217
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
218
-			} catch(PDOException $e) {
217
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
218
+			} catch (PDOException $e) {
219 219
 				echo "error : ".$e->getMessage();
220 220
 			}
221 221
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
222 222
 		} else $all = array();
223 223
 		if (empty($all)) {
224
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
224
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
225 225
 			if ($filter_name != '') {
226
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
226
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
227 227
 			}
228 228
 			$Spotter = new Spotter($this->db);
229 229
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		return $all;
233 233
 	}
234 234
 
235
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
235
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
236 236
 		global $globalStatsFilters;
237 237
 		if ($filter_name == '') $filter_name = $this->filter_name;
238 238
 		if ($year == '' && $month == '') {
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
241 241
 			try {
242 242
 				$sth = $this->db->prepare($query);
243
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
244
-			} catch(PDOException $e) {
243
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
244
+			} catch (PDOException $e) {
245 245
 				echo "error : ".$e->getMessage();
246 246
 			}
247 247
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
248 248
 		} else $all = array();
249 249
                 if (empty($all)) {
250
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
250
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
251 251
 			if ($filter_name != '') {
252
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
252
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
253 253
 			}
254 254
 			$Spotter = new Spotter($this->db);
255 255
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
256
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
256
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
257 257
                 }
258 258
                 return $all;
259 259
 	}
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
265 265
                  try {
266 266
                         $sth = $this->db->prepare($query);
267
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
268
-                } catch(PDOException $e) {
267
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
268
+                } catch (PDOException $e) {
269 269
                         echo "error : ".$e->getMessage();
270 270
                 }
271 271
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
272 272
                 if (empty($all)) {
273
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
273
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
274 274
 			if ($filter_name != '') {
275
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
275
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
276 276
 			}
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                 return $all;
282 282
 	}
283 283
 
284
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
284
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
285 285
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
286 286
 		if ($filter_name == '') $filter_name = $this->filter_name;
287 287
 		if ($year == '' && $month == '') {
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			if (isset($forsource)) {
291 291
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
292 292
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
293
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
293
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
294 294
 			} else {
295 295
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
296 296
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			try {
300 300
 				$sth = $this->db->prepare($query);
301 301
 				$sth->execute($query_values);
302
-			} catch(PDOException $e) {
302
+			} catch (PDOException $e) {
303 303
 				echo "error : ".$e->getMessage();
304 304
 			}
305 305
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -307,16 +307,16 @@  discard block
 block discarded – undo
307 307
                 if (empty($all)) {
308 308
 	                $Spotter = new Spotter($this->db);
309 309
             		$filters = array();
310
-			$filters = array('year' => $year,'month' => $month);
310
+			$filters = array('year' => $year, 'month' => $month);
311 311
             		if ($filter_name != '') {
312
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
312
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
313 313
 			}
314 314
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
315
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
315
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
316 316
                 }
317 317
                 return $all;
318 318
 	}
319
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
319
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
320 320
 		global $globalStatsFilters;
321 321
 		if ($filter_name == '') $filter_name = $this->filter_name;
322 322
 		if ($year == '' && $month == '') {
@@ -324,24 +324,24 @@  discard block
 block discarded – undo
324 324
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
325 325
 			try {
326 326
 				$sth = $this->db->prepare($query);
327
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
328
-			} catch(PDOException $e) {
327
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
328
+			} catch (PDOException $e) {
329 329
 				echo "error : ".$e->getMessage();
330 330
 			}
331 331
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
332 332
 		} else $all = array();
333 333
                 if (empty($all)) {
334
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
334
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
335 335
 			if ($filter_name != '') {
336
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
336
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
337 337
 			}
338 338
 	                $Spotter = new Spotter($this->db);
339 339
     		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
340
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
340
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
341 341
                 }
342 342
                 return $all;
343 343
 	}
344
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
344
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
345 345
 		global $globalStatsFilters;
346 346
 		if ($filter_name == '') $filter_name = $this->filter_name;
347 347
 		if ($year == '' && $month == '') {
@@ -349,24 +349,24 @@  discard block
 block discarded – undo
349 349
 			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
350 350
 			 try {
351 351
 				$sth = $this->db->prepare($query);
352
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
353
-			} catch(PDOException $e) {
352
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
353
+			} catch (PDOException $e) {
354 354
 				echo "error : ".$e->getMessage();
355 355
 			}
356 356
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
357 357
 		} else $all = array();
358 358
 		if (empty($all)) {
359
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
359
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
360 360
 			if ($filter_name != '') {
361
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
361
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
362 362
 			}
363 363
 			$Spotter = new Spotter($this->db);
364 364
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
365
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
365
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
366 366
 		}
367 367
 		return $all;
368 368
 	}
369
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
369
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
370 370
 		$Connection = new Connection();
371 371
 		if ($filter_name == '') $filter_name = $this->filter_name;
372 372
 		if ($Connection->tableExists('countries')) {
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
376 376
 				 try {
377 377
 					$sth = $this->db->prepare($query);
378
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
379
-				} catch(PDOException $e) {
378
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
379
+				} catch (PDOException $e) {
380 380
 					echo "error : ".$e->getMessage();
381 381
 				}
382 382
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 			return array();
393 393
 		}
394 394
 	}
395
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
395
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
396 396
 		global $globalStatsFilters;
397 397
 		if ($filter_name == '') $filter_name = $this->filter_name;
398 398
 		if ($year == '' && $month == '') {
@@ -400,25 +400,25 @@  discard block
 block discarded – undo
400 400
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
401 401
 			try {
402 402
 				$sth = $this->db->prepare($query);
403
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
404
-			} catch(PDOException $e) {
403
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
404
+			} catch (PDOException $e) {
405 405
 				echo "error : ".$e->getMessage();
406 406
 			}
407 407
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
408 408
 		} else $all = array();
409 409
 		if (empty($all)) {
410
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
410
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
411 411
 			if ($filter_name != '') {
412
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
412
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
413 413
 			}
414 414
 			$Spotter = new Spotter($this->db);
415 415
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
416
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
416
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
417 417
 		}
418 418
 		return $all;
419 419
 	}
420 420
 
421
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
421
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
422 422
 		global $globalStatsFilters;
423 423
 		if ($filter_name == '') $filter_name = $this->filter_name;
424 424
 		if ($year == '' && $month == '') {
@@ -426,24 +426,24 @@  discard block
 block discarded – undo
426 426
 			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
427 427
 			try {
428 428
 				$sth = $this->db->prepare($query);
429
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
430
-			} catch(PDOException $e) {
429
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
430
+			} catch (PDOException $e) {
431 431
 				echo "error : ".$e->getMessage();
432 432
 			}
433 433
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434 434
 		} else $all = array();
435 435
                 if (empty($all)) {
436
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
436
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
437 437
 			if ($filter_name != '') {
438
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
438
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
439 439
 			}
440 440
             		$Spotter = new Spotter($this->db);
441 441
             		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
442
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
442
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
443 443
                 }
444 444
                 return $all;
445 445
 	}
446
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
446
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
447 447
 		global $globalStatsFilters;
448 448
 		if ($filter_name == '') $filter_name = $this->filter_name;
449 449
 		if ($year == '' && $month == '') {
@@ -451,22 +451,22 @@  discard block
 block discarded – undo
451 451
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
452 452
 			try {
453 453
 				$sth = $this->db->prepare($query);
454
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
455
-			} catch(PDOException $e) {
454
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
455
+			} catch (PDOException $e) {
456 456
 				echo "error : ".$e->getMessage();
457 457
 			}
458 458
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
459 459
 		} else $all = array();
460 460
                 if (empty($all)) {
461
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
461
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
462 462
             		if ($filter_name != '') {
463
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
463
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
464 464
 			}
465 465
             		$Spotter = new Spotter($this->db);
466 466
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
467 467
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
468
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
469
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
468
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
469
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
470 470
         		$all = array();
471 471
         		foreach ($pall as $value) {
472 472
         			$icao = $value['airport_departure_icao'];
@@ -483,11 +483,11 @@  discard block
 block discarded – undo
483 483
         		foreach ($all as $key => $row) {
484 484
         			$count[$key] = $row['airport_departure_icao_count'];
485 485
         		}
486
-        		array_multisort($count,SORT_DESC,$all);
486
+        		array_multisort($count, SORT_DESC, $all);
487 487
                 }
488 488
                 return $all;
489 489
 	}
490
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
490
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
491 491
 		global $globalStatsFilters;
492 492
 		if ($filter_name == '') $filter_name = $this->filter_name;
493 493
 		if ($year == '' && $month == '') {
@@ -495,22 +495,22 @@  discard block
 block discarded – undo
495 495
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
496 496
 			try {
497 497
 				$sth = $this->db->prepare($query);
498
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
499
-			} catch(PDOException $e) {
498
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
499
+			} catch (PDOException $e) {
500 500
 				echo "error : ".$e->getMessage();
501 501
 			}
502 502
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503 503
 		} else $all = array();
504 504
 		if (empty($all)) {
505
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
505
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
506 506
 			if ($filter_name != '') {
507
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
507
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
508 508
 			}
509 509
 			$Spotter = new Spotter($this->db);
510 510
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
511 511
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
512
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
513
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
512
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
513
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
514 514
         		$all = array();
515 515
         		foreach ($pall as $value) {
516 516
         			$icao = $value['airport_arrival_icao'];
@@ -527,12 +527,12 @@  discard block
 block discarded – undo
527 527
         		foreach ($all as $key => $row) {
528 528
         			$count[$key] = $row['airport_arrival_icao_count'];
529 529
         		}
530
-        		array_multisort($count,SORT_DESC,$all);
530
+        		array_multisort($count, SORT_DESC, $all);
531 531
                 }
532 532
  
533 533
                 return $all;
534 534
 	}
535
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
535
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
536 536
 		global $globalDBdriver, $globalStatsFilters;
537 537
 		if ($filter_name == '') $filter_name = $this->filter_name;
538 538
 		if ($globalDBdriver == 'mysql') {
@@ -542,18 +542,18 @@  discard block
 block discarded – undo
542 542
 			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
543 543
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
544 544
 		}
545
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
545
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
546 546
                  try {
547 547
                         $sth = $this->db->prepare($query);
548 548
                         $sth->execute($query_data);
549
-                } catch(PDOException $e) {
549
+                } catch (PDOException $e) {
550 550
                         echo "error : ".$e->getMessage();
551 551
                 }
552 552
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
553 553
                 if (empty($all)) {
554 554
 			$filters = array('airlines' => array($stats_airline));
555 555
 			if ($filter_name != '') {
556
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
556
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
557 557
 			}
558 558
             		$Spotter = new Spotter($this->db);
559 559
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -562,29 +562,29 @@  discard block
 block discarded – undo
562 562
                 return $all;
563 563
 	}
564 564
 	
565
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
565
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
566 566
 		global $globalStatsFilters;
567 567
 		if ($filter_name == '') $filter_name = $this->filter_name;
568 568
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
569
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
570 570
                  try {
571 571
                         $sth = $this->db->prepare($query);
572 572
                         $sth->execute($query_data);
573
-                } catch(PDOException $e) {
573
+                } catch (PDOException $e) {
574 574
                         echo "error : ".$e->getMessage();
575 575
                 }
576 576
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
577 577
                 if (empty($all)) {
578 578
 			$filters = array('airlines' => array($stats_airline));
579 579
 			if ($filter_name != '') {
580
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
581 581
 			}
582 582
             		$Spotter = new Spotter($this->db);
583 583
             		$all = $Spotter->countAllDatesLastMonth($filters);
584 584
                 }
585 585
                 return $all;
586 586
 	}
587
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
587
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
588 588
 		global $globalDBdriver, $globalStatsFilters;
589 589
 		if ($filter_name == '') $filter_name = $this->filter_name;
590 590
 		if ($globalDBdriver == 'mysql') {
@@ -592,40 +592,40 @@  discard block
 block discarded – undo
592 592
 		} else {
593 593
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
594 594
 		}
595
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
595
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
596 596
                  try {
597 597
                         $sth = $this->db->prepare($query);
598 598
                         $sth->execute($query_data);
599
-                } catch(PDOException $e) {
599
+                } catch (PDOException $e) {
600 600
                         echo "error : ".$e->getMessage();
601 601
                 }
602 602
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
603 603
                 if (empty($all)) {
604 604
 			$filters = array('airlines' => array($stats_airline));
605 605
 			if ($filter_name != '') {
606
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
606
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
607 607
 			}
608 608
             		$Spotter = new Spotter($this->db);
609 609
             		$all = $Spotter->countAllDatesLast7Days($filters);
610 610
                 }
611 611
                 return $all;
612 612
 	}
613
-	public function countAllDates($stats_airline = '',$filter_name = '') {
613
+	public function countAllDates($stats_airline = '', $filter_name = '') {
614 614
 		global $globalStatsFilters;
615 615
 		if ($filter_name == '') $filter_name = $this->filter_name;
616 616
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
617
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
617
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
618 618
                  try {
619 619
                         $sth = $this->db->prepare($query);
620 620
                         $sth->execute($query_data);
621
-                } catch(PDOException $e) {
621
+                } catch (PDOException $e) {
622 622
                         echo "error : ".$e->getMessage();
623 623
                 }
624 624
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
625 625
                 if (empty($all)) {
626 626
 			$filters = array('airlines' => array($stats_airline));
627 627
 			if ($filter_name != '') {
628
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
628
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
629 629
 			}
630 630
             		$Spotter = new Spotter($this->db);
631 631
             		$all = $Spotter->countAllDates($filters);
@@ -640,28 +640,28 @@  discard block
 block discarded – undo
640 640
                  try {
641 641
                         $sth = $this->db->prepare($query);
642 642
                         $sth->execute($query_data);
643
-                } catch(PDOException $e) {
643
+                } catch (PDOException $e) {
644 644
                         echo "error : ".$e->getMessage();
645 645
                 }
646 646
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
647 647
                 if (empty($all)) {
648 648
             		$filters = array();
649 649
             		if ($filter_name != '') {
650
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
650
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
651 651
 			}
652 652
             		$Spotter = new Spotter($this->db);
653 653
             		$all = $Spotter->countAllDatesByAirlines($filters);
654 654
                 }
655 655
                 return $all;
656 656
 	}
657
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
657
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
658 658
 		global $globalStatsFilters;
659 659
 		if ($filter_name == '') $filter_name = $this->filter_name;
660 660
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661 661
                  try {
662 662
                         $sth = $this->db->prepare($query);
663 663
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
664
-                } catch(PDOException $e) {
664
+                } catch (PDOException $e) {
665 665
                         echo "error : ".$e->getMessage();
666 666
                 }
667 667
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
                 if (empty($all)) {
670 670
 			$filters = array('airlines' => array($stats_airline));
671 671
 			if ($filter_name != '') {
672
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
672
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
673 673
 			}
674 674
             		$Spotter = new Spotter($this->db);
675 675
             		$all = $Spotter->countAllMonths($filters);
@@ -684,21 +684,21 @@  discard block
 block discarded – undo
684 684
                  try {
685 685
                         $sth = $this->db->prepare($query);
686 686
                         $sth->execute(array(':filter_name' => $filter_name));
687
-                } catch(PDOException $e) {
687
+                } catch (PDOException $e) {
688 688
                         echo "error : ".$e->getMessage();
689 689
                 }
690 690
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
691 691
                 if (empty($all)) {
692 692
             		$filters = array();
693 693
             		if ($filter_name != '') {
694
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
694
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
695 695
 			}
696 696
             		$Spotter = new Spotter($this->db);
697 697
             		$all = $Spotter->countAllMilitaryMonths($filters);
698 698
                 }
699 699
                 return $all;
700 700
 	}
701
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
701
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
702 702
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
703 703
 		if ($filter_name == '') $filter_name = $this->filter_name;
704 704
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -715,30 +715,30 @@  discard block
 block discarded – undo
715 715
                  try {
716 716
                         $sth = $this->db->prepare($query);
717 717
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
718
-                } catch(PDOException $e) {
718
+                } catch (PDOException $e) {
719 719
                         echo "error : ".$e->getMessage();
720 720
                 }
721 721
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
722 722
                 if (empty($all)) {
723 723
 			$filters = array('airlines' => array($stats_airline));
724 724
 			if ($filter_name != '') {
725
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
725
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
726 726
 			}
727 727
             		$Spotter = new Spotter($this->db);
728
-            		$all = $Spotter->countAllHours($orderby,$filters);
728
+            		$all = $Spotter->countAllHours($orderby, $filters);
729 729
                 }
730 730
                 return $all;
731 731
 	}
732 732
 	
733
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
733
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
734 734
 		global $globalStatsFilters;
735 735
 		if ($filter_name == '') $filter_name = $this->filter_name;
736 736
 		if ($year == '') $year = date('Y');
737
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
737
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
738 738
 		if (empty($all)) {
739
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
739
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
740 740
 			if ($filter_name != '') {
741
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
741
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
742 742
 			}
743 743
 			$Spotter = new Spotter($this->db);
744 744
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -746,16 +746,16 @@  discard block
 block discarded – undo
746 746
 		}
747 747
 		return $all;
748 748
 	}
749
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
749
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
750 750
 		global $globalStatsFilters;
751 751
 		if ($filter_name == '') $filter_name = $this->filter_name;
752 752
 		if ($year == '') $year = date('Y');
753
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
753
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
754 754
 		if (empty($all)) {
755 755
 		        $filters = array();
756
-			$filters = array('year' => $year,'month' => $month);
756
+			$filters = array('year' => $year, 'month' => $month);
757 757
             		if ($filter_name != '') {
758
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
758
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
759 759
 			}
760 760
 			$Spotter = new Spotter($this->db);
761 761
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -763,15 +763,15 @@  discard block
 block discarded – undo
763 763
 		}
764 764
 		return $all;
765 765
 	}
766
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
766
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
767 767
 		global $globalStatsFilters;
768 768
 		if ($filter_name == '') $filter_name = $this->filter_name;
769 769
 		if ($year == '') $year = date('Y');
770
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
770
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
771 771
 		if (empty($all)) {
772
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
772
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
773 773
 			if ($filter_name != '') {
774
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
774
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
775 775
 			}
776 776
 			$Spotter = new Spotter($this->db);
777 777
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -779,24 +779,24 @@  discard block
 block discarded – undo
779 779
 		}
780 780
 		return $all;
781 781
 	}
782
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
782
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
783 783
 		global $globalStatsFilters;
784 784
 		if ($filter_name == '') $filter_name = $this->filter_name;
785 785
 		if ($year == '' && $month == '') {
786 786
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
787 787
 			try {
788 788
 				$sth = $this->db->prepare($query);
789
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
790
-			} catch(PDOException $e) {
789
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
790
+			} catch (PDOException $e) {
791 791
 				echo "error : ".$e->getMessage();
792 792
 			}
793 793
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
794 794
 			$all = $result[0]['nb'];
795
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
795
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
796 796
 		if (empty($all)) {
797
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
797
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
798 798
 			if ($filter_name != '') {
799
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
799
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
800 800
 			}
801 801
 			$Spotter = new Spotter($this->db);
802 802
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		}
805 805
 		return $all;
806 806
 	}
807
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
807
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
808 808
 		global $globalStatsFilters;
809 809
 		if ($filter_name == '') $filter_name = $this->filter_name;
810 810
 		if ($year == '' && $month == '') {
@@ -812,17 +812,17 @@  discard block
 block discarded – undo
812 812
 			try {
813 813
 				$sth = $this->db->prepare($query);
814 814
 				$sth->execute(array(':filter_name' => $filter_name));
815
-			} catch(PDOException $e) {
815
+			} catch (PDOException $e) {
816 816
 				echo "error : ".$e->getMessage();
817 817
 			}
818 818
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
819 819
 			$all = $result[0]['nb_airline'];
820
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
820
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
821 821
 		if (empty($all)) {
822 822
             		$filters = array();
823
-			$filters = array('year' => $year,'month' => $month);
823
+			$filters = array('year' => $year, 'month' => $month);
824 824
             		if ($filter_name != '') {
825
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
825
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
826 826
 			}
827 827
 			$Spotter = new Spotter($this->db);
828 828
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 		}
831 831
 		return $all;
832 832
 	}
833
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
833
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
834 834
 		global $globalStatsFilters;
835 835
 		if ($filter_name == '') $filter_name = $this->filter_name;
836 836
 		if ($year == '' && $month == '') {
@@ -839,18 +839,18 @@  discard block
 block discarded – undo
839 839
 			try {
840 840
 				$sth = $this->db->prepare($query);
841 841
 				$sth->execute($query_values);
842
-			} catch(PDOException $e) {
842
+			} catch (PDOException $e) {
843 843
 				echo "error : ".$e->getMessage();
844 844
 			}
845 845
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
846 846
 			$all = $result[0]['nb'];
847 847
 		} else {
848
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
848
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
849 849
 		}
850 850
 		if (empty($all)) {
851
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
851
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
852 852
 			if ($filter_name != '') {
853
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
853
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
854 854
 			}
855 855
 			$Spotter = new Spotter($this->db);
856 856
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 		}
859 859
 		return $all;
860 860
 	}
861
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
861
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
862 862
 		global $globalStatsFilters;
863 863
 		if ($filter_name == '') $filter_name = $this->filter_name;
864 864
 		//if ($year == '') $year = date('Y');
@@ -868,18 +868,18 @@  discard block
 block discarded – undo
868 868
 			try {
869 869
 				$sth = $this->db->prepare($query);
870 870
 				$sth->execute($query_values);
871
-			} catch(PDOException $e) {
871
+			} catch (PDOException $e) {
872 872
 				echo "error : ".$e->getMessage();
873 873
 			}
874 874
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
875 875
 			$all = $result[0]['nb'];
876 876
 		} else {
877
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
877
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
878 878
 		}
879 879
 		if (empty($all)) {
880
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
880
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
881 881
 			if ($filter_name != '') {
882
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
882
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
883 883
 			}
884 884
 			$Spotter = new Spotter($this->db);
885 885
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -888,56 +888,56 @@  discard block
 block discarded – undo
888 888
 		return $all;
889 889
 	}
890 890
 
891
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
891
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
892 892
 		if ($filter_name == '') $filter_name = $this->filter_name;
893 893
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
894
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
894
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
895 895
                  try {
896 896
                         $sth = $this->db->prepare($query);
897 897
                         $sth->execute($query_values);
898
-                } catch(PDOException $e) {
898
+                } catch (PDOException $e) {
899 899
                         echo "error : ".$e->getMessage();
900 900
                 }
901 901
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
902 902
                 return $all;
903 903
 	}
904
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
904
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
905 905
 		if ($filter_name == '') $filter_name = $this->filter_name;
906 906
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
907
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
907
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
908 908
                  try {
909 909
                         $sth = $this->db->prepare($query);
910 910
                         $sth->execute($query_values);
911
-                } catch(PDOException $e) {
911
+                } catch (PDOException $e) {
912 912
                         echo "error : ".$e->getMessage();
913 913
                 }
914 914
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
915 915
                 return $all;
916 916
         }
917
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
917
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
918 918
 		if ($filter_name == '') $filter_name = $this->filter_name;
919 919
     		global $globalArchiveMonths, $globalDBdriver;
920 920
     		if ($globalDBdriver == 'mysql') {
921 921
     			if ($month == '') {
922 922
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
923
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
923
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
924 924
 			} else {
925 925
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
926
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
926
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
927 927
 			}
928 928
 		} else {
929 929
 			if ($month == '') {
930 930
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
931
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
931
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
932 932
 			} else {
933 933
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
934
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
934
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
935 935
 			}
936 936
                 }
937 937
                  try {
938 938
                         $sth = $this->db->prepare($query);
939 939
                         $sth->execute($query_values);
940
-                } catch(PDOException $e) {
940
+                } catch (PDOException $e) {
941 941
                         echo "error : ".$e->getMessage();
942 942
                 }
943 943
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
                  try {
956 956
                         $sth = $this->db->prepare($query);
957 957
                         $sth->execute($query_values);
958
-                } catch(PDOException $e) {
958
+                } catch (PDOException $e) {
959 959
                         echo "error : ".$e->getMessage();
960 960
                 }
961 961
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
                  try {
973 973
                         $sth = $this->db->prepare($query);
974 974
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
975
-                } catch(PDOException $e) {
975
+                } catch (PDOException $e) {
976 976
                         echo "error : ".$e->getMessage();
977 977
                 }
978 978
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
                  try {
990 990
                         $sth = $this->db->prepare($query);
991 991
                         $sth->execute(array(':filter_name' => $filter_name));
992
-                } catch(PDOException $e) {
992
+                } catch (PDOException $e) {
993 993
                         echo "error : ".$e->getMessage();
994 994
                 }
995 995
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1006,20 +1006,20 @@  discard block
 block discarded – undo
1006 1006
                  try {
1007 1007
                         $sth = $this->db->prepare($query);
1008 1008
                         $sth->execute(array(':filter_name' => $filter_name));
1009
-                } catch(PDOException $e) {
1009
+                } catch (PDOException $e) {
1010 1010
                         echo "error : ".$e->getMessage();
1011 1011
                 }
1012 1012
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1013 1013
                 return $all[0]['total'];
1014 1014
         }
1015
-	public function getStatsOwner($owner_name,$filter_name = '') {
1015
+	public function getStatsOwner($owner_name, $filter_name = '') {
1016 1016
     		global $globalArchiveMonths, $globalDBdriver;
1017 1017
 		if ($filter_name == '') $filter_name = $this->filter_name;
1018 1018
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1019 1019
                  try {
1020 1020
                         $sth = $this->db->prepare($query);
1021
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1022
-                } catch(PDOException $e) {
1021
+                        $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1022
+                } catch (PDOException $e) {
1023 1023
                         echo "error : ".$e->getMessage();
1024 1024
                 }
1025 1025
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1037,20 +1037,20 @@  discard block
 block discarded – undo
1037 1037
                  try {
1038 1038
                         $sth = $this->db->prepare($query);
1039 1039
                         $sth->execute(array(':filter_name' => $filter_name));
1040
-                } catch(PDOException $e) {
1040
+                } catch (PDOException $e) {
1041 1041
                         echo "error : ".$e->getMessage();
1042 1042
                 }
1043 1043
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1044 1044
                 return $all[0]['total'];
1045 1045
         }
1046
-	public function getStatsPilot($pilot,$filter_name = '') {
1046
+	public function getStatsPilot($pilot, $filter_name = '') {
1047 1047
     		global $globalArchiveMonths, $globalDBdriver;
1048 1048
 		if ($filter_name == '') $filter_name = $this->filter_name;
1049 1049
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1050 1050
                  try {
1051 1051
                         $sth = $this->db->prepare($query);
1052
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1053
-                } catch(PDOException $e) {
1052
+                        $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1053
+                } catch (PDOException $e) {
1054 1054
                         echo "error : ".$e->getMessage();
1055 1055
                 }
1056 1056
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
                 else return 0;
1059 1059
         }
1060 1060
 
1061
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1061
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1062 1062
 		global $globalDBdriver;
1063 1063
 		if ($filter_name == '') $filter_name = $this->filter_name;
1064 1064
 		if ($globalDBdriver == 'mysql') {
@@ -1066,15 +1066,15 @@  discard block
 block discarded – undo
1066 1066
                 } else {
1067 1067
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1068 1068
 		}
1069
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1069
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1070 1070
                  try {
1071 1071
                         $sth = $this->db->prepare($query);
1072 1072
                         $sth->execute($query_values);
1073
-                } catch(PDOException $e) {
1073
+                } catch (PDOException $e) {
1074 1074
                         return "error : ".$e->getMessage();
1075 1075
                 }
1076 1076
         }
1077
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1077
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1078 1078
 		global $globalDBdriver;
1079 1079
 		if ($filter_name == '') $filter_name = $this->filter_name;
1080 1080
 		if ($globalDBdriver == 'mysql') {
@@ -1083,11 +1083,11 @@  discard block
 block discarded – undo
1083 1083
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1084 1084
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1085 1085
                 }
1086
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1086
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1087 1087
                  try {
1088 1088
                         $sth = $this->db->prepare($query);
1089 1089
                         $sth->execute($query_values);
1090
-                } catch(PDOException $e) {
1090
+                } catch (PDOException $e) {
1091 1091
                         return "error : ".$e->getMessage();
1092 1092
                 }
1093 1093
         }
@@ -1111,75 +1111,75 @@  discard block
 block discarded – undo
1111 1111
         }
1112 1112
         */
1113 1113
 
1114
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1114
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1115 1115
 		global $globalDBdriver;
1116 1116
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1117 1117
 		$query_values = array();
1118 1118
 		if ($globalDBdriver == 'mysql') {
1119 1119
 			if ($year != '') {
1120 1120
 				$query .= ' AND YEAR(stats_date) = :year';
1121
-				$query_values = array_merge($query_values,array(':year' => $year));
1121
+				$query_values = array_merge($query_values, array(':year' => $year));
1122 1122
 			}
1123 1123
 			if ($month != '') {
1124 1124
 				$query .= ' AND MONTH(stats_date) = :month';
1125
-				$query_values = array_merge($query_values,array(':month' => $month));
1125
+				$query_values = array_merge($query_values, array(':month' => $month));
1126 1126
 			}
1127 1127
 			if ($day != '') {
1128 1128
 				$query .= ' AND DAY(stats_date) = :day';
1129
-				$query_values = array_merge($query_values,array(':day' => $day));
1129
+				$query_values = array_merge($query_values, array(':day' => $day));
1130 1130
 			}
1131 1131
 		} else {
1132 1132
 			if ($year != '') {
1133 1133
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1134
-				$query_values = array_merge($query_values,array(':year' => $year));
1134
+				$query_values = array_merge($query_values, array(':year' => $year));
1135 1135
 			}
1136 1136
 			if ($month != '') {
1137 1137
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1138
-				$query_values = array_merge($query_values,array(':month' => $month));
1138
+				$query_values = array_merge($query_values, array(':month' => $month));
1139 1139
 			}
1140 1140
 			if ($day != '') {
1141 1141
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1142
-				$query_values = array_merge($query_values,array(':day' => $day));
1142
+				$query_values = array_merge($query_values, array(':day' => $day));
1143 1143
 			}
1144 1144
 		}
1145 1145
 		$query .= " ORDER BY source_name";
1146
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1146
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1147 1147
 		try {
1148 1148
 			$sth = $this->db->prepare($query);
1149 1149
 			$sth->execute($query_values);
1150
-		} catch(PDOException $e) {
1150
+		} catch (PDOException $e) {
1151 1151
 			echo "error : ".$e->getMessage();
1152 1152
 		}
1153 1153
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1154 1154
 		return $all;
1155 1155
 	}
1156 1156
 
1157
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1157
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1158 1158
 		global $globalDBdriver;
1159 1159
 		if ($globalDBdriver == 'mysql') {
1160 1160
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1161 1161
 		} else {
1162 1162
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1163 1163
                 }
1164
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1164
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1165 1165
                  try {
1166 1166
                         $sth = $this->db->prepare($query);
1167 1167
                         $sth->execute($query_values);
1168
-                } catch(PDOException $e) {
1168
+                } catch (PDOException $e) {
1169 1169
                         return "error : ".$e->getMessage();
1170 1170
                 }
1171 1171
         }
1172
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1172
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1173 1173
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1174
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1174
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1175 1175
                  try {
1176 1176
                         $sth = $this->db->prepare($query);
1177 1177
                         $sth->execute($query_values);
1178
-                } catch(PDOException $e) {
1178
+                } catch (PDOException $e) {
1179 1179
                         return "error : ".$e->getMessage();
1180 1180
                 }
1181 1181
         }
1182
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1182
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1183 1183
 		global $globalDBdriver;
1184 1184
 		if ($globalDBdriver == 'mysql') {
1185 1185
 			if ($reset) {
@@ -1194,15 +1194,15 @@  discard block
 block discarded – undo
1194 1194
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1195 1195
 			}
1196 1196
 		}
1197
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1197
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1198 1198
                  try {
1199 1199
                         $sth = $this->db->prepare($query);
1200 1200
                         $sth->execute($query_values);
1201
-                } catch(PDOException $e) {
1201
+                } catch (PDOException $e) {
1202 1202
                         return "error : ".$e->getMessage();
1203 1203
                 }
1204 1204
         }
1205
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1205
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1206 1206
 		global $globalDBdriver;
1207 1207
 		if ($globalDBdriver == 'mysql') {
1208 1208
 			if ($reset) {
@@ -1217,15 +1217,15 @@  discard block
 block discarded – undo
1217 1217
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1218 1218
 			}
1219 1219
 		}
1220
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1220
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1221 1221
                  try {
1222 1222
                         $sth = $this->db->prepare($query);
1223 1223
                         $sth->execute($query_values);
1224
-                } catch(PDOException $e) {
1224
+                } catch (PDOException $e) {
1225 1225
                         return "error : ".$e->getMessage();
1226 1226
                 }
1227 1227
         }
1228
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1228
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1229 1229
 		global $globalDBdriver;
1230 1230
 		if ($globalDBdriver == 'mysql') {
1231 1231
 			if ($reset) {
@@ -1240,15 +1240,15 @@  discard block
 block discarded – undo
1240 1240
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1241 1241
 			}
1242 1242
 		}
1243
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1243
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1244 1244
                  try {
1245 1245
                         $sth = $this->db->prepare($query);
1246 1246
                         $sth->execute($query_values);
1247
-                } catch(PDOException $e) {
1247
+                } catch (PDOException $e) {
1248 1248
                         return "error : ".$e->getMessage();
1249 1249
                 }
1250 1250
         }
1251
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1251
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1252 1252
 		global $globalDBdriver;
1253 1253
 		if ($globalDBdriver == 'mysql') {
1254 1254
 			if ($reset) {
@@ -1263,15 +1263,15 @@  discard block
 block discarded – undo
1263 1263
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1264 1264
 			}
1265 1265
 		}
1266
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1266
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1267 1267
                  try {
1268 1268
                         $sth = $this->db->prepare($query);
1269 1269
                         $sth->execute($query_values);
1270
-                } catch(PDOException $e) {
1270
+                } catch (PDOException $e) {
1271 1271
                         return "error : ".$e->getMessage();
1272 1272
                 }
1273 1273
         }
1274
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1274
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1275 1275
 		global $globalDBdriver;
1276 1276
 		if ($globalDBdriver == 'mysql') {
1277 1277
 			if ($reset) {
@@ -1286,15 +1286,15 @@  discard block
 block discarded – undo
1286 1286
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1287 1287
 			}
1288 1288
 		}
1289
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1289
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1290 1290
                  try {
1291 1291
                         $sth = $this->db->prepare($query);
1292 1292
                         $sth->execute($query_values);
1293
-                } catch(PDOException $e) {
1293
+                } catch (PDOException $e) {
1294 1294
                         return "error : ".$e->getMessage();
1295 1295
                 }
1296 1296
         }
1297
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1297
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1298 1298
 		global $globalDBdriver;
1299 1299
 		if ($globalDBdriver == 'mysql') {
1300 1300
 			if ($reset) {
@@ -1309,15 +1309,15 @@  discard block
 block discarded – undo
1309 1309
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1310 1310
 			}
1311 1311
 		}
1312
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1312
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1313 1313
                  try {
1314 1314
                         $sth = $this->db->prepare($query);
1315 1315
                         $sth->execute($query_values);
1316
-                } catch(PDOException $e) {
1316
+                } catch (PDOException $e) {
1317 1317
                         return "error : ".$e->getMessage();
1318 1318
                 }
1319 1319
         }
1320
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1320
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1321 1321
 		global $globalDBdriver;
1322 1322
 		if ($globalDBdriver == 'mysql') {
1323 1323
 			if ($reset) {
@@ -1332,15 +1332,15 @@  discard block
 block discarded – undo
1332 1332
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1333 1333
 			}
1334 1334
 		}
1335
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1335
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1336 1336
                  try {
1337 1337
                         $sth = $this->db->prepare($query);
1338 1338
                         $sth->execute($query_values);
1339
-                } catch(PDOException $e) {
1339
+                } catch (PDOException $e) {
1340 1340
                         return "error : ".$e->getMessage();
1341 1341
                 }
1342 1342
         }
1343
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1343
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1344 1344
 		global $globalDBdriver;
1345 1345
 		if ($airport_icao != '') {
1346 1346
 			if ($globalDBdriver == 'mysql') {
@@ -1356,16 +1356,16 @@  discard block
 block discarded – undo
1356 1356
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1357 1357
 				}
1358 1358
 			}
1359
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1359
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1360 1360
 			try {
1361 1361
 				$sth = $this->db->prepare($query);
1362 1362
 				$sth->execute($query_values);
1363
-			} catch(PDOException $e) {
1363
+			} catch (PDOException $e) {
1364 1364
 				return "error : ".$e->getMessage();
1365 1365
 			}
1366 1366
                 }
1367 1367
         }
1368
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1368
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1369 1369
 		global $globalDBdriver;
1370 1370
 		if ($airport_icao != '') {
1371 1371
 			if ($globalDBdriver == 'mysql') {
@@ -1373,16 +1373,16 @@  discard block
 block discarded – undo
1373 1373
 			} else {
1374 1374
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1375 1375
 			}
1376
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1376
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1377 1377
 			 try {
1378 1378
 				$sth = $this->db->prepare($query);
1379 1379
 				$sth->execute($query_values);
1380
-			} catch(PDOException $e) {
1380
+			} catch (PDOException $e) {
1381 1381
 				return "error : ".$e->getMessage();
1382 1382
 			}
1383 1383
                 }
1384 1384
         }
1385
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1385
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1386 1386
 		global $globalDBdriver;
1387 1387
 		if ($airport_icao != '') {
1388 1388
 			if ($globalDBdriver == 'mysql') {
@@ -1398,16 +1398,16 @@  discard block
 block discarded – undo
1398 1398
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1399 1399
 				}
1400 1400
 			}
1401
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1401
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1402 1402
 			 try {
1403 1403
                     		$sth = $this->db->prepare($query);
1404 1404
 	                        $sth->execute($query_values);
1405
-    		        } catch(PDOException $e) {
1405
+    		        } catch (PDOException $e) {
1406 1406
             		        return "error : ".$e->getMessage();
1407 1407
 	                }
1408 1408
 	        }
1409 1409
         }
1410
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1410
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1411 1411
 		global $globalDBdriver;
1412 1412
 		if ($airport_icao != '') {
1413 1413
 			if ($globalDBdriver == 'mysql') {
@@ -1415,11 +1415,11 @@  discard block
 block discarded – undo
1415 1415
 			} else {
1416 1416
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1417 1417
 			}
1418
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1418
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1419 1419
 			try {
1420 1420
 				$sth = $this->db->prepare($query);
1421 1421
 				$sth->execute($query_values);
1422
-			} catch(PDOException $e) {
1422
+			} catch (PDOException $e) {
1423 1423
 				return "error : ".$e->getMessage();
1424 1424
 			}
1425 1425
                 }
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
                  try {
1432 1432
                         $sth = $this->db->prepare($query);
1433 1433
                         $sth->execute($query_values);
1434
-                } catch(PDOException $e) {
1434
+                } catch (PDOException $e) {
1435 1435
                         return "error : ".$e->getMessage();
1436 1436
                 }
1437 1437
         }
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
                  try {
1442 1442
                         $sth = $this->db->prepare($query);
1443 1443
                         $sth->execute($query_values);
1444
-                } catch(PDOException $e) {
1444
+                } catch (PDOException $e) {
1445 1445
                         return "error : ".$e->getMessage();
1446 1446
                 }
1447 1447
         }
@@ -1451,13 +1451,13 @@  discard block
 block discarded – undo
1451 1451
                  try {
1452 1452
                         $sth = $this->db->prepare($query);
1453 1453
                         $sth->execute($query_values);
1454
-                } catch(PDOException $e) {
1454
+                } catch (PDOException $e) {
1455 1455
                         return "error : ".$e->getMessage();
1456 1456
                 }
1457 1457
         }
1458 1458
         
1459 1459
         public function addOldStats() {
1460
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1460
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1461 1461
     		$Common = new Common();
1462 1462
     		$Connection = new Connection();
1463 1463
     		date_default_timezone_set('UTC');
@@ -1475,40 +1475,40 @@  discard block
 block discarded – undo
1475 1475
 			$Spotter = new Spotter($this->db);
1476 1476
 
1477 1477
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1478
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1478
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1479 1479
 			foreach ($alldata as $number) {
1480
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1480
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1481 1481
 			}
1482 1482
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1483
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1483
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1484 1484
 			foreach ($alldata as $number) {
1485
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1485
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1486 1486
 			}
1487 1487
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1488
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1488
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1489 1489
 			foreach ($alldata as $number) {
1490
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1490
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1491 1491
 			}
1492 1492
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1493
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1493
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1494 1494
 			foreach ($alldata as $number) {
1495
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1495
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1496 1496
 			}
1497 1497
 			if ($globalDebug) echo 'Count all owners...'."\n";
1498
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1498
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1499 1499
 			foreach ($alldata as $number) {
1500
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1500
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1501 1501
 			}
1502 1502
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1503
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1503
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1504 1504
 			foreach ($alldata as $number) {
1505
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1505
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1506 1506
 			}
1507 1507
 			
1508 1508
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1509
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1509
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1510 1510
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1511
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1511
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1512 1512
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1513 1513
 	        	$alldata = array();
1514 1514
 	        	
@@ -1526,14 +1526,14 @@  discard block
 block discarded – undo
1526 1526
     			foreach ($alldata as $key => $row) {
1527 1527
     				$count[$key] = $row['airport_departure_icao_count'];
1528 1528
         		}
1529
-			array_multisort($count,SORT_DESC,$alldata);
1529
+			array_multisort($count, SORT_DESC, $alldata);
1530 1530
 			foreach ($alldata as $number) {
1531
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1531
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1532 1532
 			}
1533 1533
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1534
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1534
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1535 1535
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1536
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1536
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1537 1537
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1538 1538
 	        	$alldata = array();
1539 1539
     			foreach ($pall as $value) {
@@ -1550,16 +1550,16 @@  discard block
 block discarded – undo
1550 1550
         		foreach ($alldata as $key => $row) {
1551 1551
         			$count[$key] = $row['airport_arrival_icao_count'];
1552 1552
 	        	}
1553
-    			array_multisort($count,SORT_DESC,$alldata);
1553
+    			array_multisort($count, SORT_DESC, $alldata);
1554 1554
                         foreach ($alldata as $number) {
1555
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1555
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1556 1556
 			}
1557 1557
 			if ($Connection->tableExists('countries')) {
1558 1558
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1559 1559
 				$SpotterArchive = new SpotterArchive();
1560
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1560
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1561 1561
 				foreach ($alldata as $number) {
1562
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1562
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1563 1563
 				}
1564 1564
 			}
1565 1565
 			
@@ -1573,37 +1573,37 @@  discard block
 block discarded – undo
1573 1573
 			$lastyear = false;
1574 1574
 			foreach ($alldata as $number) {
1575 1575
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1576
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1576
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1577 1577
 			}
1578 1578
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1579 1579
 			$alldata = $Spotter->countAllMilitaryMonths();
1580 1580
 			foreach ($alldata as $number) {
1581
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1581
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1582 1582
 			}
1583 1583
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1584 1584
 			$alldata = $Spotter->countAllMonthsOwners();
1585 1585
 			foreach ($alldata as $number) {
1586
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1586
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1587 1587
 			}
1588 1588
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1589 1589
 			$alldata = $Spotter->countAllMonthsPilots();
1590 1590
 			foreach ($alldata as $number) {
1591
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1591
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1592 1592
 			}
1593 1593
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1594 1594
 			$alldata = $Spotter->countAllMonthsAirlines();
1595 1595
 			foreach ($alldata as $number) {
1596
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1596
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1597 1597
 			}
1598 1598
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1599 1599
 			$alldata = $Spotter->countAllMonthsAircrafts();
1600 1600
 			foreach ($alldata as $number) {
1601
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1601
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1602 1602
 			}
1603 1603
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1604 1604
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1605 1605
 			foreach ($alldata as $number) {
1606
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1606
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1607 1607
 			}
1608 1608
 			if ($globalDebug) echo 'Airports data...'."\n";
1609 1609
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
     			}
1649 1649
     			$alldata = $pall;
1650 1650
 			foreach ($alldata as $number) {
1651
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1651
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1652 1652
 			}
1653 1653
 			echo '...Arrival'."\n";
1654 1654
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
     			}
1691 1691
     			$alldata = $pall;
1692 1692
 			foreach ($alldata as $number) {
1693
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1693
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1694 1694
 			}
1695 1695
 
1696 1696
 			echo 'Flights data...'."\n";
@@ -1698,28 +1698,28 @@  discard block
 block discarded – undo
1698 1698
 			echo '-> countAllDatesLastMonth...'."\n";
1699 1699
 			$alldata = $Spotter->countAllDatesLastMonth();
1700 1700
 			foreach ($alldata as $number) {
1701
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1701
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1702 1702
 			}
1703 1703
 			echo '-> countAllDates...'."\n";
1704 1704
 			$previousdata = $this->countAllDates();
1705 1705
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1706 1706
 			$this->deleteStatFlight('date');
1707
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1707
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1708 1708
 			$values = array();
1709 1709
 			foreach ($alldata as $cnt) {
1710 1710
 				$values[] = $cnt['date_count'];
1711 1711
 			}
1712
-			array_multisort($values,SORT_DESC,$alldata);
1713
-			array_splice($alldata,11);
1712
+			array_multisort($values, SORT_DESC, $alldata);
1713
+			array_splice($alldata, 11);
1714 1714
 			foreach ($alldata as $number) {
1715
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1715
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1716 1716
 			}
1717 1717
 			
1718 1718
 			$this->deleteStatFlight('hour');
1719 1719
 			echo '-> countAllHours...'."\n";
1720 1720
 			$alldata = $Spotter->countAllHours('hour');
1721 1721
 			foreach ($alldata as $number) {
1722
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1722
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1723 1723
 			}
1724 1724
 
1725 1725
 
@@ -1729,41 +1729,41 @@  discard block
 block discarded – undo
1729 1729
 			if ($Connection->tableExists('countries')) {
1730 1730
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1731 1731
 				$SpotterArchive = new SpotterArchive();
1732
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1732
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1733 1733
 				foreach ($alldata as $number) {
1734
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1734
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1735 1735
 				}
1736 1736
 			}
1737 1737
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1738 1738
 			$Spotter = new Spotter($this->db);
1739
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1739
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1740 1740
 			foreach ($alldata as $number) {
1741
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1741
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1742 1742
 			}
1743 1743
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1744
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1744
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1745 1745
 			foreach ($alldata as $number) {
1746
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1746
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1747 1747
 			}
1748 1748
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1749
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1749
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1750 1750
 			foreach ($alldata as $number) {
1751
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1751
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1752 1752
 			}
1753 1753
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1754
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1754
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1755 1755
 			foreach ($alldata as $number) {
1756
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1756
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1757 1757
 			}
1758 1758
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1759
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1759
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1760 1760
 			foreach ($alldata as $number) {
1761
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1761
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1762 1762
 			}
1763 1763
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1764
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1764
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1765 1765
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1766
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1766
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1767 1767
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1768 1768
 	        	//$alldata = array();
1769 1769
     			foreach ($dall as $value) {
@@ -1783,12 +1783,12 @@  discard block
 block discarded – undo
1783 1783
     			}
1784 1784
     			$alldata = $pall;
1785 1785
 			foreach ($alldata as $number) {
1786
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1786
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
1787 1787
 			}
1788 1788
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1789
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1789
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1790 1790
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1791
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1791
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1792 1792
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1793 1793
 	        	//$alldata = array();
1794 1794
     			foreach ($dall as $value) {
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
     			}
1809 1809
     			$alldata = $pall;
1810 1810
                         foreach ($alldata as $number) {
1811
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1811
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
1812 1812
 			}
1813 1813
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1814 1814
 			$Spotter = new Spotter($this->db);
@@ -1816,27 +1816,27 @@  discard block
 block discarded – undo
1816 1816
 			$lastyear = false;
1817 1817
 			foreach ($alldata as $number) {
1818 1818
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1819
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1819
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1820 1820
 			}
1821 1821
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1822 1822
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1823 1823
 			foreach ($alldata as $number) {
1824
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1824
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1825 1825
 			}
1826 1826
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1827 1827
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1828 1828
 			foreach ($alldata as $number) {
1829
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1829
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1830 1830
 			}
1831 1831
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1832 1832
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1833 1833
 			foreach ($alldata as $number) {
1834
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1834
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1835 1835
 			}
1836 1836
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1837 1837
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1838 1838
 			foreach ($alldata as $number) {
1839
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1839
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1840 1840
 			}
1841 1841
 			if ($globalDebug) echo '...Departure'."\n";
1842 1842
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
     			}
1860 1860
     			$alldata = $pall;
1861 1861
 			foreach ($alldata as $number) {
1862
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1862
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
1863 1863
 			}
1864 1864
 			if ($globalDebug) echo '...Arrival'."\n";
1865 1865
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1882,32 +1882,32 @@  discard block
 block discarded – undo
1882 1882
     			}
1883 1883
     			$alldata = $pall;
1884 1884
 			foreach ($alldata as $number) {
1885
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1885
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
1886 1886
 			}
1887 1887
 
1888 1888
 			if ($globalDebug) echo 'Flights data...'."\n";
1889 1889
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1890 1890
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1891 1891
 			foreach ($alldata as $number) {
1892
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1892
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1893 1893
 			}
1894 1894
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1895 1895
 			//$previousdata = $this->countAllDatesByAirlines();
1896
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1896
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1897 1897
 			$values = array();
1898 1898
 			foreach ($alldata as $cnt) {
1899 1899
 				$values[] = $cnt['date_count'];
1900 1900
 			}
1901
-			array_multisort($values,SORT_DESC,$alldata);
1902
-			array_splice($alldata,11);
1901
+			array_multisort($values, SORT_DESC, $alldata);
1902
+			array_splice($alldata, 11);
1903 1903
 			foreach ($alldata as $number) {
1904
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1904
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1905 1905
 			}
1906 1906
 			
1907 1907
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1908 1908
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1909 1909
 			foreach ($alldata as $number) {
1910
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1910
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1911 1911
 			}
1912 1912
 			
1913 1913
 
@@ -1929,7 +1929,7 @@  discard block
 block discarded – undo
1929 1929
 						$last_update_day = date('Y').'-01-01 00:00:00';
1930 1930
 					}
1931 1931
 				}
1932
-				if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
1932
+				if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
1933 1933
 					$last_update_day = date('Y').'-01-01 00:00:00';
1934 1934
 					$reset = true;
1935 1935
 				}
@@ -1938,32 +1938,32 @@  discard block
 block discarded – undo
1938 1938
 				// Count by filter
1939 1939
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1940 1940
 				$Spotter = new Spotter($this->db);
1941
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1941
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1942 1942
 				foreach ($alldata as $number) {
1943
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1943
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1944 1944
 				}
1945
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1945
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1946 1946
 				foreach ($alldata as $number) {
1947
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1947
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1948 1948
 				}
1949
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1949
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1950 1950
 				foreach ($alldata as $number) {
1951
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1951
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1952 1952
 				}
1953
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1953
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1954 1954
 				foreach ($alldata as $number) {
1955
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1955
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1956 1956
 				}
1957
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1957
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1958 1958
 				foreach ($alldata as $number) {
1959
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1959
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1960 1960
 				}
1961
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1961
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1962 1962
 				foreach ($alldata as $number) {
1963
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1963
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1964 1964
 				}
1965
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1966
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1965
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1966
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1967 1967
 		        	$alldata = array();
1968 1968
 	    			foreach ($pall as $value) {
1969 1969
 		        		$icao = $value['airport_departure_icao'];
@@ -1979,12 +1979,12 @@  discard block
 block discarded – undo
1979 1979
     				foreach ($alldata as $key => $row) {
1980 1980
     					$count[$key] = $row['airport_departure_icao_count'];
1981 1981
     				}
1982
-				array_multisort($count,SORT_DESC,$alldata);
1982
+				array_multisort($count, SORT_DESC, $alldata);
1983 1983
 				foreach ($alldata as $number) {
1984
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1984
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
1985 1985
 				}
1986
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1987
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1986
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1987
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1988 1988
 				$alldata = array();
1989 1989
     				foreach ($pall as $value) {
1990 1990
 		        		$icao = $value['airport_arrival_icao'];
@@ -2000,40 +2000,40 @@  discard block
 block discarded – undo
2000 2000
         			foreach ($alldata as $key => $row) {
2001 2001
     					$count[$key] = $row['airport_arrival_icao_count'];
2002 2002
 		        	}
2003
-        			array_multisort($count,SORT_DESC,$alldata);
2003
+        			array_multisort($count, SORT_DESC, $alldata);
2004 2004
 				foreach ($alldata as $number) {
2005
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2005
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
2006 2006
 				}
2007 2007
 				$Spotter = new Spotter($this->db);
2008 2008
 				$alldata = $Spotter->countAllMonths($filter);
2009 2009
 				$lastyear = false;
2010 2010
 				foreach ($alldata as $number) {
2011 2011
 					if ($number['year_name'] != date('Y')) $lastyear = true;
2012
-					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2012
+					$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2013 2013
 				}
2014 2014
 				$alldata = $Spotter->countAllMonthsOwners($filter);
2015 2015
 				foreach ($alldata as $number) {
2016
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2016
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2017 2017
 				}
2018 2018
 				$alldata = $Spotter->countAllMonthsPilots($filter);
2019 2019
 				foreach ($alldata as $number) {
2020
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2020
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2021 2021
 				}
2022 2022
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
2023 2023
 				foreach ($alldata as $number) {
2024
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2024
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2025 2025
 				}
2026 2026
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
2027 2027
 				foreach ($alldata as $number) {
2028
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2028
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2029 2029
 				}
2030 2030
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2031 2031
 				foreach ($alldata as $number) {
2032
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2032
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2033 2033
 				}
2034 2034
 				echo '...Departure'."\n";
2035
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2036
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2035
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2036
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2037 2037
 				foreach ($dall as $value) {
2038 2038
     					$icao = $value['departure_airport_icao'];
2039 2039
     					$ddate = $value['date'];
@@ -2051,11 +2051,11 @@  discard block
 block discarded – undo
2051 2051
     				}
2052 2052
 	    			$alldata = $pall;
2053 2053
 				foreach ($alldata as $number) {
2054
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2054
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
2055 2055
 				}
2056 2056
 				echo '...Arrival'."\n";
2057
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2058
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2057
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2058
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2059 2059
 				foreach ($dall as $value) {
2060 2060
 					$icao = $value['arrival_airport_icao'];
2061 2061
 					$ddate = $value['date'];
@@ -2073,40 +2073,40 @@  discard block
 block discarded – undo
2073 2073
     				}
2074 2074
     				$alldata = $pall;
2075 2075
 				foreach ($alldata as $number) {
2076
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2076
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
2077 2077
 				}
2078 2078
     
2079 2079
 				echo 'Flights data...'."\n";
2080 2080
 				echo '-> countAllDatesLastMonth...'."\n";
2081 2081
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2082 2082
 				foreach ($alldata as $number) {
2083
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2083
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2084 2084
 				}
2085 2085
 				echo '-> countAllDates...'."\n";
2086
-				$previousdata = $this->countAllDates('',$filter_name);
2087
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2086
+				$previousdata = $this->countAllDates('', $filter_name);
2087
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2088 2088
 				$values = array();
2089 2089
 				foreach ($alldata as $cnt) {
2090 2090
 					$values[] = $cnt['date_count'];
2091 2091
 				}
2092
-				array_multisort($values,SORT_DESC,$alldata);
2093
-				array_splice($alldata,11);
2092
+				array_multisort($values, SORT_DESC, $alldata);
2093
+				array_splice($alldata, 11);
2094 2094
 				foreach ($alldata as $number) {
2095
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2095
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2096 2096
 				}
2097 2097
 				
2098 2098
 				echo '-> countAllHours...'."\n";
2099
-				$alldata = $Spotter->countAllHours('hour',$filter);
2099
+				$alldata = $Spotter->countAllHours('hour', $filter);
2100 2100
 				foreach ($alldata as $number) {
2101
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2101
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2102 2102
 				}
2103 2103
 				echo 'Insert last stats update date...'."\n";
2104 2104
 				date_default_timezone_set('UTC');
2105
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2105
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2106 2106
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2107
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2107
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2108 2108
 						$this->deleteOldStats($filter_name);
2109
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2109
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2110 2110
 					}
2111 2111
 				}
2112 2112
 
@@ -2119,16 +2119,16 @@  discard block
 block discarded – undo
2119 2119
 				// SUM all previous month to put as year
2120 2120
 				$previous_year = date('Y');
2121 2121
 				$previous_year--;
2122
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2123
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2124
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2125
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2122
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2123
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2124
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2125
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2126 2126
 				$allairlines = $this->getAllAirlineNames();
2127 2127
 				foreach ($allairlines as $data) {
2128
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2129
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2130
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2131
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2128
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2129
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2130
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2131
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2132 2132
 				}
2133 2133
 				
2134 2134
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2137,7 +2137,7 @@  discard block
 block discarded – undo
2137 2137
 						try {
2138 2138
 							$sth = $this->db->prepare($query);
2139 2139
 							$sth->execute();
2140
-						} catch(PDOException $e) {
2140
+						} catch (PDOException $e) {
2141 2141
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2142 2142
 						}
2143 2143
 					}
@@ -2146,15 +2146,15 @@  discard block
 block discarded – undo
2146 2146
 					try {
2147 2147
 						$sth = $this->db->prepare($query);
2148 2148
 						$sth->execute();
2149
-					} catch(PDOException $e) {
2149
+					} catch (PDOException $e) {
2150 2150
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2151 2151
 					}
2152 2152
 				}
2153 2153
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2154 2154
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2155
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2155
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2156 2156
 						$this->deleteOldStats();
2157
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2157
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2158 2158
 						$lastyearupdate = true;
2159 2159
 					}
2160 2160
 				}
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 					try {
2177 2177
 						$sth = $this->db->prepare($query);
2178 2178
 						$sth->execute();
2179
-					} catch(PDOException $e) {
2179
+					} catch (PDOException $e) {
2180 2180
 						return "error : ".$e->getMessage();
2181 2181
 					}
2182 2182
 				}
@@ -2190,14 +2190,14 @@  discard block
 block discarded – undo
2190 2190
 				try {
2191 2191
 					$sth = $this->db->prepare($query);
2192 2192
 					$sth->execute();
2193
-				} catch(PDOException $e) {
2193
+				} catch (PDOException $e) {
2194 2194
 					return "error : ".$e->getMessage();
2195 2195
 				}
2196 2196
 			}
2197 2197
 			if (!isset($lastyearupdate)) {
2198 2198
 				echo 'Insert last stats update date...'."\n";
2199 2199
 				date_default_timezone_set('UTC');
2200
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2200
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2201 2201
 			}
2202 2202
 			if ($globalStatsResetYear) {
2203 2203
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +473 added lines, -164 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -80,7 +82,9 @@  discard block
 block discarded – undo
80 82
                 }
81 83
         }
82 84
 	public function getAllAirlineNames($filter_name = '') {
83
-		if ($filter_name == '') $filter_name = $this->filter_name;
85
+		if ($filter_name == '') {
86
+			$filter_name = $this->filter_name;
87
+		}
84 88
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
85 89
                  try {
86 90
                         $sth = $this->db->prepare($query);
@@ -92,7 +96,9 @@  discard block
 block discarded – undo
92 96
                 return $all;
93 97
         }
94 98
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
95
-		if ($filter_name == '') $filter_name = $this->filter_name;
99
+		if ($filter_name == '') {
100
+			$filter_name = $this->filter_name;
101
+		}
96 102
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
97 103
                  try {
98 104
                         $sth = $this->db->prepare($query);
@@ -104,7 +110,9 @@  discard block
 block discarded – undo
104 110
                 return $all;
105 111
         }
106 112
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
107
-		if ($filter_name == '') $filter_name = $this->filter_name;
113
+		if ($filter_name == '') {
114
+			$filter_name = $this->filter_name;
115
+		}
108 116
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
109 117
                  try {
110 118
                         $sth = $this->db->prepare($query);
@@ -116,7 +124,9 @@  discard block
 block discarded – undo
116 124
                 return $all;
117 125
         }
118 126
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
119
-		if ($filter_name == '') $filter_name = $this->filter_name;
127
+		if ($filter_name == '') {
128
+			$filter_name = $this->filter_name;
129
+		}
120 130
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
121 131
                  try {
122 132
                         $sth = $this->db->prepare($query);
@@ -129,7 +139,9 @@  discard block
 block discarded – undo
129 139
         }
130 140
 
131 141
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
132
-		if ($filter_name == '') $filter_name = $this->filter_name;
142
+		if ($filter_name == '') {
143
+			$filter_name = $this->filter_name;
144
+		}
133 145
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
134 146
                  try {
135 147
                         $sth = $this->db->prepare($query);
@@ -142,7 +154,9 @@  discard block
 block discarded – undo
142 154
         }
143 155
 
144 156
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
145
-		if ($filter_name == '') $filter_name = $this->filter_name;
157
+		if ($filter_name == '') {
158
+			$filter_name = $this->filter_name;
159
+		}
146 160
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
147 161
                  try {
148 162
                         $sth = $this->db->prepare($query);
@@ -157,10 +171,15 @@  discard block
 block discarded – undo
157 171
 
158 172
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
159 173
 		global $globalStatsFilters;
160
-		if ($filter_name == '') $filter_name = $this->filter_name;
174
+		if ($filter_name == '') {
175
+			$filter_name = $this->filter_name;
176
+		}
161 177
 		if ($year == '' && $month == '') {
162
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
163
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
178
+			if ($limit) {
179
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
180
+			} else {
181
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
182
+			}
164 183
 			try {
165 184
 				$sth = $this->db->prepare($query);
166 185
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -168,7 +187,9 @@  discard block
 block discarded – undo
168 187
 				echo "error : ".$e->getMessage();
169 188
 			}
170 189
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
171
-		} else $all = array();
190
+		} else {
191
+			$all = array();
192
+		}
172 193
                 if (empty($all)) {
173 194
             	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174 195
             	    if ($filter_name != '') {
@@ -182,10 +203,15 @@  discard block
 block discarded – undo
182 203
 	}
183 204
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
184 205
 		global $globalStatsFilters;
185
-		if ($filter_name == '') $filter_name = $this->filter_name;
206
+		if ($filter_name == '') {
207
+			$filter_name = $this->filter_name;
208
+		}
186 209
 		if ($year == '' && $month == '') {
187
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
188
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			if ($limit) {
211
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
212
+			} else {
213
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
214
+			}
189 215
 			try {
190 216
 				$sth = $this->db->prepare($query);
191 217
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -193,7 +219,9 @@  discard block
 block discarded – undo
193 219
 				echo "error : ".$e->getMessage();
194 220
 			}
195 221
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
196
-		} else $all = array();
222
+		} else {
223
+			$all = array();
224
+		}
197 225
                 if (empty($all)) {
198 226
             		$Spotter = new Spotter($this->db);
199 227
             		$filters = array();
@@ -208,10 +236,15 @@  discard block
 block discarded – undo
208 236
 	}
209 237
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
210 238
 		global $globalStatsFilters;
211
-		if ($filter_name == '') $filter_name = $this->filter_name;
239
+		if ($filter_name == '') {
240
+			$filter_name = $this->filter_name;
241
+		}
212 242
 		if ($year == '' && $month == '') {
213
-			if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
214
-			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
243
+			if ($limit) {
244
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
245
+			} else {
246
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
247
+			}
215 248
 			try {
216 249
 				$sth = $this->db->prepare($query);
217 250
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -219,7 +252,9 @@  discard block
 block discarded – undo
219 252
 				echo "error : ".$e->getMessage();
220 253
 			}
221 254
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
222
-		} else $all = array();
255
+		} else {
256
+			$all = array();
257
+		}
223 258
 		if (empty($all)) {
224 259
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
225 260
 			if ($filter_name != '') {
@@ -234,10 +269,15 @@  discard block
 block discarded – undo
234 269
 
235 270
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
236 271
 		global $globalStatsFilters;
237
-		if ($filter_name == '') $filter_name = $this->filter_name;
272
+		if ($filter_name == '') {
273
+			$filter_name = $this->filter_name;
274
+		}
238 275
 		if ($year == '' && $month == '') {
239
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
240
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
276
+			if ($limit) {
277
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
278
+			} else {
279
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
280
+			}
241 281
 			try {
242 282
 				$sth = $this->db->prepare($query);
243 283
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -245,7 +285,9 @@  discard block
 block discarded – undo
245 285
 				echo "error : ".$e->getMessage();
246 286
 			}
247 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
248
-		} else $all = array();
288
+		} else {
289
+			$all = array();
290
+		}
249 291
                 if (empty($all)) {
250 292
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
251 293
 			if ($filter_name != '') {
@@ -259,9 +301,14 @@  discard block
 block discarded – undo
259 301
 	}
260 302
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
261 303
 		global $globalStatsFilters;
262
-		if ($filter_name == '') $filter_name = $this->filter_name;
263
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
264
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
304
+		if ($filter_name == '') {
305
+			$filter_name = $this->filter_name;
306
+		}
307
+		if ($limit) {
308
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
309
+		} else {
310
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
311
+		}
265 312
                  try {
266 313
                         $sth = $this->db->prepare($query);
267 314
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -283,17 +330,29 @@  discard block
 block discarded – undo
283 330
 
284 331
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
285 332
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
286
-		if ($filter_name == '') $filter_name = $this->filter_name;
333
+		if ($filter_name == '') {
334
+			$filter_name = $this->filter_name;
335
+		}
287 336
 		if ($year == '' && $month == '') {
288
-			if ($globalVATSIM) $forsource = 'vatsim';
289
-			if ($globalIVAO) $forsource = 'ivao';
337
+			if ($globalVATSIM) {
338
+				$forsource = 'vatsim';
339
+			}
340
+			if ($globalIVAO) {
341
+				$forsource = 'ivao';
342
+			}
290 343
 			if (isset($forsource)) {
291
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
292
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
344
+				if ($limit) {
345
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
346
+				} else {
347
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
348
+				}
293 349
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
294 350
 			} else {
295
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
296
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
351
+				if ($limit) {
352
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
353
+				} else {
354
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
355
+				}
297 356
 				$query_values = array(':filter_name' => $filter_name);
298 357
 			}
299 358
 			try {
@@ -303,7 +362,9 @@  discard block
 block discarded – undo
303 362
 				echo "error : ".$e->getMessage();
304 363
 			}
305 364
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
306
-		} else $all = array();
365
+		} else {
366
+			$all = array();
367
+		}
307 368
                 if (empty($all)) {
308 369
 	                $Spotter = new Spotter($this->db);
309 370
             		$filters = array();
@@ -318,10 +379,15 @@  discard block
 block discarded – undo
318 379
 	}
319 380
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
320 381
 		global $globalStatsFilters;
321
-		if ($filter_name == '') $filter_name = $this->filter_name;
382
+		if ($filter_name == '') {
383
+			$filter_name = $this->filter_name;
384
+		}
322 385
 		if ($year == '' && $month == '') {
323
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
324
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
386
+			if ($limit) {
387
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
388
+			} else {
389
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
390
+			}
325 391
 			try {
326 392
 				$sth = $this->db->prepare($query);
327 393
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -329,7 +395,9 @@  discard block
 block discarded – undo
329 395
 				echo "error : ".$e->getMessage();
330 396
 			}
331 397
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
332
-		} else $all = array();
398
+		} else {
399
+			$all = array();
400
+		}
333 401
                 if (empty($all)) {
334 402
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335 403
 			if ($filter_name != '') {
@@ -343,10 +411,15 @@  discard block
 block discarded – undo
343 411
 	}
344 412
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
345 413
 		global $globalStatsFilters;
346
-		if ($filter_name == '') $filter_name = $this->filter_name;
414
+		if ($filter_name == '') {
415
+			$filter_name = $this->filter_name;
416
+		}
347 417
 		if ($year == '' && $month == '') {
348
-			if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
349
-			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
418
+			if ($limit) {
419
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
420
+			} else {
421
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
422
+			}
350 423
 			 try {
351 424
 				$sth = $this->db->prepare($query);
352 425
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -354,7 +427,9 @@  discard block
 block discarded – undo
354 427
 				echo "error : ".$e->getMessage();
355 428
 			}
356 429
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
357
-		} else $all = array();
430
+		} else {
431
+			$all = array();
432
+		}
358 433
 		if (empty($all)) {
359 434
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360 435
 			if ($filter_name != '') {
@@ -368,11 +443,16 @@  discard block
 block discarded – undo
368 443
 	}
369 444
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
370 445
 		$Connection = new Connection();
371
-		if ($filter_name == '') $filter_name = $this->filter_name;
446
+		if ($filter_name == '') {
447
+			$filter_name = $this->filter_name;
448
+		}
372 449
 		if ($Connection->tableExists('countries')) {
373 450
 			if ($year == '' && $month == '') {
374
-				if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
375
-				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
451
+				if ($limit) {
452
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
453
+				} else {
454
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
455
+				}
376 456
 				 try {
377 457
 					$sth = $this->db->prepare($query);
378 458
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -387,17 +467,24 @@  discard block
 block discarded – undo
387 467
                 }
388 468
                 */
389 469
 				return $all;
390
-			} else return array();
470
+			} else {
471
+				return array();
472
+			}
391 473
 		} else {
392 474
 			return array();
393 475
 		}
394 476
 	}
395 477
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
396 478
 		global $globalStatsFilters;
397
-		if ($filter_name == '') $filter_name = $this->filter_name;
479
+		if ($filter_name == '') {
480
+			$filter_name = $this->filter_name;
481
+		}
398 482
 		if ($year == '' && $month == '') {
399
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
400
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
483
+			if ($limit) {
484
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
485
+			} else {
486
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
487
+			}
401 488
 			try {
402 489
 				$sth = $this->db->prepare($query);
403 490
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -405,7 +492,9 @@  discard block
 block discarded – undo
405 492
 				echo "error : ".$e->getMessage();
406 493
 			}
407 494
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
408
-		} else $all = array();
495
+		} else {
496
+			$all = array();
497
+		}
409 498
 		if (empty($all)) {
410 499
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
411 500
 			if ($filter_name != '') {
@@ -420,10 +509,15 @@  discard block
 block discarded – undo
420 509
 
421 510
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
422 511
 		global $globalStatsFilters;
423
-		if ($filter_name == '') $filter_name = $this->filter_name;
512
+		if ($filter_name == '') {
513
+			$filter_name = $this->filter_name;
514
+		}
424 515
 		if ($year == '' && $month == '') {
425
-			if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
426
-			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
516
+			if ($limit) {
517
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
518
+			} else {
519
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
520
+			}
427 521
 			try {
428 522
 				$sth = $this->db->prepare($query);
429 523
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -431,7 +525,9 @@  discard block
 block discarded – undo
431 525
 				echo "error : ".$e->getMessage();
432 526
 			}
433 527
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
528
+		} else {
529
+			$all = array();
530
+		}
435 531
                 if (empty($all)) {
436 532
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
437 533
 			if ($filter_name != '') {
@@ -445,10 +541,15 @@  discard block
 block discarded – undo
445 541
 	}
446 542
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447 543
 		global $globalStatsFilters;
448
-		if ($filter_name == '') $filter_name = $this->filter_name;
544
+		if ($filter_name == '') {
545
+			$filter_name = $this->filter_name;
546
+		}
449 547
 		if ($year == '' && $month == '') {
450
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
451
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
548
+			if ($limit) {
549
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
550
+			} else {
551
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
552
+			}
452 553
 			try {
453 554
 				$sth = $this->db->prepare($query);
454 555
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -456,7 +557,9 @@  discard block
 block discarded – undo
456 557
 				echo "error : ".$e->getMessage();
457 558
 			}
458 559
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		} else $all = array();
560
+		} else {
561
+			$all = array();
562
+		}
460 563
                 if (empty($all)) {
461 564
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
462 565
             		if ($filter_name != '') {
@@ -477,7 +580,9 @@  discard block
 block discarded – undo
477 580
         			$icao = $value['airport_departure_icao'];
478 581
         			if (isset($all[$icao])) {
479 582
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
480
-        			} else $all[$icao] = $value;
583
+        			} else {
584
+        				$all[$icao] = $value;
585
+        			}
481 586
         		}
482 587
         		$count = array();
483 588
         		foreach ($all as $key => $row) {
@@ -489,10 +594,15 @@  discard block
 block discarded – undo
489 594
 	}
490 595
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
491 596
 		global $globalStatsFilters;
492
-		if ($filter_name == '') $filter_name = $this->filter_name;
597
+		if ($filter_name == '') {
598
+			$filter_name = $this->filter_name;
599
+		}
493 600
 		if ($year == '' && $month == '') {
494
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
495
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
601
+			if ($limit) {
602
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
603
+			} else {
604
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
605
+			}
496 606
 			try {
497 607
 				$sth = $this->db->prepare($query);
498 608
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -500,7 +610,9 @@  discard block
 block discarded – undo
500 610
 				echo "error : ".$e->getMessage();
501 611
 			}
502 612
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503
-		} else $all = array();
613
+		} else {
614
+			$all = array();
615
+		}
504 616
 		if (empty($all)) {
505 617
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
506 618
 			if ($filter_name != '') {
@@ -521,7 +633,9 @@  discard block
 block discarded – undo
521 633
         			$icao = $value['airport_arrival_icao'];
522 634
         			if (isset($all[$icao])) {
523 635
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
524
-        			} else $all[$icao] = $value;
636
+        			} else {
637
+        				$all[$icao] = $value;
638
+        			}
525 639
         		}
526 640
         		$count = array();
527 641
         		foreach ($all as $key => $row) {
@@ -534,13 +648,21 @@  discard block
 block discarded – undo
534 648
 	}
535 649
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
536 650
 		global $globalDBdriver, $globalStatsFilters;
537
-		if ($filter_name == '') $filter_name = $this->filter_name;
651
+		if ($filter_name == '') {
652
+			$filter_name = $this->filter_name;
653
+		}
538 654
 		if ($globalDBdriver == 'mysql') {
539
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
540
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
655
+			if ($limit) {
656
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
657
+			} else {
658
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
659
+			}
541 660
 		} else {
542
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
543
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661
+			if ($limit) {
662
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
663
+			} else {
664
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
665
+			}
544 666
 		}
545 667
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
546 668
                  try {
@@ -564,7 +686,9 @@  discard block
 block discarded – undo
564 686
 	
565 687
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
566 688
 		global $globalStatsFilters;
567
-		if ($filter_name == '') $filter_name = $this->filter_name;
689
+		if ($filter_name == '') {
690
+			$filter_name = $this->filter_name;
691
+		}
568 692
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
569 693
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
570 694
                  try {
@@ -586,7 +710,9 @@  discard block
 block discarded – undo
586 710
 	}
587 711
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
588 712
 		global $globalDBdriver, $globalStatsFilters;
589
-		if ($filter_name == '') $filter_name = $this->filter_name;
713
+		if ($filter_name == '') {
714
+			$filter_name = $this->filter_name;
715
+		}
590 716
 		if ($globalDBdriver == 'mysql') {
591 717
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
592 718
 		} else {
@@ -612,7 +738,9 @@  discard block
 block discarded – undo
612 738
 	}
613 739
 	public function countAllDates($stats_airline = '',$filter_name = '') {
614 740
 		global $globalStatsFilters;
615
-		if ($filter_name == '') $filter_name = $this->filter_name;
741
+		if ($filter_name == '') {
742
+			$filter_name = $this->filter_name;
743
+		}
616 744
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
617 745
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
618 746
                  try {
@@ -634,7 +762,9 @@  discard block
 block discarded – undo
634 762
 	}
635 763
 	public function countAllDatesByAirlines($filter_name = '') {
636 764
 		global $globalStatsFilters;
637
-		if ($filter_name == '') $filter_name = $this->filter_name;
765
+		if ($filter_name == '') {
766
+			$filter_name = $this->filter_name;
767
+		}
638 768
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
639 769
 		$query_data = array('filter_name' => $filter_name);
640 770
                  try {
@@ -656,7 +786,9 @@  discard block
 block discarded – undo
656 786
 	}
657 787
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
658 788
 		global $globalStatsFilters;
659
-		if ($filter_name == '') $filter_name = $this->filter_name;
789
+		if ($filter_name == '') {
790
+			$filter_name = $this->filter_name;
791
+		}
660 792
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661 793
                  try {
662 794
                         $sth = $this->db->prepare($query);
@@ -679,7 +811,9 @@  discard block
 block discarded – undo
679 811
 	}
680 812
 	public function countAllMilitaryMonths($filter_name = '') {
681 813
 		global $globalStatsFilters;
682
-		if ($filter_name == '') $filter_name = $this->filter_name;
814
+		if ($filter_name == '') {
815
+			$filter_name = $this->filter_name;
816
+		}
683 817
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
684 818
                  try {
685 819
                         $sth = $this->db->prepare($query);
@@ -700,9 +834,14 @@  discard block
 block discarded – undo
700 834
 	}
701 835
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
702 836
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
703
-		if ($filter_name == '') $filter_name = $this->filter_name;
704
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
705
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
837
+		if ($filter_name == '') {
838
+			$filter_name = $this->filter_name;
839
+		}
840
+		if ($limit) {
841
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
842
+		} else {
843
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
844
+		}
706 845
 		if ($orderby == 'hour') {
707 846
 			/*
708 847
 			if ($globalDBdriver == 'mysql') {
@@ -711,7 +850,9 @@  discard block
 block discarded – undo
711 850
 			*/
712 851
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
713 852
 		}
714
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
853
+		if ($orderby == 'count') {
854
+			$query .= " ORDER BY hour_count DESC";
855
+		}
715 856
                  try {
716 857
                         $sth = $this->db->prepare($query);
717 858
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -732,8 +873,12 @@  discard block
 block discarded – undo
732 873
 	
733 874
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
734 875
 		global $globalStatsFilters;
735
-		if ($filter_name == '') $filter_name = $this->filter_name;
736
-		if ($year == '') $year = date('Y');
876
+		if ($filter_name == '') {
877
+			$filter_name = $this->filter_name;
878
+		}
879
+		if ($year == '') {
880
+			$year = date('Y');
881
+		}
737 882
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
738 883
 		if (empty($all)) {
739 884
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -748,8 +893,12 @@  discard block
 block discarded – undo
748 893
 	}
749 894
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
750 895
 		global $globalStatsFilters;
751
-		if ($filter_name == '') $filter_name = $this->filter_name;
752
-		if ($year == '') $year = date('Y');
896
+		if ($filter_name == '') {
897
+			$filter_name = $this->filter_name;
898
+		}
899
+		if ($year == '') {
900
+			$year = date('Y');
901
+		}
753 902
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
754 903
 		if (empty($all)) {
755 904
 		        $filters = array();
@@ -765,8 +914,12 @@  discard block
 block discarded – undo
765 914
 	}
766 915
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
767 916
 		global $globalStatsFilters;
768
-		if ($filter_name == '') $filter_name = $this->filter_name;
769
-		if ($year == '') $year = date('Y');
917
+		if ($filter_name == '') {
918
+			$filter_name = $this->filter_name;
919
+		}
920
+		if ($year == '') {
921
+			$year = date('Y');
922
+		}
770 923
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
771 924
 		if (empty($all)) {
772 925
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -781,7 +934,9 @@  discard block
 block discarded – undo
781 934
 	}
782 935
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
783 936
 		global $globalStatsFilters;
784
-		if ($filter_name == '') $filter_name = $this->filter_name;
937
+		if ($filter_name == '') {
938
+			$filter_name = $this->filter_name;
939
+		}
785 940
 		if ($year == '' && $month == '') {
786 941
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
787 942
 			try {
@@ -792,7 +947,9 @@  discard block
 block discarded – undo
792 947
 			}
793 948
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
794 949
 			$all = $result[0]['nb'];
795
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
950
+		} else {
951
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
952
+		}
796 953
 		if (empty($all)) {
797 954
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
798 955
 			if ($filter_name != '') {
@@ -806,7 +963,9 @@  discard block
 block discarded – undo
806 963
 	}
807 964
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
808 965
 		global $globalStatsFilters;
809
-		if ($filter_name == '') $filter_name = $this->filter_name;
966
+		if ($filter_name == '') {
967
+			$filter_name = $this->filter_name;
968
+		}
810 969
 		if ($year == '' && $month == '') {
811 970
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
812 971
 			try {
@@ -817,7 +976,9 @@  discard block
 block discarded – undo
817 976
 			}
818 977
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
819 978
 			$all = $result[0]['nb_airline'];
820
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
979
+		} else {
980
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
981
+		}
821 982
 		if (empty($all)) {
822 983
             		$filters = array();
823 984
 			$filters = array('year' => $year,'month' => $month);
@@ -832,7 +993,9 @@  discard block
 block discarded – undo
832 993
 	}
833 994
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
834 995
 		global $globalStatsFilters;
835
-		if ($filter_name == '') $filter_name = $this->filter_name;
996
+		if ($filter_name == '') {
997
+			$filter_name = $this->filter_name;
998
+		}
836 999
 		if ($year == '' && $month == '') {
837 1000
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
838 1001
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -860,7 +1023,9 @@  discard block
 block discarded – undo
860 1023
 	}
861 1024
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
862 1025
 		global $globalStatsFilters;
863
-		if ($filter_name == '') $filter_name = $this->filter_name;
1026
+		if ($filter_name == '') {
1027
+			$filter_name = $this->filter_name;
1028
+		}
864 1029
 		//if ($year == '') $year = date('Y');
865 1030
 		if ($year == '' && $month == '') {
866 1031
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -889,7 +1054,9 @@  discard block
 block discarded – undo
889 1054
 	}
890 1055
 
891 1056
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
892
-		if ($filter_name == '') $filter_name = $this->filter_name;
1057
+		if ($filter_name == '') {
1058
+			$filter_name = $this->filter_name;
1059
+		}
893 1060
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
894 1061
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
895 1062
                  try {
@@ -902,7 +1069,9 @@  discard block
 block discarded – undo
902 1069
                 return $all;
903 1070
 	}
904 1071
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1072
+		if ($filter_name == '') {
1073
+			$filter_name = $this->filter_name;
1074
+		}
906 1075
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
907 1076
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
908 1077
                  try {
@@ -915,7 +1084,9 @@  discard block
 block discarded – undo
915 1084
                 return $all;
916 1085
         }
917 1086
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
918
-		if ($filter_name == '') $filter_name = $this->filter_name;
1087
+		if ($filter_name == '') {
1088
+			$filter_name = $this->filter_name;
1089
+		}
919 1090
     		global $globalArchiveMonths, $globalDBdriver;
920 1091
     		if ($globalDBdriver == 'mysql') {
921 1092
     			if ($month == '') {
@@ -945,7 +1116,9 @@  discard block
 block discarded – undo
945 1116
         }
946 1117
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
947 1118
     		global $globalArchiveMonths, $globalDBdriver;
948
-		if ($filter_name == '') $filter_name = $this->filter_name;
1119
+		if ($filter_name == '') {
1120
+			$filter_name = $this->filter_name;
1121
+		}
949 1122
     		if ($globalDBdriver == 'mysql') {
950 1123
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
951 1124
 		} else {
@@ -963,7 +1136,9 @@  discard block
 block discarded – undo
963 1136
         }
964 1137
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
965 1138
     		global $globalArchiveMonths, $globalDBdriver;
966
-		if ($filter_name == '') $filter_name = $this->filter_name;
1139
+		if ($filter_name == '') {
1140
+			$filter_name = $this->filter_name;
1141
+		}
967 1142
     		if ($globalDBdriver == 'mysql') {
968 1143
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
969 1144
                 } else {
@@ -980,7 +1155,9 @@  discard block
 block discarded – undo
980 1155
         }
981 1156
 	public function getStatsAirlineTotal($filter_name = '') {
982 1157
     		global $globalArchiveMonths, $globalDBdriver;
983
-		if ($filter_name == '') $filter_name = $this->filter_name;
1158
+		if ($filter_name == '') {
1159
+			$filter_name = $this->filter_name;
1160
+		}
984 1161
     		if ($globalDBdriver == 'mysql') {
985 1162
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
986 1163
                 } else {
@@ -997,7 +1174,9 @@  discard block
 block discarded – undo
997 1174
         }
998 1175
 	public function getStatsOwnerTotal($filter_name = '') {
999 1176
     		global $globalArchiveMonths, $globalDBdriver;
1000
-		if ($filter_name == '') $filter_name = $this->filter_name;
1177
+		if ($filter_name == '') {
1178
+			$filter_name = $this->filter_name;
1179
+		}
1001 1180
     		if ($globalDBdriver == 'mysql') {
1002 1181
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1003 1182
 		} else {
@@ -1014,7 +1193,9 @@  discard block
 block discarded – undo
1014 1193
         }
1015 1194
 	public function getStatsOwner($owner_name,$filter_name = '') {
1016 1195
     		global $globalArchiveMonths, $globalDBdriver;
1017
-		if ($filter_name == '') $filter_name = $this->filter_name;
1196
+		if ($filter_name == '') {
1197
+			$filter_name = $this->filter_name;
1198
+		}
1018 1199
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1019 1200
                  try {
1020 1201
                         $sth = $this->db->prepare($query);
@@ -1023,12 +1204,17 @@  discard block
 block discarded – undo
1023 1204
                         echo "error : ".$e->getMessage();
1024 1205
                 }
1025 1206
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1026
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1027
-                else return 0;
1207
+                if (isset($all[0]['cnt'])) {
1208
+                	return $all[0]['cnt'];
1209
+                } else {
1210
+                	return 0;
1211
+                }
1028 1212
         }
1029 1213
 	public function getStatsPilotTotal($filter_name = '') {
1030 1214
     		global $globalArchiveMonths, $globalDBdriver;
1031
-		if ($filter_name == '') $filter_name = $this->filter_name;
1215
+		if ($filter_name == '') {
1216
+			$filter_name = $this->filter_name;
1217
+		}
1032 1218
     		if ($globalDBdriver == 'mysql') {
1033 1219
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1034 1220
             	} else {
@@ -1045,7 +1231,9 @@  discard block
 block discarded – undo
1045 1231
         }
1046 1232
 	public function getStatsPilot($pilot,$filter_name = '') {
1047 1233
     		global $globalArchiveMonths, $globalDBdriver;
1048
-		if ($filter_name == '') $filter_name = $this->filter_name;
1234
+		if ($filter_name == '') {
1235
+			$filter_name = $this->filter_name;
1236
+		}
1049 1237
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1050 1238
                  try {
1051 1239
                         $sth = $this->db->prepare($query);
@@ -1054,13 +1242,18 @@  discard block
 block discarded – undo
1054 1242
                         echo "error : ".$e->getMessage();
1055 1243
                 }
1056 1244
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1057
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1058
-                else return 0;
1245
+                if (isset($all[0]['cnt'])) {
1246
+                	return $all[0]['cnt'];
1247
+                } else {
1248
+                	return 0;
1249
+                }
1059 1250
         }
1060 1251
 
1061 1252
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1062 1253
 		global $globalDBdriver;
1063
-		if ($filter_name == '') $filter_name = $this->filter_name;
1254
+		if ($filter_name == '') {
1255
+			$filter_name = $this->filter_name;
1256
+		}
1064 1257
 		if ($globalDBdriver == 'mysql') {
1065 1258
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1066 1259
                 } else {
@@ -1076,7 +1269,9 @@  discard block
 block discarded – undo
1076 1269
         }
1077 1270
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1078 1271
 		global $globalDBdriver;
1079
-		if ($filter_name == '') $filter_name = $this->filter_name;
1272
+		if ($filter_name == '') {
1273
+			$filter_name = $this->filter_name;
1274
+		}
1080 1275
 		if ($globalDBdriver == 'mysql') {
1081 1276
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1082 1277
 		} else {
@@ -1462,10 +1657,14 @@  discard block
 block discarded – undo
1462 1657
     		$Connection = new Connection();
1463 1658
     		date_default_timezone_set('UTC');
1464 1659
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1465
-			if ($globalDebug) echo 'Update stats !'."\n";
1660
+			if ($globalDebug) {
1661
+				echo 'Update stats !'."\n";
1662
+			}
1466 1663
 			if (isset($last_update[0]['value'])) {
1467 1664
 				$last_update_day = $last_update[0]['value'];
1468
-			} else $last_update_day = '2012-12-12 12:12:12';
1665
+			} else {
1666
+				$last_update_day = '2012-12-12 12:12:12';
1667
+			}
1469 1668
 			$reset = false;
1470 1669
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
1471 1670
 			if ($globalStatsResetYear) {
@@ -1474,42 +1673,60 @@  discard block
 block discarded – undo
1474 1673
 			}
1475 1674
 			$Spotter = new Spotter($this->db);
1476 1675
 
1477
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1676
+			if ($globalDebug) {
1677
+				echo 'Count all aircraft types...'."\n";
1678
+			}
1478 1679
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1479 1680
 			foreach ($alldata as $number) {
1480 1681
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1481 1682
 			}
1482
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1683
+			if ($globalDebug) {
1684
+				echo 'Count all airlines...'."\n";
1685
+			}
1483 1686
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1484 1687
 			foreach ($alldata as $number) {
1485 1688
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1486 1689
 			}
1487
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1690
+			if ($globalDebug) {
1691
+				echo 'Count all registrations...'."\n";
1692
+			}
1488 1693
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1489 1694
 			foreach ($alldata as $number) {
1490 1695
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1491 1696
 			}
1492
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1697
+			if ($globalDebug) {
1698
+				echo 'Count all callsigns...'."\n";
1699
+			}
1493 1700
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1494 1701
 			foreach ($alldata as $number) {
1495 1702
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1496 1703
 			}
1497
-			if ($globalDebug) echo 'Count all owners...'."\n";
1704
+			if ($globalDebug) {
1705
+				echo 'Count all owners...'."\n";
1706
+			}
1498 1707
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1499 1708
 			foreach ($alldata as $number) {
1500 1709
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1501 1710
 			}
1502
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1711
+			if ($globalDebug) {
1712
+				echo 'Count all pilots...'."\n";
1713
+			}
1503 1714
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1504 1715
 			foreach ($alldata as $number) {
1505 1716
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1506 1717
 			}
1507 1718
 			
1508
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1719
+			if ($globalDebug) {
1720
+				echo 'Count all departure airports...'."\n";
1721
+			}
1509 1722
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1510
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1723
+			if ($globalDebug) {
1724
+				echo 'Count all detected departure airports...'."\n";
1725
+			}
1511 1726
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1512
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1727
+			if ($globalDebug) {
1728
+				echo 'Order departure airports...'."\n";
1729
+			}
1513 1730
 	        	$alldata = array();
1514 1731
 	        	
1515 1732
     			foreach ($pall as $value) {
@@ -1520,7 +1737,9 @@  discard block
 block discarded – undo
1520 1737
     				$icao = $value['airport_departure_icao'];
1521 1738
         			if (isset($alldata[$icao])) {
1522 1739
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1523
-        			} else $alldata[$icao] = $value;
1740
+        			} else {
1741
+        				$alldata[$icao] = $value;
1742
+        			}
1524 1743
 			}
1525 1744
     			$count = array();
1526 1745
     			foreach ($alldata as $key => $row) {
@@ -1530,11 +1749,17 @@  discard block
 block discarded – undo
1530 1749
 			foreach ($alldata as $number) {
1531 1750
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1532 1751
 			}
1533
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1752
+			if ($globalDebug) {
1753
+				echo 'Count all arrival airports...'."\n";
1754
+			}
1534 1755
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1535
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1756
+			if ($globalDebug) {
1757
+				echo 'Count all detected arrival airports...'."\n";
1758
+			}
1536 1759
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1537
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1760
+			if ($globalDebug) {
1761
+				echo 'Order arrival airports...'."\n";
1762
+			}
1538 1763
 	        	$alldata = array();
1539 1764
     			foreach ($pall as $value) {
1540 1765
 	        		$icao = $value['airport_arrival_icao'];
@@ -1544,7 +1769,9 @@  discard block
 block discarded – undo
1544 1769
     				$icao = $value['airport_arrival_icao'];
1545 1770
         			if (isset($alldata[$icao])) {
1546 1771
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1547
-	        		} else $alldata[$icao] = $value;
1772
+	        		} else {
1773
+	        			$alldata[$icao] = $value;
1774
+	        		}
1548 1775
     			}
1549 1776
         		$count = array();
1550 1777
         		foreach ($alldata as $key => $row) {
@@ -1555,7 +1782,9 @@  discard block
 block discarded – undo
1555 1782
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1556 1783
 			}
1557 1784
 			if ($Connection->tableExists('countries')) {
1558
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1785
+				if ($globalDebug) {
1786
+					echo 'Count all flights by countries...'."\n";
1787
+				}
1559 1788
 				$SpotterArchive = new SpotterArchive();
1560 1789
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1561 1790
 				foreach ($alldata as $number) {
@@ -1567,46 +1796,66 @@  discard block
 block discarded – undo
1567 1796
 			// Add by month using getstat if month finish...
1568 1797
 
1569 1798
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1570
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1799
+			if ($globalDebug) {
1800
+				echo 'Count all flights by months...'."\n";
1801
+			}
1571 1802
 			$Spotter = new Spotter($this->db);
1572 1803
 			$alldata = $Spotter->countAllMonths();
1573 1804
 			$lastyear = false;
1574 1805
 			foreach ($alldata as $number) {
1575
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1806
+				if ($number['year_name'] != date('Y')) {
1807
+					$lastyear = true;
1808
+				}
1576 1809
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1577 1810
 			}
1578
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1811
+			if ($globalDebug) {
1812
+				echo 'Count all military flights by months...'."\n";
1813
+			}
1579 1814
 			$alldata = $Spotter->countAllMilitaryMonths();
1580 1815
 			foreach ($alldata as $number) {
1581 1816
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1582 1817
 			}
1583
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1818
+			if ($globalDebug) {
1819
+				echo 'Count all owners by months...'."\n";
1820
+			}
1584 1821
 			$alldata = $Spotter->countAllMonthsOwners();
1585 1822
 			foreach ($alldata as $number) {
1586 1823
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1587 1824
 			}
1588
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1825
+			if ($globalDebug) {
1826
+				echo 'Count all pilots by months...'."\n";
1827
+			}
1589 1828
 			$alldata = $Spotter->countAllMonthsPilots();
1590 1829
 			foreach ($alldata as $number) {
1591 1830
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1592 1831
 			}
1593
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1832
+			if ($globalDebug) {
1833
+				echo 'Count all airlines by months...'."\n";
1834
+			}
1594 1835
 			$alldata = $Spotter->countAllMonthsAirlines();
1595 1836
 			foreach ($alldata as $number) {
1596 1837
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1597 1838
 			}
1598
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1839
+			if ($globalDebug) {
1840
+				echo 'Count all aircrafts by months...'."\n";
1841
+			}
1599 1842
 			$alldata = $Spotter->countAllMonthsAircrafts();
1600 1843
 			foreach ($alldata as $number) {
1601 1844
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1602 1845
 			}
1603
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1846
+			if ($globalDebug) {
1847
+				echo 'Count all real arrivals by months...'."\n";
1848
+			}
1604 1849
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1605 1850
 			foreach ($alldata as $number) {
1606 1851
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1607 1852
 			}
1608
-			if ($globalDebug) echo 'Airports data...'."\n";
1609
-			if ($globalDebug) echo '...Departure'."\n";
1853
+			if ($globalDebug) {
1854
+				echo 'Airports data...'."\n";
1855
+			}
1856
+			if ($globalDebug) {
1857
+				echo '...Departure'."\n";
1858
+			}
1610 1859
 			$this->deleteStatAirport('daily');
1611 1860
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1612 1861
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1727,44 +1976,62 @@  discard block
 block discarded – undo
1727 1976
 			// Count by airlines
1728 1977
 			echo '--- Stats by airlines ---'."\n";
1729 1978
 			if ($Connection->tableExists('countries')) {
1730
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1979
+				if ($globalDebug) {
1980
+					echo 'Count all flights by countries by airlines...'."\n";
1981
+				}
1731 1982
 				$SpotterArchive = new SpotterArchive();
1732 1983
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1733 1984
 				foreach ($alldata as $number) {
1734 1985
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1735 1986
 				}
1736 1987
 			}
1737
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Count all aircraft types by airlines...'."\n";
1990
+			}
1738 1991
 			$Spotter = new Spotter($this->db);
1739 1992
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1740 1993
 			foreach ($alldata as $number) {
1741 1994
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1742 1995
 			}
1743
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1996
+			if ($globalDebug) {
1997
+				echo 'Count all aircraft registrations by airlines...'."\n";
1998
+			}
1744 1999
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1745 2000
 			foreach ($alldata as $number) {
1746 2001
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1747 2002
 			}
1748
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2003
+			if ($globalDebug) {
2004
+				echo 'Count all callsigns by airlines...'."\n";
2005
+			}
1749 2006
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1750 2007
 			foreach ($alldata as $number) {
1751 2008
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1752 2009
 			}
1753
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2010
+			if ($globalDebug) {
2011
+				echo 'Count all owners by airlines...'."\n";
2012
+			}
1754 2013
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1755 2014
 			foreach ($alldata as $number) {
1756 2015
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1757 2016
 			}
1758
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2017
+			if ($globalDebug) {
2018
+				echo 'Count all pilots by airlines...'."\n";
2019
+			}
1759 2020
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1760 2021
 			foreach ($alldata as $number) {
1761 2022
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1762 2023
 			}
1763
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2024
+			if ($globalDebug) {
2025
+				echo 'Count all departure airports by airlines...'."\n";
2026
+			}
1764 2027
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1765
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2028
+			if ($globalDebug) {
2029
+				echo 'Count all detected departure airports by airlines...'."\n";
2030
+			}
1766 2031
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1767
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2032
+			if ($globalDebug) {
2033
+				echo 'Order detected departure airports by airlines...'."\n";
2034
+			}
1768 2035
 	        	//$alldata = array();
1769 2036
     			foreach ($dall as $value) {
1770 2037
     				$icao = $value['airport_departure_icao'];
@@ -1785,11 +2052,17 @@  discard block
 block discarded – undo
1785 2052
 			foreach ($alldata as $number) {
1786 2053
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1787 2054
 			}
1788
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2055
+			if ($globalDebug) {
2056
+				echo 'Count all arrival airports by airlines...'."\n";
2057
+			}
1789 2058
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1790
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2059
+			if ($globalDebug) {
2060
+				echo 'Count all detected arrival airports by airlines...'."\n";
2061
+			}
1791 2062
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1792
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2063
+			if ($globalDebug) {
2064
+				echo 'Order arrival airports by airlines...'."\n";
2065
+			}
1793 2066
 	        	//$alldata = array();
1794 2067
     			foreach ($dall as $value) {
1795 2068
     				$icao = $value['airport_arrival_icao'];
@@ -1808,37 +2081,53 @@  discard block
 block discarded – undo
1808 2081
     			}
1809 2082
     			$alldata = $pall;
1810 2083
                         foreach ($alldata as $number) {
1811
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2084
+				if ($number['airline_icao'] != '') {
2085
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2086
+				}
2087
+			}
2088
+			if ($globalDebug) {
2089
+				echo 'Count all flights by months by airlines...'."\n";
1812 2090
 			}
1813
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1814 2091
 			$Spotter = new Spotter($this->db);
1815 2092
 			$alldata = $Spotter->countAllMonthsByAirlines();
1816 2093
 			$lastyear = false;
1817 2094
 			foreach ($alldata as $number) {
1818
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2095
+				if ($number['year_name'] != date('Y')) {
2096
+					$lastyear = true;
2097
+				}
1819 2098
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1820 2099
 			}
1821
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2100
+			if ($globalDebug) {
2101
+				echo 'Count all owners by months by airlines...'."\n";
2102
+			}
1822 2103
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1823 2104
 			foreach ($alldata as $number) {
1824 2105
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1825 2106
 			}
1826
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2107
+			if ($globalDebug) {
2108
+				echo 'Count all pilots by months by airlines...'."\n";
2109
+			}
1827 2110
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1828 2111
 			foreach ($alldata as $number) {
1829 2112
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1830 2113
 			}
1831
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2114
+			if ($globalDebug) {
2115
+				echo 'Count all aircrafts by months by airlines...'."\n";
2116
+			}
1832 2117
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1833 2118
 			foreach ($alldata as $number) {
1834 2119
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1835 2120
 			}
1836
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2121
+			if ($globalDebug) {
2122
+				echo 'Count all real arrivals by months by airlines...'."\n";
2123
+			}
1837 2124
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1838 2125
 			foreach ($alldata as $number) {
1839 2126
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1840 2127
 			}
1841
-			if ($globalDebug) echo '...Departure'."\n";
2128
+			if ($globalDebug) {
2129
+				echo '...Departure'."\n";
2130
+			}
1842 2131
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1843 2132
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1844 2133
     			foreach ($dall as $value) {
@@ -1861,7 +2150,9 @@  discard block
 block discarded – undo
1861 2150
 			foreach ($alldata as $number) {
1862 2151
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1863 2152
 			}
1864
-			if ($globalDebug) echo '...Arrival'."\n";
2153
+			if ($globalDebug) {
2154
+				echo '...Arrival'."\n";
2155
+			}
1865 2156
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1866 2157
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1867 2158
     			foreach ($dall as $value) {
@@ -1885,13 +2176,19 @@  discard block
 block discarded – undo
1885 2176
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1886 2177
 			}
1887 2178
 
1888
-			if ($globalDebug) echo 'Flights data...'."\n";
1889
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2179
+			if ($globalDebug) {
2180
+				echo 'Flights data...'."\n";
2181
+			}
2182
+			if ($globalDebug) {
2183
+				echo '-> countAllDatesLastMonth...'."\n";
2184
+			}
1890 2185
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1891 2186
 			foreach ($alldata as $number) {
1892 2187
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1893 2188
 			}
1894
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2189
+			if ($globalDebug) {
2190
+				echo '-> countAllDates...'."\n";
2191
+			}
1895 2192
 			//$previousdata = $this->countAllDatesByAirlines();
1896 2193
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1897 2194
 			$values = array();
@@ -1904,7 +2201,9 @@  discard block
 block discarded – undo
1904 2201
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1905 2202
 			}
1906 2203
 			
1907
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2204
+			if ($globalDebug) {
2205
+				echo '-> countAllHours...'."\n";
2206
+			}
1908 2207
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1909 2208
 			foreach ($alldata as $number) {
1910 2209
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1912,7 +2211,9 @@  discard block
 block discarded – undo
1912 2211
 			
1913 2212
 
1914 2213
 			// Stats by filters
1915
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2214
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2215
+				$globalStatsFilters = array();
2216
+			}
1916 2217
 			foreach ($globalStatsFilters as $name => $filter) {
1917 2218
 				//$filter_name = $filter['name'];
1918 2219
 				$filter_name = $name;
@@ -1936,7 +2237,9 @@  discard block
 block discarded – undo
1936 2237
 				
1937 2238
 
1938 2239
 				// Count by filter
1939
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2240
+				if ($globalDebug) {
2241
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2242
+				}
1940 2243
 				$Spotter = new Spotter($this->db);
1941 2244
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1942 2245
 				foreach ($alldata as $number) {
@@ -1973,7 +2276,9 @@  discard block
 block discarded – undo
1973 2276
 	    				$icao = $value['airport_departure_icao'];
1974 2277
         				if (isset($alldata[$icao])) {
1975 2278
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1976
-        				} else $alldata[$icao] = $value;
2279
+        				} else {
2280
+        					$alldata[$icao] = $value;
2281
+        				}
1977 2282
 				}
1978 2283
 	    			$count = array();
1979 2284
     				foreach ($alldata as $key => $row) {
@@ -1994,7 +2299,9 @@  discard block
 block discarded – undo
1994 2299
 	    				$icao = $value['airport_arrival_icao'];
1995 2300
         				if (isset($alldata[$icao])) {
1996 2301
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1997
-		        		} else $alldata[$icao] = $value;
2302
+		        		} else {
2303
+		        			$alldata[$icao] = $value;
2304
+		        		}
1998 2305
 	    			}
1999 2306
         			$count = array();
2000 2307
         			foreach ($alldata as $key => $row) {
@@ -2008,7 +2315,9 @@  discard block
 block discarded – undo
2008 2315
 				$alldata = $Spotter->countAllMonths($filter);
2009 2316
 				$lastyear = false;
2010 2317
 				foreach ($alldata as $number) {
2011
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2318
+					if ($number['year_name'] != date('Y')) {
2319
+						$lastyear = true;
2320
+					}
2012 2321
 					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2013 2322
 				}
2014 2323
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.